Skip to content

Instantly share code, notes, and snippets.

if [ -z "`ps -e | grep ssh-agent`" ] ; then
ssh-agent /bin/bash
ssh-add ~/.ssh/id_rsa
fi
ps -e | grep ssh-agent
if [ -z "`ps -e | grep ssh-agent`" ] ; then ssh-agent /bin/bash ; ssh-add ~/.ssh/id_rsa ; fi
cd
./certbot-auto certonly -n --standalone \
-d www.example1.com \
-d www.example2.com \
--expand \
--pre-hook "service nginx stop" \
--post-hook "service nginx start"
# root
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
sudo -i -u postgres
# postgres
createuser # TODO superuser, with password
echo "host all $USERNAME 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf
# root
adduser deploy-user
# ...
visudo
# ...
# deploy-user
sudo apt-get update
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
sudo mkdir -p /var/www/pokemon-go-chat-production.beta.uy
sudo vim /etc/nginx/sites-available/pgc_api_production.conf
# server {
# ...
# location /.well-known/acme-challenge {
# root /var/www/pokemon-go-chat-production.beta.uy;
# }
@charly-vega
charly-vega / gist:2b3c6607a5b6877f09436e91e9660c61
Created July 22, 2016 22:30 — forked from tamoyal/gist:10441108
Create super user and database user in Mongo 2.6
# Create your superuser
$ mongo
> use admin
> db.createUser({user:"someadmin",pwd:"secret", roles:[{role:"root",db:"admin"}]})
> exit
# Alias for convenience (optional and at your own risk)
$ echo 'alias mongo="mongo --port 27017 -u someadmin -p secret --authenticationDatabase admin"' >> ~/.bash_profile
$ source ~/.bash_profile
@charly-vega
charly-vega / login_vs.sh
Created August 6, 2016 22:00
Echo SL virtual server credentials
function login_vs () {
local vs_details=`slcli vs list | grep $1`
vs_details=($vs_details)
vs_id=${vs_details[0]}
local vs_credentials=`slcli vs credentials $vs_id | grep $2`
vs_credentials=($vs_credentials)
echo ${vs_credentials[1]}
}
# via https://docs.docker.com/engine/installation/binaries/#/get-the-linux-binaries
# check docker binaries location first
which docker
wget https://test.docker.com/builds/Linux/x86_64/docker-1.12.2-rc1.tgz
tar -xvzf docker-1.12.2-rc1.tgz
service docker stop
killall docker

Function Composition in Ruby

I'm sure several dozen other people have done this already, but I found it nifty. Often when I'm using the Rails console I do things like this:

Model.find(:all).map(&:something).map(&:others).map(&:size)

Not bad all in all. But, like most good things, it spoils you eventually. Now I want it

-- via https://wiki.postgresql.org/wiki/Shared_Database_Hosting
-- prep template1
-- \c template1 <ROOTUSER>
REVOKE ALL ON DATABASE template1 FROM public;
GRANT ALL ON DATABASE template1 TO rds_superuser WITH GRANT OPTION;
REVOKE ALL ON SCHEMA public FROM public;
GRANT ALL ON SCHEMA public TO rds_superuser WITH GRANT OPTION;