Skip to content

Instantly share code, notes, and snippets.

Avatar

radicalsauce

  • San Francisco, CA
View GitHub Profile
@radicalsauce
radicalsauce / Guess the Number - Python
Last active Aug 29, 2015
Guess The Number Game (Written for Coursera's An Introduction to Interactive Programming in Python class)
View Guess the Number - Python
# "Guess the number" mini-project
# By Kelly Hale, 3/12/14
# input will come from buttons and an input field in simplegui
# all output for the game will be printed in the console
import simplegui
import random
import math
View favicon-interceptor.js
// early experiments with node had mysterious double requests
// turned out these were for the stoopid favicon
// here's how to short-circuit those requests
// and stop seeing 404 errors in your client console
var http = require('http');
http.createServer(function (q, r) {
// control for favicon
View list.js
var makeLinkedList = function(){
var list = {};
list.head = null;
list.tail = null;
list.addToTail = function(value){
var newNode = makeNode(value);
if (!list.head) {
list.head = newNode;
}
@radicalsauce
radicalsauce / mergesort.js
Last active Oct 7, 2015
Javascript MergeSort
View mergesort.js
// A simple JS mergesort, per Wikipedia's pseudocode
// http://en.wikipedia.org/wiki/Mergesort
// by K.R. Hale
var mergeSort = function(array) {
//base case
if (array.length <= 1) return array;
//recursive case
var middle = Math.floor(array.length / 2);
@radicalsauce
radicalsauce / concat.js
Last active Oct 7, 2015
Javascript Concat()
View concat.js
// A recreation of the native JS string method
// Accepts as many string arguments as you can feed it, returns concatenated string
// K.R. Hale
var concat = function() {
var result = "";
for(var i = 0; i < arguments.length; i++) {
result += arguments[i];
}
return result;
@radicalsauce
radicalsauce / adv_js_prompts.js
Last active Apr 3, 2019
JS Interview Questions
View adv_js_prompts.js
// PROMPT ONE:
var getUserComments = function(callback) {
// pretend this performs some async operation like an Ajax call
var commentCount = 50;
callback({ comments: commentCount });
};
var User = {
fullName: 'Joe Shmoe',
@radicalsauce
radicalsauce / purple-air-notif.js
Last active Aug 29, 2020
Notifies me via Twilio when my local AQI slips into "unhealthy" ranges
View purple-air-notif.js
/*
How to use:
- Set up Twilio:
You will need a Twilio account and a Twilio phone number. All in all this should run you
about $1. Details here: https://www.twilio.com/docs/sms/quickstart/node
You'll want to save your new Twilio # into your phone contacts and set to favorite so it can wake you up
if you're using DND.
- Find the sensor you want to monitor: