Skip to content

Instantly share code, notes, and snippets.

View rpavlik's full-sized avatar

Rylie Pavlik rpavlik

View GitHub Profile
@rpavlik
rpavlik / gist:2227902
Created March 28, 2012 16:15
Finding and bulk-fixing git remotes that have changed
# These commands are intended to be copied and pasted, and run one at a time in a bash-like shell. Git Bash
# on Windows was used for testing, Linux bash should also be fine, and actually, even tcsh on vrac rhel
# machines is OK because the most complicated shell construct we use is a pipe, which is pretty universal.
# Change to the parent of all your source dirs.
#For me, this is something like /c/Users/rpavlik/Desktop/src on Windows using Git Bash
# Run this to see all the files we'll consider modifying.
# Make sure that they are all actually git config files.
# On Linux or other places with newer "find", you might have to replace "-path" with "-wholename".
@rpavlik
rpavlik / dochange.sh
Created March 28, 2012 16:53
Sed script for changing locations of repositories
# See other gist https://gist.github.com/2227902 for info on how this works and how to be safe with it.
# In this case, instead of supplying a single command to sed, we tell it a file
# to load its commands from. I generated that file using the spreadsheet "RepositoryChanges"
# and ample use of the CONCATENATE function.
# Preview it.
find . -maxdepth 3 -path "*/.git/config" -print0 | xargs -0 sed -f repochange.sed
# Do it.
find . -maxdepth 3 -path "*/.git/config" -print0 | xargs -0 sed -i -f repochange.sed
@rpavlik
rpavlik / nunchuck
Created April 7, 2012 02:51
Arduino 1.0-compatible nunchuck example based on http://www.windmeadow.com/node/42
#include <Wire.h>
#include <string.h>
#undef int
#include <stdio.h>
uint8_t outbuf[6]; // array to store arduino output
int cnt = 0;
int ledPin = 13;
@rpavlik
rpavlik / update-qtconf.sh
Created April 26, 2012 17:08
Generate a qt.conf file if you've moved an MXE cross-compiler with Qt.
#!/bin/sh
# In case of a moved MXE tree, this script can be run to
# generate a qt.conf file that will replace qmake's built-in
# paths and prefix with the new location.
#
# Script maintained at https://gist.github.com/gists/2501032
#
# Ryan Pavlik <[email protected]> <[email protected]>
bindir=$(cd $(dirname ${0}) && pwd)
@rpavlik
rpavlik / mount-homeshare.js
Created May 21, 2012 17:24
Windows WSH Script to ensure that %HOMEDRIVE%%HOMEPATH% exists, mounting %HOMESHARE% if necessary
// WSH Script to ensure that %HOMEDRIVE%%HOMEPATH% exists, mounting %HOMESHARE% if necessary
// Ryan Pavlik - 21-May-2012 - [email protected]
var wshShell = new ActiveXObject("WScript.Shell");
var wshProcEnv = wshShell.Environment("PROCESS");
// Make sure the %HOMEPATH% is the root directory of some drive, and we have a %HOMESHARE% and %HOMEDRIVE%
if (wshProcEnv("HOMEPATH") == "\\" && wshProcEnv("HOMESHARE") != "" && wshProcEnv("HOMEDRIVE") != "") {
var fso = new ActiveXObject("Scripting.FileSystemObject");
@rpavlik
rpavlik / dfu-unor3-patch.diff
Created July 31, 2012 15:43
dfu-programmer diff to add alternate product ID for arduino usbserial chip.
Index: src/arguments.c
===================================================================
--- src/arguments.c (revision 105)
+++ src/arguments.c (working copy)
@@ -72,6 +72,7 @@
{ "at90usb647", tar_at90usb647, adc_AVR, 0x2FF9, 0x03eb, 0x10000, 0x2000, true, 128, true, false, 128, 0x0800 },
{ "at90usb646", tar_at90usb646, adc_AVR, 0x2FF9, 0x03eb, 0x10000, 0x2000, true, 128, true, false, 128, 0x0800 },
{ "at90usb162", tar_at90usb162, adc_AVR, 0x2FFA, 0x03eb, 0x04000, 0x1000, true, 128, true, false, 128, 0x0200 },
+ { "at90usb162unor3",tar_at90usb162, adc_AVR, 0x2FEF, 0x03eb, 0x04000, 0x1000, true, 128, true, false, 128, 0x0200 },
{ "at90usb82", tar_at90usb82, adc_AVR, 0x2FF7, 0x03eb, 0x02000, 0x1000, true, 128, true, false, 128, 0x0200 },
@rpavlik
rpavlik / findsize.sh
Created August 15, 2012 21:22
Command to find what routines take the most space in your AVR app.
#!/bin/sh
# Pass it a .elf file
avr-nm --demangle --line-numbers --print-size --size-sort --reverse-sort $1
@rpavlik
rpavlik / findjava.js
Created August 21, 2012 22:31
Finding java once and for all - no batch file nonsense
getJRE = function(ver, wantJDK) {
var wshShell = new ActiveXObject("WScript.Shell");
var key = "HKLM\\SOFTWARE\\JavaSoft\\" +
(wantJDK ? "Java Development Kit\\" : "Java Runtime Environment\\") +
ver +
"\\JavaHome";
//WScript.Echo(key);
try {
@rpavlik
rpavlik / generateMirrorsDSL.groovy
Last active October 10, 2015 22:58
Groovy script to generate svn2git mirror jobs in Jenkins - now replaced by https://github.com/vancegroup/svn2git-mirrors-config
hourly = 'H * * * * '
daily = 'H H(0-7) * * *'
defaults = [
frequency: daily,
noMinimizeUrl: false
]
def fillDefaults(themap) {
defaults.eachWithIndex{ defaultIt, i->
if (!themap.containsKey(defaultIt.key)) { themap[defaultIt.key] = defaultIt.value }
@rpavlik
rpavlik / enumpolicy.h
Created October 1, 2012 19:42
Little example of putting the error handling policy out in a policy class.
struct ThrowingErrorHandler {
template<typename ValueType>
struct GetterReturnType {
typedef ValueType type;
};
inline static void handleError() {
throw std::runtime_error("Value not found in enumeration!");
}