Skip to content

Instantly share code, notes, and snippets.

View oscarmorrison's full-sized avatar

Oscar Morrison oscarmorrison

View GitHub Profile
@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 / 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;;
};
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 / CreditCardCheckSum.js
Last active April 1, 2016 15:19
Credit Card CheckSum Javascript
function checksumCC(creditCardString){
sum = creditCardString
.split('')
.reverse()
.reduce(function(total, num, i){
num = parseInt(num, 10);
if(i%2 !== 0){
num *= 2;
if(num>9){
num -= 9;
@oscarmorrison
oscarmorrison / String Match.
Last active April 30, 2016 03:47
String Match. Match two strings with a tolerence
function matchString(stringOne, stringTwo, tolerance){
stringOne = stringOne.toLowerCase().replace(/ /g,'');
stringTwo = stringTwo.toLowerCase().replace(/ /g,'');
var minLen = Math.max(stringOne.length, stringTwo.length);
var bigLen = Math.min(stringOne.length, stringTwo.length);
for(var i = 0, count = 0; i < minLen; i++){
if(stringOne[i] === stringTwo[i]){
count++;
}
}
@oscarmorrison
oscarmorrison / missing-image.html
Created June 4, 2016 03:38
html backup image
<img src="img/missing-image.png" onerror="javascript:this.src='img/default.png'">
@oscarmorrison
oscarmorrison / openWaffle.sh
Last active June 5, 2016 16:38
Open Waffle from Repository
# https://github.com/youUsername/repoName.git
# https://waffle.io/youUsername/repoName
url=$(git config --get remote.origin.url)
url=$( tr '[A-Z]' '[a-z]' <<< $url)
url=${url%.git}
url="${url/github.com/waffle.io}"
echo $url
open $url
var fs = require('fs');
var filePath = 'js/data/data.json';
var outputPath = 'sitemap.xml';
var date = new Date().toISOString();
var header = '<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">\n';
var baseUrl = 'http://getfreestuff.co/';
fs.readFile(filePath, 'utf8', function(err, data){
var json = JSON.parse(data);
var urls = [];
@oscarmorrison
oscarmorrison / gist:6ebd9344e16448121ef4a5cdea1427b4
Created November 6, 2016 14:02
Kankun plug gist for MacOS (OSX)
#!/usr/bin/python
import os
import socket
import sys
def encode_packet(data):
output = bytearray()
for i in range(0, len(data)):
tmpoutput = bytearray([0, data[i]])
@oscarmorrison
oscarmorrison / mysportsclubactivitydetails.js
Created November 11, 2016 14:44
Boston Sports Club Scrape
/*jslint node: true */
/*jshint esversion: 6 */
'use strict';
var Nightmare = require('nightmare');
var moment = require('moment');
var debug = false;
var nightmare = new Nightmare({
show: debug,