Skip to content

Instantly share code, notes, and snippets.

View oivoodoo's full-sized avatar
🏠
Working from home

Alex oivoodoo

🏠
Working from home
View GitHub Profile
@oivoodoo
oivoodoo / Express error handling.js
Created March 6, 2011 21:42
Mongoose multiple validations
var sys = require ('sys');
module.exports = function(app) {
function NotFound(msg) {
this.name = 'NotFound';
Error.call(this, msg);
Error.captureStackTrace(this, arguments.callee);
}
@oivoodoo
oivoodoo / twitter_tumblr_data.js
Created March 21, 2011 10:24
Retrieve data from twitter and tumblr for my own web site.
$(function(){
$.getJSON('http://search.twitter.com/search.json?callback=?&q=oivoodoo&rpp=5', function(data){
var html = "";
for(var i = 0; i < data.results.length; i++) {
var tweet = data.results[i];
html += "<div class='tweet'><a href='http://twitter.com/oivoodoo/'>@oivoodoo</a>:<span>" + tweet.text + '</span></div>';
}
$('#twitter').html(html);
});
class Account < ActiveRecord::Base
has_many :memberships, :class_name => 'AccountAdministrator'
has_many :administrators, :through => :memberships
end
class Administrator < ActiveRecord::Base
has_many :memberships, :class_name => 'AccountAdministrator'
has_many :accounts, :through => :memberships
accepts_nested_attributes_for :memberships
{
"name": "chrome-games",
"description": "Small webserver for storing games settings",
"version": "0.0.1",
"author": "Alexander Korsak<alex.korsak@gmail.com>",
"contributors": [
{ "name": "Alexander Korsak", "email": "alex.korsak@gmail.com" }
],
"dependencies": {
"express": ">= 2.0.0",
sys = require('sys')
express = require('express')
jade = require('jade')
connect = require('connect')
stylus = require('stylus')
RedisStore = require('connect-redis')(connect)
app = express.createServer(
connect.cookieParser()
connect.static(__dirname + '/public'),
(function(global) {
global.DateTime = DateTime = {};
DateTime.instance = (function() {
return {
getTime: function(date, offset, format) {
var date = new Date(date.getTime() + offset * 1000);
return date.getUTCHours() + ":" + date.getUTCMinutes();
}
};
})();
/*
* Wrapper for html5 local storage
*/
var Storage = function() {};
Storage.define = function(table) {
window.localStorage[table] = window.localStorage[table] || "[]";
return new Table(table);
};
inherit = (function() {
var F = function() {};
return function(C, P) {
F.prototype = P.prototype;
C.prototype = new F();
C.uber = P.prototype;
C.prototype.constructor = C;
};
})();
$(function() {
var BaseController = function(link) {
var context = this;
this.link = link;
this.syncLink = link + "/sync";
$(window).bind('online', function() {
context.sync();
});
};
require 'net/https'
require 'open-uri'
url = URI.parse(YOUR_SERVER_URL)
http_session = Net::HTTP.new(uri.host, uri.port)
http_session.use_ssl = true if uri.port == 443
http_session.start { |http|
}