Skip to content

Instantly share code, notes, and snippets.

@starstuck
starstuck / qbench.q
Last active December 19, 2023 17:30
Q/kdb benchmark
// Simple Q benchmark
//
// example call:
//
// q bench.q -s 8
STDOUT: -1
COUNT: 5000
EXAMPLES:(enlist ".Q.btoa[\"Hello World!\"]")
@starstuck
starstuck / cygpath-util.sh
Created May 7, 2020 16:16
Quick cygwin paths conversion without calling cygpath
# Following path conversion functions assume that cygrdives are mounted at root.
# Your fstab entry should look like this:
#
# none / cygdrive binary,posix=0,noacl,user 0 0
#
declare -A _CYGDRIVEMAP=([C]="/c" [P]="/p")
# Convert mixed path to unix path. Mixed path is using windows drive at the beginning,
# but with forward slashes already
to_unix_path () {
@starstuck
starstuck / hunspell.el
Created April 28, 2020 17:53
Using cygwin hunspell as Emacs ispell program
;; Working hunspell configuration for emacs for windows. It is using hunspell under Cygwin.
;;
;; It will require cygwin-mount.el downloaded to your emacs library path from
;; https://www.emacswiki.org/emacs/cygwin-mount.el
;;
;; Setup cygwin-mount first
(setq cygwin-directory "c:/cygwin")
(require `cygwin-mount)
(setq cygwin-mount-cygwin-bin-directory (concat cygwin-directory "/bin"))
(cygwin-mount-activate)
@starstuck
starstuck / ssh-agent.sh
Created June 17, 2019 09:25
Script to load and share ssh-agent across all terminal session on single system. Add it to your ~/.profile.
# -*- sh -*-
export SSH_AGENT_FILE=~/.ssh/agent
start() {
(umask 077; ssh-agent >| ${SSH_AGENT_FILE})
. ${SSH_AGENT_FILE}
ssh-add
}
if [ ! -f "${SSH_AGENT_FILE}" ]; then
@starstuck
starstuck / actions.ts
Last active April 18, 2019 17:24
Concise, strong typing in Redux actions and reducers (TypeScript).
import { ActionCreatorsMapObject, AnyAction } from 'redux';
export enum ActionType {
ReportError = 'REPORT_ERROR',
UpdateToDos = 'UPDATE_TODOS'
}
type ThunkDispatch = <T extends { type: ActionType }>(action: T) => T;
type ThunkAction<A extends { type: ActionType }, S, E> = (
@starstuck
starstuck / pom.xml
Last active April 3, 2019 14:39
Example of maven to download and invoke swagger codegen
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-project</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
@starstuck
starstuck / keybase.md
Created March 8, 2019 13:26
Keybase proof

Keybase proof

I hereby claim:

  • I am tomstarstuck on github.
  • I am starstuck (https://keybase.io/starstuck) on keybase.
  • I have a public key ASCy3r8YyuneO7itqGqwcGXsNWL3LCZG-IG8rjADhGmYIgo

To claim this, I am signing this object:

@starstuck
starstuck / restic.sh
Last active April 1, 2019 10:42
Restic multi-arch wrapper
#!/usr/bin/env bash
# -*- sh -*-
#
# This script runs right restic executable for system where it is called.
# Download restic releases to ../libexec folder and update VERSION valriable.
# It will also set RESTIC_REPOSITORY, based on assumption that the script lies
# in bin folder in the repository.
VERSION="0.9.3"
SYS=$(uname -s | tr '[:upper:]' '[:lower:]')
@starstuck
starstuck / install-slack-black.sh
Last active January 24, 2019 09:32
Install Slack black theme on macOS
#!/usr/bin/env bash
sudo mkdir -p /Library/Application\ Support/Slack/Resources
curl https://raw.githubusercontent.com/laCour/slack-night-mode/master/css/raw/black.css | sudo tee /Library/Application\ Support/Slack/Resources/black.css > /dev/null
sudo patch --backup /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js << EOF
*** ssb-interop.js
--- ssb-interop.js.patched
***************
*** 95,99 ****
const mainModule = require.resolve('../ssb/main.ts');
const isDevMode = loadSettings.devMode && isPrebuilt();
@starstuck
starstuck / async_reservations.js
Created October 4, 2018 14:59
Monitor aync resources in node.js application
import asyncHooks from 'async_hooks';
const reservations = new Map();
asyncHooks.createHook({
init: function init(asyncId, type, triggerAsyncId) {
const e = {};
Error.captureStackTrace(e, init);
reservations.set(asyncId, {type, triggerAsyncId, stack: e.stack});
},
destroy: function destroy(asyncId) {