Skip to content

Instantly share code, notes, and snippets.

@jwage
jwage / SplClassLoader.php
Last active August 16, 2024 17:36
Add MIT license.
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// Released under MIT license: http://www.opensource.org/licenses/mit-license.php
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
<?php /*mongodb custom php session handler
copyright 2010 ryan day
lgpl
*/
$mongo = new Mongo();
//MongoSession::setConfig('collection','session_test');
$mongo_session = new MongoSession($mongo);
@aarongustafson
aarongustafson / TinyMCE-config-HTML5.js
Created August 26, 2010 12:57
Working on a TinyMCE config that supports HTML5
// General
button_tile_map : true,
editor_selector : 'lg_mceEditor',
mode:'textareas',
theme : 'advanced',
// Cleanup/Output
apply_source_formatting : true,
convert_fonts_to_spans : true,
convert_newlines_to_brs : false,
@foxzool
foxzool / rails3template.rb
Created January 13, 2011 10:24
my rails3 template
require "thor/shell"
say("Modifying a new Rails app ...", :yellow)
#----------------------------------------------------------------------------
# Configure
#----------------------------------------------------------------------------
=begin
unless options[:database] == 'sqlite3'
username = ask("What's your database username[root]")
username = 'root' if username.blank?
@huacnlee
huacnlee / install-php.sh
Created March 8, 2011 03:13
Ubuntu 10.10 install PHP Apache2 from source
sudo apt-get install libjpeg8-dev libmysqlclient-dev
curl -O http://www.php.net/get/php-5.3.5.tar.gz/from/a/mirror
curl -O http://mirror.bjtu.edu.cn/apache//httpd/httpd-2.2.17.tar.gz
tar zxf httpd-2.2.17.tar.gz
cd httpd-2.2.17
./configure --prefix=/etc/apache2 --enable-so --enable-cgi --enable-info --enable-rewrite \
--enable-speling --enable-usertrack --enable-deflate --enable-ssl --enable-mime-magic \
--enable-dav --enable-vhost-alias --enable-proxy --enable-expires --enable-headers
make && sudo make install
@bdunogier
bdunogier / curl_progress.php
Created June 16, 2011 22:31
PHP/cURL download progress monitoring
<?php
file_put_contents( 'progress.txt', '' );
$targetFile = fopen( 'testfile.iso', 'w' );
$ch = curl_init( 'http://ftp.free.org/mirrors/releases.ubuntu-fr.org/11.04/ubuntu-11.04-desktop-i386-fr.iso' );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $ch, CURLOPT_NOPROGRESS, false );
curl_setopt( $ch, CURLOPT_PROGRESSFUNCTION, 'progressCallback' );
curl_setopt( $ch, CURLOPT_FILE, $targetFile );
* GET /posts {"controller":"posts","action":"index"}
* GET /posts/{:id:\d+} {"controller":"posts","action":"show"}
* GET /posts/add {"controller":"posts","action":"add"}
* PUT /posts {"controller":"posts","action":"create"}
* GET /posts/{:id:\d+}/edit {"controller":"posts","action":"edit"}
* POST /posts/{:id:\d+} {"controller":"posts","action":"update"}
* DELETE /posts/{:id:\d+} {"controller":"posts","action":"delete"}
@alkemann
alkemann / tests.php
Created October 4, 2011 14:04
Run PHPUnit tests in browser for ease of reading, running subsets or debuggin.
<?php
/**
* Place this file in the webroot of your project,
* access it through http://project.dev/tests.php or http://localhost/project/webroot/tests.php
*
* Assuming you have defined a BASEPATH to the root of your project and
*/
define('BASEPATH', __DIR__.'/..'); // root of project, this one assumes /project/webroot/tests.php
define('LOCATION', BASEPATH .'/app'); // in a SF2 project, this is where the phpunit.xml file is
@philsturgeon
philsturgeon / gearman-workers.sh
Created January 16, 2012 01:53 — forked from fabriziomachado/gearman-workers.sh
/etc/init.d/gearman-workers
#!/bin/bash
#
# /etc/init.d/gearman-workers
### BEGIN INIT INFO
# Provides: gearman-workers
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6