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 'gsl' | |
a = [0,1,2,3,4,8] | |
v = GSL::Vector.alloc(a).sort | |
q1 = v.quantile_from_sorted_data(0.25) | |
q3 = v.quantile_from_sorted_data(0.75) | |
iqr = q3 - q1 | |
tw = q3 + iqr * 1.5 | |
bw = q1 - iqr * 1.5 | |
to = a.filter { |x| x > tw } |
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
(defn with-fallback [amap fallback-fn] | |
(proxy [clojure.lang.PersistentArrayMap | |
clojure.lang.IFn] | |
[(into-array Object amap)] | |
(invoke [key] (or (get amap key) | |
(fallback-fn amap key))))) | |
(def a (with-fallback {:a 1} | |
(fn [amap key] (str "no value for " key " in " amap)))) |
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 'json' | |
require 'uri' | |
require 'net/http' | |
URL = '<YOUR INCOMING WEBHOOK URL HERE>' | |
MESSAGE = { | |
username: 'monit', |
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 | |
Signal.list.each do |signal, number| | |
begin | |
print "trapping % -6s ..." % signal | |
Signal.trap(signal) do | |
puts 'caught ' + signal | |
exit | |
end | |
puts 'ok.' |
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
Promise = require('bluebird') | |
cached = null | |
module.exports = (args) -> | |
return cached if cached? | |
cached = Promise.resolve(args) | |
unless module.parent? |
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
# Disable secure boot in the bios security tab. | |
wget http://cdimage.debian.org/cdimage/unofficial/non-free/cd-including-firmware/8.2.0-live+nonfree/amd64/iso-hybrid/debian-live-8.2.0-amd64-standard+nonfree.iso | |
# Insert USB stick. Check device. Here sdb | |
cp debian-live-8.2.0-amd64-standard+nonfree.iso /dev/sdb | |
# Insert usb. Hit F12 on startup to enter the boot menu. | |
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 | |
# | |
# synopsis | |
# | |
# ruby merge_locales.rb config/locales translations.yml | |
require 'yaml' | |
require 'rubygems' | |
require 'highline/import' |
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/ruby | |
require 'optparse' | |
require 'ostruct' | |
require 'RMagick' | |
include Magick | |
# ------------------------------------------------------------ |
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 | |
# | |
# synopsis | |
# | |
# ruby merge_locales.rb config/locales translations.yml | |
require 'yaml' | |
require 'rubygems' | |
require 'highline/import' |
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
# config/initializers/i18n.rb | |
# chain the translations usage tracker into the i18n backend | |
require File.expand_path('../../../lib/i18n/backend/track_usage', __FILE__) | |
I18n.backend = I18n::Backend::Chain.new(I18n::Backend::TrackUsage.new, I18n.backend) |
NewerOlder