Skip to content

Instantly share code, notes, and snippets.

open System
let rec readUntilDone input =
match input with
| "42" -> 0
|_ -> Console.WriteLine(input)
readUntilDone(Console.ReadLine())
[<EntryPoint>]
let main args =
var MongoClient = require('mongodb').MongoClient;
var mapFn = function() {
emit(1, { length: this.length });
}
var reduceFn = function(key, values) {
var sum = 0;
values.forEach(function(doc) {
sum += doc.length;
@bmaland
bmaland / defiance_ark_hunter.rb
Created April 3, 2013 19:33
This script submits all 150 Ark Hunter codes to your Defiance account using PhantomJS and Selenium WebDriver (Ruby bindings). Code source: http://digiex.net/general-discussions/gaming-hangout/12462-defiance-all-150-arkfall-codes.html
# INSTRUCTIONS:
# - make sure you have ruby and phantomjs installed
# - gem install selenium-webdriver
# - start phantomjs in remote web driver mode: 'phantomjs --webdriver=4567'
# - change username/pass below
# - run the script (e.g. 'ruby defiance_ark_hunter.rb')
USERNAME = "user"
PASSWORD = "pass"
#!/bin/bash
# Script for running tests on the continuous integration server.
set -e # exit on error
## Make sure latest gems are installed
bundle install
## Verify that asset precompilation works
var CdView = Backbone.View.extend({
tagName: "li",
initialize: function() {
this.model.on("change" this.render);
},
events: {
"click .icon": "open",
@bmaland
bmaland / discogs-dump-parser.rb
Created June 4, 2012 06:33
Parses XML dumps from discogs.com and converts it to a nice text format
#!/usr/bin/env ruby
require "active_support/all"
require "hashie"
require "nokogiri"
if ARGV.blank?
puts "Usage: #{$0} filename.xml"
exit 1
end
@bmaland
bmaland / caching_test.rb
Created April 23, 2012 12:12
JRuby encoding problem when reading cached cells
# -*- coding: utf-8 -*-
require 'test_helper'
class DirectorCell < Cell::Rails
attr_reader :count
def initialize(*)
super
@count = 0
end
@bmaland
bmaland / gist:1992205
Created March 7, 2012 09:36
Loop through views in a Serve project
<ul>
<% Dir.glob("views/[^_]*").each do |file| %>
<li><a href="/<%= file %>"><%= file %></a></li>
<% end %>
</ul>
>>> class C(object):
... cattr = "hej"
... def __init__(self, name):
... self.cattr = name
...
>>> c = C("hi")
>>> d = C("hej")
>>> d.cattr
'hej'
>>> c.cattr
@bmaland
bmaland / serverstart.sh
Created November 23, 2010 17:41
serverstart.sh
$ TimblServer -f dimin.train -S 6060
TiMBL Server 1.0.0 (c) ILK 1998 - 2010.
Tilburg Memory Based Learner
[...]