Skip to content

Instantly share code, notes, and snippets.

@madkap
madkap / Javascript.md
Last active September 9, 2016 19:20
GTK - Ruby / Rails / JS /

Node.js

Module

A module encapsulates related/shared code into a single unit of code. Understanding module exports

Export a Module
// exports and module.exports are the same object
var exports = module.exports = {};

// create methods for module export
module.exports = {
@madkap
madkap / border-box.scss
Created May 8, 2015 17:07
border-box reset
*, *:after, *:before {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
@madkap
madkap / gems.md
Last active August 29, 2015 14:20
Oh That's How You Do That
@madkap
madkap / blinking cursor.scss
Created October 22, 2014 22:52
blinking cursor
// from http://codepen.io/ArtemGordinsky/pen/GnLBq
// using http://bourbon.io/docs/#animation
@include keyframes(blink) {
from, to {
color: transparent;
}
50% {
color: black;
}
@madkap
madkap / vertical-align
Last active August 29, 2015 14:07
vertical-align with css
%vertical-align {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
/* or with bourbon
@include transform(translateY(-50%));
*/
@madkap
madkap / SelectAll
Last active August 29, 2015 14:06
Select All Checkbox - Check or uncheck all checkboxes based on select-all checkbox. If individual checkboxes change update select-all checkbox accordingly.
$('#select-all').on 'change', @onChangeSelectAll
$('input[name="check-me"]').on 'change', @onChangeCheckbox
onChangeSelectAll: (e) ->
$('input[name="check-me"]').prop 'checked', $(e.target).prop('checked')
onChangeCheckbox: (e) ->
selected = false
number_selected = 0
$('input[name="check-me"]').each ->
@madkap
madkap / font-size.scss
Last active August 29, 2015 14:02
Fontsize Mixin - sizing based on rem with fallback to px
html {
font-size: 62.5%; //sets fontsize to 10px
}
@mixin fontsize($size:1.6, $line: $size * 1.5){
font-size: ($size * 10) + px;
line-height: ($line * 10) + px;
font-size: $size + rem;
line-height: $line + rem;
}
@madkap
madkap / background-color
Created May 27, 2014 21:15
fun way to debug and look how elements are laid out
* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }