Skip to content

Instantly share code, notes, and snippets.

@milep
milep / server.rb
Created November 7, 2012 16:12
Serve files from folder with webrick
require 'webrick'
include WEBrick # let's import the namespace so
# I don't have to keep typing
# WEBrick:: in this documentation.
def start_webrick(config = {})
# always listen on port 8080
config.update(:Port => 8080)
server = HTTPServer.new(config)
@milep
milep / bd_example.java
Created January 1, 2012 20:57
Example about Java's BigDecimals
//Example about Java's BigDecimals
BigDecimal vat = new BigDecimal("23");
BigDecimal price = new BigDecimal("200");
BigDecimal h = new BigDecimal("100");
price.multiply(vat.divide(h)).add(price);
@milep
milep / Vagrantfile
Created December 9, 2011 12:54
Example Vagrant file with puppet for the starter Rails App
Vagrant::Config.run do |config|
config.vm.box = "oneiric64"
config.vm.forward_port "http", 3000, 5000
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "puppetmanifests"
puppet.manifest_file = "oneiric64.pp"
puppet.module_path = "puppetmodules"
end
@milep
milep / starter.txt
Created December 8, 2011 07:08
Rails 3.1 starter template
# >---------------------------------------------------------------------------<
#
# _____ _ _ __ ___ _
# | __ \ (_) | \ \ / (_) | |
# | |__) |__ _ _| |___\ \ /\ / / _ ______ _ _ __ __| |
# | _ // _` | | / __|\ \/ \/ / | |_ / _` | '__/ _` |
# | | \ \ (_| | | \__ \ \ /\ / | |/ / (_| | | | (_| |
# |_| \_\__,_|_|_|___/ \/ \/ |_/___\__,_|_| \__,_|
#
# This template was generated by rails_apps_composer, a custom version of
@milep
milep / mongoid_test.rb
Created February 3, 2011 13:19
problem with references_and_referenced_in_many
require "rubygems"
require "mongoid"
require "test/unit"
Mongoid.configure do |config|
name = "ref_test"
config.master = Mongo::Connection.new.db(name)
config.logger = nil
end
^[]2;[zsh] MLeMBP::/Users/milep^GTime: 16:31 up 2 days, 19:18, 5 users, load averages: 0.05 0.19 0.26
MLeMBP.local::/Users/milep
Initializing zsh version number 4.3.9
^[]2;[zsh] MLeMBP::/Users/milep^Gzsh-% ls
^[]2; ls ^GDesktop Downloads Library Music Public apps projects
Documents Dropbox Movies Pictures Sites dev scripts
^[]2;[zsh] MLeMBP::/Users/milep^Gzsh-%
...
% jruby -v
jruby 1.4.0RC1 (ruby 1.8.7 patchlevel 174) (2009-09-30 80c263b) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java]
% jruby script/console
Loading development environment (Rails 2.3.4)
/Users/milep/projects/eebu/src/eebu/vendor/gems/image_voodoo-0.6/lib/image_voodoo/awt.rb:15:in `to_java':TypeError: too big for signed byte: 253
>>
package jabber;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.SASLAuthentication;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
public class Main {