Skip to content

Instantly share code, notes, and snippets.

View williameliel's full-sized avatar
💭
annoying-a

William Garcia williameliel

💭
annoying-a
View GitHub Profile
@williameliel
williameliel / remove emojis
Created June 12, 2014 15:16
Remove Emojis from Instagram/Twitter/Facebook API responses
function remove_emoji($text) {
$clean_text = "";
// Match Emoticons
$regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
$clean_text = preg_replace($regexEmoticons, '', $text);
// Match Miscellaneous Symbols and Pictographs
$regexSymbols = '/[\x{1F300}-\x{1F5FF}]/u';
@williameliel
williameliel / gist:e2e7d051cb5a2663b814
Created May 26, 2015 14:29
Restore MySQL - Ubuntu
#!/bin/bash
if [[ ! "$(/usr/sbin/service mysql status)" =~ "start/running" ]]
then
/usr/sbin/service mysql start
fi
@williameliel
williameliel / gist:cb612466711203280332
Created June 1, 2015 16:45
Purge Varnish on Save
function varnish_purge($post_id)
{
$hostname = 'localhost';
$port = 80;
$URL = get_permalink( $post_id );
$debug = false;
// $finalURL = sprintf(
// "http://%s:%d%s", $hostname, $port, $URL
// );
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div id="tweet"></div>
FastCGI caching directives
fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=WORDPRESS:30m inactive=30m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_lock on;
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_cache_valid 5m;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
server {
##DM - uncomment following line for domain mapping
#!/bin/bash
if [ -z $1 ]
then
echo "Enter commit message"
exit 1;
fi
middleman build
git add -A
git commit -am "$1"
git push
@williameliel
williameliel / export.sh
Created December 14, 2015 17:53
Export all MYSQL Databases individual files
#!/bin/bash
USER="zend"
PASSWORD=""
#OUTPUT="/Users/rabino/DBs"
#rm "$OUTPUTDIR/*gz" > /dev/null 2>&1
databases=`mysql -u $USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
@williameliel
williameliel / gist:ce5131182f7c3b9d918a
Created March 22, 2016 16:01
Add IP to apache log -varnish
default_vcl add to vcl_recv func
if (req.restarts == 0) {
if (req.http.X-Forwarded-For) {
set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
}
@williameliel
williameliel / install-redis.sh
Created May 23, 2016 00:47 — forked from dstroot/install-redis.sh
Install Redis on Amazon EC2 AMI
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://raw.github.com/gist/2776679/04ca3bbb9f085b192f6aca945120fe12d59f15f9/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"