Skip to content

Instantly share code, notes, and snippets.

View ka8725's full-sized avatar
🚀
Ruby on Rails expert with business development mindset | WideFix Founder

Andrei Kaleshka ka8725

🚀
Ruby on Rails expert with business development mindset | WideFix Founder
View GitHub Profile
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 -> |
|
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
% **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 December 26, 2015 00:52
The merge sort algorithm implemented in Erlang
msort([]) ->
[];
msort([H|[]]) ->
[H];
msort(List) ->
[H|L] = divide2(List),
msort(msort(H), msort(L)).
msort(List1, List2) ->
msort(List1, List2, []).
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
We couldn’t find that file to show.
@ka8725
ka8725 / enum.rb
Last active September 12, 2015 02:44
require 'set'
class I18n
def self.t(t, options = {})
"#{t} - #{options}"
end
end
class Enum
class TokenNotFoundError < StandardError; end
directory 'gitstats'
EXCLUDE_FILES = /(^vendor\/)|(^public\/)|(\.(jpg|png|gif|bmp|yaml|yml|jar|zip|gz|rar)$)/.freeze
Member = Struct.new(:email, :lines) do
include Comparable
def <=>(other)
self.lines <=> other.lines
end
#lang racket
(require rackunit)
;; BEGIN
(define (sqr x)
(* x x))
(define (max x y)
(if (> x y) x y))
@ka8725
ka8725 / smart.txt
Last active August 29, 2015 14:17 — forked from avsej/smart.txt
smartctl 6.3 2014-07-26 r3976 [x86_64-linux-4.0.0-0.rc3.git2.1.fc23.x86_64] (local build)
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Device Model: Samsung SSD 850 PRO 256GB
Serial Number: S1SUNSAFA06649M
LU WWN Device Id: 5 002538 8a0713409
Firmware Version: EXM01B6Q
User Capacity: 256,060,514,304 bytes [256 GB]
Sector Size: 512 bytes logical/physical