Skip to content

Instantly share code, notes, and snippets.

View swanhtet1992's full-sized avatar
🪶
Studying programming again!

Swan Htet Aung swanhtet1992

🪶
Studying programming again!
View GitHub Profile
@swanhtet1992
swanhtet1992 / ZgDetector.java
Created May 13, 2015 03:37
Zawgyi detector
package android.widget;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.text.TextUtils;
/**
*
* @author SH
*/
'''This script goes along the blog post
"Building powerful image classification models using very little data"
from blog.keras.io.
It uses data that can be downloaded at:
https://www.kaggle.com/c/dogs-vs-cats/data
In our setup, we:
- created a data/ folder
- created train/ and validation/ subfolders inside data/
- created cats/ and dogs/ subfolders inside train/ and validation/
- put the cat pictures index 0-999 in data/train/cats

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@swanhtet1992
swanhtet1992 / Interceptor.java
Created May 17, 2016 08:44 — forked from alex-shpak/Interceptor.java
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON

Keybase proof

I hereby claim:

  • I am swanhtet1992 on github.
  • I am sha (https://keybase.io/sha) on keybase.
  • I have a public key whose fingerprint is 4850 3D9F 9D47 47B4 01F9 633E 2C3C 9C5E C6BC CDD2

To claim this, I am signing this object:

private final Handler mHandler = new Handler();
// should be inside onItemClick of DrawerItemClickListener
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mFragManager.beginTransaction().replace(R.id.content_frame,mFragment).addToBackStack(null).commit();
}
}, 300);
/*1) Searching Array by converting Array to ArrayList in Java
ArrayList in Java has a convenient method called contains() which returns true if object passed to it are inside ArrayList. by converting an array into ArrayList in Java we can easily use this option for searching any element in Java array.
2) Search Java array by converting Array to HashSet
Just like we can leverage ArrayList's contains method we can also use HashSet contains() method which has O(1) response time for search. So if you need constant search time to find an element in array, consider converting your Array into HashSet in Java. see the code section for complete example of searching elements in Java array using HashSet's contains() method.
3) Searching Java Array using Arrays.binarySearch()
Binary Search is another faster way of searching elements in Java array but it requires array to be sorted while earlier examples of finding elements on Array can be used with both sorted and unsorted array. java.util.Arrays class provides both so
@swanhtet1992
swanhtet1992 / 0_reuse_code.js
Created November 1, 2013 14:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="config_app_name">AVélib</string>
<string name="config_authority">com.cyrilmottier.android.avelib.citybikes</string>
<string name="config_com.google.android.maps.v2.api_key">XXX</string>
</resources>
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software