Skip to content

Instantly share code, notes, and snippets.

@danielbeardsley
danielbeardsley / json_controller.rb
Created November 19, 2009 05:57
A Generalized Json Controller for use with extjs-mvc and Restful CRUD
class JsonController < ApplicationController
rescue_from ActiveRecord::RecordNotFound do |exception|
render :json => { :success => false }, :status => :not_found
end
before_filter :find_record, :only => [ :get, :update, :destroy ]
layout 'base'
(defmacro ->r
"The proposed Rohner arrow"
([x] x)
([x form] (if (seq? form)
(with-meta (replace {'_ x} form) (meta form))
(list form x)))
([x form & more] `(->r (->r ~x ~form) ~@more)))
(use 'clojure.walk)
@francescoagati
francescoagati / core.clj
Created August 16, 2010 19:08
n example of with-diret-linking for overloading symbols in a local scope in clojure
(comment
"an example of with-diret-linking for overloading symbols in a local scope"
)
(ns prova.core)
(use 'clojure.contrib.macro-utils)
(require '[prova.over :as over])
(require '[clojure.contrib.macros :as macros])
@francescoagati
francescoagati / commandline
Created March 10, 2011 17:15
rainbows.conf
rainbows -c rainbows.conf
<?php
require __DIR__.'/silex.phar';
use Silex\Framework;
$app = new Framework();
$app->get('/hello.{_format}', function($_format) use ($twig) {
$template = $twig->loadTemplate("hello.$_format.twig");
@ramontayag
ramontayag / gist:1101138
Created July 23, 2011 07:16
How I setup my Apotomo widgets

Your app/widgets directory can get crazy pretty fast. If you're learning Apotomo, then you'll probably move things around and try many ways to order your widgets directory. This is not so much about that - I still haven't found a good way to organize my widgets, but I've found a way to keep the widget classes themselves DRY.

Create an ApplicationWidget just like Rails' ApplicationController

And it should look something like this:

# A BaseWidget to apply stuff to widgets across
# the board. All widgets should inherit from this
class ApplicationWidget < Apotomo::Widget

include ActionController::RecordIdentifier # so I can use dom_id

@bjpirt
bjpirt / nnc.rb
Created February 6, 2012 16:46
Naughty Netcat
#!/usr/bin/env ruby
require 'rubygems'
require 'eventmachine'
class Client < EventMachine::Connection
def initialize(server)
@server = server
@server.client = self
@start_time = Time.now.to_f
end
@endymion
endymion / wait_until.rb
Created March 9, 2012 17:59 — forked from metaskills/wait_until.rb
Never sleep() using Capybara!
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations?
describe 'Modal' do
should 'display login errors' do
visit root_path
click_link 'My HomeMarks'
within '#login_area' do
fill_in 'email', with: '[email protected]'
fill_in 'password', with: 'test'
@nadako
nadako / Main.hx
Created October 31, 2014 14:38
Structure initialization helper macro
import StructHelper.make;
typedef A = {
a:Int,
b:String,
c:Float,
d:Bool,
e:Array<Int>,
f:{
g:Array<Bool>,