Skip to content

Instantly share code, notes, and snippets.

View ehlyzov's full-sized avatar

Eugene Hlyzov ehlyzov

  • http://datafabric.cc
  • SaintPetersburg, Russia
View GitHub Profile
def calculate_params(context, method_name, params)
if params.kind_of?(Array)
context.send(method_name, *params)
elsif params.kind_of?(Hash)
context = context.send(method_name)
calculate_params(context, params.keys[0], params.values[0])
elsif params.respond_to?(:to_sym)
context.send(method_name, params)
else raise ArgumentError, "Unknown type of function params"
end
j(document).click(function(e){
if(j('#popup_div').is(':visible') && !(e.target.id == 'popup_div') && (0 == j(e.target).parents('#popup_div').length)) {
j('#popup_div');
}
});
module ProteinPresenter
custom_presenter = lambda { |att| att.to_s }
# тут делаются презентеры, хотя лучше из выносить вообще в
# отдельные файлы. Существующих возможностей для этого куча.
presenter :title, lambda {|att| attr.capitalize }
presenter :num, custom_presenter
presenter :m2, lambda {|m| m.to_s.capitalize }
end
output :json
module ProteinPresenter
custom_presenter = lambda { |att| att.to_s }
# тут делаются презентеры, хотя лучше из выносить вообще в
# отдельные файлы. Существующих возможностей для этого куча.
presenter :title, lambda {|att| attr.capitalize }
presenter :num, custom_presenter
presenter :m2, lambda {|m| m.to_s.capitalize }
end
output :json
{
"people":[
{
"person":{
"animals":[
{
"animal":{
"id":416016843,
"name":"Poiyo",
"pet_type":"fish",
# Controller
def dull_party
Human.class_eval do
def login
name
end
def hello_world
'Hello world!'
(defun gist-region (begin end &optional private)
"Post the current region as a new paste at gist.github.com
Copies the URL into the kill ring.
With a prefix argument, makes a private paste."
(interactive "r\nP")
(destructuring-bind (login . token) (github-auth-info)
(let* ((file (or (buffer-file-name) (buffer-name)))
(name (file-name-nondirectory file))
(ext (or (cdr (assoc major-mode gist-supported-modes-alist))
(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\.yml$" . yaml-mode))
;; use exuberant-ctags
;;
;; Generate file with:
;; ctags-exuberant -a -e -f TAGS --tag-relative -R app lib vendor
(setq rinari-tags-file-name "TAGS")
;; haml-mode and & sass-mode
def download
load_mascot_dat_file
unless File.exist?(@mascot_dat_file.source || '')
flash[:error] = "Couldn't find file #{@mascot_dat_file.source}"
redirect_to mascot_dat_files_path and return
end
send_file @mascot_dat_file.source
end
"log"
[["1811504200009947", "1811504200007535", "9165", :update, :no, :ok, #<MicrotiterPlate id: 2119993678, name: nil, number: "9947", created_at: "2010-02-28 10:55:03", updated_at: "2010-02-28 10:55:03", spotted_plate_id: nil, position: 14, barcode: "1811504200009947", parent_id: 2119993679, deleted_at: nil>], ["1811504200009992", "1811504200009302", "9163", :update, "20090401_gesell_4831-9301-9302-9303_Tof9163", :ok, #<MicrotiterPlate id: 2119993680, name: nil, number: "9992", created_at: "2010-02-28 10:55:12", updated_at: "2010-02-28 10:55:12", spotted_plate_id: nil, position: 16, barcode: "1811504200009992", parent_id: 116103490, deleted_at: nil>]]
[["1811504200009947", "1811504200007535", "9165", :update, :no, :ok, #<MicrotiterPlate id: 2119993678, name: nil, number: "9947", created_at: "2010-02-28 10:55:03", updated_at: "2010-02-28 10:55:03", spotted_plate_id: nil, position: 14, barcode: "1811504200009947", parent_id: 2119993679, deleted_at: nil>], ["1811504200009992", "1811504200009302", "9163", :upda