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
module Merb::Helpers::Form | |
def date_field(*args) | |
if bound?(*args) | |
current_form_context.bound_date_field(*args) | |
else | |
current_form_context.unbound_date_field(*args) | |
end | |
end | |
def datetime_field(*args) |
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
# A nice demonstration of how much faster Ruby 1.9 is than Ruby 1.8 | |
require "complex" | |
class Complex | |
def m | |
z=self | |
1024.times { |i| z=z*z+self; return i+1 if z.abs > 2 } | |
return 1024 | |
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
class Floppy | |
def method_missing(method, *args) | |
super unless args.length > 0 && method.to_s[-1..-1] == "=" | |
if args.first.is_a?(Proc) | |
(class << self; self; end).class_eval do | |
define_method(method.to_s[0..-2].to_sym, args.first) | |
end | |
else | |
(class << self; self; end).send(:attr_accessor, method.to_s[0...-1]) |
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
module Matz | |
def self.included(*) | |
puts <<-MATZ | |
Simplicity is NOT a Goal | |
------------------------ | |
Things too simple are difficult | |
Things too complex are difficult |
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
rm -R $HOME/Desktop/server-{1,2} | |
mkdir -p $HOME/Desktop/server-{1,2} | |
mysql_install_db --datadir=$HOME/Desktop/server-1 && mysqld --server-id 1 -h ~/Desktop/server-1 --socket ~/Desktop/server-1/mysql.sock -P 10001 --log-bin & | |
mysql_install_db --datadir=$HOME/Desktop/server-2 && mysqld --server-id 2 -h ~/Desktop/server-2 --socket ~/Desktop/server-2/mysql.sock -P 10002 --master-port=10001 --master-host=127.0.0.1 --master-user=root & | |
alias sql-master="mysql -h127.0.0.1 -P10001 -uroot" | |
alias sql-slave="mysql -h127.0.0.1 -P10002 -uroot" | |
alias sql-master-admin="mysqladmin -h127.0.0.1 -P10001 -uroot" |
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
Original Source: https://github.com/chneukirchen/styleguide | |
= Christian Neukirchen's Ruby Style Guide | |
You may not like all rules presented here, but they work very well for | |
me and have helped producing high quality code. Everyone is free to | |
code however they want, write and follow their own style guides, but | |
when you contribute to my code, please follow these rules: | |
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
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin` | |
# Be sure to have rails and thin installed. | |
require "rubygems" | |
# We are not loading Active Record, nor the Assets Pipeline, etc. | |
# This could also be in your Gemfile. | |
gem "actionpack", "~> 3.2" | |
gem "railties", "~> 3.2" | |
# The following lines should come as no surprise. Except by |
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
use std::io; | |
fn main() { | |
eval(bytes!("++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.")); // I stole this off of wikipedia, sorry, wikipedia :( | |
} | |
fn eval(program: &[u8]) { | |
let mut pointer = 0u; | |
let mut memory = [0u8, ..1024]; | |
let mut jmp_stack = vec!(); |
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
module Sass::Script::Functions | |
def user_color | |
color_values = options[:custom][:user].color. | |
scan(/^#?(..?)(..?)(..?)$/).first. | |
map {|num| num.ljust(2, num).to_i(16)} | |
Sass::Script::Color.new(color_values) | |
end | |
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
// Fast Block Distributed CUDA Implementation of the Hungarian Algorithm | |
// | |
// Annex to the paper: | |
// Paulo A. C. Lopes, Satyendra Singh Yadav, Aleksandar Ilic, Sarat Kumar Patra , | |
// "Fast Block Distributed CUDA Implementation of the Hungarian Algorithm", | |
// Parallel Computing | |
// | |
// Hungarian algorithm: | |
// (This algorithm was modified to result in an efficient GPU implementation, see paper) | |
// |
OlderNewer