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 / cleanup.bat
Created February 9, 2016 04:31
Cleanup garbage files generated from Mac and Win
@echo off
set /p dirs="Where to cleanup? : "
echo %dirs%
del /s /f /a %dirs%\*.DS_STORE
del /s /f /a %dirs%\*._.*
del /s /f /a %dirs%\*Thumbs.db
@lackneets
lackneets / bookmarklet.txt
Created February 9, 2016 09:43
Chinese Friendly (No more 14px chinese font)
javascript: (function(){
"use strict";
var regexCJ = /[\u4e00-\u9fa5]+|[\u0800-\u4e00]+/;
function getTextContainerNodes(){
var nodes = Array.from(document.body.getElementsByTagName("*"));
var leafNodes = nodes.filter(function(elem) {
return elem.hasChildNodes() && Array.from(elem.childNodes).filter(function(node){
return node.nodeType === 3;
}).length > 0
@lackneets
lackneets / cleanup.php
Created February 16, 2016 14:27
Wordpress Backdoor Cleanup
<?php
/*
Wordpress Backdoor Cleanup
Put this under upload folder
*/
ini_set('display_errors', true);
function clenup($path) {
$dir = new DirectoryIterator($path);
@lackneets
lackneets / inner.html
Last active February 18, 2016 03:58
iframe cross-domain auto height
<!-- Send Height to Parent -->
<script type="text/javascript">
function sendHeight(){
if(parent.postMessage){
parent.postMessage({
height: document.body.offsetHeight,
location: window.location.toString()
}, '*');
}
}
@lackneets
lackneets / common.sh
Last active August 30, 2016 04:14
Remember some useful command
# Install imagemagick
sudo apt-get install imagemagick
# Resize jpeg images under subdirectories
find . -name "*.jpg" -exec mogrify -resize 1600x1600\> -quality 75% -verbose -format jpg {} +
# Resize jpeg images only if > 1MB
# http://superuser.com/questions/204564/how-can-i-find-files-that-are-bigger-smaller-than-x-bytes
find . -name "*.jpg" -size +1M -exec mogrify -resize 1600x1600\> -quality 75% -verbose -format jpg {} +
@lackneets
lackneets / _list_toolbar.htm
Last active April 13, 2016 04:42
Pagination of October CMS Backend List
<div data-control="toolbar">
<div class="form-group span-left">
<select class="form-control custom-select pagination-select" style="width:200px">
<option selected="selected" value="1">第 1 頁</option>
</select>
</div>
</div>
<script>
$(function(){
@lackneets
lackneets / currency.html
Created April 26, 2016 07:58
Frontend currency format solution
<!DOCTYPE html>
<html>
<head>
<title>Example of Currency</title>
<!-- Javascripts here -->
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
<script>
$(function(){
@lackneets
lackneets / .htaccess
Last active May 18, 2016 04:43
lessc php adapter
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$
RewriteRule ^(.*)$ - [E=BASE:%1]
RewriteRule ^(.*\.less)$ %{ENV:BASE}/$1.css [QSA,L]
RewriteRule ^(.*\.less)\.css$ %{ENV:BASE}/lessc.php [QSA,L]
</IfModule>
@lackneets
lackneets / grids.example.less
Last active May 19, 2016 10:20
Simple Grid System
// The Basic
.grids{
letter-spacing: -.31em;
> * {
display: inline-block;
letter-spacing: 0.01em;
}
}
// Options
@lackneets
lackneets / lazysizes.ie8.js
Last active July 1, 2016 09:16
Fallback for lazysizes on IE8
window.ready=function(e){"loading"!=document.readyState?e():document.addEventListener?document.addEventListener("DOMContentLoaded",e):document.attachEvent("onreadystatechange",function(){"loading"!=document.readyState&&e()})};
/* Fallback for lazysizes on IE8 */
window.ready(function(){
if (document.documentMode == 8) {
var elms = document.querySelectorAll('.lazyload');
for(var i=0; i<elms.length; i++){
elms[i].setAttribute('class', String(elms[i].getAttribute('class')).replace(/\s*lazyload\s*/g, ' lazyloaded '));
if(elms[i].getAttribute('data-src')){
elms[i].setAttribute('src', elms[i].getAttribute('data-src'));