Skip to content

Instantly share code, notes, and snippets.

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

Eugeny esshka

🏠
Working from home
View GitHub Profile
<form action="<%= @pay_desc['mrh_url'] %>" method="post">
<input type=hidden name=MrchLogin value="<%= @pay_desc['mrh_login'] %>">
<input type=hidden name=OutSum value="<%= @pay_desc['out_summ'] %>">
<input type=hidden name=InvId value="<%= @pay_desc['inv_id'] %>">
<input type=hidden name=Desc value="<%= @pay_desc['inv_desc'] %>">
<input type=hidden name=SignatureValue value="<%= @pay_desc['crc'] %>">
<input type=hidden name=Shp_item value="<%= @pay_desc['shp_item'] %>">
<input type=hidden name=IncCurrLabel value="<%= @pay_desc['in_curr'] %>">
<input type=hidden name=Culture value="<%= @pay_desc['culture'] %>">
<input type=submit value='Оплатить'>
# Speed things up by not loading Rails env
config.assets.initialize_on_precompile = false
Tested on: Datatable 1.8.2, Rails 3.1.3
This example uses Coffeescript and Haml (you should too :-) )
The following is an example of Datatables server-side processing of a table
which displays a user's song list including the songs' artist names. In
Rails, Song and Artist are ActiveRecord models in a one artist-many song relat.
1a. the Rails controller code
class SongsController < ApplicationController
  1. Add gem 'delayed_job', '2.1.4' to your Gemfile

  2. Run bundle install

  3. Run rails g migration create_delayed_jobs

  4. Edit the created migration to contain:

     class CreateDelayedJobs < ActiveRecord::Migration
       def self.up
         create_table :delayed_jobs, :force => true do |table|
           table.integer  :priority, :default => 0      # jobs can jump to the front of
    

table.integer :attempts, :default => 0 # retries, but still fail eventually

# derived from http://railscasts.com/episodes/340-datatables
# handles server side multi-column searching and sorting
class Datatable
delegate :params, :h, :raw, :link_to, :number_to_currency, to: :@view
def initialize(klass,view)
@klass = klass
@view = view
end

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

# When calling a method with a splat then the parameters are passed as a comma separated list
# When receiving arguments with a splat then they are converted into an Array
# When using a double splat (2.0+) then the argument is converted into a Hash (i.e. named parameters)
def foo(*args)
p args
end
foo 'a', 'b', 'c'
# => ["a", "b", "c"]
@esshka
esshka / sort.rb
Created May 6, 2014 10:00 — forked from aspyct/sort.rb
# Sample implementation of quicksort and mergesort in ruby
# Both algorithm sort in O(n * lg(n)) time
# Quicksort works inplace, where mergesort works in a new array
def quicksort(array, from=0, to=nil)
if to == nil
# Sort the whole array, by default
to = array.count - 1
end

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create Droplet

Create droplet of your liking (ubuntu 12.10 x32)

Setup DNS

On Digital Ocean, create a DNS entry for your server (xyz.com)

Make sure it has NS records that use digital oceans nameservers

# Login as root
ssh root@domain
# Create deploy user
adduser <username> #Adds User with username given. Enter Password when Prompted. Other Details are Optional
# Add user to sudo group
usermod -g <groupname> <username>
# Add .ssh/authorized_keys for deploy user