Skip to content

Instantly share code, notes, and snippets.

View fragmuffin's full-sized avatar

Peter Boin fragmuffin

  • Melbourne, Australia
  • 02:18 (UTC +10:00)
View GitHub Profile
@fragmuffin
fragmuffin / .gitignore
Last active August 21, 2023 07:10
Python3 Template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# Log files
*.log
@fragmuffin
fragmuffin / gridQuery2.py
Created May 22, 2020 03:11
This one's for Rob
#!/usr/bin/env python
import sqlite3
def create_connection(db_file):
""" create a database connection to the SQLite database
specified by the db_file
:param db_file: database file
:return: Connection object or None
"""
@fragmuffin
fragmuffin / .bashrc
Last active November 6, 2019 14:45
Bash command prompt PS1
#... portion of .bashrc
export GIT_PS1_SHOWDIRTYSTATE=true # staged '+', unstaged '*'
export GIT_PS1_SHOWUNTRACKEDFILES=true # '%' untracked files
export GIT_PS1_SHOWUPSTREAM="auto" # '<' behind, '>' ahead, '<>' diverged, '=' no difference
export GIT_PS1_SHOWSTASHSTATE=true # '$' something is stashed
function __prompt_command() {
local ERRORCODE="$?"
@fragmuffin
fragmuffin / .gitignore
Last active May 9, 2019 00:21
Persistent Object Data
__pycache__
myfile.json
@fragmuffin
fragmuffin / README.md
Last active January 3, 2019 09:13
images for links

Images?

Some forum posts just want a url... I'm hoping pushing images to this gist will host them effectively ;)

@fragmuffin
fragmuffin / README.md
Last active December 30, 2018 01:14
cqparts _render color prop
./test.sh

output is:

FreeCAD 0.17, Libs: 0.17R13522 (Git)
Fasteners workbench Loaded
[
@fragmuffin
fragmuffin / Dockerfile
Last active December 11, 2018 15:02
Reproduce facebook/watchman bug
FROM ubuntu:16.04
# build-time arguments
ARG tester_name=tester
ADD . /code
WORKDIR /code
USER root
RUN bash /code/setup.sh
@fragmuffin
fragmuffin / README.md
Created October 5, 2018 16:47
python function as script

Python Function as Script

This is a quick demonstration of how to create a function that can be used as either:

  • command-line script with parameters, or
  • imported module function

Running in Command-Line

Direct

@fragmuffin
fragmuffin / sync.py
Created July 23, 2018 03:35
Python OS system call with subprocess
import sys
import os
import subprocess
# Set sync source & destination
source_path = "temp/a"
dest_path = "temp/b"
# Sync: source_path -> mountpoint
if sys.platform.startswith('win'):
@fragmuffin
fragmuffin / .gitignore
Last active May 22, 2018 11:45
cqparts part equality and bom discussion
*.pyc