This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typing | |
import unittest | |
class TreeNode: | |
def __init__(self, left=None, right=None): | |
self.left = left | |
self.right = right | |
def is_superbalanced(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'json' | |
require 'Simplenote' | |
class ZimDirectory < Hash | |
class ZimException < Exception | |
end | |
attr_reader :dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PhantomJS doesn't support bind yet | |
Function.prototype.bind = Function.prototype.bind || function (thisp) { | |
var fn = this; | |
return function () { | |
return fn.apply(thisp, arguments); | |
}; | |
}; | |
(function(p) { | |
var fs = require('fs'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program YearTenComputerSystemsProjectByBrandonEthakadaAndTaiBellLiu; | |
uses ptccrt, ptcgraph; | |
var keyz : string; | |
selection,speed : integer; | |
procedure InitIt; | |
var gd, gm : integer; | |
begin | |
Gd := d8bit; | |
Gm := m640x480; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'digest/sha1' | |
class Proof < Struct.new :data, :difficulty, :token | |
def valid? | |
hash = Digest::SHA1.hexdigest("#{data} #{difficulty} #{token}") | |
pl = prefix_length(hash.to_i(16)) | |
difficulty <= pl | |
end | |
def increment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
class Account < Struct.new :balance | |
end | |
class MoneyTransfer < Struct.new :source, :destination | |
def initialize source, destination | |
super | |
source.extend Transferrer | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <arpa/inet.h> | |
#include <errno.h> | |
#include <netdb.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <strings.h> | |
#include <dns_sd.h> | |
void callback(DNSServiceRef sdRef, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NUM_POOLS = 5 | |
Grad = Struct.new :name, :gender, :region | |
def norm_name first, last | |
"#{first.strip} #{last.strip}" | |
end | |
def norm_gender gender | |
{'M' => 'Male', 'F' => 'Female'}[gender] || gender |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# We have a few repeat customers here at the TWU 27 hotdog shack. | |
# | |
# They've decided it's FUN to visit our stand. | |
# | |
# So, we've cooked up something a little special for our valued customers. | |
set -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Retarded simple event-binding "DSL" | |
Best with: | |
* jQuery (or Zepto) | |
* event_emitter | |
https://github.com/ajaxorg/ace/blob/master/lib/ace/lib/event_emitter.js | |
Usage: | |
tie($(window), "hashchange") |