Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
alias cd="pushd $@ > /dev/null" |
<?php | |
class FlashMessages { | |
private $messages = array(); | |
private $now = false; | |
private static $instance = null; | |
private function __construct() { | |
// Save all messages | |
$this->messages = $_SESSION['flash_messages']; |
<? | |
function aes128_cbc_encrypt($key, $data, $iv) { | |
if(16 !== strlen($key)) $key = hash('MD5', $key, true); | |
if(16 !== strlen($iv)) $iv = hash('MD5', $iv, true); | |
$padding = 16 - (strlen($data) % 16); | |
$data .= str_repeat(chr($padding), $padding); | |
return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv); | |
} |
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
/* | |
* RC4 symmetric cipher encryption/decryption | |
* | |
* @license Public Domain | |
* @param string key - secret key for encryption/decryption | |
* @param string str - string to be encrypted/decrypted | |
* @return string | |
*/ | |
function rc4(key, str) { | |
var s = [], j = 0, x, res = ''; |
<?php | |
/* From: http://www.php.net/manual/en/function.str-getcsv.php#88773 and http://www.php.net/manual/en/function.str-getcsv.php#91170 */ | |
if(!function_exists('str_putcsv')) | |
{ | |
function str_putcsv($input, $delimiter = ',', $enclosure = '"') | |
{ | |
// Open a memory "file" for read/write... | |
$fp = fopen('php://temp', 'r+'); | |
// ... write the $input array to the "file" using fputcsv()... | |
fputcsv($fp, $input, $delimiter, $enclosure); |
<?php | |
function parseAttributes($text) { | |
$attributes = array(); | |
$pattern = '#(?(DEFINE) | |
(?<name>[a-zA-Z][a-zA-Z0-9-:]*) | |
(?<value_double>"[^"]+") | |
(?<value_single>\'[^\']+\') | |
(?<value_none>[^\s>]+) | |
(?<value>((?&value_double)|(?&value_single)|(?&value_none))) |
### | |
####### HISTIGNORE ####### | |
### | |
# examples from interwebs, noob dot file notes | |
#export HISTIGNORE='pwd:exit:fg:bg:top:clear' | |
# (if try to erasedups do not ignore things want 2 pune but on OSX it no workie) | |
# ignore things that start with a space, and ignore the exit command | |
#HISTIGNORE='[ \t]*:exit' | |
# some slashdot dudes says | |
#export HISTIGNORE="&:ls:[bf]g:exit:pwd:clear:mount:umount:[ \t]*" |
<?php | |
require_once('/path/to/wordpress/wp-load.php'); | |
require_once('class-wp_post_helper.php'); | |
// initialize | |
$post = new wp_post_helper(array( | |
'post_name' => 'slug' , // slug | |
'post_author' => 1 , // author's ID | |
'post_date' => '2012/11/15 20:00:00' , // post date and time | |
'post_type' => 'posts' , // post type (you can use custom post type) |
#!/bin/bash | |
# | |
# Steam installer for Debian wheezy (32- and 64-bit) | |
# | |
# Place into empty directory and run. | |
# | |
download() { | |
local url="$1" | |
local filename="$(basename "$url")" |