Skip to content

Instantly share code, notes, and snippets.


Oscar Morrison oscarmorrison

View GitHub Profile
oscarmorrison /
Created Jan 4, 2019
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"* ]]
echo "Switching repo remote origin url from HTTPS to SSH"
echo $giturl
oscarmorrison /
Last active Nov 14, 2021
Python Cat Feeder two servos
#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
View gist:570cb3c739f5e948f617eccdad2c87cc
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See for all currently supported options.
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
oscarmorrison / heroku set .env .sh
Created Jul 29, 2017
Set you local config variables for remote heroku
View heroku set .env .sh
heroku config:set `cat .env`
oscarmorrison / d3Importer.js
Last active Oct 7, 2022
Modularly import only the D3.js modules you require
View d3Importer.js
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 / getParamsFromSearchURL.js
Last active Jul 6, 2017
Get params from search url
View getParamsFromSearchURL.js
const getParamsFromSearchURL = url => url.slice(1).split('&').reduce((params, pairs) => {
const [key, value] = pairs.split('=');
key && value && (params[key] = getValue(value));
return params;
}, {});
// this parses foo=true -> make true a bool, not a string
const getValue = value => {
value = decodeURIComponent(value);
try {
oscarmorrison /
Created May 26, 2017 — forked from hew/
Operator Mono w/ Italics on OSX VIm

Operator Mono w/ Italics on OSX Vim

oscarmorrison / validateEmail.js
Last active May 27, 2017
ES6 email validation
View validateEmail.js
// regex from
const EMAIL_REGEX = /^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-?\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/;
const validateEmail = email => {
return email
&& email.length < 255
&& EMAIL_REGEX.test(email);
export default validateEmail;
View gist:a758b9ca4ae654e5afe4dd2f75081c3c
<!DOCTYPE html>
<script src=""></script>
var data = [4,8,15,16,23,42];
<style type="text/css">
oscarmorrison / countWordsInText.js
Last active Jan 14, 2017
count the words in a string, and order by popularity
View countWordsInText.js
let text = "There’s an interesting discussion on Quora about the differences between Golang and Scala. As a former academic with tendencies towards functional programming, I used to be very tempted by Scala.1 It offers all the functional goodness without the exoticism of Haskell, and came with reasonably good tools and frameworks. Like Clojure, it’s a functional language you can actually do some work with. The problem with Scala is, the more advanced you get, the more complicated (unreadable?) your code becomes. I remember that back in grad school the dude who was able to doodle the craziest and mathematically most challenging solution to some problem in Haskell was someone everyone looked up to. But it turns out in the “real world” simplicity always trumps virtuosity and sophistication, which is one of the many reasons I love Golang so much. A language with no “magic,” good concurrency support, great documentation and community that compiles into machine code and runs faster than Python? Yes, please. Read th