Skip to content

Instantly share code, notes, and snippets.

View hnq90's full-sized avatar
🎯
Focusing

Huy Nguyen Quang hnq90

🎯
Focusing
View GitHub Profile
@hnq90
hnq90 / flickr_allsize.js
Created May 22, 2015 02:40
Flickr All Images Size
// ==UserScript==
// @name Flickr All Images Size
// @namespace https://greasyfork.org/scripts/6850-flickr-all-images-size
// @include /flickr\.com\/(photos|groups|search)\//
// @version 4.3.7
// @grant GM_getValue
// @grant GM_setValue
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// @description Show direct links to all Flickr image sizes.
// ==/UserScript==
$.fn.protectImage = (settings) ->
settings = jQuery.extend(
zIndex: 10
offset: 0
, settings)
@each ->
thisImg = $(this)
position = thisImg.offset()
height = thisImg.height()
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@hnq90
hnq90 / checkEmoji.php
Last active August 29, 2015 14:16
Check emoji is existed in string
/**
* Check emoji from string
*
* @return bool if existed emoji in string
*/
public static function checkEmoji($str)
{
$regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
preg_match($regexEmoticons, $str, $matches_emo);
if (!empty($matches_emo[0])) {
@hnq90
hnq90 / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@hnq90
hnq90 / second2time
Created January 13, 2015 09:46
Seconds to Time Format
public function secondsToTime($value)
{
$hours = 0;
$minutes = 0;
if (filter_var($value)) {
$hours = str_pad(floor($value / (60 * 60)), 2, '0', STR_PAD_LEFT);
$minutes = str_pad(floor(($value - $hours * 60 * 60) / 60), 2, '0', STR_PAD_LEFT);
}
$timeString = Yii::t('app', '{hours} hours {minutes} minutes', ['hours' => $hours, 'minutes' => $minutes]);
@hnq90
hnq90 / CentOS-HostOnlyAdapter
Last active August 29, 2015 14:12
CentOS-HostOnlyAdapter
DEVICE=eth1
HWADDR=08:00:27:20:6F:25
TYPE=Ethernet
UUID=e992fe95-72ff-4efe-8aac-5b00f09a5fb4
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=192.168.56.103
NETMASK=255.255.255.0
@hnq90
hnq90 / detect_speed.sh
Created December 18, 2014 04:00
Detect HDD Speed
#!/bin/sh
for i in 1 2 3; do sudo hdparm -tT /dev/sda; done
#/dev/sda:
# Timing cached reads: 9676 MB in 2.00 seconds = 4839.70 MB/sec
# Timing buffered disk reads: 326 MB in 3.01 seconds = 108.28 MB/sec
#
#/dev/sda:
# Timing cached reads: 9910 MB in 2.00 seconds = 4957.12 MB/sec
# Timing buffered disk reads: 292 MB in 3.01 seconds = 97.15 MB/sec
@hnq90
hnq90 / CheckEmoji.php
Created November 26, 2014 10:18
Check Emoji exist in string
/**
* Check emoji from string
*
* @return bool if existed emoji in string
*/
function checkEmoji($str)
{
$regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
preg_match($regexEmoticons, $str, $matches_emo);
if (!empty($matches_emo[0])) {
@hnq90
hnq90 / zsh_alias.sh
Last active May 18, 2025 05:17
ZSH Alias
# Aliases in this file are bash and zsh compatible
alias -g ...='../..'
alias -g ....='../../..'
alias -g .....='../../../..'
alias -g C='| wc -l'
alias -g H='| head'
alias -g L="| less"
alias -g N="| /dev/null"
alias -g S='| sort'
alias -g G='| grep' # now you can do: ls foo G something