View isemptyobject.js
'use strict'; | |
angular.module('crmApp') | |
.filter('isEmptyObject', function () { | |
return function (obj) { | |
return angular.equals({}, obj); | |
}; | |
}); |
View array_to_csv.php
function convert_to_csv($input_array, $output_file_name, $delimiter) | |
{ | |
/** open raw memory as file, no need for temp files, be careful not to run out of memory thought */ | |
$f = fopen('php://memory', 'w'); | |
/** loop through array */ | |
foreach ($input_array as $line) { | |
/** default php csv handler **/ | |
fputcsv($f, $line, $delimiter); | |
} | |
/** rewrind the "file" with the csv lines **/ |
View nested list.js
function getList(item, $list) { | |
if($.isArray(item)) { | |
$.each(item, function (key, value) { | |
getList(value, $list); | |
}); | |
return; | |
} | |
if (item) { | |
var $li = $('<li />'); | |
if (item.name) { |
View validate_date.php
# http://php.net/manual/en/function.checkdate.php | |
function validateDate($date, $format = 'Y-m-d H:i:s') | |
{ | |
$d = DateTime::createFromFormat($format, $date); | |
return $d && $d->format($format) == $date; | |
} | |
var_dump(validateDate('2012-02-28 12:12:12')); # true | |
var_dump(validateDate('2012-02-30 12:12:12')); # false | |
var_dump(validateDate('2012-02-28', 'Y-m-d')); # true |
View gist:4a6e9ae973ed09fae382
<?php | |
use Zend\Mvc\ModuleRouteListener; | |
use Zend\Mvc\MvcEvent; | |
class Module | |
{ | |
public function onBootstrap(MvcEvent $e) | |
{ |
View composer_git_create_project
php composer.phar create-project -sdev --repository-url="https://packages.zendframework.com" zendframework/skeleton-application c:\xampp\htdocs\zf2 |
View MySQL Datetime Manipulation
update log_data SET `timestamp` = `timestamp` + INTERVAL 1 DAY WHERE id >= 1000 LIMIT 1000; | |
SELECT datetime + INTERVAL 10 YEAR + INTERVAL 3 MONTH + INTERVAL 22 DAY | |
+ INTERVAL 10 HOUR + INTERVAL 30 MINUTE AS new_date_time FROM table; |
View chart.html
<div id="chart"> | |
<h4>Percent of adults over 25 with at least a bachelor's degree:</h4> | |
<p><strong>Median:</strong> <span class="median"></span></p> | |
<small>Source: <cite><a href="http://census.gov">U.S. Census Bureau</a></cite>, via <cite><a href="http://beta.censusreporter.org/compare/01000US/040/table/?release=acs2011_1yr&table=B15003">Census Reporter</a></cite></small> | |
</div> |
View Download CSV
public function downloadCsvAction() | |
{ | |
$oldTimeLimit = ini_get('max_execution_time'); | |
ini_set('max_execution_time', 60); | |
$lang = $this->params('lang', "en"); | |
$this->setRatingsViewData($this->viewData, $lang); | |
$headers = array( | |
'location_name', | |
'breakdown_period', |
View D3 States
function getRandomInt(min, max) { | |
return Math.floor(Math.random() * (max - min)) + min; | |
} | |
/* | |
Code example explaining the enter, update and exit states in D3. | |
The 3 states basically define the actions that occur when data is added to a selection of elements. | |
Say if we were selecting data from a database where we had to perform a search with a query string, | |
each time we ran query the number of rows returned could be more, less, or could be the same but | |
contain different data, these in essence are the 3 states. more = enter, less = exit, same = update. |
NewerOlder