Skip to content

Instantly share code, notes, and snippets.

@alyssaq
alyssaq / dashtozeros.py
Last active August 29, 2015 14:01
Pandas: Remove percentages and strings and convert to float
# Preprocessing: Convert '--' to 0
number_re = re.compile(r'\s?--')
str2float = lambda x: x if np.isreal(x) else number_re.sub('0', x, re.U)
data[key] = data[key].map(str2float).astype(float)
@alyssaq
alyssaq / install_PIL.sh
Last active August 29, 2015 14:01
Installing PIL with jpeg support for Mac OSX Mavericks
# http://stackoverflow.com/questions/8915296/python-image-library-fails-with-message-decoder-jpeg-not-available-pil
# Jpeg support
brew install libjpeg
# Install PIL
sudo RCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install PIL --allow-external PIL --allow-unverified PIL
# Generate ssh key with your email
ssh-keygen -t rsa -C "[email protected]"
# For github: Add your key to github
# For heroku: type the command
heroku keys:add
heroku keys # list your keys
# List your added ssh keys
ssh-add -l
@alyssaq
alyssaq / bash_profile.sh
Last active August 29, 2015 14:01
Fresh Mavericks Install
# alias
alias ls='ls -hBG'
alias ll='ls -lAhBG'
alias pyserver='python -m SimpleHTTPServer 8888'
export LSCOLORS=ExGxBxDxCxEgEdxbxgxcxd
alias emacs='/usr/local/Cellar/emacs/HEAD/bin/emacsclient'
alias startemacs='/Applications/Emacs.app/Contents/MacOS/Emacs'
export GIT_EDITOR="subl --wait --new-window"
@alyssaq
alyssaq / Python-nosetests.sublime-build
Last active August 29, 2015 14:02
sublime settings
{
"cmd": ["nosetests", "-s", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"working_dir": "/Users/bun/Documents/<project_dir>",
"path" : "/usr/local/bin"
}
@alyssaq
alyssaq / brew.sh
Last active August 29, 2015 14:02
python3-requirements.txt
brew install gcc
brew install freetype #for matplotlib
@alyssaq
alyssaq / index.html
Last active September 3, 2024 20:59
HTML5 skeleton template
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>App</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script charset="utf-8" src="js/app.js"></script>
<link rel="stylesheet" href="css/app.css" />
</head>
<body>
@alyssaq
alyssaq / ui-patterns
Created July 11, 2014 11:24
UI Patterns
Interacting with data stores:
- Restful API access
- Local storage
Rendering data to ui: Views
Models:
- Represent your data: POJO
- Read/write properties on the data
- Persist data to the server
- Responding to user interaction/
event listeners that fire when data changes
@alyssaq
alyssaq / jsbin.yokaxi.css
Last active February 13, 2024 07:57
Bouncing smiley face
.smile {
position: absolute;
top: 0;
left: 60%;
width: 100px;
height: 100px;
margin-left: -50px;
}
@-webkit-keyframes circle {
@alyssaq
alyssaq / highlight.txt
Last active February 13, 2024 07:57
Sublime text/template highlight
To support HTML highlighting of underscore/handlebar/html templates in Sublime Text 2:
Sublime > Preferences > Browse Packages...
Open HTML > HTML.tmLanguage
Line 286:
Comment:
<!-- <string>(?:^\s+)?(&lt;)((?i:script))\b(?![^&gt;]*/&gt;)</string> -->
Add:
<string>(?:^\s+)?(&lt;)((?i:script))\b(?![^&gt;]*/&gt;)(?!.*type=["']text/*.(template|html)['"])</string>