Skip to content

Instantly share code, notes, and snippets.

View avinayak's full-sized avatar

Atul Vinayak avinayak

  • Hiive
  • Vancouver, BC
  • 03:08 (UTC -07:00)
View GitHub Profile
@avinayak
avinayak / audit_log.sql
Created June 6, 2023 23:05
Automated jsonb audit_log generator for all tables in current schema
CREATE TABLE audit_log (
id serial PRIMARY KEY,
object_id uuid NOT NULL,
object_type VARCHAR(50),
event VARCHAR(50),
delta JSONB,
timestamp TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
@avinayak
avinayak / jvoc.json
Created September 4, 2022 20:48
jvoc.json
[
{
"w": "あっち",
"k": "",
"k_en": "",
"m": "over there",
"wt": "Pronoun",
"j": 5,
"i": 1,
"c": "w"
@avinayak
avinayak / japanese_vocab_study_order.json
Created September 4, 2022 19:40
japanese_vocab_study_order.json
This file has been truncated, but you can view the full file.
{
"あっち": {
"index": 3,
"word": "あっち",
"kana": "",
"romaji": "",
"type": "Pronoun",
"jlpt": 5,
"meaning": "over there",
"card": "word",
@avinayak
avinayak / cron.exs
Created May 16, 2022 06:51
A interval cron thing in genserver
defmodule Cron do
use GenServer
@name __MODULE__
def start_link(initial_map) do
GenServer.start_link(__MODULE__, initial_map, name: @name)
end
def add_job(key, job, interval) do
GenServer.cast(@name, {:add_job, {key, job, interval}})
@avinayak
avinayak / hello.exs
Last active May 15, 2022 09:30
Simplest plug based http sever
# run with $ elixir --no-halt hello.exs
Mix.install([{:plug_cowboy, "~> 2.0"}])
defmodule HWPlug.Plug do
import Plug.Conn
def init(options), do: options
def call(conn, _opts) do
conn

1. pg. xxi: Care About Your Craft

Why spend your life developing software unless you care about doing it well?

2. pg. xxi: Think! About Your Work

Turn off the autopilot and take control. Constantly critique and appraise your work.

3. pg. 2: You Have Agency

@avinayak
avinayak / gist:b79991439ddc5d86b8f669e0e1e8082e
Created February 5, 2021 07:15
CMakeList.txt for SDL2 Projects in CLion
cmake_minimum_required(VERSION 3.17)
project(Pong)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
add_executable(Pong main.cpp pong.cpp pong.h)
import urllib.request
import urllib.parse
import json
import random
import tweepy
que = ['why', 'how', 'why', 'how', 'why', 'how', 'why', 'how',
'what', 'who', 'can', 'is', 'will', 'could', 'would']
def auto_query(que, word):
@avinayak
avinayak / recording p5js
Last active September 23, 2020 10:03
recording p5js skecthes in editor.p5js.org
### Add the snippet below in sketch.js
### optional: convert to mp4 using ffmpeg -fflags +genpts -i input.webm -r 24 out.mp4
function record(){chunks.length=0;let e=document.querySelector("#defaultCanvas0").captureStream(300),t=new MediaRecorder(e);t.ondataavailable=(e=>{e.data.size&&chunks.push(e.data)}),t.onstop=exportVideo,setTimeout(()=>{t.stop()},1e4),t.start()}function exportVideo(e){var t=new Blob(chunks),o=document.createElement("video");o.id="recorded",o.controls=!0,o.src=URL.createObjectURL(t),document.body.appendChild(o),o.play()}chunks=[],record();