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 / 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 / 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 / active_admin.rb
Created November 1, 2012 14:38 — forked from fred/active_admin.rb
extend active admin to prettier boolean values
# It extends activeadmin to show pretty boolean values
#
# config/initializers/active_admin.rb
module ActiveAdmin
module Views
class TableFor
def bool_column(attribute)
column(attribute){ |model| model[attribute] ? '&#x2714;'.html_safe : '&#x2717;'.html_safe }
end
@Fivell
Fivell / gist:4001706
Created November 2, 2012 14:31 — forked from simonharrer/gist:1173228
Use JRuby to create a Java Soap Web Service
require 'java'
require 'jruby/core_ext'
module WS
class WebService
def test()
puts "Call received at #{Time.new}"
# x = Result.new
# x.name = "asdf"
# return x
@Fivell
Fivell / active_admin.rb
Created November 8, 2012 14:01 — forked from rdj/active_admin.rb
active_admin custom filter
# config/initializers/active_admin.rb
require 'active_admin_custom_filter'
ActiveAdmin.setup do |config|
# ...
end
@Fivell
Fivell / deploy.rb
Created November 20, 2012 13:00 — forked from mrichman/deploy.rb
Capistrano deploy.rb
set :application, "myapplication"
set :repository, "user@example.com:git/#{application}.git"
set :server_name, "www.example.com"
set :scm, "git"
set :checkout, "export"
set :deploy_via, :remote_cache
set :branch, "master"
set :base_path, "/path/to/www"
set :deploy_to, "/path/to/www/#{application}"
set :apache_site_folder, "/etc/apache2/sites-enabled"
class ZendeskTicketsJob
extend Resque::Plugins::ExponentialBackoff
@queue = :low
FIELDS = ['zendesk_id', 'requester_id', 'assignee_id', 'group', 'subject', 'tags', 'status', 'priority', 'via', 'ticket_type', 'created_at', 'assigned_at', 'solved_at', 'resolution_time', 'satisfaction', 'group_stations', 'assignee_stations', 'reopens', 'replies', 'first_reply_time_in_minutes', 'first_reply_time_in_minutes_within_business_hours', 'first_resolution_time_in_minutes', 'first_resolution_time_in_minutes_within_business_hours', 'full_resolution_time_in_minutes', 'full_resolution_time_in_minutes_within_business_hours', 'agent_wait_time_in_minutes', 'agent_wait_time_in_minutes_within_business_hours', 'requester_wait_time_in_minutes', 'requester_wait_time_in_minutes_within_business_hours', 'reservation_code', 'requires_manual_closing']
def self.perform(url)
`rm /tmp/zendesk_tickets*`
`wget #{url} -O /tmp/zendesk_tickets.csv.zip`
`unzip -p /tmp/zendesk_tickets.csv.zip > /tmp/zendesk_tickets.csv`
# db/migrate/20111218135715_globalize_models.rb
class GlobalizeModels < ActiveRecord::Migration
def up
NewsItem.create_translation_table!(
{:title => :string, :body => :text},
{:migrate_data => true}
)
end
# db/migrate/20111218135715_globalize_models.rb
class GlobalizeModels < ActiveRecord::Migration
def up
NewsItem.create_translation_table!(
{:title => :string, :body => :text},
{:migrate_data => true}
)
end