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
| Android Tips and Tricks | |
| 1) ImageView setCropToPadding by code when setting CENTER_CROP as scaleType: | |
| ==================================================================== | |
| Field field; | |
| try { | |
| field = ImageView.class.getDeclaredField("mCropToPadding"); | |
| field.setAccessible(true); | |
| field.set((ImageView) convertView, 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
| $ openssl genrsa -des3 -passout pass:x -out server.pass.key 2048 | |
| ... | |
| $ openssl rsa -passin pass:x -in server.pass.key -out server.key | |
| writing RSA key | |
| $ rm server.pass.key | |
| $ openssl req -new -key server.key -out server.csr | |
| ... |
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 org.jsoup.Jsoup; | |
| import org.jsoup.nodes.Document; | |
| import org.jsoup.nodes.Element; | |
| import java.io.IOException; | |
| import java.text.SimpleDateFormat; | |
| import java.util.Date; | |
| import java.util.HashMap; | |
| public class WikipediaFeatureArticle { |
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
| for y in `ls *` | |
| do | |
| echo $y | |
| sed -i 's|old-text-here|new-text-here|g' "$y" | |
| done |
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
| encryption: | |
| openssl rsa/des/des3 -e -salt -pass pass:passphrase -in input_file -out output_file | |
| decryption: | |
| openssl rsa/des/des3 -d -salt -pass pass:pass-phrase -in input_file -out output_file |
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-keygen -t rsa -b 4096 -C "your_email@example.com" |
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
| 1) Nine patch | |
| It allows extension in 9 ways, | |
| i.e. 4 corners that are unscaled, | |
| 4 edges that are scaled in 1 axis, | |
| and the middle one that can be scaled into both axes. | |
| 2) Implicit and explicit intents | |
| Implicit intents do not name a specific component, | |
| but instead declare a general action to perform, which allows a component from another app to handle it. | |
| eg: default system intents like sms,call,sendTo,view etc |
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
| https://docs.oracle.com/javase/8/docs/technotes/guides/concurrency/threadPrimitiveDeprecation.html | |
| Java Thread Primitive Deprecation | |
| Why is Thread.stop deprecated? | |
| Because it is inherently unsafe. Stopping a thread causes it to unlock all the monitors that it has locked. (The monitors are unlocked as the ThreadDeath exception propagates up the stack.) If any of the objects previously protected by these monitors were in an inconsistent state, other threads may now view these objects in an inconsistent state. Such objects are said to be damaged. When threads operate on damaged objects, arbitrary behavior can result. This behavior may be subtle and difficult to detect, or it may be pronounced. Unlike other unchecked exceptions, ThreadDeath kills threads silently; thus, the user has no warning that his program may be corrupted. The corruption can manifest itself at any time after the actual damage occurs, even hours or days in the future. | |
| Couldn't I just catch the ThreadDeath exception and fix the damaged object |
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
| Process & Threads | |
| * volatile - java keyword indicating that a variable's value will be modified by different threads. (for synchronization) | |
| * Types of process & in the order of importance: | |
| - Foreground process- running Activity, Bounded services, Foreground service(startForeground),Service with its own lifeCycle, Broadcast receiver | |
| - Visible process - foreground activity(visible, but onPause called), service bound to visible/foreground activity | |
| - Service process - A process that is running a service that has been started with the startService() method,eg music in bg,download | |
| - Background process - background activity(onstop called) | |
| - Empty process - A process that doesn't hold any active application components, for caching purposes, to improve startup time |
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
| Peripheral Mode [ Supported above api 21 only (M and above, some devices including google nexus devices) ] | |
| =============== | |
| BluetoothManager = #getSystemService(BLUETOOTH_SERVICE); | |
| BluetoothAdaper = BluetoothManager#getAdapter(); | |
| Server: | |
| ------ | |
| BluetoothGattServer = BluetoothManager#openGattServer(Context,BluetoothGattServerCallback) |
OlderNewer