Wednesday, September 30, 2015

unix commands for fun

sysvbanner
cowsay
cowthink
sl - steam locomotive
toilet & figlet
-F metal or --metal
-F gay or --gay
fortune
oneko
cmatrix
aafire
bb
rig

Saturday, September 5, 2015

List of Apps installed on my iPhones - the iPhone 6 and the iPhone 6 Plus

0. All of Apple & Google available on the platform.

  • Wikipedia
  • Bing
Social
  1. Facebook
  2. Twitter
  3. Pinterest
  4. Instagram
  5. Hyperlapse
  6. LinkedIn
  7. SnapChat
  8. SlingShot
  9. Path
  10. Tumblr
  11. Flickr
  12. Ello
  13. Klout
Media Sharing
  1. Stream
  2. Air
  3. Meerkat
  4. Periscope
Music
  1. Spotify
  2. 8Tracks
  3. Gaana
  4. Saavn
  5. SoundCloud
  6. SoundHound
  7. Pandora
News
  1. TechCrunch
  2. Mashable
  3. Engadget
  4. Medium
  5. Flipboard
  6. Pocket
  7. Play Newsstand (by Google)
  8. Paper (by Facebook)
  9. News Digest (by Yahoo)
Communication
  1. Hangouts (by Google)
  2. Viber
  3. WhatsApp
  4. Messenger (by Facebook)
  5. HipChat
  6. Slack
  7. Skype
  8. Line
  9. Appear.in
  10. PushBullet
  11. Inbox (by Google)
  12. Outlook (by Microsoft)
  13. Here Maps (by Microsoft)
  14. Earth (by Google)
  15. Human
  16. Strava
Travel
  1. Expedia
  2. Kayak
  3. Ixigo
  4. GoIbibo
  5. MakeMyTrip
  6. ClearTrip
  7. HipMunk
  8. GetAround
  9. JetRadar
  10. SeatGuru
  11. Quicket
  12. Flight SkyScanner
  13. AirfareWatchDog
  14. Momondo
  15. Skiplagged
  16. Hopper
  17. Airbnb
  18. Couchsurfing
  19. HomeAway
  20. Dwellable
  21. Rome2Rio
  22. Triposo
  23. Tripomatic
  24. Tripsta
  25. Tripcase
Cloud Storage/Backup
  1. Box
  2. OneDrive
  3. DropBox
  4. Copy
  5. Mega
  6. SpaceMonkey
  7. Bitcasa
  8. Syncplicity
  9. Cubby
Online Shopping
  1. Amazon
  2. Rakuten Ichiba
  3. AliExpress
Finance
  1. SplitWise
  2. Expensify
  3. DayCost
  4. cRate
  5. fxTrade
  6. Currency
  7. Level

Misc
  1. Quizup
  2. Quora
  3. Office Lens
  4. Translate
  5. TimeHop
  6. OpenSignal
  7. Fing
  8. Commander Compass Lite
  9. ZType
  10. Kindle (by Amazon)
  11. Kobo (by Rakuten)
  12. OverDrive
  13. Sway
  14. Flava
  15. CDE
  16. Sphere (by Google)
  17. Carousel (by DropBox)
  18. ShoeBox
  19. Doodle
  20. EverNote
  21. Xender
  22. Infinit
  23. MacId
  24. Tether

List of Apps installed on my Android Device - Asus Zenfone 5

Before i try some other Android device, i compiled a list of apps i use on my current Android phone. Although this is my secondary phone, i do use it quite often. I have skipped the default ones provided by Google, and all social networking related or social media sharing ones. I also skipped local Japanese apps, by Rakuten, for example. No eCommerce/online shopping apps were listed either.
  1. 8Tracks
  2. Aldiko
  3. AliExpress
  4. Bandcamp
  5. Bing
  6. Camera (by Google)
  7. CDE (Computer Desktop Encyclopaedia)
  8. CityMaps
  9. Dolphin Zero
  10. ES File Explorer
  11. Fing (network tool)
  12. Firefox (by Mozilla)
  13. Flava
  14. Flights (by SkyScanner)
  15. Flipboard
  16. Gaana
  17. Hopper Flights
  18. Jamendo
  19. Kindle (by Amazon)
  20. Kobo (by Rakuten)
  21. Libon
  22. Line
  23. My Tracks
  24. Office Mobile (by Microsoft)
  25. OneDrive (by Microsoft, for Media Backup)
  26. OpenSignal (network tool)
  27. Opera - Mini, Max, Mobile, whatever
  28. OverDrive
  29. Photos (by Google, for Media Backup)
  30. Portal (by PushBullet)
  31. PushBullet
  32. QR Code Reader
  33. Saavn
  34. ShoeBox (for Media Backup)
  35. Skype
  36. Translate
  37. Viber
  38. WhatsApp
  39. Wikipedia
  40. Xender

