Skip to content

Instantly share code, notes, and snippets.

@a-v-ebrahimi
a-v-ebrahimi / ios_show_alert
Created March 2, 2014 11:52
iOS : Show alert
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title"
message:@"prompt"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok", nil ];
alert.tag = 10;
[alert show];
@a-v-ebrahimi
a-v-ebrahimi / exec_honey
Created June 8, 2014 21:19
Android:Execute AsyncTask Honeycomb
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
my_task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[])null);
else
my_task.execute((Void[])null);
@a-v-ebrahimi
a-v-ebrahimi / check_google_play_services
Created July 2, 2014 12:57
Check Google Play Services Is Available
private void checkGooglePlayServicesIsAvailable() {
int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (errorCode != ConnectionResult.SUCCESS) {
GooglePlayServicesUtil.getErrorDialog(errorCode, this, 0).show();
}
}
@a-v-ebrahimi
a-v-ebrahimi / gist:22b55e9eb8087c9c85d1
Created September 1, 2014 05:00
Check if user is elevated (UAC)
// copied from :
// http://stackoverflow.com/a/17492949/305135
public static class UacHelper
{
private const string uacRegistryKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System";
private const string uacRegistryValue = "EnableLUA";
private static uint STANDARD_RIGHTS_READ = 0x00020000;
private static uint TOKEN_QUERY = 0x0008;
@a-v-ebrahimi
a-v-ebrahimi / gradle_apk_name
Last active August 29, 2015 14:25
Android Gradle APK name
buildTypes {
release {
//...
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File(
output.outputFile.parent,
output.outputFile.name.replace("app-release.apk", "YOURAPPNAME-${variant.versionName}.apk"))
}
}
@a-v-ebrahimi
a-v-ebrahimi / copypath
Created August 5, 2015 11:42
Copy path to clipboard (Automator)
on run {input, parameters} try
tell application "Finder" to set the clipboard to POSIX path of (target of window 1 as alias)
on error
beep
end try return input end run
@a-v-ebrahimi
a-v-ebrahimi / ShowAlert
Created January 29, 2012 17:33
Show Alert in Android
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Reset...");
alertDialog.setMessage("Are you sure?");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// here you can add functions
}
});
alertDialog.setIcon(R.drawable.icon);
alertDialog.show();
@a-v-ebrahimi
a-v-ebrahimi / andActivity
Created February 2, 2012 12:00
android activity class
import android.app.Activity;
import android.os.Bundle;
public class actSpecial extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_);
registerEvents();
@a-v-ebrahimi
a-v-ebrahimi / showActivity
Created February 6, 2012 19:36
android Show Activity
Intent intent = new Intent(FirstActivity.this, OrderScreen.class);
startActivity(intent);
@a-v-ebrahimi
a-v-ebrahimi / getdatafromactivitybundle
Last active October 1, 2015 11:48
get data from Activity Bundle
Bundle bundle = this.getIntent().getExtras();
if (bundle!=null && bundle.containsKey("input"))
{
String txt=bundle.getString("input");
}