Skip to content

Instantly share code, notes, and snippets.

View fernandoaleman's full-sized avatar

Fernando Aleman fernandoaleman

View GitHub Profile
# Command to replace php memory limit in php.ini with env var
sed -i "s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i" /etc/php5/php.ini
@fernandoaleman
fernandoaleman / redis-cannot-allocate-memory.txt
Last active March 1, 2023 14:14
redis bgsave failed because fork Cannot allocate memory
Modify /etc/sysctl.conf and add
vm.overcommit_memory=1
Then restart sysctl by:
$ sudo sysctl -p /etc/sysctl.conf
@fernandoaleman
fernandoaleman / auto-install-ruby-with-rbenv.zsh
Last active February 21, 2022 06:38
Auto install ruby with rbenv
# This snippet checks your current directory for a .ruby-version file
# and if it exists, it then checks to see if that version of ruby is
# installed. If not, it will ask you if you want to install it.
#
# Add this snippet to $HOME/.zshrc
# In zsh, the chpwd will run a command every time you change directories.
function chpwd {
# Check if a .ruby-version file exists
if [[ -f "$PWD/.ruby-version" ]]; then
@fernandoaleman
fernandoaleman / clone-git-repo.txt
Last active October 20, 2023 10:37
How to clone git repo with all branches and tags
# Clone repo
git clone --mirror git@github.com/fernandoaleman/app.git app/.git
# Change into app directory
cd app
# Update git config
git config --unset core.bare
# Checkout master branch
@fernandoaleman
fernandoaleman / homebrew-elasticsearch-1.0.2.rb
Created July 21, 2017 15:43
Homebrew Elasticsearch 1.0.2 Formula
require 'formula'
class Elasticsearch < Formula
homepage 'http://www.elasticsearch.org'
url 'https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.0.2.tar.gz'
sha256 '2fc2cd05e5f301ba972c9bf90232b70592568990f526f2634b3a768c4615ad70'
head do
url 'https://github.com/elasticsearch/elasticsearch.git'
depends_on 'maven'
@fernandoaleman
fernandoaleman / install-mongodb-ubuntu1604.md
Last active November 23, 2018 12:39
Install MongoDB on Ubuntu 16.06

Install MongoDB on Ubuntu 16.04

Import MongoDB GPG Key

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5

Add MongoDB apt repository

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
@fernandoaleman
fernandoaleman / node-0.10.48.rb
Last active September 11, 2018 16:21
Install Node 0.10.48 via Homebrew
class Node01048 < Formula
desc "Platform built on V8 to build network applications"
homepage "https://nodejs.org/"
url "https://nodejs.org/dist/v0.10.48/node-v0.10.48.tar.xz"
sha256 "365a93d9acc076a0d93f087d269f376abeebccad599a9dab72f2f6ed96c8ae6e"
revision 2
head "https://github.com/nodejs/node.git", :branch => "v0.10-staging"
bottle do
sha256 "0053425c1c78f3afc8c7b311d7808d4e0f9ff955ec5edcef972529eabdf05856" => :sierra
@fernandoaleman
fernandoaleman / rabbitmq-cluster.sh
Created February 27, 2018 16:30
Create RabbitMQ cluster
#!/bin/bash
set -e
function getHostname()
{
local HOST=''
while test -z "$HOST"
do
read -p "$1 : " HOST
@fernandoaleman
fernandoaleman / install-rabbitmq-ubuntu1604.md
Last active November 21, 2022 04:09
Install RabbitMQ on Ubuntu 16.06

Install RabbitMQ on Ubuntu 16.04

Install Erlang

wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
sudo apt-get update -y
sudo apt-get install -y erlang erlang-nox
@fernandoaleman
fernandoaleman / apache-503-proxy.md
Last active April 16, 2022 21:04
Solving Apache 503 “Service temporarily unavailable” proxy timed out

Error

[Tue Jun 03 22:05:51 2014] [error] (110)Connection timed out: proxy: HTTP: attempt to connect to 127.0.0.1:3000 (127.0.0.1) failed
[Tue Jun 03 22:05:51 2014] [error] ap_proxy_connect_backend disabling worker for (127.0.0.1)
[Tue Jun 03 22:05:52 2014] [error] proxy: HTTP: disabled connection for (127.0.0.1)
[...]

The problem is that the Apache proxy module, recognising that the service was unavailable, stopped redirecting requests to it for one minute.