Skip to content

Instantly share code, notes, and snippets.

@ranacseruet
ranacseruet / gist:7379890
Created November 9, 2013 00:35
Binary Tree Traversal In LISP(Preorder,Inorder & PostOrder)
(defparameter *tree2* '(40 (30 (25 () ()) (35 () ())) (60 (50 () ()) ())))
(defparameter *tree* '(3 (2 (1 () ()) ()) (5 () ())))
;validate if given parameter is a binary tree or not
(defun is-tree(tree)
(cond
((null tree) NIL)
((< (list-length tree) 3) NIL)
(t)
)
@ranacseruet
ranacseruet / gist:8233791
Created January 3, 2014 06:33
Go! AOP Test
<?php
use \Go\Core\AspectKernel;
use \Go\Core\AspectContainer;
/**
* Application Aspect Kernel
*/
class ApplicationAspectKernel extends AspectKernel
{
@ranacseruet
ranacseruet / gist:8412771
Created January 14, 2014 03:50
Benchmark for arrayaccess vs object access for PHP classes
//test.class.php
<?php
class Test implements ArrayAccess
{
private $data = array();
public function __set($key, $value){
$this->data[$key] = $value;
}
@ranacseruet
ranacseruet / MyS3Client.php
Last active July 28, 2022 19:58
Retrieve Multiple files from Amazon S3
<?php
namespace S3;
use Aws\S3\S3Client;
use \Aws\Common\Exception\TransferException;
/**
* Description of S3Client
* @author Rana
* @link http://codesamplez.com/programming/amazon-s3-get-multiple-objects-php
@ranacseruet
ranacseruet / gist:9700579
Created March 22, 2014 03:17
Custom CodeIgnite Profiler Class For Doctrine
<?php
namespace Doctrine\DBAL\Logging;
class CIProfiler implements SQLLogger
{
public $start = null;
private $ci;
@ranacseruet
ranacseruet / VideoStream.php
Last active October 30, 2024 12:43
PHP VideoStream class for HTML5 video streaming
<?php
/**
* Description of VideoStream
*
* @author Rana
* @link http://codesamplez.com/programming/php-html5-video-streaming-tutorial
*/
class VideoStream
{
private $path = "";
@ranacseruet
ranacseruet / PDAO.php
Last active October 21, 2023 16:31
PHP Dynamic Object With Array and Iterative access capability
<?php
class PDAO implements \ArrayAccess, \Iterator
{
/**
* @var array data
*/
protected $data = array();
/**
@ranacseruet
ranacseruet / pushNotifier
Last active September 30, 2016 15:16
A simple NodeJS script, to implement apple push notification service
var apn = require("apn")
var apnError = function(err){
console.log("APN Error:", err);
}
var options = {
"cert": "cert.pem",
"key": "key.pem",
"passphrase": null,
@ranacseruet
ranacseruet / Tooltip
Created March 24, 2015 04:29
An Actionscript 3.0 Class To create custom tooltip(old code)
class Tooltip {
private var theTip:MovieClip;
private var tFormat:TextFormat;
function Tooltip(hex:Number,hex2:Number) {
this.theTip = _root.createEmptyMovieClip("tooltip", _root.getNextHighestDepth());
this.theTip.createTextField("theText",this.theTip.getNextHighestDepth(),3,1,95,20);
@ranacseruet
ranacseruet / queryStringToJS.js
Created February 22, 2017 15:03
Parse url search queries into js object
static searchQueries() {
const queryString = window.location.search.substring(1)
const pairs = queryString.split('&')
let queryObj = {}
for (let i=0; i<pairs.length; i++) {
const keyVal = pairs[i].split('=')
queryObj[keyVal[0]] = decodeURIComponent(keyVal[1])
}
return queryObj
}