Skip to content

Instantly share code, notes, and snippets.

View destinydriven's full-sized avatar

destinydriven destinydriven

View GitHub Profile
@destinydriven
destinydriven / install-nginx-latest.sh
Created September 23, 2018 23:11 — forked from craigvantonder/install-nginx-latest.sh
Install Nginx Mainline / Stable on Ubuntu 16.04
#!/bin/bash
# https://www.nginx.com/resources/wiki/start/topics/tutorials/install/
# Switch to root
sudo su
# Add the mainline release
echo "deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ xenial nginx" > /etc/apt/sources.list.d/nginx.list
/**
* Generates a single row in a csv from an array of
* data by writing the array to a temporary file and
* returning it's contents
*
* @param array $row Row data
* @return mixed string with the row in csv-syntax, false on fputcsv or fwrite failure
*/
protected function _generateRow($row = null) {
static $fp = false;
@destinydriven
destinydriven / Timesheet.php
Last active July 26, 2018 17:36
method deleteAllNonRequestableByPayrollPeriodId()
public function deleteAllNonRequestableByPayrollPeriodId($payrollPeriodID) {
$conditions = [
$this->alias . '.payroll_period_id' => $payrollPeriodID,
$this->alias . '.is_approved' => false,
$this->alias . '.is_closed' => false
];
$ids = $this->find(
'all',
array(
public $validate = array(
'employee_id' => array(
'required' => array(
'rule' => array('notBlank'),
'required' => true,
'allowEmpty' => false,
'message' => 'Employee ID must be specified!'
),
),
'email' => array(
We need to write a little shell script to wrap wkhtmltopdf in xvfb. Make a file called wkhtmltopdf.sh and add the following:
xvfb-run -a -s "-screen 0 1024x768x24" wkhtmltopdf "$@"
Move this shell script to /usr/local/bin, and set permissions:
sudo chmod a+x /usr/local/bin/wkhtmltopdf.sh
Check to see if it works once again: run
@destinydriven
destinydriven / DboSource.php
Last active October 18, 2017 02:08 — forked from anonymous/gist:e8a986aba73db0375ec91c7cc7411839
_prepareUpdateFields()
/**
* Quotes and prepares fields and values for an SQL UPDATE statement
*
* @param Model $Model The model to prepare fields for.
* @param array $fields The fields to update.
* @param bool $quoteValues If values should be quoted, or treated as SQL snippets
* @param bool $alias Include the model alias in the field name
* @return array Fields and values, quoted and prepared
*/
protected function _prepareUpdateFields(Model $Model, $fields, $quoteValues = true, $alias = false) {
server {
listen 80;
listen [::]:80;
rewrite ^(.*) http://cube.example.com$1 permanent;
root /var/www/cube.example.com/html/app/webroot;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
<?php
/**
* Flash Component
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
@destinydriven
destinydriven / gist:7df10047a6eb65a3af80
Created July 13, 2015 22:22
FlashComponent::_call()
/**
* Magic method for verbose flash methods based on element names.
*
* For example: $this->Flash->success('My message') would use the
* success.ctp element under `app/View/Element/Flash` for rendering the
* flash message.
*
* @param string $name Element name to use.
* @param array $args Parameters to pass when calling `FlashComponent::set()`.
* @return void
public $components = array(
'Paginator',
'RequestHandler',
'DataTable.DataTable' => array(
'Employee' => array(
'columns' => array(
'id' => false, // bSearchable and bSortable will be false
'last_name' => array('label' => 'Last Name', 'bSearchable' => true, 'bSortable' => true), // bSearchable and bSortable will be true, with a custom label `Name`
'first_name' => array('label' => 'First Name', 'bSearchable' => true, 'bSortable' => true,),
'nic_number' => array('label' => 'NIC #', 'bSearchable' => true, 'bSortable' => true),