Skip to content

Instantly share code, notes, and snippets.

View akirill0v's full-sized avatar

Alexander Kirillov akirill0v

View GitHub Profile
@akirill0v
akirill0v / Gemfile
Created May 11, 2011 16:41 — forked from victusfate/Gemfile
Rails 3.1 Beta 1 on Heroku Working Config
# source 'http://rubygems.org'
source :gemcutter
gem 'rails', '3.1.0.beta1'
# Asset template engines
gem 'json'
gem 'sass'
gem 'coffee-script'
gem 'uglifier'
@akirill0v
akirill0v / gist:1596827
Created January 11, 2012 21:20 — forked from Watson1978/gist:1062455
MacRuby : Build UniversalBinary

Build LLVM 2.9

$ svn co https://llvm.org/svn/llvm-project/llvm/branches/release_29@127367 llvm-2.9
$ cd llvm-2.9
$ env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" CC=/usr/bin/gcc CXX=/usr/bin/g++ ./configure --enable-bindings=none --enable-optimized --with-llvmgccdir=/tmp
$ env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" CC=/usr/bin/gcc CXX=/usr/bin/g++ make 
$ sudo env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" CC=/usr/bin/gcc CXX=/usr/bin/g++ make install

Build MacRuby

@akirill0v
akirill0v / engine.rb
Created January 25, 2012 19:31
Include jquery-rails into Engine (Rails 3.x)
require 'rails'
require 'jquery-rails'
$:.unshift File.dirname(__FILE__)
module MyEngine
class Engine < Rails::Engine
if defined?(query::Rails::Engine)
initializer :after_append_asset_paths,
:group => :all,
@akirill0v
akirill0v / 0-readme.md
Created January 31, 2012 19:13 — forked from burke/0-readme.md
ruby-1.9.3-p0 cumulative performance patch.

Patched ruby 1.9.3-p0 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p0 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84).

Huge thanks to funny-falcon for the performance patches.

@akirill0v
akirill0v / gist:2366922
Created April 12, 2012 12:30 — forked from realmyst/gist:1262561
Склонение числительных в javascript
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
use:
declOfNum(count, ['найдена', 'найдено', 'найдены']);
@akirill0v
akirill0v / gist:2366996
Created April 12, 2012 12:46 — forked from realmyst/gist:2366995
rails pluralization
#yml:
in_count_complex:
one: "в %{count} комплексе"
few: "в %{count} комплексах"
many: "в %{count} комплексах"
#view:
= t :in_count_complex, :count => projects.count
require File.join(File.dirname(__FILE__), 'token')
class Lexer
attr_reader :grammar_rules, :regex_pattern, :output, :buffer, :priority_hash
DEFAULT_GRAMMAR_RULES = {
:operators => %w[\+ \- \* \/ \^],
:brackets => %w[\( \)],
:operands => ['\d*\.\d+|0\.\d+|-0\.\d*[1-9]\d*', '\d+']
}
PRIORITY_HASH = {
@akirill0v
akirill0v / gist:3340977
Created August 13, 2012 13:51 — forked from kosmatov/image-preview-html5.js
File preview on HTML5/JS/jQuery
$('form').on('change', 'input[type="file"]', function(e) {
var files = e.target.files,
f = files[0],
reader = new FileReader(),
t = this
;
reader.onload = (function(file) {
require 'multi_json'
MultiJson.load('{"abc":"def"}') #=> {"abc" => "def"}
MultiJson.load('{"abc":"def"}', :symbolize_keys => true) #=> {:abc => "def"}
MultiJson.dump({:abc => 'def'}) # в JSON
MultiJson.dump({:abc => 'def'}, :pretty => true) # + преобразует в наглядный вид
store_translations(:de, :i18n => {
:transliterate => {
:rule => {
"ü" => "ue",
"ö" => "oe"
}
}
)
I18n.locale = :en