Skip to content

Instantly share code, notes, and snippets.

View Epigene's full-sized avatar

Augusts Bautra Epigene

View GitHub Profile
SELECT `applications`.* FROM `applications` LEFT OUTER JOIN `agreements` `agreements_f0` ON `applications`.`id` = `agreements_f0`.`application_id` WHERE ((`applications`.`hidden` = ? OR `applications`.`hidden` IS ?)) AND ((LOWER(`applications`.`client_name`) LIKE LOWER(?)) OR (LOWER(`applications`.`client_email`) LIKE LOWER(?)) OR (LOWER(`applications`.`client_identification_no`) LIKE LOWER(?)) OR (LOWER(`applications`.`client_phone`) LIKE LOWER(?)) OR (LOWER(`applications`.`client_phone2`) LIKE LOWER(?)) OR (LOWER(`applications`.`client_phone3`) LIKE LOWER(?)) OR (LOWER(`applications`.`client_phone4`) LIKE LOWER(?)) OR (LOWER(`applications`.`vehicle_no`) LIKE LOWER(?)) OR (LOWER(`applications`.`vehicle_vin`) LIKE LOWER(?)) OR (LOWER(`applications`.`vehicle_no2`) LIKE LOWER(?)) OR (LOWER(`applications`.`vehicle_technical_certificate_no`) LIKE LOWER(?)) OR (LOWER(`applications`.`vehicle_technical_certificate_no2`) LIKE LOWER(?)) OR (LOWER(`applications`.`number`) LIKE LOWER(?)) OR (LOWER(`applications`.`reque
@Epigene
Epigene / ruby.json
Last active August 31, 2018 12:38
Ruby (predominantly RSpec) snippets for VSC.
{
"scope spec template": {
"prefix": "scope_spec",
"body": [
"describe \".SCOPE_NAME\" do",
" subject(:collection) { described_class.SCOPE_NAME }",
"",
" context \"when instantiating actual records\", :slow do",
" let!(:match) { create(:FACTORY, :TRAIT) }",
" let!(:counter) { create(:FACTORY) }",
@Epigene
Epigene / UbuntuRedis.md
Last active August 15, 2018 10:17
Install Redis on your Production Ubuntu

Install deps

sudo apt-get update
sudo apt-get install -y build-essential tcl8.5

Get code

cd /tmp
@Epigene
Epigene / Nim Spells.md
Created July 17, 2018 20:16
Some know-how and cheats for Nim programming languages

Compiling with the -d:release flag will turn the bounds checks off. This will result in higher performance but less safety.

@Epigene
Epigene / resales_flow.md
Last active May 24, 2018 08:06
Kā pārpušot Order datus uz app.
  1. CPP pusē atrod ordera ID un epastu
  2. SHA pusē atrod SalesEvent ierakstu, kura Origin ir 1. solī atrastais ID
  3. Dzēš 2. solī atrasto SalesEvent
  4. Parūpējas, ka SHA pusē nav Useru, kuru :email vai :origin_email ir tāds, kā iecerētais jaunais epasts
  5. CPP pusē 1. solī atrastajam Order iestata statusu "new" un samaina epastu uz vajadzīgo
  6. Tam pašam Order samaina statusu uz "paid", izņem "api processed ķeksi" un saglabā
  7. Pārliecinās, ka SH pusē ir jauns SalesEvent ar Origin, kas sakrīt ar 1. solī iegūto ID un jaunu user asociāciju
{
"workbench.colorTheme": "Solarized Dark",
"editor.minimap.enabled": false,
"explorer.fontFamily": "DejaVu Sans Mono",
"explorer.autoReveal": false,
"editor.fontFamily": "DejaVu Sans Mono, 'Courier New', monospace, 'Droid Sans Fallback'",
"editor.tabSize": 2,
"editor.fontSize": 12.5,
"window.zoomLevel": 1,
"editor.rulers": [80, 120],
@Epigene
Epigene / test_service.rb
Created February 23, 2018 09:53
An example of a service class code created by a rails service generator
module V1
module Api
class TestService
# This service TODO
def initialize
end
def call
end
@Epigene
Epigene / bench_data.csv
Created October 14, 2017 17:13
Raw data for setup strategy comparison
file line_number group time
./spec/setup_benchmark.rb 9 SetupBenchmark::NewVSAllOthersWhenTestingBookVampireTitle::WhenSettingUpWithNew 0.198
./spec/setup_benchmark.rb 17 SetupBenchmark::NewVSAllOthersWhenTestingBookVampireTitle::WhenSettingUpWithInstanceDouble 0.173
./spec/setup_benchmark.rb 25 SetupBenchmark::NewVSAllOthersWhenTestingBookVampireTitle::WhenSettingUpWithFactoryGirlBuildStubbed 0.396
./spec/setup_benchmark.rb 33 SetupBenchmark::NewVSAllOthersWhenTestingBookVampireTitle::WhenSettingUpWithFactoryGirlBuild 0.916
./spec/setup_benchmark.rb 41 SetupBenchmark::NewVSAllOthersWhenTestingBookVampireTitle::WhenSettingUpWithFactoryGirlCreate 1.155
./spec/setup_benchmark.rb 55 SetupBenchmark::InstanceDoubleVSFactoryGirlBuildStubbedFactoryGirlBuildAndFactoryGirlCreate::WhenSettingUpWithInstanceDouble 0.443
@Epigene
Epigene / book.rb
Created October 14, 2017 17:00
complete mock
after_save :do_something
private
def do_something
ApplicationRecord.class
end
@Epigene
Epigene / bout4.rb
Created October 14, 2017 16:58
Build VS create
describe "FactoryGirl.build VS FactoryGirl.create" do
subject { book.save! }
bout4_number_of = 200
context "when setting up with FactoryGirl.build" do
let(:book) { build(:book) }
bout4_number_of.times do
it "triggers ApplicationRecord.class in callback" do