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 / backend.css
Last active August 22, 2016 02:55
Better OctoberCMS font-size for Traditional Chinese
/* October */
html:lang(zh-tw), body:lang(zh-tw){ font-size:14.5px }
:lang(zh-tw) h5,.h5{ font-size:1rem }
:lang(zh-tw) .btn{ font-size:1rem; font-weight: normal; }
:lang(zh-tw) .btn[class^="oc-icon-"]:before,.btn[class*=" oc-icon-"]:before{ font-size:1rem }
:lang(zh-tw) .btn-text{ font-size:1rem }
:lang(zh-tw) .dropdown-menu{ font-size:1rem }
:lang(zh-tw) .dropdown-menu .dropdown-container > ul li a[class^="oc-icon-"]:before,.dropdown-menu .dropdown-container > ul li a[class*=" oc-icon-"]:before{ font-size:1rem }
:lang(zh-tw) .touch .dropdown-menu .dropdown-container > ul li a:hover:before{ font-size:1rem }
:lang(zh-tw) div.control-popover .popover-head h3{ font-size:1rem }
@lackneets
lackneets / youtube-responsive.js
Last active August 9, 2016 02:29
Make youtube iframe responsive
$(function(){
$('iframe[src*="youtube"][width][height]').each(function(){
var w = $(this).attr('width');
var h = $(this).attr('height');
$(this).wrap($('<div class="youtube-wrapper">').css({
'max-width' : '100%',
'height': 0,
'padding-bottom': (h/w*100) + '%',
'position': 'relative'
})).css({
@lackneets
lackneets / font-falimies.js
Last active July 2, 2016 09:48
Get all font-family on page
(function(){
var fonts = [];
Array.from(document.styleSheets).forEach(function(styleSheet){
Array.from(styleSheet.cssRules || []).forEach(function(rule){
String(rule.style && rule.style.fontFamily).split(/\s*,\s*/).forEach(function(font){
font = font.replace(/^["'](.*)["']$/, '$1');
if(font && fonts.indexOf(font) == -1 && !font.match(/undefined|inherit|initial/i)){
fonts.push(font);
}
})
@lackneets
lackneets / .htaccess
Last active June 12, 2016 11:27
[Recommand] Global managament PNG auto minify on demand using Apache & PHP & pngquant
# OctoberCMS storage/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$
RewriteRule ^(.*)$ - [E=BASE:%1]
# .../xxx.png => minified/.../xxx.png if exists
RewriteCond %{DOCUMENT_ROOT}%{ENV:BASE}minified/$1 -f
@lackneets
lackneets / .htaccess
Last active March 14, 2021 19:30
PNG auto minify on demand using Apache & PHP & pngquant
# OctoberCMS storage/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$
RewriteRule ^(.*)$ - [E=BASE:%1]
# foo/xxx.png => foo/xxx-min.png if exists
RewriteCond %{DOCUMENT_ROOT}%{ENV:BASE}$1min/$2-min.$3 -f
@lackneets
lackneets / phpquant.php
Created June 5, 2016 08:14
Example of PHP streaming pngquant
<?php
$new_path = '/path/to/input.png';
$cmd = 'pngquant -';
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to
);
$process = proc_open($cmd, $descriptorspec, $pipes);
@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'));
@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 / .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 / 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(){