Skip to content

Instantly share code, notes, and snippets.

View jondeandres's full-sized avatar

Jon jondeandres

  • Uniphore (https://www.uniphore.com)
  • Barcelona
View GitHub Profile
@jondeandres
jondeandres / README.md
Created November 26, 2012 00:39 — forked from jhbabon/README.md
Playing with DCI in Ruby: Chaining Contexts

DCI: Chain of contexts example

Run each chain:

$ ruby full_chain.rb
$ ruby half_chain.rb
$ ruby no_chain.rb
#!/bin/bash
thin start -p 3000 -R test.ru
export PROJECTS=~/wuaki/
function cs {
local dest current
mkdir -p "$PROJECTS"
cd "$PROJECTS/$1"
}
function _cs_scandir
@jondeandres
jondeandres / C pointers
Last active December 14, 2015 11:28
C Pointers
int main(int argc, char *argv[])
{
int *array, i;
array = malloc(sizeof(int) * 100);
memset((void *)array, 0, sizeof(int) * 100);
*(array + sizeof(int) * 30) = 4;
for(i = 0; i < 100; i++) {
int value;
value = *(array + sizeof(int) * i);
#!/usr/bin/env ruby
#
# Git commit-msg hook. If your branch name is in the form "username/vod-45-new-feature"
# it automatically adds the prefix "[VOD-45]" to commit
# messages.
#
# Example
# =======
#
# git checkout -b bob/vod-45-some-cool-feature
(defun copy-buffer ()
"Copy buffer to clipboard"
(clipboard-kill-ring-save (point-min) (point-max)))
(defun git-changelog ()
(interactive)
(shell-command "git --no-pager log --no-merges --pretty=format:'- %s' `git describe --abbrev=0 --tags`.." "*changelog*")
(switch-to-buffer "*changelog*")
(copy-buffer))
redis = require('redis')
client = redis.connect('127.0.0.1', 6379)
class RedisModel
@primary_key: "id"
@model: nil
@counters: {}
-- class methods
@counter: =>
module WuakiBackground
module DelayedTask
def self.include(base)
base.extend(ClassMethods)
end
module ClassMethods
def before_perform(*args)
_args = args.dup
options = _args.extract_options!
@jondeandres
jondeandres / queue.rb
Created July 10, 2013 21:33
Push Job to Resque without Resque.
require 'yaml'
require 'multi_json'
module MyApp
module Queue
extend self
def redis
MyApp.redis
end
@jondeandres
jondeandres / dci_example.rb
Last active December 21, 2015 14:18
DCI example
require 'delegate'
class GuestRole < SimpleDelegator
def books
Book.published
end
end
class AdminRole < SimpleDelegator
def books