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 / poller.go
Last active October 3, 2019 10:15 — forked from nhocki/poller.go
Simple task scheduling with Redis & Go. Similar to Sidekiq's `perform_in` and `perform_at`.
// poller.go
package main
import (
"fmt"
"os"
"os/signal"
"time"
@tranphuoctien
tranphuoctien / index.html
Created March 8, 2018 07:04 — forked from anonymous/index.html
xhr.responseType='document' Test // source http://jsbin.com/bovetayuwu
<!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
@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
@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;
}
@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 / 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 / FileController.js
Created March 28, 2016 06:55 — forked from tkh44/FileController.js
Simple file upload for sails.js
module.exports = {
get: function (req, res) {
res.sendfile(req.path.substr(1));
},
_config: {
rest: false,
shortcuts: false
}
};
@tranphuoctien
tranphuoctien / wget.js
Created March 21, 2016 11:55 — forked from JacobHsu/wget.js
Downloading using wget #nodejs
//note: http://www.html-js.com/article/1961
// Function to download file using wget
var download_file_wget = function(file_url) {
// extract the file name
var file_name = url.parse(file_url).pathname.split('/').pop();
// compose the wget command
var wget = 'wget -P ' + DOWNLOAD_DIR + ' ' + file_url;
// excute wget using child_process' exec function
// Pattern
//Usually, you call a callback as the last thing you do inside a function.
//You might consider it synonymous with return, only JavaScript does
//not halt function execution when it hits it. It can be easy to accidentally
//let execution continue after calling a callback, when you really expected it to end.
//In order to make this easy to spot, and make sure execution stops in the way you expect,
//I recommend returning the callback function call.
// wrong!