Skip to content

Instantly share code, notes, and snippets.

@jim-my
jim-my / dict_namedtuple.py
Created September 22, 2021 21:04 — forked from href/dict_namedtuple.py
Convert any dictionary to a named tuple
from collections import namedtuple
def convert(dictionary):
return namedtuple('GenericDict', dictionary.keys())(**dictionary)
"""
>>> d = dictionary(a=1, b='b', c=[3])
>>> named = convert(d)
>>> named.a == d.a
True
>>> named.b == d.b
@jim-my
jim-my / .zshrc lazy_load()
Last active September 19, 2021 04:52 — forked from QinMing/.zshrc
.zshrc lazy_load(): (lazy loading shell functions)
# Copyright (c) 2016-2018 Ming Qin (覃明) <https://github.com/QinMing>
# Open source under MIT LICENSE.
lazy_load() {
# Act as a stub to another shell function/command. When first run, it will load the actual function/command then execute it.
# E.g. This made my zsh load 0.8 seconds faster by loading `nvm` when "nvm", "npm" or "node" is used for the first time
# $1: space separated list of alias to release after the first load
# $2: file to source
# $3: name of the command to run after it's loaded
# $4+: argv to be passed to $3
@jim-my
jim-my / _aws_golang_examples.md
Created September 3, 2020 11:42 — forked from eferro/_aws_golang_examples.md
golang aws: examples

AWS Golang SDK examples

@jim-my
jim-my / web-servers.md
Created August 24, 2020 12:10 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@jim-my
jim-my / _service.md
Last active August 15, 2020 01:44 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample (old init.d) service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@jim-my
jim-my / docker-ssh-forward.bash
Created June 4, 2020 01:49 — forked from d11wtq/docker-ssh-forward.bash
How to SSH agent forward into a docker container
docker run -rm -t -i -v $(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK ubuntu /bin/bash
@jim-my
jim-my / karabiner.edn
Created December 28, 2019 00:50 — forked from kaushikgopal/karabiner.edn
My source Karabiner file in Goku's edn format (For generated karabiner.json see https://gist.github.com/kaushikgopal/c802ca81044066f7d93a50c5269cc812)
{
;; ! | means mandatory
;; # | means optional
;; !! | mandatory command + control + optional + shift (hyper)
;; ## | optional any
;; to understand better how modifiers work in karabiner
;; https://pqrs.org/osx/karabiner/json.html#from-event-definition-modifiers
;; C | left_command
@jim-my
jim-my / infra-secret-management-overview.md
Created February 3, 2019 00:03 — forked from maxvt/infra-secret-management-overview.md
Infrastructure Secret Management Software Overview

Currently, there is an explosion of tools that aim to manage secrets for automated, cloud native infrastructure management. Daniel Somerfield did some work classifying the various approaches, but (as far as I know) no one has made a recent effort to summarize the various tools.

This is an attempt to give a quick overview of what can be found out there. The list is alphabetical. There will be tools that are missing, and some of the facts might be wrong--I welcome your corrections. For the purpose, I can be reached via @maxvt on Twitter, or just leave me a comment here.

There is a companion feature matrix of various tools. Comments are welcome in the same manner.

brew install macvim --with-cscope --with-lua --override-system-vim
@jim-my
jim-my / where_is.rb
Last active August 29, 2015 14:19 — forked from wtaysom/where_is.rb
module Where
class <<self
attr_accessor :editor
def is_proc(proc)
source_location(proc)
end
def is_method(klass, method_name)
source_location(klass.method(method_name))