Skip to content

Instantly share code, notes, and snippets.

View robinnorth's full-sized avatar
:octocat:

Robin North robinnorth

:octocat:
View GitHub Profile
@robinnorth
robinnorth / git_remove-ignored-files.sh
Last active February 21, 2018 16:24
Git: Remove all files ignored by .gitignore from repository
git rm -r --cached .
git add .
git commit -m 'Removed all files that are in the .gitignore'
@robinnorth
robinnorth / bash_cheat-sheet.sh
Created April 15, 2013 08:25
Bash: Cheat sheet
# chmod all files in directory, including .hidden files
chmod [MODE] .[a-zA-Z0-9_]*
# create gzipped tarball, preserving permissions
tar -c -p -v -z -f /home/example/www.example.com_site-2013-04-15.tar.gz -C /home/example/ .
# Recursively chmod only directories
find . -type d -exec chmod 755 {} \;
# Similarly, recursively set the execute bit on every directory
@robinnorth
robinnorth / Detect.cs
Last active September 11, 2018 16:30
Detect Vive/Oculus usage with SteamVR
// From https://steamcommunity.com/app/358720/discussions/0/343787283754448603/?ctp=2#c1326718197205185044
bool BIsHTCViveController()
{
System.Text.StringBuilder sbType = new System.Text.StringBuilder(1000);
Valve.VR.ETrackedPropertyError err = Valve.VR.ETrackedPropertyError.TrackedProp_Success;
SteamVR.instance.hmd.GetStringTrackedDeviceProperty((uint)trackedObj.index, Valve.VR.ETrackedDeviceProperty.Prop_ManufacturerName_String, sbType, 1000, ref err);
return ( err == Valve.VR.ETrackedPropertyError.TrackedProp_Success && sbType.ToString().StartsWith("HTC") );
}
DB="your_database_name"
USER="your_db_user"
PASS="your_db_pass"
HOST="database_hostname"
(
echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8 COLLATE utf8_general_ci;'
mysql -p $PASS -u $USER -h $HOST "$DB" -e "SHOW TABLES" --batch --skip-column-names \
| xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;'
) \
| mysql -p $PASS -u $USER -h $HOST "$DB"
@robinnorth
robinnorth / reset-ios-simulators.sh
Created December 13, 2016 11:10
Reset iOS Simulators to default
#!/bin/bash
# Kill any running Xcode or CoreSimulator processes
killall Xcode
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
# Remove existing simulators, including any installed apps
rm -rf ~/Library/Developer/CoreSimulator/Devices
# Recreate available devices and simulators to correspond to iOS runtime bundled with installed Xcode version and any additionally-installed runtimes
open /Applications/Xcode.app
# List available devices (in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/CoreSimulator/Profiles
@robinnorth
robinnorth / wordpress_export-post-data.php
Created April 26, 2013 11:44
WordPress: Simple, configurable script to export post data to a CSV file
<?php
/**
* Export WordPress post data to CSV
* Based on <http://stackoverflow.com/a/3474698> and <http://ran.ge/2009/10/27/howto-create-stream-csv-php/>
*/
/**
*********************************************************************
* Configuration
*********************************************************************