Skip to content

Instantly share code, notes, and snippets.

@dohaivu
dohaivu / WebApi tracing
Created April 3, 2013 09:57
tracing for webapi
public static void Register(HttpConfiguration config)
{
config.Services.Replace(typeof(ITraceWriter), new MyTracer());
}
public class MyTracer : ITraceWriter
{
@dohaivu
dohaivu / Git message.md
Last active June 5, 2017 04:32
Useful tips for #git message

Why is this change necessary?

This question tells reviewers of your pull request what to expect in the commit, allowing them to more easily identify and point out unrelated changes.

How does it address the issue?

Describe, at a high level, what was done to affect change. “Introduce a red/black tree to increase search speed” or “Remove , which was causing ” are good examples.

@dohaivu
dohaivu / apps.js
Created October 19, 2013 09:33 — forked from eliOcs/apps.js
/*jslint node: true */
"use strict";
var express = require("express"),
consolidate = require("consolidate"),
Handlebars = require("handlebars"),
fs = require("fs");
var app = express();
@dohaivu
dohaivu / git.md
Last active June 6, 2017 10:38 — forked from neilgee/git.css
#git commands
/* Set up Git Configuration */

git config --global user.email "neil@coolestguidesontheplanet.com"

git config --global user.name "Neil Gee"

git config --global core.editor "vi"

git config --global color.ui true
@dohaivu
dohaivu / business-models.md
Last active August 29, 2015 14:04 — forked from ndarville/business-models.md
Busineess model

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@dohaivu
dohaivu / .bash_profile
Last active September 9, 2017 02:53 — forked from Pallinder/.bash_profile
[go setup] #go gdb debug setup
alias gdbnew='/usr/local/Cellar/gdb/7.6/bin/gdb'
@dohaivu
dohaivu / aws_cli.md
Created May 30, 2017 06:49
[aws cli] aws commands #tags:aws, cli
pip install awscli

aws configure # use access key, secret key
@dohaivu
dohaivu / recyclerview.java
Last active September 18, 2017 03:38
RecyclerView #android
protected void onCreate(Bundle savedInstanceState) {
DividerItemDecoration decoration = new DividerItemDecoration(getApplicationContext(), VERTICAL);
recyclerView.addItemDecoration(decoration);
}
// override onDraw ItemDecoration.java, draw a devider line
@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
canvas.save();
@dohaivu
dohaivu / colors.md
Last active May 26, 2018 02:23
colors
Percentage to HEX
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
@dohaivu
dohaivu / resize.java
Last active July 12, 2017 04:51
[Android images handling] image resize, rotate in #android
public static int calculateInSampleSize(
BitmapFactory.Options options, int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
final int halfHeight = height / 2;