Skip to content

Instantly share code, notes, and snippets.

@stephencoe
stephencoe / usevm.md
Created December 20, 2012 02:03 — forked from fideloper/usevm.md

#You should do all your LAMP development in a Virtual Machine

##Here's Why:

Many of us develop on Macintoshes. There are many reasons for this, but one of them is that it's based on a Unix platform of some sort. This allows us to run common server software such as Apache, Ruby, Python and Nodejs on our Macs.

Our computers become powerful develoment machines similar to the servers our apps will eventually live on.

Sometime we start our computer only to find Apache won't start, or MySQL can't create a PID file, or we've updated to Mountain Lion and Apache needs to be reconfigured. Death!

/*
See it in action: http://jsbin.com/iyinux/edit#javascript,html,live
Also Fun: http://jsbin.com/oyanih/7/edit#javascript,html,live
Better Fun: http://jsbin.com/uhakaw/34/edit#javascript,html,live
*/
/*
EXAMPLE USE OF JAVASCRIPT PUBSUB -
https://github.com/mroderick/PubSubJS
*************************************************************/
@stephencoe
stephencoe / Zend Less
Created July 25, 2013 12:15
less auto compile in Zend Framework 1.12
protected function _initCss(){
require_once APPLICATION_PATH . "/../library/lessphp/lessc.inc.php";
$inputFile = APPLICATION_PATH."/../public/css/less/style.less";
$outputFile = APPLICATION_PATH."/../public/css/style.css";
// load the cache
$cacheFile = APPLICATION_PATH . "/../data/cache/css-compiled.less.cache";
@stephencoe
stephencoe / gist:6127586
Last active December 20, 2015 11:59
Jquery 2.0 with IE<10 fallback
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]> <html class="ie7"> <![endif]-->
<!--[if IE 8 ]> <html class="ie8"> <![endif]-->
<!--[if IE 9 ]> <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]-->
<head>
<!--[if IE]>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
@stephencoe
stephencoe / gist:2d71ea355564bfe0e0d3
Created January 16, 2015 12:31
Fix inuit white space without HTML comments
/**
* Fix for inuit
* https://github.com/csswizardry/inuit.css/issues/170#issuecomment-14859371
* https://github.com/sparklemotion/nokogiri.org/blob/master/sass/oscailte/helpers/_grid-fix.scss
*/
.layout {
letter-spacing: -0.31em;
}
/* Opera hack */

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post

var page = new WebPage(),
address, output, size;
//capture and captureSelector functions adapted from CasperJS - https://github.com/n1k0/casperjs
capture = function(targetFile, clipRect) {
var previousClipRect;
var clipRect = {top: 0, left:0, width: 40, height: 40};
if (clipRect) {
if (!isType(clipRect, "object")) {
throw new Error("clipRect must be an Object instance.");
@stephencoe
stephencoe / server.js
Created January 24, 2015 08:12
Basic node static server
// npm install serve-static --save-dev
var connect = require('connect');
var serveStatic = require('serve-static');
connect().use(serveStatic(__dirname)).listen(8080);
@stephencoe
stephencoe / placeholder.js
Last active August 29, 2015 14:15
Placeholder polyfill - no jquery
/**
* @license http://opensource.org/licenses/MIT
* Polyfill [].forEach.call using the polyfill service
* @link https://github.com/Financial-Times/polyfill-service
*/
if(false === ('placeholder' in document.createElement('input'))){
var inputs = document.getElementsByTagName('input');
[].forEach.call(inputs, function(input){
if(input.getAttribute('placeholder')){
@stephencoe
stephencoe / ExampleModel.js
Last active December 28, 2018 11:20
Serve cached images from s3 instead of cloudinary. It needs tidying but it works and reduces bandwidth dramatically. - inspired by https://gist.github.com/dboskovic/23858511bf3c1cbebdbd
//...
Model.add({
content: {
type: Types.Html, wysiwyg: true, height: 400
},
hash : {
type : String,
hidden : true
},