Skip to content

Instantly share code, notes, and snippets.

View tranphuoctien's full-sized avatar
🎯
Focusing

Tien Tran tranphuoctien

🎯
Focusing
View GitHub Profile
@tranphuoctien
tranphuoctien / focusElement.js
Created March 28, 2016 06:58 — forked from tkh44/focusElement.js
Focus an element. Use the focus-delay="" to delay the focus x amount of ms
ticketApp.directive('focusElement', function($timeout) {
return {
restrict: 'A',
scope: {
focusElement: '@',
focusDelay: '@'
},
link: function($scope, $element, $attrs) {
$scope.$focusElement = angular.isDefined($scope.focusElement) ? $($scope.focusElement): $element;
@tranphuoctien
tranphuoctien / install.sh
Created October 7, 2017 08:09 — forked from ziadoz/install.sh
Install Chrome, ChromeDriver and Selenium on Ubuntu 16.04
#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c
# http://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver
# http://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception
# http://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal
# http://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04
# Versions
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
@tranphuoctien
tranphuoctien / BitbucketDeployAngular4.text
Last active October 18, 2017 11:52
BitbucketDeployAngular4
Deploy your Angular 2 project with Bitbucket Pipelines to Firebase Hosting
## Firebase
Please see the Firebase setup instruction to setup a project on Firebase.
## Firebase CI Token
To run the `firebase deploy` command you need to obtain a login token from Firebase. To do so, run the `firebase login:ci` on your command line which will generate a token. Copy the generated token.
## Environment Variables
Goto your project in Bitbucket, open the Settings and select Environment variables.
@tranphuoctien
tranphuoctien / BlockUIForAngular4.ts
Last active October 18, 2017 15:19
Add Block UI for Angular4
import { Component } from '@angular/core';
import {
Router,
// import as RouterEvent to avoid confusion with the DOM Event
Event as RouterEvent,
NavigationStart,
NavigationEnd,
NavigationCancel,
NavigationError
@tranphuoctien
tranphuoctien / random.js
Created February 9, 2018 12:46 — forked from kerimdzhanov/random.js
JavaScript: get a random number from a specific range
/**
* Get a random floating point number between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {number} a random floating point number
*/
function getRandomFloat(min, max) {
return Math.random() * (max - min) + min;
}
# post_data contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_data -T application/json -H 'Authorization: JWT or some thing' -c 100 -n 2000 http://localhost/api/v1/heath
package main
import "fmt"
func main() {
x := make(map[string][]string)
x["key"] = append(x["key"], "value")
x["key"] = append(x["key"], "value1")
package validation
import (
"fmt"
"reflect"
"strings"
validatorP "gopkg.in/go-playground/validator.v9"
)
package main
import (
"fmt"
"sync"
)
const (
MAX_WORKERS = 10 // Maximum worker goroutines
HOLDING_CAPACITY = 30 // Holding capacity of the channel
@tranphuoctien
tranphuoctien / gist:64aae3d4cd7b303d4ebae9acbfc96ce8
Created March 8, 2018 07:02 — forked from ebidel/gist:3581825
Using xhr.responseType='document' with CORS
<!DOCTYPE html>
<!--
Copyright 2012 Eric Bidelman
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