Skip to content

Instantly share code, notes, and snippets.

@williscool
williscool / p4merge
Created August 24, 2012 20:18 — forked from henrik242/p4merge
Helper script for p4merge and Git on MacOSX
#!/bin/bash
for arg; do [[ $arg = /* ]] || arg=$PWD/$arg; absargs+=("$arg"); done;
/Applications/p4merge.app/Contents/Resources/launchp4merge "${absargs[@]}"
anonymous
anonymous / gist:3795993
Created September 27, 2012 19:38
Render Partial in Controller
$sm = $this->getServiceLocator();
$view = new ViewModel(array('foo' => 'bar'));
$view->setTemplate('foo/bar');
$resolver = $sm->get('ViewManager')->getResolver();
$renderer = new PhpRenderer();
$renderer->setResolver($resolver);
$html = $renderer->render($view);
@nateware
nateware / haproxy.conf
Created October 31, 2012 15:36
HAProxy sample config for EC2
#
# This config file is a combination of ideas from:
# http://www.37signals.com/svn/posts/1073-nuts-bolts-haproxy
# http://www.igvita.com/2008/05/13/load-balancing-qos-with-haproxy/
# http://wiki.railsmachine.com/HAProxy
# http://elwoodicious.com/2008/07/15/nginx-haproxy-thin-fastcgi-php5-load-balanced-rails-with-php-support/
# http://upstream-berlin.com/2008/01/09/using-haproxy-with-multiple-backends-aka-content-switching/
# http://wiki.railsmachine.com/HAProxy
# http://gist.github.com/raw/25482/d39fb332edf977602c183194a1cf5e9a0b5264f9
#
@ndarville
ndarville / business-models.md
Last active October 9, 2025 17:55
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
anonymous
anonymous / Authentication.php
Created December 18, 2012 01:27
ZF2 Authentication Validator
<?php
/**
* Zend Framework 2
*
* @category Zend
* @package Validator
*/
namespace Zend\Validator;

MvcEvent::BOOTSTRAP

This event is triggered by the following classes:

  1. Zend\Mvc\Application: it's triggered in the bootstrap method.

The following classes are listening to this event (they are sorted from higher priority to lower priority):

  1. Class: Zend\Mvc\View\Http\ViewManager. Method: onBootstrap. Priority: 10000. Task: preparing the view layer.
@jordiwes
jordiwes / gist:4667235
Created January 29, 2013 20:01
Here is my file upload code. You'll notice that the validator is commented out, this is not because it didn't work, it's because I don't need it. It's an internal application and doesn't need any validaiton.
use Zend\File\Transfer\Adapter\Http;
$adapter = new Http();
//$size = new Size(array('min'=>2000)); //minimum bytes filesize
//$adapter->setValidators(array($size), $File['name']);
@mvsantos
mvsantos / remove-image-background.sh
Created May 10, 2013 14:16
Remove/strip image background - rough mode - requires ImageMagick
# Requires ImageMagick
# Converting the source from JPEG to PNG - if necessary
convert my_src_image.jpg my_src_image.png
# Option A
# - Requires a temporary intermediate file
# - Drill more than 10 might result in poor results
(ns clj-wamp-example
(:require [org.httpkit.server :as http-kit]
[clj-wamp.server :as wamp]))
; Topic URIs
(defn rpc-url [path] (str "http://clj-wamp-example/api#" path))
(defn evt-url [path] (str "http://clj-wamp-example/event#" path))
(defn wamp-websocket-handler [req]
(http-kit/with-channel req channel
@noprompt
noprompt / project.clj
Last active December 19, 2020 14:38
Demonstration using Garden to recreate the Semantic Grid framework.
(defproject semantic-gs "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.5.1"]
[compojure "1.1.5"]
[garden "0.1.0-beta5"]
[hiccup "1.0.3"]]
:plugins [[lein-ring "0.8.5"]]
:ring {:handler semantic-gs.handler/app}
:profiles
{:dev {:dependencies [[ring-mock "0.1.5"]]}})