Skip to content

Instantly share code, notes, and snippets.

@michaelkarrer81
michaelkarrer81 / change_db_owner.sh
Last active August 29, 2015 14:09 — forked from gingerlime/change_db_owner.sh
Change Owner of Postgres DB
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script set ownership for all table, sequence and views for a given database
Credit: Based on http://stackoverflow.com/a/2686185/305019 by Alex Soto

Odoo - Rename an addon without losing data

Rename addon

  • Change __openerp__.py addon name field
  • Change README.rst file
  • Change translations files (i18n folder, .po and .pot files)
@michaelkarrer81
michaelkarrer81 / git_tricks
Last active January 31, 2019 20:37
[GIT Installation and Configuration] Git installation and configuration options #git
#!/usr/bin/env bash
# https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407#.3o6drt47o
# http://blogs.atlassian.com/2013/03/git-submodules-workflows-tips/#scenarios
# http://stackoverflow.com/questions/2144406/git-shallow-submodules
# -----------------
# INSTALL AND SETUP
# -----------------
# https://github.com/bobthecow/git-flow-completion/wiki/Install-Bash-git-completion
@michaelkarrer81
michaelkarrer81 / bash4-tricks.sh
Created November 2, 2015 09:34
Bash 4 Tricks
#!/usr/bin/env bash
#http://mywiki.wooledge.org/BashFAQ/001
#psql -d intdadi_demo -t --field-separator-zero --quiet --single-transaction --set AUTOCOMMIT=off --set ON_ERROR_STOP=on --no-align -c 'SELECT code, iso_code from res_lang'
# ATTENTION: This IS a generic solutions since the IFS delimiter NULL is used :)
# HINT: Sice we use a save NULL as the delimiter between fields we have to use read -d '' for all fields but the
# last one of one record. The last field in the record will havae a newline after it and therefore starts the
@michaelkarrer81
michaelkarrer81 / post-receive
Created December 3, 2015 07:59 — forked from sergeylukin/post-receive
Git hook (post-receive): update working tree on PUSH
#!/bin/sh
#
# This hook is placed in Bare repository and it updates Working tree whenever a PUSH
# is executed
#
# Assuming following file structure:
# .
# |-- myproject
# |-- myproject.git
# set WORKTREE=../myproject
@michaelkarrer81
michaelkarrer81 / saltstack.sh
Last active March 29, 2022 08:41
[Saltstack Cheat Sheet] #saltstack
# ============
# COMMON TASKS
# ============
# Run state.sls file on minion(s)
salt -G 'os:Ubuntu' state.apply ubuntu1401 # Formula file name without .sls at the end
salt -G 'os:Ubuntu' state.apply ubuntu1401 test=True # Test only (dryrun)
salt -G "minion_roles:ONLINE" state.apply execute_script_example pillar='{"single_instance_update": "aiat"}'
# Webhook state.sls example
@michaelkarrer81
michaelkarrer81 / sample.conf
Created January 18, 2016 10:45 — forked from renoirb/sample.conf
Salt stack master to use remote git for both pillar and state files
##
## Use-case: Host in a remote git (on a ssh-able host) both pillars and states on Salt Stack 0.17.x
##
## See thread: https://groups.google.com/forum/#!topic/salt-users/bOz2cdY-pnY
#
# Salt stack master and minion procedure, short version:
#
# - On the Master:
#
# wget -O - http://bootstrap.saltstack.org | sudo sh -s -- -M git v0.17.0
@michaelkarrer81
michaelkarrer81 / Howto convert a PFX to a seperate .key & .crt file
Created July 14, 2016 08:59 — forked from TemporaryJam/Howto convert a PFX to a seperate .key & .crt file
How to convert a .pfx SSL certificate to .crt/key (pem) formats. Useful for NGINX
source: http://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/
`openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]`
What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.
Now let’s extract the certificate:
`openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]`
@michaelkarrer81
michaelkarrer81 / retain.conf
Last active November 9, 2016 12:54
Nginx retain query!
location /some/location {
# check, if any query strings are available
if( $args = '' ) {
# no query found, so...
return 301 /destination/url/;
}
# if it reaches here, then query is found, so...
return 301 /destination/url/?$args;
}
@michaelkarrer81
michaelkarrer81 / happy_git_on_osx.md
Created December 13, 2016 08:26 — forked from trey/happy_git_on_osx.md
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "you@example.com"