Skip to content

Instantly share code, notes, and snippets.

View ismasan's full-sized avatar

Ismael Celis ismasan

View GitHub Profile
development:
adapter: mysql
database: my_database_name
username: my_database_user
password:
host: localhost
encoding: UTF8
test:
adapter: mysql
// Ismael Celis 2010
/* Usage
-----------------------------------*/
var socket = new WebSocketDispatcher('some_channel', 'some_user_token');
// Bind to custom events emitted by the server
// You can bind more than one handler to the same event. Handlers will be run in the order you registered them.
socket.bind('some_custom_event', function(data){
// jquery example here.
// data is any data you broadcast to open sockets from the server. It can be jSon.
/*
The MIT License (MIT)
Copyright (c) 2014 Ismael Celis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@ismasan
ismasan / Gemfile
Created March 17, 2010 17:04 — forked from rmanalan/.gems
gem 'rack-contrib', :git => 'git://github.com/rack/rack-contrib.git'
gem 'rack-rewrite'
require 'sinatra/base'
module DataBase
class << self
attr_accessor :data
end
end
class Server < Sinatra::Base
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
# Quick spike for a multi-page presenter configurator (intended for Rails apps)
# Create you own presenters with validation (one per page). Use this module to configure the sequence of steps (pages)
require File.dirname(__FILE__) + '/../config/environment'
module Wizard
class UnknownStepError < ArgumentError;end
class InvalidStepError < StandardError;end
@@sequences = {}
@ismasan
ismasan / gist:464257
Created July 5, 2010 11:30
Event-emitter module for Javascript objects
/* Abstract event binding
Example:
var MyEventEmitter = function(){};
MyEventEmitter.prototype = new AbstractEventsDispatcher;
var emitter = new MyEventEmitter();
// Bind to single event
emitter.bind('foo_event', function(data){ alert(data)} );
/* Javascript classes, prototypes and method visibility
--------------------------------------------------------------*/
// Simple, prototype-less class
var Makoto = function(name){
function privateMethod(){
return 1;
}
SELECT app_id, AVG(logs.hits) AS hits_avg, SUM(logs.hits) AS hits,
CONCAT(YEAR(logs.created_at), '-', LPAD(MONTH(logs.created_at), 2, '0'), '-', LPAD(DAY(logs.created_at), 2, '0'), ' ', LPAD(HOUR(logs.created_at), 2, '0'),':',LPAD(FLOOR(MINUTE(logs.created_at)/5)*5, 2, '0'), ':00') AS date_interval
FROM `logs`
WHERE logs.created_at > "2010-07-22 00:00:00"
GROUP BY app_id, date_interval
ORDER BY app_id;