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
<?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>
@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
/*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
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);
// Apache 2.0 licensed.
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/** An implementation of {@link BaseAdapter} which uses the new/bind pattern for its views. */
public abstract class BindableAdapter<T> extends BaseAdapter {
/* The date/time conversion code is going to be moved outside the asynctask later,
* so for convenience we're breaking it out into its own method now.
*/
private String getReadableDateString(long time){
// Because the API returns a unix timestamp (measured in seconds),
// it must be converted to milliseconds in order to be converted to valid date.
Date date = new Date(time * 1000);
SimpleDateFormat format = new SimpleDateFormat("E, MMM d");
return format.format(date).toString();
}
#! /usr/bin/env python2
import cv2
import numpy as np
from collections import deque
orig_image = None
gray_image = None
threshold_image = None
edge_image = None
dependencies {
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.wrapp.floatlabelededittext:library:0.0.5'
}
@swanhtet1992
swanhtet1992 / quiz.scala
Last active August 29, 2015 14:11
Solution for λ Talks in Yangon registration quiz
def multiply(x: Double, n: Double): Double = {
if (n == 0) 0 else x + multiply(x, n - 1)
}
def power(b: Int, e: Int): Double = {
if (e > 0) multiply(b.toDouble, power(b, e - 1))
else if (e < 0) 1/power(b, -e) // let me use / for negative e :P
else 1.0
}
/*
* Copyright 2014 Chris Banes
*
* 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