Skip to content

Instantly share code, notes, and snippets.

@alyssaq
alyssaq / sort_objects.js
Last active February 13, 2024 07:57
Sort object property keys in Javascript
function objectToArray(obj) {
var keys = Object.keys(obj);
return keys.map(function(key) {
return [key, obj[key]];
});
}
function arrayToObject(arr) {
var obj = {};
arr.forEach(function(tuple) {
@alyssaq
alyssaq / commands.md
Last active August 29, 2015 14:05
Useful Unix commands

Case insensitive search for files in Documents with name starting with stuff.

$ find ~/Documents -iname stuff\* -ls

Recursively finding the string 'stuff' ignoring case from dir

$ grep -R -i Stuff /path/to/dir

STDIN, STDOUT, and STDERR = 0, 1, 2. So, 2>&1 means error redirecting to output

<!DOCTYPE html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.4.8/fabric.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<canvas id="c" width="400" height="400"></canvas>
@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>
@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 / 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 / index.html
Last active February 13, 2024 07:55
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 / brew.sh
Last active August 29, 2015 14:02
python3-requirements.txt
brew install gcc
brew install freetype #for matplotlib
@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 / 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"