Skip to content

Instantly share code, notes, and snippets.

@wookiecooking
wookiecooking / markdown.js
Created May 14, 2013 06:00
Markdown compiler js
if (typeof markdown === 'undefined') var markdown = {
parse: function (s) {
var r = s, ii, pre1 = [], pre2 = [];
// detect newline format
var newline = r.indexOf('\r\n') != -1 ? '\r\n' : r.indexOf('\n') != -1 ? '\n' : ''
// store {{{ unformatted blocks }}} and <pre> pre-formatted blocks </pre>
r = r.replace(/{{{([\s\S]*?)}}}/g, function (x) { pre1.push(x.substring(3, x.length - 3)); return '{{{}}}'; });
r = r.replace(new RegExp('<pre>([\\s\\S]*?)</pre>', 'gi'), function (x) { pre2.push(x.substring(5, x.length - 6)); return '<pre></pre>'; });
@wookiecooking
wookiecooking / development_server.sh
Last active December 17, 2015 08:09
[WordPress] migration script
#!/bin/sh
#current info
CUR_URL=development.server.com
CUR_DB_HOST=database_host
CUR_DB_NAME=database_name
CUR_DB_USER=database_user
CUR_DB_PASS=database_password
CUR_PATH=/path/to/site/
@wookiecooking
wookiecooking / replace.php
Created May 16, 2013 17:36
[PHP] Search and Replace for MySQL
<?php
/**
*
* Safe Search and Replace on Database with Serialized Data v2.0.1
*
* This script is to solve the problem of doing database search and replace when
* developers have only gone and used the non-relational concept of serializing
* PHP arrays into single database columns. It will search for all matching
* data on the database and change it, even if it's within a serialized PHP
* array.
@wookiecooking
wookiecooking / serve.sh
Created May 17, 2013 02:54
[Bashscript] Starts a basic web server on the port specified.
#!/bin/bash
#
# Starts a basic web server on the port specified.
#
# ./serve.sh 3000 -> http://localhost:3000
#
# Copyright 2012 Eric Bidelman <[email protected]>
port=$1
if [ $# -ne 1 ]
@wookiecooking
wookiecooking / handle_file_upload.php
Created May 17, 2013 03:23 — forked from ebidel/handle_file_upload.php
[PHP] File Upload + Form
<?php
$fileName = $_FILES['afile']['name'];
$fileType = $_FILES['afile']['type'];
$fileContent = file_get_contents($_FILES['afile']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'name' => $fileName,
'type' => $fileType,
'dataUrl' => $dataUrl,
@wookiecooking
wookiecooking / h5bp-twitter-bootstrap
Last active December 17, 2015 10:39 — forked from paulirish/h5bp-twitter-bootstrap
[Bootstrap] Shell script to quickly setup a project using html5boilerplate and twitter bootstrap
#!/bin/sh
echo "
Cool, let's start.
"
src=$PWD
@wookiecooking
wookiecooking / install-php5+nginx.sh
Created May 17, 2013 03:37 — forked from spolu/install-php5+nginx.sh
[Ubuntu] Install PHP5 and NGINX
sudo apt-get install nginx
sudo apt-get install spawn-fcgi
apt-get install php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
@wookiecooking
wookiecooking / gist:5596758
Last active December 17, 2015 10:39 — forked from eric1234/gist:4384588
[PHP] Check PHP for errors
find ./ -name \*.php | xargs -n 1 php -l
@wookiecooking
wookiecooking / lamp_wp.sh
Created May 17, 2013 08:15
[Ubuntu] Install LAMP + WordPress
sudo apt-get update
sudo apt-get install lamp-server
sudo apt-get install git
cd /var/www/
sudo wget http://wordpress.org/latest.tar.gz
sudo tar -zxvf latest.tar.gz && mv wordpress/* . && rmdir wordpress
sudo rm index.html
@wookiecooking
wookiecooking / loadgist.js
Created May 17, 2013 08:23
[JS] Ajax'd Load Gist
// Prompts to http://stackoverflow.com/users/592125/forresto
function loadgist(gistid) {
$.ajax({
url: 'https://api.github.com/gists/' + gistid,
type: 'GET',
dataType: 'jsonp'
}).success(function(gistdata) {
// This can be less complicated if you know the gist file name