Skip to content

Instantly share code, notes, and snippets.

View oscarmorrison's full-sized avatar

Oscar Morrison oscarmorrison

View GitHub Profile
var isbns = ['ISBN 0-330-28498-3',
'ISBN 1-58182-008-9',
'ISBN 2-226-05257-7',
'ISBN 3-7965-1900-8',
'ISBN 4-19-830127-1',
'ISBN 5-85270-001-0',
'ISBN 978-600-119-125-1',
'978-601-7151-13-3',
'ISBN 978-602-8328-22-7',
'ISBN 978-603-500-045-1',
@oscarmorrison
oscarmorrison / Return first Image from HTML Content
Last active February 7, 2016 21:01
Return first Image from HTML Content
var getFristImage = function(content) {
var el = document.createElement( 'html' );
el.innerHTML = content;
return el.getElementsByTagName( 'img' )[0].src;;
};
@oscarmorrison
oscarmorrison / IFTTTDate.md
Last active December 3, 2023 21:44
Make IFTTT Date Format play nice with Google Spreadsheets

##Date and Time

=TIMEVALUE(SUBSTITUTE("{{OccurredAt}}"," at ", " ")) + DATEVALUE(SUBSTITUTE("{{OccurredAt}}"," at ", " "))

##Date

=DATEVALUE(SUBSTITUTE("{{OccurredAt}}"," at ", " "))

##Time

@oscarmorrison
oscarmorrison / Bash Profile Backup
Last active May 3, 2019 07:33
Bash Profile Backup
export PS1="\e[44mogem@local:\e[m \w \[$txtcyn\]\$git_branch\[$txtrst\] \n$ "
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
export GITAWAREPROMPT=~/.bash/git-aware-prompt
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export PATH=$PATH:~/.scripts/
export PATH=$PATH:/usr/local/bin
export PATH="$HOME/.node/bin:$PATH"
source $GITAWAREPROMPT/main.sh
import subprocess
raw_location = subprocess.check_output("whereami", shell=False)
raw_location = raw_location.split()
lat = raw_location[1]
lon = raw_location[3]
hashtag = "#latlon"+lat+"__"+lon
command = "echo "+ "\'" + hashtag + "\' | pbcopy"
p = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE)
p.stdin.write(hashtag)
p.stdin.close()
@oscarmorrison
oscarmorrison / getDate.js
Created November 1, 2015 23:41
Javascript get current date
//"YYYY-MM-DD hh:mm"
function zeroFill(i){
return (i<10 ? '0' : '') + i;
}
var getDate = function(){
var d = new Date();
var year = d.getFullYear();
var month = zeroFill(d.getMonth())
var day = zeroFill(d.getDate())
@oscarmorrison
oscarmorrison / TimeinWords.rb
Created September 12, 2015 07:37
Time in Words (Ruby)
def get_word(num)
teen = "teen"
case num
when 0; return "o' clock"
when 1; return "one"
when 2; return "two"
when 3; return "three"
when 4; return "four"
when 5; return "five"
when 6; return "six"
@oscarmorrison
oscarmorrison / brute_search.rb
Created September 6, 2015 06:07
Brute Force String Pattern matching in Ruby
sentence = "soijasdoijasdiojfuhfuhsdfhoscaroijasdoijasdijd"
n = sentence.length
key = "oscar"
l = key.length
i = 0
while i < n do
j = 0
puts sentence[i]
@oscarmorrison
oscarmorrison / gist:4c9b156ec3f1c4d9d0c2
Created June 28, 2015 12:29
String to Int/Double/Float
var intString = "10"
var numberInt = intString.toInt()
var numberString = "10.1"
var numberDouble = (numberString as NSString).doubleValue
var numberFloat = NSString(string: numberString).floatValue
@oscarmorrison
oscarmorrison / gist:80a448f266d89508bd6f
Last active August 29, 2015 14:20
Parse objects from PFQuery and Store only objects != current user
var usernames = [PFUser]()
var currentUser = PFUser.currentUser()
override func viewDidLoad() {
super.viewDidLoad()
var query = PFUser.query()
query?.findObjectsInBackgroundWithBlock({ (objects, error: NSError?) -> Void in
if error == nil{
for username in objects as Array!{
if(self.currentUser?.objectId != username.objectId){