This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Reads automatically arguments options | |
* @return array | |
*/ | |
function get_opts() { | |
$result = array(); | |
$key = null; | |
$value = null; | |
$asize = count($_SERVER['argv']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* An array merging helper | |
* @params array $original | |
* @params array $additionnal | |
* @return array | |
*/ | |
function merge_array( $original, $additionnal ) | |
{ | |
if ( empty($additionnal) ) return $original; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// include the beaba framework before ... | |
$app = new beaba\core\WebApp(array( | |
'layouts' => array( | |
'profile/view' => function( $app, $data ) { | |
echo '<h1>Profile</h1>'; | |
echo '<p> Name : ' . $data['name'] . '</p>'; | |
echo '<p> Email : ' . $data['email'] . '</p>'; | |
} | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This function is distributed under the MIT Open Source License. | |
* @author Ioan CHIRIAC | |
* @link https://github.com/ichiriac | |
*/ | |
function generate_password($password, $salt = 'your-secret-salt', $algo = 'sha256') | |
{ | |
// split the password | |
$password = str_split($password, ceil(strlen($password)/2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Fibonnaci short algorithm | |
* @link http://fr.wikipedia.org/wiki/Suite_de_Fibonacci | |
* @author I. CHIRIAC | |
*/ | |
function fibo( $i ) { | |
return ( | |
$i <= 1 ? $i : | |
( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Function: sanitize | |
* Returns a sanitized string, typically for URLs. | |
* | |
* Parameters: | |
* $string - The string to sanitize. | |
* $lowercase - Force the string to lowercase? | |
* $alnum - If set to *true*, will remove all non-alphanumeric characters. | |
*/ | |
function sanitize($string, $lowercase = true, $alnum = false) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function renderTemplate($template, $data) { | |
$data_keys = array_map(function($key) { | |
return '%' . $key . '%'; | |
}, array_keys($data)); | |
$data_values = array_values($data); | |
return str_replace($data_keys, $data_values, $template); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class jPrototype { | |
protected static $prototype = array(); | |
public static function prototype() { | |
if ( !self::$prototype ) { | |
self::$prototype = new self(); | |
} | |
return self::$prototype; | |
} | |
public function __set($property, $value) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('CRLF', "\r\n"); | |
class HaveToWork extends Thread { | |
protected $wait; | |
public $socket = null; | |
public function __construct() { | |
$this->wait = true; | |
$this->start(); | |
} | |
public function run() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="../core-menu/core-submenu.html" rel="import"> | |
<link href="../core-item/core-item.html" rel="import"> | |
<link href="../core-pages/core-pages.html" rel="import"> | |
<link href="../paper-checkbox/paper-checkbox.html" rel="import"> | |
<polymer-element name="my-element"> | |
<template> | |
<style> | |
#design_host { |
OlderNewer