Skip to content

Instantly share code, notes, and snippets.

View sillygwailo's full-sized avatar

Richard Eriksson sillygwailo

View GitHub Profile
@sillygwailo
sillygwailo / disqus.jade
Last active December 23, 2015 16:59
Disqus Universal code in Jade (templating engine for Node.js)
#disqus_thread
script(type='text/javascript')
var disqus_shortname = '#{ disqus_shortname }';
var disqus_identifier = '#{ disqus_shortname}-#{ current.path.join('-') }';
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
noscript
@sillygwailo
sillygwailo / harp-webhook.md
Last active December 23, 2015 20:49
Resources Consulted While Building a Webhook to Compile a Harp Application Into a Static Website

Resources Consulted While Building a Webhook to Compile a Harp Application Into a Static Website

@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 / YouTube.py
Created October 15, 2013 03:25
YouTube
import cgi, urllib, urlparse, webbrowser, sys, clipboard, console
argLen = len(sys.argv)
if argLen > 1:
url = sys.argv[1]
else:
url = clipboard.get()
p = urlparse.urlparse(url)
@sillygwailo
sillygwailo / filter-d7-to-d8.html
Created October 23, 2013 20:57
Instructions on how to update a Drupal 7 filter module to Drupal 8 (to go in a Drupal.org handbook page)
<ol>
<li>create a file called <code>filter.services.yml</code> file, with the following format:
<code><pre>
services:
plugin.manager.filter:
class: Drupal\modulename\Filter\FilterName
arguments: ['@container.namespaces']
</pre></code>
Replace <code>modulename</code> with the module's machine name, and <code>FilterName</code> with a unique name for the filter.</li>
<li>create a folder called <code>lib/Drupal/modulename/Plugin</code> (replacing <code>modulename</code> with the module's machine name). In Mac and Unix environments, in the module's folder, you can use the following shell command:
#!/usr/bin/python
import Image
import base64, zlib
# Jay Parlar convinced me to turn this data structure
# from a dictionary into an object.
class PackedImage(object):
def __init__(self, mode, size, data):
self.mode = mode
#!/usr/bin/python
import Image
import base64, zlib
# Jay Parlar convinced me to turn this data structure
# from a dictionary into an object.
class PackedImage(object):
def __init__(self, mode, size, data):
self.mode = mode
@sillygwailo
sillygwailo / random-runkeeper-route.md
Created February 6, 2014 01:57
Create a Random Route in RunKeeper
  1. Punch in an address or intersection as a starting (and ending) point at http://www.routeloops.com/
  2. Type in a route length in miles. You might need to convert from km if you're metric like me. You can change the units of measurement in the settings.
  3. Click "Creat a route of this Length"
  4. Click "Import/Export"
  5. Choose GPX (you don't need a large number of points for a route).
  6. This will open GPX output in a new window/tab. Use the save function of your browser, and give the file a name with the extension .gpx
  7. If you haven't already, install the RunKeeper GPX bookmarklet at http://jacqueminv.github.io/rkrace-bookmarklet/
  8. Login to RunKeeper.
  9. Visit http://runkeeper.com/new/route
  10. Now click the RunKeeper GPX bookmarklet installed in step #7. You should see a GPX icon on the left side.
@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();