Skip to content

Instantly share code, notes, and snippets.

View ForrestSutton's full-sized avatar

Forrest Sutton ForrestSutton

View GitHub Profile
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@ForrestSutton
ForrestSutton / git setup on ubuntu
Last active October 28, 2016 19:34
Git setup on Linux
sudo apt-get install curl git -y
sudo aptitude install git-completion
git config --global color.ui "auto"
git config --global user.name "Forrest Sutton"
git config --global user.email "<email>@gmail.com"
ssh-keygen -t dsa -C "<email>@gmail.com"
@ForrestSutton
ForrestSutton / mongodb commands
Created May 9, 2013 13:27
mongodb commands
//start mongodb
mongod --dbpath data
mongoimport --db opendata --collection atlenergy < energy_wb.json
#restore database from mongodump
mongorestore --collection col --db opendata opendata/col.bson
@ForrestSutton
ForrestSutton / mysql.mysql
Last active December 4, 2019 16:52
Mysql Recipes
#split a name into three parts. you can also compare fname and mname when mname is blank
SELECT initialimport.CustomerNumber as CustNumb,
SUBSTRING_INDEX(SUBSTRING_INDEX(ContactPerson, ' ', 1), ' ', -1) as fname,
SUBSTRING_INDEX(SUBSTRING_INDEX(ContactPerson, ' ', 2), ' ', -1) as mname,
SUBSTRING_INDEX(SUBSTRING_INDEX(ContactPerson, ' ', 3), ' ', -1) as lname
FROM initialimport;
@ForrestSutton
ForrestSutton / railsMongodb
Created May 25, 2013 18:48
rails and mongo db
-O, [--skip-activerecord] # Skip Active Record files
-J, [--skip-prototype] # Skip Prototype files
-T, [--skip-testunit] # Skip Test::Unit files
You can get a complete list of all the available options by running the command:
$ rails new --help
Creating the app
$ sudo gem install rails
rails new YourApp -OJT
the Hash Rocket syntax (:foo => "bar")
is deprecated in favor of the new-to-Ruby JSON-style hash (foo: "bar")
run inside project
rvm use 1.9.3-p327@rails3 --rvmrc
rails new APP -T
rails generate controller Users new --no-test-framework
rails generate model User name:string email:string --no-test-framework
rails _3.2.13_ new demo #when the sytem has rails 4 but you want rails 3.2
@ForrestSutton
ForrestSutton / mongoHW
Created July 2, 2013 15:58
mongo for programmers
import pymongo
import sys
import traceback
# establish a connection to the database
connection = pymongo.Connection("mongodb://localhost", safe=True)
# get a handle to the school database
db=connection.school
students = db.students
@ForrestSutton
ForrestSutton / googleAppDrive
Created September 18, 2013 19:24
google app engine and google drive api
https://github.com/ahmednuaman/gdrive-cms-py-gae
http://developer.android.com/training/basics/activity-lifecycle/pausing.html
#speed test from the command line
wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip
#kinn bikes
http://www.kickstarter.com/projects/kinnbikes/kinn-a-fast-family-friendly-transport-bike?ref=tag
@ForrestSutton
ForrestSutton / postgres cheat sheet
Last active June 17, 2016 17:17
postgres reference
#change to postgres user and open psql prompt
sudo -u postgres psql postgres`
#list databases
postgres=# \l
#list roles
postgres=# \du
#create role
postgres=# CREATE ROLE demorole1 WITH LOGIN ENCRYPTED PASSWORD 'password1' CREATEDB;
sudo apt-get install openssh-server
sudo apt-get install python-pip
sudo apt-get install python-pip3
envhost /
vim
ipython jupyter