Tuesday, August 25, 2015

Transform Web Browser to Editor Trick

1. Use web browser as plain text text editor, try using bookmarklet
type in browser's address bar: data:text/html, <html contenteditable>
2. Make a webpage's contents editable, without losing styling, execute on JavaScript console or via bookmarklet.
javascript: document.body.contentEditable='true'; document.designMode='on'; void 0;
"void 0;" is very important!

Saturday, July 11, 2015

Image Metadata Javascript

function getMeta(imageUrl){
  $('<img/>').attr('src', imageUrl).load(function(){
     s = {w:this.width, h:this.height};
     alert(s.w+' '+s.h);    
  });
}

Thursday, July 2, 2015

Java Logging

try {
    Handler handler = new FileHandler("OutFile.log");
    Logger.getLogger("").addHandler(handler);
    
} catch (IOException e) {
    Logger logger = Logger.getLogger("package.name"); 
    StackTraceElement elements[] = e.getStackTrace();
    for (int i = 0, n = elements.length; i < n; i++) {
        logger.log(Level.WARNING, elements[i].getMethodName());
    }
}

Java Exception StackTrace

[Exception.getStackTrace()]
catch (Exception cause) {
    StackTraceElement elements[] = cause.getStackTrace();
    for (int i = 0, n = elements.length; i < n; i++) {       
        System.err.println(elements[i].getFileName()
            + ":" + elements[i].getLineNumber() 
            + ">> "
            + elements[i].getMethodName() + "()");
    }
}
[ExceptionObject.printStackTrace()]

Sunday, June 28, 2015

Probable Prime using Java Big Integer

BigInteger prime = BigInteger.valueOf(0);
for (int i = 0; i < n; i++) {
    prime = prime.nextProbablePrime();
}
System.out.println(prime.intValue());

Most Efficient Code for Nth Prime

public static int nthprime(int n) {
if (n == 1) return 2;
if (n == 2) return 3;
int limit, root, count = 1;
limit = (int)(n * (Math.log(n) + Math.log(Math.log(n)))) + 3;
root = (int) Math.sqrt(limit) + 1;
limit = (limit - 1) / 2;
root = root / 2 - 1;
boolean[] sieve = new boolean[limit];
for (int i = 0; i < root; ++i) {
if (!sieve[i]) {
++count;
for (int j = 2 * i * (i + 3) + 3, p = 2 * i + 3; j < limit; j += p) {
sieve[j] = true;
}
}
}
int p;
for (p = root; count < n; ++p) {
if (!sieve[p]) {
++count;
}
}
return 2 * p + 1;
}

Sunday, June 21, 2015

CSS Element Full Rotation

/* rotation animation */
@-webkit-keyframes rotate {
  from { -webkit-transform:rotate(0deg); }
  to { -webkit-transform:rotate(360deg); }
}

@-moz-keyframes rotate {
  from { -moz-transform:rotate(0deg); }
  to { -moz-transform:rotate(360deg); }
}

@-ms-keyframes rotate {
  from { -ms-transform:rotate(0deg); }
  to { -ms-transform:rotate(360deg); }
}

@-o-keyframes rotate {
  from { -o-transform:rotate(0deg); }
  to { -o-transform:rotate(360deg); }
}

.rotating {
  -webkit-transform-origin: 50% 50%;
  -webkit-animation-name: rotate;
  -webkit-animation-duration: 1s;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-timing-function: linear;
  -moz-transform-origin: 50% 50%;
  -moz-animation-name: rotate;
  -moz-animation-duration: 1s;
  -moz-animation-iteration-count: infinite;
  -moz-animation-timing-function: linear;
  -ms-transform-origin: 50% 50%;
  -ms-animation-name: rotate;
  -ms-animation-duration: 1s;
  -ms-animation-iteration-count: infinite;
  -ms-animation-timing-function: linear;
  -o-transform-origin: 50% 50%;
  -o-animation-name: rotate;
  -o-animation-duration: 1s;
  -o-animation-iteration-count: infinite;
  -o-animation-timing-function: linear;
}

Clean Up Email

[from:noreply* OR from:do-not-reply* OR from:donotreply* OR from:notification*]
[from:news* OR from:digest* OR from:auto* OR from:reports* OR from:*mailer*]

Friday, June 19, 2015

io to nio

File folder=new Folder("D:\\");

File[] files = folder.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith("" + FILE_EXT + "");
}
});

Path dir=Paths.get("D:\\");
DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "*.{" + FILE_EXT + "}");

Base64

Base64.encodeBase64String(input.getBytes(charset));

Friday, June 12, 2015

Quick System.out.println()

static<T> void z(T arg) { System.out.println(arg); }
use z(object)
buzz around! dump text, write to console, overflow the terminal, debug code

Wednesday, May 27, 2015

Things to do on Fresh Linux installation

