Skip to content

Instantly share code, notes, and snippets.

View hfknight's full-sized avatar

fei.io hfknight

View GitHub Profile
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@hfknight
hfknight / safari-mobile-hover-state-go-back-retain.css
Last active February 9, 2016 19:37
Mobile Safari CSS :hover caching issue (go back button)
/* on an iOS device, when you click the link having :hover css and navigate away to the next page and then hit the browsers’ back button, when you come back on this screen, you will see the above link is still in hover state */
// use Modernizr, the no-touch class will be added to the root html element for non-touch devices. Then you can do this
a.myclass {
color:#999;
}
.no-touch a.myclass:hover,
a.myclass:active {
@hfknight
hfknight / footer-stick-at-the-bottom.css
Created April 5, 2016 17:59
CSS: footer always at the bottom
@hfknight
hfknight / function*.js
Last active January 4, 2017 02:03
function* Generator
/*
The function* declaration (function keyword followed by an asterisk) defines a generator function, which returns a Generator object.
You can also define generator functions using the GeneratorFunction constructor and a function* expression.
*/
// Syntax
function* name([param[, param[, ... param]]]) {
statements
}
@hfknight
hfknight / css-sliding-underline-animation.css
Last active June 20, 2017 18:16
CSS Sliding Underline
/* TOP TO BOTTOM */
.sliding-u-t-b {
text-decoration: none;
display: inline-block;
border-bottom: 0px solid transparent;
width: 210px;
transition: 0.5s ease;
height: 25px;
}
function MouseWheelHandler(e) {
var e = window.event || e; // old IE support
var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
if (delta < 0) // scroll down
// scroll downaction here
else // scroll up
// scroll up action here
}
if (window.addEventListener) {
@hfknight
hfknight / image-lazyload.js
Created October 12, 2017 15:13
JS Proxy Pattern: Image Lazy Load
// Provide a surrogate or placeholder for another object to control access to it.
// 常用的虚拟代理形式:某一个花销很大的操作,可以通过虚拟代理的方式延迟到这种需要它的时候才去创建
//(例:使用虚拟代理实现图片懒加载)
// 图片懒加载的方式:先通过一张loading图占位,然后通过异步的方式加载图片,等图片加载好了再把完成的图片加载到img标签里面。
var imgFunc = (function() {
var imgNode = document.createElement('img');
document.body.appendChild(imgNode);
return {
setSrc: function(src) {
@hfknight
hfknight / gist:e1ef62e431e5282bb5170dbbf51ec44b
Created January 8, 2018 18:56
[Synology] Transmission Failed to run package service Solution
Edit script var/packages/transmission/scripts/start-stop-status
in start_daemon () block
changed from :
su - ${USER} "PATH=${PATH} ${TRANSMISSION} -g ${INSTALL_DIR}/var/ -x ${PID_FILE}"
to
sudo -u ${USER} /bin/sh -c "PATH=${PATH} ${TRANSMISSION} -g ${INSTALL_DIR}/var/ -x ${PID_FILE}"
@hfknight
hfknight / gist:2eaf5ce22774acc28e4735d3bf01c1f5
Last active February 20, 2018 20:28
Save your Life from failed Windows 10 Updates
In the search box on the taskbar, type cmd.
2.Right-click Command Prompt in the search results and select Run as administrator. (Select Yes, when prompted by the User Account Control.)
3.In the Administrator: Command Prompt window, type the following command and press Enter:
SC config wuauserv start= auto [Press Enter]
SC config bits start= auto [Press Enter]
SC config cryptsvc start= auto [Press Enter]
@hfknight
hfknight / visually-hidden.css
Last active March 14, 2018 15:12
Hiding Content Visually but accessible for screen reader
.element-invisible {
position: absolute !important;
height: 1px; width: 1px;
margin: -1px; padding: 0; border: 0;
overflow: hidden;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
}