Skip to content

Instantly share code, notes, and snippets.

View mancdevcarl's full-sized avatar

Carl mancdevcarl

  • MancDev
  • Manchester
View GitHub Profile
public class MyAppClass extends Application
{
public static Typeface FONT_AWESOME;
public static FontAwesomeHelper FONT_AWESOME_HELPER;
@Override
public void onCreate()
{
super.onCreate();
@mancdevcarl
mancdevcarl / gist:9f0d3230b4c381ce7a4d
Last active August 29, 2015 14:13
Simple Green Screen images for Android
//This demo app Assumes there are 2 jpg files on the sdcard in the root directory
public class MainActivity extends ActionBarActivity {
ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@mancdevcarl
mancdevcarl / gist:6201438
Last active December 20, 2015 21:59
Draw text in center of bitmap using canvas
class CreateShareImage extends AsyncTask<String, Void, String> {
@Override
protected void onPreExecute() {
}
@Override
protected String doInBackground(String... params) {
Bitmap bkgImage = BitmapFactory.decodeResource(
MainActivity.this.getResources(), R.drawable.stork);
Bitmap mutableBitmap = bkgImage.copy(Bitmap.Config.ARGB_8888, true);
@mancdevcarl
mancdevcarl / gist:5855364
Created June 25, 2013 02:06
Thread, Runnable, Handler, AsyncTask
public class BlehActivity extends Activity {
private Handler handler;
private ProgressBar progress;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
progress = (ProgressBar) findViewById(R.id.progressBar1);
handler = new Handler();
@mancdevcarl
mancdevcarl / gist:5767317
Last active December 18, 2015 10:19
POST
String sourceString = "";
HttpURLConnection connection;
OutputStreamWriter request = null;
URL url = null;
String response = null;
String params = "refext=http://offliberty.com&track=" + uri[0];
try {
@mancdevcarl
mancdevcarl / gist:5754340
Last active December 18, 2015 08:29
Reverse GEO to get City(locality)
public class ReverseGeoAsync extends AsyncTask<String, String, String> {
public interface AsyncDone {
void networkRequestCompleted(String res);
}
private AsyncDone _listener;
public ReverseGeoAsync(AsyncDone listenerParam) {
_listener = listenerParam;
}
@Override
protected String doInBackground(String... uri) {
@mancdevcarl
mancdevcarl / gist:5750508
Last active December 18, 2015 07:58
HttpRequest, extend Async, Interface callback to ImageView
import com.example.streetview.HttpRequest.NetworkListener;
public class MainActivity extends Activity implements NetworkListener {
ImageView iv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
iv = (ImageView) findViewById(R.id.img);
@mancdevcarl
mancdevcarl / gist:5737023
Last active December 18, 2015 05:59
AsyncTask Callback Example
public class Act extends Activity {
OnTaskCompleted otc = new OnTaskCompleted() {
@Override
public void onTaskCompleted(String result) {
Log.d("onTaskCompleted", result);
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@mancdevcarl
mancdevcarl / gist:5716335
Last active December 18, 2015 03:09
Check if service is running using SharedPreferences
//**in the service (ServiceX)
public static boolean isRunning(Context ctx) {
sharedPref = ctx.getSharedPreferences("my_pref", MODE_PRIVATE);
return sharedPref.getBoolean("running", false);
}
private void setRunning(boolean running) {
sharedPref = getSharedPreferences("my_pref", MODE_PRIVATE);
SharedPreferences.Editor prefEditor = sharedPref.edit();
prefEditor.putBoolean("running", running);
prefEditor.commit();
find someDir/ -iname "*.flv" -exec ffmpeg -i {} -sameq -ar 22050 {}.mp4 ";" -ls
vlc * --sout '#transcode{vcodec=h264,vb=92,channels=1,ab=16,samplerate=1024,width=320}:standard{access=http,mux=ts,dst=:666/tv.mp4}' --random --sout-keep
awk -F'[ "]+' '$7 == "/" { ipcount[$1]++ }END { for (i in ipcount) {printf "%15s - %d\n", i, ipcount[i] } }' /var/log/apache2/access.log
ffmpeg -loop 1 -shortest -y -i img.jpg -i snd.wav -acodec copy -vcodec mjpeg out.avi
ls * |sort > play.txt
cat play.txt | while IFS= read -r f; do printf "%05d %s\n" "$RANDOM" "$f"; done | sort -n | cut -c7- >> play.m3u
sed -e 's/$/\nwf.mp4/' -i play.m3u