Skip to content

Instantly share code, notes, and snippets.

@m1yag1
m1yag1 / dirwatcher
Last active August 29, 2015 14:16 — forked from kdart/dirwatcher
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
"""
Watch for new downloads in ~/Downloads (or another directory) and take actions.
The actions are determined by the file extension (determining the mime type).
"""
from __future__ import absolute_import
from __future__ import print_function
@m1yag1
m1yag1 / sqlalchemy_dupe_row
Last active August 29, 2015 14:25 — forked from kennyledet/sqlalchemy_dupe_row
SQLAlchemy Duplicate Row
def copy_row(model, row, ignored_columns=[]):
copy = model()
for col in row.__table__.columns:
if col.name not in ignored_columns:
try:
copy.__setattr__(col.name, getattr(row, col.name))
except Exception as e:
print e
continue
@m1yag1
m1yag1 / app.plist
Created November 18, 2015 19:15
launchd template
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>local.IDENTIFIER_HERE.SOMETHING</string>
<key>KeepAlive</key>
<false/>
<key>RunAtLoad</key>
<false/>
from sqlalchemy import create_engine, MetaData
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import sessionmaker
def create_sa_connection(connection):
engine = create_engine(connection, echo=False)
Session = sessionmaker(bind=engine)
return engine, session()
@m1yag1
m1yag1 / one_file_flask.py
Created November 4, 2016 20:28
A one file flask application for trying things out.
# THIS PROJECT IS AN EXAMPLE APP. SOME CODE MAY NOT BE ACTUALLY USEFUL
# FOR DEMONSTRATION PURPOSES ONLY
# YOUR MILEAGE MAY VARY
import os
from flask import (Flask,
Blueprint,
redirect,
@m1yag1
m1yag1 / one_flask.py
Created August 26, 2017 15:43 — forked from mikefromit/one_flask.py
a one file flask app for trying stuff
# THIS PROJECT IS AN EXAMPLE APP. SOME CODE MAY NOT BE ACTUALLY USEFUL
# FOR DEMONSTRATION PURPOSES ONLY
# YOUR MILEAGE MAY VARY
# Requirements are Flask, Flask-WTF, Flask-SQLAlchemy
import os
from flask import (Flask,
Blueprint,
redirect,
@m1yag1
m1yag1 / one_flask_auth.py
Last active May 28, 2021 18:32
A one file example Flask application based on one_flask.py showcasing flask-security for authentication.
# THIS PROJECT IS AN EXAMPLE APP. SOME CODE MAY NOT BE ACTUALLY USEFUL
# FOR DEMONSTRATION PURPOSES ONLY
# YOUR MILEAGE MAY VARY
# Requirements are Flask, Flask-WTF, Flask-SQLAlchemy, bcrypt
import os
from flask import (Flask,
Blueprint,
redirect,
@m1yag1
m1yag1 / tmux.md
Created October 3, 2017 14:01 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@m1yag1
m1yag1 / brew_install.sh
Last active May 19, 2023 15:17
Bash script for installing homebrew
#!/usr/bin/env bash
# This is part of a larger script for setting a mac for python development.
set -e
# Shared functions
pretty_print() {
printf "\n%b\n" "$1"
}
@m1yag1
m1yag1 / tasks.json
Created October 9, 2017 20:07
Business model of a collection of tasks.
{
"DLM": 0,
"attachments-count": 0,
"boardColumn": {
"color": "#0AD2F5",
"id": 12044,
"name": "In Progess"
},
"canComplete": true,
"canEdit": true,