Skip to content

Instantly share code, notes, and snippets.

:octocat:

Dan Harper danharper

:octocat:
View GitHub Profile
View edit.erb
<% if @note %>
<form action="/<%= @note.id %>" method="post" id="edit">
<input type="hidden" name="_method" value="put">
<textarea name="content"><%=h @note.content %></textarea>
<input type="checkbox" name="complete" <%= "checked" if @note.complete %>>
<input type="submit">
</form>
<p><a href="/<%= @note.id %>/delete">Delete</a></p>
<% else %>
<p>Note not found.</p>
@danharper
danharper / helper.js
Created Feb 6, 2012
Handlebars Conditional Helper
View helper.js
Handlebars.registerHelper('if_task_active', function(options) {
var state = this.model.state_id;
if (state == 300) {
return options.fn(this);
}
return options.inverse(this);
});
@danharper
danharper / helper.js
Created Feb 6, 2012
Handlebars Conditional Helper with Arguments
View helper.js
Handlebars.registerHelper('if_task_state', function(options) {
var states = options.hash.is.split(',')
, r = false
;
_.each(states, function(state) {
if (state == this.model.state)
r = true;
}, this);
@danharper
danharper / wrapper.php
Created Feb 20, 2012
FuelPHP package wrapper
View wrapper.php
<?php
public static function __callStatic($method, $arguments)
{
return call_user_func_array(array(self::$_instance, $method), $arguments);
}
@danharper
danharper / index.html
Created Jul 16, 2012
A web page created at CodePen.io
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Simple Styled Radio Inputs &middot; CodePen</title>
<!--
Copyright (c) 2012 Dan Harper, http://codepen.io/danharper
Permission is hereby granted, free of charge, to any person obtaining
@danharper
danharper / unblockus
Created Aug 22, 2012
Toggle Mac Wi-Fi DNS settings for using Unblock-Us.
View unblockus
function unblockuson() {
sudo networksetup -setdnsservers "Wi-Fi" 208.122.23.22 208.122.23.23
sudo networksetup -setairportpower "en1" "off"
sudo networksetup -setairportpower "en1" "on"
echo "Unblock-Us: ENABLED"
}
function unblockusoff() {
sudo networksetup -setdnsservers "Wi-Fi" "empty"
sudo networksetup -setairportpower "en1" "off"
@danharper
danharper / gist:4247146
Created Dec 9, 2012
Removing Browser's Print Header/Footer
View gist:4247146
@page {
margin: .312in .312in .322in;
}
@media print {
html {
margin: 0 .1in;
}
}
@danharper
danharper / ApiJobsController.php
Created Dec 30, 2012
Implementing Eiffel in Laravel 4 is a piece of cake compared to Fuel.
View ApiJobsController.php
<?php
class ApiJobsController extends BaseController
{
public function index()
{
throw new NotImplemented;
}
public function show($id)
@danharper
danharper / harlem shake.js
Created Feb 20, 2013
Harlem Shake, copied from http://pastebin.com/aGGDYN59, which is likely copied from somewhere else. Paste this into your console
View harlem shake.js
javascript:(function(){function c(){var e=document.createElement("link");e.setAttribute("type","text/css");e.setAttribute("rel","stylesheet");e.setAttribute("href",f);e.setAttribute("class",l);document.body.appendChild(e)}function h(){var e=document.getElementsByClassName(l);for(var t=0;t<e.length;t++){document.body.removeChild(e[t])}}function p(){var e=document.createElement("div");e.setAttribute("class",a);document.body.appendChild(e);setTimeout(function(){document.body.removeChild(e)},100)}function d(e){return{height:e.offsetHeight,width:e.offsetWidth}}function v(i){var s=d(i);return s.height>e&&s.height<n&&s.width>t&&s.width<r}function m(e){var t=e;var n=0;while(!!t){n+=t.offsetTop;t=t.offsetParent}return n}function g(){var e=document.documentElement;if(!!window.innerWidth){return window.innerHeight}else if(e&&!isNaN(e.clientHeight)){return e.clientHeight}return 0}function y(){if(window.pageYOffset){return window.pageYOffset}return Math.max(document.documentElement.scrollTop,document.body.scrollTop)}funct
View vhost
NameVirtualHost *:80
# Dynamic Virtual Host
<VirtualHost *:80>
UseCanonicalName off
VirtualDocumentRoot "/Library/WebServer/Sites/%1"
<Directory "/Library/WebServer/Sites/%1" >
AllowOverride All
</Directory>
You can’t perform that action at this time.