Skip to content

Instantly share code, notes, and snippets.

View Yuffster's full-sized avatar
🕳️
ᕕ( ᐛ ) ᕗ

Michelle Steigerwalt Yuffster

🕳️
ᕕ( ᐛ ) ᕗ
View GitHub Profile
@Yuffster
Yuffster / wtf.js
Last active December 13, 2015 22:08
WTF, JavaScript?
var str ="START LINE '$' END LINE",
tmp = "\n\n\tSome stuff is here\n\n\t{{replace_me}}\n\n\t\nTHIS SHOULD BE AT THE END";
console.log(tmp.replace("{{replace_me}}", str));
@Yuffster
Yuffster / scratch.py
Last active August 29, 2015 14:18
Weird XOR Thing
def single_character_xor(string, xor):
xored = map(lambda n: n ^ ord(xor), map(ord, string))
return "".join(map(chr,xored))
def detect_wtf(string):
for i in range(255):
xored = single_character_xor(string, chr(i))
if xored[0] == string[0].upper():
print string+" when XORed with %d"%i+"="+xored
@Yuffster
Yuffster / cool_way.py
Created April 2, 2015 20:24
Hamming Distance
def hamming_distance(a,b):
"""
Computes the byte difference between two strings.
>>> hamming_distance("this is a test", "wokka wokka!!!")
37
"""
count = 0
a = string_to_byte_array(a)
b = string_to_byte_array(b)
@Yuffster
Yuffster / 00_database_with_proxy.js
Created June 17, 2015 22:57
Code Words: Pseudosynchronous APIs Code Examples
function DatabaseClient(callback) {
var self = this;
var queue = [];
var ready = false;
console.log("Connecting to database.");
function run(method, args) {
console.log("Executing operation: Database."+method);
@Yuffster
Yuffster / 00_concat.js
Last active August 29, 2015 14:23
Code Words Pseudosynchronous APIs Part I
function concat() {
var output = "";
Array.prototype.forEach.call(arguments, function(arg) {
output += arg;
});
return output;
}
console.log(concat('abc', 'def', 'ghi')); // 'abcdefghi'
@Yuffster
Yuffster / correct.js
Last active August 29, 2015 14:23 — forked from benjamingr/correct.js
function createUser(username, callback) {
var connection = DatabaseClient.connect();
var users = connection.call('collection', 'users');
var query = users.call('query', {username: username});
return query.then(function(existing){
if(existing) throw new Error("User already exists: " + username);
else return users.call('create', {username: username});
}).fin(function(connection){ return connection.call('close'); });
}
function createUser(username, callback) {
var connection = DatabaseClient.connect();
var users = connection.collection('users');
var query = users.query({username: username});
return query.then(function(existing){
if(existing) throw new Error("User already exists: " + username);
else return users.create({username: username});
}).fin(function(connection){ return connection.call('close'); });
}
from blessings import Terminal
from time import sleep
from random import randrange, choice
class Glyph():
def __init__(self, content, terminal):
self.content = content
self.terminal = terminal
function GRUNDTAL(taskType, data) {
var template = document.getElementById(taskType + 'Task-template').innerHTML;
this.template = Handlebars.compile(template);
this.taskName = taskType;
this._data = data || {};
this.step = this._data.step || 'info';
}
GRUNDTAL.prototype = {
from labsuite.protocol import Protocol
from labsuite.protocol.formatters import JSONFormatter
protocol = Protocol()
protocol.set_info(
name="Test Protocol",
description="A protocol to test JSON output.",
author="Michelle Steigerwalt"
)