Skip to content

Instantly share code, notes, and snippets.

@thinkjson
thinkjson / 2017_07_06_lesson.py
Created July 7, 2017 00:37
Programming lesson: imports, function definition, keyboard shortcuts, function calls, for loops, iteration and conditionals
# Imports
import subprocess
# Function definition
def say(thing):
subprocess.call('say %s' % thing, shell=True)
# Keyboard shortcuts
# Cmd+S save
# Cmd+C copy
@thinkjson
thinkjson / scrollback
Created May 2, 2015 18:42
yet another programming lesson
>>> from speech import say
>>> words = []
>>> words
[]
>>> words.append("hello")
>>> words
['hello']
>>> words.append("elisheva")
>>> say(words)
>>> words.reverse()
@thinkjson
thinkjson / gist:ec5e23a3e39c9a26fd57
Created April 13, 2015 12:02
Intro to Programming Lesson 2
Python 2.7.8 (default, Apr 8 2015, 14:55:10)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ["one","two","three"]
['one', 'two', 'three']
>>> ["one","two","three"][:2]
['one', 'two']
>>> ["one","two","three"][:-1]
['one', 'two']
>>> ["one","two","three"][-1]
@thinkjson
thinkjson / REPL
Created April 11, 2015 00:42
Intro to Programming Lesson 2
$ python
Python 2.7.8 (default, Apr 8 2015, 14:55:10)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from speech import say
>>> say('this is a test')
>>> say('this is a test')
>>> say('Hello Ellisheva!')
>>> say('hello daddy')
>>> "na"*3
@thinkjson
thinkjson / new_host_DNS.py
Last active August 29, 2015 14:17
Check to see when DNS for a new host has propagated
import requests
import sys
import time
import subprocess
if len(sys.argv) != 2:
print 'Usage: new_host_DNS.py [url]'
sys.exit(0)
NX = True
@thinkjson
thinkjson / voice.py
Created June 3, 2014 12:41
say REPL
import cmd
import os
import subprocess
import shlex
from pipes import quote
devnull = open(os.devnull, 'w')
class Voice(cmd.Cmd):
"""Simple command processor example."""
@thinkjson
thinkjson / bookmarklet.js
Last active August 29, 2015 13:56
CORS Instapaper POC for pages with Content Protection Policy
javascript:$.post('http://server.thinkjson.com/echo.php?url=' + encodeURIComponent(location.href) + '&title=' + encodeURIComponent(document.title));
@thinkjson
thinkjson / loggly.js
Created February 21, 2014 02:12
Loggly example
var http = require('http');
var options = {
host: 'logs.loggly.com',
port: 80,
path: '/inputs/{input_id}',
method: 'POST'
};
exports.write = function(data) {
var req = http.request(options, function(res) {});
req.on('error', function(e) {
@thinkjson
thinkjson / bible-tweet-bookmarklet
Last active December 22, 2015 19:09
Create a new bookmark with the content below as the url to attempt to autolink Bible references in Tweets
javascript:$('.tweet-text').each(function(i, item) { $(this).html($(this).html().replace(/(\w+) \d+\:\d+/g, '<a href="https://www.bible.com/search?q=$&">$&</a>')); });