Skip to content

Instantly share code, notes, and snippets.

View hrgdavor's full-sized avatar

Davor Hrg hrgdavor

  • RGO communications
  • Croatia
View GitHub Profile
@hrgdavor
hrgdavor / Bits.java
Last active April 25, 2017 16:48
java convert long to 64 bits(0|1) string
public class Bits{
public static void main(String[] args){
long val = -12435L;
System.out.println(longBits(val));
// 1111111111111111111111111111111111111111111111111100111101101101
System.out.println(longBitsSpaced(val));
// 11111111 11111111 11111111 11111111 11111111 11111111 11001111 01101101
}
@hrgdavor
hrgdavor / Highlander.java
Created March 10, 2017 12:15
Use a TCP port to check if another instance is running ad stop it (for dev when restarting app multiple times to test)
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
public class Highlander {
@hrgdavor
hrgdavor / matcher
Created October 17, 2015 20:57
small, simple, matcher function factory for searching DOM nodes
/** any tag
- () - any alement that is a tag and not TextElement
- (func) - matching decided by the provided function
- (tag) - element with that tag
- (attr,value) - element with attribute and value for it
- (tag,attr,value) */
function matcher(p1,p2,p3){
if(typeof(p1) == 'function') return p1;
if(!p3){
if(!p2){