Skip to content

Instantly share code, notes, and snippets.

@mdavis199
mdavis199 / AndroidEmulator.md
Created March 1, 2021 12:34 — forked from Try-Parser/AndroidEmulator.md
Running emulator without Android Studio in Windows With Flutter

Android Emulator Setup without Android Studio in Windows with Flutter

First Download the Android SDK Commandline Tool only.

https://developer.android.com/studio/

Goto Download Options

Find Commandline tools only Section

@mdavis199
mdavis199 / emulator-install-using-avdmanager.md
Created March 1, 2021 12:34 — forked from mrk-han/emulator-install-using-avdmanager.md
Installing and creating Emulators with AVDMANAGER (For Continuous Integration Server or Local Use)

Install and Create Emulators using AVDMANAGER and SDKMANAGER

TL;DR

For generic skin emulator with default apis (without google apis):

  1. List All System Images Available for Download: sdkmanager --list | grep system-images

  2. Download Image: sdkmanager --install "system-images;android-29;default;x86"

@mdavis199
mdavis199 / Makefile
Created June 22, 2021 17:00 — forked from mpneuried/Makefile
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)
@mdavis199
mdavis199 / usb-unlock-luks.md
Created November 11, 2021 07:59 — forked from da-n/usb-unlock-luks.md
Unlock LUKS full disk with USB stick

Configuration for passwordless root filesystem

Source: https://www.howtoforge.com/tutorial/passwordless-encryption-of-linux-root-partition/

The process of entering the passphrase at boot time will now be automated using an USB memory stick. Instead of using a passphrase , the secret key on the USB will decrypt the encrypted volumes. Connect an USB stick to the VM and locate it using the dmesg command. It is detected as /dev/sdb in my VM.

The secret key of 8192 random byte is extracted from the usb stick using the dd command.

dd if=/dev/sdb of=/root/secret.key bs=512 skip=4 count=16
@mdavis199
mdavis199 / gist:d47d32b0f8003729bb5b204e5ea4ad1e
Created November 11, 2021 08:00 — forked from da-n/gist:f906ca5a7e2a9c5fa7e29883b80a3be9
Unlock rootfs via SSH login in initramfs

unlocking rootfs via ssh login in initramfs

You can unlock your rootfs on bootup from remote, using ssh to log in to the booting system while it's running with the initramfs mounted.

Setup

For remote unlocking to work, the following packages have to be installed before building the initramfs: dropbear busybox

The file /etc/initramfs-tools/initramfs.conf holds the configuration options used when building the initramfs. It should contain BUSYBOX=y (this is set as the default when the busybox package is installed) to have busybox installed into the initramfs, and should not contain DROPBEAR=n, which would disable installation of dropbear to initramfs. If set to DROPBEAR=y, dropbear will be installed in any case; if DROPBEAR isn't set at all, then dropbear will only be installed in case of an existing cryptroot setup.

@mdavis199
mdavis199 / fail.py
Created November 21, 2021 14:55 — forked from jhazelwo/fail.py
Supress traceback for custom Python exceptions
#!/usr/bin/env python3
""" -*- coding: utf-8 -*-
Example Python3 Raise Exception without Traceback
Example Python3 Hide Traceback
Python3 Custom Exception Class
Python3 custom exception suppress traceback example
Python3 custom exception without traceback example
Example Python Raise Exception without Traceback
Example Python Hide Traceback
Python Custom Exception Class
@mdavis199
mdavis199 / RefreshHandle.cpp
Created June 23, 2022 15:39 — forked from yhnmj6666/RefreshHandle.cpp
Bind std handles to AllocConsole()
void BindCrtHandlesToStdHandles(bool bindStdIn, bool bindStdOut, bool bindStdErr)
{
// Re-initialize the C runtime "FILE" handles with clean handles bound to "nul". We do this because it has been
// observed that the file number of our standard handle file objects can be assigned internally to a value of -2
// when not bound to a valid target, which represents some kind of unknown internal invalid state. In this state our
// call to "_dup2" fails, as it specifically tests to ensure that the target file number isn't equal to this value
// before allowing the operation to continue. We can resolve this issue by first "re-opening" the target files to
// use the "nul" device, which will place them into a valid state, after which we can redirect them to our target
// using the "_dup2" function.
if (bindStdIn)
@mdavis199
mdavis199 / init_console_handlers_windows.go
Created June 25, 2022 10:57 — forked from SCP002/init_console_handlers_windows.go
Golang: Initialize console handlers after AttachConsole or AllocConsole on Windows.
// Used in https://github.com/SCP002/terminator.
package main
import (
"errors"
"os"
"golang.org/x/sys/windows"
)
@mdavis199
mdavis199 / popen.py
Created June 25, 2022 11:00 — forked from SCP002/popen.py
Python: Start process. Keep StdOut and StdErr in the original order. Display output real time character by character. Capture output on exit.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Requirements:
# Python 3.7+ (uses data classes, lines 16 and 25).
import dataclasses as dc
import os
import subprocess
import sys
@mdavis199
mdavis199 / fix-powershell-context-menu.reg
Created June 25, 2022 11:03 — forked from SCP002/configure-ps1-context-menu.reg
Windows Registry: Run PowerShell scripts with double click. Various tweaks of context menu for .ps1 and .psm1 files. See coments for description.
Windows Registry Editor Version 5.00
; WARNING:
; Uses Visual Studio Code as a standard editor.
; You might change it to your own with default file path, like:
;
; [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit\Command]
; @="\"C:\\Windows\\System32\\notepad.exe\" \"%1\""
;