Skip to content

Instantly share code, notes, and snippets.

@phucnh
phucnh / .ctags
Last active November 10, 2016 16:33 — forked from ScrapCodes/etags.sh
file for etags --regex@${file} to generate scala tags.
-e
--langdef=scala
--langmap=scala:.scala
--regex-scala=class\s+(\w+)/\1/c,classes/
--regex-scala=object\s+(\w+)/\1/c,objects/
--regex-scala=trait\s+(\w+)/\1/t,traits/
--regex-scala=type\s+(\w+)/\1/T,types/
--regex-scala=def\s+(\w+)/\1/m,methods/
--regex-scala=val\s+(\w+)/\1/l,constants/
--regex-scala=var\s+(\w+)/\1/l,variables/
@phucnh
phucnh / API.md
Created July 12, 2016 16:33 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

This cheat sheet originated from the forum, credits to Laurent Poulain. We copied it and changed or added a few things.

Evaluation Rules

  • Call by value: evaluates the function arguments before calling the function
  • Call by name: evaluates the function first, and then evaluates the arguments if need be
    def example = 2      // evaluated when called
    val example = 2      // evaluated immediately
package Boot
import akka.actor.{Cancellable, Actor, ActorSystem, Props}
import akka.stream.{OverflowStrategy, ActorFlowMaterializer}
import akka.stream.actor.ActorSubscriberMessage.{OnComplete, OnNext}
import akka.stream.actor.{ActorSubscriber, OneByOneRequestStrategy, RequestStrategy}
import akka.stream.scaladsl._
import org.akkamon.core.exporters.StatsdExporter
import org.akkamon.core.instruments.{CounterTrait, LoggingTrait, TimingTrait}
@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,
@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 / 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 / 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:d24a732e923f54da3552
Created February 4, 2016 16:48 — forked from gakuzzzz/gist:8d497609012863b3ea50
Scalaz勉強会 主要な型クラスの紹介
@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