Skip to content

Instantly share code, notes, and snippets.

View miguelff's full-sized avatar

Miguel Fernández miguelff

View GitHub Profile
@miguelff
miguelff / postgres-cheatsheet.md
Created July 4, 2022 10:33 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@miguelff
miguelff / dump.sql
Last active June 14, 2021 16:06 — forked from AlexeyKupershtokh/dump.sql
Postgres DDL to Clickhouse converter
select
concat(
'create table ',
table_name,
'(',
string_agg(
concat(
column_name,
' ',
CASE when is_nullable = 'YES' THEN 'Nullable(' END,
@miguelff
miguelff / main.go
Created February 5, 2021 12:43 — forked from wolfeidau/main.go
Golang Backpressure Example
package main
// The aim of this example is to illustrate backpressure using golang channels and go routines.
//
// This is the basis for a simple data processing service which could either be reading from
// some internal queue or a socket of some sort.
import (
"fmt"
"math/rand"
@miguelff
miguelff / octave.md
Created March 30, 2020 15:41 — forked from obstschale/octave.md
An Octave introduction cheat sheet.

Octave CheatSheet

GNU Octave is a high-level interpreted language, primarily intended for numerical computations.
(via GNU Octave)

Basics

  • not equal ~=
  • logical AND &&
WITH fulfillment_method_classification AS (
SELECT
f._shop_key,
f."order id",
f."shop shipping country",
f."fulfillment id",
CASE
WHEN ofsd."is shopify shipping fulfillment" = 'Fulfilled via Shopify Shipping'
THEN 'Shopify Shipping'
WHEN _api_client_key = -2
@miguelff
miguelff / latency.markdown
Created November 18, 2019 09:46 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@miguelff
miguelff / .travis.yml
Created July 21, 2019 16:32 — forked from ryboe/.travis.yml
Example .travis.yml for Golang
# use the latest ubuntu environment (18.04) available on travis
dist: xenial
language: go
# Force-enable Go modules. Also force go to use the code in vendor/
# These will both be unnecessary when Go 1.13 lands.
env:
- GO111MODULE=on
- GOFLAGS='-mod vendor'
@miguelff
miguelff / debugging_c_with_llvm.md
Created May 24, 2018 13:07 — forked from gregmalcolm/debugging_c_with_llvm.md
Debugging C with llvm's clang and lldb

Assuming you llvm installed (comes as standard on Mac OS Mavrick xtools)

Create a helloworld.c file:

  #include<stdio.h>
  
  int main()
  {
 int x=3;