Skip to content

Instantly share code, notes, and snippets.

View quanengineering's full-sized avatar
🏗️

Quan quanengineering

🏗️
View GitHub Profile
@quanengineering
quanengineering / gist:957c0dc1ec229fc54db5
Last active October 22, 2018 04:41
Friendly id Vietnamese
class VietnameseService
VIETNAMESE_CONVERT_TABLE = {
"a" => ["à","á","ạ","ả","ã","â","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],
"e" => ["è","é","ẹ","ẻ","ẽ","ê","ề","ế","ệ","ể","ễ"],
"i" => ["ì","í","ị","ỉ","ĩ"],
"o" => ["ò","ó","ọ","ỏ","õ","ô","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],
"u" => ["ù","ú","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],
"y" => ["ỳ","ý","ỵ","ỷ","ỹ"],
"d" => ["đ"],
"A" => ["À","Á","Ạ","Ả","Ã","Â","Ầ","Ấ","Ậ","Ẩ","Ẫ","Ă","Ằ","Ắ","Ặ","Ẳ","Ẵ"],
@quanengineering
quanengineering / gist:1f072bdad055732cbf21
Last active February 10, 2016 15:47
Config /etc/php5/apache2/php.ini to enable xdebug
--Add lines to php.ini
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
@quanengineering
quanengineering / gist:59ed8e1b4bef117ff886
Last active February 10, 2016 15:47
Requirement to use PHPExcel
use this script to check:
<?php
echo "GD: ", extension_loaded('gd') ? 'OK' : 'MISSING', '<br>';
echo "XML: ", extension_loaded('xml') ? 'OK' : 'MISSING', '<br>';
echo "zip: ", extension_loaded('zip') ? 'OK' : 'MISSING', '<br>';
?>
by default XML and ZIP is OK, GD have to install manually: `sudo apt-get install php5-gd`
@quanengineering
quanengineering / casper.js
Last active March 15, 2016 19:05
How to crawl with casperjs (bypass login page)
var casper = require('casper').create();
var url = 'https://www.getnewsmart.com/articles/80250-xiaomi-keeps-sights-on-india-has-no-ipo-timetable';
casper.start(url, function() {
this.echo(this.getTitle());
})
casper.waitFor(function check() {
return true;
@quanengineering
quanengineering / callback.js
Created March 12, 2016 18:55
callback example
// global variable
var allUserData = [];
function logStuff (userData) {
console.log('22222222');
if ( typeof userData === "string")
{
console.log(userData);
}
else if ( typeof userData === "object")
@quanengineering
quanengineering / promise.js
Last active March 15, 2016 04:01
How to use promise
var Q = require('q');
var request = require('request');
var cheerio = require('cheerio');
function getArticleUrlPerPage(pageNumber, articleUrls) {
var deferred = Q.defer();
var options = {
method: 'GET',
@quanengineering
quanengineering / callback.js
Created March 15, 2016 04:05
How to use callback
function getArticleUrlPerPage(pageNumber, articleUrls, callback) {
var options = {
method: 'GET',
url: 'https://www.getnewsmart.com/?last_time_title=This+week&page=' + pageNumber + '&section=&xhr=true',
};
request(options, function(error, response, body) {
if (error) throw new Error(error);
$ = cheerio.load(body);
$('.text-wrapper').each(function(i, elem) {
d=3; % Change this to change the size of the matrix
n=10; % Change this to change the range of the numbers
floor(n*rand(d,d))
@quanengineering
quanengineering / InstallOpenVPNGuide.md
Last active August 9, 2018 00:52
Setup OpenVPN on VPS
@quanengineering
quanengineering / README.md
Last active December 18, 2022 17:46
Generate outfits from twelve70.com main closet then add to favourite

Scripts to automate twelve70.com

How to run the script: You should copy and paste it into the browser console.

Generate outfits from main closet then add to favourite

You should close the site when there are no outfits generated anymore.

image