#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
#!/usr/bin/osascript | |
(* subroutine to bring an application to front. | |
you could invoke it from an alias in your | |
~/.bash_profile, another script or an alfred workflow | |
*) | |
property default_app : "" | |
on bring_to_front(app_name) | |
set res to false |
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
Map<String, Schema.SObjectField> field_objmap = schema.SObjectType.Opportunity.fields.getMap(); | |
List<Schema.SObjectField> field_objmap_values = field_objmap.values(); | |
List<String> field_names_list = new List<String>(); | |
for(Schema.SObjectField s : field_objmap_values) { | |
String field_label = String.valueOf(s.getDescribe().getLabel()); // Perhaps store this in another map | |
String field_name = String.valueOf(s.getDescribe().getName()); | |
String field_type = String.valueOf(s.getDescribe().getType()); | |
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 | |
# -*- coding: utf-8 -*- | |
"""atbash.py | |
""" | |
from string import letters | |
def atbash(txt): | |
sub_table = zip(letters[:26], "".join(reversed(letters[:26]))) | |
sub_table += zip(letters[26:], "".join(reversed(letters[26:]))) | |
sub_table = dict(sub_table) |
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 |
I hereby claim:
- I am hernamesbarbara on github.
- I am hernamesbarbara (https://keybase.io/hernamesbarbara) on keybase.
- I have a public key whose fingerprint is 8D83 4863 3195 7A45 4D2C 9BEF BE6B 90F3 C6E1 8518
To claim this, I am signing this object:
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'], |