Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Hydrate an object by populating public properties
*
* Hydrates an object by setting public properties of the object.
*
* @param array $data
* @param object $object
* @return object
{
init: function(elevators, floors) {
for (var idx in elevators) {
elevators[idx].on('floor_button_pressed', function(floornum) {
if (this.destinationQueue.indexOf(floornum) === -1) {
this.destinationQueue.push(floornum);
this.destinationQueue.sort();
this.checkDestinationQueue();
}
});
<?php
return [
'/userid=[0-9]{1,3}/' => 'user'
];
<?php
$routes = array(
'routeA' => array(
//config here
)
);
$routes['routeB'] = $routes['routeA'];
$config = array(
<?php
$range = range(1, $rc);
$qs = implode(',', array_fill(0,$rc, '?'));
$titleQuery = $db->prepare('SELECT tablename_id, tablename_title, table_type, table_attribute FROM tablename WHERE tablename_id IN (' . $qs . ') ORDER BY tablename_title;');
$titleQuery->execute($range);
$tableNames = $titleQuery->fetchAll(PDO::FETCH_ASSOC);
//$rc is a variable that stores the row count of the particular table
foreach($tableNames as $tablename_data) {
<?php
$email = new Input();
$notEmptyEmailValidator = new NotEmpty();
$notEmptyEmailValidator->setMessages([
NotEmpty::INVALID => 'Please enter an Email Address',
NotEmpty::IS_EMPTY => 'Please enter an Email Address',
]);
<?php
return [
'version' => '1.0.0',
'table' => 'table_name',
'info' => [
'item' => [
'name' => 'cherry',
'value' => 'pick'
]
@BinaryKitten
BinaryKitten / autoloader.php
Created December 4, 2015 11:23
ThemeAutoloader
<?php
spl_autoload_register( 'my_theme_autoloader' );
function my_theme_autoloader( $class_name ) {
if ( substr( $class_name, 0, 6 ) == 'theme_' ) {
$cur_theme_file = get_stylesheet_directory() . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . $class_name . '.php';
$parent_theme_file = get_template_directory() . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . $class_name . '.php';
if ( file_exists( $cur_theme_file ) ) {
require_once $cur_theme_file;
} elseif ( file_exists( $parent_theme_file ) ) {
@BinaryKitten
BinaryKitten / functions.php
Created January 11, 2016 15:50
functions.php
<?php
add_action('plugins_loaded', function() {
if (is_plugin_active($pluginFile) {
add_action('wp_head', function() {
echo '<style>/** correction for plugin **/ stupid.override { display: annoyed; }</style>';
});
});
})