Skip to content

Instantly share code, notes, and snippets.

View kevgathuku's full-sized avatar

Kevin Gathuku kevgathuku

View GitHub Profile
@kevgathuku
kevgathuku / query.sql
Last active August 29, 2015 14:08 — forked from hlashbrooke/query.sql
SELECT email_address, COUNT(email_address) AS occurrences
FROM users
GROUP BY email_address
HAVING occurrences > 1
@kevgathuku
kevgathuku / .bashrc
Last active August 29, 2015 14:10 — forked from clneagu/.bashrc
# Call virtualenvwrapper's "workon" if .venv exists. This is modified from--
# http://justinlilly.com/python/virtualenv_wrapper_helper.html
# which is linked from--
# http://virtualenvwrapper.readthedocs.org/en/latest/tips.html#automatically-run-workon-when-entering-a-directory
check_virtualenv() {
if [ -e .venv ]; then
env=`cat .venv`
if [ "$env" != "${VIRTUAL_ENV##*/}" ]; then
echo "Found .venv in directory. Calling: workon ${env}"
workon $env
@kevgathuku
kevgathuku / tmux-cheatsheet.markdown
Created May 5, 2016 17:42 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@kevgathuku
kevgathuku / vim-on-heroku.sh
Created May 16, 2016 15:25 — forked from naaman/vim-on-heroku.sh
vim on heroku
#!/usr/bin/env bash
mkdir vim
curl https://s3.amazonaws.com/heroku-vim/vim-7.3.tar.gz --location --silent | tar xz -C vim
export PATH=$PATH:/app/vim/bin
@kevgathuku
kevgathuku / getter_and_setter.py
Created August 3, 2016 15:27 — forked from luhn/getter_and_setter.py
Using getters and setters with SQLAlchemy
class Table(Base):
id = Column(Integer, primary_key=True)
_name = Column('name', String(24))
@property
def name(self):
return self._name;
@name.setter
def name(self, value):
@kevgathuku
kevgathuku / .bashrc
Created August 4, 2016 12:08 — forked from cjerdonek/.bashrc
A snippet to automatically call virtualenvwrapper's "workon" command when entering a directory in the shell. This can be added to your .profile, .bash_profile, .bashrc, etc.
# Call virtualenvwrapper's "workon" if .venv exists. This is modified from--
# http://justinlilly.com/python/virtualenv_wrapper_helper.html
# which is linked from--
# http://virtualenvwrapper.readthedocs.org/en/latest/tips.html#automatically-run-workon-when-entering-a-directory
check_virtualenv() {
if [ -e .venv ]; then
env=`cat .venv`
echo "Found .venv in directory. Calling: workon ${env}"
workon $env
fi
@kevgathuku
kevgathuku / sqltypes.py
Created August 5, 2016 15:45 — forked from kijun/sqltypes.py
Useful sqlalchemy custom types
import json
import sqlalchemy.types
class JSONType(sqlalchemy.types.PickleType):
"""An example
>>> class User(declarative_base):
... friends = Column(JSONType())
...
@kevgathuku
kevgathuku / len.hs
Created September 17, 2016 11:29 — forked from animatedlew/len.hs
Here are two ways to implement Haskell's length function. One way is to map all the elements to 1, then sum them all up. Another way is to add up each head as you recursively call len' with the tail. The result will be the length of the list.
-- Maps each element to a 1, then sums up all the elements
len :: [a] -> Integer
len = sum . map (\_ -> 1)
-- Adds up all the heads (recursively) until the list is empty
len' :: [a] -> Integer
len' [] = 0
len' (_:xs) = 1 + len' xs
-- Extract into a fold using this technique: [ [] := v, (:) := f ]
@kevgathuku
kevgathuku / styles.css
Created October 5, 2016 17:32 — forked from pburtchaell/styles.css
VH and VW units can cause issues on iOS devices. To overcome this, create media queries that target the width, height, and orientation of iOS devices.
/**
* VH and VW units can cause issues on iOS devices: http://caniuse.com/#feat=viewport-units
*
* To overcome this, create media queries that target the width, height, and orientation of iOS devices.
* It isn't optimal, but there is really no other way to solve the problem. In this example, I am fixing
* the height of element `.foo` —which is a full width and height cover image.
*
* iOS Resolution Quick Reference: http://www.iosres.com/
*/
@kevgathuku
kevgathuku / front-end-curriculum.md
Created February 1, 2017 17:10 — forked from stevekinney/front-end-curriculum.md
Front-end Curriculum Draft

Module 1

  • Semantic markup
  • HTML standards mode and quirks mode
  • HTML fundamentals
    • Classes and IDs
  • CSS fundamentals
    • Selectors
    • Resets and normalizers
    • The box model