float rand(float n){return fract(sin(n) * 43758.5453123);}
float noise(float p){
float fl = floor(p);
float fc = fract(p);
return mix(rand(fl), rand(fl + 1.0), fc);
}
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 utterance = new SpeechSynthesisUtterance(); | |
| var voices = speechSynthesis.getVoices(); | |
| utterance.voice = voices[16]; | |
| utterance.rate = 1.2; | |
| utterance.pitch = 1; | |
| mo = new MutationObserver(mutations => { | |
| mutations.forEach(mutation => { | |
| const e = mutation.addedNodes[0]; | |
| if (e) { | |
| utterance.text = e.querySelector('#author-name').innerText + ': ' + e.querySelector('#message').innerText; |
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
| /* | |
| ProxyDom usage: | |
| var div = ..., proxy = ProxyDom(div); | |
| proxy.text('hey').class('bold', true).attr('data-id', 'identity'); | |
| */ | |
| /* | |
| template usage: | |
| <div data-template='name'> | |
| <div data-bind='title'></div> |
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 | |
| /** | |
| * Asynchronously Post Http requests | |
| * $request = AsyncHttpPost::create($url, array('key' => 'post data')); | |
| * Need to call isDone to begin working. | |
| * Use either wait() to wait for the request to finish (blocking) | |
| * Or use isDone to check if the request has completed. | |
| */ | |
| class AsyncHttpPost { |
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/bash | |
| if [ -n "$(svn st | egrep '^A|M' | awk '{print$2}' | xargs cat | grep -i '@todo')" ]; then | |
| echo 'There are TODOs:'; | |
| svn st | egrep '^A|M' | awk '{print$2}' | while read filename; do | |
| if [ -n "$(cat $filename | head -c 100000 | grep -i '@todo')" ]; then | |
| echo $filename | |
| cat $filename | head -c 100000 | grep -i '@todo' | awk '{ sub(/^[ *]*/, "", $0); print " > " $0 }' | |
| echo | |
| fi |
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 | |
| function xml_encode($root, $values) { | |
| return xml_add_children(new SimpleXMLElement("<?xml version='1.0' encoding='utf-8'?><$root/>"), $values)->asXML(); | |
| } | |
| function xml_add_children($root, $values) { | |
| foreach ($values as $key => $value) { | |
| if ($key[0] == '@') { | |
| $root->addAttribute(substr($key, 1), $value); |
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 Trxn { | |
| public static function run($trxn) { | |
| $result = $trxn(); | |
| return $result; | |
| } | |
| public static function then(Closure $now, Closure $next) { | |
| return function() use($now, $next) { |
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 dbus | |
| import time | |
| import gobject | |
| import datetime | |
| import dbus.mainloop.glib as glib | |
| class Main(): | |
| def __init__(self): | |
| dbus_loop = glib.DBusGMainLoop(set_as_default=True) | |
| bus = dbus.SessionBus(mainloop = dbus_loop) |
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 gevent | |
| from gevent.pywsgi import WSGIServer, WSGIHandler | |
| def f(env, start_response): | |
| start_response('200 OK', [('Content-type', 'text/plain')]) | |
| gevent.sleep(4) | |
| return 'hi' | |
| class NoErrorHandler(WSGIHandler): | |
| def process_result(self): |