Skip to content

Instantly share code, notes, and snippets.

View blackode's full-sized avatar
:octocat:
Pushed code so fast, even my coffee is still loading. ☕💻 #CodingFuel

Ankanna blackode

:octocat:
Pushed code so fast, even my coffee is still loading. ☕💻 #CodingFuel
View GitHub Profile
@blackode
blackode / README-Template.md
Created August 7, 2019 02:54 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@blackode
blackode / upgrade.md
Created May 22, 2019 16:37 — forked from chrismccord/upgrade.md
Phoenix 1.2.x to 1.3.0 Upgrade Instructions

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:

@blackode
blackode / terminfo.md
Created May 21, 2019 03:38
How to load `.terminfo` files ?
tic -x resources/xterm-256color-italic.terminfo
tic -x resources/tmux-256color-italic.terminfo
@blackode
blackode / demo_server_v2.md
Last active December 24, 2018 10:33
demo_server version 2
defmodule DemoServer do
  use GenServer
- @vsn "1"
+ @vsn "2"

## Client API
def start_link employee do
      GenServer.start_link __MODULE__, employee, []
 end
@blackode
blackode / demo_gen_server.ex
Created December 23, 2018 00:13
Demo GenServer
defmodule DemoServer do
use GenServer
## Server API
def init(employee) do # initiating the state with the value 1 passed
{:ok, employee}
end
# add the value to the state and returns :ok
@blackode
blackode / supervisor.ex
Created April 3, 2018 13:51
a supervisor
defmodule Bank.Supervisor do
use Supervisor
def start_link(initial_balance) do
bank_supervisor = {:ok, sup} = Supervisor.start_link(__MODULE__, [initial_balance])
start_children(sup, initial_balance)
bank_supervisor
end
def start_children(sup, initial_balance) do
{:ok, cache_pid} =
Supervisor.start_child(sup, worker(Bank.Cache, [initial_balance]))
@blackode
blackode / cache.ex
Created April 3, 2018 13:49
State preserving after server collapse
defmodule Bank.Cache do
use GenServer
def start_link initial_balance do
GenServer.start_link(__MODULE__, initial_balance)
end
def init(initial_balance) do
{:ok, initial_balance}
end
def get_balance(pid) do
GenServer.call pid, :get
@blackode
blackode / bank.ex
Created April 3, 2018 13:44
Artilce Demonstration Project
defmodule Bank do
use GenServer
alias Bank.Cache
@moduledoc """
Documentation for Bank.
"""
# client API
def start_link(cache_pid) do
GenServer.start_link(Bank, cache_pid, name: Bank)
end
@blackode
blackode / stack.ex
Last active March 28, 2018 21:04
Stack Implementation Using Genserver
# stack.ex
defmodule Stack do
use GenServer
# server callbacks
def init(args), do: {:ok, args}
#used to handle synchronous requests
def handle_call(:get, _from, state) do
@blackode
blackode / Array.ex
Last active March 1, 2018 17:19
The flatten function implementation in Elixir
# Elixir V1.6
defmodule Array do
@moduledoc """
A collective data module with some helpful functions
"""
@doc """
Flattens the given list of nested lists. By default it gives out the unique list of items by removing the duplicates
inside.