This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Cookbook Name:: rack_version | |
# Recipe:: default | |
if ['solo', 'app_master', 'app'].include?(node[:instance_role]) | |
gem_package "rack" do | |
version "1.4.1" | |
action :remove | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The product of the first two digits is 24. | |
# The fourth digit is half of the second digit. | |
# The sum of the last two digits is the same as the sum of the first and third digits. | |
# The sum of all the digits is 26. | |
# The second and third digits add up to the last digit. | |
def number_to_digits(n) | |
n.to_s.split("").map(&:to_i) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function array_to_attributes($atts) { | |
$attribute_format = '%s="%s"'; | |
$attributes = array(); | |
if (is_array($atts)) { | |
foreach ($atts as $key => $value) { | |
$attributes[] = sprintf($attribute_format, $key, $value); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
apt-get -y update | |
apt-get -y upgrade | |
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline-gplv2-dev libyaml-dev libffi-dev libjemalloc-dev | |
apt-get -y install autoconf curl bzip2 | |
apt-get -y autoremove | |
apt-get -y clean | |
cd /usr/local/src | |
curl http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> start_at = Time.now | |
=> 2012-02-11 14:20:51 -0500 | |
>> end_at = 8.hours.from_now | |
=> Sat, 11 Feb 2012 22:20:54 EST -05:00 | |
>> shift_duration = (end_at - start_at).to_i | |
=> 28802 | |
>> shift_intervals = shift_duration/15.minutes | |
=> 32 | |
>> break_starts = []; shift_intervals.times{|n| break_starts << (break_starts.last || start_at) + (15.minutes * n)} | |
=> 32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Point = Struct.new(:x, :y) | |
point = Point.new do |n| | |
n.x = 1 | |
n.y = 2 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Point = KeywordStruct.new :x, :y | |
Point.new(x: 1, y: 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "pathname" | |
class DefaultPermissionFilter | |
DEFAULTS = { | |
"directory" => 0755, | |
"file" => 0644 | |
} | |
def run(path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "benchmark" | |
N = 1_000_000 | |
module SmallExtension | |
def a | |
end | |
def b | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.*; | |
import javax.swing.*; | |
public class AnimatedScreenCapture extends JFrame { | |
JLabel label; | |
Robot robot; | |
Rectangle screenRect; | |
int scaleX; |