Skip to content

Instantly share code, notes, and snippets.

View carlessanagustin's full-sized avatar

carles san agustin carlessanagustin

View GitHub Profile
@carlessanagustin
carlessanagustin / postgres-cheatsheet.md
Created February 29, 2016 09:44 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

If run with -E flag, it will describe the underlaying queries of the \ commands (cool for learning!).

Most \d commands support additional param of __schema__.name__ and accept wildcards like *.*

@carlessanagustin
carlessanagustin / get-ip-address.sh
Created March 14, 2016 09:42
Get only the IP address
# method 1
$ echo $(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
# method 2
$ echo $(ip -o -4 addr list eth0 | perl -n -e 'if (m{inet\s([\d\.]+)\/\d+\s}xms) { print $1 }')
#!/usr/bin/env python
"""
Basic script to create an empty python package containing one module
"""
from skeleton import Skeleton, Var
class BasicModule(Skeleton):
"""
Create an empty module with its etup script and a README file.
@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
  • 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