Skip to content

Instantly share code, notes, and snippets.

@tcomaj
tcomaj / modifyNodeListPrototype.js
Last active April 11, 2021 09:12
jQuery like shorthand for qs, qsa + add Array methods to NodeList prototype
NodeList.prototype.__proto__ = Array.prototype;
// Use any array methods on NodeLists
$$('.cards').map(card => card.textContent); // ['card 1', 'card 2']
@tcomaj
tcomaj / handleError.js
Last active April 11, 2021 08:30
HOF to handle error in promise
// Function to handle error
function handleError(fn) {
return function(...params) {
return fn(...params).catch(function (err) {
// do something with the error
console.error(`Oops!`, err);
});
}
}
@tcomaj
tcomaj / 0_reuse_code.js
Created July 16, 2016 15:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@tcomaj
tcomaj / body {CSS: Font Shorthand
Created May 24, 2012 14:22
CSS: Font Shorthand
body {
font: font-style font-variant font-weight font-size/line-height font-family;
}
body {
font: italic small-caps normal 13px/150% Arial, Helvetica, sans-serif;
}
@tcomaj
tcomaj / CSS: IE6, IE7 Double Margin, Padding Bug
Created May 24, 2012 14:14
CSS: IE6, IE7 Double Margin, Padding Bug
ul li {
float: left;
margin-left: 5px;
*display: inline; /*IE7 and below*/
_display: inline; /*IE6 and below*/
}
/* this example fixes double left margin bug */
@tcomaj
tcomaj / CSS: Font-face import
Created May 24, 2012 14:09
CSS: Font-face import
@font-face {
font-family: 'MyFontFamily';
src: url('myfont-webfont.eot?#iefix') format('embedded-opentype'),
url('myfont-webfont.woff') format('woff'),
url('myfont-webfont.ttf') format('truetype'),
url('myfont-webfont.svg#svgFontName') format('svg');
}
@tcomaj
tcomaj / CSS: Remove textarea scrollbar in IE
Created May 24, 2012 13:54
CSS: Remove textarea scrollbar in IE
textarea{
overflow:auto;
}
@tcomaj
tcomaj / CSS: Fixed Footer (IE6)
Created May 24, 2012 13:53
CSS: Fixed Footer (IE6)
@tcomaj
tcomaj / CSS: Transparency (Cross Browser)
Created May 24, 2012 13:49
CSS: Transparency (Cross Browser)
.transparent_class {
/* IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
/* IE 5-7 */
filter: alpha(opacity=50);
/* Netscape */
-moz-opacity: 0.5;
@tcomaj
tcomaj / CSS: Text Selection
Created May 24, 2012 13:46
CSS: Text Selection
::selection {
color: white;
background-color: #ef8629;
}
::-moz-selection {
color: white;
background: #ef8629;
}