Skip to content

Instantly share code, notes, and snippets.

View mejibyte's full-sized avatar

Andrés Mejía mejibyte

View GitHub Profile
var names = ["Andrés Mejía", "Federico Builes", "Jairo Vasquez", "Jorge Cardona"];
google.load("jquery", "1.3.2");
google.setOnLoadCallback(onLoad);
function randomReadableString(length){
if (!length) length = 10;
var vowels = "aeiou";
var consonants = "bcdfghjklmnpqrstvwxyz";
var ans = "";
for (var i=0; i<length; ++i){
class Admin::BaseController < ApplicationController
layout "admin"
before_filter :require_admin
ActiveScaffold.set_defaults do |config|
config.ignore_columns.add [:created_at, :updated_at]
end
end
/* Sample solution for NCPC'08: Code Theft
* Author: Nils Grimsmo
*
* Warning: For a simple solution, look somewhere else...
*
* Solution: - View lines as symbols (hash once).
* - Build suffix tree for new code snippet
* - Find the matching statistics for each fragment
* from the repository.
*
using namespace std;
#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
# -*- coding: utf-8 -*-
# This script will download the meaning of all names found on http://www.misabueso.com/nombres/
# Date: July 20, 2009, at 2:14AM
# Author: Andrés Mejía <andmej@gmail.com>
# The format of the output file is as follows.
# For each name fetched, there are two lines:
# Line 1: The name itself
# Line 2: A valid HTML chunk containing the meaning of the name and some other stuff
@mejibyte
mejibyte / gist:791105
Created January 22, 2011 12:56
Test Omniauth Callback Controllers in Devise
# encoding: utf-8
require 'test_helper'
class Users::OmniauthCallbacksControllerTest < ActionController::TestCase
context "Facebook callback" do
setup do
# This a Devise specific thing for functional tests. See https://github.com/plataformatec/devise/issues/closed#issue/608
request.env["devise.mapping"] = Devise.mappings[:user]
end
/* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2004, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
require 'socket'
# Threaded echo server
# It services multiple clients at a time.
# Note that it may accept connections too much.
Socket.tcp_server_loop(16807) {|sock, client_addrinfo|
Thread.new {
begin
IO.copy_stream(sock, sock)
ensure
NUMBER = /[0-9]+/
HOURS_DESCRIPTOR = /\s*(h|hour|hours)\s*/i
MINUTES_DESCRIPTOR = /\s*(m|min|minute|minutes)\s*/i
SEPARATOR = /(:|and|&)/i
INITIAL_TAG = /\[\s*t\s*:\s*/i
FINAL_TAG = /\s*\]/i
HOURS_AND_MINUTES_WITH_SEPARATOR = /#{INITIAL_TAG}(#{NUMBER})#{HOURS_DESCRIPTOR}?\s*#{SEPARATOR}\s*(#{NUMBER})#{MINUTES_DESCRIPTOR}?#{FINAL_TAG}/
HOURS_AND_MINUTES_WITHOUT_SEPARATOR = /#{INITIAL_TAG}(#{NUMBER})#{HOURS_DESCRIPTOR}\s*(#{NUMBER})#{MINUTES_DESCRIPTOR}?#{FINAL_TAG}/
ONLY_HOURS = /#{INITIAL_TAG}(#{NUMBER})#{HOURS_DESCRIPTOR}#{FINAL_TAG}/
ONLY_MINUTES = /#{INITIAL_TAG}(#{NUMBER})#{MINUTES_DESCRIPTOR}#{FINAL_TAG}/
@mejibyte
mejibyte / rally.rb
Created August 22, 2011 20:54 — forked from EmmanuelOga/rally.rb
Scrape rally on rails scores.
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'mysql'
require 'active_record'
ActiveRecord::Base.establish_connection(
adapter: "mysql", encoding: "utf8", database: "scores", username: "root", password: ""
)