Skip to content

Instantly share code, notes, and snippets.

View vangberg's full-sized avatar

Harry Vangberg vangberg

View GitHub Profile
import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
/* ACTIONS */
export const ADD = 'something_clever/ADD'
export function add () {
return { type: ADD }
}
dices = [
[ 2,
3,1,6,5,
4
],
[ 3,
1,2,4,6,
5
],
[ 5,

Fibur

Fibur is a library that allows concurrency during Ruby I/O operations without needing to make use of callback systems. Traditionally in Ruby, to achieve concurrency during blocking I/O operations, programmers would make use of Fibers and callbacks. Fibur eliminates the need for wrapping your I/O calls with Fibers and a callback. It allows you to write your blocking I/O calls the way you normally would, and still have concurrent execution during those I/O calls.

Example

Say you have a method that fetches data from a network resource:

var sys = require('sys');
var http = require('http');
var host = '127.0.0.1';
var couch = http.createClient(5984, host);
var listen = function() {
sys.log("listening");
var request = couch.request('GET', '/demo/_changes?feed=continuous', {'host': host});
#! /usr/bin/env ruby
# this program will give you a 'named screen' (ns) command that will create
# named screens that will also name Terminal.app tabs, even on re-attach.
# save it in ~/bin/ns and use as in
#
# to create a named screen
#
# ns foobar
#
Test::Unit::TestCase.send :include, Sinatra::Test
class Waste < Sinatra::Base
get '/' do
puts session[:test]
end
end
describe 'Waste' do
before do
@vangberg
vangberg / base.rb
Created January 30, 2009 01:57 — forked from bmizerany/base.rb
host "sinatrarb.com"
accept :xml
provides :xml
get '/' do
"Welcome!"
end
get '/' do
"You are not to be welcomed!"
end
Let's make a list of Sinatra-based apps!
Apps:
- http://github.com/cschneid/irclogger "Sinatra based irclogger.com"
- http://github.com/rtomayko/wink "minimalist blogging engine"
- http://github.com/foca/integrity "The easy and fun Continuous Integration server"
- http://github.com/sr/git-wiki "git-powered wiki"
- http://github.com/entp/seinfeld "Seinfeld-inspired productivity calendar to track your public github commits."
- http://github.com/karmi/marley "Marley, the blog engine without <textareas>."
- http://github.com/ichverstehe/gaze "Serve up your Markdown files with this tiny Sinatra app!"
#!/usr/bin/env ruby
#--
# Name : git_watch.rb
# Author : Jerod Santo
# Contact : "moc.liamg@otnas.dorej".reverse
# Date : 2008 October 14
# About : Checks a git repository for changes and emails provided email
# address if changes have been made. Schedule with cron.
#--
# The simplest thing that could possibly work. Will probably overwrite files if someone uploads
# a file that has the same file name as an already uploaded file. Requires the columns 'size' and
# 'content_type', see the 'store_file' method. You could obviously just remove those calls
# if you don't want to store the file size and the content type in the database.
#
# If you need a fancy name (in the spirit of 'paperclip' and 'attachment_fu'), you can call this code
# 'fucking_simple_fu' so that you can refer to this code and look like a cool kid on teh block.
class Attachment < ActiveRecord::Base
after_create :store_file