Skip to content

Instantly share code, notes, and snippets.

View davetrux's full-sized avatar

David Truxall davetrux

View GitHub Profile
@davetrux
davetrux / SQLiteDebugADB
Created March 24, 2014 14:42
Verbose Logging of SQLite statements in Android
adb shell setprop log.tag.SQLiteLog V
adb shell setprop log.tag.SQLiteStatements V
adb shell stop
adb shell start
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
// dark mode
console.log('dark mode')
}
@davetrux
davetrux / reverse.sh
Created August 23, 2019 00:19
SELinux allow Localhost for nginx to reverse proxy docker containers
sudo setsebool httpd_can_network_connect 1 -P
@davetrux
davetrux / build.gradle
Created August 3, 2016 17:15
Gradle-Openbakery BundleId Switch
if(buildType == "AppStore") {
infoplist {
bundleIdentifier = "com.hpe.appstore"
}
signing {
mobileProvisionURI = 'file://' + currentPath + appStoreProfile
certificateURI = "file://" + currentPath + appStoreCert
certificatePassword = certPassword
}
@davetrux
davetrux / hideshow
Created November 29, 2017 22:58
Mac Hide/Show Hidden Files
## Put these in your .bash_profile found in your home directory
## in the terminal type source ~/.bash_profile to reload your profile to make them immediately usable or close and re-open Terminal
# Hide and show hidden files in Finder windows
alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'
@davetrux
davetrux / hmac.swift
Last active November 8, 2016 19:06
HMAC algorithm for iOS
import Foundation
//You have to create a bridging header in your project containing:
// #import <CommonCrypto/CommonHMAC.h>
extension String {
func digestHMac256(key: String) -> String! {
let str = self.cStringUsingEncoding(NSUTF8StringEncoding)
@davetrux
davetrux / Enum.TryParse
Created September 26, 2013 19:35
A function for .Net to perform something like Enum.TryParse. See http://blog.davidtruxall.com/2005/12/08/generics-and-enums-or-enum-tryparse/
/// <SUMMARY>
/// Takes a string that represents an enum member
/// and returns the enum member
/// </SUMMARY>
/// <TYPEPARAM name="T">An Enum</TYPEPARAM>
/// <PARAM name="input">The string that is the enum member name, case does not matter</PARAM>
/// <PARAM name="returnValue">The value from the enum that matches the string, or the first value of the enum</PARAM>
/// <RETURNS>True when there is a match, false when not </RETURNS>
/// <REMARKS>
/// - When no match the first item in the enum is returned
@davetrux
davetrux / Android Dev Key
Created April 6, 2013 03:28
Command line call to get the Android dev key. Empty password.
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -v -list
@davetrux
davetrux / Android Multi-API Preference Saving
Created March 28, 2013 03:08
Another static Android API example
@SuppressWarnings("deprecation")
public class Settings extends PreferenceActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB )
addPreferencesFromResource(R.xml.settings);
else
addPreferencesAPIv11();
@davetrux
davetrux / Static Inner Class API
Last active December 15, 2015 12:19
Using newer Android APIs in an older version
/*
* Handles Gingerbread crash due to implementation change
*/
private static Point getDisplaySize(final Display display) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
return APIv11.getDisplaySize(display);
} else {
final Point point = new Point();
point.x = display.getWidth();