Skip to content

Instantly share code, notes, and snippets.

View chris-piekarski's full-sized avatar

Christopher Piekarski chris-piekarski

  • Boulder, CO
  • 03:57 (UTC)
View GitHub Profile
@chris-piekarski
chris-piekarski / android_io
Created August 31, 2013 21:04
Android Read/Write External Storage
//From AOSP Doc
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
/* Checks if external storage is available for read and write */
public boolean isExternalStorageWritable() {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
return true;
}
@chris-piekarski
chris-piekarski / android_config.xml
Created August 28, 2013 16:30
Android config.xml
Add res/values/config.xml
<resources>
<bool name="config_hardwareAccelerated">true</bool>
<bool name="config_largeHeap">false</bool>
<bool name="is_large_screen">false</bool>
<bool name="allow_rotation">false</bool>
</resources>
Get values with:
@chris-piekarski
chris-piekarski / kill_all_by_name
Last active December 20, 2015 10:59
Kill all procs by name
kill `ps ax | grep chrome | grep -v 'grep' | cut -f1 -d' ' -s`
#test -> check if -f 1 or -f 2
ps ax | grep rake | grep -v 'grep' | cut -d ' ' -f 2
@chris-piekarski
chris-piekarski / go_html_page_serve
Created July 16, 2013 04:56
Serve up html page from Go
func goHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
fmt.Print("Got a POST")
}
body, _ := ioutil.ReadFile("mag.html")
w.Write(body)
}
@chris-piekarski
chris-piekarski / gerrit_git_push_config
Created June 28, 2013 16:13
Gerrit Git Push Config
$ cat .git/config
...
[remote "for-a-exp"]
url = tr:kernel/common
receivepack = git receive-pack [email protected] [email protected]
push = HEAD:refs/for/experimental
$ git push for-a-exp
@chris-piekarski
chris-piekarski / tag_aosp_repo
Created June 27, 2013 20:05
How to tag AOSP using repo
repo forall -c 'git tag spectralink_sprint_8'
repo forall -c 'git push ssh://cpiekarski@tinfoil:29418/$REPO_PROJECT --tags'
@chris-piekarski
chris-piekarski / logcat_phone_app
Created June 25, 2013 21:10
Get logcat buffer from phone app
private String getLogData(String level) {
Log.d(TAG, "Getting log data for level: "+level);
StringBuilder log = new StringBuilder();
try {
Process process = Runtime.getRuntime().exec("logcat -d");
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String line = "";
ipython
import rglob

android-1.6_r1.4

rglob.lcount("/home/chris/aosp_android-1.6_r1.4/", "*.java")
2687649
rglob.lcount("/home/chris/aosp_android-1.6_r1.4/", "*.cpp")
1994029
1 5 * * * /bin/bash -l -c -i "source $HOME/.keychain/chis-devpc-sh && /usr/bin/scp -vvv -F /home/chris/.ssh/config -i /home/chris/.ssh/id_rsa db:/var/apps/perch/shared/backups/\* /home/chris/ServerBackups/" > /home/chris/tmp/db_backup_copy_log.cron 2>&1
@chris-piekarski
chris-piekarski / wrong_thread_exception
Created May 2, 2013 21:17
Android Views & CalledFromWrongThreadException
#CalledFromWrongThreadException
#Views can only be executed on by the thread that created them. If your in a different thread you have to use
#the runOnUiThread method.
runOnUiThread(new Runnable() {
public void run() {
//stuff that updates ui
}