Skip to content

Instantly share code, notes, and snippets.

@jwestbrook
jwestbrook / index.json
Last active May 18, 2016 20:09
My Jason Client JSON
{
"$jason": {
"head": {
"title": "Tiles",
"description": "A Tiled View of the World"
},
"body": {
"sections": [{
"items": [{
"type": "label",
@jwestbrook
jwestbrook / gist:45a967c02cbad2548875
Last active September 4, 2015 16:50
Bootstrap 2.3.2 clearfix in mixins.less
//Fix the clearfix
.clearfix {
*zoom: 1;
&:before,
&:after {
display: table;
content: "";
// Fixes Opera/contenteditable bug:

To migrate a PrototypeJS Lighthouse ticket

search for ticket number in issues, if found skip to next ticket

Copy current title into new github issue

add first lines

[previous lighthouse ticket #](https://prototype.lighthouseapp.com/projects/ticket_link) 
var BackboneAdapterMethods = {
hide : function(){
this.invoke('hide');
},
attr : function(map){
this.invoke('writeAttribute',map);
},
text: function() {
@jwestbrook
jwestbrook / migratesessions.php
Last active January 2, 2016 21:39
I had to migrate PHP sessions from file based sessions to Memcached based sessions. I couldn't shutdown the servers involved for the split second it would take because all of my users would lose their current sessions. I put this together to migrate the file based sessions to memcached sessions.
<?php
$m = new Memcached();
$m->addServer('localhost', 11211);
$sessions = scandir("/var/lib/php/session/");
if($sessions)
{
foreach($sessions as $s)
{
@jwestbrook
jwestbrook / gist:6246119
Created August 16, 2013 00:09
use underscore, prototype, and backbone together in the same file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>project-name</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.1/underscore-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/prototype/1.7.1.0/prototype.js"></script>
</head>
<body>
<?php
/** Check for a valid GET parameter before rendering the rest of the page
* otherwise send a 404 header to prevent bots
*/
if(!isset($_GET['YOUR_FAVORITE_PARAMETER']))
{
header("HTTP/1.0 404 Not Found");
exit;
}
/*
@jwestbrook
jwestbrook / gist:5961046
Last active December 19, 2015 13:19
PrototypeJS Class Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Prototype Classes</title>
<script src="//ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js"></script>
<script type="text/javascript">
var myClass = Class.create(
{
initialize : function(option)
@jwestbrook
jwestbrook / boilerplate.html
Last active December 16, 2015 09:59
html5
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>project-name</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<h1>project-name</h1>
</body>
/**
* Bind and Trigger custom and native events in Prototype
* @author Juriy Zaytsev (kangax)
* @author Benjamin Lupton (balupton)
* @copyright MIT license
**/
(function(){
var eventMatchers = {
'HTMLEvents': /^(?:load|unload|abort|error|select|hashchange|popstate|change|submit|reset|focus|blur|resize|scroll)$/,