Skip to content

Instantly share code, notes, and snippets.

@tamboer
tamboer / formatToHourMinutes.php
Last active December 14, 2015 21:39
php function that takes a decimal value and format to hour and minutes
<?php
function formatToHourMinutes($decTime) {
$negative = false;
if(!is_numeric($decTime))return $decTime;
if($decTime == 0)return '-';
if($decTime < 0){
$negative = true;
$decTime = abs($decTime);//$decTime = -1 * abs($decTime);
}
@tamboer
tamboer / validateInteger
Created March 13, 2013 15:09
link for php solution to validate integer
http://stackoverflow.com/questions/4100022/php-validate-integer
@tamboer
tamboer / commonDateTimeFunctions.php
Last active December 14, 2015 21:39
PHP - Common Date and Time functions
<?php
class Common_Datetime {
static public function months() {
$month_name_arr = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$month_name_arr = array("january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december");
return $month_name_arr;
}
/**
@tamboer
tamboer / isValidTime.php
Last active December 14, 2015 21:48
untested preg_match for valid time
<?php
public function isValidTime($time,$is24Hours=true,$seconds=false) {
$pattern = "/^".($is24Hours ? "([1-2][0-3]|[01]?[1-9])" : "(1[0-2]|0?[1-9])").":([0-5]?[0-9])".($seconds ? ":([0-5]?[0-9])" : "")."$/";
if (preg_match($pattern, $time)) {
return true;
}
return false;
}
@tamboer
tamboer / nextAndPreviousYears.php
Last active December 14, 2015 21:48
php function returns array with the n next years, current year and n previous years
<?php
/**
*
* returns array with the next ($next*)years, current year and previous (previous*)years
* return as int
* (except for current, needs to change)
*
*/
public function getNextAndPreviousYears($current,$next = null,$previous = null){
@tamboer
tamboer / jQueryBasics.js
Last active December 14, 2015 21:59
jQuery basics
$(function() {
$('#datatable').dataTable( {
//"bSort": false
} );
// ##### DATA TABLE COLUMN FILTER ###### //
// if($('#datatable').length > 0){
// $('#datatable').dataTable().columnFilter();
@tamboer
tamboer / Zend_Common.php
Last active December 14, 2015 21:59
Some common Zend controller actions
<?php
public function common() {
Zend_Controller_Front::getInstance()->getBaseUrl();
//$this->_helper->layout()->setLayout('nomenulayoutwide');
$this->getHelper('layout')->disableLayout();
$this->_helper->_layout->setLayout('login');
$this->_helper->redirector('list');
@tamboer
tamboer / regex.txt
Last active December 14, 2015 23:58
netbeans regex - regular expressions Just starting to use this
["](.*)//finds everything in the line after the "
/*********************/
http://stackoverflow.com/questions/4419000/regex-match-everything-after-question-mark
\?(.*)//match everything that is after/follows the question mark.
/*********************/
@tamboer
tamboer / gitStuff.txt
Last active December 15, 2015 01:39
git stuff
cd /var/www
mkdir scrum
chmod -R 777 scrum/
cd scrum/
git init
git status
git remote add origin git@github.com:buschagne/scrum.git
sudo nano .git/config
@tamboer
tamboer / Zend_Date.php
Created March 18, 2013 14:59
Zend_date functions
<?php
$currentDate = new Zend_Date();
$currentDate->setDate($taskDistribution["date"], "yyyy-MM-dd");
$startTime = new Zend_Date();
$startTime->setTime($taskDistribution["start_time"], "HH:mm:ss");
$endTime = new Zend_Date();
$endTime->setTime($taskDistribution["end_time"], "HH:mm:ss");
if($endTime->toString('HH') == '00')
$endTime->setHour('24');