Skip to content

Instantly share code, notes, and snippets.

@somoso
somoso / androidstudio.gitignore
Last active November 23, 2016 14:07
Android Studio gitignore
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
@somoso
somoso / git-prune-merged.sh
Created November 23, 2016 14:04
Prune branches that have already been merged into master
#!/bin/sh
git branch -d $(git branch --merged)
//http://stackoverflow.com/a/19597101/617028
private static char[] VALID_CHARACTERS =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456879".toCharArray();
// cs = cryptographically secure
public static String csRandomAlphaNumericString(int numChars) {
SecureRandom srand = new SecureRandom();
Random rand = new Random();
char[] buff = new char[numChars];
@somoso
somoso / rn_bug.py
Last active July 11, 2018 15:19
Updated gist to support React Native 0.55
#!/usr/bin/env python3
import urllib.request
import sys
import argparse
import configparser
def main(parsed_args):
url = get_rn_url(parsed_args)
@somoso
somoso / install-android-sdk-tools.sh
Created August 4, 2018 19:14
Install command line Android SDK tools and set up bash/zsh profile to allow tools to make use of new SDK tools
#!/usr/bin/env bash
SDK_LINUX=https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
SDK_MAC=https://dl.google.com/android/repository/sdk-tools-darwin-4333796.zip
if [ -z ${JAVA_HOME+x} ]; then
echo "\$JAVA_HOME environmental variable is not set."
echo "Find the location of your Java directory, and then put it in your"
echo "~/.bash_profile (or any other shell equivalent)"
exit 0
@somoso
somoso / take-bugreport.cmd
Created August 13, 2018 12:49
Capture bug report on Android (needs Android SDK to be installed)
adb shell -c "bugreport > /sdcard/bugreport.txt"
adb pull /sdcard/bugreport.txt
@somoso
somoso / clone-repo.sh
Last active July 23, 2020 12:18
Clone a Git repository from source to destination.
#!/bin/bash
set -ea
# Function to generate a random string for making a temp folder with our repo contents
function randomstring {
echo $(openssl rand -base64 12)
}
# Check parameters
if [ "$#" -lt "2" ]; then
@somoso
somoso / nginx-rtmp.conf
Created July 14, 2019 09:05
NGINX RTMP Config file for streaming h264 vid w/ mp3 audio
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
exec ffmpeg -threads 16 -re -i rtmp://localhost:1935/$app/$name -an -vcodec h264 -s 320x240 -f flv rtmp://localhost:1935/real/${name};
exec ffmpeg -threads 16 -re -i rtmp://localhost:1935/$app/$name -vn -acodec mp3 -q:a 9 -f flv rtmp://localhost:1935/audio/${name};
}
@somoso
somoso / rebuild-icon-cache.bat
Created July 14, 2019 09:27
Rebuild icon cache in Windows
CD /d %userprofile%\AppData\Local
DEL IconCache.db /a
EXIT
explorer.exe
@somoso
somoso / black_bars_crop.sh
Created January 8, 2020 09:22
Cropping black bars out of a video using ffmpeg
#!/bin/bash
# First argument is the video file with the black borders that need to be removed
# Second argument is the resulting video
ffmpeg -i $1 -vf "$(ffmpeg -i $1 -t 1 -vf cropdetect -f null - 2>&1 | awk '/crop/ { print $NF }' | tail -1)" $2