Skip to content

Instantly share code, notes, and snippets.

View helpse's full-sized avatar

Sergio Melendez helpse

View GitHub Profile
import datetime
def prettydate(d):
diff = datetime.datetime.utcnow() - d
s = diff.seconds
if diff.days > 7 or diff.days < 0:
return d.strftime('%d %b %y')
elif diff.days == 1:
return '1 day ago'
elif diff.days > 1:
return '{} days ago'.format(diff.days)
@helpse
helpse / TreeArray.php
Last active November 17, 2015 14:13
Get a tree from an array and indicators
<?php
/**
* Author: Sergio Melendez
* www.inspiredsolutions.pe
*
* Usage:
* $data = TreeArray::factory($array, $indicators)->get();
*
* Input: [['a': 1, 'b': 2],['a': 1, 'b': 3]]
* Input: ['a']
@helpse
helpse / Odbc.php
Last active December 28, 2015 19:49 — forked from ceeram/Odbc.php
ODBC for DBO Modified by Sergio Melendez It works for a Linux / Apache / PHP / PDO_ODBC / ODBC / MSSQL environment The PDO driver provided by Microsoft for Linux, doesn't implement some PDO methods, you have to modify Model.php and DboSource.php as well (You can ask me for details)
<?php
/**
* ODBC for DBO
* Modified by Sergio Melendez
*
* It works for a Linux / Apache / PHP / PDO_ODBC / ODBC / MSSQL environment
* The PDO driver provided by Microsoft for Linux, doesn't implement some PDO methods,
* you have to modify Model.php and DboSource.php as well (You can ask me for details)
*
* PHP versions 4 and 5

Favourite Kohana Tips

Passing a route as array

    $this->redirect($this->request->route()->uri(array(
				'controller' => 'welcome',
				'action' => 'home',
			)));
@helpse
helpse / prueba.php
Last active December 31, 2015 06:09
<?php
$server = $_SERVER['SERVER_NAME'];
$host = 'http://200.48.11.178';
$clientCarroceria = new SoapClient($host."/webservices/carroceria.php?wsdl");
var_dump($clientCarroceria);
//die();
class Finances
@@sum = 0
def self.get_orders
Order.where(state: [1, 2, 3, 4])
end
def self.get_bids
BidRequest.where(state: [1, 2, 3, 5])