Skip to content

Instantly share code, notes, and snippets.

View dungvn3000's full-sized avatar

Nguyen Duc Dung dungvn3000

View GitHub Profile
@whit3hawks
whit3hawks / Java Array of all Country Names
Last active October 17, 2023 10:55
Java Array of all Country Names.
String[] countries = new String[]{"Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falklan
@naoto-ogawa
naoto-ogawa / sample_monadLogger.hs
Created January 15, 2017 07:27
Monad Logger Sample
-- {-# LANGUAGE OverloadedStrings #-}
import Data.Text
import Control.Monad.Trans
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.State
import Control.Monad.Trans.Identity
import Control.Monad.Identity
import Control.Monad.Logger
import scala.concurrent.duration._
def scheduleTaskAtFixedRate[A](initialDelay: FiniteDuration, period: FiniteDuration, task: Task[A]): Task[Unit] =
Task.create { (s, callback) =>
def loop(delay: Long): Task[Unit] =
Task.defer {
val startedAt = s.currentTimeMillis()
val t = task.flatMap { _ =>
val duration = s.currentTimeMillis() - startedAt
val nextDelay = {
@nrollr
nrollr / MySQL_macOS_Sierra.md
Last active January 31, 2024 14:45
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :

@kellymclaughlin
kellymclaughlin / haskell-smartos.md
Last active January 26, 2019 17:33
GHC build steps for Haskell on SmartOS

I borrowed these steps from the buildbot setup for SmartOS I found at http://haskell.inf.elte.hu/builders/. Generally the standard build steps for ghc seems to work pretty well at this point aside from a few more test failures than I observed when building on Linux.

  1. Clone ghc repo and check out desired branch or tag.
  2. Edit mk/build.mk to be the following:
import "regexp"
// Basic regular expressions for validating strings
const (
Email string = "^(((([a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+(\\.([a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(([a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])([a-zA-Z]|\\d|-|\\.|_|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*([a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.)+(([a-zA-Z]|[\\
@nkt
nkt / Results.md
Last active September 27, 2023 08:24
ReactPHP vs Node.js

wrk -t4 -c400 -d10s http://127.0.0.1:1337/

PHP

Running 10s test @ http://127.0.0.1:1337/
  4 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
 Latency 7.02ms 6.94ms 82.86ms 85.27%
@gzoller
gzoller / FlexiFlowExample.scala
Last active November 5, 2018 13:40
Akka Stream FlexiFlow switch example
object PrimaryFlow extends App {
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
val sj = ScalaJack()
val graph = FlowGraph.closed() { implicit builder: FlowGraph.Builder[Unit] =>
import FlowGraph.Implicits._
val in = Source(List.empty[String]) // hook this up to RabbitMQ
val out = Sink.foreach( (mc:Command) => println("Command:" +mc) )
@magnetikonline
magnetikonline / README.md
Last active June 27, 2023 17:26
Nginx keepalive connections config example to upstream servers.

Nginx upstream HTTP keepalive config example

As per Nginx documentation, the key directives of proxy_http_version and proxy_set_header need to be set as per below:

upstream backend {
	server 127.0.0.1:8080;
	keepalive 8;
}

server {
@jrudolph
jrudolph / TestMultipartFileUpload.scala
Last active February 13, 2023 18:09
akka-http Multipart file-upload client + server example
package akka.http.scaladsl
import java.io.File
import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.util.ByteString
import scala.concurrent.duration._
import akka.actor.ActorSystem