Skip to content

Instantly share code, notes, and snippets.

View angrykoala's full-sized avatar
💭
🐨

angrykoala angrykoala

💭
🐨
View GitHub Profile
@angrykoala
angrykoala / deferred_promise.ts
Created May 25, 2023 16:21
A promise which execution is deferred until awaited
/** Defers an execution until a promise is awaited */
class DeferredPromise<T = void> extends Promise<T> {
private executor: () => Promise<T>;
private resultPromise: Promise<T> | undefined; // Memoize the promise, to avoid executing the executor twice if awaited twice
constructor(executor: () => Promise<T>) {
super(() => {
// Dummy callback to make Promise happy
});
this.executor = executor;
@angrykoala
angrykoala / cheatsheet.cypher
Created March 12, 2021 09:40
A cheatsheet for Neo4j cypher
/// QUERIES
// Get all nodes
MATCH(n)
RETURN n
// Get all nodes with label
MATCH(m:Movie)
RETURN m
@angrykoala
angrykoala / uncrustify.cfg
Created July 26, 2020 12:19
C# beautify config
# C# beautify config
# @angrykoala
newlines = LF # AUTO (default), CRLF, CR, or LF
indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs
input_tab_size = 4 # original tab size
output_tab_size = 4 # new tab size
indent_columns = output_tab_size
# indent_label = 0 # pos: absolute col, neg: relative column
@angrykoala
angrykoala / 30_navigation
Last active September 6, 2023 10:53
My i3 Config
## Move to i3 folder
## Note: sudo apt autoremove regolith-wm-navigation
###############################################################################
# Window and Workspace Navigation
###############################################################################
## Navigate // Relative Parent // <> a ##/
set_from_resource $i3-wm.binding.focus_parent i3-wm.binding.focus_parent a
bindsym $mod+$i3-wm.binding.focus_parent focus parent
@angrykoala
angrykoala / utilify.ts
Last active January 23, 2024 23:07
Random set of utilities for typescript
// utilify.ts - Random set of utilities for TypeScript
// by @angrykoala
// FUNCTIONS
/** Ensures input is an array, if not, turns it into an array (empty array if input is null or undefined) */
export function arrayfy<T>(raw: T | Array<T> | undefined | null): Array<T> {
if (Array.isArray(raw)) return raw;
if (raw === undefined || raw === null) return [];
else return [raw];
@angrykoala
angrykoala / tslint.json
Last active May 31, 2019 18:24
tslint.json
{
"defaultSeverity": "error",
"extends": ["tslint:recommended"],
"jsRules": {},
"rules": {
"arrow-parens": false,
"quotemark": false,
"trailing-comma": false,
"ordered-imports": false,
"object-literal-shorthand": false,
@angrykoala
angrykoala / tsconfig.json
Last active May 31, 2019 18:22
tsconfig
{
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "dist",
"sourceMap": false,
"strict": true,
"target": "es2015",
"typeRoots": [ "./@types", "./node_modules/@types"],
@angrykoala
angrykoala / userChrome.css
Last active July 26, 2021 13:51
My Firefox customization
/*
Add this file under ~/.mozilla/firefox/***.default/chrome/ in linux
Or AppData/Roaming/Mozilla/Firefox/Profiles/***.default/chrome in windows
about:config --> toolkit.legacyUserProfileCustomizations.stylesheets
*/
/* Removes "Open All In Tabs" button in bookmarks tabs */
openintabs-menuseparator, .openintabs-menuitem, .bookmarks-actions-menuseparator {
display: none !important;
@angrykoala
angrykoala / ts2gs_preprocessing.js
Created March 21, 2019 19:09
Preprocess typescript files to make export/import statements work on appscript after compiling with ts2gs
// Preprocess typescript files to make export/import statements work on appscript after compiling with ts2gs
const fs = require('fs');
const path = require('path');
const glob = require("glob")
const ncp = require('ncp').ncp;
const source = path.join(__dirname, "..", "/lib");
const target = path.join(__dirname, "..", "/bin");
#!/bin/sh
# Unites and compress pdf
# Usage compress_pdf.sh file1.pdf file2.pdf output_file.pdf
last_arg=${*: -1:1}
last_arg_temp="${last_arg}_temp.pdf"
args_except_last=${@:1:$#-1}
echo "Creating pdf $last_arg"