Skip to content

Instantly share code, notes, and snippets.

View belgoros's full-sized avatar

Serguei Cambour belgoros

View GitHub Profile
@belgoros
belgoros / wgc.ex
Created April 19, 2023 19:50 — forked from am-kantox/wgc.ex
Wolf + Goat + Cabbage
defmodule WolfGoatCabbage.State do
defstruct banks: %{true => [], false => []}, ltr: true, history: []
end
defmodule WolfGoatCabbage.Subj do
defstruct me: nil, incompatible: []
end
defmodule WolfGoatCabbage do
alias WolfGoatCabbage.{State, Subj}
@belgoros
belgoros / tm_properties
Created July 29, 2022 09:52 — forked from tedw/tm_properties
TextMate 2 Settings
spellChecking = true
spellingLanguage = 'en'
softTabs = true
softWrap = false
invisiblesMap = "~ \t┊"
TM_STRIP_WHITESPACE_ON_SAVE = true
TM_GIT = "/usr/local/bin/git"
TM_RUBY = "/usr/local/var/rbenv/shims/ruby"
@belgoros
belgoros / TestDouble.java
Created June 4, 2021 14:48 — forked from hillmanli-seekers/TestDouble.java
BigDecimal vs double: illustration of accuracy and performance impact
import java.math.BigDecimal;
import java.util.function.Consumer;
import java.util.function.DoubleSupplier;
import java.util.stream.DoubleStream;
public class TestDouble {
private static double doubleTotal = 0;
private static double kahanDoubleTotal = 0;
@belgoros
belgoros / stored_procedure_service.rb
Created May 8, 2021 15:53 — forked from ys/stored_procedure_service.rb
Execute stored procedure
class StoredProcedureService
def self.instance
@instance ||= StoredProcedureService.new
end
def execute(name, *args)
results = []
begin
connection.execute("CALL #{name}(#{args.join(',')})").each(as: :hash, symbolize_keys: true) do |row|
@belgoros
belgoros / gist:6a8b233ea70abd449202aa3baecbdffa
Created July 31, 2020 07:46 — forked from leftclickben/gist:322b7a3042cbe97ed2af
Steps to migrate from SVN to GitLab

Steps to migrate from SVN to GitLab

This process worked for me. I take no responsibility for any damage or loss incurred as a result of following or not following these steps or, for that matter, anything else you might do or not do.

Setup

  • SVN is hosted at svn.domain.com.au.
  • SVN is accessible via http (other protocols should work).
  • GitLab is hosted at git.domain.com.au and:
@belgoros
belgoros / Guardian JWT.md
Created October 24, 2019 14:04 — forked from nikneroz/Guardian JWT.md
Elixir + Phoenix Framework + Guardian + JWT. This is tutorial and step by step installation guide.

Elixir + Phoenix Framework + Guardian + JWT + Comeonin

Preparing environment

We need to generate secret key for development environment.

mix phoenix.gen.secret
# ednkXywWll1d2svDEpbA39R5kfkc9l96j0+u7A8MgKM+pbwbeDsuYB8MP2WUW1hf

Let's generate User model and controller.

@belgoros
belgoros / regexCheatsheet.js
Created January 15, 2019 08:35 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@belgoros
belgoros / components.a-teeny-component.js
Created October 26, 2018 15:09 — forked from jenweber/components.a-teeny-component.js
Example of passing actions from controller to nested component
import Ember from 'ember';
export default Ember.Component.extend({
});
@belgoros
belgoros / a-teeny-component.component.js
Created October 26, 2018 15:09 — forked from NullVoxPopuli/a-teeny-component.component.js
Example of passing actions from controller to nested component
import Ember from 'ember';
export default Ember.Component.extend({
// this component only received args from the caller
// but it does track its own local info property
info: '', // initial form field value
});
@belgoros
belgoros / pr.md
Created July 19, 2016 07:44 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: