Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / hmacsha1.scala
Last active August 29, 2015 14:26 — forked from ohac/hmacsha1.scala
HMAC-SHA1 for Scala
import javax.crypto.spec.SecretKeySpec
import javax.crypto.Mac
object A {
def main(args: Array[String]): Unit = {
val secret = new SecretKeySpec("the_secret".getBytes, "HmacSHA1")
val mac = Mac.getInstance("HmacSHA1")
mac.init(secret)
val result: Array[Byte] = mac.doFinal("foo".getBytes)
println(result.map(_.toString).mkString(","))
/**
* The MIT License (MIT)
*
* Copyright (c) 2013-2015 Andrew Snare, Age Mooij
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@phucnh
phucnh / auth.go
Last active August 29, 2015 14:23 — forked from tristanwietsma/auth.go
package main
import (
"encoding/base64"
"net/http"
"strings"
)
type handler func(w http.ResponseWriter, r *http.Request)
package com.cyberz.foxapi.dao
import scala.slick.jdbc.JdbcBackend._
/**
* Created by Yuto Suzuki on 15/03/06.
*/
object BaseTransaction {
/**
@phucnh
phucnh / run_play_console.scala
Last active August 29, 2015 14:17
create play application
import play.api.{ DefaultApplication, Mode, Play }
val applicationPath = new java.io.File(".")
val classLoader = this.getClass.getClassLoader
val sources = None
val applicationMode = Mode.Dev
Play.start(new DefaultApplication(applicationPath, classLoader, sources, applicationMode))
#!/bin/bash
#
# =========================================================================
# Copyright 2014 Rado Buransky, Dominion Marine Media
#
# 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