Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Andrey Koleshko ka8725

🏠
Working from home
Block or report user

Report or block ka8725

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
View ruby.rb
class Base
end
class A < Base
def foo
puts 'foo'
end
end
class A < Base
View magic.ru
params = {a: 1, b: "2", n: {c: 3}}
struct = Magic.new(params)
struct.a # => 1
struct.b # => "2"
struct.c # => undefined method "c"
struct[] # => undefined method "[]"
struct.a = 2 # => undefined method "a ="
View gist:551daaf4ea9256706393
Running 30s test @ http://127.0.0.1:3000/users
1 threads and 16 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 321.24ms 37.67ms 794.62ms 93.10%
Req/Sec 49.87 6.95 60.00 67.80%
1491 requests in 30.08s, 13.32MB read
Requests/sec: 49.56
Transfer/sec: 453.51KB
View cache_pool.rb
class User
end
class UserChild < User
end
def cache
@cache ||= {}
end
View cache.rb
@semaphore = Mutex.new
def cache
@cache ||= {}
end
def get_y
sleep 1
Object.new
end
View migrations.txt
Timeline
production state ->|
|
|<- migration that changes User entities, developer #1, no tests for the migration
|
|<- migration that renames User to Customer, developer #2, no tests for the migration
|
|
deploy -> |
|
View finalize.rb
1 module HasFinalize
2 def self.included(base)
3 base.class_eval do
4 private
5
6 def finalize(&block)
7 ObjectSpace.define_finalizer(self, &block)
8 end
9 end
10 end
View qsort.erl
% **Quicksort**
% The head of the list is taken as the pivot; the list is then split according to those elements smaller
% than the pivot and the rest. These two lists are then recursively sorted by quicksort, and joined together,
% with the pivot between them.
-module(test).
-export([qsort/1]).
reverse(List) ->
reverse(List, []).
@ka8725
ka8725 / msort.erl
Last active Dec 26, 2015
The merge sort algorithm implemented in Erlang
View msort.erl
msort([]) ->
[];
msort([H|[]]) ->
[H];
msort(List) ->
[H|L] = divide2(List),
msort(msort(H), msort(L)).
msort(List1, List2) ->
msort(List1, List2, []).
View pwd.rb
Warden::Strategies.add(:password) do
def authenticate!
service = UserLoginService.new(params['email'], params['password'])
if service.authenticate?
success!(service.user)
else
throw :warden
end
end
You can’t perform that action at this time.