Skip to content

Instantly share code, notes, and snippets.

View corporatepiyush's full-sized avatar

Piyush Katariya corporatepiyush

View GitHub Profile
corporatepiyush /
Last active September 12, 2023 07:07
MacOS Optimisation
sudo sysctl kern.sysv.shmmax=16777216
sudo sysctl kern.sysv.shmmin=1
sudo sysctl kern.sysv.shmmni=128
sudo sysctl kern.sysv.shmseg=32
sudo sysctl kern.sysv.shmall=4096
sudo sysctl kern.ipc.somaxconn=8192
sudo sysctl kern.maxfiles=1048576
sudo sysctl kern.maxfilesperproc=65535
sudo sysctl kern.ipc.maxsockbuf=16777216
sudo sysctl net.inet.tcp.delayed_ack=0
corporatepiyush / FileDB.dart
Last active August 15, 2023 14:15
Using File System as Key Value Database
// ignore_for_file: prefer_function_declarations_over_variables
import 'dart:async';
import 'dart:collection';
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
import 'package:basics/basics.dart';
import 'package:quiver/cache.dart';
corporatepiyush / fetchSave.js
Created June 29, 2023 15:07
Taking a day wise backup of large SQL Table incrementally
const pg = require('pg-promise')();
const fs = require('fs');
const db = pg({
user: "****",
password: "*****",
host: "******",
port: 5432,
database: "*****",
ssl: {
corporatepiyush /
Last active August 15, 2023 07:39
Block ads and malware for MacOS
# Protection from Malicious Domain (ads, malware, hack scripts, fakenews and gambling ) for MacOS.
# You may not be doing it but various apps installed on your system doing it internally, so having ad blocker in Browser does not helps.
# Execute below command in your terminal once every week.
sudo chmod 774 /private/etc/hosts
curl > hosts
sudo mv hosts /private/etc/hosts
corporatepiyush / dial-pq-via-ssh.go
Created May 27, 2023 09:02 — forked from vinzenz/dial-pq-via-ssh.go
Use postgres via SSH in Golang
package main
import (
corporatepiyush / rollups.sql
Created November 14, 2019 18:27 — forked from marcocitus/rollups.sql
Efficient real-time rollups with backfilling in Citus
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)
AS $function$
corporatepiyush / example.sql
Created November 7, 2019 13:19 — forked from marcocitus/example.sql
Safe incremental rollups on Postgres and Citus
-- 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
corporatepiyush / Allocate CPU cores
Last active December 16, 2020 10:21
Allocating CPU cores
// 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
corporatepiyush / pubsub-coordinator.sql
Created September 13, 2018 10:33 — forked from marcocitus/pubsub-coordinator.sql
Prototype for PubSub on PG 10 with Citus 7
/* commands to run on the coordinator */
SELECT master_add_node('', 5432);
SELECT master_add_node('', 5432);
SELECT start_metadata_sync_to_node(nodename, nodeport) FROM pg_dist_node;
SET citus.replication_model TO 'streaming'
event_id bigserial primary key,
corporatepiyush / ngrams.js
Created October 13, 2017 14:11
Ngrams Generators
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;