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
CREATE OR REPLACE FUNCTION r_scatter(title text, sql text) | |
RETURNS text AS | |
$BODY$ | |
str <- pg.spi.exec (sql); | |
pdf('/tmp/scatter_plot.pdf'); | |
plot(str,main=title,cex=0.3, pch=20,col=rgb(255,0,0,2,maxColorValue=255),ylim=c(0,100)); | |
dev.off(); | |
print('done'); | |
$BODY$ | |
LANGUAGE 'plr' VOLATILE; |
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
/********************************************* | |
* OPL 5.0 Model | |
* Author: Andrew Fecheyr Lippens | |
* Creation Date: 9/05/2009 at 23:49 | |
*********************************************/ | |
// Setup | |
int horizon = 60*24*21-1; // Number of minutes in a week | |
int blocktime = 5; |
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 lets you do stuff like | |
1> my_lib:seq_float(10.01,10.13,0.02). | |
[10.01,10.03,10.05,10.07,10.09,10.11,10.13] |
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
# Sample the CPU Load and Memory usage of an application over time and | |
# returns the average, standard deviation and min-max range. | |
# processname to check as $1, number of samples as $2 | |
# eg: ruby ps_avg.rb safari 100 | |
process_name = ARGV[0] | |
sample_count = ARGV[1] || 120 | |
samples_per_seconds = 3 | |
sleep_time = (1/samples_per_seconds.to_f) |
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 | |
# Dynamic DNS updater by Andruby for Zerigo | |
# www.andrewsblog.org | |
ApiKey = 'myzerigoapikey' # your Zerigo API key | |
Host = 'test.example.com' # the host you want to dynamically update | |
User = '[email protected]' # your Zerigo username | |
NameServer = 'a.ns.zerigo.net' # Zerigo nameserver to query | |
LastIpTmpFile = '/tmp/dyn_update_last_ip' # a temporary file where we store the last ip adress |
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
# Script to setup swap space on a Amazon AWS instance | |
# Takes about 1 minute per GB of swap size | |
# run it like this: | |
# ruby aws_swap.rb 4G | |
SWAP_LOCATION = "/mnt/swapfile" | |
def run(cmd) | |
if ARGV.join(' ').include?('-p') | |
puts cmd |
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
# Helper class for file I/O and time measurement | |
class Problem | |
def initialize(input_file,output_file=nil) | |
@output_file = output_file | |
@start_time = Time.now | |
@input_file = input_file | |
@output_file ||= input_file.gsub('.txt','').gsub('.in','.out') | |
File.delete(@output_file) if File.exists?(@output_file) | |
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
# Application Generator Template | |
# Modifies a Rails app to use Mongoid, Devise, jQuery, Haml | |
# Usage: rails new app_name -m http://gist.github.com/raw/452364/gistfile1.txt | |
# More info: http://github.com/fortuity/rails3-mongoid-devise/ | |
# If you are customizing this template, you can use any methods provided by Thor::Actions | |
# http://rdoc.info/rdoc/wycats/thor/blob/f939a3e8a854616784cac1dcff04ef4f3ee5f7ff/Thor/Actions.html | |
# and Rails::Generators::Actions | |
# http://github.com/rails/rails/blob/master/railties/lib/rails/generators/actions.rb |
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
after "deploy:symlink", "deploy:restart_workers" | |
## | |
# Rake helper task. | |
# http://pastie.org/255489 | |
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/ | |
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/ | |
def run_remote_rake(rake_cmd) | |
rake_args = ENV['RAKE_ARGS'].to_s.split(',') | |
cmd = "cd #{fetch(:latest_release)} && #{fetch(:rake, "rake")} RAILS_ENV=#{fetch(:rails_env, "production")} #{rake_cmd}" |
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
getal = 2 | |
primes = [2] | |
begin | |
getal += 1 | |
primes << getal unless primes.any? { |deler| getal % deler == 0 } | |
end until primes.size >= 1000 | |
p primes |
OlderNewer