Skip to content

Instantly share code, notes, and snippets.

@fizz
fizz / clean_virtualenvs.sh
Last active February 12, 2020 01:16
Uninstall a package from all pyenv virtualenvs that have it installed (e.g. in order to use pipx)
ipython 2>&1 | tail | xargs -IJK -p zsh -c 'eval "$(pyenv init -)" && eval "$(pyenv virtualenv-init -)" && pyenv activate JK && pip uninstall -y ipython'
#!/bin/sh
# Get the procs sorted by the number of inotify watchers
#
# From `man find`:
# %h Leading directories of file's name (all but the last element). If the file name contains no slashes (since it
# is in the current directory) the %h specifier expands to `.'.
# %f File's name with any leading directories removed (only the last element).
lines=$(
find /proc/*/fd \
@fizz
fizz / attributes.rb
Created April 21, 2019 05:48 — forked from lizthegrey/attributes.rb
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@fizz
fizz / docker_aliases.sh
Last active April 21, 2019 05:41
Docker aliases
function dumpenv { docker inspect -f '{{range $index, $value := .Config.Env}}{{println $value}}{{end}}' $1; }
function dumpenv2 { docker inspect -f '{{range $index, $value := .Config.Env}}{{println $value}}{{end}}' $1 > $1.env; }
function ct2sh { docker inspect -f "$(<./run.tpl)" $1 > $1.sh; }
function labels { docker inspect -f '{{range $l, $v := .Config.Labels}} {{printf "%q" $l}}={{printf "%q\n" $v}} {{end}}' $1;}
@fizz
fizz / learning_schedules.py
Last active April 21, 2019 05:31
learning_schedules.py
# Copyright 2017 The TensorFlow Authors. 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.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# Faster R-CNN with Resnet-101 (v1) configured for the Oxford-IIIT Pet Dataset.
# Users should configure the fine_tune_checkpoint field in the train config as
# well as the label_map_path and input_path fields in the train_input_reader and
# eval_input_reader. Search for "PATH_TO_BE_CONFIGURED" to find the fields that
# should be configured.
model {
faster_rcnn {
num_classes: 37
image_resizer {
@fizz
fizz / exporter.py
Created April 19, 2018 03:21 — forked from gauravkaila/exporter.py
Code to comment out in the exporter.py script
# Copyright 2017 The TensorFlow Authors. 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.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@fizz
fizz / run.tpl
Created April 8, 2018 21:17 — forked from hervenicol/run.tpl
`docker inspect` template to regenerate the `docker run` command that created a container
docker run \
--name={{.Name}} \
{{range $e := .Config.Env}}--env={{printf "%q" $e}} \
{{end}}{{range $p, $conf := .NetworkSettings.Ports}}{{with $conf}}-p {{(index $conf 0).HostIp}}:{{(index $conf 0).HostPort}}:{{$p}} \
{{end}}{{end}}{{range $n, $conf := .NetworkSettings.Networks}}{{with $conf}}--network {{printf "%q" $n}} \
{{range $conf.Aliases}}--network-alias {{printf "%q" .}} {{end}} \
{{end}}{{end}}{{range $v := .HostConfig.VolumesFrom}}--volumes-from={{printf "%q" .}} \
{{end}}{{range $v := .HostConfig.Binds}}--volume={{printf "%q" .}} \
{{end}}{{range $l, $v := .Config.Labels}}--label {{printf "%q" $l}}={{printf "%q" $v}} \
{{end}}{{range $v := .HostConfig.CapAdd}}--cap-add {{printf "%q" .}} \
@fizz
fizz / run.tpl
Created April 7, 2018 06:09 — forked from efrecon/run.tpl
`docker inspect` template to regenerate the `docker run` command that created a container
docker run \
--name={{.Name}} \
{{range $e := .Config.Env}}--env={{printf "%q" $e}} \
{{end}}{{range $p, $conf := .NetworkSettings.Ports}}{{with $conf}}-p {{(index $conf 0).HostIp}}:{{(index $conf 0).HostPort}}:{{$p}} \
{{end}}{{end}}{{range $n, $conf := .NetworkSettings.Networks}}{{with $conf}}--network {{printf "%q" $n}} \
{{range $conf.Aliases}}--network-alias {{printf "%q" .}} {{end}} \
{{end}}{{end}}{{range $v := .HostConfig.VolumesFrom}}--volumes-from={{printf "%q" .}} \
{{end}}{{range $v := .HostConfig.Binds}}--volume={{printf "%q" .}} \
{{end}}{{range $l, $v := .Config.Labels}}--label {{printf "%q" $l}}={{printf "%q" $v}} \
{{end}}{{range $v := .HostConfig.CapAdd}}--cap-add {{printf "%q" .}} \
@fizz
fizz / Continue.as
Last active April 21, 2019 05:28
gamedev
import com.example.Peekaboo
import com.example.PlayerState
class com.example.Continue extends Peekaboo {
static var _$ = _global
function Continue(){
showWhen(PlayerState.saveExists())
}
function onRelease(){