Skip to content

Instantly share code, notes, and snippets.

View dgoguerra's full-sized avatar

Diego Guerra dgoguerra

View GitHub Profile
@dgoguerra
dgoguerra / instructions.sh
Last active September 3, 2015 10:54
Compile PHP 5.5.28 from source in CentOS 6.5 to be used on Plesk 11.5. Based on http://kb.odin.com/en/118378
# Download source
cd /usr/local/src/
wget http://fr2.php.net/get/php-5.5.28.tar.bz2/from/this/mirror --output-document="php-5.5.28.tar.bz2"
# Untar to php-5.5.28/
tar xjvf php-5.5.28.tar.bz2
yum install libxml2-devel openssl-devel bzip2-devel curl-devel libjpeg-devel \
libpng-devel freetype-devel gmp-devel mysql-devel ncurses-devel unixODBC-devel \
@dgoguerra
dgoguerra / readme.md
Last active August 29, 2015 14:25
Basic UglifyJS usage, installing it in a project (not globally)

Add UglifyJS to the project:

npm install --save-dev uglify-js

Run it through a source file, wich name mangling and compression:

node_modules/uglify-js/bin/uglifyjs input-file.js \
@dgoguerra
dgoguerra / readme.md
Last active August 29, 2015 14:25 — forked from coolaj86/how-to-publish-to-npm.md
NPM publishing notes

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "[email protected]"
npm set init.author.url "http://yourblog.com"

npm adduser

// autoclick the correct squares at 1/10 of a sec...
var interval = setInterval(function() { $('iframe').contents().find('.thechosenone').click(); }, 100);
// stop whenever you want!
clearInterval(interval);
@dgoguerra
dgoguerra / mysql-dump-s3.sh
Last active February 8, 2016 14:04
Dump a MySQL database and upload the compressed output to S3
#!/bin/bash
# File name
readonly PROGNAME=$(basename $0)
# File name, without the extension
readonly PROGBASENAME=${PROGNAME%.*}
# Arguments
readonly ARGS="$@"
# Arguments number
readonly ARGNUM="$#"
@dgoguerra
dgoguerra / ngrok.md
Last active August 29, 2015 14:21
ngrok notes

Open an HTTP tunnel to localhost

To open an HTTP tunnel to localhost on port 80:

ngrok http 80

If the forwarding setup is http://1d3a3ba5.ngrok.io -> localhost:80, access it with the URL http://1d3a3ba5.ngrok.io.

@dgoguerra
dgoguerra / get_nested_obj_property.js
Created May 10, 2015 18:27
Access a nested object property using a string with Lodash / Underscore (or another implementation of the reduce() function)
function getObjProperty(containerObj, str, defaultValueArg) {
var defaultValue = typeof defaultValueArg !== 'undefined' ? defaultValueArg : null;
try {
return _(str.split('.')).reduce(function(obj, key) {
return obj[key];
}, containerObj);
} catch (e) {
return defaultValue;
}
@dgoguerra
dgoguerra / mysql_tables_size.sql
Last active November 24, 2016 13:11
MySQL tables size
-- From: http://stackoverflow.com/a/9620273
-- Change 'SCHEMA_NAME_HERE'
SELECT table_name AS "Tables",
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = 'SCHEMA_NAME_HERE'
ORDER BY (data_length + index_length) DESC;
@dgoguerra
dgoguerra / aws-s3api.sh
Last active May 20, 2016 10:21
Obtain an AWS S3 bucket size
bucket_name="BUCKET_NAME"
aws s3api list-objects \
--bucket $bucket_name \
--region `aws s3api get-bucket-location --bucket $bucket_name --output text` \
--output json \
--query "[sum(Contents[].Size), length(Contents[])]"
@dgoguerra
dgoguerra / vhost.py
Last active August 29, 2015 14:08 — forked from fideloper/vhost.py
#! /usr/bin/python
from sys import argv
from os.path import exists
from os import makedirs
from os import symlink
from os import system
import getopt
#