Skip to content

Instantly share code, notes, and snippets.

View harikt's full-sized avatar
⛱️
Tanvish Technologies

Hari K T harikt

⛱️
Tanvish Technologies
View GitHub Profile
@dhrrgn
dhrrgn / oembed.php
Last active August 29, 2015 13:57
<?php
$url = 'https://twitter.com/dhrrgn/status/440968615697715200';
$embedly = new Embedly\Embedly([
'key' => getenv('EMBEDLY_KEY'),
]);
if (preg_match('#https?://(?:www.)?twitter.com/[^/]+/status/([0-9]+)#i', $url, $match)) {
$oembed = json_decode(file_get_contents('https://api.twitter.com/1/statuses/oembed.json?id='.$match[1]), true);
@billschaller
billschaller / JsonHelper.php
Last active August 29, 2015 14:03
How to json_encode Doctrine (or other) model objects nicely without recursion issues.
<?php
/**
* Class JsonHelper
*
* Handles json_encoding Model objects in a way that prevents recursion issues. Stores hashes of
* "seen" objects, and if an object has already been seen, the JsonSerializableTrait unsets the key
* of the duplicate object.
*
*/
class JsonHelper
g:vdebug_options['path_maps'] = {"/var/www/cc": "/Users/trq/src/clients/cc/site"}
autocmd FileType html setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType htmljinja setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType javascript setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType php setlocal ts=4 sts=4 sw=4 expandtab
@harikt
harikt / questions.md
Last active August 29, 2015 14:04
When and where are you using an event / signal hanlder ?

Are you making use of the event handling system like Symfony event handler, Aura.Signal, Zend event manager or any other in your core framework?

Are you using signal/events before they hit the action class ( controller action ) ?

I have a feeling it will be good to have an event handling system in core of a framework.

The basic idea is to call a signal

  • before a route is checked
  • before dispatching
@harikt
harikt / Author.php
Created August 10, 2014 06:58
Experiments reinventing wheel :)
<?php
class Author
{
private $name;
private $id;
public function __construct(AuthorId $id, $name = '')
{
$this->id = $id;
$this->name = $name;
<?php
use PHPUnit_Framework_TestCase;
use Symfony\Component\DomCrawler\Crawler;
class SimpleHttpTest extends PHPUnit_Framework_TestCase
{
public function testHttp()
{
$crawler = new Crawler(file_get_contents('http://myapp.lcl/hello/Jon'));
@trq
trq / scomposer
Last active August 29, 2015 14:08
#!/usr/bin/env bash
d=$(date +%s)
remote='some-aws-box'
dir="composer-$d.tmp"
if [ -f composer.json ]; then
ssh $remote mkdir "$dir"
scp composer.json $remote:"$dir"/composer.json
@iansltx
iansltx / FastForwarder.php
Last active August 29, 2015 14:15
Calculate due dates, taking business days into account
<?php
class FastForwarder
{
protected $skipWhen = [];
protected $numDays = 0;
public static function createWithDays($num_days)
{
$ff = new static;
@tankist
tankist / php
Created May 4, 2011 09:13
Collection pagination example
class Model_Mapper_Db_User extends Skaya_Model_Mapper_Db_Abstract {
public function getUsersPaginator($order = null) {
$userTable = self::_getTableByName(self::TABLE_NAME);
$select = $userTable->select();
if ($order) {
$select->order($this->_mapOrderStatement($order));
}
$paginator = Skaya_Paginator::factory($select, 'DbSelect');
$paginator->addFilter(new Zend_Filter_Callback(array(
@webmozart
webmozart / composer.json
Created August 4, 2012 11:51
DON'T USE THIS GIST! Please clone https://github.com/bschussek/standalone-forms instead.
{
"require": {
"symfony/form": "2.1.*",
"symfony/validator": "2.1.*",
"symfony/templating": "2.1.*",
"symfony/framework-bundle": "2.1.*"
},
"minimum-stability": "dev"
}