Skip to content

Instantly share code, notes, and snippets.

View corporatepiyush's full-sized avatar

Piyush Katariya corporatepiyush

View GitHub Profile
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index 6f07731a49..30d64531db 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -587,7 +587,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
}
// Charge the allocation against the G. We'll account
// for internal fragmentation at the end of mallocgc.
- assistG.gcAssistBytes -= int64(size)
+ assistG.gcAssistBytes = 1024
@marcocitus
marcocitus / rollups.sql
Last active November 14, 2019 18:27
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)
RETURNS bigint LANGUAGE sql
AS $function$
@DTFagus
DTFagus / analyse_watchers.js
Created August 12, 2014 14:22
Bookmarklet to analyse angular watchers
javascript: (function() {
var root = $(document.getElementsByTagName('html'));
var watchers = [];
var attributes = [];
var attributes_with_values = [];
var elements = [];
var elements_per_attr = [];
var scopes = [];
@marcocitus
marcocitus / pubsub-coordinator.sql
Last active December 9, 2020 05:21
Prototype for PubSub on PG 10 with Citus 7
/* 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,
@kornysietsma
kornysietsma / wikiparse.clj
Last active January 2, 2021 18:41
parsing wikipedia dumps in clojure
(ns wikiparse.core
(:require [clojure.java.io :as io]
[clojure.data.xml :as xml]
[clojure.zip :refer [xml-zip]]
[clojure.data.zip.xml :refer [xml-> xml1-> text]])
(:import [ org.apache.commons.compress.compressors.bzip2 BZip2CompressorInputStream])
(:gen-class :main true))
(defn bz2-reader
"Returns a streaming Reader for the given compressed BZip2
@ploeh
ploeh / Safefs.hs
Last active March 29, 2022 18:37
Safe head function using Either in Haskell
safeHead [] = Left "The list was empty. No head is available."
safeHead xs = Right . head $ xs
-- Sample usage from GHCI:
--
-- *Safefs> safeHead [1..3]
-- Right 1
-- *Safefs> safeHead [7]
-- Right 7
-- *Safefs> safeHead [2, 3]
@alistairewj
alistairewj / install-postgres-10-ubuntu.md
Last active January 4, 2023 19:36
Install PostgreSQL 10 on Ubuntu

Install PostgreSQL 10 on Ubuntu

This is a quick guide to install PostgreSQL 10 - tested on Ubuntu 16.04 but likely can be used for Ubuntu 14.04 and 17.04 as well, with one minor modification detailed below.

(Optional) Uninstall other versions of postgres

To make life simple, remove all other versions of Postgres. Obviously not required, but again, makes life simple. If you have data in your previous version of postgres that you'd like to retain, then this is not recommended. Instead, you'll have to use pg_upgrade or pg_upgradecluster.

Go vs. Scala (Akka) Concurrency

A comparison from 2 weeks using Go.

Actors vs. Functions

Akka's central principle is that there you have an ActorSystem which runs Actors. An Actor is defined as a class and it has a method to receive messages.

@bellbind
bellbind / algorithms-for-jpeg.js
Last active November 17, 2023 13:03
[javascript]Algorithms for JPEG processing
/* eslint no-unused-vars: 0, no-multi-spaces: 0 */
"use strict";
// [JPEG encode process]
// 1. RGB to YUV
// 2. Padding & chunk to 8x8-blocks
// 3. DCT
// 4. Quantization
// 5. zigzag scan
// 6. Huffman coding
@acutmore
acutmore / README.md
Last active January 21, 2024 20:30
Emulating a 4-Bit Virtual Machine in (TypeScript\JavaScript) (just Types no Script)

A compile-time 4-Bit Virtual Machine implemented in TypeScript's type system. Capable of running a sample 'FizzBuzz' program.

Syntax emits zero JavaScript.

type RESULT = VM<
  [
    ["push", N_1],         // 1
    ["push", False],       // 2
 ["peek", _], // 3