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
// Choose a temperature only at one of the three measurement scales, leave the other two "undefined". | |
let celsius = undefined | |
let fahrenheit = undefined | |
let kelvin = 300 | |
function cToF() { | |
return celsius * 9/5 + 32 | |
} | |
function cToK() { |
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 random | |
N=8 | |
6**N | |
dices = [1]*N | |
n = 1 | |
while dices != [6]*N: |
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 'digest/sha1' | |
0.upto(1000).each do |i| | |
s = i.to_s | |
digest = Digest::SHA1.hexdigest(s) | |
fg = digest[0..5] | |
fg_ = {} | |
fg_[:r] = fg[0..1] | |
fg_[:g] = fg[2..3] |
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
#!/bin/bash | |
# Put this in /etc/udev/rules.d/automount.rules | |
# | |
# ACTION=="add", ENV{DEVTYPE}=="partition", RUN+="domount %N" | |
# All based on: | |
# https://wiki.archlinux.org/index.php/USB_Storage_Devices | |
# But: |
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 'securerandom' | |
avg = nil | |
0.upto(1000) do |k| | |
n = 0 | |
places = {} | |
loop do |
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 'thin' | |
require 'sinatra' | |
# by Guido De Rosa, guido.derosa at vemarsas.it, 2012, distributed under the | |
# same licensing conditions of jqueryFileTree. | |
# Based on connectors/jqueryFileTree.rb contained in | |
# labs.abeautifulsite.net/archived/jquery-fileTree/jquery.fileTree-1.01.zip | |
# An adaptation from CGI to Sinatra. |
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
see also | |
http://wiki.micasaverde.com/index.php/UI_Simple | |
http://jsoneditor.net/ | |
http://jsonviewer.stack.hu/ | |
Assuming IP = 192.168.33.155 | |
Get devices etc. (simplified) |
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
WIDTH = 20 # Copyright (C) 2011, Guido De Rosa; License: MIT | |
histogram = Array.new(1 + WIDTH, 0) | |
2800.times do | |
x = WIDTH/2 | |
WIDTH.times { x += (rand <=> 0.5)/2.0 } # random-walk | |
histogram[x] += 1 | |
end | |
histogram.each_with_index do |bar_value, i| | |
printf "%02d ", i; (bar_value.to_f/10).ceil.times {print '|'}; puts | |
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
# Adapted from http://kangaroobox.blogspot.com/2009/12/switching-ruby-platforms-on-debian.html | |
update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 400 \ | |
--slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \ | |
/usr/share/man/man1/ruby1.9.1.1.gz \ | |
--slave /usr/bin/ri ri /usr/bin/ri1.9.1 \ | |
--slave /usr/bin/irb irb /usr/bin/irb1.9.1 | |
# --slave /usr/bin/gem gem /usr/bin/gem1.9.1 | |
# removed: it's a master alternative now |
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
map{|h| h.rekey{|k| @@chkcols.invert[k]}} |
NewerOlder