Skip to content

Instantly share code, notes, and snippets.

View jackmakesthings's full-sized avatar
🌙

jack jackmakesthings

🌙
View GitHub Profile
@jackmakesthings
jackmakesthings / _basic-navbar.scss
Created October 25, 2013 19:22
Common pattern: responsive nav. This version is sticky, top-aligned, and single-level. Defaults to a hidden dropdown nav menu with a show/hide trigger button, morphs into a typical horizontal bar at larger views. (Working on a personal code library, demo coming soon.)
// Modify line-heights, font-sizes, etc to suit the design - anything with a // after it is optional or can change per-design
// Note: this is super barebones. Making it pretty/fit your design is on you, gentle coder.
.masthead {
position: fixed;
top: 0;
width: 100%;
height: 3em; //
background: white; //
h1 {
@jackmakesthings
jackmakesthings / list-files.php
Created November 1, 2013 13:12
Looping through a directory with PHP and generating a list of files. (This snippet is pretty basic, but easily extensible.) Initial code from http://www.ultramegatech.com/2009/03/working-with-directories-in-php/
$dir = '/path/to/your/files/';
if($dh = opendir($dir)) {
while(($file = readdir($dh)) !== false) {
if($file != '.' && $file != '..') {
if(is_dir($dir . $file)) {
echo "<div> - " . $file . "</div>\n";
}
else {
echo "<div>" . $file . "</div>\n";
}
@jackmakesthings
jackmakesthings / config.rb
Last active December 27, 2015 14:29
dat compass.
Sass::Script::Number.precision = 3
require 'susy'
require 'compass-normalize'
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "scss"
@jackmakesthings
jackmakesthings / googlefont.php
Last active December 28, 2015 19:19
Shortcut php function for a quick Google Fonts url if you know the font you want. Works handily in a wordpress functions.php file.
<?php
function googlefont($name, $styles = null) {
$return = '<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=' . $name;
if($styles !== null) { $return .= ':' . $styles; }
$return .= '">';
return $return;
}
// usage: <?php echo googlefont('Oswald', '400,700');
@jackmakesthings
jackmakesthings / mixins-extends.css
Created November 25, 2013 03:19
Snipped from North ( https://github.com/Snugug/north ) -- extend/mixin pattern for more elegant output.
.message--STATUS, .message--WARNING, .message--ERROR {
box-sizing: border-box;
padding: 0.25em 0.5em;
width: 80%;
margin: 0 auto;
border: 2px solid;
}
.message--STATUS {
border-color: green;
@jackmakesthings
jackmakesthings / emmet.html
Last active December 30, 2015 01:09
Emmet snippets - in the interest of standardizing markup between projects a little more. Install Emmet via the Sublime Text package manager, then paste any of these snippets into an html document and hit tab (or tab-enter, or whatever you've set as your Emmet trigger key). Pieces added in no particular order.
*NAVIGATION*
<!-- Basic nav structure: -->
nav>(ul.nav-menu>li.nav-item>a.nav-link[href=""]{Link})
<!-- With a menu-toggle button (for responsive layouts): -->
nav>(ul.nav-menu>li.nav-item>a.nav-link[href=""]{Link})+a.menu-toggle[href="#"]{+}
<!-- With five items and ordering classes set: -->
nav>(ul.nav-menu>(li.nav-item-$*5>a.nav-link[href=""]{Link}))+a.menu-toggle[href="#"]{+}
@jackmakesthings
jackmakesthings / responsive-nav--markup.html
Created December 2, 2013 18:44
component: responsive, single-level nav bar. still trying to settle on how to organize these modules, bear with me.
<html>
<body>
<header>
<nav>
<ul class="nav-menu">
<li><a href="">I'm a Link</a></li>
<li><a href="">He's a Link</a></li>
<li><a href="">She's a Link</a></li>
<li><a href="">Cause we're all links</a></li>
<li><a href="">Yeah!</a></li>
@jackmakesthings
jackmakesthings / Hello kittens
Last active August 29, 2015 13:56
Generated by SassMeister.com.
Showing a buddy one way to do container elements.
@jackmakesthings
jackmakesthings / modular-content.php
Last active August 29, 2015 13:56
How to streamline a bunch of dynamic bits in php
<?php
/**
* so let's say this is your overall page template, index.php or whatever
* you could set a variable up top that dictates the module types that are possible
**/
$modules = array(
'gallery',
'faq',
@jackmakesthings
jackmakesthings / trigger-repaints.js
Created March 18, 2014 13:23
snippet from a (handy) article on viewport units - how to force elements to repaint to get around a chrome vh/vw resizing bug. which is probably fixed by now, but i can think of other uses for this. -- http://css-tricks.com/viewport-sized-typography/
causeRepaintsOn = $("h1, h2, h3, p");
$(window).resize(function() {
causeRepaintsOn.css("z-index", 1);
});
// todo: un-jquerify, for the hell of it