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 / .formatter.exs
Last active June 11, 2020 17:39
Elixir codebase formatter
# project_root/.formatter.exs
[
# functions to let allow the no parens like def print value
locals_without_parens: [hello: 2, get_user: 1, addtion: *],
# files to format
inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"],
@blackode
blackode / default.md
Last active October 18, 2017 12:25
Json Representation
{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
 ]
@blackode
blackode / tcp_server.ex
Created June 28, 2017 22:23
TcpServer Implementation with gen_tcp erlang module
defmodule TcpServer do
use GenServer
def start_link() do
ip = Application.get_env :tcp_server, :ip, {127,0,0,1}
port = Application.get_env :tcp_server, :port, 6666
GenServer.start_link(__MODULE__,[ip,port],[])
end
def init [ip,port] do
@blackode
blackode / postgres_guide.md
Last active May 19, 2023 07:46 — forked from tacionery/postgres_guide
install postgresql on antergos

uninstall postgresql if necessary

sudo pacman -R postgresql postgresql-libs

remove postgres files

sudo rm -rfv /var/lib/postgres
@blackode
blackode / ets_keys.ex
Last active March 27, 2017 15:25
list of keys in ets tables
defmodule EtsKeys do
def keys(table_name) do
first_key = :ets.first(table_name)
keys(table_name, first_key, [first_key])
end
def keys(_table_name, '$end_of_table', ['$end_of_table'|acc]) do
acc
end
def keys(table_name, current_key, acc) do
@blackode
blackode / when_macro.ex
Last active September 19, 2019 14:04
Macros in guard clauses...
defmodule MyGuards do
defmacro is_kid age do
quote do: unquote(age) < 12
end
defmacro is_adult age do
quote do: unquote(age) > 18
end
@blackode
blackode / when_cond.exs
Last active March 8, 2017 08:34
when conditions as functions
defmodule Hello do
def hello(name,age) when is_kid(age) do
IO.puts "Hello Kid #{name}"
end
def hello(name,age) when is_adult(age) do
IO.puts "Hello Mister #{name}"
end
def is_kid age do
age < 12
end
@blackode
blackode / hi.ex
Created February 27, 2017 09:52
demo mdoule
defmodule Hi do
def hi1 do
IO.puts "hi1"
end
def hi2 do
IO.puts "hi2"
end
@blackode
blackode / hello.ex
Created February 27, 2017 09:49
Module Demo files
defmodule Hello do
def hello1 do
IO.puts "hello1"
end
def hello2 do
IO.puts "hello2"
end
@blackode
blackode / functions2.ex
Last active February 27, 2017 11:04
task with short docs
defmodule Mix.Tasks.MyTasks.Functions do
use Mix.Task
@shortdoc "Returns functions in Module"
@moduledoc ~S"""
This is used to list out the all available functions in the module.
You suppose to pass module_name as parameter to the task.
#Usage
```