Skip to content

Instantly share code, notes, and snippets.

Yuri Leikind leikind

  • Belgium
Block or report user

Report or block leikind

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 example.ex
case Connection.open(amqp_url) do
{:error, reason} -> # pattern matching
Logger.error(["Cannot establish connection to RabbitMQ, reason:", inspect(reason)])
{:error, reason}
{:ok, connection} -> # pattern matching
{:ok, channel} = Channel.open(connection) # pattern matching
Exchange.declare(channel, @exchange, :fanout)
View keybase.md

Keybase proof

I hereby claim:

  • I am leikind on github.
  • I am leikind (https://keybase.io/leikind) on keybase.
  • I have a public key ASDfZ5OGmfASmpWp5FyIxWP0wwPHAP3YNEp0D4Xn6SQ54go

To claim this, I am signing this object:

@leikind
leikind / upgrade.md
Last active Mar 14, 2017 — forked from chrismccord/upgrade.md
Phoenix 1.2.x to 1.3.0 Upgrade Instructions
View upgrade.md

If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8

To use the new phx.new project generator, you can install the archive with the following command:

$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

Bump your phoenix dep

Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs:

View shapes.rb
require 'set'
module Shapes
class Coordinate < Struct.new(:x, :y)
def inspect; "#{x}:#{y}"; end
end
class Line < Struct.new(:p1, :p2)
def inspect
View auth_examples.ex
defmodule Efrontback.AuthExamples do
alias Efrontback.Device
alias Efrontback.User
alias Efrontback.Repo
use Efrontback.Web, :model
def no_schema() do
real_device_token = "abcdefg"
View ruby_poor_mans_monads.rb
# kinda library code
def pack(v)
[v]
end
class Array
def unpack
self[0]
end
@leikind
leikind / pack_string_in_number_and_back.rb
Created Nov 4, 2016
pack a UTF8 string in a huge number, and unpack it
View pack_string_in_number_and_back.rb
def string_to_number(str)
Integer('0b' + str.unpack('B*')[0])
end
def number_to_utf8_string(num)
str = [num.to_s(2)].pack('B*')
str.force_encoding(Encoding::UTF_8)
end
p string_to_number("мудак")
View resize.go
package main
import (
"fmt"
"github.com/nfnt/resize"
"image/jpeg"
"io"
"os"
)
View elixir_coin.md

ElixirCoin

Let's build a small distributed system to mine a new cryptocurrency and become millionaires in ElixirCoins!

An ElixirCoin is a {secret_string, positive_integer} pair for which the MD5 digest of the concatenation of the secret string with the given integer is a hash whose hexadecimal representation starts with at least 5 consecutive zeroes.

For instance:

  • {"foo", 123} is not an ElixirCoin because the MD5 hash of foo123 is ef238ea00a26528de40ff231e5a97f50
  • {"Serun+u", 1} is a valid ElixirCoin because the MD5 hash of Serun+u1 is 00000011f4de73238f12fb2c57d5dc56
@leikind
leikind / SignalOfRandomNum.elm
Created Dec 15, 2015
A signal of random numbers every second where the first seed is a timestamp
View SignalOfRandomNum.elm
module SignalOfRandomNum where
import Graphics.Element as GE
import Time
import Random
import Maybe exposing (..)
randomIntSignal : Int -> Int -> Signal Time.Time -> Signal Int
randomIntSignal lo hi inputSignal =
let
You can’t perform that action at this time.