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 / crash_old_ie.html
Last active September 24, 2015 09:08
This should crash IE6 & IE7.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Crash IE6 + IE7</title>
<!--[if IE 6]>
<script>
@nathansmith
nathansmith / randomize_array.js
Created December 9, 2010 21:59
Randomize a JavaScript array
function randomize() {
return Math.round(Math.random()) - 0.5;
}
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120].sort(randomize);
@nathansmith
nathansmith / if-poem.md
Last active July 18, 2021 23:20
"IF" by Rudyard Kipling
If you can keep your head when all about you
Are losing theirs and blaming it on you,
If you can trust yourself when all men doubt you
But make allowance for their doubting too,
If you can wait and not be tired by waiting,
Or being lied about, don't deal in lies,
Or being hated, don't give way to hating,
And yet don't look too good, nor talk too wise:
@nathansmith
nathansmith / template.php
Created January 29, 2011 06:11
Drupal 7 HTML5 Minification
<?php
function THEMENAME_process_html(&$variables) {
if (!empty($variables)) {
$css_before = array(' type="text/css"', ' media="all"');
$css_after = array('', '');
$js_before = array(' type="text/javascript"', '<!--//--><![CDATA[//><!--', '//--><!]]>');
$js_after = array('', '', '');
<!--
A quick fix for my friend Chris Bowler.
http://chrisbowler.com/journal/alternate-css-files
-->
<link rel="stylesheet" media="screen" id="time_style" href="/-/css/day.css" />
<script>
@nathansmith
nathansmith / moz-webkit.css
Created March 22, 2011 01:51
Target Firefox and WebKit via hacky CSS.
/*
Read more here:
https://developer.mozilla.org/en/CSS/@-moz-document
For more browser-specific hacks:
http://paulirish.com/2009/browser-specific-css-hacks
*/
@-moz-document url-prefix() {
/* Put your Firefox specific code here. */
@nathansmith
nathansmith / adaptive_layout_idea.html
Created April 6, 2011 05:13
Conditionally serve CSS to screen widths that can handle it. With a fallback for when JavaScript is disabled and/or not supported.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>
Adaptive Layout Idea
</title>
<link rel="stylesheet" href="basic_defaults.css" />
<noscript>
<link rel="stylesheet" href="fallback.css" />
/*
Adapt.js licensed under GPL and MIT.
Read more here: http://adapt.960.gs
*/
// Closure.
(function(w, d, config, undefined) {
// If no config, exit.
if (!config) {
@nathansmith
nathansmith / check_all.js
Last active March 10, 2019 16:39
Used to check all checkboxes in a page.
// Paste into Firebug or Chrome Dev Tools console
// when viewing a page with multiple checkboxes.
(function(d) {
var input = d.querySelectorAll('input[type="checkbox"]');
var i = input.length;
while (i--) {
input[i].checked = true;
}
@nathansmith
nathansmith / screwed.js
Last active June 10, 2020 17:01
Force yourself to learn JavaScript.
// If you're a glutton for punishment, and/or claim
// that JavaScript libraries have too much "bloat",
// use this to force yourself to write JS longhand.
(function(window) {
function screwed() {
window._ = null;
window.$ = null;
window.$A = null;
window.$F = null;