Skip to content

Instantly share code, notes, and snippets.

View lukaszkorecki's full-sized avatar
🌴
🛹

Łukasz Korecki lukaszkorecki

🌴
🛹
View GitHub Profile
@krzysiekherod
krzysiekherod / gist:9744218
Created March 24, 2014 16:48
automatic bisect
git bisect start HEAD HEAD~20 && git bisect run rspec ./spec/YOUR_TEST_FILE.rb:LINE_NUMBER ; git bisect reset
find $(manpath | tr ':' '\n') -iname '*.1' | xargs cat | (LC_CTYPE=C tr -C '[:alnum:]-_' '\n') | egrep '^--[\-_[:alnum:]]+$' | sort | uniq -c | sort -n
require 'active_support'
class MyLogger < ActiveSupport::BufferedLogger
SEVERITY_NAME = %w( DEBUG INFO WARN ERROR FATAL UNKNOWN )
def custom_line(severity, message)
# Customized Log Format!
message = [Time.now.strftime("%Y-%m-%d %H:%M:%S"), ENV['BL_JOB_ID']||$$, SEVERITY_NAME[severity], message].join("\t")
end
def add(severity, message = nil, progname = nil, &block)
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql-5.1.38-osx10.5-x86_64/bin/mysql_config
require 'net/http'
require 'uri'
require 'json'
# sudo gem install json
# Usage example:
# putio = Putio.new("YOUR_API_KEY","YOUR_API_SECRET")
# puts JSON.parse(putio.user.friends.get)
# puts JSON.parse(putio.search :query => "massive attack"
var input = document.getElementById('myfileinput');
var files = input.files;
var file = files[i];
var xhr = new XMLHttpRequest();
xhr.open('post', '/path/to/destination', true);
xhr.onreadystatechange = function() {
if (this.readyState != 4) { return; }
// request finished - handle response
};
@klang
klang / luddite-mode.el
Created August 20, 2010 07:03
Luddite mode for emacs gives a few extra lines, when the tool-, menu- and scroll-bars are turned off.
;; first, remove all the crap that looks different from emacs 20.7.1
; luddite mode
(cond ((> emacs-major-version 20)
(tool-bar-mode -1) ; introduced in emacs 21
(menu-bar-mode -1)
(scroll-bar-mode -1)
(menu-bar-showhide-fringe-menu-customize-disable)
(blink-cursor-mode -1)
(windmove-default-keybindings 'meta)))
es_alias = ENV.fetch('ALIAS')
hosts = ENV.fetch('HOSTS')
old_index = ENV.fetch('OLD_INDEX')
old_type = ENV.fetch('OLD_TYPE')
new_index = ENV.fetch('NEW_INDEX')
new_type = ENV.fetch('NEW_TYPE')
size = ENV.fetch('SCAN_SIZE', 100)
client = Elasticsearch::Client.new(hosts: hosts)
unless client.indices.exists(index: new_index)
module Marshal
class << self
@@prok = Proc.new { |o| o.is_a?(String) ? Iconv.iconv("UTF-8//IGNORE", "UTF-8", o.force_encoding("UTF-8").encode("UTF-8")).first : o }
alias old_load load
def load(source)
old_load source, @@prok
end
end
describe "routes to the articles controller" do
extend RouteSpecHelpers
scope_options controller: 'articles', blog: 'my_blog'
get '/blogs/my_blog/articles/new' => { action: 'new' }
post '/blogs/my_blog/articles' => { action: 'create' }
get '/blogs/my_blog/articles/1' => {action: 'show', id: '1' }