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
#include <stdio.h> | |
#include <functional> | |
double any_op(double, double, std::function<double(double,double)>); | |
int main() | |
{ | |
std::function<double(double,double)> add = [](double a, double b) -> double { return a+b; }; | |
std::function<double(double,double)> sub = [](double a, double b) -> double { return a-b; }; |
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
In [21]: a = np.zeros( (20) ) | |
In [22]: b = np.asarray( [2, 5, 7, 15] ) | |
In [23]: a | |
Out[23]: | |
array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., | |
0., 0., 0., 0., 0., 0., 0.]) | |
In [24]: a[b] = 1 |
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
$ # First we set the correct python path and compilation flags | |
$ export vi_cv_path_python_plibs="-L/bitly/local/lib/python2.7/config/ -lpython2.7 -lpthread -lutil -Xlinker -export-dynamic" | |
$ # Configure will all the options we love the most | |
$ ./configure --with-features=huge --enable-pythoninterp --with-python-config-dir=/bitly/local/lib/python2.7/config/ | |
$ # Make & install | |
$ make -j & sudo make install |
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 re | |
def check_winner(board,row=4): | |
try: | |
return re.search(r"([^.|])(\1{%d}|%s)"%(row-1,"|".join(r"(.{%d}\1){%d}"%(len(a[0])+d,row-1) for d in range(-1,2))), "|".join("".join(x) for x in a)).group()[0] | |
except: | |
return "No one" | |
if __name__ == "__main__": | |
a = [ |
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
package main | |
import ( | |
"bytes" | |
"errors" | |
"fmt" | |
"io" | |
"net/http" | |
"net/url" | |
"path" |
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
#!/bin/env python | |
# $ seq 50 | python chunk.py 5 "xargs echo '-> '" | |
# -> 1 2 3 4 5 | |
# -> 6 7 8 9 10 | |
# -> 11 12 13 14 15 | |
# -> 16 17 18 19 20 | |
# -> 21 22 23 24 25 | |
# -> 26 27 28 29 30 | |
# -> 31 32 33 34 35 | |
# -> 36 37 38 39 40 |
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
package main | |
import ( | |
"crypto/tls" | |
"net" | |
"net/http" | |
"time" | |
"fmt" | |
"errors" | |
) |
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
#!/bin/bash | |
# Publishes IRC messages from a particular channel to a pubsub | |
server="irc.wikimedia.org" | |
channel="#en.wikipedia" | |
pubsub="http://localhost:8080/pub" | |
( echo "USER irc2ps * * :irc2ps_bot | |
NICK irc2ps$RANDOM | |
JOIN $channel"; cat -) | nc $server 6667 | |
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
$ sort -m country.decodes.2012-07-* | grep -v "(null)" | uniq -c | sort -n > country.count | |
$ cat country.count.norm | column -t -c1 | cut -f1 -d" " | paste -sd+ | bc | xargs -I{} awk '{if ($1/{} > .001) {print $1/{} " " $2}}' country.count.norm | sort -n | column | |
$ #tl;tr? |
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
<!DOCTYPE html> | |
<!-- | |
This visualization shows how a distribution gets decayed to uniform | |
using a poisson based decay model. This type of decay is implemented | |
in forgettable in order to store time relevant statistical models. | |
In this visualization, the blocks on the right (darker color) | |
represent the original distribution, while the blocks on the right | |
(lighter color) are the decayed values. The decay is currently | |
happening at a constant rate and the visualization can be reset by |
OlderNewer