Skip to content

Instantly share code, notes, and snippets.

View oscarmorrison's full-sized avatar

Oscar Morrison oscarmorrison

View GitHub Profile
@oscarmorrison
oscarmorrison / d3Importer.js
Last active March 6, 2024 12:50
Modularly import only the D3.js modules you require
import { line, curve, curveCatmullRom } from "d3-shape";
import { scaleTime, scaleLinear } from "d3-scale";
import { axisBottom, axisLeft } from 'd3-axis';
import { timeParse, isoFormat } from "d3-time-format";
import { select } from "d3-selection";
import { extent, max, min } from "d3-array";
export default {
line: line,
scaleTime: scaleTime,
@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 / 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'">
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 / server.py
Last active November 14, 2021 19:32
Python Cat Feeder two servos
#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
pinOutOne = 4
#set this two whatever your 2nd servo is in
pinOutTwo = 5
@oscarmorrison
oscarmorrison / heroku set .env .sh
Created July 29, 2017 17:32
Set you local config variables for remote heroku
heroku config:set `cat .env`
@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
@oscarmorrison
oscarmorrison / switchGitProtocol.sh
Created January 4, 2019 04:35
A quick bash script to change a repo from ssh to https and vice versa
echo "Opening git repo"
giturl=$(git config --get remote.origin.url)
giturl=$( tr '[A-Z]' '[a-z]' <<< $giturl)
if [[ $giturl == *"https"* ]]
then
echo "Switching repo remote origin url from HTTPS to SSH"
echo $giturl
giturl=${giturl#https://github.com/}
repo=${giturl/\.git}
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
@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]])