Skip to content

Instantly share code, notes, and snippets.

View zachmayberry's full-sized avatar

Zachary Mayberry zachmayberry

View GitHub Profile
@roryashfordbentley
roryashfordbentley / gist:a251f4f118bc7777b25c
Last active August 29, 2015 14:09
We are living in a post grunt world and I am a post grunt girl
{
"name": "Flexbones",
"version": "0.1.0",
"description": "Flexbones script running in a post Grunt world",
"scripts": {
"compile-sass": "sass assets/sass/style.scss:style.css",
"concat": "concat-cli --files assets/js/**/*.js --output scripts.min.js",
"uglify-js": "uglifyjs scripts.min.js -o scripts.min.js",
"build-js": "npm run concat && npm run uglify-js",
"optimise-images": "imageoptim-cli --directory assets/imgs",
@christhesoul
christhesoul / video-helper.php
Last active October 5, 2021 23:09
PHP Video class for displaying embedded content from YouTube, Vimeo or BlipTv.
<?php
/*
Example use:
$video = new Video('https://www.youtube.com/watch?v=xfJvrH7iQ3c', 1);
$video->render_embed();
Use responsively: http://css-tricks.com/NetMag/FluidWidthVideo/Article-FluidWidthVideo.php
*/
@brandonkelly
brandonkelly / templating.md
Last active February 7, 2024 15:20
Templating in EE vs. Craft
@creationix
creationix / jsonparse.js
Last active May 10, 2024 14:36
A streaming JSON parser as an embeddable state machine.
// A streaming byte oriented JSON parser. Feed it a single byte at a time and
// it will emit complete objects as it comes across them. Whitespace within and
// between objects is ignored. This means it can parse newline delimited JSON.
function jsonMachine(emit, next) {
next = next || $value;
return $value;
function $value(byte) {
if (!byte) return;
if (byte === 0x09 || byte === 0x0a || byte === 0x0d || byte === 0x20) {
@theangryangel
theangryangel / AuthController.js
Created February 28, 2013 21:54
sails (v0.8.82) + passport + passport-local Rough Example. For the love of all that is holy, don't use this in production.
// api/controllers/AuthController.js
var passport = require('passport');
var AuthController = {
login: function (req,res)
{
res.view();
},
#!/usr/bin/ruby
require 'time'
def format_time(seconds)
hours = (seconds / 3600).to_i
minutes = ((seconds % 3600) / 60).to_i
seconds = (seconds % 60).to_i
minutes = "0#{minutes}" if minutes < 10
seconds = "0#{seconds}" if seconds < 10
@mfkp
mfkp / index.html
Created December 17, 2011 01:39
mailchimp ajax signup form example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jquery.ketchup.all.min.js" type="text/javascript"></script>
</head>
<body>
<div id="email">
<span>Enter your email to sign up</span>
<form action="/subscribe.php" id="invite" method="POST">
@tbranyen
tbranyen / backbone_pushstate_router.js
Last active February 25, 2024 21:38
hijack links for pushState in Backbone
// All navigation that is relative should be passed through the navigate
// method, to be processed by the router. If the link has a `data-bypass`
// attribute, bypass the delegation completely.
$(document).on("click", "a[href]:not([data-bypass])", function(evt) {
// Get the absolute anchor href.
var href = { prop: $(this).prop("href"), attr: $(this).attr("href") };
// Get the absolute root.
var root = location.protocol + "//" + location.host + Application.root;
// Ensure the root is part of the anchor href, meaning it's relative.
@mxriverlynn
mxriverlynn / 1-referencing.js
Created July 19, 2011 13:57
using an event aggregator with backbone
MedicationView = Backbone.View.extend({
events: {
"click #edit": "editMedication"
},
editMedication: function(){
var editView = new AddEditView({model: this.model});
editView.render();
}
});