Skip to content

Instantly share code, notes, and snippets.

View parabuzzle's full-sized avatar

Mike Heijmans parabuzzle

View GitHub Profile
validate :test
def test
unless column.nil?
...do your test...
end
return true
end
@parabuzzle
parabuzzle / ardy.pde
Created December 2, 2011 21:39
Simple arduino interface for LED manipulation based on monitoring.
// simple interface expecting data from serial
// provided by ardy.rb
//
// pin states:
// 48 = ok
// 49 = bad
//
// originated by mike heijmans
int ledPin = 13; // which pin do I control?
#!/usr/bin/env ruby
require 'json'
ARGV.each do |file|
begin
JSON.parse(File.open(file).read)
puts "you're good! :: #{file}"
rescue
puts "FAIL! :: #{file}"
@parabuzzle
parabuzzle / drainswap.sh
Created August 27, 2014 12:41
drainswap
#!/bin/bash
free_data="$(free)"
mem_data="$(echo "$free_data" | grep 'Mem:')"
free_mem="$(echo "$mem_data" | awk '{print $4}')"
buffers="$(echo "$mem_data" | awk '{print $6}')"
cache="$(echo "$mem_data" | awk '{print $7}')"
total_free=$((free_mem + buffers + cache))
used_swap="$(echo "$free_data" | grep 'Swap:' | awk '{print $3}')"
@parabuzzle
parabuzzle / jekyll_dev.rb
Last active August 29, 2015 14:06
A simple little ruby script for starting a jekyll server and builder
#!/bin/env ruby
require 'thread'
# Set the process name
$0 = 'jekyll_dev'
# Environment
ENV['JEKYLL_WITH_DRAFTS'] ||= 'true'
@parabuzzle
parabuzzle / gist:74ccc41c7712fd12d45a
Last active August 29, 2015 14:06
User config for sublime
{
"tab_size": 2,
"translate_tabs_to_spaces": true,
"ensure_newline_at_eof_on_save": true
}
@parabuzzle
parabuzzle / rebase
Created October 13, 2014 16:55
rebase my current branch off of master!
alias rebase!="git rebase -i `git merge-base \`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'\` master`"
{
"tab_size": 2,
"translate_tabs_to_spaces": true,
"color_scheme": "Packages/User/Colorsublime/themes/Merbivore.tmTheme",
"ensure_newline_at_eof_on_save": true,
"trim_trailing_white_space_on_save": true,
"rulers":
[
80,
120
require 'httparty'
hipchat_token = ENV['HIPCHAT_TOKEN']
hipchat_email = ENV['HIPCHAT_EMAIL']
hipchat_api = ENV['HIPCHAT_API'] || 'api.hipchat.com'
url = "https://#{hipchat_api}/v2/user/#{hipchat_email}?auth_token=#{hipchat_token}"
user = JSON.parse HTTParty.get(url).body
@parabuzzle
parabuzzle / mensa_number.rb
Created March 21, 2015 17:37
Mensa number question
#!/usr/bin/env ruby
# Find a SIX digit number in which the FIRST digit is ONE more than the THIRD,
# the SECOND digit is ONE less than the FOURTH, the FIFTH digit is ONE less than
# the THIRD, and the SIXTH digit is ONE more than the FOURTH. The sum of the
# SECOND and THIRD digits equal the FIRST. The sum of all digits is 30.
# Returns 6 digit numbers that the sum of the digits are 30
def possible_numbers
numbers = []