Skip to content

Instantly share code, notes, and snippets.

View Ajwah's full-sized avatar

Kevin Johnson Ajwah

  • Toronto, Canada
View GitHub Profile
@Ajwah
Ajwah / protocol.ex
Created September 1, 2021 12:13
Convert %Plug.Conn{} Struct to JSON
defmodule Encoders do
alias Jason.Encoder
alias Encoder.BitString
defimpl Encoder, for: Tuple do
def encode(data, options) when is_tuple(data) do
data
|> Tuple.to_list()
|> Encoder.List.encode(options)
end
@Ajwah
Ajwah / property.feature
Last active July 24, 2020 23:53
Proposal: PBT BDD
@hp
Property: HP
HP stands for health points and denotes whether an entity is alive or
dead.
@valid
Given HP
When valid
Then it must be a natural number
And greater than or equal to 0
def run_all(path, dest) do
:fprof.trace([:start, verbose: true, procs: :all])
"#{path}/*.feature"
|> Path.wildcard()
|> Enum.map(&execute/1)
:fprof.trace(:stop)
:fprof.profile()
:fprof.analyse(totals: false, dest: '#{dest}.analysis')
@Ajwah
Ajwah / gist:b589bea83ee9ede2e246324ca8d544d2
Created May 6, 2020 18:41
Debugging Breakpoint VSCode Extension Elixir
Kindly see comments below
@Ajwah
Ajwah / gist:f9144ddaf627b8435d005b7b7b914367
Created May 6, 2020 18:39
Debugging Breakpoint VSCode Extension Elixir
Here are some screenshots
@Ajwah
Ajwah / gist:4dee98bbb1e0c9257bb52dcd6c6802e2
Last active May 6, 2020 18:37
Debugging Breakpoint VSCode Elixir
```elixir
%ElixirSense.Core.Metadata{calls: %{
7 => [%ElixirSense.Core.State.CallInfo{arity: 0, func: :atom, mod: nil, position: {7, 11}}, %ElixirSense.Core.State.CallInfo{arity: 1, func: :a, mod: nil, position: {7, 9}}, %ElixirSense.Core.State.CallInfo{arity: 1, func: :spec, mod: nil, position: {7, 4}}],
10 => [%ElixirSense.Core.State.CallInfo{arity: 0, func: :hello, mod: nil, position: {10, 9}}, %ElixirSense.Core.State.CallInfo{arity: 1, func: :spec, mod: nil, position: {10, 4}}]}, error: nil,
lines_to_env: %{
1 => %ElixirSense.Core.State.Env{aliases: [], attributes: [], behaviours: [], imports: [], module: Dummy, module_variants: [Dummy], protocol: nil, protocol_variants: [], requires: [], scope: :Dummy, scope_id: 1, vars: []},
7 => %ElixirSense.Core.State.Env{aliases: [], attributes: [], behaviours: [], imports: [], module: Dummy, module_variants: [Dummy], protocol: nil, protocol_variants: [], requires: [], scope: :Dummy, scope_id: 2, vars: []},
8 => %ElixirSense.Core.State.Env{aliases: [], attrib
@Ajwah
Ajwah / gist:2ec0b9cb3171f4a618b86dc73b2aeca7
Created May 6, 2020 06:41
Debugging Breakpoint VSCode Elixir
%ElixirSense.Core.Metadata{calls: %{
7 => [%ElixirSense.Core.State.CallInfo{arity: 0, func: :atom, mod: nil, position: {7, 11}}, %ElixirSense.Core.State.CallInfo{arity: 1, func: :a, mod: nil, position: {7, 9}}, %ElixirSense.Core.State.CallInfo{arity: 1, func: :spec, mod: nil, position: {7, 4}}],
10 => [%ElixirSense.Core.State.CallInfo{arity: 0, func: :hello, mod: nil, position: {10, 9}}, %ElixirSense.Core.State.CallInfo{arity: 1, func: :spec, mod: nil, position: {10, 4}}]}, error: nil,
lines_to_env: %{
1 => %ElixirSense.Core.State.Env{aliases: [], attributes: [], behaviours: [], imports: [], module: Dummy, module_variants: [Dummy], protocol: nil, protocol_variants: [], requires: [], scope: :Dummy, scope_id: 1, vars: []},
7 => %ElixirSense.Core.State.Env{aliases: [], attributes: [], behaviours: [], imports: [], module: Dummy, module_variants: [Dummy], protocol: nil, protocol_variants: [], requires: [], scope: :Dummy, scope_id: 2, vars: []},
8 => %ElixirSense.Core.State.Env{aliases: [], attributes: [],
-module(palin).
-export([distributer/0, distributer/1, client/1, server/1, palin/1, nopunct/1, palindrome/1]).
distributer() ->
distributer({spawn(palin, server, ["A"]), spawn(palin, server, ["B"])}).
distributer({Server1, Server2}) ->
receive
{result, Msg} ->
io:format(Msg),
# edit commit msg
git commit --amend
# delete accidental commits made to master
git reset d3adfb9dd33d74815f445e6ace76501ff5a4208d
git reset --hard
@Ajwah
Ajwah / gist:b7223adc601611ba2b83
Created February 22, 2016 17:46
raspberry pi2 model b v1.1
use sdformatter
diskutil list
sudo diskutil unmountDisk /dev/disk3
sudo dd of=/dev/rdisk3 if=/Users/Coder/Downloads/2016-02-09-raspbian-jessie\ 2.img bs=4m
sudo diskutil mountDisk /dev/disk3