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 xslt_transform($xslFile, $xmlStr) | |
{ | |
$xsl = new DomDocument(); | |
$xsl->load($xslFile, LIBXML_NOCDATA); | |
$xml = new DomDocument(); | |
$xml->loadXML($xmlStr); | |
$xslt = new XSLTProcessor(); | |
$xslt->registerPHPFunctions(); |
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
class Singleton(object): | |
class __metaclass__(type): | |
def __call__(cls, *args, **kwargs): | |
if not getattr(cls, 'instance', None): | |
print 'Creating instance' | |
cls.instance = cls.__new__(cls, *args, **kwargs) | |
print 'Created %s' % id(cls.instance) | |
cls.instance.__init__(*args, **kwargs) | |
return cls.instance |
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
<script src="http://code.onion.com/fartscroll.js"></script> | |
<script type="text/javascript"> | |
jQuery(document).ready(function(){ | |
fartscroll(200); | |
}); | |
</script> |
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
<VirtualHost *> | |
ServerName hostname.com | |
ServerAlias www.hostname.com | |
DocumentRoot /var/www/hostname.com/htdocs/ | |
DirectoryIndex index.php index.html index.htm | |
<Directory /> | |
Options FollowSymLinks | |
AllowOverride All | |
</Directory> |
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 encryptData($value){ | |
$key = "top secret key"; | |
$text = $value; | |
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); | |
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); | |
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv); | |
return $crypttext; | |
} |
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 convert_to_csv($input_array, $output_file_name, $delimiter) | |
{ | |
/** open raw memory as file, no need for temp files */ | |
$temp_memory = fopen('php://memory', 'w'); | |
/** loop through array */ | |
foreach ($input_array as $line) { | |
/** default php csv handler **/ | |
fputcsv($temp_memory, $line, $delimiter); |
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
s<?php | |
function pluck($nestedArray, $key, $value, $maintainKeys=true){ | |
$func = 'return ($obj["' . $key . '"] == "' . $value . '") ? true : false;'; | |
$callback = create_function('$obj', $func); | |
$filtered = array_filter($nestedArray, $callback); | |
return ($maintainKeys) ? $filtered : array_values($filtered); | |
} | |
$users = [ |
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
var ons = function (n) {return n < 11 || n > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((n - 1) % 10, 3)] : 'th'}; | |
for(var i=1; i <= 100; i++){ console.log(i + '' + ons(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
<?php | |
if (file_exists('vendor/autoload.php')) { | |
$loader = include 'vendor/autoload.php'; | |
} else { | |
throw new Exception('Composer dependencies have not been installed'); | |
} | |
use Zend\EventManager\EventCollection, | |
Zend\EventManager\EventManager; |
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
alias http='python -m SimpleHTTPServer' | |
function featurebranch() { git checkout master && git pull upstream master && git checkout -b "$1"; } | |
function newbox() { git clone [email protected]:djheru/vagrant-template.git "$1"; } | |
function ignore() { git update-index --assume-unchanged "$1"; } | |
function unignore() { git update-index --no-assume-unchanged "$1"; } | |
alias l='ls -lah' | |
alias ..='cd ..' | |
alias snif='phpcs -v -n -p --standard=PSR2 ./' |
OlderNewer