Skip to content

Instantly share code, notes, and snippets.

@jblotus
jblotus / gist:5397690
Created April 16, 2013 17:13
Disabled css
.disabled {
/* Theoretically for IE 8 & 9 (more valid) */
/* ...but not required as filter works too */
/* should come BEFORE filter */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
/* This works in IE 8 & 9 too */
/* ... but also 5, 6, 7 */
filter: alpha(opacity=80);
@jblotus
jblotus / gist:3288675
Created August 7, 2012 19:33
Force page reload when back button pressed
<script>
window.onload = function() {
if (typeof window.load_once !== 'undefined' && window.load_once) {
window.location.reload();
}
window.load_once = true;
}
</script>
@jblotus
jblotus / gist:2648200
Created May 9, 2012 19:27
Handlebars global scope issues with partials in a block
<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="https://github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js"></script>
</head>
<body>
<script id="partial" type="text/x-handlebars-template">
{{this}}
</script>
@jblotus
jblotus / gist:2252197
Created March 30, 2012 15:11
Invoking a private or protected method with Reflection, for unit testing purposes
/**
* Invokes a protected or private method
*
* @param object $object the object containing the method
* @param string $method_name the string name of the method contained on the object
* @param array $args an array of args to pass to the method (order matters)
*
* @return Closure the result of executed method
*/
public function invokePrivateMethod($object, $method_name, array $args = array())
@jblotus
jblotus / gist:1635698
Created January 18, 2012 21:13
SC Api
error example:
{"success":false,"errors":["No api key was passed"]}
GET /students/users
===================
get all teachers or parents for a student
params
------
@jblotus
jblotus / gist:1333900
Created November 2, 2011 15:20
iterate by reference
foreach ($objList as &$obj) {
$obj->key = 'whatever';
}
//prevent leaks
unset($obj);
@jblotus
jblotus / gist:1256470
Created October 1, 2011 18:41
PHP configure 5.3.8 script centos 5.6 32bit
# --enable-fpm #EXPERIMENTAL: Enable building of the fpm SAPI executable
# --enable-gd-native-ttf GD: Enable TrueType string function
# --enable-mbstring Enable multibyte string support
# --enable-sockets Enable sockets support
# --with-bz2[=DIR] Include BZip2 support
# --with-curl[=DIR] Include cURL support
# --with-gd[=DIR] Include GD support. DIR is the GD library base
# --with-mcrypt[=DIR] Include mcrypt support
# --with-mysql[=DIR] Include MySQL support. DIR is the MySQL base
# directory. If mysqlnd is passed as DIR,
Lithium PHP Framework Talk Outline
About Lithium
-------------
Lithium PHP is modern PHP 5.3+ MVC framework aimed at developers looking for a framework that offers amazing flexibility built
on top of a solid set of built-in conventions and defaults. Lithium takes liberal advantage of PHP 5.3 features like
closures (anonymous functions), namespaces (for autoloading classes) and late-static-binding (proper subclassing for static methods).
Lithium was developed by some of the core developers of CakePHP and brings a strong pedigree from experienced high-adoption framework designers.
Talk Summary
@jblotus
jblotus / gist:1182650
Created August 31, 2011 02:00
Lithium PHP Auth Filter
Users::applyFilter('save', function($self, $params, $chain) {
$record = $params['entity'];
if ($record->validates() && !$record->id) {
$record->password = Password::hash($record->password);
}
$params['entity'] = $record;
return $chain->next($self, $params, $chain);
@jblotus
jblotus / gist:1159587
Created August 20, 2011 20:00
Lithium issue with CamelCased Helpers not being underscored
/* app/extensions/MyHelper.php */
<?php
namespace lithium\template\helper;
class MyHelper {
public function foo() {
return 'bar';
}