Skip to content

Instantly share code, notes, and snippets.

hakre hakre

Block or report user

Report or block hakre

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hakre
hakre / XmlArrayElement.php
Created Jul 14, 2015
Recursive Method Calls with SimpleXML and DOMDocument Context
View XmlArrayElement.php
<?php
/**
* Class ArrayXmlElement
*
* Use an array definition stored as XML to convert a tree structure from another DOMDocument
*
* @author hakre <http://hakre.wordpress.com>
*/
class XmlArrayElement extends SimpleXMLElement
{
@hakre
hakre / output-buffer-to-temp.php
Created Dec 19, 2012
Output buffer for large output to temporary file on disk (>2MB)
View output-buffer-to-temp.php
<?php
/*
* Output buffer for large output to temporary file on disk (>2MB)
*
* @link http://stackoverflow.com/questions/5446647/how-can-i-use-var-dump-output-buffering-without-memory-errors/
*/
/**
* Iterate over lines of a stream resource.
*
@hakre
hakre / simplexml-import.php
Created Feb 12, 2013
In SimpleXML, how can I add an existing SimpleXMLElement as a child element?
View simplexml-import.php
<?php
/**
* In SimpleXML, how can I add an existing SimpleXMLElement as a child element?
*
* @link http://stackoverflow.com/q/767327/367456
* @link http://eval.in/9568
* @link http://3v4l.org/1sI05
*/
/**
@hakre
hakre / other.php
Created Jun 18, 2017
inject php declare ticks poc
View other.php
<?php
/**
* just some file
*/
$a = 1;
if ($a > 0) {
$a += 2;
print($a);
@hakre
hakre / DateInterval_11556731.php
Created Jul 19, 2012
How we can add two date intervals in PHP
View DateInterval_11556731.php
<?php
/**
* How we can add two date intervals in PHP
* @link http://stackoverflow.com/q/11556731/367456
* @link http://codepad.viper-7.com/oBW2le
*
* NOTE: This code is rough.
*/
header("Content-Type: text/plain;");
@hakre
hakre / TextRange.php
Created Feb 23, 2012
TextRange and TextRangeTrimmer HTML/DOMDocument text processing classes
View TextRange.php
<?php
/**
* TextRange.php - DOMDocument based Textrange and text manipulation
*
* @author hakre <http://hakre.wordpress.com/credits>
* @version 1.1.1
*/
/**
* TextRange - Collection of DOMText nodes
View repl.bat
@if (@X)==(@Y) @end /* Harmless hybrid line that begins a JScript comment
::************ Documentation ***********
::REPL.BAT version 5.0
:::
:::REPL Search Replace [Options [SourceVar]]
:::REPL /?[REGEX|REPLACE]
:::REPL /V
:::
::: Performs a global regular expression search and replace operation on
@hakre
hakre / gist:2397187
Created Apr 16, 2012
Contextual user-friendly time and dates with PHP
View gist:2397187
<?php
/**
* @link http://snipt.net/pkarl/pkarlcom-contextualtime/
* @link http://pkarl.com/articles/contextual-user-friendly-time-and-dates-php/
*/
function contextualTime($small_ts, $large_ts=false) {
if(!$large_ts) $large_ts = time();
$n = $large_ts - $small_ts;
if($n <= 1) return 'less than 1 second ago';
if($n < (60)) return $n . ' seconds ago';
@hakre
hakre / block-category-delete-example.php
Created Nov 23, 2010
Wordpress Block Category Delete Example
View block-category-delete-example.php
<?php
/**
* Block deletion of certain categories by their ID.
*
* Copyright (C) 2010 hakre <http://hakre.wordpress.com/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
View some-iterator-fun.php
<?php
/*
* Some Iterator Fun
*
* @link http://hakre.wordpress.com/2012/02/28/some-php-iterator-fun/
*/
/**
* Iterator that fetches each iteration value from a
You can’t perform that action at this time.