Skip to content

Instantly share code, notes, and snippets.

View hhursev's full-sized avatar

hhursev

  • ::1
View GitHub Profile
@hhursev
hhursev / paradigms.js
Created December 14, 2015 13:38
Paradigms
// imperative
let makes = [];
for (i = 0; i < cars.length; i++) {
makes.push(cars[i].make)
}
// declarative
let makes = cars.map((car) => { return car.make })
@hhursev
hhursev / comprehensions.py
Created December 14, 2015 13:01
comprehensions
nice_things = ['coffee', 'cheese', 'crackers', 'tea', 'chocolate']
# for
# indexing
# slices
# comprehensions
# think of something bigger (experiment)
# itertools
@hhursev
hhursev / python_virtualenvs.md
Last active August 16, 2016 07:50
Setup virtualenv and virtualenvwrapper

Run the following:

sudo apt-get install -y python-pip &&
sudo pip install virtualenv==1.11.6 &&
sudo pip install virtualenvwrapper==4.3 &&
echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc &&
mkdir ~/.virtualenvs &&
WORKON_HOME=~/.virtualenvs &&
source /usr/local/bin/virtualenvwrapper.sh
@hhursev
hhursev / test.py
Created March 25, 2015 11:37
Second challenge sample tests
import unittest
import solution
class TestGrandmaPickles(unittest.TestCase):
def test_jars_content_result_elements_are_generators(self):
for jar in solution.jars_content(
jars=2,
@hhursev
hhursev / postgresql.apt.sh
Last active August 29, 2015 14:12
script enabling PostgreSQL APT
#!/bin/sh
# script to add apt.postgresql.org to sources.list
# from command line
CODENAME="$1"
# lsb_release is the best interface, but not always available
if [ -z "$CODENAME" ]; then
CODENAME=$(lsb_release -cs 2>/dev/null)
fi
@hhursev
hhursev / fabfile.py
Created August 12, 2014 08:42
Example fabfile to use
import os
from fabric.api import env, local, run, prefix, cd
env.roledefs = {
'xx': ['host:port'],
}
env.forward_agent = True