View rollups.sql
CREATE TABLE rollups ( | |
name text, | |
rolled_up_generation bigint default -1 | |
); | |
-- Create a stub on workers to allow usage as a default in distributed tables | |
SELECT run_command_on_workers($$ | |
CREATE OR REPLACE FUNCTION current_rollup_generation(rollup_name text) | |
RETURNS bigint LANGUAGE sql | |
AS $function$ |
View example.sql
-- Create the raw events table | |
CREATE TABLE page_views ( | |
site_id int, | |
path text, | |
client_ip inet, | |
view_time timestamptz default now(), | |
view_id bigserial | |
); | |
-- Allow fast lookups of ranges of sequence IDs |
View Allocate CPU cores together.sh
// suppose you spawned 16 node processes on 16 core CPU | |
ps axf | grep node | grep -v grep | awk '{print $1}' | xargs -n 1 taskset -cp 0-15 |
View pubsub-coordinator.sql
/* commands to run on the coordinator */ | |
CREATE EXTENSION citus; | |
SELECT master_add_node('10.0.0.2', 5432); | |
SELECT master_add_node('10.0.0.3', 5432); | |
SELECT start_metadata_sync_to_node(nodename, nodeport) FROM pg_dist_node; | |
SET citus.replication_model TO 'streaming' | |
CREATE TABLE events ( | |
event_id bigserial primary key, |
View ngrams.js
const _ = require('ramda') | |
const ngrams = function (string) { | |
var r = []; | |
for (var n = 2; n <= string.length; n++) | |
for (var i = 0; i <= string.length - n; i++) | |
r.push(string.substring(i, i + n)); | |
return r; | |
} |
View findAndCopy.sh
find <directory> -name 'screen.png' | xargs -n1 cp <file/directory to be copied> |
View Parallel.sh
seq 1 10 | xargs -n1 -P5 <any command> |
View CountLines.sh
find $directory$ -type f -name "*.py" | xargs cat | wc -l |
View ListSSHKeys.sh
for keyfile in ~/.ssh/id_*; do ssh-keygen -l -f "${keyfile}"; done | uniq |
View download.sh
// download audio files and convert them to mp3 | |
cat links.txt | xargs -n1 -P2 youtube-dl --extract-audio --audio-format mp3 --audio-quality 9 |