sudo apt-get install synaptic vlc gimp gimp-data gimp-plugin-registry gimp-data-extras y-ppa-manager bleachbit openjdk-7-jre oracle-java8-installer flashplugin-installer unace unrar zip unzip p7zip-full p7zip-rar sharutils rar uudeview mpack arj cabextract file-roller libxine1-ffmpeg mencoder flac faac faad sox ffmpeg2theora libmpeg2-4 uudeview libmpeg3-1 mpeg3-utils mpegdemux liba52-dev mpeg2dec vorbis-tools id3v2 mpg321 mpg123 libflac++6 totem-mozilla icedax lame libmad0 libjpeg-progs libdvdcss2 libdvdread4 libdvdnav4 libswscale-extra-2 ubuntu-restricted-extras ubuntu-wallpapers*


  1. synaptic is a package manager, which we use in many tutorials.
  2. vlc is one of the most popular and powerful media players available.
  3. gimpgimp-datagimp-plugin-registry, andgimp-data-extras are all parts of a powerful photo editor, built to rival Adobe Photoshop.
  4. y-ppa-manager is there so you can manage PPAs without needing to use the Terminal.
  5. bleachbit is a powerful cleaning utility.
  6. openjdk-7-jre is an open-source Java emulator.
  7. oracle-java8-installer is the official Java installer.
  8. flashplugin-installer is the official Flash installer.
  9. unaceunrarzipunzipp7zip-fullp7zip-rarsharutilsraruudeviewmpackarj,cabextract, and file-roller are there to extract and compress files in various archive formats.
  10. libxine1-ffmpegmencoderflacfaacfaad,soxffmpeg2theoralibmpeg2-4uudeview,libmpeg3-1mpeg3-utilsmpegdemuxliba52-devmpeg2decvorbis-toolsid3v2mpg321,mpg123libflac++6totem-mozillaicedax,lamelibmad0libjpeg-progslibdvdcss2,libdvdread4libdvdnav4libswscale-extra-2and ubuntu-restricted-extras are all media codecs. They play videos, music, and DVDs.
  11. ubuntu-wallpapers* adds basically every wallpaper that has ever lived.

Sunday, May 17, 2015

Exploring java.time package

Forget Java.Date and Java.Calendar,
try Java.Time!

Source Code

//生年月日
LocalDate bf=LocalDate.of(1992,12,16);
LocalDate rf=LocalDate.of(2015,12,19);
Clock c=Clock.systemUTC();
Clock d=Clock.systemDefaultZone();
LocalDate n=LocalDate.now();//c or d
dump("Current Instant : "+Instant.now());
dump("Current Instant as per System UTC: "+Instant.now(c));
dump("Current Instant as per System Default Timezone : "+Instant.now(d));
dump("Birthdate -> "+bf);
dump("DoM : " +bf.getDayOfMonth()+" of "+bf.lengthOfMonth()+"-day long "+bf.getMonth());
dump("DoY : "+bf.getDayOfYear()+" of "+bf.lengthOfYear()+"-day long "+bf.getYear());
dump("Today -> "+n);
Period yet=bf.until(n);//Duration equivalent in terms of Days
//å¹´é½¢
dump("Age : -> "+yet.getYears()+" years "+yet.getMonths()+" months "+yet.getDays()+" days");
dump("Today -> "+n);
dump("Flight -> "+rf);
Period more=n.until(rf);//Try Duration for time to sleep, go home or wake up.
dump("Return : -> "+more.getYears()+" years "+more.getMonths()+" months "+more.getDays()+" days");

Wet Run - Sample Output

Current Instant : 2015-05-18T07:55:55.178Z
Current Instant as per System UTC: 2015-05-18T07:55:55.192Z
Current Instant as per System Default Timezone : 2015-05-18T07:55:55.192Z
Birthdate -> 1992-12-16
DoM : 16 of 31-day long DECEMBER
DoY : 351 of 366-day long 1992
Today -> 2015-05-18
Age : -> 22 years 5 months 2 days
Today -> 2015-05-18
Flight -> 2015-12-19
Return : -> 0 years 7 months 1 days

Monday, May 11, 2015

Common Regular Expressions

IP Address Regexp

\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b

MAC Address Regexp

^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$

Domain Name Regexp

^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$

Floating Point Number Regexp

[-+]?(?:\b[0-9]+(?:\.[0-9]*)?|\.[0-9]+\b)(?:[eE][-+]?[0-9]+\b)?

Roman Number Regexp

^(?i:(?=[MDCLXVI])((M{0,3})((C[DM])|(D?C{0,3}))?((X[LC])|(L?XX{0,2})|L)?((I[VX])|(V?(II{0,2}))|V)?))$


Going one step further with Kotlin & gRPC

Recently, I tried using Quarkus with Kotlin for grpc. I have worked with grpc for communication between microservices in Java & Golang. ...