Skip to content

Instantly share code, notes, and snippets.

Nikolay Rozhkov nirname

Block or report user

Report or block nirname

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nirname
nirname / notifier.rb
Last active Jul 10, 2018
Send email through ApplicationMailer with file attachments from ActiveStorage
View notifier.rb
response.docs.each_with_index do |doc, i|
attachments[doc.filename.to_s] = {:mime_type => doc.blob.content_type, :content => doc.blob.download }
end
@nirname
nirname / stdin.sh
Created Aug 8, 2016
Read stdin in shell
View stdin.sh
myvar=`cat`
echo "$myvar"
@nirname
nirname / sqlformat.sh
Last active Aug 8, 2016
Using `sqlformat` for pgAdmin3
View sqlformat.sh
#!/bin/bash
/usr/local/bin/sqlformat --keywords upper --reindent --identifiers lower -
@nirname
nirname / .gitconfig
Last active Nov 25, 2015
Git comparison with meld
View .gitconfig
[diff]
external = /home/user/diff.py
@nirname
nirname / options.coffee
Last active Nov 25, 2015
Catch list of parameters in function
View options.coffee
// coffescript
(options...)->
$.each options, (i, v)->
console.log v
@nirname
nirname / superkiller.js
Created Nov 10, 2015
Recursivly remove property by name
View superkiller.js
function superkiller(o, prop_name) {
if(o.hasOwnProperty(prop_name)) {
delete o[prop_name]
}
$.each(x, function(i, e) {
if(typeof(e) == "object") { superkiller(e, prop_name) }
});
}
@nirname
nirname / escape.rb
Created Apr 24, 2015
Escape HTML and split user text from text_area to display
View escape.rb
h.simple_format h.h(object.text)
@nirname
nirname / delegate_all.rb
Created Apr 19, 2013
Delegates all method to target
View delegate_all.rb
def method_missing(method_name, *arguments, &block)
return target.send(method_name, *arguments, &block) if target.respond_to? method_name
super
end
@nirname
nirname / boolean.rb
Last active Dec 12, 2015
Condition with array of predicated
View boolean.rb
[true, false].reduce(&:&)
[true, false].reduce(&:|)
# the same
[true, false].any?
@nirname
nirname / unique.coffee
Last active Dec 11, 2015
Making a unique javascript array using JQuery
View unique.coffee
if Array.prototype.unique == undefined
Array.prototype.unique = ->
filtered_array = []
$.each this.sort(), (index, value)->
filtered_array.push(value) if filtered_array.indexOf(value) == -1
filtered_array
if Array.prototype.is_unique == undefined
Array.prototype.is_unique = ->
this.length == this.unique.length
You can’t perform that action at this time.