Skip to content

Instantly share code, notes, and snippets.

View murphybytes's full-sized avatar

John Murphy murphybytes

View GitHub Profile
@murphybytes
murphybytes / motion_sensor.ino
Created December 22, 2012 17:46
This Arduino sketch is used to interact with a motion sensor.
int led_pin = 13;
int pir_pin = 2;
int pir_state = LOW;
int pin_status = 0;
void setup() {
pinMode( led_pin, OUTPUT );
pinMode( pir_pin, INPUT );
Serial.begin(9600);
@murphybytes
murphybytes / remove.c
Last active December 15, 2015 01:59
My implementation of an O(n) algorithm that removes characters from a string.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main( int argc, char* argv[] ) {
if( argc < 3 ) {
printf( "Usage: repl <word> <char to replace>\n" );
return 1;
@murphybytes
murphybytes / gist:5490197
Created April 30, 2013 17:11
Typical chef client configuration
log_level :info
log_location STDOUT
node_name 'east-prod-jumpserver'
export PATH=/Applications/Postgres93.app/Contents/MacOS/bin:$PATH
@murphybytes
murphybytes / fwr
Created June 23, 2014 15:47
Search ruby files for text
#!/bin/bash
echo "Search ruby files containing $1 in $(pwd)"
for f in `find . -name '*.rb'`; do grep -nH $1 $f; done
@murphybytes
murphybytes / gist:b13c8daa4fd3800d369b
Created September 8, 2014 17:15
Git Config with log graphs
[alias]
lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit
[core]
excludesfile = /Users/a918144/.gitignore_global
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
@murphybytes
murphybytes / gist:9fd38aa221f07f95553c
Created May 27, 2015 22:58
Create Field Selector
<script>
console.log( "creating field selector" );
var field_selector = new Agsolver.FieldSelector( {
map_div_id: 'map',
geoserver_url: "<%= ENV['GEOSERVER_URL'] %>",
editable: true,
input_div_id: 'prospector_field_map_coords_as_geojson'
});
</script>
if idIf, ok := m.Data["id"]; ok {
switch idIf.(type) {
case float64:
id := int64(idIf.(float64))
c.hMu.Lock()
defer c.hMu.Unlock()
if ch, ok := c.handler[id]; ok {
@murphybytes
murphybytes / main.go
Created February 29, 2016 01:35
Grid Search in Go
package main
import "fmt"
func newMatrix(r int) []string {
grid := make([]string, 0, r)
for j := 0; j < r; j++ {
var s string
fmt.Scan(&s)
@murphybytes
murphybytes / flat.rb
Created March 12, 2016 07:47
Flatten
#!/usr/bin/env ruby
# Adds new method to the Array class that flattens arrays of ints
# non-integer elements in the array will raise
# an exception.