Skip to content

Instantly share code, notes, and snippets.

View ebridges's full-sized avatar
🛠️
Fixing things

Edward Q. Bridges ebridges

🛠️
Fixing things
View GitHub Profile
@ebridges
ebridges / gist:4643237
Created January 26, 2013 16:55
git commit partial changes
$ git add -p file1
$ git stash --keep-index
$ git commit -m 'only partial adds' file1
$ git stash pop
@ebridges
ebridges / edit-commits
Created February 11, 2013 19:14
git edit commit author
$ git rebase f034498fbcf4e728d022e1511d630191f2f5ee67^ --interactive
# mark each commit that needs updating with "edit" or "e"
Then, for each commit:
$ git commit --amend --reuse-message=HEAD --author="Edward Bridges <ebridges@squarespace.com>"
$ git rebase --continue
@ebridges
ebridges / gist:4965434
Created February 16, 2013 03:40
git init local folder to an upstream repo
mkdir -p ~/src/my-boxen
cd ~/src/my-boxen
git init
git remote add upstream https://github.com/boxen/our-boxen
git fetch upstream
git checkout -b master upstream/master
git remote add origin https://github.com/wfarr/my-boxen
git push origin master
@ebridges
ebridges / maven-apklib-pom.xml
Created February 26, 2013 14:45
Setup a maven project to mimic Android default setup for libraries.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Example APK Lib</name>
<groupId>com.example</groupId>
<artifactId>example-android-apklib</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apklib</packaging>
@ebridges
ebridges / maven-parent-pom.xml
Created February 26, 2013 17:18
Basic maven parent pom
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Example Parent POM</name>
<url>http://maven.apache.org</url>
<groupId>com.example</groupId>
<artifactId>example-parent-pom</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
@ebridges
ebridges / artifact-install.sh
Created February 26, 2013 18:56
Install an artifact into a local repo
#!/bin/bash
jarfile=
groupId=
artifactId=
version=
localRepo=
packaging=jar
createChksum=true
generatePom=true
@ebridges
ebridges / GetVersion.java
Last active December 14, 2015 10:18
Get the versionCode & versionName attributes from `AndroidManifest.xml` at runtime
import android.app.Activity;
// http://stackoverflow.com/questions/3874775/detect-my-apps-own-androidversioncode-at-run-time
public class GetVersion {
public static Integer getVersion(Activity activity) {
Integer version = 0;
try {
version = activity.getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
} catch (NameNotFoundException e) {
// Todo: handle
@ebridges
ebridges / android-video-error-codes.pl
Created March 2, 2013 14:02
PVMF Error Codes for Android video playback using MediaPlayer. This perl script will generate a Java enum based on the listing of codes at the end of the gist. Error codes derived from https://github.com/android/platform_external_opencore/blob/master/pvmi/pvmf/include/pvmf_return_codes.h
# https://github.com/android/platform_external_opencore/blob/master/pvmi/pvmf/include/pvmf_return_codes.h
use strict;
my $enumName = "VideoErrorCode";
my $first = 1;
my %data;
for(<DATA>){
chomp;
my ($msg,$code) = split /,/;
@ebridges
ebridges / android-eclipse-mvn-config.xml
Created March 11, 2013 21:40
Maven configuration to generate Eclipse project for an Android POM.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<excludes>
<exclude>com.google.android:android</exclude>
</excludes>
<buildOutputDirectory>bin</buildOutputDirectory>
<classpathContainers>
@ebridges
ebridges / install-deps.pl
Last active December 16, 2015 05:59
Load a bunch of dependencies from a source repo into a local folder to make a POM portable.
#!/usr/bin/perl
use strict;
my $repo="$ENV{HOME}/.m2/repository";
my $cwd = `pwd`;
chomp($cwd);
my $localRepo=$cwd.'/lib';
for(<DATA>) {