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 / 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 / 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
{
"data": {"values":
[
{"_submitted_by": "dalli",
"INTRO_DISTRICT": [
"Afgooye"
],
"count": 1
},
{"_submitted_by": "dalli",
@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
@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