Skip to content

Instantly share code, notes, and snippets.

@vpacher
vpacher / .sh
Created February 20, 2019 16:07
shield_pins=('13', '16', '19' '26')
gpio_dir=/sys/class/gpio
for i in $shield_pins[@] do
echo $i > $gpio_dir/export
echo 'out' > $gpio_dir/gpio$i/direction
done
while true
do
def is_admin?
(current_user.is_a?(User) && current_user.is_admin?)
end
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
triggering before callbacks for `deploy:update_code'
* executing `thinking_sphinx:stop'
* executing `thinking_sphinx:configure'
* executing "if [ -d /home/rails/outlet/releases/20111022235219 ]; then cd /home/rails/outlet/releases/20111022235219; else cd /home/rails/outlet/current; fi; bundle exec rake RAILS_ENV=production thinking_sphinx:configure"
servers: ["jansan-002.vm.brightbox.net"]
[jansan-002.vm.brightbox.net] executing command
require 'net/http'
res = Net::HTTP.get URI.parse("http://www.securetrading.com/exchangerates/curr-gbp-ns-today.txt")
f = 1/10000000.0
p res.map(&:chomp).inject({}) { |hash, line| e = line.split; hash[e[0]] = e[1].to_i * f if e[1]; hash}
class Hash
def lookup_by_range(num)
self.find {|range, v| range.include?(num) }.last
end
end
ProspFmBitmapMethods = [:prosp_fm_sm, :prosp_fm_gay, :prosp_fm_bim, :prosp_fm_nondism, :prosp_fm_sf, :prosp_fm_les, :prosp_fm_bif, :prosp_fm_nondisf]
ProspFmBitmapMethods.each_with_index do |method, offset|
module_eval <<-EVAL, __FILE__, __LINE__
def #{method}
self.prospfm_bm & #{1 << offset}
end
def #{method}?
#{method} > 0
end
def #{method}=(new_val)
rvm_path = "#{deployment_user_home_directory}/.rvm"
rvm_version = "ruby-1.9.2-p0" # Find this in ~/.rvm/rubies/
set :default_environment, {
"PATH" => %W[
#{rvm_path}/gems/#{rvm_version}/bin
#{rvm_path}/gems/#{rvm_version}@global/bin
#{rvm_path}/rubies/#{rvm_version}/bin
#{rvm_path}/bin
$PATH
].join(":"),