Skip to content

Instantly share code, notes, and snippets.

View andrew-ma's full-sized avatar
💭
I may be slow to respond.

Andrew Ma andrew-ma

💭
I may be slow to respond.
View GitHub Profile
# sh commands
# 1) boot live linux, and open terminal
# 2) see current devices
cat /proc/partitions
# 2) plug in sd card in adapter
# 3) find plugged in device (look at size, and find the disk, not partition,
# and you get /dev/<disk>)
@andrew-ma
andrew-ma / JS object to application x-www-form-urlencoded content-type
Last active August 12, 2021 05:47
JS object to application/x-www-form-urlencoded content-type
/**
* @param {Object} object
* @return {string}
*/
export function toFormUrlEncoded(object) {
return Object.entries(object)
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
.join('&');
}
https://linkedin.pyropear.com/
@andrew-ma
andrew-ma / FirefoxInstructions.txt
Last active January 31, 2022 11:23
Firefox Config
Go to where Firefox is installed. (%programfiles%\Mozilla Firefox)
Put the "mozilla.cfg" file in the current folder. (%programfiles%\Mozilla Firefox)
Put the "local-settings.js" file in the defaults\pref folder. (%programfiles%\Mozilla Firefox\defaults\pref)
@andrew-ma
andrew-ma / Requirements File Point to Github
Last active August 12, 2021 05:44
Requirements File Point to Github
https://github.com/andrew-ma/pysim/archive/master.zip
or
# this requires "git" to be installed, because it does a "git clone" behind the scenes
git+https://github.com/andrew-ma/pysim@master
@andrew-ma
andrew-ma / Install Docker with 'apt install'
Last active October 25, 2022 05:08
Install Docker on Debian, Ubuntu, or Kali
sudo apt remove docker docker-engine docker.io containerd runc -y
sudo apt update -y
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release -y
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg --yes
DEBIAN_VERSION="$(lsb_release -cs)"
if [ $? -ne 0 ]; then DEBIAN_VERSION=$(cat /etc/os-release | grep VERSION_CODENAME | cut -d"=" -f2 | tr -d '"'); fi
if [ "$DEBIAN_VERSION" = "kali-rolling" ]; then DEBIAN_VERSION="buster"; fi
RELEASE_ID=$(cat /etc/os-release | grep '^ID=' | cut -d'=' -f2)
if [ ! "$RELEASE_ID" = 'ubuntu' ]; then RELEASE_ID='debian'; fi
ARCHITECTURE=$(dpkg --print-architecture)
@andrew-ma
andrew-ma / Install Vscode on Debian
Created July 15, 2021 02:34
Install Vscode on Debian
curl -OJL "https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64"
sudo dpkg -i code_*.deb
@andrew-ma
andrew-ma / Install Vscode Extensions Offline
Last active August 12, 2021 05:45
Install Vscode Extensions Offline
# Save extensions to file
code --list-extensions | sed '/\(vscode-pylance\|jupyter\)/d' > ~/vscode_extensions.txt
# Install extensions from file
cat ~/vscode_extensions.txt | xargs -n 1 code --force --install-extension
# Uninstall extensions from file
cat ~/vscode_extensions.txt | xargs -n 1 code --force --uninstall-extension
@andrew-ma
andrew-ma / Mount vmware shared folder
Last active August 12, 2021 05:45
Mount vmware shared folder
sudo /usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs -o subtype=vmhgfs-fuse,allow_other
@andrew-ma
andrew-ma / Qt Custom Styled Item Delegate
Created July 31, 2021 23:02
Qt Custom Styled Item Delegate
from PyQt5.QtWidgets import QStyle, QStyledItemDelegate, QStyleOptionViewItem
from PyQt5.QtGui import QPainter
from PyQt5.QtCore import QModelIndex
class AsciiStyledItemDelegate(QStyledItemDelegate):
def __init__(self, style: QStyle, parent=None):
super().__init__(parent)
self.style = style
@staticmethod