Skip to content

Instantly share code, notes, and snippets.

View ForrestSutton's full-sized avatar

Forrest Sutton ForrestSutton

View GitHub Profile
import datetime
import pytz
#formula
utcnow = datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)
Edinburgh= utcnow.astimezone(pytz.timezone('Europe/London'))
east = utcnow.astimezone(pytz.timezone('US/Eastern'))
cent = utcnow.astimezone(pytz.timezone('US/Central'))
@ForrestSutton
ForrestSutton / ubuntu base install
Last active October 4, 2018 20:24
Ubuntu Default Setup
#!/bin/sh
echo 'installing Dev tools'
sudo apt-get install vim
sudo apt-get install curl
sudo apt-get install git
sudo apt-get install unzip
echo 'installing python tools'
sudo apt-get install python-pip
grep -E -o "\b[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+\b" filename.txt > new list uniq
grep -o '[[:alnum:]+\.\_\-]*@[[:alnum:]+\.\_\-]*' EMAIL_SAMPLES.TXT | sort | uniq -i > fixthese.txt
grep -o '[[:alnum:]+\.\_\-]*@[[:alnum:]+\.\_\-]*' bouncedEmail.csv | sort | uniq -i > fixthese2.txt
#this will grab a little after the email address
#!/bin/bash
#echo 'installing opensshserver '
#sudo apt-get install openssh-server
echo 'installing opensh-client '
sudo apt install openssh-client
echo 'installing vim'
sudo apt-get install vim
sudo apt-get install curl
sudo apt-get install git
@ForrestSutton
ForrestSutton / ubuntu command
Last active June 28, 2017 19:08
Debian/Ubuntu list all installed apps/packages
#to list installed apps
dpkg --get-selections | grep -v deinstall
#to copy list to a file
dpkg --get-selections | grep -v deinstall > mylist.txt
#to restore the packages/apps
dpkg --clear-selections
$ sudo dpkg --set-selections < mylist.txt
sudo apt-get install openssh-server
sudo apt-get install python-pip
sudo apt-get install python-pip3
envhost /
vim
ipython jupyter
@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;
@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 / 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
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