Skip to content

Instantly share code, notes, and snippets.

View tatarurzvn's full-sized avatar

Razvan Tataru tatarurzvn

View GitHub Profile
@tatarurzvn
tatarurzvn / gist:99926b29746f04f2efba6119cc8496e6
Created June 17, 2022 14:46
pg_dump / pg_restore faster
pg_dump -j 4 --section=pre-data -Fc -d DB -h 127.0.0.1 -p 5432 -U postgres --schema public > pre_date
pg_dump -j 4 --section=data -Fc -Z 9 -d DB -h 127.0.0.1 -p 5432 -U postgres --schema public > data_date
pg_dump -j 4 --section=post-data -Fc -Z 9 -d DB -h 127.0.0.1 -p 5432 -U postgres --schema public > post_date
# -j4 -> because 4 tables
# Split per sections
# -Fc -> pg_restore format
# -Z 9 -> copression (cool if i need to scp it)
@tatarurzvn
tatarurzvn / check-redis.sh
Last active June 17, 2022 14:47
check running redises
#!/usr/bin/env bash
for port in $(ps aux | perl -ne 'print if not /perl/ and not /63790/ and /redis-server/;' | perl -F'\s+' -lane '@arr = split /:/, "$F[-1]"; print $arr[1];'); do
echo "==> Clients connected to Redis on TCP port [$port] <==";
redis-cli -p $port client list;
done
@tatarurzvn
tatarurzvn / greedy.c
Created November 18, 2017 20:31
Greedy exercise
#include <stdio.h>
#define MAX_WEIGHT 10
int getValoare(float values[], float weights[], int size)
{
int currentWeight = 0;
int currentValue = 0;
int i = 0;
@tatarurzvn
tatarurzvn / prime-check.sh
Created November 1, 2017 21:06
Shell(zsh) exercises: print n fibos, is prime and print n primes; CN Homework
#!/bin/zsh
echo "Hey $USER, please enter a number: "
read NBR
CHECK=2
IS_PRIME=1
while [ $CHECK -lt `expr $NBR / 2` ]
do
if [ `expr $NBR % $CHECK` -eq 0 ]