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
#blog.oscarmorrison.com | |
#Cat feeder (open and close server) | |
#change the pin, and port here. | |
from flask import Flask, jsonify | |
import RPi.GPIO as IO | |
import time | |
pinOut = 4 | |
app = Flask(__name__) |
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
const uniqueArray = function(array) { | |
return array.filter(function (item, pos) { | |
return array.indexOf(item) == pos; | |
}) | |
} |
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
$('a[href^=http]').each(function(){ | |
if(this.href.indexOf(location.hostname) < 0) { | |
$(this).attr({target: '_blank'}); | |
} | |
}); |
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
/*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, |
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/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]]) |
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
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 = []; |
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
# 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 |
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
<img src="img/missing-image.png" onerror="javascript:this.src='img/default.png'"> |
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
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++; | |
} | |
} |
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
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; |