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 decrypted_password | |
aes.decrypt | |
aes.key = Rails.configuration.aes256_key | |
password = aes.update(self.crypted_password.unpack("m").first) | |
(password << aes.final).gsub(%r(#{self.password_salt}$), '') | |
end | |
private |
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 encrypt_bugdb_password | |
if !(self.bugdb_password_changed? or self.new_record?) | |
return | |
end | |
cipher = OpenSSL::Cipher::Cipher.new CipherHelper::encryption_type | |
cipher.encrypt | |
cipher.key = Digest::SHA1.hexdigest CipherHelper::key | |
cipher.iv = self.initialization_vector = cipher.random_iv | |
encrypted_password = cipher.update self.bugdb_password | |
encrypted_password << cipher.final |
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
(test/with-test | |
(defn to_wound | |
([s t] | |
(let [x (+ 4 (- t s))] | |
(max 2 (min 6 x))))) | |
(test/is (= (to_wound 3 3) 4)) | |
(test/is (= (to_wound 3 4) 5)) | |
(test/is (= (to_wound 3 2) 3)) | |
(test/is (= (to_wound 3 1) 2)) | |
(test/is (= (to_wound 4 1) 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
Host *yourdomain.com | |
User someuser |
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
$ ssh yourdomain.com |
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
group :development do | |
rake-remote_task | |
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
require 'rake/remote_task' | |
host 'yourdomain.com', :app | |
remote_task :example_task, role: :app do | |
run 'uname -a' | |
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
$ rake example_task | |
(in /home/josiah/Projects/gem-testers) | |
Linux gem-testers.org 2.6.32.16-linode28 #1 SMP Sun Jul 25 21:32:42 UTC 2010 i686 Intel(R) Xeon(R) CPU L5520 @ 2.27GHz GenuineIntel GNU/Linux |
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
(test/with-test | |
(defn- swap-duel-probabilities | |
([probabilities] | |
{:lead (:follow probabilities) :follow (:lead probabilities)})) | |
(test/is (= (swap-duel-probabilities {:lead 0.5 :follow 0.6}) {:lead 0.6 :follow 0.5}))) | |
(defn aggregate-probability | |
([probabilities duelist] | |
(reduce |
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/lib/ruby | |
require 'open3' | |
Open3.popen2('pianobar', 'r+') do |stdin, stdout| | |
out = '' | |
sleep_now = false | |
loop do | |
o, i, _ = IO.select([stdout], [stdin], nil, 10000000) | |
unless o.first.nil? | |
out += o.first.readpartial(8000) |