Skip to content

Instantly share code, notes, and snippets.

View sillygwailo's full-sized avatar
💭
Looking for collaborators.

Richard Eriksson sillygwailo

💭
Looking for collaborators.
View GitHub Profile
@sillygwailo
sillygwailo / random-instapaper.js
Last active August 27, 2023 18:47
Random Instapaper Article Bookmarklet
// based on http://avoidtheinevitable.wordpress.com/2013/01/21/instapaper-random-article-bookmarklet/ updated to
// Instapaper's latest design. This only picks a random article from the first page of Instapaper items
javascript:var l=document.querySelectorAll(".article_item .article_inner_item .host a");l[Math.floor(1+Math.random()*l.length)].click();
@sillygwailo
sillygwailo / bash.sh
Last active July 16, 2023 23:09
Beer in my terminal prompt on Fridays
# The following code goes in your ~/.profile
#
# This propmpt shows a beer when you launch a Terminal window on a Fridays.
# It checks every time you get a new prompt. A minute after 11:59M on a
# Thursday, if you press enter, it will add beer to the prompt. A minute
# after 11:59 PM on a Friday, no more beer.
#
# This is for terminals that use the Bash shell, which was the default for
# MacOS previous to Catalina.
@sillygwailo
sillygwailo / extract-ios-wallpaper.md
Last active April 24, 2023 14:31
Extract your iOS wallpaper if the image is not in your Camera Roll
  1. Backup your iOS device to your computer (not iCloud) through iTunes
  2. Download iPhone / iPod Touch Backup Extractor from http://supercrazyawesome.com/
  3. Run the app, and click "Read Backups"
  4. Find the backup you just made
  5. Make an empty directory
  6. Scroll all the way down and highlight "iOS Files"
  7. Extract the iOS files to the directory you made
  8. Visit https://www.dcode.fr/cpbitmap-format
  9. Click "Choose File"
  10. Inside the directory you created, find the iOS Files/Library/Springboard directory.
#! /bin/bash
# Enter a time using 24H. 1:30pm is 13:30 .
ENTERTIME="%filltext:name=Time (in 24H)%"
# See https://gist.github.com/palaniraja/f8e21e8c66eac7e1b313 for a
# list of time zone names.
T1=$(TZ="America/New_York" date -jf "%H:%M %z" "$ENTERTIME $(date "+%z")" "+%-I:%M %p %Z" | tr -s '[:lower:]' '[:upper:]')
@sillygwailo
sillygwailo / goodreads-bookmarklet.js
Last active January 22, 2022 18:31 — forked from lightningdb/goodreads-bookmarklet.js
Add to Goodreads from Amazon.com book page bookmarklet
javascript: var asin_elements, asin;
asin_elements = document.getElementsByName('ASIN');
if (asin_elements.length == 0) {
asin_elements = document.getElementsByName('ASIN.0');
};
if (asin_elements.length == 0) {
alert('Sorry, this doesn\'t appear to be an Amazon book page.');
} else {
asin = asin_elements[0].value;
if (asin.match(/\D/) === null) {
@sillygwailo
sillygwailo / Open in Chrome from Safari.scpt
Created September 23, 2011 07:16
Open in Chrome from Safari and vice versa
-- from http://www.tuaw.com/2011/03/14/use-applescript-to-open-current-safari-url-in-google-chrome/
-- install FastScripts http://www.red-sweater.com/fastscripts/ and place this AppleScript in the Scripts applications folder for Google Chrome.
-- For me that was ~/Library/Scripts/Applications/Safari
-- You can then assign it a keyboard shortcut. I went with Cmd-Shift-C
property theURL : ""
tell application "Safari"
set theURL to URL of current tab of window 1
end tell
tell application "Google Chrome"
@sillygwailo
sillygwailo / amazon_ca.js
Created July 23, 2020 18:23
Bookmarklet to switch from an Amazon.com URL to the Amazon.ca equivalent
url = new URL(window.location.href);
if (url.hostname = 'amazon.com') {
amazon_ca = url.href.replace('amazon.com', 'amazon.ca');
location.href = amazon_ca;
}
@sillygwailo
sillygwailo / gist:6906171
Created October 9, 2013 18:50
Duane Storey's iPhone-friendly random password generator in Python
# Duane Storey wrote an iPhone-friendly random password in PHP.
# http://www.migratorynerd.com/tips/iphone-friendly-strong-password-generator/
# "Basically the idea is to only use mostly keys that are accessible without
# having to hit shift or the keyboard button that switches to symbol mode."
# This is a port to Python if you wanted to wanted to generate it using something
# like Pythonista for iOS. http://omz-software.com/pythonista/
import random
def generate_password(length = 10):
@sillygwailo
sillygwailo / article.js
Last active May 15, 2018 09:07
Node module to provide the correct article for words starting with vowels
/*
TODO: * An article that starts a sentence should be capitalized.
* A more comprehensive list of subtleties like "a useful", "a once", "an hour", "an historical"
* Tests
*/
exports.article = function(text) {
var vowels = 'aeiou';
var an_exceptions = ['eucalyptus', 'eunuch', 'euphemism', 'euphemistic', 'euphonium', 'euphoric', 'european', 'once', 'one', 'onesie', 'union', 'unique', 'unison', 'united', 'useful', 'utopia', 'utopic', 'user', 'unicorn'];
var a_exceptions = ['hour', 'historical', 'honorable', 'honourable'];
if (a_exceptions.indexOf(text) != -1 || (vowels.indexOf(text.charAt(1)) == -1 && an_exceptions.indexOf(text) == -1)) {
@sillygwailo
sillygwailo / reading.js
Created April 15, 2014 22:19
Receiving a POST request in Node.js from Reading.am
var http = require('http'),
fs = require('fs'),
qs = require('querystring');
server = http.createServer( function(req, res) {
if (req.method == 'POST') {
var body = '';
req.on('data', function (data) {
body += data;
});