Skip to content

Instantly share code, notes, and snippets.

View rafasashi's full-sized avatar
👍
Happy

Raphaël Dartigues rafasashi

👍
Happy
View GitHub Profile
function custom_json_decode(&$contents=NULL, $normalize_contents=true, $force_array=true){
//---------------decode contents---------------------
$decoded_contents=NULL;
if(is_string($contents)){
$decoded_contents=json_decode($contents,$force_array);
@rafasashi
rafasashi / parser.php
Last active August 29, 2015 14:21 — forked from martinsik/parser.php
<?php
$curl = curl_init('http://www.livescore.com/soccer/england/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10');
$html = curl_exec($curl);
curl_close($curl);
if (!$html) {
function get_array_value($array=array(), $path=array()){
foreach($path as $key) {
if(isset($array[$key])){
$array=$array[$key];
}
else{

Gearman can be installed on Windows through cygwin.

Install Cygwin packages

Install cygwin packages (through setup.exe):

  • gcc
  • make
  • libuuid1-devel
  • libiconv

install Boost headers

debian

apt-get install libboost-all-dev

fedora

yum install boost-devel

@rafasashi
rafasashi / README.rst
Last active August 29, 2015 14:22 — forked from dupuy/README.rst

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

@rafasashi
rafasashi / How to review and run an external php script safely.markdown
Last active August 29, 2015 14:23
How to review and run an external php script safely?
  1. fetch the original script but never change it directly
  2. parse the php script using token_get_all() and token_name()
  3. replace every sensitive functions by a wrape_function_name to control the behavore
  4. rebuild the script and store the mirror script somewhere
  5. use getcwd() to store the current directory and chdir() to reset it to the original location so the static resources will be dowloaded from the origine
  6. execute the mirror script
  7. use chdir() to restore the previous directory location
<?php
if (!isset($_SESSION['user'])) {
require_once( COMPONENTS . "/user/class.user.php" );
$_SESSION['user'] = $_SERVER['PHP_AUTH_USER'];
$_SESSION['lang'] = 'en';
$_SESSION['theme'] = 'default';
$_SESSION['project'] = '/var/www';
$User = new User();
@rafasashi
rafasashi / strip_single_tag.php
Last active November 28, 2019 03:44
strip a single html tag
function strip_single_tag($str,$tag=''){
if(is_array($tag)){
foreach($tag as $t){
$str=strip_single_tag($str,$t);
}
}
else{