Skip to content

Instantly share code, notes, and snippets.

View nicksheffield's full-sized avatar

Nick Sheffield nicksheffield

View GitHub Profile
@nicksheffield
nicksheffield / package.json
Last active August 29, 2015 13:56
Node JS Package example
{
"name" : "appname",
"version" : "0.0.1",
"description" : "Description goes here.",
"main" : "app.js",
"author" : "Nick Sheffield",
"dependencies" : {
"express" : "~4.7.2",
"mongoose" : "~3.6.2",
"morgan" : "~1.2.2"
@nicksheffield
nicksheffield / Links.txt
Created March 3, 2014 21:59
Links for the bootcamp class
@nicksheffield
nicksheffield / ribbon.svg
Last active August 29, 2015 13:57
SVG of a ribbon with twitter logo
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nicksheffield
nicksheffield / script.js
Last active August 29, 2015 13:57
iOS style sticky section headers
$(window).scroll(function(){
var scrollY = window.scrollY // how far you are scrolled down
$('section').each(function(){
var e = $(this), // element
height = e.height() // height of element
eTop = e.offset().top // element top offset,
h1 = e.find('h1') // title element
// if the screen is scrolled down past the top of the section
@nicksheffield
nicksheffield / gist:aa6b02d384d82c1fdd0b
Created May 1, 2014 04:03
Adds the circle method to 2d canvas context
CanvasRenderingContext2D.prototype.circle = function (x, y, r) {
this.beginPath();
this.arc(x, y, r, 0, 2 * Math.PI, false);
this.closePath();
}
@nicksheffield
nicksheffield / flex.css
Created August 31, 2014 11:59
Extremely simple flexbox system
.flex{
display: flex;
flex: 1;
justify-content: space-between;
}
.flex-row { flex-flow: row nowrap; }
.flex-column { flex-flow: column nowrap; }
@nicksheffield
nicksheffield / RomanToInt.js
Created February 25, 2015 04:43
Roman numeral to integer converter
function romanToInt(s){
var n=0,i=0,d={'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000};
for(;i<s.length;i++)n+=d[s[i+1]]>d[s[i]]?d[s[i]]*-1:d[s[i]];
return n;
}
@nicksheffield
nicksheffield / flexy.css
Last active August 29, 2015 14:19
HTML attribute based flexbox framework
[layout], [data-layout] { display: flex; }
[layout~="row"], [data-layout~="row"] { flex-direction: row; }
[layout~="col"], [data-layout~="col"] { flex-direction: column; }
[layout~="full-col"], [data-layout~="full-col"] { flex-direction: column; min-height: 100vh; }
[justify~="start"], [data-justify~="start"] { justify-content: flex-start; }
[justify~="end"], [data-justify~="end"] { justify-content: flex-start; }
[justify~="center"], [data-justify~="center"] { justify-content: center; }
[justify~="between"], [data-justify~="between"] { justify-content: space-between; }
[justify~="around"], [data-justify~="around"] { justify-content: space-around; }
[align~="start"], [data-align~="start"] { align-items: flex-start; }
@nicksheffield
nicksheffield / gist:a543801d5d729e16ea18
Created June 4, 2015 02:04
Easy jQuery smooth scroll
# Modified from https://css-tricks.com/snippets/jquery/smooth-scrolling/
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({ scrollTop: target.offset().top }, 500, function(){
location.hash = target.selector;
@nicksheffield
nicksheffield / index.html
Created August 12, 2015 06:05
Basic jQuery DOM Traversal
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DOM Traversal</title>
<style>
.box1, .box2, .box3, .box4, .box5{
border: 1px solid black;
padding: 1em;