This file contains 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
SELECT setval('tbl_tbl_id_seq', max(tbl_id)) FROM tbl; |
This file contains 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
//BASH | |
cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2 | |
//BASH PERL | |
cat /proc/cpuinfo | perl -n -e '/^Serial[ ]*: ([0-9a-f]{16})$/ && print "$1\n"' | |
//Python |
This file contains 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
//You can use a Runnable to wrap your method: | |
Runnable r = new Runnable() { | |
public void run() { | |
Sesija.forceNalog(reg.getText().toString(), num); | |
} | |
} | |
//Then pass it to your method and call r.run(); where you need it: |
This file contains 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 Internet Protocol v4 the value consists of an integer, the least significant 8 bits of which represent the value of the TOS octet in IP packets sent by the socket. RFC 1349 defines the TOS values as follows: | |
IPTOS_LOWCOST (0x02) | |
IPTOS_RELIABILITY (0x04) | |
IPTOS_THROUGHPUT (0x08) | |
IPTOS_LOWDELAY (0x10) | |
The last low order bit is always ignored as this corresponds to the MBZ (must be zero) bit. | |
24 is 0x18 i.e. 0x10 | 0x08, which corresponds to IPTOS_THROUGHPUT and IPTOS_LOWDELAY being set. |
This file contains 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
WifiConfiguration wifiConfig = new WifiConfiguration(); | |
wifiConfig.SSID = String.format("\"%s\"", ssid); | |
wifiConfig.preSharedKey = String.format("\"%s\"", key); | |
WifiManager wifiManager = (WifiManager)getSystemService(WIFI_SERVICE); | |
//remember id | |
int netId = wifiManager.addNetwork(wifiConfig); | |
wifiManager.disconnect(); | |
wifiManager.enableNetwork(netId, true); | |
wifiManager.reconnect(); |
This file contains 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
//Simple helper class to encrypt and decrypt strings using AES128. | |
//The result is Ascii-encoded (actually hex, no base64), so no byte[] has to be stored. | |
//A SEED value is used as a shared secret (“Master-Password”). | |
//Only with the same SEED the stored values can be decrypted. | |
package net.sf.andhsli.hotspotlogin; | |
import java.security.SecureRandom; | |
import javax.crypto.Cipher; | |
import javax.crypto.KeyGenerator; | |
import javax.crypto.SecretKey; |
This file contains 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
private void mixSound() throws IOException { | |
AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT, 44100, AudioTrack.MODE_STREAM); | |
InputStream in1=getResources().openRawResource(R.raw.track1); | |
InputStream in2=getResources().openRawResource(R.raw.track2); | |
byte[] music1 = null; | |
music1= new byte[in1.available()]; | |
music1=convertStreamToByteArray(in1); | |
in1.close(); |
This file contains 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
/** | |
* Ensures that the caller receives an usable multicast socket. | |
* In case the network configuration does not have a default gateway | |
* set, the multicast socket might not work. This is the case when | |
* the device is connected to a Wireless Direct printer. In that | |
* cases, force a network interface into the socket. | |
* | |
* @return A ready-to-use multicast socket. | |
*/ | |
public static MulticastSocket createMulticastSocket(Context context) |
This file contains 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
// From android 4.1 / 4.2, the following Roboto font families are available: | |
android:fontFamily="sans-serif" // roboto regular | |
android:fontFamily="sans-serif-light" // roboto light | |
android:fontFamily="sans-serif-condensed" // roboto condensed | |
android:fontFamily="sans-serif-thin" // roboto thin (android 4.2) | |
android:fontFamily="sans-serif-medium" // roboto medium (android 5.0) | |
// in combination with this | |
android:textStyle="normal|bold|italic" |
This file contains 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
//Add the following override to your activity, | |
//This ought to fix the color banding issue you are seeing | |
//by setting the window format to support more colors. | |
@Override | |
public void onAttachedToWindow() { | |
getWindow().setFormat(PixelFormat.RGBA_8888); | |
} | |
//More info : http://developer.android.com/reference/android/view/Window.html#setFormat(int) |