Skip to content

Instantly share code, notes, and snippets.

View dansackett's full-sized avatar

Dan Sackett dansackett

View GitHub Profile
/*
Given a string "s1"
eg. ABKHJDLNCMLNCKS
and another string with a length equal to or less than s1, called "s2"
eg. AKHJDMNS
write a function that determines whether the characters in s2 are a subset of
from itertools import cycle
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
def encrypt(key, plaintext):
"""Encrypt the string and return the ciphertext"""
pairs = zip(plaintext, cycle(key))
result = ''
import $ from 'jquery';
import join from 'lodash/join';
import slice from 'lodash/slice';
import isNil from 'lodash/isNil';
/**
* Mutate the contents of an HTML node if it is not within the bounds of a
* parent node by truncating the output.
*
@dansackett
dansackett / tmux-cheatsheet.markdown
Created May 3, 2017 05:20 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
`````
````.:::;,```
```.,,,:'''';;.`` `
```.;;,,,:,,:+#+,.``
```#+;::,.``.,::''::```
````:';;:;,``..``.,,;+,`.`
.` `,:'#':..``...,,.,;;,`. `
`.```.,';;```.:...,;';''''.``
``````,:,``,::..`...,;;:;#+`.`

ASKpy - Collect Input from your Users

ASKpy is a module which makes collecting Raw Input for your Python program more robust. It supports creating prompts, conditional questions, validation, and transforming responses.

Installation

Installing ASKpy is as simple as:

@dansackett
dansackett / replify
Created August 19, 2016 18:16 — forked from danielrw7/ replify
replify - Create a REPL for any command
#!/bin/sh
command="${*}"
printf "Initialized REPL for [%s]\n" "$command"
printf "%s> " "$command"
read -r input
while [ "$input" != "" ];
do
eval "$command $input"
printf "\n%s> " "$command"
@dansackett
dansackett / 0_description.md
Last active June 12, 2016 23:55
Virtualenv and Virtualenvwrapper Setup

What this is

This is how we prefer to setup our environments at CodeZeus for Python and Django development. It uses virtualenv and virtualenvwrapper to contain dependencies and make the workflow more automatic.

PLAY [all] *********************************************************************
TASK [core : Install packages] *************************************************
failed: [default] (item=[u'language-pack-en', u'build-essential', u'zip', u'redis-server', u'npm', u'nodejs-legacy', u'libssl-dev', u'openssl', u'python-setuptools', u'mysql-server-5.6', u'nginx', u'php5-cli', u'php5-fpm', u'php5-gd', u'php5-mcrypt', u'php5-imap', u'php5-mysql', u'php5-curl', u'php5-json', u'php5-xdebug', u'php5-redis', u'php5-intl', u'ruby', u'ruby-dev', u'libsqlite3-dev', u'rubygems', u'bundler', u'curl', u'git', u'swaks']) => {"failed": true, "item": ["language-pack-en", "build-essential", "zip", "redis-server", "npm", "nodejs-legacy", "libssl-dev", "openssl", "python-setuptools", "mysql-server-5.6", "nginx", "php5-cli", "php5-fpm", "php5-gd", "php5-mcrypt", "php5-imap", "php5-mysql", "php5-curl", "php5-json", "php5-xdebug", "php5-redis", "php5-intl", "ruby", "ruby-dev", "libsqlite3-dev", "rubygems", "bundler", "curl", "git", "sw
@dansackett
dansackett / beautiful_idiomatic_python.md
Created December 14, 2015 17:31 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]: