Skip to content

Instantly share code, notes, and snippets.

View webfacer's full-sized avatar
🤪
just coding it!

Ilic Davor webfacer

🤪
just coding it!
View GitHub Profile
@agitso
agitso / CliEmailService.php
Created February 26, 2013 11:08
Use TYPO3 Flow UriBuilder in a non-controller context (fx. in a service that is used by command controller)
<?php
...
/**
* @var \TYPO3\Flow\Mvc\Routing\UriBuilder
*/
protected $uriBuilder;
/**
@nikic
nikic / objects_arrays.md
Last active May 16, 2025 22:07
Post explaining why objects often use less memory than arrays (in PHP)

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

@wwdboer
wwdboer / gist:4943672
Created February 13, 2013 10:27
PHP: Get Vimeo ID
function get_vimeoid( $url ) {
$regex = '~
# Match Vimeo link and embed code
(?:<iframe [^>]*src=")? # If iframe match up to first quote of src
(?: # Group vimeo url
https?:\/\/ # Either http or https
(?:[\w]+\.)* # Optional subdomains
vimeo\.com # Match vimeo.com
(?:[\/\w]*\/videos?)? # Optional video sub directory this handles groups links also
\/ # Slash before Id
@corleonis
corleonis / recreateTSFE.php
Created January 22, 2013 15:20
Inits the TSFE global object in the backend of Typo3
function buildTSFE($pid = 1) {
global $BACK_PATH;
//needed for TSFE
require_once(PATH_t3lib.'class.t3lib_timetrack.php');
require_once(PATH_t3lib.'class.t3lib_tsparser_ext.php');
require_once(PATH_t3lib.'class.t3lib_page.php');
require_once(PATH_t3lib.'class.t3lib_stdgraphic.php');
require_once($BACK_PATH.'sysext/cms/tslib/class.tslib_fe.php');
@takien
takien / youtubeID.js
Last active August 15, 2025 06:28
Get YouTube ID from various YouTube URL using JavaScript
/**
* Get YouTube ID from various YouTube URL
* @author: takien
* @url: http://takien.com
* For PHP YouTube parser, go here http://takien.com/864
*/
function YouTubeGetID(url){
var ID = '';
url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
@kasparsd
kasparsd / wordpress-plugin-svn-to-git.md
Last active June 2, 2025 17:14
Using Git with Subversion Mirroring for WordPress Plugin Development
@nciske
nciske / parse_youtube_videoid.php
Created August 24, 2012 14:58
Parse YouTube Video ID from url
// http://stackoverflow.com/questions/2936467/parse-youtube-video-id-using-preg-match
function my_get_youtube_videoid( $url ){
if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match)) {
return $match[1];
}
}

These instructions work for the Raspberry Pi running Raspbian (hard float) and create a hardware optimized version of NodeJS for the Raspberry PI, (and include a working install and NPM!!!):

  1. Install Raspbian - http://www.raspberrypi.org/downloads

  2. Install the necessary dependecies:

sudo apt-get install git-core build-essential

(If you just installed git then you need to administer your git identity first, else adding the patches below will fail!!!)

@tpennock-gist
tpennock-gist / Wordpress - Display wp_query details
Created July 20, 2012 16:18
Wordpress - Display wp_query SQL query details
<? echo $GLOBALS['wp_query']->request; ?>
@MikeRogers0
MikeRogers0 / validate-email.php
Created June 16, 2012 17:09
How to validate an email address with PHP
<?php
function validEmail($email){
// Check the formatting is correct
if(filter_var($email, FILTER_VALIDATE_EMAIL) === false){
return FALSE;
}
// Next check the domain is real.
$domain = explode("@", $email, 2);
return checkdnsrr($domain[1]); // returns TRUE/FALSE;