Skip to content

Instantly share code, notes, and snippets.

import psutil, os, json
def get_folders(path):
if os.access(path, os.X_OK) == True:
files_and_folders = os.listdir(path)
folders = []
for f in files_and_folders:
if f[0] not in ['.','~']:
full_path = path+'/'+f
if os.path.isdir(full_path) == True:
@davidjmerritt
davidjmerritt / Minecraft Overviewer Hash Tag Marker
Created January 24, 2016 01:19
For use with Minecraft Overviewer. This method will look for "#tags" in your in-game signs. For example: "Here is my chest full of #gold." This will populate your Minecraft overviewer.py map with a gold.png.
def customSignFilter(poi):
import re
if poi['id'] == 'Sign':
text_list = [poi['Text1'], poi['Text2'], poi['Text3'], poi['Text4']]
tag = None
for i in range(0,len(text_list)):
if text_list[i].find("#") > -1:
text_trunc = text_list[i][text_list[i].find("#"):len(text_list[i])]
if text_trunc.find(" ") > -1:
tag = str(text_trunc[1:text_trunc.find(" ")]).lower()
@davidjmerritt
davidjmerritt / ffmpeg_clip_and_fade.sh
Last active January 31, 2016 08:23
Requires ffmpeg, mediainfo
#!/bin/sh
date_and_time=`date`
input_file=${1}
output_file=${2}
start_second=5
stop_second=25
framerate_in=`mediainfo -i ${input_file} | grep "Frame rate " | awk -F " " {'print $4'}`
[
[0, 0, "air"],
[1, 0, "stone"],
[1, 1, "granite"],
[1, 2, "polished granite"],
[1, 3, "diorite"],
[1, 4, "polished diorite"],
[1, 5, "andesite"],
[1, 6, "polished andesite"],
[2, 0, "grass"],
@davidjmerritt
davidjmerritt / __main__pymclevel.py
Created January 31, 2016 07:57
__main__.py for pymclevel integration.
#!/usr/bin/python
import time, sys, json
import mclevel
def block_dict():
with open("pymclevel/blocks.json") as f:
return json.load(f)
def load_world_data(world_path):
@davidjmerritt
davidjmerritt / exmple_bottle_server.py
Last active February 2, 2016 19:52
Basic example http server using bottle.py
from bottle import route, run, response, request
import sys, os, time, json
# CONVERT DICTONARY TO JSON
def dict_to_json(dict_data,return_type='pretty'):
if return_type == 'pretty':
return json.dumps(dict_data, sort_keys=True,indent=4, separators=(',', ': '))
elif return_type == 'raw':
return json.dumps(dict_data)
@davidjmerritt
davidjmerritt / submenu.html
Created May 4, 2016 15:16
Javascript Option Submenu
<html>
<head>
</head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
</head>
<style>
* {
padding: 0;
margin: 0;
@davidjmerritt
davidjmerritt / multiprocess.py
Last active November 6, 2016 22:22
Python multiprocessing test
#!/usr/bin/python
from multiprocessing import Pool
import time
import urllib
start = time.time()
urls = [
"https://docs.python.org/2/library/urllib.html",
"http://www.nytimes.com",
@davidjmerritt
davidjmerritt / circle_prog.html
Created May 16, 2017 03:18
Multi-state circular progress loader
<html>
<head>
<style>
#my_canvas {
border:3px solid #333;
background-color: rgb(39, 93, 140);
border-radius: 250px;
width:25;
webkit-filter: grayscale(1);
}
@davidjmerritt
davidjmerritt / ffmpeg_clipping.py
Last active July 21, 2017 17:07
A base for programmatically clipping video using FFmpeg.
#!/usr/bin/python
import subprocess, time, os
def run_command(command):
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = p.communicate()[0]
return output[:-1]