Skip to content

Instantly share code, notes, and snippets.

View hthuong09's full-sized avatar

Thuong (Tyson) Nguyen hthuong09

View GitHub Profile
@hthuong09
hthuong09 / share-online.biz.php
Created June 23, 2015 19:28
share-online.biz file size encryption algorithm
<?php
function encrypt($original) {
$arr = range(0, strlen($original) - 1);
shuffle($arr);
$shuffleStr = '';
$hexStr = '';
foreach ($arr as $char) {
$shuffleStr .= $original[$char];
$hexStr .= str_pad(dechex($char), 3, "0", STR_PAD_LEFT);
}
@hthuong09
hthuong09 / youtubetv.css
Created October 13, 2015 04:28
Youtube TV on Chrome Fullscreen
@-moz-document url-prefix("https://www.youtube.com/tv") {
.html5-video-player .video-stream {
width: 100%;
height: 100%;
}
}
@hthuong09
hthuong09 / inject jquery.js
Created October 15, 2015 06:57
inject jquery to any webpage
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
@hthuong09
hthuong09 / model.php
Created December 10, 2015 03:11
Global scope eloquent
<?php
class Comment extends Eloquent {
public function newQuery()
{
return parent::newQuery()->where('cat', '=', 6);
}
// Now when you will perform a query like :
@hthuong09
hthuong09 / recursiveDLMF.py
Created February 2, 2016 03:57
Recursively get download link mediafire folder
from mediafire import MediaFireApi
import humanfriendly
import sys
import wget
api = MediaFireApi()
#folder_key = sys.argv[1]
folder_key = 'oct0x6rwhtkks';
@hthuong09
hthuong09 / gist:7e10957df5bdd5ef2e354aa5334c4e42
Created April 28, 2016 06:00 — forked from gleuch/gist:2475825
Javascript documentfragment to string (w/ text selection)
// selection range
var range = window.getSelection().getRangeAt(0);
// plain text of selected range (if you want it w/o html)
var text = window.getSelection();
// document fragment with html for selection
var fragment = range.cloneContents();
// make new element, insert document fragment, then get innerHTML!
/*
* robotMaze.js
*
* The blue key is inside a labyrinth, and extracting
* it will not be easy.
*
* It's a good thing that you're a AI expert, or
* we would have to leave empty-handed.
*/
@hthuong09
hthuong09 / archinstall.sh
Created August 18, 2016 03:10
Arch Install with EFI and Grub2
# These command was inspired from helmuthdu/aui
# BASIC INSTALLATION
# Select Keymap
loadkeys us
# Select Editor
pacman -S vim nano
# Configure Mirrorlist
@hthuong09
hthuong09 / gist:f9f124aef3cffa1b9aa723abfa1be4a6
Created September 26, 2016 01:57 — forked from maskit/gist:2252422
WebSocket traffic sniffer
(function () {
WebSocket.prototype._send = WebSocket.prototype.send;
WebSocket.prototype.send = function (data) {
this._send(data);
this.addEventListener('message', function (msg) {
console.log('>> ' + msg.data);
}, false);
this.send = function (data) {
this._send(data);
console.log("<< " + data);
@hthuong09
hthuong09 / using_bind_method.js
Created September 28, 2016 06:11
Pass argument to setTimeout inside loop
/*
Syntax
fun.bind(thisArg[, arg1[, arg2[, ...]]])
Parameters
thisArg
The value to be passed as the this parameter to the target function when the bound function is called. The value is ignored if the bound function is constructed using the new operator.
Passed undefined = use original this
arg1, arg2, ...
Arguments to prepend to arguments provided to the bound function when invoking the target function.
Return value