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 / 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 / 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"

If you have a huge repository (in size and in history) and want to add a subfolder
to your project as a submodule you can follow this example to save time and space
using git's shallow clone and shallow checkout feature. It is a bit more complicated
in this example because I assume that you want your submodule to track a non-default
branch, called `mybranch`, instead of the `master` branch. Things could probably get
a lot simpler when using the default branch. After following the commands in these
examples you can use `git submodule update` and `git submodule update --remote` as normal.
@michaelkarrer81
michaelkarrer81 / postgres-cheatsheet.md
Last active February 26, 2024 21:21 — forked from Kartones/postgres-cheatsheet.md
[PostgreSQL command line cheatsheet] #database #postgresql

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@michaelkarrer81
michaelkarrer81 / phantom.py
Created May 25, 2018 08:37 — forked from jsok/phantom.py
Use PhantomJS and Python Selenium bindings to take screenshots of websites.
import StringIO
from selenium import webdriver
from PIL import Image
# Install instructions
#
# npm install phantomjs
# sudo apt-get install libjpeg-dev
# pip install selenium pillow