Skip to content

Instantly share code, notes, and snippets.

View justinmklam's full-sized avatar

Justin Lam justinmklam

View GitHub Profile
@justinmklam
justinmklam / update_conda.sh
Created February 21, 2019 18:10
Commands to update root conda and all packages. (Because I always forget what the commands are...)
# Update base conda if required
conda update -n root conda
# Update all conda packages
conda update --all
@justinmklam
justinmklam / python_argparser_example.py
Last active January 10, 2020 18:11
Demonstrates simple usage of argparser.
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description='Describe the utility.'
)
# This is a required argument
parser.add_argument(
'filepath',
type=str,
@justinmklam
justinmklam / linux_fresh_install_generic.sh
Last active March 6, 2019 18:22
Additional software installs for a fresh OS install of linux.
#=================
# Add Custom PPAs
#=================
# For latest stable git
sudo add-apt-repository ppa:git-core/ppa
sudo apt install git -y
# GUI to easily change GRUB boot order (set Windows first for its updates)
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt install grub-customizer -y
@justinmklam
justinmklam / linux_fresh_install_elementary.sh
Last active February 23, 2019 05:08
Modifications to make Elementary OS more usable.
## For Elementary OS 5.0
# Enable adding custom PPA's
apt install software-properties-common
# PulseAudio volume control
apt install -y pavucontrol
# Elementary Tweaks
sudo add-apt-repository ppa:philip.scott/elementary-tweaks
sudo apt install elementary-tweaks
@justinmklam
justinmklam / linux_useful_commands.sh
Last active April 18, 2019 17:23
Useful snippets in bash.
# Find text in files in current directory
# -i - ignore text case
# -r - recursively search files in subdirectories.
# -n is line number, and
# -l - show file names instead of file contents portions.
grep -irn "search string" .
# Update system time from google (used to be able to do `sudo ntpdate time.nist.gov`, but ntpdate is considered deprecated as of 16.04
# Caveat: Might be 8-50 ms behind
sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d" " -f5-8)Z"
@justinmklam
justinmklam / python-virtual-envs.md
Last active May 19, 2021 19:52
Common commands for managing python virtual environments

Managing Multiple Versions of Python

Workflow:

  1. Download the binary of a desired python version
  2. Create a virtual environment that uses the desired python binary

Pyenv (preferred)

# List all available versions
@justinmklam
justinmklam / python_numpy_import_error.sh
Last active February 27, 2019 20:54
Fix for error: ImportError: numpy.core.multiarray failed to import
# Source: https://github.com/tensorflow/tensorflow/issues/559
# Check the current numpy version (and any error messages that come up)
python -c "import numpy;print numpy.__version__;print numpy.__file__";
# Do this a few times until all versions of numpy are removed
pip uninstall numpy
# Reinstall numpy
pip install -U numpy
@justinmklam
justinmklam / linux_remotedebug_ios_webkit_adapter.sh
Last active March 6, 2019 16:54
Install steps for dependencies and toolkit to enable debugging of iOS on Linux (or Windows).
# Source: https://github.com/RemoteDebug/remotedebug-ios-webkit-adapter
#================================
#=== Install libimobiledevice ===
#================================
# Source: https://github.com/libimobiledevice/libimobiledevice
sudo apt install autoconf autotools-dev -y
# Clone the required repos
git clone https://github.com/libimobiledevice/libplist
@justinmklam
justinmklam / javascript_override_console_log.js
Created March 5, 2019 21:49
console.log() override to display messages in a frontend element instead.
// Override console log to show messages on frontend. Useful for debugging on mobile (where console is unavailable).
//
// Example HTML:
//
// <div id="log"></div>
//
// Source: https://stackoverflow.com/a/20256785
(function () {
var old = console.log;
@justinmklam
justinmklam / linux-trackpoint-increase-sensitivity.sh
Created March 7, 2019 17:29
Increase trackpoint sensitivity on Ubuntu.
# Source: https://askubuntu.com/a/511281
xinput --list --short | grep -i trackpoint
# In this case, device id=16. This lists all available properties and current values
xinput list-props 16
# Change from 1.0 to 0.35 for higher sensitivity
xinput --set-prop 16 "Device Accel Constant Deceleration" 0.35
## Add the above command to Startup Applications