This file contains hidden or 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 datetime | |
| import enum | |
| import re | |
| import sys | |
| import types | |
| from collections import namedtuple | |
| from decimal import Decimal | |
| from operator import attrgetter |
This file contains hidden or 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 hidden or 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
| class Thing < Struct.new(:color) | |
| @@things = {} | |
| def self.parse description | |
| type_name, color = description.split | |
| @@things[type_name].new color | |
| end | |
| def self.type_code code | |
| @@things[code] = self |
This file contains hidden or 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 'date' | |
| require 'minitest/autorun' | |
| class Time | |
| def self.normalize time | |
| dt = DateTime.parse(time).to_time.utc | |
| Time.utc(Time.now.year, nil, nil, dt.hour, dt.min) | |
| end | |
| def inbetween start_time, end_time |
This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| # Welcome to the Chinese Support Add-on's field edition ruleset. | |
| # Here, you can tweak the note editor helper's behavior to your liking. | |
| # | |
| # If you messed things up, you can safely delete file | |
| # addons/chinese/edit_behavior.py from your Anki directory. | |
| # It will be recreated the next time you restart Anki. | |
| # | |
| # You can read about all available functions at: | |
| # https://github.com/ttempe/chinese-support-addon/wiki/Edit-behavior |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 'benchmark' | |
| require 'delegate' | |
| class Direct | |
| def method | |
| 'direct' | |
| end | |
| def base | |
| 'base' |
This file contains hidden or 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 |