Skip to content

Instantly share code, notes, and snippets.

View lelinhtinh's full-sized avatar
🤤
Slimming failure

Thành Thân Thiện lelinhtinh

🤤
Slimming failure
  • Da nang, Vietnam
  • 04:41 (UTC +07:00)
View GitHub Profile
@lelinhtinh
lelinhtinh / webWorkerInUserscript.user.js
Last active June 7, 2016 07:49
Web worker trong Userscript
// ==UserScript==
// @name Web Worker in Userscript
// @namespace http://baivong.github.io
// @version 1.0.2
// @description Use Web Worker in Userscript
// @author Zzbaivong
// @match https://github.com/baivong
// @resource worker https://gist.githubusercontent.com/baivong/4830c63ad2351d76d019e7e451121eb2/raw/77eda54e0a0c1136d6ac93ad8ccafb275b410866/worker.js
// @grant GM_getResourceText
// ==/UserScript==
self.addEventListener('message', function(e) {
self.postMessage(e.data + ' World!');
}, false);
@lelinhtinh
lelinhtinh / Stop auto load imges when parseHTML in jQuery
Created June 6, 2016 13:48
Chặn tải ảnh khi dùng parseHTML trong jQuery
// http://stackoverflow.com/a/15217348
$.get(URL).done(function (responseText) {
responseText = responseText.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match, capture) {
return '<img data-src="' + capture + '" />';
});
console.log($(responseText).find('img'));
});
@lelinhtinh
lelinhtinh / google-img-resize.mdown
Created June 4, 2016 08:49
Google’s authentication-less on-the-fly image resizing service

Google's authentication-less on-the-fly image resizing service

I found it while poking around the Google+ HTML. Jotting down some notes felt like a good idea, so here goes. If you know more about this API, let me know, please!

(Word of warning: I spent ~30 minutes on both my experimentation and this here write-up, so it might not be the most thought-provoking, brilliant thing you read today.)

@lelinhtinh
lelinhtinh / factory-shared.js
Created April 25, 2016 00:07 — forked from zachshallbetter/factory-shared.js
Examples of OOP "class" with "inheritance" done using JavaScript including languages that transpile into js. Take notice to the amount of boilerplate that's needed in ES5 compared to ES6. These examples all have the same interface with pros/cons for each pattern. If they seem similar that's whole point especially the difference between prototypa…
var EventEmitter = require('events').EventEmitter;
var _ = require('lodash');
// Factory shared
var makePerson = function() {
var person = {};
EventEmitter.call(person);
person.wallet = 0;
_.extend(person, personMethods)
return person;
@lelinhtinh
lelinhtinh / version_compare.js
Created April 24, 2016 23:44 — forked from TheDistantSea/version_compare.js
Function to compare two version strings (e.g. "1.6.1" is smaller than "1.7"). Developed in order to answer http://stackoverflow.com/a/6832721/50079.
/**
* Compares two software version numbers (e.g. "1.7.1" or "1.2b").
*
* This function was born in http://stackoverflow.com/a/6832721.
*
* @param {string} v1 The first version to be compared.
* @param {string} v2 The second version to be compared.
* @param {object} [options] Optional flags that affect comparison behavior:
* <ul>
* <li>
@lelinhtinh
lelinhtinh / Triangle.less
Last active January 17, 2016 08:53
Less mixin to create a triangle
.triangle-base(){
&:after,
&:before {
z-index: 20;
position: absolute;
width: 0;
height: 0;
border-style: solid;
content: " ";
}
@lelinhtinh
lelinhtinh / colorrun hack
Created June 28, 2015 06:45
colorrun hack
// http://colorrun.pl/
// This is fun! ^^
// by Zzbaivong
var $c1 = document.getElementById("color-1"),
$c2 = document.getElementById("color-2"),
c1,
c2,
colorrun = function() {
c1 = parseInt($c1.style.backgroundColor.match(/\d+/)[0], 10);
@lelinhtinh
lelinhtinh / zzFmBackup.js
Created May 25, 2015 15:52
ForumotionBackupTemplates
/**
* zzFmBackup
* ForumotionBackupTemplates
* v2.0.1
* Zzbaivong <http://devs.forumvi.com> *
*/
var goodIcon = "http://i.imgur.com/YNQGXWY.png",
badIcon = "http://i.imgur.com/cf2Pe8g.png",
disableIcon = "http://i.imgur.com/06GXmA1.png",
@lelinhtinh
lelinhtinh / FileSaver.min.js
Created May 25, 2015 15:50
An HTML5 saveAs() FileSaver implementation
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
var saveAs=saveAs||function(e){"use strict";if("undefined"==typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var t=e.document,n=function(){return e.URL||e.webkitURL||e},o=t.createElementNS("http://www.w3.org/1999/xhtml","a"),r="download"in o,i=function(n){var o=t.createEvent("MouseEvents");o.initMouseEvent("click",!0,!1,e,0,0,0,0,0,!1,!1,!1,!1,0,null),n.dispatchEvent(o)},a=e.webkitRequestFileSystem,c=e.requestFileSystem||a||e.mozRequestFileSystem,u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},f="application/octet-stream",s=0,d=500,l=function(t){var o=function(){"string"==typeof t?n().revokeObjectURL(t):t.remove()};e.chrome?o():setTimeout(o,d)},v=function(e,t,n){t=[].concat(t);for(var o=t.length;o--;){var r=e["on"+t[o]];if("function"==typeof r)try{r.call(e,n||e)}catch(i){u(i)}}},p=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blo