Skip to content

Instantly share code, notes, and snippets.

<?php
public function live_table_reduce($columns, $listing)
{
foreach($listing->toArray() as $key=>$value){
if(is_array($value) && !empty($value['label'])){
$value = $value['label'];
}
$columns[$key]['data'][] = $value;
$columns[$key]['value'] = Inflector::humanize($key);
}
select id,
(SELECT GROUP_CONCAT(`COLUMN_NAME` SEPARATOR ', ')
FROM `INFORMATION_SCHEMA`.`COLUMNS`
WHERE `TABLE_SCHEMA`='heavysalvage'
AND `TABLE_NAME`='auctions'
AND COLUMN_NAME LIKE '%rear_%')
from auctions order by cab DESC;
if (isset($attachment['transformers'][$class])) {
return new $attachment['transformers'][$class]($options);
}
@mergeweb
mergeweb / stuff.js
Last active September 10, 2015 13:20
this.beforeSave()
.then(this.send.bind(this))
.then(this.success.bind(this))
.then(this.afterSave.bind(this))
// Error validation shown in page
.catch(function(error){
// HERE IS WHERE I WANT THE DEFAULT HTML5 ERRORS TO SHOW
// This will be called if any of the above promises throw an error
})
.then(this.enable_save.bind(this))
Request = {
send: function (options) {
this.options.success = this.success.bind(this);
this.options.error = this.error.bind(this);
this.options = _.extend(this.options, options)
return this.request(this.options);
},
request: function (options){
return new Promise(function (resolve, reject){
// Do the usual XHR stuff
<?php
App::uses('PwfSource', 'Model/Datasource');
App::uses('Model', 'Model');
public function setUp() {
$this->Source = ClassRegistry::init('PwfSource');
$this->sourceMethods = get_class_methods($this->Source);
$methods = array_diff($this->sourceMethods, ['read', '__call', '__isset', '__get']);
$this->Source = $this->getMock('PwfSource', $methods);
<?php
$this->Source = $this->getMock('PwfSource');
ConnectionManager::create($this->sourceName, array(
'datasource' => get_class($this->Source),
));
$this->Model = $this->getMock(
'PwfTask',
array('getDataSource'),
function create_post_types() {
register_post_type('degrees-and-programs', [
'labels' => [
'name' => 'Degrees and Programs',
'all_items' => 'All Degrees/Programs'
],
'public' => true,
'has_archive' => true,
'rewrite' => ['slug' => 'degrees-and-programs'],
'hierarchical' => true,
<table cellspacing="0" cellpadding="0" class="gstl_50 gssb_c" style="width: 599px; top: 485px; position: absolute; text-align: left; /* display: none; */ left: 34px;" dir="ltr">
<tbody>
<tr>
<td class="gssb_f"></td>
<td class="gssb_e" style="width: 100%;">
<table cellspacing="0" cellpadding="0" class="gsc-completion-container" style="width: 100%;">
<tbody>
<tr class="">
<td class="gssb_a " dir="ltr" style="text-align: left;">
<div class="gsq_a">
@mergeweb
mergeweb / Field Options
Last active August 29, 2015 14:21
ACF Fields Repeatable
{
"id":"whitepaper_acf",
"title":"Whitepaper ACF",
"location":[
[
{
"param":"post_type",
"operator":"==",
"value":"upnup-whitepapers",
"order_no":0,