Skip to content

Instantly share code, notes, and snippets.

View schie's full-sized avatar
:octocat:
doing stuff

Dustin Schie schie

:octocat:
doing stuff
View GitHub Profile
@schie
schie / git-alias.sh
Created October 31, 2018 21:18
git aliases
# In .bashrc, .bash_profile, .zshrc, insert following the following
alias g=git
alias ga='git add'
alias gaa='git add --all'
alias gapa='git add --patch'
alias gau='git add --update'
alias gb='git branch'
alias gba='git branch -a'
alias gbd='git branch -d'
@schie
schie / string-to-color.js
Created February 3, 2018 18:35
Converting a random string to a hex color
function stringTColor(str) {
let hash = 0;
for (let i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
let color = '#';
for (let i = 0; i < 3; i++) {
let value = (hash >> (i * 8)) & 0xFF;
color += ('00' + value.toString(16)).substr(-2);
}
@schie
schie / docker-commands.md
Created October 23, 2017 22:48
Useful Docker Commands

Delete All Containers

$ docker rm $(docker ps -a -q)

Delete All Images

$ docker rmi $(docker images -q)
@schie
schie / query-string-form-fill.js
Created September 28, 2017 18:33
Setting form fields with query string
function parseSearchString () {
var qs = window.location.search
qs = qs.replace(/^\?/,'')
var parts = qs.split('&')
var params = {}
parts.forEach(function (part) {
var pair = part.split('=')
params[pair[0]] = decodeURIComponent(pair[1])
})
return params
@schie
schie / Dockerfile
Created January 27, 2016 05:04
Dockerfile example for hubot with slack adapter
FROM node:latest
MAINTAINER Dustin Schie, [email protected]
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
@schie
schie / hc-sr04.ino
Created December 4, 2015 02:09 — forked from flakas/hc-sr04.ino
Modified Arduino Ping))) example to work with 4-Pin HC-SR04 Ultrasonic Sensor Distance Measuring Module
/* HC-SR04 Sensor
https://www.dealextreme.com/p/hc-sr04-ultrasonic-sensor-distance-measuring-module-133696
This sketch reads a HC-SR04 ultrasonic rangefinder and returns the
distance to the closest object in range. To do this, it sends a pulse
to the sensor to initiate a reading, then listens for a pulse
to return. The length of the returning pulse is proportional to
the distance of the object from the sensor.
The circuit:
@schie
schie / LCD_Blinker.ino
Created December 2, 2015 04:05
Arduino Blinker w/ LCD KeyPad Shield
#include <LiquidCrystal.h>
// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// define some values used by the panel and buttons
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
@schie
schie / test
Created September 25, 2015 19:04
test
test
@schie
schie / TurtleExample.py
Created September 18, 2015 03:27
Example of using turtle, python's built-in graphics module
# Example of using turtle, python's built-in graphics module
# import turtle with a new name
# who wants to write out t-u-r-t-l-e that many times?
import turtle as t
t.speed(5) # speed
t.pensize(5) # thickness
# convenience method for drawing circles
@schie
schie / ClassExample.py
Created September 18, 2015 02:53
Example of how classes work in python
# import the math module (this will be used in Circle class)
import math
# created a generic shape class
class Shape:
# the function to initialize the shape
def __init__(self, width, height):
# the properties of the shape
self.width = width
self.height = height