View XMLReader PHP Sample
<?php
$reader = new XMLReader();
$reader->open("book.xml");
while ($reader->read()) {
switch ($reader->nodeType) {
case (XMLREADER::ELEMENT):
if ($reader->localName=="book") {
$bookid = $reader->getAttribute("id");
$xml = simplexml_load_string($reader->readOuterXML());
View pypy pip install
#Download the get-pip file
wget https://bootstrap.pypa.io/get-pip.py
#install it with admin permission
pypy get-pip.py
#Usage
pypy -m pip install validators
#Install MysQL DB in pypy
View gist:808c7c7468015e3a2dc98e55792f2926
<?php
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
<?php
/**
* 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:
output_dictonary["nodes"].append(clean_empty(get_list_of_dirs(dir)))
View JavaScript.sublime-build
// Sublime Text - Build System for Javascript
{
"cmd": ["node", "$file"],
"selector": "source.js"
}
View fork-example.php
<?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()).
View eloquent.md

Conventions:

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() {