Skip to content

Instantly share code, notes, and snippets.

View pykello's full-sized avatar

Hadi Moshayedi pykello

View GitHub Profile
SET citus.next_shard_id TO 1220000;
-- Tests functions related to cluster membership
-- before starting the test, lets try to create reference table and see a
-- meaningful error
CREATE TABLE test_reference_table (y int primary key, name text);
SELECT create_reference_table('test_reference_table');
ERROR: cannot create reference table "test_reference_table"
DETAIL: There are no active worker nodes.
-- add the nodes to the cluster
SELECT 1 FROM master_add_node('localhost', :worker_1_port);
#lang racket
(require graphviz)
(define tables
`(("product" ("title"
"description"
"price"))
("category" ("title"
"description"))
@pykello
pykello / .bashrc
Last active May 29, 2019 20:52
dot files
SHELLSEP=❖
function git_branch {
[ -d .git ] && echo " $SHELLSEP $(git name-rev --name-only @) ★ $(git remote get-url origin)"
}
function pg_version {
if command -v pg_config >/dev/null; then
echo " $SHELLSEP $(pg_config --version)"
fi
@pykello
pykello / echo.py
Created April 28, 2019 07:11 — forked from solusipse/echo.py
Simple echo server written in pure Python
# Example of simple echo server
# www.solusipse.net
import socket
def listen():
socket1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket1.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
socket1.bind(('0.0.0.0', 5555))
socket1.listen(10)
set -g history-limit 100000
# Use Alt-arrow keys without prefix key to switch panes
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
set-option -g default-command bash
@pykello
pykello / create.sh
Created March 21, 2019 16:20
Citus Test Cluster
#!/bin/bash
set -e
DIRS=(data/coordinator data/worker1 data/worker2 data/worker3)
PORTS=(5432 5433 5434 5435)
ADD_AS_WORKER=(0 1 2 2)
COORDINATOR_PORT=${PORTS[0]}
COORDINATOR_DATA=${DIRS[0]}
for i in "${!DIRS[@]}"; do
#!/bin/sh
date
for pid in $(ps aux | grep postgres | awk '{print $2}'); do echo `sudo ls -1 /proc/$pid/fd 2>/dev/null | wc -l` pid=$pid; done | sort -k1 -n | tail
/* solution 1 */
class Solution {
public:
int calculateNum(string &s, int &c) {
int result = 0;
while (c < s.length() && s[c] != '+' && s[c] != '-' && s[c] != '*' && s[c] != '/') {
if (s[c] >= '0' && s[c] <= '9') {
result = result * 10 + s[c] - '0';
}
c++;
-- Compress a table using cstore_fdw
CREATE OR REPLACE FUNCTION compress_table(uncomp_table regclass) RETURNS VOID AS
$BODY$
DECLARE
table_name text;
comp_table_name text;
ispartitionv boolean;
parent text;
partition_expression text;
import Control.Applicative ((<*>), (*>), (<*))
import Control.Monad (replicateM)
import Data.Functor ((<$>))
import Data.Ix (range)
import Text.ParserCombinators.ReadP
-- Main
main = do
query_count <- read <$> getLine
queries <- map (parse like_query) <$> replicateM query_count getLine