Skip to content

Instantly share code, notes, and snippets.

View Checksum's full-sized avatar
:octocat:
Doing stuff

Srinath Sankar Checksum

:octocat:
Doing stuff
View GitHub Profile
@Checksum
Checksum / stack.yaml
Created July 31, 2019 00:40
Elm 0.19.1 stack.yaml
flags: {}
packages:
- .
extra-deps:
- language-glsl-0.3.0@sha256:85c1e7bf2cf5d6e604b7a2899c27e2935033425944db200798e57849e64d4c81
- time-1.9.2@sha256:874e07fb970531b9dcd814f74e00f253ce2f22ccd8272a6c4c137ee9040237fb
resolver: lts-12.14
@Checksum
Checksum / postgresql.sql
Last active January 14, 2020 06:15
PostgreSQL handy queries
-- Get size of database
SELECT pg_size_pretty(pg_database_size('database-name'));
-- Set the current session as read only
SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;
-- Locks
-- https://www.postgresql.org/docs/10/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS
SELECT pg_try_advisory_lock(123123213123) as lockObtained;
@Checksum
Checksum / sqlcmd.sql
Created April 9, 2019 00:53
sqlcmd cheat sheet
-- type 'go' to execute the block
-- List all tables
1> select * from information_schema.tables;
-- Describe table
1> exec sp_columns table_name;
@Checksum
Checksum / regex.md
Created March 11, 2019 23:47
Regex Tricks
  • Split every character: "something".split(/(?!^)/)

  • Never split: "something".split(/^.$/)

@Checksum
Checksum / building-elm.md
Last active February 27, 2019 05:35
Building Elm 0.19
  • Clone elm/compiler
  • Install stack
  • Install required version of cabal using stack --resolver lts-9 install cabal-install (commercialhaskell/stack#3453 (comment))
  • PATH=~/.local/bin:$PATH stack init --solver to install the required version of GHC
  • PATH=~/.local/bin:$PATH stack build --flag elm:dev to build
@Checksum
Checksum / postgresql-event-trigger.sql
Created August 1, 2018 07:20
Automatically create column on new tables using PostgreSQL event triggers
-- Function to automatically create a user_id column for new tables with name starting with user_
create or replace function create_user_id_column()
returns event_trigger
language plpgsql volatile as
$$
declare
obj record;
identity text[];
begin
for obj in select * from pg_event_trigger_ddl_commands()
@Checksum
Checksum / postgresql-json-queries.md
Last active January 14, 2020 06:11
Collection of queries to manipulate JSONB in PostgreSQL
CREATE TABLE users(
  id serial not null primary key,
  username text not null
);

CREATE TABLE tweets(
  id serial not null primary key,
  content jsonb default('{}')
);

Keybase proof

I hereby claim:

  • I am Checksum on github.
  • I am checksum (https://keybase.io/checksum) on keybase.
  • I have a public key whose fingerprint is EEA1 CD10 320D 497A B440 F6BD 45DD 4E24 58A5 101A

To claim this, I am signing this object:

@Checksum
Checksum / markdown.py
Last active August 29, 2015 14:07
Custom Markdown extension in Python
import re
import markdown2
class CustomMarkdown(markdown2.Markdown):
"""
Custom markdown processor that we use for task list
"""
reTaskList = re.compile('''
(?P<prefix>[\r\n|\n|\r]*)
@Checksum
Checksum / README.md
Last active December 10, 2015 20:48 — forked from mbostock/.block

This simple force-directed graph shows character co-occurence in Les Misérables. A physical simulation of charged particles and springs places related characters in closer proximity, while unrelated characters are farther apart. Layout algorithm inspired by Tim Dwyer and Thomas Jakobsen. Data based on character coappearence in Victor Hugo's Les Misérables, compiled by Donald Knuth.