Skip to content

Instantly share code, notes, and snippets.

@michaelkarrer81
michaelkarrer81 / img_utils.python
Created May 26, 2021 08:30 — forked from dangtrinhnt/img_utils.python
Autorotate and autoresize images in mass with Python and PIL
#!/usr/bin/env python
"""
File: autorotate.py
Origial Author: Damien Riquet <d.riquet@gmail.com>
Current Maintainer: Trinh Nguyen <dangtrinhnt[at]gmail[dot]com>
Description: This script provides an auto-rotate feature of pictures
USAGE: autorotate.py [-h] [--recursive] directory [directory ...]
positional arguments:
@michaelkarrer81
michaelkarrer81 / remote_dev.py
Created March 23, 2020 14:12 — forked from ilyasProgrammer/remote_dev.py
Remote Debug Odoo in Pycharm Prof
On your remote server, run: pip install cython pydevd
IMPORTANT: Make sure that your computer is visible to server's IP by pinging your computer's IP
AND make port forwarding if necessary
Create debug folder localy using same path as on remote server. Necessary for correct break points work.
Connect remote content for debug:
sshfs bar:/srv/odoo /srv/odoo/
Use this path for mapping.
On your computer, configure a Python Remote Debug in run configurations.
@michaelkarrer81
michaelkarrer81 / cors.nginxconf
Created March 18, 2019 07:57 — forked from pauloricardomg/cors.nginxconf
Nginx configuration for CORS-enabled HTTPS proxy with origin white-list defined by a simple regex
#
# Acts as a nginx HTTPS proxy server
# enabling CORS only to domains matched by regex
# /https?://.*\.mckinsey\.com(:[0-9]+)?)/
#
# Based on:
# * http://blog.themillhousegroup.com/2013/05/nginx-as-cors-enabled-https-proxy.html
# * http://enable-cors.org/server_nginx.html
#
server {
@michaelkarrer81
michaelkarrer81 / diff_freeze.py
Created November 2, 2018 18:34 — forked from qgerome/diff_freeze.py
How to compare or diff 2 pip freeze or 2 requirements.txt in Python
"""
pip install click
"""
import click
import itertools
@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
@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)
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 / 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"

@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 / 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]`