Skip to content

Instantly share code, notes, and snippets.

View FrankApiyo's full-sized avatar
:shipit:
Code Mode

Frankline Apiyo FrankApiyo

:shipit:
Code Mode
View GitHub Profile
@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