Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@kafene
kafene / example.php
Last active August 29, 2015 14:04 — forked from tekapo/example.php
wp_post_helper
<?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)
@kafene
kafene / rc4.js
Created July 18, 2014 09:27 — forked from farhadi/rc4.js
rc4 functions in php and javascript
/*
* 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 = '';
###
####### 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
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.

Awesome PHP

A list of amazingly awesome PHP libraries, resources and shiny things.

Composer

<?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);
#!/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")"