Skip to content

Instantly share code, notes, and snippets.

Santosh Kumar santosh79

Block or report user

Report or block santosh79

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
@santosh79
santosh79 / escrow.sol
Created Jun 29, 2018
Escrow Solidity Contract
View escrow.sol
pragma solidity ^0.4.21;
// This is a simple smart
contract Escrow {
mapping(address => uint256) depositorMappings;
mapping(address => uint256) recipientMappings;
mapping(address => address) depositorToRecipientMappings;
mapping(address => address) recipientToDepositorMappings;
mapping(address => uint) depositorBlockMappings;
uint256 constant oneDayInBlocks = 3 * 60 * 24; // around 3 blocks a minute
View keybase.md

Keybase proof

I hereby claim:

  • I am santosh79 on github.
  • I am santosh_kumar (https://keybase.io/santosh_kumar) on keybase.
  • I have a public key whose fingerprint is A96B F906 823F 22CA 63B9 CBE4 7025 A470 FFBF E06F

To claim this, I am signing this object:

View array_flattener.ex
defmodule ArrayFlattener do
def flatten(list) do
flatten(list, []) |> :lists.reverse
end
def flatten([], acc) do; acc; end
def flatten([head|rest], acc) when is_list(head) do
flatten rest, flatten(head, acc)
end
View migrating_processes.ex
defmodule MigratingProcesses.Manager do
use GenServer
def start_link do
GenServer.start_link __MODULE__, :ok, [name: :migration_manager]
end
def init(:ok) do
Process.flag :trap_exit, true
{:ok, %{}}
View misc.ex
def pmap(coll, func) do
tasks = coll |>
Enum.map(fn(item) ->
Task.async(fn -> func.(item) end)
end) |> Enum.map(fn(task) ->
Task.await(task)
end)
end
View prime_finder.clj
(defn find-prime
[start end]
(take 1 (filter #(is-prime %) (range start end))))
View git_flow_for_production.md

Doing a staging cut

This involves taking what is in mainline(master) and moving it to staging.

git checkout staging
git pull origin staging
git checkout master
git pull origin master
git merge staging
git checkout staging
View simple_dns.ex
defmodule SimpleDNS do
def start do
pid = spawn __MODULE__, :loop, [%{}]
{:ok, pid}
end
def get_entry(pid, hostname) do
send pid, {self(), {:get_entry, hostname}}
get_response pid
end
View simple_rand.ex
defmodule SimpleDNS do
use GenServer
#
# Server
#
def start do
GenServer.start __MODULE__, :ok
end
def get_entry(pid, hostname) do
View simple_rand.ex
defmodule SimpleDNS do
def start do
pid = spawn __MODULE__, :loop, [%{}]
{:ok, pid}
end
def get_entry(pid, hostname) do
send pid, {self(), {:get_entry, hostname}}
get_response pid
end
You can’t perform that action at this time.