Skip to content

Instantly share code, notes, and snippets.

@vhqtvn
vhqtvn / callback-to-promise.ts
Last active June 23, 2021 16:07
Callback to promise
function make_wrapper<T extends { [k: string]: any }>(root: T) {
type VHWithoutLastElement<T extends [...args: any]> = T extends [...args: infer P, last: any] ? P : never;
type VHLastElement<T extends [...args: any]> = T extends [...args: any, last: infer LastType] ? LastType : never;
type VHCallbackExtractValue<T extends any> = T extends ((err: any, value: infer ValueType) => void) ? (ValueType extends unknown ? void : ValueType) : never;
type VHPromisifier<T extends (...args: any) => any> = T extends (...args: infer P) => any ? ((...args: VHWithoutLastElement<P>) => Promise<VHCallbackExtractValue<VHLastElement<P>>>) : never;
return <fn_t extends keyof T>(fn: fn_t): VHPromisifier<T[fn_t]> => {
return promisify(root[fn]).bind(root);
};
}
@miguelgrinberg
miguelgrinberg / .vimrc
Last active May 6, 2026 23:26
My .vimrc configuration for working in Python with vim
" plugins
let need_to_install_plugins = 0
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
let need_to_install_plugins = 1
endif
call plug#begin()
Plug 'tpope/vim-sensible'
# HELP jvm_classes_loaded The number of classes that are currently loaded in the JVM
# TYPE jvm_classes_loaded gauge
jvm_classes_loaded 8543.0
# HELP jvm_classes_loaded_total The total number of classes that have been loaded since the JVM has started execution
# TYPE jvm_classes_loaded_total counter
jvm_classes_loaded_total 8543.0
# HELP jvm_classes_unloaded_total The total number of classes that have been unloaded since the JVM has started execution
# TYPE jvm_classes_unloaded_total counter
jvm_classes_unloaded_total 0.0
# HELP jvm_info JVM version info
@jofftiquez
jofftiquez / github-workflow-guide.md
Last active March 16, 2026 08:07
CI/CD - Github Workflow + Firebase Hosting Guide

Template

Below is a template of GitHub's Workflow Action config file. Workflow is GitHub's CI/CD tool, like CircleCI.

Directory relative to the root of your application - .github/workflows/main.yml.

name: Deploy

on: 
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
@oseiskar
oseiskar / swagger-yaml-to-html.py
Last active January 23, 2026 11:51
Converts Swagger YAML to a static HTML document (needs: pip install PyYAML)
#!/usr/bin/python
#
# Copyright 2017 Otto Seiskari
# Licensed under the Apache License, Version 2.0.
# See http://www.apache.org/licenses/LICENSE-2.0 for the full text.
#
# This file is based on
# https://github.com/swagger-api/swagger-ui/blob/4f1772f6544699bc748299bd65f7ae2112777abc/dist/index.html
# (Copyright 2017 SmartBear Software, Licensed under Apache 2.0)
#
next_xid = 1
active_xids = set()
records = []
def new_transaction():
global next_xid
next_xid += 1
active_xids.add(next_xid)
return Transaction(next_xid)
@josephspurrier
josephspurrier / values_pointers.go
Last active April 24, 2026 09:22
Golang - Asterisk and Ampersand Cheatsheet
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value
@staltz
staltz / introrx.md
Last active May 7, 2026 01:31
The introduction to Reactive Programming you've been missing
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active May 8, 2026 18:12
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\