Skip to content

Instantly share code, notes, and snippets.

@hukl
hukl / gist:1401981
Created November 28, 2011 20:49
Erlang Shell History Errors
[hukl@nine ~/Desktop/erlang:master]$ erl
Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:8:8] [rq:8] [async-threads:0] [hipe] [kernel-poll:false]
*** ERROR: Shell process terminated! ***
{error_logger,{{2011,11,28},{21,45,14}},"~s~n",["Error in process <0.23.0> with exit value: {{case_clause,{error,{{bad_object,eval_work_list},\"/Users/hukl/.erlang-hist.nonode@nohost\"}}},[{group_history,load,2},{group_history,load,2},{group,server,3}]}\n"]}
{error_logger,{{2011,11,28},{21,45,14}},"~s~n",["Error in process <0.24.0> with exit value: {{case_clause,{error,{{bad_object,eval_work_list},\"/Users/hukl/.erlang-hist.nonode@nohost\"}}},[{group_history,load,2},{group_history,load,2},{group,server,3}]}\n"]}
{error_logger,{{2011,11,28},{21,45,14}},supervisor_report,[{supervisor,{<0.21.0>,user_sup}},{errorContext,child_terminated},{reason,{{case_clause,{error,{{bad_object,eval_work_list},"/Users/hukl/.erlang-hist.nonode@nohost"}}},[{group_history,load,2},{group_history,load,2},{group,server,3}]}},{offender,[{pid,<0.23.0
@hukl
hukl / gist:1364952
Created November 14, 2011 19:54
Ruby vs Erlang building URL query params for a GET request
-module(myjoin).
-export([join/1, join/2, start/0]).
start() ->
join( [{foo,"bar"},{baz,"bang"}] ).
join([H|T]) ->
{K,V} = H,
Acc = atom_to_list(K) ++ "=" ++ V,
@hukl
hukl / has_many_through_boom.rb
Created October 24, 2011 18:49
has_many :through regression. behaves as if :uniq => true was set
require 'active_record'
# Print out what version we're running
puts "Active Record #{ActiveRecord::VERSION::STRING}"
# Connect to an in-memory sqlite3 database (more on this in a moment)
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => ':memory:'
@hukl
hukl / has_many.rb
Created October 23, 2011 19:58
Rails has_many :through regression
class Order
has_many :order_tickets
has_many :tickets, :through => :order_tickets
end
class Ticket
has_many :order_tickets
has_many :orders, :through => :order_tickets
end
@hukl
hukl / Time.rb
Created September 13, 2011 15:08
Got to love ruby
Timecop.travel( 10.minutes.ago ) do
# do some stuff in the past
end
# Return back to normal
@hukl
hukl / last_changed.sh
Created August 26, 2011 14:57
Get revision when a given file was last modified
git log --pretty=format:%H file | head -n1
@hukl
hukl / varnish.vcl
Created July 15, 2011 15:27
Varnish Conf for local / subnet cache of ruby gems index
backend default {
.host = "production.s3.rubygems.org";
.port = "80";
}
sub vcl_recv {
set req.http.Host = "production.s3.rubygems.org";
return(lookup);
}
@hukl
hukl / base64.rb
Created June 21, 2011 19:08
Manual Base64 Padding
payload << "=" until ( payload.length % 4 == 0 )
@hukl
hukl / custom_analyzer.sh
Created May 24, 2011 16:34 — forked from karmi/elastic_search_ngram_analyzer_for_urls.sh
NGram Analyzer in ElasticSearch
curl -X DELETE localhost:9200/custom_analyzer_test
curl -X PUT localhost:9200/custom_analyzer_test -d '
{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0,
"analysis" : {
"analyzer" : {
"url_analyzer" : {
int cursor = 0;
SearchResponse searchResponse = new SearchRequestBuilder(client)
.setIndices(alias)
.setSearchType(SearchType.SCAN)
.setQuery(matchAllQuery())
.setSize(10)
.setFrom(cursor)
.setScroll(TimeValue.timeValueMinutes(10))
.execute()