Skip to content

Instantly share code, notes, and snippets.

View lackneets's full-sized avatar
🤗
Sorry I am super busy. I may respond in weeks or months

Lackneets Chang (小耀博士) lackneets

🤗
Sorry I am super busy. I may respond in weeks or months
  • TAROBO Investment Advisors Ltd.
  • Taipei, Taiwan
View GitHub Profile
@lackneets
lackneets / by-receiver-bookmarklet.js
Last active August 29, 2015 14:24
Download Gmail in Group save by Receiver
javascript: function gmailRawURL(t){return"//mail.google.com/mail/"+String(location).match(/(u\/\d*\/)/)+"?ik="+GLOBALS[9]+"&view=om&th="+t}function downloadURL(t,a){var o=document.createElement("a");o.setAttribute("href",a),o.setAttribute("download",t),o.click(),console.log("Download",a,"as",t)}function download(t,a){var o=document.createElement("a");o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),o.setAttribute("download",t),o.click()}Array.prototype.forEach.call($$(".kQ"),function(t){t.click()}),Array.prototype.forEach.call($$(".kv .adf"),function(t){t.click()}),Array.prototype.forEach.call($$(".h7 .hb .g2.ac2"),function(t){console.log(t.getAttribute("email"))});var mails=$$(".adP.adO"),recieverEmails=Array.prototype.map.call($$(".h7 .hb .g2.ac2"),function(t){return t.getAttribute("email")}),mailUrls=[];for(var i in mails)id=String(mails[i].className).match(/m([\d\w]+)/),id&&mailUrls.push(gmailRawURL(id[1]));mailUrls.forEach(function(t,a){downloadURL(recieverEmails[a]+".eml",t
@lackneets
lackneets / .htaccess
Created October 16, 2015 23:08
Hide html extension .htaccess
RewriteEngine On
# To externally redirect /dir/foo.html to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.html
RewriteCond %{REQUEST_FILENAME}.html -f [NC]
RewriteRule ^ %{REQUEST_URI}.html [L]
@lackneets
lackneets / backup.php
Last active December 17, 2015 14:52 — forked from menzerath/backup.php
PHP: Recursively Backup Files & Folders to ZIP-File
<?php
/*
* PHP: Recursively Backup Files & Folders to ZIP-File
* (c) 2012-2014: Marvin Menzerath - http://menzerath.eu
*/
// Make sure the script can handle large folders/files
ini_set('max_execution_time', 600);
ini_set('memory_limit','1024M');
@lackneets
lackneets / bindMethods.js
Last active December 22, 2015 11:44
Bind all instance methods
function MyController(){
// Bind all
for (var method in this.constructor.prototype) {
this[method] = this[method].bind(this);
}
/* Equals to
this.render = this.render.bind(this);
this.filter = this.filter.bind(this);
...
*/
@lackneets
lackneets / GiftShuffer.php
Created January 11, 2016 03:42
公平的資料庫獎項抽獎
<?php
/*
0 4 4 4 7 10000 15300 17200
| 金槌 | 手機 | 吹風機 | Coach 隨手包 | ... | ... | 環保筷 | 商品抵用券 |
↑ ( 隨機數字 12345 )
*/
class GiftShuffler {
@lackneets
lackneets / .htaccess
Created January 15, 2016 03:25
Redirect to minified version images
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# %{ENV:BASE} is current url path
# See http://stackoverflow.com/questions/21062290/set-rewritebase-to-the-current-folder-path-dynamically
RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$
RewriteRule ^(.*)$ - [E=BASE:%1]
@lackneets
lackneets / common.less
Last active June 23, 2016 04:17
Guideline for HTML5
/* Common Behaviors */
.noselect {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@lackneets
lackneets / jquery.externals.js
Last active February 19, 2016 18:48
Auto make external links open in new tab
$(document).on('mouseenter touchstart', 'a[href]:not([target])', function(){
if(this.getAttribute('href').match(/^(https?:)?\/\//)){
this.setAttribute('target', '_blank');
}
});
@lackneets
lackneets / inheritance.js
Created January 26, 2016 09:42
ECMA5 Class inheritance inspired by Babel
"use strict";
function classDefine(subClass, prototype, staticMembers){
return classInherit(Object, subClass, prototype, staticMembers);
}
function classInherit(superClass, subClass, prototype, staticMembers){
subClass.prototype = Object.create(superClass.prototype, {
super: {value: superClass, enumerable: false, writable: false, configurable: true },
constructor: {value: subClass, enumerable: false, writable: false, configurable: true },
}); // Extend the prototype from super class
(define gcd
(lambda (a b)
(cond
((> b a) (gcd a (- b a)))
(else b)
)
)
)
(gcd 5120 65536)