Skip to content

Instantly share code, notes, and snippets.

View ahlusar1989's full-sized avatar
🏀
Let's Go!

Saran Ahluwalia ahlusar1989

🏀
Let's Go!
View GitHub Profile
# BEWD2 optimized solution for 99 bottles
def pluralize(word, count)
"#{count} #{word}#{'s' unless count == 1}"
end
def sing_bottles(count)
pluralized_count = pluralize("bottle", count)
puts "#{pluralized_count} of beer on the wall"
puts "#{pluralized_count} of beer"
puts "#{pluralize("bottle", count - 1)} of beer on the wall!"
@ahlusar1989
ahlusar1989 / index.html
Last active August 29, 2015 14:16 — forked from mbostock/.block
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
margin: 0;
background: #222;
min-width: 960px;
}
@ahlusar1989
ahlusar1989 / README.md
Last active August 29, 2015 14:16 — forked from anonymous/README.md

Part 1

Proof of concept

Say, you want to save your D3 application in a CouchDB database. This is just a proof of concept that this is possible. I use the »Focus + Context« diagram by Mike Bostock (http://bl.ocks.org/1667367) as an example.

Prerequisites:

@ahlusar1989
ahlusar1989 / livemap.py
Last active August 29, 2015 14:25 — forked from dbr/livemap.py
Live Google Map marker update with Tornado
"""Playing with tornado.websocket, to add markers to a Google Map using WebSockets
$ pip install tornado
$ python livemap.py --port=8888
Open http://localhost:8888 in one window
Each time http://localhost:8888/ping is opened in a second window, a
new marker is added to the map (at a random location)
@ahlusar1989
ahlusar1989 / cleaner.py
Last active August 29, 2015 14:25 — forked from lawlesst/cleaner.py
cleaning invalid characters from xml
def invalid_xml_remove(c):
#http://stackoverflow.com/questions/1707890/fast-way-to-filter-illegal-xml-unicode-chars-in-python
illegal_unichrs = [ (0x00, 0x08), (0x0B, 0x1F), (0x7F, 0x84), (0x86, 0x9F),
(0xD800, 0xDFFF), (0xFDD0, 0xFDDF), (0xFFFE, 0xFFFF),
(0x1FFFE, 0x1FFFF), (0x2FFFE, 0x2FFFF), (0x3FFFE, 0x3FFFF),
(0x4FFFE, 0x4FFFF), (0x5FFFE, 0x5FFFF), (0x6FFFE, 0x6FFFF),
(0x7FFFE, 0x7FFFF), (0x8FFFE, 0x8FFFF), (0x9FFFE, 0x9FFFF),
(0xAFFFE, 0xAFFFF), (0xBFFFE, 0xBFFFF), (0xCFFFE, 0xCFFFF),
(0xDFFFE, 0xDFFFF), (0xEFFFE, 0xEFFFF), (0xFFFFE, 0xFFFFF),
from glob import iglob
import csv
from collections import *
import os, sys
import csv
import itertools
from csv import reader
import xml.etree.cElementTree as ElementTree
from xml.etree.ElementTree import XMLParser
@ahlusar1989
ahlusar1989 / data.csv
Created October 5, 2015 20:55 — forked from eightysteele/data.csv
Unicode DictReader and DictWriter
id name age
0 aaron 34
1 tina 36
2 noah ©
@ahlusar1989
ahlusar1989 / boston.json
Created October 23, 2015 11:43 — forked from pprett/boston.json
Decision Tree Viewer (D3 and Sklearn)
{"error": 42716.2954, "samples": 506, "value": [22.532806324110698], "label": "RM <= 6.94", "type": "split", "children": [{"error": 17317.3210, "samples": 430, "value": [19.93372093023257], "label": "LSTAT <= 14.40", "type": "split", "children": [{"error": 6632.2175, "samples": 255, "value": [23.349803921568636], "label": "DIS <= 1.38", "type": "split", "children": [{"error": 390.7280, "samples": 5, "value": [45.58], "label": "CRIM <= 10.59", "type": "split", "children": [{"error": 0.0000, "samples": 4, "value": [50.0], "label": "Leaf - 4", "type": "leaf"}, {"error": 0.0000, "samples": 1, "value": [27.9], "label": "Leaf - 5", "type": "leaf"}]}, {"error": 3721.1632, "samples": 250, "value": [22.90520000000001], "label": "RM <= 6.54", "type": "split", "children": [{"error": 1636.0675, "samples": 195, "value": [21.629743589743576], "label": "LSTAT <= 7.57", "type": "split", "children": [{"error": 129.6307, "samples": 43, "value": [23.969767441860473], "label": "TAX <= 222.50", "type": "split", "children": [{"err
@ahlusar1989
ahlusar1989 / _.md
Last active October 31, 2015 12:53
Three Circles