Skip to content

Instantly share code, notes, and snippets.

View dgoguerra's full-sized avatar

Diego Guerra dgoguerra

View GitHub Profile
@dgoguerra
dgoguerra / coredump.md
Last active August 29, 2015 13:56
Generating and viewing core dumps

Enable generating core dumps

The configuration file /proc/sys/kernel/core_pattern defines the default behaviour when a crash occurs. If it contains a single word such as core, a core dump will be generated on the current directory with that name. If the first character of its content is |, then the core file will be piped to a process, such as Apport (|/usr/share/apport/apport %p %s %c).

To enable core dumps for your current terminal session ignoring the default action:

ulimit -c unlimited
@dgoguerra
dgoguerra / www-data-permissions.md
Last active August 29, 2015 14:00
/var/www proper permissions

Add your user to www-data group.

sudo adduser USERNAME www-data

Then, change recursively the ownership of /var/www to your username.

sudo chown USERNAME:www-data -R /var/www
@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
#
@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 / 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.

// 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 / 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 "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

@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 / 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 / oh-my-zsh-install.md
Last active December 16, 2015 22:22
oh-my-zsh installation http://ohmyz.sh/

Installation:

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Once installed, to toggle betwen zsh and bash (default shell in OSX) without uninstalling oh-my-zsh (uninstall_oh_my_zsh), just run the appropriate:

chsh -s /bin/zsh
chsh -s /bin/bash