Skip to content

Instantly share code, notes, and snippets.

View nilcolor's full-sized avatar
💫
API by day, IPA by night

Alexey Blinov nilcolor

💫
API by day, IPA by night
View GitHub Profile
@nilcolor
nilcolor / bdb.js
Created April 13, 2012 11:14
"Быстрый" датабиндинг для Backbone.js
events: {
"change input": "fieldChanged",
"change select": "selectionChanged",
},
selectionChanged: function(e){
var field = $(e.currentTarget);
var value = $("option:selected", field).val();
var data = {};
data[field.attr('id')] = value;
@nilcolor
nilcolor / bdb.coffee
Created April 13, 2012 11:17
"Быстрый" датабиндинг для Backbone.js
events:
"change input": "fieldChanged",
"change select": "selectionChanged",
selectionChanged: (event) ->
field = $ event.currentTarget
value = $("option:selected", field).val()
data = {}
data[field.attr 'id'] = value
@nilcolor
nilcolor / init.el
Created April 20, 2012 09:11 — forked from mig/init.el
Simple Emacs 24 configuration for Rails development
;; emacs configuration
(push "/usr/local/bin" exec-path)
(add-to-list 'load-path "~/.emacs.d")
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(setq inhibit-startup-message t)
@nilcolor
nilcolor / rspec-syntax-cheat-sheet.rb
Created May 4, 2012 06:36 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@nilcolor
nilcolor / currencies_spec.rb
Created May 4, 2012 08:36
API spec sample
require 'spec_helper'
describe "Currency catalog API" do
let(:token) { create(:user).authentication_token }
before(:all) do
2.times { create :currency }
end
describe 'fetch the list of currencies' do
@nilcolor
nilcolor / a.rb
Created June 29, 2012 12:53
Code styles
def catch22
model = Model.create!(:field1 => product_row[:part_number],
:field2 => product_row[:element_name],
:field3 => product_row[:pattern_value],
:field4 => product_row[:fixed_dp],
:field5 => product_row[:franchise_name],
:field6 => product_row[:product_code],
:field7 => (product_row[:volume].to_i == 0 ? nil : product_row[:volume]),
:field8 => product_row[:package_quantity])
# other code...
@nilcolor
nilcolor / ajax-file-upload.js
Created July 3, 2012 11:14
Upload file using FormData (a-la AJAX file upload using XMLHTTPRequest2)
function sendForm() {
var fileData = new FormData(document.getElementById("cpd-file"));
var xhr = new XMLHttpRequest();
xhr.open("POST", "/upload_file", true);
xhr.setRequestHeader('Accept', 'application/json');
xhr.onload = function(progressEvent) {
if (xhr.status == 200) {
console.log('Uploaded', xhr);
} else {
@nilcolor
nilcolor / 0. nginx_setup.sh
Created August 17, 2012 08:56 — forked from mikhailov/0. nginx_setup.sh
Nginx+Unicorn
# Nginx+Unicorn best-practices congifuration guide.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@nilcolor
nilcolor / sublime-shortcuts.md
Last active October 10, 2015 20:48 — forked from kahlil/sublime-shortcuts.md
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 - Useful Shortcuts (Mac OS X)

General

  • ⌘T go to file
  • ⌘⌃P go to project
  • ⌘R go to methods
  • ⌃G go to line
  • ⌘KB toggle side bar
  • ⌘⇧P command prompt
@nilcolor
nilcolor / gist:3781382
Created September 25, 2012 12:07 — forked from jasoncodes/gist:1223731
Installing Ruby 1.9.3 with rbenv
brew install rbenv
brew install ruby-build
brew install rbenv-vars
brew install readline
brew install ctags
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
exec $SHELL -i # reload the shell
CONFIGURE_OPTS="--disable-install-doc --with-readline-dir=$(brew --prefix readline)" rbenv install 1.9.3-p194
rbenv global 1.9.3-p194
gem install bundler rbenv-rehash git-up hitch gem-browse gem-ctags cheat awesome_print pry