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 / config.py
Created April 29, 2024 08:35
peewee sqlite
from playhouse.sqliteq import SqliteQueueDatabase
db = SqliteQueueDatabase(
"products.db",
autostart=True,
pragmas={
"journal_mode": "wal",
"cache_size": -1024 * 32,
"foreign_keys": 1,
"ignore_check_constraints": 0,
@Checksum
Checksum / twitter.js
Last active March 11, 2024 10:41
StopTheMadness user scripts
// Remove posts marked as "Ad"
(() => {
const adSel = `[data-testid=placementTracking]`
const targetNode = document.querySelector(`body`)
const observer = new MutationObserver((mutations) => {
for (const m of mutations) {
m.addedNodes.forEach(node => {
if (ad = node.querySelector(adSel)) {
ad.remove();
}
@Checksum
Checksum / neolink.log
Last active May 1, 2023 06:40
Neolink error log
@Checksum
Checksum / redis-helpers.lua
Created March 23, 2022 03:59
Redis Lua helpers
local function key_patterns()
local uniq = {}
for _, key in ipairs(redis.call('keys', '*')) do
local pattern = string.match(key, "(.-):")
if pattern ~= nil and pattern ~= "" then
if uniq[pattern] == nil then
table.insert(uniq, pattern)
uniq[pattern]=1
else
uniq[pattern]=uniq[pattern]+1
@Checksum
Checksum / .zshrc.local.sh
Last active November 22, 2023 23:30
zshrc.local
# git
alias gs='git status'
alias gd='git diff'
alias gds='git diff --staged'
alias gcom='git checkout master'
alias gco='git checkout'
alias gp='git pull'
alias git-deleted='git log --diff-filter=D --summary'
# utils
@Checksum
Checksum / main.rs
Created September 13, 2020 02:02
Syscheck rust lifetime issue
use crate::core::{Check, Error as CheckError};
use iced::{Application, Command, Container, Element, Settings, Text};
fn main() -> iced::Result {
Syscheck::run(Settings::default())
}
#[derive(Debug)]
pub enum Syscheck {
Setup(SetupState),
@Checksum
Checksum / assert.jq
Last active December 29, 2023 17:09
Assertion library for jq
# A simple assertion library for jq (https://github.com/stedolan/jq)
# Author: Srinath Sankar
def assert(level; expr; msg):
if expr then
.
else
. |= . + [{ level: level, message: msg }]
end;
@Checksum
Checksum / diff-patch.jq
Last active August 26, 2021 01:04
JSON diff and patch for jq
# JSON diff and patch for jq (https://stedolan.github.io/jq/)
# Author: Srinath Sankar
#
# Usage:
# diff: jq -sS 'include "diff-patch"; diff' a.json b.json > patch.json
# patch: jq -sS 'include "diff-patch"; patch' a.json patch.json
#
# Caveats: tested only with top level objects using jq 1.6
def flatten_obj:
@Checksum
Checksum / websocket_proxy.js
Last active February 25, 2024 20:46
Intercepting WebSockets in the browser using JavaScript
const WebSocketProxy = new Proxy(window.WebSocket, {
construct(target, args) {
console.log("Proxying WebSocket connection", ...args);
const ws = new target(...args);
// Configurable hooks
ws.hooks = {
beforeSend: () => null,
beforeReceive: () => null
};
@Checksum
Checksum / snippets.sh
Last active November 18, 2021 02:45
Bash snippets
#!/bin/bash
# Dynamic bracket expansion
eval echo "{1..3}"
eval echo "foo-{bar,baz}-{1..3}"
# Merge JSON objects
merged="$(jq -ers '.[0] * .[1]' <(echo '{"name": "foo"}') <(echo '{"age": "baz"}') 2>/dev/null)"
# Check if string is valid JSON