Skip to content

Instantly share code, notes, and snippets.

@phucnh
phucnh / type-bounds.scala
Last active August 29, 2015 14:27 — forked from retronym/type-bounds.scala
Tour of Scala Type Bounds
class A
class A2 extends A
class B
trait M[X]
//
// Upper Type Bound
//
def upperTypeBound[AA <: A](x: AA): A = x
@phucnh
phucnh / Dockerfile
Created August 17, 2015 04:58
Sample Dockerfile jar project
FROM ubuntu:trusty
# Port mapping
EXPOSE 8080
# Install oracle-java8
RUN \
apt-get install -y software-properties-common && \
add-apt-repository -y ppa:webupd8team/java && \
apt-get update && \
@phucnh
phucnh / android_pkg_name_validate.js
Created October 30, 2015 08:21 — forked from rishabhmhjn/android_pkg_name_validate.js
Regex to validate Android Package Name
var pattern = /^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_]$/i;
[
"me.unfollowers.droid",
"me_.unfollowers.droid",
"me._unfollowers.droid",
"me.unfo11llowers.droid",
"me11.unfollowers.droid",
"m11e.unfollowers.droid",
"1me.unfollowers.droid",
@phucnh
phucnh / vimium-emacs.md
Created November 1, 2015 02:07
Emacs-Style Key Bindings for Vimium

My Vimium Key Bindings (Emacs-Style)

This is a full set of key bindings (as of Vimium v1.45); covering all Vimium functionality. I have tried to map all Vimium functionality to comparable Emacs functionality (whenever possible). In cases where there is no equivalent, those commands are prefixed by <c-g> (indicating <c-g>oogle Chrome; and because <c-g> does not conflict with other Emacs shortcuts at all).

Commented Shortcuts: There are a few Emacs-style shortcuts that are simply not possible in Vimium. All of my shortcuts (including those which were not possible; i.e. where I used a decent alternative) have been commented below. This should help to clarify my rationale.

_Compatibility: All of these shortcuts were tested on Mac OS X (Mavericks). Please note that all of my shortcuts operate under the assumption that your Emacs Meta key is the Alt/Option key. This really was my only choice, because the key is already used in Chrome for shortcuts that c

@phucnh
phucnh / rm_mysql.md
Created January 20, 2016 10:13 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

brew remove mysql

@phucnh
phucnh / gist:d24a732e923f54da3552
Created February 4, 2016 16:48 — forked from gakuzzzz/gist:8d497609012863b3ea50
Scalaz勉強会 主要な型クラスの紹介
@phucnh
phucnh / ScalaEnum.scala
Created February 17, 2016 12:14 — forked from tjweir/ScalaEnum.scala
DIY Scala Enums (with optional exhaustiveness checking)
trait Enum { //DIY enum type
import java.util.concurrent.atomic.AtomicReference //Concurrency paranoia
type EnumVal <: Value //This is a type that needs to be found in the implementing class
private val _values = new AtomicReference(Vector[EnumVal]()) //Stores our enum values
//Adds an EnumVal to our storage, uses CCAS to make sure it's thread safe, returns the ordinal
private final def addEnumVal(newVal: EnumVal): Int = { import _values.{get, compareAndSet => CAS}
val oldVec = get
@phucnh
phucnh / gist:7522ca0942407f62c4fd
Created March 16, 2016 08:22 — forked from mbedward/gist:6e3dbb232bafec0792ba
Scala macro to convert between a case class instance and a Map of constructor parameters. Developed by Jonathan Chow (see http://blog.echo.sh/post/65955606729/exploring-scala-macros-map-to-case-class-conversion for description and usage). This version simply updates Jonathan's code to Scala 2.11.2
import scala.language.experimental.macros
import scala.reflect.macros.blackbox.Context
trait Mappable[T] {
def toMap(t: T): Map[String, Any]
def fromMap(map: Map[String, Any]): T
}
object Mappable {
@phucnh
phucnh / dropbox_git.md
Created May 6, 2016 01:33 — forked from trey/dropbox_git.md
Using Dropbox to Share Git Repositories

Using Dropbox to Share Git Repositories

First, create a Git subfolder inside your Dropbox folder. Then you can share the individual projects inside that folder with whomever you want (or just use it for instant offsite backups).

From inside a Git project:

git clone --bare . ~/Dropbox/Git/gitproject.git
git remote add dropbox ~/Dropbox/Git/gitproject.git

When you're ready to push:

@phucnh
phucnh / tslint.json
Created May 15, 2016 07:09
typescript coding style configurations
{
"rules": {
"class-name": true,
"comment-format": [false,
"check-space",
"check-lowercase"
],
"curly": true,
"eofline": false,
"forin": true,