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
git clone https://github.com/wmnnd/distillery-demo.git | |
cd distillery-demo | |
# Add distillery as dependency in mix.exs | |
mix deps.get | |
# To create the initial release | |
MIX_ENV=prod mix release.init | |
MIX_ENV=prod mix release |
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
def dynamic_load(fqcn): | |
parts = [ | |
x.strip() | |
for x in fqcn.split('.') | |
if x.strip() | |
] | |
module = __import__('.'.join(parts[:-1]), | |
globals(), | |
locals(), | |
[]) |
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
# Sick of all people who keep sending posts where attitude seems to mean everything | |
import operator | |
word_sum = lambda s: reduce(operator.add, [ord(i) - ord('a') + 1 for i in s]) | |
words = None | |
with open('/usr/share/dict/words') as d: | |
words = filter(lambda w: word_sum(w.strip()) == 100, d) | |
print words |
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
def two_digit_words(n): | |
words = dict([ | |
(1, 'one'), | |
(2, 'two'), | |
(3, 'three'), | |
(4, 'four'), | |
(5, 'five'), | |
(6, 'six'), | |
(7, 'seven'), | |
(8, 'eight'), |
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
expr = "28+30+++39+32" | |
filter(bool, expr.split("+")) | |
filter(None, expr.split("+")) | |
bool(None) == bool('') == bool() == False |
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
class Borg: | |
_shared_state = {} | |
def __init__(self): | |
self.__dict__ = self._shared_state | |
b = Borg() | |
b.name = 'Borg' | |
c = Borg() |
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
// Use as sum(4, 5) | |
// Use as sum(sum(4, 5), sum(1, 2)) | |
def sum(x: Int, y: Int): Int = { | |
x + y; | |
} | |
// Use as sum(4, 5) | |
// Use as sum(sum(4, 5), sum(1, 2)) | |
def sum = (x: Int, y: Int) => { x + y; } |
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
/* | |
* Combinators in Finagle: | |
* | |
* - flatMap | |
* - rescue | |
* - collect | |
* - andThen | |
* - | |
*/ | |
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
<?php | |
/** | |
* @func: Executes the command passed to it as argument and prints the | |
* command console output line by line onto the html output stream hence | |
* giving the illusion of having the command executing in the html window itself. | |
*/ | |
function html_exec_cmd($cmd) { | |
$proc = popen("($cmd)2>&1", "r"); | |
echo '<pre>'; | |
while(!feof($proc)) { |
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 random | |
import uuid | |
import hashlib | |
items = [8, 19, 1, 03, 52, 62, 23, 62, 236, 9, 0, 12] | |
sorted(items, key=lambda x: hashlib.md5(uuid.uuid1().hex).hexdigest()) |