Skip to content

Instantly share code, notes, and snippets.

@brschwar
brschwar / respsizes.js
Created October 16, 2015 16:08 — forked from tevko/respsizes.js
Dev Tools Snippet to auto-calculate responsive image sizes value on window resize
/**
*
* Paste image class / identifier in IIFE parenthesis at end of function
*
* */
(function(i){"use strict";var img=document.querySelector(i),sizes=[];window.addEventListener("resize",()=>{var vw=Math.round(((img.offsetWidth*100)/window.innerWidth))+"vw",mq="(min-width: "+window.innerWidth+"px)",value=vw;vw!=="0vw"&&sizes.indexOf(vw)===-1&&(sizes.push(value),console.log(mq,vw))})})("PASTE CLASS OR IDENTIFIER HERE");
@brschwar
brschwar / outline CSS layout
Created October 13, 2015 20:52
Visualize the outline of your CSS layout in the browser. From http://www.sitepoint.com/command-line-api-fun-profit/
[].forEach.call($$("*"),function(a){a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16)})
@brschwar
brschwar / Git remove ignored files
Created October 13, 2015 20:46
Remove files which are ignored in .gitignore
git rm -r --cached .
git add .
git commit -m "Removed all ignored folders and files"
git push origin master
@brschwar
brschwar / icons.sass
Last active August 29, 2015 14:15 — forked from nickawalsh/icons.sass
@import compass
$icons: sprite-map("icons/*.png")
$icons-hd: sprite-map("icons-hd/*.png")
i
background: $icons
display: inline-block
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi)
background: $icons-hd
enscript -1R --line-numbers -p - --word-wrap --highlight=java --color=0 FILE.txt | pstopdf -i -o ~/Desktop/out.pdf && open ~/Desktop/out.pdf
@brschwar
brschwar / module-pattern.js
Last active December 24, 2015 01:29
Revealing Module Pattern
// module declaration
var Module = (function () {
var _privateFunction = function () {
// private logic
};
var publicFunction = function () {
// public logic
};
@brschwar
brschwar / revealing-module.js
Created July 16, 2013 14:23
Addy Osmani's Revealing Module Pattern Example
// Addy Osmani's Revealing Module Pattern Example
var myRevealingModule = function () {
var privateVar = "Ben Cherry",
publicVar = "Hey there!";
function privateFunction() {
console.log( "Name:" + privateVar );
}