Skip to content

Instantly share code, notes, and snippets.

View nathansmith's full-sized avatar
😎
Ask me about free high fives!

Nathan Smith nathansmith

😎
Ask me about free high fives!
View GitHub Profile
@nathansmith
nathansmith / truncate.html
Created March 20, 2014 19:58
Just a text truncation example.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<title>Truncation Example</title>
<style>
* {
font-size: 13px;
@nathansmith
nathansmith / #1 insert-jquery.js
Last active August 29, 2015 14:00
Silly script to log tags/content.
(function() {
var s = document.createElement('script');
s.src = 'http://code.jquery.com/jquery-1.11.0.min.js';
document.body.appendChild(s);
})();
@nathansmith
nathansmith / highlight.scss
Created May 14, 2014 15:19
Stylesheet for Highlight.js
//
// Monokai style - ported by Luigi Maselli - http://grigio.org
//
pre {
background: #272822;
font-size: 14px;
overflow: auto;
padding: 10px;
}
@nathansmith
nathansmith / lulz.js
Last active August 29, 2015 14:04
Paste this into browser console, to illustrate why arbitrary script execution is bad.
(function(d) {
'use strict';
// DOM elements.
var body = d.body;
var html = d.documentElement;
var head = d.head || d.getElementsByTagName('head')[0];
// Style attributes.
var b = body.style;
@nathansmith
nathansmith / #1 example.css
Last active August 29, 2015 14:04
JS to detect non-IE browsers. IE10 & IE11 throw false positives about "preserve 3D" CSS transforms.
.not-IE .foobar {
/*
3D CSS transforms here.
*/
}
@nathansmith
nathansmith / td-max-width-img.html
Last active August 29, 2015 14:06
For Firefox/IE: Showing how to simulate max-width on an <img> in a <table>.
<style>
/*
Assuming a basic CSS reset
does something like this...
*/
table {
border-collapse: collapse;
border-spacing: 0;
@nathansmith
nathansmith / angular_2.0_musings.html
Last active August 29, 2015 14:08
Trying to wrap my head around the Angular 2.x syntax.
<!--
Test HTML elements.
JS should console.log "bar" 5 times.
-->
<div (foo)="bar"></div>
<div (foo)="bar"></div>
<div (foo)="bar"></div>
<div (foo)="bar"></div>
@nathansmith
nathansmith / handlebars_match.js
Last active August 29, 2015 14:18
Handlebars helper to {{#match}} against multiple strings.
define(function(require) {
'use strict';
var handlebars = require('handlebars');
/*
========================================
This Handlebars helper compares a string
against a "|" separated list of strings.
========================================
@nathansmith
nathansmith / css_pre_post_processing_expanation.md
Last active August 29, 2015 14:23
Eat Lightning and Crap Thunder™ — aka: CSS Mullet — Sass in the front, PostCSS in the back :)

CSS Pre-Processing

When it comes to languages that power the web, CSS is a double-edged sword. Often heralded for being quick to learn, like chess it takes awhile to master. Due to its simplicity, it is easy to get to a point where CSS files become unruly, mired by code repetition and lack of consistency.

Enter CSS pre-processors (and post-processors). Of all the CSS pre-processing approaches, Sass (Syntactically Awesome Style Sheets) is the clear front-runner.

http://sass-lang.com

Metaphorically, Sass is to CSS what jQuery is to JavaScript. Not only that, Sass gives CSS a seat at the table of first-class programming languages.

@nathansmith
nathansmith / rgb_hex.js
Last active September 4, 2015 05:24
Convert colors to RGB
/*
This will change:
"rgba(255, 255, 255)" or "#fff"
Into:
#FFFFFF
*/