Skip to content

Instantly share code, notes, and snippets.

@kevinwritescode
kevinwritescode / Util_Lang.php
Created November 1, 2011 17:52
Translation Init Example with Abstract DIP
<?php
class Util_Lang
{
protected static $_class;
protected static $_session;
/**
* Get a translated value and possibly replace with real time data
* If the value does not exist, a phrase will be auto generated from key
@kevinwritescode
kevinwritescode / Util_Svn.php
Created November 1, 2011 18:05
Quickly get the SVN revision number at the application level of a ZEND project
<?php
class Util_Svn
{
protected static $_revision;
/**
* Get the current SVN version at the application path folder
*
* @return string Revision Number
<?php
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// BEGIN LOGIC TO ADD ACCOUNT
try {
$accountRes = self::createAccount($productDef, '1' . $phone, $productDef['apiServiceId'], $amount, true);
} catch (Exception $e) {
switch ($e->getCode()) {
case XXXX:
<?php
if (!empty($settings->discountReplace->enable) && $product['id'] == $settings->discountReplace->productId && $transType == $settings->discountReplace->type) {
$discounts = array(
'location' => $settings->discountReplace->location,
'division' => $settings->discountReplace->division,
'subdistributor' => $settings->discountReplace->subdistributor,
'distributor' => $settings->discountReplace->distributor
);
}
?>
@kevinwritescode
kevinwritescode / gist:3425546
Created August 22, 2012 13:27
Checker Gradient
background-color: #f5f5f5;
background-image: -webkit-linear-gradient(45deg, rgba(256, 256, 256, 0.5) 25%, transparent 25%, transparent 75%, rgba(256, 256, 256, 0.5) 75%, rgba(256, 256, 256, 0.5)), -webkit-linear-gradient(45deg, rgba(256, 256, 256, 0.5) 25%, transparent 25%, transparent 75%, rgba(256, 256, 256, 0.5) 75%, rgba(256, 256, 256, 0.5));
background-size: 4px 4px;
background-position: 0 0, 2px 2px;
if ($style == 'created') {
$sql .= " AND s.chg_tot < 10";
$sql .= " AND (s.chg_tot > 0 OR s.credit = 1 OR s.credit = 2)";
$sql .= " AND (s.last_date IS NULL OR s.last_date >= " . $db->quote($startDate) . ")";
$sql .= " AND s.cre_date BETWEEN " . $db->quote($startDate) . " AND " . $db->quote($endDate);
}
// If a user tops-up with a PIN product and forget to supply their phone, set it for them
if (!$phone && !empty($response['pin'])) {
$phone = $lookup['topupphone'];
}
$('.ajaxloader').change(function(e) {
e.preventDefault();
console.log('top leveler');
var value = $(this).val();
var child = $(this).attr('data-child');
var ajaxurl = $(this).attr('data-ajax');
if (child && ajaxurl) {
#!/bin/bash
# Download and Build Every Company Site
# @author Kevin Nuut
USER_HOME=$(eval echo ~${SUDO_USER})
base="/var/www/"
confd="/var/www/confd/"
log="/var/log/company/"
@kevinwritescode
kevinwritescode / !Wrapping-Express-Router.md
Last active August 29, 2015 14:11
Wrapping Express Router

I love using Express 4's Router for rapid API development, but I hate having to link existing functions to the router.use() function by mapping req.body properties to the function parameters. So I wrote the following script, which will automatically map each property. Additionally, if you have parameters called req or res, it will reserve those words to pass the routers parameters directly.

Note that this implementation assumes any function being called will return a Q promise. It will also return a default status of 500 for any error thrown by the function, unless overridden.