This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var spinner: UIActivityIndicatorView! | |
| func setupSpinner(){ | |
| spinner = UIActivityIndicatorView(frame: CGRect(x: 0, y: 0, width: 40, height:40)) | |
| spinner.color = UIColor.gray | |
| self.spinner.center = CGPoint(x:UIScreen.main.bounds.size.width / 2, y:UIScreen.main.bounds.size.height / 2) | |
| self.view.addSubview(spinner) | |
| spinner.hidesWhenStopped = true | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import UIKit | |
| struct H { | |
| static func showOneBtnAlert(_ ctx: UIViewController, header: String, msg: String) { | |
| let alert = UIAlertController(title: header, message: msg, preferredStyle: UIAlertControllerStyle.alert) | |
| alert.addAction(UIAlertAction(title: Btn.ok, style: UIAlertActionStyle.default, handler: nil)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| export DISPLAY=:0 | |
| ts="$(date +%Y-%m-%d_%H:%M:%S)" | |
| /usr/bin/notify-send -t 5000 "Ok. hi" $ts | |
| #spd-say hello_my_friend |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static String getDeviceId(Context ctx) { | |
| TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); | |
| String deviceId; | |
| if (tm.getDeviceId() != null) { | |
| deviceId = tm.getDeviceId(); | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static String getDeviceId(Context ctx) { | |
| TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); | |
| String deviceId; | |
| if (tm.getDeviceId() != null) { | |
| deviceId = tm.getDeviceId(); | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| n = 11 | |
| while n != 1: | |
| print n | |
| if n % 2 == 0: | |
| n /= 2 | |
| else: | |
| n = 3 * n + 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void openPlayMarketByPackageName(Context ctx, String packageName) { | |
| try { | |
| ctx.startActivity(new Intent(Intent.ACTION_VIEW, | |
| Uri.parse("market://details?id=" + packageName))); | |
| } catch (android.content.ActivityNotFoundException anfe) { | |
| ctx.startActivity(new Intent(Intent.ACTION_VIEW, | |
| Uri.parse("https://play.google.com/store/apps/details?id=" + packageName))); | |
| } catch (Exception ex) { | |
| ex.printStackTrace(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ssh root@MachineB 'bash -s' < local_script.sh | |
| PID=`ps -ef | grep rest-ser | grep -v grep | awk '{print $2}'` | |
| #!/bin/bash | |
| PID=`ps -ef | grep rest-ser | grep -v grep | awk '{print $2}'` | |
| echo $PID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Override | |
| public boolean onOptionsItemSelected(MenuItem item) { | |
| switch (item.getItemId()) { | |
| case android.R.id.home: | |
| Toast.makeText(getApplicationContext(),"Back button clicked", Toast.LENGTH_SHORT).show(); | |
| break; | |
| } | |
| return true; | |
| } |