View XMLReader PHP Sample
$reader = new XMLReader();
while ($reader->read()) {
switch ($reader->nodeType) {
if ($reader->localName=="book") {
$bookid = $reader->getAttribute("id");
$xml = simplexml_load_string($reader->readOuterXML());
View pypy pip install
#Download the get-pip file
#install it with admin permission
pypy -m pip install validators
#Install MysQL DB in pypy
View gist:808c7c7468015e3a2dc98e55792f2926
function encrypt($string, $key=5) {
$result = '';
for($i=0, $k= strlen($string); $i<$k; $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result .= $char;
return base64_encode($result);
View Stash
* Stash Class to handle the CI DB Cache clear by centralizing in Library
* Contributor - Giri Annamalai M
* Add the following to _reset_write of CI QueryBuilder
* Stash::table($this->qb_from)->clear();
class Stash
protected $ci;
View Python
import os, json
def get_list_of_dirs(path):
output_dictonary = {}
list_of_dirs = [os.path.join(path, item) for item in os.listdir(path) if os.path.isdir(os.path.join(path, item))]
output_dictonary["text"] = os.path.basename(path)
output_dictonary["href"] = '#'+os.path.basename(path)
output_dictonary["type"] = "directory"
output_dictonary["nodes"] = []
for dir in list_of_dirs:
View JavaScript.sublime-build
// Sublime Text - Build System for Javascript
"cmd": ["node", "$file"],
"selector": "source.js"
View fork-example.php
* @file
* Basic demonstration of how to do parallel threads in PHP.
// This array of "tasks" could be anything. For demonstration purposes
// these are just strings, but they could be a callback, class or
// include file (hell, even code-as-a-string to pass to eval()).


Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

View Enhance.js
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
componentDidMount() {
this.setState({ data: 'Hello' });
render() {