Skip to content

Instantly share code, notes, and snippets.

View frontrangerider2004's full-sized avatar

FrontRangeRider frontrangerider2004

  • Colorado
  • 10:59 (UTC -06:00)
View GitHub Profile
@frontrangerider2004
frontrangerider2004 / .vimrc
Created February 14, 2023 04:26
A reasonable vimrc for macos
" Show line numbers
set number
" Use spaces instead of tabs
set expandtab
" Be smart when using tabkey
set smarttab
" 1 tab == 4 spaces
@frontrangerider2004
frontrangerider2004 / macbook-setup.md
Last active September 12, 2023 18:05
Macbook Setup

Macbook Setup

Initialize Accounts & Passwords

  • Install password manager or setup company provided
  • Create AppleID or get one from your corporate account
  • Install browser extensions for password manager
  • Setup fingerprint unlock
  • Dark Theme
  • Enable 24hr clock
# optional exit code
CODE=0
cleanup() {
echo "[${SCRIPT_NAME}] Cleaning stuff up..."
exit ${CODE}
}
# should be defined early in the script since bash doesn't provide function hoisting
trap cleanup EXIT
const megabytes = Math.round(process.memoryUsage().heapUsed / 1024 / 1024);
console.log(`The script uses approximately ${megabytes} MB`);
@frontrangerider2004
frontrangerider2004 / bulk-rename.sh
Created June 19, 2018 03:32
Rename all files with tacos- in the filename to have burgers- in place of tacos-
for f in $(ls); do mv ${f} ${f/tacos-/burgers}; done
@frontrangerider2004
frontrangerider2004 / dbExport.java
Created October 17, 2017 20:29
Export all SQLite database files from your Android Application's private data directory to the SD Card
public static void exportAllDatabases(final Context context) {
Log.d(LOG_TAG, "exportAllDatabases: ");
File sd = Environment.getExternalStorageDirectory();
if (sd.canWrite()) {
final File[] databases = new File(context.getFilesDir().getParentFile().getPath() + "/databases").listFiles();
for (File databaseFile: databases) {
final String backupFilename = databaseFile.getName() + "-" + Build.SERIAL +
"-" + System.currentTimeMillis() + ".db";
File backupFile = new File(sd, backupFilename);
FileChannel inputChannel = null;
@frontrangerider2004
frontrangerider2004 / build.gradle
Created October 11, 2017 19:59
semantic version names for output apk files
android {
...... other stuff here
....
// Rename output apk file to use semantic versioning (gradle 3.2+)
// This will create hyde-x.x.x-${productFlavor}-${buildType}-${isSigned}.apk
applicationVariants.all { variant ->
variant.outputs.each { output ->
def originalOutputFile = output.outputFile
output.outputFile = new File(originalOutputFile.parentFile,
originalOutputFile.name.replace("${archivesBaseName}", "${archivesBaseName}-${variant.versionName}"))
# SED Search/Replace all files of type in a directory:
find ./ -type f -name "*.js" -print0 | xargs -0 sed -i .bak 's;<search-string>;<replace-string>'
# Find all files and exclude a pattern. The o option is essentially 'or' so this does exclude or print
find ./ -path "./my/path/to/ignore/" -prune -o -print
@frontrangerider2004
frontrangerider2004 / while-read-loops-and-find.bash
Last active September 7, 2016 15:16
Shows how to use while read loops and the find command to properly loop over the output of a find command.
#!/bin/bash
#######################################################################
# Examples of using the find commands
#######################################################################
# This is an unsafe and bad way to loop over output of find commands
# One should use the while read loop to avoid potential errors with the output
# of the find command. See below:
for file in $(find . -maxdepth 1 -type d -path Projects -prune -o -print);
do
@frontrangerider2004
frontrangerider2004 / MyDatabaseService.java
Created July 31, 2016 19:45
Threaded and Queued Heavy R/W For Android Databases
/**
Android service skeleton that performs intensive off main thread database operations.
This example uses a HandlerThread which will queue up requests rather than parallelize
them, which is good for database operations.
*/
public class MyDatabaseService extends Service {
private HandlerThread databaseThread;
private Handler databaseHandler;
private MyDatabaseHelper dbHelper;