#extract words in parens from a string
value.match(/(.+)\((.*)\)(.+)/)[1].split(' ')[1]
#replace the following characters with empty string: , . - ( )
toUppercase(value).replace(/\,|\.|\-|\(|\)|\[|\]/, '')
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#db/seeds.rb | |
# Run 'rake db:seed' from terminal to create an Admin User in your database | |
#Seed DB with at least 1 Admin User | |
admin=User.new({ name: "Admin User", email: 'admin@rubyonrails.com', | |
password: 'password', password_confirmation: 'password'}) | |
admin.toggle!(:admin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ack is a tool like grep, designed for programmers with large trees of heterogeneous source code | |
#to install ack, see http://betterthangrep.com/ | |
#to use ack, launch terminal (mac osx) and type 'ack <some_keywords>' | |
#ack will search all files in the current directory & sub-directories | |
#here's how I have my config file setup. this file is located on mac osx here | |
# ~/.ackrc | |
# Always sort the files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export TERM=xterm-color | |
export CLICOLOR=1 | |
export GREP_OPTIONS='--color=auto' | |
# export LSCOLORS=Exfxcxdxbxegedabagacad | |
export LSCOLORS=gxfxcxdxbxegedabagacad # Dark lscolor scheme | |
# Don't put duplicate lines in your bash history | |
export HISTCONTROL=ignoredups | |
# increase history limit (100KB or 5K entries) | |
export HISTFILESIZE=100000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set completion-ignore-case on | |
#use up arrow to search history backwards | |
"\e[A": history-search-backward | |
"\e[B": history-search-forward | |
$if Bash | |
Space: magic-space | |
$endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(RPostgreSQL) #import the library | |
driver <- dbDriver('PostgreSQL') #define the database driver | |
db <- dbConnect(driver, host='foobar_host', #set the host to the postgreSQL IP or alias | |
user='foo_bar', #input username | |
password='my_secret_code', #input your password | |
dbname='my_gp_db') #input the name of the databse | |
myquery <- "SELECT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env python | |
# Handling NA values in pandas | |
import pandas as pd | |
# replace all NA values with your own missing value | |
my_data_frame['my_column'].fillna('MY_MISSING_VAL') | |
# return a subset of your dataframe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
# look at free reports | |
free = df[df.report_name.isin(free)] | |
# look at paid reports only | |
paid = df[df.report_name.apply(lambda x: x not in free)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from yhat import Yhat, BaseModel | |
from sklearn import datasets | |
from sklearn.svm import SVC | |
class IrisModel(yhat.BaseModel): | |
def transform(self, data): | |
data = [ | |
data['SepalLength'], | |
data['SepalWidth'] / 2.0, | |
data['PetalLength'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install yhat |
OlderNewer