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 socket, time | |
# http://www.usa.gov/About/developer-resources/1usagov.shtml | |
s = socket.socket() | |
s.connect(('developer.usa.gov', 80)) | |
s.send('GET /1usagov HTTP/1.0\n\n') | |
s.setblocking(False) | |
while True: |
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
//Practically all this code comes from https://github.com/alangrafu/radar-chart-d3 | |
//I only made some additions and aesthetic adjustments to make the chart look better | |
//(of course, that is only my point of view) | |
//Such as a better placement of the titles at each line end, | |
//adding numbers that reflect what each circular level stands for | |
//Not placing the last level and slight differences in color | |
// | |
//For a bit of extra information check the blog about it: | |
//http://nbremer.blogspot.nl/2013/09/making-d3-radar-chart-look-bit-better.html |
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 boto | |
from moto import mock_s3 | |
from model import MyModel | |
@mock_s3 | |
def test_save_study(): | |
conn = boto.connect_s3() | |
conn.create_bucket('mybucket') |
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
require 'pp' | |
require 'socket' | |
module BluetoothPolarHrm | |
AF_BLUETOOTH=31 # these are correct for the Linux Bluez stack | |
BTPROTO_RFCOMM=3 | |
class << self | |
def connect_bt address_str,channel=1 | |
bytes=address_str.split(/:/).map {|x| x.to_i(16) } | |
s=Socket.new(AF_BLUETOOTH, :STREAM, BTPROTO_RFCOMM) |
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 LazyCollection extends Backbone.Collection | |
indexQuerystring: 'index' | |
index: 1 | |
lastLength: 0 | |
fetch: (options) -> | |
options or= {} | |
if options.reset | |
@index = 1 | |
@lastLength = 0 | |
else |
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
/* | |
** Client side - /public/src/app.js | |
*/ | |
var myApp = { | |
// Collections | |
Collections: { | |
list: Backbone.Collection.extend() | |
}, | |
// Views |
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
# Jest Example | |
This is directly from the jest website. | |
## Requirements | |
- node | |
- npm | |
## 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
Aardvark | |
Elephant | |
Albatross | |
Alligator | |
Alpaca | |
Anaconda | |
Ant | |
Anteater | |
Antelope | |
Armadillo |
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 threading, os, sys | |
from multiprocessing import cpu_count | |
NUM_CPUS = cpu_count() | |
def batch_process(command_list, batch_size=NUM_CPUS): | |
iteratorlock = threading.Lock() | |
exceptions = [] | |
cmd = command_list.__iter__() | |
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
from datetime import datetime, date, timedelta | |
def EurodollarExpirations(): | |
start = datetime.now().date() | |
n = 20 | |
ex = [date(2008,12,15)] | |
for i in range(120): | |
x = ex[-1] | |
x += timedelta(days=91) | |
if x.day <= 12: x += timedelta(days=7) |