Skip to content

Instantly share code, notes, and snippets.

View carlessanagustin's full-sized avatar

carles san agustin carlessanagustin

View GitHub Profile
@carlessanagustin
carlessanagustin / add_var_path.sh
Last active April 11, 2016 14:48
Append environment variable PATH with SED
#!/bin/bash
PATHOK="`grep myprog /etc/environment`"
if [ -z $PATHOK ]; then
sed -e '/^PATH/s/"$/:\/usr\/lib\/myprog\/bin"/g' -i /etc/environment
fi
@carlessanagustin
carlessanagustin / sudoers_edit.md
Last active July 9, 2021 19:03
Ways of adding NOPASSWD to /etc/sudoers file

Way 1:

groupadd -r admin
usermod -a -G admin vagrant
cp /etc/sudoers /etc/sudoers.orig
sed -i -e '/Defaults\s\+env_reset/a Defaults\texempt_group=admin' /etc/sudoers
sed -i -e 's/%admin ALL=(ALL) ALL/%admin ALL=NOPASSWD:ALL/g' /etc/sudoers
visudo -cf /etc/sudoers
  • My default:
vim ~/.zshrc
  ZSH_THEME="clean"
  HIST_STAMPS="dd.mm.yyyy"
  • iTerm2 default:
import scrapy
import peewee
import re
import urllib
import cStringIO
from PIL import Image
from playhouse.db_url import connect
db = connect('mysql://root:@127.0.0.1/house')
@carlessanagustin
carlessanagustin / Vagrantfile-minimal.rb
Created May 17, 2016 08:19
Minimal Vagrantfile for ubuntu/trusty64 (14.04 LTS)
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.provider "virtualbox"
config.vm.box = "ubuntu/trusty64"
config.vm.provider "virtualbox" do |vb|
vb.memory = 512
@carlessanagustin
carlessanagustin / Vagrantfile
Last active May 18, 2016 15:29
GNU Health installation script for Fundación Recover
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.provider "virtualbox"
config.vm.box = "ubuntu/trusty64"
config.vm.provider "virtualbox" do |vb|
vb.memory = 512
@carlessanagustin
carlessanagustin / inventory_vars.yml
Created May 26, 2016 09:00
Ansible - Working with inventory variables
- name: 1st
tags: debug
debug: var=hostvars['{{ item }}']['ansible_eth1']['ipv4']['address']
with_items: "{{ groups['master'] }}"
- name: 2nd
tags: debug
debug: var=hostvars['{{ item }}']['ansible_default_ipv4']['address']
with_items: "{{ groups['master'] }}"
@carlessanagustin
carlessanagustin / docker-composeVSansible_playbook.md
Last active May 27, 2016 04:59
Comparison between a docker-compose script and a ansible playbook for launchin a Wordpress stack

docker-compose

wordpress:
 image: wordpress
 links:
   - db:mysql
 ports:
   - 8080:80
@carlessanagustin
carlessanagustin / background_processes.md
Last active May 31, 2016 08:54
Running processes in the background

Running processes in background

nohup

nohup COMMAND [ARG]...
echo $HOME/nohup.out

nohup make > make.log
nohup make > make.log &
@carlessanagustin
carlessanagustin / pssh-howto.md
Last active June 1, 2016 09:12
Running parallel remote command with pssh

Method 1:

If you need to run the same command on multiple servers you can use a very useful tool called pssh. You can install it with Homebrew running:

brew install pssh

Once installed you can run the following command to get the current uptime on multiple server: