Skip to content

Instantly share code, notes, and snippets.

View crankycoder's full-sized avatar

Victor Ng crankycoder

View GitHub Profile

{ "body": { "key": { "eldest_kid": "0120f6e10574deeefaf8a68b284bb1f027683ff28c757cd025010c20ad5ffe13556c0a", "host": "keybase.io", "kid": "0120f6e10574deeefaf8a68b284bb1f027683ff28c757cd025010c20ad5ffe13556c0a", "uid": "1937bc2ddd1811722f0efa789b0c2419", "username": "crankycoder" }, "merkle_root": {

@crankycoder
crankycoder / Vision (colorblind) (rainglow).itermcolors
Last active May 28, 2021 17:40
Colorblind palette for iTerm2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.050980392156862744</real>
<key>Green Component</key>
<real>0.050980392156862744</real>
@crankycoder
crankycoder / setup-pyenv-ubuntu-20.sh
Last active May 27, 2021 02:48
Setup pyenv for ubuntu 20 distros
#!/bin/bash
sudo apt-get install git python-is-python3 python3-pip make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl
sudo pip install virtualenvwrapper
# Official pyenv repos are under github.com/yyuu
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
git clone https://github.com/yyuu/pyenv-virtualenvwrapper.git ~/.pyenv/plugins/pyenv-virtualenvwrapper
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
@crankycoder
crankycoder / mad.py
Created October 30, 2019 15:59
MAD Cat
'''
Run this with:
env FLASK_APP=foo.py flask run
.
|'.._ __......._ _.-'.
\M\ ^'.-' ''-/ /
-bash-4.2$ pytest
========================================= test session starts ==========================================
platform linux2 -- Python 2.7.12, pytest-3.2.3, py-1.4.34, pluggy-0.4.0
rootdir: /home/hadoop/taar, inifile:
plugins: cov-2.5.1
collected 24 items
test_collaborativerecommender.py ....
test_legacyrecommender.py ...
test_localerecommender.py ....
@crankycoder
crankycoder / smartplug.py
Created June 8, 2016 21:46 — forked from arminwasicek/smartplug.py
Simple library/command-line-utility to control a EDIMAX Smart Plug Switch (SP-1101W) from Python
##
# The MIT License (MIT)
#
# Copyright (c) 2014 Stefan Wendler
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@crankycoder
crankycoder / building-static-nginx.txt
Created May 26, 2016 01:36 — forked from rjeczalik/building-static-nginx.txt
Notes on building nginx as a static binary.
# Building static nginx for teh lulz
#
# basic dependencies
sudo apt-get install libxslt1-dev libxml2-dev zlib1g-dev libpcre3-dev libbz2-dev libssl-dev
# download nginx and openssl
wget http://nginx.org/download/nginx-1.5.6.tar.gz
tar xf nginx-1.5.6.tar.gz; cd nginx-1.5.6
@crankycoder
crankycoder / gist:34d11a9f8202a10f3adb
Created October 1, 2014 23:35
Bootstrap Ubuntu 14.04 into a workable MozStumbler buildbox
#!/bin/sh
sudo apt-get -qqy update
sudo apt-get install -y unzip git make openjdk-7-jdk
# Everybody loves that android needs x86 stuff
sudo dpkg --add-architecture i386
sudo apt-get -qqy install libncurses5:i386 libstdc++6:i386 zlib1g:i386

Save books out of Safari Books Online

From http://objectivesea.tumblr.com/post/9033067018/safaribooks

This is hard. I spent way too much time figuring this out, because I was annoyed that a book I bought (Addison-Wesley) was available online for free, except only for 45 days after which payment was required. So I made this hack... probably useful to no one else, but here it is.

Requirements:

  1. iPad.
  2. Safari To Go (the Safari Books Online iPad app).
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-- Original grok filters
-- POSINT \b(?:[0-9]+)\b
-- GREEDYDATA .*
-- HOUR (?:2[0123]|[01][0-9])
-- MINUTE (?:[0-5][0-9])
-- SECOND (?:(?:[0-5][0-9]|60)(?:[.,][0-9]+)?)