This is a collection of my most often used lines of code, as well as a few other examples I want to have ready at a moment's notice. These snippets focus on building HTML from scratch, linking in good web fonts, and setting up responsive styles for your pages.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Donec fermentum augue sem. Sed eleifend, erat a venenatis euismod, felis arcu tempus quam, imperdiet vestibulum ipsum orci eget dui. Praesent semper commodo urna, vitae sodales tellus aliquet a. Suspendisse varius condimentum enim id ornare. Mauris porttitor interdum sem et convallis. Cras dictum, diam ut feugiat bibendum, tortor tellus aliquet massa, pulvinar posuere tortor enim vitae turpis. Sed ultrices augue turpis, et pellentesque est sagittis in. Aliquam ac quam nibh. Quisque et fringilla dolor. Nullam massa ipsum, semper convallis purus sit amet, mollis interdum leo. Vivamus ut tempor nunc.
Nunc finibus lacus eget orci pellentesque lacinia. Nullam vitae dui facilisis, venenatis velit vehicula, fringilla eros. Vestibulum interdum nulla eu nunc convallis rhoncus. Sed eget sapien magna. Nam quis finibus velit, eu dictum mauris. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nam et libero quis velit consectetur lobortis. Donec a libero vel mauris faucibus porta.
Vestibulum malesuada pulvinar dolor vitae eleifend. Nunc maximus quam et tempus tempus. Cras tempus nibh quam, vitae sodales nisi egestas laoreet. Aenean sed tincidunt ex. Pellentesque blandit pharetra arcu, non volutpat nunc dapibus ut. Suspendisse convallis at nunc sit amet euismod. Suspendisse non sem elit. Ut pharetra enim in purus porttitor facilisis mollis ut nisl. Sed varius semper sollicitudin. Nullam aliquam sodales pulvinar. Nam tellus sapien, hendrerit ac mollis eget, rhoncus a diam.
Nunc eu lorem vitae nisl laoreet imperdiet. Etiam nunc velit, auctor ut felis id, vestibulum efficitur quam. Pellentesque commodo sit amet velit ut accumsan. Ut malesuada lacinia arcu, volutpat accumsan lorem rutrum ac. Integer tincidunt dui a neque accumsan, ut hendrerit leo cursus. Nulla sed mollis tortor, vitae luctus odio. Praesent gravida sed mauris ac laoreet. Pellentesque a lorem purus. Ut tincidunt ante ac nibh maximus, et suscipit risus sagittis. Nullam rhoncus augue eu semper ultrices. Quisque nec mollis ex. Suspendisse potenti.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title></title>
<style></style>
</head>
<body>
<script></script>
</body>
</html>
<meta name=apple-mobile-web-app-capable content=no>
<meta name=apple-mobile-web-app-status-bar-style content=black>
<meta name=format-detection content="telephone=no">
<meta name=viewport content="width=device-width, initial-scale=1">
<link href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABwElEQVR42pWST0sbURTFr7hzET+CmwouxA+gUvAPbbNTFIqCtH4D0Y2ubMAUIRlK0NZKiJjEjdqCKEZBFD+BQgJOdKAjCtKmghOVmlCa0znPOCbGEXzw49x377lnFm/k4TEMeRGLxRAIBODz+Yiq2Ts6knp56ui6NIRCIaRSKWQyGViWRVirHmf0uAaEw2FlNE2TXy6DvWQyCXpcA/x+PwzDUAvZrHhKZ+xxRo9rAE26roNaKEiVy+zpgHQ6DepzZvKvINUTG6K9j77BLV6qw2DMS5z7REK0gr3jBOT+Ss27eS8O8jvYz61hL7eK/bzSO9i3WbU926D3xt5xAq7z4hmYe43dPxEkroNYvwo6qlB3jT3lGYi8AnecgKu81PbPdmLL+ooV6+MtF35bFWW9rews6OVOaYCnb6YDifMpLP0aL/LBgffFn6pve6bR96W9IqD27ec2rJxpiJ+MKhZOxqhFnFp56K0I6A29xLI5iYgxXGSkoqYuH0+C3oqAnk+t2DyN4LsZxLcfAVfooZc7Za8wvCDRLq0ZXcFmdFM1ass9JfehuMTLXoFvenYpdca5NB7+lqbDjA31Eeih9+4/+A+4dfTbehtGHQAAAABJRU5ErkJggg==" rel="shortcut icon">
<section data-module>
</section>
<style>
[data-module],
[data-module]:before,
[data-module]:after,
[data-module] *,
[data-module] *:before,
[data-module] *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-kerning: auto;
font-family: inherit;
margin: 0;
padding: 0;
}
[data-module],
[data-module] * {
line-height: 1;
font-size: 10pt;
font-family: 'Open Sans', 'Source Sans Pro', Roboto, 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', 'Myriad Pro', 'Segoe UI', Myriad, Helvetica, 'Lucida Grande', 'DejaVu Sans Condensed', 'Liberation Sans', 'Nimbus Sans L', Tahoma, Geneva, Arial, sans-serif;
}
</style>
font-family: 'Open Sans', 'Source Sans Pro', Roboto, 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', 'Myriad Pro', 'Segoe UI', Myriad, Helvetica, 'Lucida Grande', 'DejaVu Sans Condensed', 'Liberation Sans', 'Nimbus Sans L', Tahoma, Geneva, Arial, sans-serif;
font-family: 'Source Sans Pro', 'Open Sans', Roboto, 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', 'Myriad Pro', 'Segoe UI', Myriad, Helvetica, 'Lucida Grande', 'DejaVu Sans Condensed', 'Liberation Sans', 'Nimbus Sans L', Tahoma, Geneva, Arial, sans-serif;
font-family: 'PT Serif', Cambria, 'Hoefler Text', Utopia, 'Liberation Serif', 'Nimbus Roman No9 L Regular', Times, 'Times New Roman', serif;
font-family: 'Source Code Pro', Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace;
<link href="//fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900,200italic,300italic,400italic,600italic,700italic,900italic" rel=stylesheet type=text/css>
@import url('//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,900,300italic,400italic,600italic,700italic,900italic');
<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel=stylesheet type=text/css>
@import url('//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,700,300,600,800,400');
<link href="//fonts.googleapis.com/css?family=Fira+Sans:300,400,500,700,300italic,400italic,500italic,700italic" rel=stylesheet type=text/css>
<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel=stylesheet type=text/css>
@import url('//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css');
font-family: 'FontAwesome';
<link href="//code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel=stylesheet type=text/css>
@import url('//code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css');
font-family: 'Ionicons';
<link href="//fonts.googleapis.com/css?family=PT+Serif:400,700,400italic,700italic" rel=stylesheet type=text/css>
@import url('//fonts.googleapis.com/css?family=PT+Serif:400,700,400italic,700italic');
<link href="http://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic" rel=stylesheet type=text/css>
<link href="//fonts.googleapis.com/css?family=Source+Code+Pro:300,400,500,600,700,900" rel=stylesheet type=text/css>
@import url('//fonts.googleapis.com/css?family=Source+Code+Pro:300,400,500,600,700,900');
*,
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-kerning: auto;
}
*,
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-kerning: auto;
}
html {
font-size: 10pt;
line-height: 1.4;
font-weight: 400;
font-family: 'Open Sans', 'Source Sans Pro', Roboto, 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', 'Myriad Pro', 'Segoe UI', Myriad, Helvetica, 'Lucida Grande', 'DejaVu Sans Condensed', 'Liberation Sans', 'Nimbus Sans L', Tahoma, Geneva, Arial, sans-serif;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
}
q:before {content: '\201c'}
q:after {content: '\201d'}
q q:before {content: '\2018'}
q q:after {content: '\2019'}
html {
-webkit-text-size-adjust: 100%;
}
-webkit-box-sizing: border-box;
-moz-box-size: border-box;
box-sizing: border-box;
background: url('../img/bg.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
-webkit-tap-highlight-color: #f60 !important;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
cursor: default;
q:before { content: '“'}
q:after { content: '”'}
q q:before { content: '‘'}
q q:after { content: '’'}
*:after {
content: '';
display: block;
clear: both;
}
@-moz-document url-prefix() {
div {
color: red;
}
}
@media (min-width: 481px) {
}
@media (min-width: 769px) {
}
@element 'html' and (min-width: 0px) {
}
@element 'html' and (min-width: 481px) {
}
@element 'html' and (min-width: 769px) {
}
<script>document.write(new Date().getFullYear())</script>
<!--[if lt IE 9]><script src="http://elementqueries.com/EQCSS-polyfills.js"></script><![endif]-->
<script src="http://elementqueries.com/EQCSS.js"></script>
EQCSS={code:"",scripts:[],b:[],d:[],a:[],e:[],c:new XMLHttpRequest,load:function(){for(var b=document.querySelectorAll("script[type='text/eqcss']"),a=0;a<b.length;a++)""!=b[a].innerHTML&&(this.code+=b[a].innerHTML),b[a].src&&(this.c.open("GET",b[a].src,!1),this.c.send(null),this.code+=this.c.responseText),b[a].type="text/eqcss-read";this.code=this.code.replace(/\s+/g," ");this.code=this.code.replace(/^ | $/g,"");this.code=this.code.replace(/\/\*[\w\W]*?\*\//g,"");this.code=this.code.replace(/ *@element/g,"\n@element");this.code.replace(/(@element.*(?!@element))/g,function(a,b){EQCSS.b.push(b)});for(a=0;a<this.b.length;a++)this.b[a].replace(/@element ?["']([^"']*)["']/g,function(b,e){EQCSS.d[a]=e});for(a=0;a<this.b.length;a++)this.a[a]=[],this.b[a].replace(/and ?\( ?([^:]*) ?: ?([^)]*) ?\)/g,function(b,e,k){EQCSS.a[a].push({f:e,value:k})});for(a=0;a<this.b.length;a++)this.b[a].replace(/{(.*)}/g,function(b,e){EQCSS.e[a]=e})},apply:function(){var b,a,c,e,k,h,f,d,g,l;for(b=0;b<EQCSS.b.length;b++)for(e=document.querySelectorAll(EQCSS.d[b]),a=0;a<e.length;a++){k="EQCSS_"+b+"_"+a;e[a].setAttribute(k,k);h=document.querySelector("#"+k);h||(h=document.createElement("STYLE"),h.id=k,document.querySelector("head").appendChild(h));h=document.querySelector("#"+k);g=!0;c=0;a:for(;c<EQCSS.a[b].length;c++)switch(d=window.getComputedStyle(e[a],null),l=e[a]!=document.documentElement?window.getComputedStyle(e[a].parentNode,null):null,EQCSS.a[b][c].f){case "min-width":if(-1!=EQCSS.a[b][c].value.indexOf("px")&&(f=parseInt(d.getPropertyValue("width")),!(f>=parseInt(EQCSS.a[b][c].value)))){g=!1;break a}if(-1!=EQCSS.a[b][c].value.indexOf("%")&&(f=parseInt(d.getPropertyValue("width")),d=parseInt(l.getPropertyValue("width")),!(d/f<=100/parseInt(EQCSS.a[b][c].value)))){g=!1;break a}break;case "max-width":if(-1!=EQCSS.a[b][c].value.indexOf("px")&&(f=parseInt(d.getPropertyValue("width")),!(f<=parseInt(EQCSS.a[b][c].value)))){g=!1;break a}if(-1!=EQCSS.a[b][c].value.indexOf("%")&&(f=parseInt(d.getPropertyValue("width")),d=parseInt(l.getPropertyValue("width")),!(d/f>=100/parseInt(EQCSS.a[b][c].value)))){g=!1;break a}break;case "min-height":if(-1!=EQCSS.a[b][c].value.indexOf("px")&&(f=parseInt(d.getPropertyValue("height")),!(f>=parseInt(EQCSS.a[b][c].value)))){g=!1;break a}if(-1!=EQCSS.a[b][c].value.indexOf("%")&&(f=parseInt(d.getPropertyValue("height")),d=parseInt(l.getPropertyValue("height")),!(d/f<=100/parseInt(EQCSS.a[b][c].value)))){g=!1;break a}break;case "max-height":if(-1!=EQCSS.a[b][c].value.indexOf("px")&&(f=parseInt(d.getPropertyValue("height")),!(f<=parseInt(EQCSS.a[b][c].value)))){g=!1;break a}if(-1!=EQCSS.a[b][c].value.indexOf("%")&&(f=parseInt(d.getPropertyValue("height")),d=parseInt(l.getPropertyValue("height")),!(d/f>=100/parseInt(EQCSS.a[b][c].value)))){g=!1;break a}break;case "min-characters":if(e[a].value){if(!(e[a].value.length>=parseInt(EQCSS.a[b][c].value))){g=!1;break a}}else if(!(e[a].textContent.length>=parseInt(EQCSS.a[b][c].value))){g=!1;break a}break;case "max-characters":if(e[a].value){if(!(e[a].value.length<=parseInt(EQCSS.a[b][c].value))){g=!1;break a}}else if(!(e[a].textContent.length<=parseInt(EQCSS.a[b][c].value))){g=!1;break a}break;case "min-children":if(!(e[a].children.length>=parseInt(EQCSS.a[b][c].value))){g=!1;break a}break;case "max-children":if(!(e[a].children.length<=parseInt(EQCSS.a[b][c].value))){g=!1;break a}break;case "min-lines":f=parseInt(d.getPropertyValue("height"))-parseInt(d.getPropertyValue("border-top-width"))-parseInt(d.getPropertyValue("border-bottom-width"))-parseInt(d.getPropertyValue("padding-top"))-parseInt(d.getPropertyValue("padding-bottom"));d=parseInt(d.getPropertyValue("line-height"));if(!(f/d>=parseInt(EQCSS.a[b][c].value))){g=!1;break a}break;case "max-lines":if(f=parseInt(d.getPropertyValue("height"))-parseInt(d.getPropertyValue("border-top-width"))-parseInt(d.getPropertyValue("border-bottom-width"))-parseInt(d.getPropertyValue("padding-top"))-parseInt(d.getPropertyValue("padding-bottom")),d=parseInt(d.getPropertyValue("line-height")),!(f/d+1<=parseInt(EQCSS.a[b][c].value))){g=!1;break a}}if(!0===g){c=EQCSS.e[b];c=c.replace(/\$this/g,"["+k+"]");try{h.innerHTML=c}catch(m){h.styleSheet.cssText=c}}else try{h.innerHTML=""}catch(n){h.styleSheet.cssText=""}}}};(function(b){function a(){try{f.doScroll("left")}catch(b){setTimeout(a,50);return}c("poll")}function c(a){if("readystatechange"!=a.type||"complete"==h.readyState)("load"==a.type?window:h)[l](m+a.type,c,!1),!e&&(e=!0)&&b.call(window,a.type||a)}var e=!1,k=!0,h=window.document,f=h.documentElement,d=!~navigator.userAgent.indexOf("MSIE 8"),g=d?"addEventListener":"attachEvent",l=d?"removeEventListener":"detachEvent",m=d?"":"on";if("complete"==h.readyState)b.call(window,"lazy");else{if(!d&&f.doScroll){try{k=!window.frameElement}catch(n){}k&&a()}h[g](m+"DOMContentLoaded",c,!1);h[g](m+"readystatechange",c,!1);window[g](m+"load",c,!1)}})(function(){EQCSS.load();EQCSS.apply()});window.addEventListener("resize",function(){EQCSS.apply()});
(function() {
if (typeof EQCSS === 'undefined' && typeof EQCSS_loaded === 'undefined'){
var elementQueries = document.createElement('script')
elementQueries.src = 'http://elementqueries.com/EQCSS.js'
document.body.appendChild(elementQueries)
elementQueries.insertAdjacentHTML('beforebegin', '<!--[if lt IE 9]><script src="http://elementqueries.com/EQCSS-polyfills.js"></script><![endif]-->')
EQCSS_loaded = true
}
})();
if(typeof EQCSS==='undefined'&&typeof EQCSS_loaded==='undefined'){var eq=document.createElement('script');eq.src='http://elementqueries.com/EQCSS.js';document.body.appendChild(eq);eq.insertAdjacentHTML('beforebegin','<!--[if lt IE 9]><script src="http://elementqueries.com/EQCSS-polyfills.js"></script><![endif]-->');EQCSS_loaded=true;};
<script type="text/eqcss">
@element 'html' {
}
</script>
(function() {
var myWidget = document.createElement('section'),
widgetStyles = document.createElement('style'),
tag = document.querySelectorAll('[src*="myWidget"]')[0];
myWidget.innerHTML = '\
<!-- Add your HTML here, with line-breaks escaped by a "\" backslash character. -->\
<!-- (Don\'t forget: you can escape any character, like quotes, as well -->\
Hello\
';
widgetStyles.innerHTML = '\
/* Add your CSS here, with line-breaks escaped by a "\" backslash character */\
html { background: #09f; }\
';
function populateWidget(content) {
tag.parentNode.insertBefore(content, tag.nextSibling);
};
populateWidget(widgetStyles);
populateWidget(myWidget);
})();
(function() {
if (typeof EQCSS === 'undefined' && typeof EQCSS_loaded === 'undefined'){
var elementQueries = document.createElement('script')
elementQueries.src = 'http://elementqueries.com/EQCSS.js'
document.body.appendChild(elementQueries)
elementQueries.insertAdjacentHTML('beforebegin', '<!--[if lt IE 9]><script src="http://elementqueries.com/EQCSS-polyfills.js"></script><![endif]-->')
EQCSS_loaded = true
}
var myWidget = document.createElement('section'),
widgetStyles = document.createElement('style'),
tag = document.querySelectorAll('[src*=\'myWidget\']')[0];
myWidget.innerHTML = '\
<!-- Add your HTML here, with line-breaks escaped by a "\" backslash character. -->\
<!-- (Don\'t forget: you can escape any character, like quotes, as well -->\
Hello\
';
widgetStyles.innerHTML = '\
/* Add your EQCSS here, with line-breaks escaped by a "\" backslash character */\
@element "html" and (min-width: 0px) { html { background: #09f; } }\
';
function populateWidget(content) {
tag.parentNode.insertBefore(content, tag.nextSibling);
};
populateWidget(widgetStyles);
populateWidget(myWidget);
})();
// Block autofocus for touchscreen users
onload = function(){
if(('ontouchstart' in window)||(navigator.msMaxTouchPoints>0)){
var field = document.querySelectorAll('[autofocus]');
for(var i=0;i<field.length;i++) {
field[i].blur();
}
}
}
git pull
git st
git add --all
git commit -m "" -m ""
git push
If you need to change a config file, eg. a .htaccess
or robots.txt
for a local environment but don't want to commit those changes to the repository, you can run this command after your alteration has been made to ignore your alterations and assume that the state of your local repository is clean. This lets you track your config files within version control without including any secret information. You don't need to put config files in your .gitignore
list.
git update-index --assume-unchanged filename.txt
git log --all --graph --decorate --oneline --simplify-by-decoration
git diff --shortstat "@{0 day ago}"
grep -nr ""
du -sh * | sort -hr
wow pretty good stuff. Thanks