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
/* | |
Incremental parser wrapper for the compiler service. | |
Designed to be used for integration on text editors, to keep an up to date | |
representation of the source code in its textual and AST forms. | |
// create compiler for some source code | |
compiler = Meta.compilerFromString(code) | |
// wrap the compiler with the incremental parser | |
parser = new IncrementalParser(compiler) |
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
{ | |
// private field init | |
var a = 1; | |
// Private functions | |
function func2() { | |
}; | |
// public field init | |
$scope.b = 1; // For controllers |
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
function fish_right_prompt --description 'Right prompt section' | |
set -l last_status $status | |
set -l prompt | |
# pyenv | |
set -l pyenv "$PYENV_VERSION" | |
if not test -n "$pyenv" | |
set pyenv "$PYENV_LOCAL_VERSION" | |
end |
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/env python | |
def memoize(fn): | |
""" Memoization decorator for a function taking one or more arguments. | |
NOTE: Only hashable values can be given as arguments to the function. | |
http://code.activestate.com/recipes/578231-probably-the-fastest-memoization-decorator-in-the-/#c4 | |
""" | |
class memodict(dict): | |
def __getitem__(self, *args): |
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
def djb2(data as string): | |
""" Computes a 32bit hash using the djb2 algorithm """ | |
payload = System.Text.Encoding.ASCII.GetBytes(data) | |
result as uint = 5381 | |
for ch in payload: | |
unchecked: | |
result = result * 33 + ch | |
return result & 0xffffffff |
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
<?php | |
class RectanglePacking { | |
private $root = array(); | |
private $usedHeight = 0; | |
private $usedWidth = 0; | |
function __construct($width, $height) { |
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
""" | |
Protocol should be compatible with Nailgun (http://www.martiansoftware.com/nailgun/protocol.html) | |
""" | |
namespace boodaemon | |
from System import UInt32 | |
from System.IO import BinaryReader, BinaryWriter | |
from System.Net.IPAddress import NetworkToHostOrder, HostToNetworkOrder | |
from System.Text import ASCIIEncoding |
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 CfgParser: | |
def __init__(self, src): | |
self.src = src | |
self.idx = 0 | |
def rowcol(self, ofs=None): | |
ofs = self.idx if ofs is None else ofs | |
lines = self.src.split('\n') | |
accum = 0 |
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 Boo.Lang.Compiler.Ast | |
def Method1(x, y): | |
print 'Method1', x, y | |
def Method2(x, y, z): | |
print 'Method2', x, y, z | |
macro BindArg(expr as Expression): | |
for fn in ('Method1', 'Method2'): |
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
#!/bin/sh | |
pyenv virtualenv "$1" | |
echo "Entering a new shell session with version '$1'" | |
echo "Press ctrl+d or exit to terminate it" | |
export PYENV_VERSION="$1" | |
$SHELL |