Skip to content

Instantly share code, notes, and snippets.

@click.command("db-migration")
@with_appcontext
def migrate_schema():
migrations_path = "./migrations"
# find the database 'user_version'
data = get_db()
current_version = data.execute("PRAGMA user_version").fetchone()[0]
# iterate files in schema dir and find right file to start with
@click.command("db-migration")
@with_appcontext
def migrate_schema():
migrations_path = "./migrations"
# find the database 'user_version'
data = get_db()
current_version = data.execute("PRAGMA user_version").fetchone()[0]
# iterate files in schema dir and find right file to start with
open System
open System.IO
open System.Text.RegularExpressions
open System.Linq
open MarkdownDeep
module Seq =
let sortByDesc f s = System.Linq.Enumerable.OrderByDescending(s, new System.Func<'a, 'b>(f))
type Header = {date:DateTime; author:string; title:string; published:bool; layout:string; permalink:string }
#!/bin/bash
SCHEME_DIR=${XDG_CONFIG_HOME:-~/.config}/calico
_create_config_dir() {
if [[ ! -d $SCHEME_DIR ]]; then
mkdir -p $SCHEME_DIR
fi
}
@jeffesp
jeffesp / DockerCleanup.md
Last active September 11, 2018 12:53
Docker Cleanup

Not knowing that docker rm would just skip running containers I came up with the following:

docker ps -a | grep -v "Up" | cut -f 1 -d ' ' | tail -n +2 | xargs docker rm

but the [docker docs][1] say:

docker rm $(docker ps -a -q)

which is probably better as it doesn't depend on inverse grepping for "Up".

@jeffesp
jeffesp / pycon.md
Created November 20, 2017 21:12
Markdown of the PyCon Talk Proposal Form
def get_results(client, session_id):
# First wait on the results to be complete by checking periodically
while True:
current = client.sessions.get(session_id)
if current.status == session.Status.completed or current.status == session.Status.failed:
break
# waiting to not exhaust the call per minute limit on the API
time.sleep(5)
# Then get results and find the model_id that was generated
@jeffesp
jeffesp / JavascriptSingleton.js
Created August 31, 2016 15:14
Javascript Singleton
class Singleton {
static get instance() {
if (!this._instance) {
this._instance = Date();
}
return this._instance;
}
}
import Graphics.Element exposing (..)
import Text
type Tree a
= Empty
| Node a (Tree a) (Tree a)
-- declaring type of function named `empty`
empty : Tree a
function Find-StringInFiles
{
param ([string][PSDefaultValue(Help="*.*")]$files = "*.*", [string]$query )
Get-ChildItem -file -recurse $files | Select-String $query
}