Skip to content

Instantly share code, notes, and snippets.

View raineorshine's full-sized avatar

Raine Revere raineorshine

  • New York, NY
View GitHub Profile
@raineorshine
raineorshine / bash-cheatsheet.sh
Last active April 4, 2018 18:45
Bash Cheat Sheet
type git # get the type of any command. Great for
# seeing if a command exists.
ls -t # sort by time, newest first
ls -tr # sort by time, oldest first
grep -r "test" FILE_OR_DIR # recursive full text search
grep -i "test" FILE # case insensitive
grep -c "pattern" FILE # count
grep -n "pattern" # show line numbers
@raineorshine
raineorshine / python-cheat-sheet.py
Created November 8, 2013 17:05
Python Cheat Sheet
# importing
import sha # import the the sha module
from animal import Animal # import the Animal class from animal.py
# unit testing
# http://docs.python.org/3/library/unittest.html
import unittest
class AnimalTest(unittest.TestCase):
// change 0 to go to bol not hardbol (COMMAND MODE)
{
"keys": ["0"],
"command": "move_to",
"args": {
"to": "bol"
},
"context": [{ "key": "setting.command_mode", "operand": true }, { "key": "setting.is_widget", "operand": false }]
},
@raineorshine
raineorshine / cake-vs-gulp.md
Last active August 29, 2015 13:56
Cake vs Gulp

Cake

  • Doesn't output stdout or stderr of task commands automatically, so you have to do something like this:

     {print} = require 'util'
     {spawn} = require 'child_process'
     
     task 'build', 'Build js/ from src/', ->
     	coffee = spawn 'coffee', ['-c', '-o', 'js', 'src']
     	coffee.stderr.on 'data', (data) ->
@raineorshine
raineorshine / built-in.md
Created March 12, 2014 18:23
55 Must Know Built-In Javascript Methods and Operators
@raineorshine
raineorshine / serializeArrayToObject.js
Created March 12, 2014 18:26
Convert the results from jQuery's serializeArray to an object.
var formData = $('#myform').serializeArray();
_.merge.apply(_, formData.map(function(o) { var kvp={}; kvp[o.name] = o.value; return kvp; }))
@raineorshine
raineorshine / _sublime-cheat-sheet.md
Last active October 26, 2020 08:05
Sublime Cheat Sheet

Selection and Navigation

⌘D                Multi-select
⌘K,⌘D             Skip the current match and select the next one
⌘U                Soft Undo
⌘ + Ctrl + G      Select all occurences under cursor
⌘P                Jump to files
⌘L                Select Line
⌘ + Shift + L     Convert Selection to Multi-select

⌘ + Shift + J Select all lines at current indentation

@raineorshine
raineorshine / better-passport.js
Created March 12, 2014 18:37
Ideation for better PassportJS.
app.use(auth({
clientID: 'FACEBOOK_APP_ID',
clientSecret: 'FACEBOOK_APP_SECRET',
sessionSecret: 'SESSION_SECRET',
userCollection: 'User',
callback: '/callback',
login: '/login',
// login: function(done) {
// auth.login({
// role: req.query.role
@raineorshine
raineorshine / multiline.txt
Last active October 12, 2015 21:39
3 common use cases for mongoimport
[{
"name": "Raine"
},
{
"name": "Chris"
},
{
"name": "Gene"
}]
@raineorshine
raineorshine / d3-gapminder-improved.js
Created March 13, 2014 16:04
Some suggestions for improving the asynchronous part of https://github.com/gdiboulder/d3-gapminder.
// NOTE: The below is pseudo-code. You may need to make some adjustments to
// function signatures to use an asynchronous library like async.js
// these functions can be made truly asynchronous by accepting a callback
// this is preferrably to daisy chaining them, which is too tight a coupling
dv.get.gdp = function(cb) {
d3.csv('data/gdp.csv', function(error, data) {
dv.setup.massage(data, 'gdp');
cb(error, data);
});