Skip to content

Instantly share code, notes, and snippets.

@andreyshuster
andreyshuster / *gists*
Created July 17, 2012 13:50
find diffs in hashes
3425198 2012-08-22 12:41:34 public add this to config/envoronments/development.rb to set pry as default rails console
3129493 2012-07-17 13:50:22 public find diffs in hashes
@andreyshuster
andreyshuster / enable_pry.rb
Created August 22, 2012 12:41
add this to config/envoronments/development.rb to set pry as default rails console
silence_warnings do
begin
require 'pry'
IRB = Pry
rescue LoadError
end
end
@andreyshuster
andreyshuster / static_counter.js
Created December 8, 2012 20:14
static counter function
var uniqueID = (function() {
var id = 0; // This is the private persistent value
// The outer function returns a nested function that has access
// to the persistent value. It is this nested function we're storing
// in the variable uniqueID above.
return function() { return id++; }; // Return and increment
})(); // Invoke the outer function after defining it.
@andreyshuster
andreyshuster / gist:7887657
Created December 10, 2013 09:01
get object value by passing string
Object.byString = function(o, s) {
s = s.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
s = s.replace(/^\./, ''); // strip a leading dot
var a = s.split('.');
while (a.length) {
var n = a.shift();
if (n in o) {
o = o[n];
} else {
return;
@andreyshuster
andreyshuster / download_progress
Last active September 22, 2019 10:37
ajax download file with progress bar
var target = "file destination";
// check compartibility
// reset progress bar
$('.progress-bar').css('width', '0%').attr('aria-valuenow', 0);
var xhr=new XMLHttpRequest();
xhr.overrideMimeType('application/octet-stream');
xhr.open('GET', target, true);
xhr.responseType='arraybuffer';
xhr.send();
xhr.onprogress=function(e){
@andreyshuster
andreyshuster / gist:e5e944afb1ee13c41d22
Created May 12, 2014 12:55
compare 2 text files and print lines that differs
cat file1.txt file2.txt| sort | uniq -d
git log --oneline --graph --decorate --all
SELECT value$ FROM sys.props$ WHERE name = 'NLS_CHARACTERSET' ;
SELECT * FROM NLS_DATABASE_PARAMETERS
- go to first char of a line and use blockwise visual mode (CTRL-V)
- go down/up until first char of all lines I want to comment out are selected
- use SHIFT-I and then type my comment character (# for ruby)
- use ESC to insert the comment character for all lines
@andreyshuster
andreyshuster / gist:9c44205665bace9cd84c
Created June 10, 2014 12:10
find and replace in files in current folder
find . -type f -exec sed -i -e 's/<source>/<destination>/g' {} \;