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 page = require('webpage').create(); | |
page.open | |
page.open('http://example.com', function(status) { | |
var x = page.evaluate(function() { | |
return "-" + window.document.title + '-'; | |
}); | |
console.log(x); | |
phantom.exit(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
assert = require("assert") | |
_ = require("underscore") | |
sigmoid = (v) -> | |
return 1 / (1 + Math.E ** (-v)) | |
pass = () -> undefined | |
class Ann | |
constructor: (inputs, hiddens, outputs) -> |
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
Mutex = java.util.concurrent.locks.ReentrantLock | |
Thread = java.lang.Thread | |
mutex = new Mutex | |
sum = 0 | |
adder = (c) -> | |
-> while c > 0 | |
c -= 1 | |
mutex.lock() | |
sum += 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
run: Mutex.class | |
jjs -cp . counter.js | |
Mutex.class: Mutex.java | |
javac Mutex.java | |
.PHONY: run |
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
#ifdef _win32_ | |
#include <winsock2.h> | |
#else | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <arpa/inet.h> | |
#include <netinet/in.h> | |
#include <strings.h> | |
#include <unistd.h> | |
#include <stdio.h> |
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
CC=clang -std=c99 | |
CFLAGS=-D_GNU_SOURCE -Wall -g -O2 | |
CXX=clang++ -std=c++03 | |
CXXFLAGS=-Wall -g -O2 `pkg-config --cflags QtDBus` | |
LDFLAGS=`pkg-config --libs QtDBus` | |
all: server client | |
install: server | |
install -m755 server $(HOME)/.kde/Autostart/ |
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/ipython | |
# vim: ft=python: | |
# to run it as ipython script, suffix must be .ipy | |
tmpfile = !mktemp | |
tmpfile = tmpfile[0] | |
files = !ls | |
file = open (tmpfile, "w") | |
file.writelines(files.n) # get it as newline separated string | |
file.close() | |
!cat $tmpfile # refer to python variable in shell |
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/ksh | |
if [[ -z "$1" ]] || (( $1 <= 1024 )); then | |
echo 'usage: tcpserver port' | |
exit 1 | |
fi | |
typeset port=$1 | |
typeset pipe=`mktemp -u` | |
mkfifo $pipe |
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/ksh | |
typeset port=$((RANDOM % 60000)) | |
while ((port < 30000)); do | |
port=$((RANDOM % 60000)) | |
done | |
typeset pipe=`mktemp -u` | |
mkfifo $pipe | |
trap "rm -f $pipe" INT |
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 | |
# vim: set fileencoding=utf-8: | |
import sys | |
import numpy | |
import random | |
class Direction: | |
def __str__(self): | |
if self._dir == 0: |
OlderNewer