Skip to content

Instantly share code, notes, and snippets.

Avatar

Dave Baker fullybaked

View GitHub Profile
@fullybaked
fullybaked / bling.js
Created Feb 28, 2018 — forked from paulirish/bling.js
bling dot js
View bling.js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@fullybaked
fullybaked / usort.php
Created Sep 1, 2015
Usort with PHP7 Spaceship vs PHP5.6
View usort.php
<?php
// PHP 5.6
usort($array, function($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
});
@fullybaked
fullybaked / example.php
Last active Aug 29, 2015
Cakephp date format issue
View example.php
// open athens dates come from a date picker text input in the view, in the format dd-mm-yyyy
<?= $this->Form->input('openathens_start_date, [
'type' => 'text',
'class' => 'datepicker']);?>
<?= $this->Form->input('openathens_end_date, [
'type' => 'text',
'class' => 'datepicker']);?>
// in the Table
public function beforeMarshal(Event $event, \ArrayObject $data, \ArrayObject $options)
@fullybaked
fullybaked / data_view.php
Created Jul 22, 2015
JSON out from views
View data_view.php
<?php
// data controller
public function get_data()
{
$data = [
'item' => $this->getDataFromSomewhere(),
'min' => 0,
'max' => 10
];
View UsersTable.php
<?php
public function findByFullName($search_term) {
$users->find()
->where(['CONCAT(UserProfiles.first_name, " ", UserProfiles.lastname)' => $search_term]);
->contain(self::$applicant_contain)
->order(['Users.primary_role' => 'DESC', 'Users.modified' => 'DESC'])
->limit(25);
}
View raw.sql
select count(DISTINCT project_id), sum(amount), user_id
from payments
group by user_id
order by sum(amount) desc;
View Composable.php
<?php
/**
* This is a _very_ rough draft of an idea to create a composable field in a model
* by which, the Model::find methods would return a value object rather plain data
* for a given field.
*
* Value Objects would be created in the /Lib directory of the application
*
* This is a work in progress hence being a Gist.
*/
@fullybaked
fullybaked / File.php
Created Nov 27, 2014
Simple wrapper for PHP's file_(get|put)_contents methods
View File.php
<?php
namespace Fullybaked;
use FileNotFound;
/**
* File class
*
* Simple wrapper for native methods file_get_contents and file_put_contents
* in an OOP context and with some useful methods for getting information about
* a given File
@fullybaked
fullybaked / example.php
Last active Aug 29, 2015
Scoped CakePHP Models
View example.php
<?php
class Person extends AppModel
{
// must explicitly set the useTable so child classes
// use this not the CakePHP conventions based on their
// class name
public $useTable = 'people';
// table people exists in the database with schema
// id int(11) PK
// type varchar(20) default 'contact' not null
View keybase.md

Keybase proof

I hereby claim:

  • I am fullybaked on github.
  • I am fullybaked (https://keybase.io/fullybaked) on keybase.
  • I have a public key whose fingerprint is 9919 C36F D1FD E4E5 CB0A E92F 8B05 EE06 F9EF 3B39

To claim this, I am signing this object: