Skip to content

Instantly share code, notes, and snippets.

View hfknight's full-sized avatar

fei.io hfknight

View GitHub Profile
@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 / footer-stick-at-the-bottom.css
Created April 5, 2016 17:59
CSS: footer always at the bottom
@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 {
// 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
run curl -L https://www.npmjs.com/install.sh | sh
@hfknight
hfknight / gist:3968493158935eb60894
Created July 20, 2015 15:08
SVG edge cut off in Firefox
add attribute overflow="visible" to <svg>
/* aslo add to sprint file if using that */
@hfknight
hfknight / gist:1ae7e6ea671012fef9cc
Created June 2, 2015 19:41
EnableTouch(Active) State Support on iOS Safari
window.onload = function() {
if(/iP(hone|ad)/.test(window.navigator.userAgent)) {
document.body.addEventListener('touchstart', function() {}, false);
}
};
/* or add ontouchstart="" in element attributes */
@hfknight
hfknight / gist:ec9b37ac6093c40b25a3
Created March 23, 2015 14:49
Flex Box CSS for All Browers
.flex-container {
height: 100%;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-direction: normal;
-moz-box-direction: normal;
/* using svg as a background-image */
.my-element {
background-image: url(image.svg);
}
.no-svg .my-element {
background-image: url(image.png);
}
.my-element {
background-image: url(fallback.png);
@hfknight
hfknight / css-layout-debugger
Last active August 29, 2015 14:14
visualizing your CSS layouts
[].forEach.call($$("*"),function(a){
a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16)
})
// from https://gist.github.com/addyosmani/fd3999ea7fce242756b1