Skip to content

Instantly share code, notes, and snippets.

View luanvuhlu's full-sized avatar

luan vu luanvuhlu

View GitHub Profile
@luanvuhlu
luanvuhlu / ReadMoney.java
Last active March 27, 2024 08:54
Read money from number to Vietnam Dong text by Java and Javascript
private String readGroup(String group){
String[] readDigit = {" Không", " Một", " Hai", " Ba", " Bốn", " Năm", " Sáu", " Bảy", " Tám", " Chín" };
String temp = "";
if (group == "000") return "";
//read number hundreds
temp = readDigit[Integer.parseInt(group.substring(0,1))] + " Trăm";
//read number tens
if (group.substring(1,2).equals("0"))
if (group.substring(2,3).equals("0")) return temp;
else
@luanvuhlu
luanvuhlu / Bitmap.java
Last active February 24, 2016 01:42
Scale bitmap image Android
public Bitmap scaleBitmapDown(Bitmap bitmap, int maxDimension) {
int originalWidth = bitmap.getWidth();
int originalHeight = bitmap.getHeight();
int resizedWidth = maxDimension;
int resizedHeight = maxDimension;
if (originalHeight > originalWidth) {
resizedHeight = maxDimension;
resizedWidth = (int) (resizedHeight * (float) originalWidth / (float) originalHeight);
@luanvuhlu
luanvuhlu / ViewController.swift
Last active February 24, 2016 01:41
Set root view ios
if let userToken = result.token {
// Get user access token
let token: FBSDKAccessToken = result.token
let protectedPage = self.storyboard?.instantiateViewControllerWithIdentifier("ProtectedPageViewController") as! ProtectedPageViewController
let protectedPageNav = UINavigationController(rootViewController: protectedPage)
let appDelegate = UIApplication.shareApplication().delegate as! AppDelegate
appDelegate.window?.rootViewController = protectedPageNav
@luanvuhlu
luanvuhlu / ContactManager.java
Created February 24, 2016 01:30
Add a new contact on Android
private void addContact(ContactDetail c) {
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
int rawContactInsertIndex = ops.size();
ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
.withValue(RawContacts.ACCOUNT_TYPE, null)
.withValue(RawContacts.ACCOUNT_NAME, null).build());
//Phone Number
if(null!=c.getPhoneNumber()){
@luanvuhlu
luanvuhlu / frontendDevlopmentBookmarks.md
Created February 24, 2016 06:35 — forked from dypsilon/frontendDevlopmentBookmarks.md
A badass list of frontend development resources I collected over time.
@luanvuhlu
luanvuhlu / slugify.js
Created February 24, 2016 06:38 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
from models import BaseModel
class BaseAdmin(admin.ModelAdmin):
def save_model(self, request, obj, form, change):
if not change:
obj.created_by = request.user
obj.last_updated_by = request.user
obj.save()
$.event.special.widthChanged = {
remove : function() {
$(this).children('iframe.width-changed').remove();
},
add : function() {
var ss = document.createElement('style');
ss.type = "text/css";
ss.innerHTML = "iframe.width-changed {width: 100%;display: block;border: 0;height: 0;margin: 0;}";
document.body.appendChild(ss);
var elm = $(this);
@luanvuhlu
luanvuhlu / cookie.js
Created January 13, 2017 03:12
Cookie manager
@luanvuhlu
luanvuhlu / jsf-font-fix.html
Created February 1, 2017 05:02
Fix font not found JSF
<link rel="stylesheet" type="text/css"
href="#{request.contextPath}/resources/css/bootstrap.min.css">