Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mcescalante
mcescalante / instructions.md
Last active July 25, 2023 14:07
Run a Flask application with gunicorn and nginx

This guide assumes:

  • You have a VPS (something like DigitalOcean, Linode, etc.)
  • You have a Flask application and a basic understanding of command line instructions
  • You've got nginx installed and know where your configuration files are

Instructions

  1. First, you should install gunicorn on your box or virtualenv with pip:
@mcescalante
mcescalante / sqlite3json.py
Last active November 27, 2021 20:11
Python SQLite3 INSERT & SELECT for JSON
import sqlite3
import json
conn = sqlite3.connect('test.db')
c = conn.cursor()
# Insert values
c.execute('''insert into data values(?)''', (json.dumps({'test':'test2'}),))
conn.commit()
# Select those values, get them to be json
c.execute('select * from data')
data = c.fetchall()
print data
# Data will print: [(u'{"test": "test2"}',)]
# To load the JSON for python use
for item in data:
print json.loads(item[0])
# Data will print: {u'test': u'test2'}
import sqlite3
import json
conn = sqlite3.connect('test.db')
c = conn.cursor()
# Insert {'test':'test2'} dummy values into database
c.execute('''insert into data values(?)''',(json.dumps({'test':'test2'}),))
conn.commit()
@mcescalante
mcescalante / cx_oracle_install_instructions.md
Last active November 13, 2017 20:46
cx_Oracle installation instructions/notes for macOS or Linux

cx_Oracle Installation Instructions

I've had to put cx_Oracle (python Oracle database connector) on macOS and Linux, and both processes were similar but poorly documented on Oracle's website.

These instructions were written and tested using the client 12.1. The instructions for any 12.x are the same, but you may need to change 12_1 to 12_2 in commands if you are using version 12.2, etc.

Instructions

  1. Download 64 bit (easy to download 32 by mistake) basic + sdk instantclient from Oracle website (Note: you need an account, I used throwaway email)
@mcescalante
mcescalante / keybase.md
Created October 13, 2017 15:06
keybase proof

Keybase proof

I hereby claim:

  • I am mcescalante on github.
  • I am mcescalante (https://keybase.io/mcescalante) on keybase.
  • I have a public key whose fingerprint is 59F6 7311 E003 5EBE 4A0C D3C3 238D 8F30 A94E F114

To claim this, I am signing this object:

@mcescalante
mcescalante / .tmux.conf
Created November 8, 2016 21:07
My OSX/macOS tmux configuration, tested on 10.11.x
#allow mousing
set -g mouse-utf8 on
set -g mouse on
# Return pre-2.1 mousing behaviour
# https://github.com/tmux/tmux/issues/145
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
# Use vim keybindings in copy mode
@mcescalante
mcescalante / gist:7921270
Created December 12, 2013 00:35
Remove punctuation from python list
#Removes all of the punctuation in any item in a list. The characters to be removed are a string, "punctuation" from your list, "list"
list = [''.join(c for c in s if c not in punctuation) for s in list]
@mcescalante
mcescalante / gist:7227148
Created October 30, 2013 04:17
Open manpage and search for string
man foobar | less +/searched_string
@mcescalante
mcescalante / tardaysago.sh
Last active December 25, 2015 02:39
Find files modified since x days ago, tar them
#tar files in current directory modified since 1 day ago
find . -mtime -1 -exec tar --no-recursion -czf name.tgz {} +