Skip to content

Instantly share code, notes, and snippets.

@rubik
rubik / gisty.py
Created July 9, 2012 19:53
Example command line program powered by Baker and other cool libraries (pathlib, slumber & colorama)
import sys
import baker
import slumber
import pathlib
import colorama
API_URL = 'https://api.github.com/'
def get_api(auth=None):
@rubik
rubik / run_glm.py
Last active October 27, 2017 15:23
import numpy as np
import pymc3 as pm
import theano as t
train_new = np.load('train_new.npy')
targets = np.load('y.npy')
X = t.shared(train_new)
features = list(map(str, range(train_new.shape[1])))
with pm.Model() as logistic_model:

Keybase proof

I hereby claim:

  • I am rubik on github.
  • I am rubik (https://keybase.io/rubik) on keybase.
  • I have a public key ASAdcueU55alkZqzJ-Ha8dhGYEK3Uqy_ySm5OWVU6WtsOQo

To claim this, I am signing this object:

id percentage
1001 9.9
1003 7.2
1005 9.7
1007 9.0
1009 8.0
1011 11.5
1013 10.1
1015 9.2
1017 10.5

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth.

Data Structure Basics

Array

Definition:

[%LetsPlan.Vote{__meta__: #Ecto.Schema.Metadata<:loaded>,
availabilities: [%LetsPlan.Availability{__meta__: #Ecto.Schema.Metadata<:loaded>,
from: #Ecto.Date<2016-03-26>, id: "9b7ec626-5c58-4194-9925-535b8af597e4",
to: #Ecto.Date<2016-03-28>},
%LetsPlan.Availability{__meta__: #Ecto.Schema.Metadata<:loaded>,
from: #Ecto.Date<2016-03-30>, id: "26714a0b-ce51-4471-9214-13fcf0cae8ea",
to: #Ecto.Date<2016-03-31>}],
event: #Ecto.Association.NotLoaded<association :event is not loaded>,
event_id: 1, id: 4, inserted_at: #Ecto.DateTime<2016-03-26T19:47:03Z>,
name: "mic (again!)", updated_at: #Ecto.DateTime<2016-03-26T19:47:03Z>},
@rubik
rubik / a_cfrac.py
Created December 10, 2011 10:32
Creating a simple continued fraction from a square root
import math
def from_root(n):
'''
Construct a continued fraction from a square root. The argument
`n` should be an integer representing the radicand of the root:
>>> from_root(2)
(1, [2])
@rubik
rubik / pi_digits.py
Last active December 22, 2015 00:48
Computing PI digit by digit. The input to the function is the number of decimal digits.
f=lambda w=4:(lambda j,o,i:(lambda s,g:list(i.takewhile(lambda _:len(o)<w+1,
(((4*g(0)+g(1)-g(2)<g(4)*g(2)and(o.append(int(g(4))),s(6,10*(g(1)-g(4)*g(2))),
s(4,((10*(3*g(0)+g(1)))//g(2))-10*g(4)),s(0,g(0)*10),s(1,g(6))))or(s(6,(2*g(0)
+g(1))*g(5)),s(7,(g(0)*(7*g(3))+2+(g(1)*g(5)))//(g(2)*g(5))),s(0,g(0)*g(3)),
s(2,g(2)*g(5)),s(5,g(5)+2),s(3,g(3)+1),s(4,g(7)),s(1,g(6))))for _ in iter(int,1)
)))and o)(lambda v,y:j.__setitem__(v,y),lambda v:j[v]))([1,0,1,1,3,3,-1,-1],[],
__import__('itertools'))
@rubik
rubik / arch-strap.sh
Last active December 18, 2015 16:38
A little script that does the basic things when installing ArchLinux
#!/bin/bash
# Configuration
root=/dev/sda3
boot=/dev/sda1
home=/dev/sda4
lang=en_US-UTF-8
keyboard=it
zone=Europe
subzone=Rome
@rubik
rubik / apples.py
Last active December 17, 2015 20:49
Python solution for SPOJ problem 'Buying apples'
import collections
# From
# http://stackoverflow.com/questions/1653970/does-python-have-an-ordered-set
class OrderedSet(collections.OrderedDict, collections.MutableSet):
def update(self, *args, **kwargs):
if kwargs:
raise TypeError("update() takes no keyword arguments")