Skip to content

Instantly share code, notes, and snippets.

namespace :update do
task :services do
REPOS.each do |repo_path|
uncommitted_files = `cd #{repo_path} && git status --porcelain | wc -l`.strip.chomp.to_i
if uncommitted_files == 0
puts "Updating #{repo_path} ..."
puts `cd #{repo_path} && BUNDLE_GEMFILE=#{repo_path}/Gemfile bundle update config-gem`
@redroot
redroot / broken.rb
Last active August 29, 2015 14:01
How to get bundler command line working inside bundle exec
namespace :update do
task :services do
REPOS.each do |repo_path|
uncommitted_files = `cd #{repo_path} && git status --porcelain | wc -l`.strip.chomp.to_i
if uncommitted_files == 0
puts "Updating #{repo_path} ..."
puts `cd #{repo_path} && bundle update config-gem`
@redroot
redroot / Button Code
Last active August 29, 2015 14:01
Arduino Dumping Ground
int motorA = 3;
int button = A0;
int motorValue = 130;
// set voltage in power supply to 7.1, current fll (0.15k)
void setup()
{
pinMode(button, OUTPUT);
Serial.begin(9600);
}
@redroot
redroot / gist:baafafed43dc6269904f
Created May 4, 2014 23:32
SASS & directive example
.box {
padding: 10px;
...
&.is-active {
}
&.is-inactive {
@redroot
redroot / gist:6d61068c8f89ce34041d
Created May 4, 2014 23:29
Something for a web post
<div class='box box-light'>
<div class='box-title'>...</div>
<div class='box-inner'>...</div>
</div>
@redroot
redroot / gist:3c7948ec92ecbd3bdf1d
Created May 4, 2014 23:18
Example JS Module pattern
var Header = (function(w,d,undefined)){
var _elem = null;
var bindButtons = function(){
$(document).on('click', _elem.find(".js-toggle-sidebar"), function(){
Sidebar.toggle(); //
});
}
@redroot
redroot / gist:8932682
Last active August 29, 2015 13:56
NewRelic: Delete Servers with No Data
window.confirm = function() {
console.log.apply(console, arguments); return true;
};
$(".host_status[data-traffic_light_level=3], .host_status[data-traffic_light_level=4]").each(function(i,el){
var p = $(this).parent();
var del = $(p).find(".delete_link.to_spinner");
var no_data = $(p).find(".no_data").length > 0;
if(no_data && del.length > 0){
setTimeout(function() {
console.log($(p).find(".app_name").text());
# name: rick
# description: The best bolt
# keyword: rick
result(title:"rick", description:"No strangers to love", action: actions.open("http://www.youtube.com/watch?gl=GB&hl=en-GB&v=oHg5SJYRHA0"))
@redroot
redroot / gist:4997131
Created February 20, 2013 17:06
Example Wordpress Customiser Category Dropdown Control
<?php
class WP_Customize_Category_Control extends WP_Customize_Control {
public $type = 'dropdown-category';
public function render_content() {
$dropdown = wp_dropdown_categories(array(
"selected" => $this->value(),
"name" => $this->settings["default"]->id,
"echo" => 0
));
@redroot
redroot / gist:4473719
Created January 7, 2013 09:39
Weighted Mean - Ruby
# array of arrays
a = [[10, 1000], [9, 923], [8, 1230], [7, 10]] # [data,frequency]
mean = a.reduce(0) { |m,r| m += r[0] * r[1] } / a.reduce(0) { |m,r| m += r[1] }.to_f