Skip to content

Instantly share code, notes, and snippets.

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

Igor Fedoronchuk Fivell

🏠
Working from home
View GitHub Profile
@Fivell
Fivell / skype_db
Created April 6, 2012 15:11
sqlite access to skype on LION
sqlite3 "/Users/{#os_user}/Library/Application Support/Skype/{#skype_user}/main.db"
@Fivell
Fivell / EmailValidator
Created April 7, 2012 10:17
EmailValidator < ActiveModel::EachValidator
class EmailValidator < ActiveModel::EachValidator
EmailAddress = /\A[\w!\#$%&'*+\/=?^_\`{|}~-]+(?:\.[\w!\#$%&'*+\/=?^_\`{|}~-]+)*@(?:\w(?:[\w-]*\w)?\.)+\w(?:[\w-]*[\w])?\z/
def validate_each(record, attribute, value)
unless value =~ EmailAddress
record.errors[attribute] << (options[:message] || "is not valid")
end
end
end
@Fivell
Fivell / cities_seeds
Created April 7, 2012 10:45
rails geo seeds
This file has been truncated, but you can view the full file.
# encoding: utf-8
City.transaction do
City.create! [
{id: 10, country_id: 254, state_id: 122, name: "Mobile"},
{id: 277, country_id: 254, state_id: 127, name: "Eagle"},
{id: 429, country_id: 254, state_id: 135, name: "Macomb"},
{id: 616, country_id: 254, state_id: 145, name: "Redwood Falls"},
{id: 687, country_id: 254, state_id: 149, name: "Burwell"},
{id: 1153, country_id: 254, state_id: 172, name: "Burlington"},
{id: 1154, country_id: 254, state_id: 172, name: "Montpelier"},
@Fivell
Fivell / SplClassLoader.php
Created May 21, 2012 18:22 — forked from wilmoore/SplClassLoader.php
PHP 5.3 Namespace Autoloader
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
@Fivell
Fivell / PHP autoload lambda
Created May 21, 2012 22:34
php 5.3 autoload lambdA
<?php
spl_autoload_register(function($className)
{
$fileName = str_replace('\\', '/', ltrim($className, '\\')) . '.php';
if (file_exists($fileName)){
require $fileName;
return class_exists($className, false);
}
return false;
@Fivell
Fivell / gist:2845986
Created May 31, 2012 20:27
heroku facebook index.php
<?php
/**
* This sample app is provided to kickstart your experience using Facebook's
* resources for developers. This sample app provides examples of several
* key concepts, including authentication, the Graph API, and FQL (Facebook
* Query Language). Please visit the docs at 'developers.facebook.com/docs'
* to learn more about the resources available to you
*/
@Fivell
Fivell / play.rb
Created August 2, 2012 21:32
Ruby video player implemented using HornetsEye
require 'rubygems'
require 'hornetseye_ffmpeg'
require 'hornetseye_xorg'
require 'hornetseye_alsa'
include Hornetseye
input = AVInput.new 'sintel.mp4'
alsa = AlsaOutput.new 'default:0', input.sample_rate, input.channels
audio_frame = input.read_audio
X11Display.show 600, :output => XVideoOutput do |display|
img = input.read
@Fivell
Fivell / orders.rb
Created September 9, 2012 07:47 — forked from emzeq/orders.rb
rails3-jquery-autocomplete in ActiveAdmin
form do |f|
f.form_buffers.last << f.autocompleted_input(:product_name, url: autocomplete_product_name_orders_path, label: 'Product')
end
@Fivell
Fivell / gson_builder.rb
Created September 14, 2012 11:08
jruby java objects to_json with Gson
require 'gson-1.6.jar'
class GsonBuilder
include_package "com.google.gson"
def initialize
@gson = GsonBuilder.new.setFieldNamingPolicy(FieldNamingPolicy::LOWER_CASE_WITH_UNDERSCORES).serializeNulls().create()
end
def to_json(obj)
@Fivell
Fivell / ruby_activemq_subscriber
Created September 15, 2012 10:59
ruby stomp subscriber example with durable topics
require 'rubygems'
require 'stomp'
client_id = "client-id"
subscription_name = "subName"
topic_name = "topicName"