View morse.js
function MorseNode(ac, rate) {
// ac is an audio context.
this._oscillator = ac.createOscillator();
this._gain = ac.createGain();
this._gain.gain.value = 0;
this._oscillator.frequency.value = 750;
View gist:6fb969c04e774ab1767dc85a2278f154
In [1]: %load_ext autoreload
In [2]: %autoreload 2
In [3]: from import questions
In [4]: questions.meaning_of_life()
Out[4]: 42
In [5]: "Rewriting method"
View hn_seach.js
function query() {
// HN is done with very unsemantic classes.
job_list ='.c5a,.cae,.c00,.c9c,.cdd,.c73,.c88')),
query_list =,
shown = 0, total = job_list.length;
// Traverses up the dom stack trying to find a match of a specific class
function up_to(node, klass) {
if (node.classList.contains(klass)) {
View creating
from django.utils import timezone
import pytz
pytz_tz = pytz.timezone('America/Chicago')
# wrong -- The direct approach leads to somewhat random time offsets between timezones.
adt = timezone.datetime(year=2016, month=1, day=6, tzinfo=pytz_tz)
# correct: Localize a naive datetime.
ndt = timezone.datetime(year=2016, month=1, day=6)
# place this snippet into in ~/.atom directory
atom.workspace.observeTextEditors (editor) ->
if editor.getTitle() isnt "untitled"
sp = editor.getPath().split('/')
title = sp.slice(sp.length-2).join('/')
editor.getTitle = -> title
editor.getLongTitle = -> title
for item in atom.workspace.getPaneItems()
View ajax_django_post_request.js
// uses jquery
type: "POST",
url: "{% url 'attachment-object-coupling' project.slug %}",
data: {
attachment: attachments.attr("id"), // attachment instance_id
object: objects.attr("id"), // object instance_id
csrfmiddlewaretoken: '{{ csrf_token }}' // if not configured to include token in every post
success: function(data) {
View gist:8df5f70cd886c9abe8ce
#pip install watchdog
#sudo apt-get install xvkbd
watchmedo shell-command \
--patterns="*.rst" \
--ignore-pattern='_build/*' \
--recursive \
View gist:3108b3ea1a6b81c086b8
from selenium import webdriver
from lxml import html
#Get the page source as altered by the browser
browser = webdriver.Firefox()
html_source = browser.page_source
View gist:791d63545df3c605c872
IPAddress server(10,0,0,138);
String PostData = "someDataToPost";
if (client.connect(server, 80)) {
client.println("POST /Api/AddParking/3 HTTP/1.1");
client.println("User-Agent: Arduino/1.0");
client.println("Connection: close");
View gist:e0efcf61123d2fa96f7c
#Testing syntax highlighting.
import requests
print 'I love strings'