Skip to content

Instantly share code, notes, and snippets.

Avatar

Markus Junginger greenrobot

View GitHub Profile
@greenrobot
greenrobot / gist:8feae5738d37231988b2
Created Apr 14, 2015
WordPress DB script to update references to uploaded files (pictures)
View gist:8feae5738d37231988b2
SELECT meta_value, SUBSTRING(meta_value FROM 9) meta_value FROM `wp_postmeta` where meta_key = '_wp_attached_file' AND meta_value like '2014/%'
# UPDATE wp_postmeta SET meta_value = SUBSTRING(meta_value FROM 9) where meta_key = '_wp_attached_file' AND meta_value like '2014/%'
@greenrobot
greenrobot / ios2android.sh
Created Nov 5, 2014
Prepares iOS picture files for Android: images are renamed to conform with Android naming rules, and puts them into the correct drawable folder (-mdpi, -xhdpi, or -xxhdpi)
View ios2android.sh
#!/bin/sh
mkdir drawable-mdpi
mkdir drawable-xhdpi
mkdir drawable-xxhdpi
shopt -s nocaseglob
for iosFile in *.{png,jpeg,gif}; do
if [[ ! -f $iosFile ]]
then
continue
fi
@greenrobot
greenrobot / convert2utf8.sh
Created Feb 18, 2014
Bash script to convert Java sources to UTF-8 recursively
View convert2utf8.sh
#!/bin/sh
# For Windows: http://gnuwin32.sourceforge.net/packages/libiconv.htm
PATH=$PATH:/c/Program\ Files\ \(x86\)/GnuWin32/bin/
for file in $(find -name "*.java")
do
echo $file
iconv -f ISO-8859-1 -t UTF-8 "$file" >"${file%}.tmp"
mv "$file.tmp" "$file"
@greenrobot
greenrobot / AsyncTaskExecutionHelper.java
Created May 23, 2012
Helper bringing back parallel execution for AsyncTask (you are no serial execution and pseudo threading wimp, right?). Uses level 11 APIs when possible.
View AsyncTaskExecutionHelper.java
package de.greenrobot.util;
import java.util.concurrent.Executor;
import android.os.AsyncTask;
import android.os.Build;
/**
* Uses level 11 APIs when possible to use parallel/serial executors and falls back to standard execution if API level
* is below 11.