Skip to content

Instantly share code, notes, and snippets.

View samjarman's full-sized avatar

Sam Jarman samjarman

View GitHub Profile
# Adapted From: https://github.com/puppeteer/puppeteer/blob/main/docker/Dockerfile
# Worked with V15
FROM node:18.12.0-slim
# FROM ghcr.io/puppeteer/puppeteer:16.1.0
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
# installs, work.
RUN apt-get update \
@samjarman
samjarman / XcodeAlias.zshrc
Created October 12, 2020 21:12
An zsh alias to open xcode project from current dir, similar to "code ." when using vs code
alias xc="open *.xcworkspace || open *.xcodeproj"
$curl http://pokeapi.co/api/v2/pokemon/?limit=3
// Models...
struct PokemonListResult: Codable {
let count: Int?
let previous: URL?
let results: [PokemonIndex]?
let next: URL?
}
@samjarman
samjarman / force_kill.m
Created July 31, 2017 03:13
Force kill iOS app programmatically
@interface UIApplication(InternalAppAdditions)
- (void)terminateWithSuccess;
@end
#warning: This is private API. Do not try to submit this line to TestFlight or the App Store.
[[UIApplication sharedApplication] terminateWithSuccess];
@samjarman
samjarman / scone-puns.py
Created July 15, 2017 22:07
Looks at a unix systems dictionary for words starting with 'con' and adds 's' to them, making a scone pun. How sconvenient!
words = '/usr/share/dict/words'
with open(words, encoding="utf-8") as file:
my_list = file.readlines()
my_list = [x.strip() for x in my_list]
for rows in my_list:
if rows[0:3] == 'con':
print("s"+rows)
@samjarman
samjarman / messaging.js
Created February 19, 2017 06:10
Example of basic JS messaging for Chrome extensions
// In the extension JS
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { // Fetch the current tab
chrome.tabs.sendMessage(tabs[0].id, {message: "preach", preachText: usrMessage});
});
// In the context script
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.message == "preach"){ // Filter out other messages
alert(request.preachText, 5000);
@samjarman
samjarman / manifest.js
Last active February 19, 2017 06:20
Chrome Manfiest for content scripts
"content_scripts": [
{
"matches": [
"*://*/*" //Run on every page
],
"js": [
"content-script.js"
],
"run_at": "document_end"
}
@samjarman
samjarman / CustomUserAgent.java
Created September 15, 2016 21:42
This lets you set a custom user agent.
package com.carnivalmobile.webviewhack;
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import android.webkit.WebView;
import com.carnival.sdk.MessageActivity;
public class UserAgentHack implements Application.ActivityLifecycleCallbacks {
@samjarman
samjarman / master_and_worker.ex
Created June 6, 2016 02:49
A simple master/worker implementation in elixir without using the built in supervisors
def master do
IO.puts "Beginning"
parent = self
spawn(fn -> worker(parent) end)
master_listener
end
def master_listener do
IO.puts "listening"
parent = self
@samjarman
samjarman / pmap.ex
Last active June 6, 2016 02:47
Returns a new list with the function applied to the list supplied
@doc """
This returns a new list with the function applied to the list supplied.
Examples:
iex> Misc.pmap([1,2,3,4], fn(n) -> n * n end)
[1,4,9,16]
iex> Misc.pmap([1,2,3,4], fn(n) -> n + 1 end)
[2,3,4,5]
"""