Skip to content

Instantly share code, notes, and snippets.

require "lifx" # http://rubydoc.info/github/lifx/lifx-gem/master/frames
def calculate_color(i) # 0 <= i <= 1
h = [40 * 2 * i, 40].min # will be 40 (yellow) at i=1/2 and stay there
s = 1.0 - [(i - 0.5) * 2, 0].max # will be 1 until i=1/2 and then go down to 0
b = i
LIFX::Color.hsbk(h, s, b, LIFX::Color::KELVIN_MIN)
end
duration = 30 * 60 # seconds
@bjeanes
bjeanes / README
Last active February 2, 2020 08:13 — forked from jnbt/repairMKV.sh
Synology-compatible script to repair mkv files
https://forums.plexapp.com/index.php/topic/63691-how-to-automated-linux-script-for-fixing-broken-mkv-files-works-with-sickbeard-too/
@bjeanes
bjeanes / pre-commit.sh
Last active December 17, 2015 02:39 — forked from proxypoke/pre-commit.sh
#!/bin/bash
# Author: slowpoke <proxypoke at lavabit dot com>
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
#
# A pre-commit hook for go projects. In addition to the standard
@bjeanes
bjeanes / 4bo.clj
Created August 29, 2012 21:03 — forked from gfredericks/4bo.clj
4Bo
(defn loud-numbers
[]
(take 10 (iterate (fn [x] (println "I'm adding to " x) (inc x)) 0)))
(defn less-lazy
([coll] (less-lazy coll 1)
([coll how-far]
(lazy-seq
(future (nth coll how-far))
(cons (first coll) (less-lazy (rest coll))))))
window.app = format: {}
app.format.DollarizesCents = ->
dollarize: (pennies) ->
amount = (pennies / 100.0).toFixed(2)
"$#{@commasFor(amount)}"
#private
commasFor: (dollars) ->
@bjeanes
bjeanes / example_its_lets.rb
Created November 21, 2011 14:50 — forked from richievos/1-before_spec.rb
Spectastrophe #1
# This assumes `is_appropriate?` is renamed to `appropriate?` which is more idiomatic anyway
describe FashionSituation do
describe "#is_appropriate?" do
context "when wearing only shorts" do
let(:wearing_only_shorts) { FashionSituation.new(:shirt => false, :shoes => false, :shorts => true, :location => location) }
subject { wearing_only_shorts }
context "at a restaurant" do
let(:location) { "restaurant" }
When /^(.*) in the "([^\"]*)" section$/ do |action, title|
within "//*[(h1|h2|h3|h4|h5|h6|legend|caption)/descendant-or-self::*[contains(text(), '#{title}')]]" do
When action
end
end
When /^(.*) in the "([^\"]*)" row$/ do |action, title|
within "//*[(th|td)/descendant-or-self::*[contains(text(), '#{title}')]]" do
When action
end
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
Daemons.run_proc('PassengerMonitor') do
command = 'sudo passenger-memory-stats'
memory_limit = 250
There are many like it.
@bjeanes
bjeanes / snippet.sh
Created January 16, 2009 23:29 — forked from drnic/snippet.sh
function parse_git_deleted {
[[ $(git status | grep deleted:) != "" ]] && echo "-"
}
function parse_git_added {
[[ $(git status | grep "Untracked files:") != "" ]] && echo '+'
}
function parse_git_modified {
[[ $(git status | grep modified:) != "" ]] && echo "*"
}
function parse_git_dirty {