Skip to content

Instantly share code, notes, and snippets.

View FrankApiyo's full-sized avatar
:shipit:

Frankline Apiyo FrankApiyo

:shipit:
View GitHub Profile
@FrankApiyo
FrankApiyo / simultaneousAsignment.jpg
Last active June 19, 2021 13:45
[Python]Simultaneous Assignment

When using simultaneous assignment, all the expressions on the RHS are evaluated before any assigment is done on the LHS.

Simultaneous assignment can greatly simplify the presentation of code.

fibonacci generator (no simultaneous assigment)

def fibonacci():
  a = 0
 b = 1
@FrankApiyo
FrankApiyo / Generators.md
Last active June 20, 2021 09:34
Generators[python]

Generators are implemented with syntax very similar to functions, but instead of returning values, a yield statement is executed to indicate each element in the series

Consider the goal of computing all factors of a positive integer. A traditional function might return a list contating all factors, implemeted as follows:

def factors(n):            # traditional function that computes factors
  results = []             # store factors in a new list
  for k in range(1, n+1):
    if n % k == 0:         # divides evenly, thus k is a factor
 results.append(k) # add k to the list of factors
{
"data": {"values":
[
{"_submitted_by": "dalli",
"INTRO_DISTRICT": [
"Afgooye"
],
"count": 1
},
{"_submitted_by": "dalli",
@FrankApiyo
FrankApiyo / utils.sql
Created January 6, 2024 12:00 — forked from parallelo3301/utils.sql
PostgreSQL utils
-- v5
----------------------------------------------------------- basic instance info
-- show db version
SELECT version();
-- uptime
SELECT pg_postmaster_start_time();
-- show connections
@FrankApiyo
FrankApiyo / gist:0e94be3eac63f94d7a99fb01714f1e48
Last active November 19, 2024 06:30
Configure sops differ with git
git config diff.sopsdiffer.textconv "sops --decrypt --config /dev/null"
@FrankApiyo
FrankApiyo / phoenix.md
Last active April 26, 2025 15:53
Steps for scaffolding a demo phoenix app
mix phx.new --binary-id budgie
# add docker-compose.yml below
mix setup
mix phx.gen.auth Accounts User users --hashing-lib argon2

Edit mix.ex

defp deps do
@FrankApiyo
FrankApiyo / sample_lv_test.ex
Last active April 28, 2025 04:57
Sample LV test
defmodule AppNameWeb.LvLiveTest do
use UrlshortenerWeb.ConnCase, async: true
import Phoenix.LiveViewTest
describe "LV test" do
test "we can render the view", %{conn: conn} do
{:ok, _lv, html} = live(conn, ~p"/")
# open_browser(lv)
@FrankApiyo
FrankApiyo / regex.ex
Created April 27, 2025 13:37
Regular expression to check if a string is base 64 in elixir
~r/^[A-Za-z0-9]+$/
~r/^[A-Za-z0-9]{6}$/