Skip to content

Instantly share code, notes, and snippets.

View filipevarjao's full-sized avatar

Filipe Varjão filipevarjao

View GitHub Profile
import subprocess
# AST Node Types
class Statement:
pass
class Expression:
pass
class Assign(Statement):
# Zap
defmodule Zap do
use GenServer
@type state :: map()
def start_link(opts \\ []) do
GenServer.start_link(__MODULE__, [], name: __MODULE__)
end
# Client chat
defmodule Chat do
require Logger
def msg_loop() do
receive do
{:message_type, value} ->
spawn(fn -> Logger.info("Msg: #{value}") end)
end
version: "3"
services:
db:
image: "postgres"
container_name: "postgres_db"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=db
ports:
netstat -nap | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1/nginx: master pro
unix 3 [ ] STREAM CONNECTED 200611 1/nginx: master pro
unix 3 [ ] STREAM CONNECTED 200612 1/nginx: master pro
@filipevarjao
filipevarjao / postgres-cheatsheet.md
Created July 24, 2019 20:26 — 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)
package main
import (
"fmt"
"math"
"math/rand"
"time"
)
func main() {
-module(kitty_gen_server).
-behaviour(gen_server).
-export([start_link/0, order_cat/4, return_cat/2, close_shop/1]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
-record(cat, {name, color=green, description}).
%%% Client API
-module(kitty_gen_server).
-behaviour(gen_server).
-export([start_link/0, order_cat/4, return_cat/2, close_shop/1]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
-record(cat, {name, color=green, description}).
%%% Client API
@filipevarjao
filipevarjao / test.c
Last active September 28, 2017 19:44
typedef struct _object {
_PyObject_HEAD_EXTRA
Py_ssize_t ob_refcnt;
int color; /* the color of local mark-scan where 0 black, 1 red 2 green */
struct _typeobject *ob_type;
} PyObject;
#define _Py_CHECK_REFCNT(OP) \