Skip to content

Instantly share code, notes, and snippets.

View shurane's full-sized avatar

Ehtesh Choudhury shurane

  • Astoria, NY | Seattle, WA
  • 20:56 (UTC -07:00)
View GitHub Profile
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include "helpers.h"
#include <assert.h>
@shurane
shurane / hammerspoon.init.lua
Created March 14, 2023 23:09
HammerSpoon configuration for MacOS
-- https://gist.github.com/nyergler/7056c61174194a9af9b4d5d727f1b566
-- Magnet replacement bindings
hs.hotkey.bind({"ctrl", "alt"}, "left", function()
-- size focused window to left half of display
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
"use strict";
// https://stackoverflow.com/questions/45285129/any-difference-between-await-promise-all-and-multiple-await
// also https://jsfiddle.net/znup6vLj/
//console.clear();
function delay(ms: number) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
package main
import (
"fmt"
"html"
"log"
"net/http"
)
func main() {
@shurane
shurane / contenteditable.html
Created April 27, 2022 20:05
data:text/html, <html contenteditable> with some extra styling to make it easier to use. Just copy/paste the code in your browser and type away. Or make it a bookmarklet.
data:text/html;charset=utf-8,<title>TextEditor</title><style>body{background:#fbfbfb;color:#333;margin:0%50auto;width:100%}textarea{background:#fbfbfb;border:0;color:#333;font-family:sans-serif;font-size:2rem;height:98%;line-height:1.4;margin:0%20auto;outline:0;padding:4rem;width:100%}button{background-color:#fbfbfb;border:1px%20#ccc%20solid;color:#999;cursor:pointer;float:right;margin:10px%200;padding:5px%2010px}@media%20(max-width:100%){body{width:100%;padding:0}textarea{padding:10px}button{float:none}}</style><body><button%20onclick="sM();%20return%20false">Email%20this</button><textarea%20contenteditable%20id=TE%20spellcheck=false%20placeholder=Write...%20autofocus></textarea><script>function%20sM(){var%20a="mailto:?subject="+escape("Text%20from%20TextEditor")+"&body="+escape(document.getElementById("TE").value);window.location.href=a};</script>
[1,1]
[2,2]
[3,3]
[4,4]
[5,5]
@shurane
shurane / parse.py
Created January 12, 2022 05:13
sql grammar
import re
# countries.sql https://gist.github.com/adhipg/1600028
# countries table https://riptutorial.com/sql/example/9933/countries-table
statements = [ "SELECT * FROM countries",
"SELECT * FROM countries;",
"SELECT a.* FROM countries",
"SELECT capital FROM countries",
"SELECT capital, phonecode FROM countries",
@shurane
shurane / package.json
Created November 24, 2021 00:42
SQLite Book Page Assignments
{
"name": "2021.11.23.sqlite.book.page.assignments",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": { "test": "echo \"Error: no test specified\" && exit 1" },
"author": "",
"license": "ISC",
"dependencies": {
"better-sqlite3": "^7.4.5"
@shurane
shurane / .zshrc
Last active November 18, 2021 01:43
.zshrc
autoload -U colors && colors
# matches the style of bashrc with `username@host:dir$`
# see https://zsh-prompt-generator.site/ and https://stackoverflow.com/questions/689765/how-can-i-change-the-color-of-my-prompt-in-zsh-different-from-normal-text
PROMPT="%{$fg[green]%}%n@%m%{$reset_color%}:%{$fg[blue]%}%~%{$reset_color%}$ "
[0], 0
[1], 1
[1], 1
[0], 0
[1,2,3,0,0,0], 3
[4,5,6], 3
[4,5,6,0,0,0], 3