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
var foo; // define local 'foo' with value undefined | |
var foo; // redeclaration (bug, but probably not illegal) | |
foo = 3; // assign to 3 in file1 scope | |
Script.include('file2.js') // gets run in its own scope | |
print(foo); // => 3 | |
showFoo(); // => 1 (local foo bound in file2 scope) |
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
// | |
// Created on 10/5/2015 by Seiji Emery | |
// | |
// Reimplements cstring functions: | |
// http://www.cplusplus.com/reference/cstring/ | |
// | |
// | |
// Pseudocode: | |
// |
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
''' | |
Fuzzy search algorithm inspired by sublimetext. | |
''' | |
with open('/usr/share/dict/words') as f: | |
words = f.read().split('\n') | |
def fuzzy_match (q): | |
''' Match a query string q against a candidate string s, where len(q) <= len(s). |
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
// Note on used types: | |
// - ResourceLayer is a threadsafe singleton class with a bunch of static methods | |
// - ResourceLayer calls return a Resource*******Request temp object, which uses a | |
// bunch of declarative chained method calls to set its state. The destructor (or | |
// an explicit call) launches the request. | |
// - TextureHandle wraps / owns a gl texture (the implementation is not important) | |
// - TextureHandleRef is a std::shared_ptr<TextureHandle> | |
// - There's some implicit path stuff (PROJECT_DIR is a path object; PROJECT_DIR + string => new path). | |
// | |
// Also, architecturally we're running in an environment with multiple threads, including |
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
matches + splits string, int, hex, and floating point literals, c-style identifiers, | |
and greedily matches all symbols (differentiates between '+', '+=', '++'). | |
Also includes two operators that I wish most languages _did_ have (you can remove these), | |
||= and &&=, which would codify/simplify the lua/js null check foo = x || default (foo ||= default) | |
('[^']*'|"[^"]*"|[_a-zA-Z][_a-zA-Z0-9]*|0x[a-fA-F\d]+|-?\d+(?:.\d+(?:[eE]\d+)?)?|//|/\*|\*/|\|\|=?|&&=?|\+\+|\-\-|\.\.|==|\->|[\+\-\*/%^\|&<>]=|[\?#\[\]\(\){}:;,\.\|&\+\-\*/%^<>=]) |
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
#!/usr/bin/python | |
import os | |
from multiprocessing import Pool | |
NUM_THREADS = 8 | |
cur_dir = '.' | |
src_formats = [ '.mp4' ] | |
dst_format = '.mp3' | |
conv_cmd = 'avconv -i "{0}" "{1}"' |
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
// List of template arguments to string | |
struct Joiner { | |
string sep; | |
stringstream ss; | |
Joiner (string sep) : sep(sep) {} | |
template <typename T, typename... Args> | |
Joiner& apply (const T & v, Args... args) { | |
ss << v << sep; |
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
Asm project idea: mini interpreter | |
LANGUAGE SPEC | |
types: | |
64-bit int | |
64-bit float (?) | |
"object" pointer | |
"closure" pointer | |
c pointer (?) |
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
when-changed foo.c "clear; clang -o foo foo.c > compile_log.txt && ./foo || cat compile_log.txt" |
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
meta-cpp: a custom c++ preprocessor that adds D-like features to c++11/c++14. | |
Nicer syntax: | |
class Foo { ... } => class Foo { ... }; | |
interface Foo { void bar(); } => class Foo { virtual void bar() = 0; }; | |
class Foo { this () { ... } } => class Foo { Foo () { ... } }; | |
class Foo { => class Foo { |