Skip to content

Instantly share code, notes, and snippets.

tombohub /
Created May 18, 2021
How to save pandas dataframe to MySQL with INSERT IGNORE
This example is for inside the class.
First establish the connection into `self.conn`
def _table_column_names(self, table: str) -> str:
Get column names from database table
tombohub / gist:5653577369b6a22ed7f46fc45a4fe7e2
Created Apr 18, 2021
Database migration using pandas and sqlalchemy
View gist:5653577369b6a22ed7f46fc45a4fe7e2
from sqlalchemy import create_engine
from sqlalchemy.sql.expression import select
db1_uri = 'db_uri_here'
db2_uri = 'db_uri_here'
db1_engine = create_engine(db1_uri)
db2_engine = create_engine(db2_uri)
db1_conn = db1_engine.connect()
tombohub /
Last active Dec 30, 2020
Good python packages to start a project
# environment
pip install pipenv
# development
pipenv install devtool
# better REPL
pipenv install ipython
# reading .env variables
# upgrade pip
pipenv install -U pip
# django
pipenv install django
# environment variables
pipenv install python-decouple
# better shell
## DJANGO REST React Github pages settings
## With Cookies Session authentication
# create Procfile with content:
web: gunicorn server.wsgi
# heroku setup database
pip install dj-database-url
DATABASES['default'] = dj_database_url.config(
conn_max_age=600, ssl_require=True)
# Importing Sqlite to Postgres Heroku Django
python dumpdata --exclude=contenttypes --exclude=auth.permission > datadump.json
# Change to your mysql
# Make sure you can connect on your mysql (permissions,etc)
python migrate
#Exclude contentype data with this snippet in shell
tombohub / tailwind-setup.js
Last active Oct 19, 2020
Tailwindcss installation and setup script for create-react-app
View tailwind-setup.js
* Tailwind installation and setup script
* Installs tailwindcss
* creates src/assets/css folder to hold main.css and tailwind.css
* initializes full tailwind configuration file
* inserts new package.json scripts commands
* NOTE: you have to import main.css in src/index.js
tombohub /
Created Oct 15, 2020 — forked from samueljseay/
ES6 exports / imports cheat sheet
// default exports
export default 42;
export default {};
export default [];
export default (1 + 2);
export default foo;
export default function () {}
export default class {}
export default function foo () {}
tombohub /
Created Oct 5, 2020
Git add commit and push all in one go
git add .
git commit -m "$1"
git push
## usage:
## ./ 'your commit comment here'
tombohub /
Created Aug 7, 2020 — forked from valberg/
Django create thumbnail form ImageField and save in a different ImageField - now with updating!
# Extension of
# Note: image_folder and thumbnail_folder are both a callable (ie. a lambda that does a '/'.join())
class Image(Media):
image = models.ImageField(
thumbnail = models.ImageField(