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
diff --git a/sysdeputil.c b/sysdeputil.c | |
index 66dbe30..9dc8a5e 100644 | |
--- a/vsftpd-2.3.2/sysdeputil.c | |
+++ b/vsftpd-2.3.2/sysdeputil.c | |
@@ -64,10 +64,6 @@ | |
#include <utmpx.h> | |
/* BEGIN config */ | |
-#if defined(__APPLE__) | |
- #undef VSF_SYSDEP_HAVE_UTMPX |
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
# This is a replacement for Ruby's backtick operator that avoids shell | |
# injection attacks. | |
# | |
# In web apps that allow file uploading, it's common to run shell commands that | |
# operate on those files. For example, you might do this: | |
# | |
# `convert -resize 100x100 '#{image_filename}'` | |
# | |
# The problem is that a carefully crafted filename could cause trouble. |
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
def kata(digits = [], has_pair = false) | |
if digits.inject {|sum, digit| sum + digit } == 15 | |
has_pair ? [digits] : [] | |
else | |
start = (digits.last || 0) + 1 | |
(start..9).inject([]) do |result, digit| | |
result + kata(digits + [digit], has_pair) + kata(digits + [digit, digit], true) | |
end | |
end | |
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
def kata(digits = [], sum = 0, has_pair = false) | |
if sum < 15 | |
start = (digits.last || 0) + 1 | |
(start..9).inject([]) do |result, digit| | |
result + | |
kata(digits + [digit], sum + digit, has_pair) + | |
kata(digits + [digit, digit], sum + digit + digit, true) | |
end | |
elsif sum == 15 && has_pair | |
[digits] |
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
alias λ lambda | |
λ {|f| λ {|x| f[λ {|y| x[x][y] } ] }[λ {|x| f[λ {|y| x[x][y] }] }] }[λ {|f| λ {|n| n == 0 ? 1 : n * f[n-1] } }][6] |
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
# Put this in spec/support | |
# Make sure we get stack traces for controller and view exceptions. | |
ActionController::Base.class_eval do | |
def rescue_action_without_handler(exception) | |
raise exception | |
end | |
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
class Dependency | |
def self.foo | |
puts "Foo" | |
end | |
def self.bar | |
puts "Bar" | |
end | |
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
# I have a class that delegates functionality to a couple of objects that it | |
# constructs. I want to test this in isolation. I want to make sure that the | |
# objects are constructed with the right arguments. I also want to make sure | |
# that the results from the objects are handled correctly. | |
# | |
# I'm finding it hard to structure the code and test in a way that isn't | |
# cumbersome. What's below works, but it feels like a lot of stubbing and setup | |
# for something the should be simpler. | |
# | |
# Anyone got a better approach for this? |
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
class PagingEnumerator < Enumerator | |
def initialize(&block) | |
super do |yielder| | |
page = 0 | |
loop do | |
items = block.call(page) | |
break if items.empty? | |
items.each {|item| yielder.yield(item) } | |
page += 1 |
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
# On a new ubuntu 14.04 box, as root, with the following variables | |
# export BUILDBOX_AGENT_NAME="buildbox-agent-N" | |
# export BUILDBOX_AGENT_ACCESS_TOKEN="<your token here>" | |
# export BUILDBOX_AGENT_SSH_PRIVATE_KEY="<an ssh private key>" | |
# export BUILDBOX_AGENT_SSH_PUBLIC_KEY="<an ssh public key>" | |
# Make tmp totally in memory | |
echo "none /tmp tmpfs size=4g 0 0" >> /etc/fstab | |
mount /tmp |