Skip to content

Instantly share code, notes, and snippets.

View tagliala's full-sized avatar
🏢
Working from Rome

Geremia Taglialatela tagliala

🏢
Working from Rome
View GitHub Profile
@gdusbabek
gdusbabek / node-cassandra-client-examples.js
Created April 12, 2012 17:31
Examples of how to use node-cassandra-client
var async = require('async');
function doSimpleConnect(callback) {
var Connection = require('cassandra-client').Connection;
// these are the connection parameters you need to connecto to Cassandra.
var connectionOptions = {
host: '127.0.0.1',
port: 19170,

Transactions

As your business logic gets complex you may need to implement transactions. The classic example is a bank funds transfer from account A to account B. If the withdrawal from account A fails then the deposit to account B should either never take place or be rolled back.

Basics

All the complexity is handled by ActiveRecord::Transactions. Any model class or instance has a method named .transaction. When called and passed a block, that block will be executed inside a database transaction. If there's an exception raised, the transaction will automatically be rolled back.

Example

@davatron5000
davatron5000 / videos.php
Created February 28, 2011 23:06
WordPress Custom Post Type Boilerplate (e.g. Videos)
<?php
/*
Plugin Name: Videos
Plugin URI:
Author: Dave Rupert
Author URI: http://www.daverupert.com
Description: A custom post type that adds videos and custom taxonomies.
Version: 1.0
*/
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')