Skip to content

Instantly share code, notes, and snippets.

View tjoen's full-sized avatar

Theun Kohlbeck tjoen

View GitHub Profile
@tjoen
tjoen / import_facegen_tri.py
Created April 17, 2018 16:07 — forked from himika/import_facegen_tri.py
.tri file importer for Blender 2.49b 要 pyffi 2.1.10
#!BPY
"""
Name: 'FaceGen TRI (.tri)...'
Blender: 249
Group: 'Import'
Tooltip: 'Load a FaceGen TRI file.'
"""
__author__= "himika"
@tjoen
tjoen / plot_wav.py
Created March 2, 2018 16:17 — forked from leouieda/plot_wav.py
Python code to plot a .wav file
# Load the required libraries:
# * scipy
# * numpy
# * matplotlib
from scipy.io import wavfile
from matplotlib import pyplot as plt
import numpy as np
# Load the data and calculate the time of each sample
samplerate, data = wavfile.read('Clapping.wav')
@tjoen
tjoen / simplestdb.js
Created November 14, 2017 23:19 — forked from josephernest/simplestdb.js
Simplest JSON DB possible in node.js
var DBFILENAME = './myDb.json';
var fs = require('fs'); // filesystem access needed
var myDb = {}; // the DB will be in RAM
try { myDb = JSON.parse(fs.readFileSync(DBFILENAME)); } catch(e) { } // read DB from disk
function serialize() { fs.writeFile(DBFILENAME + '.temp', JSON.stringify(myDb), function(err) { if (!err) { fs.rename(DBFILENAME + '.temp', DBFILENAME); } } ); }
function serializeSync() { fs.writeFileSync(DBFILENAME + '.temp', JSON.stringify(myDb)); fs.rename(DBFILENAME + '.temp', DBFILENAME); }
setInterval(serialize, 60 * 1000); // serialize to disk every minute
process.on('exit', serializeSync); process.on('SIGINT', serializeSync); process.on('SIGTERM', serializeSync); // serialize to disk when process terminates
/*
@tjoen
tjoen / simplestdb.js
Created November 14, 2017 23:19 — forked from josephernest/simplestdb.js
Simplest JSON DB possible in node.js
var DBFILENAME = './myDb.json';
var fs = require('fs'); // filesystem access needed
var myDb = {}; // the DB will be in RAM
try { myDb = JSON.parse(fs.readFileSync(DBFILENAME)); } catch(e) { } // read DB from disk
function serialize() { fs.writeFile(DBFILENAME + '.temp', JSON.stringify(myDb), function(err) { if (!err) { fs.rename(DBFILENAME + '.temp', DBFILENAME); } } ); }
function serializeSync() { fs.writeFileSync(DBFILENAME + '.temp', JSON.stringify(myDb)); fs.rename(DBFILENAME + '.temp', DBFILENAME); }
setInterval(serialize, 60 * 1000); // serialize to disk every minute
process.on('exit', serializeSync); process.on('SIGINT', serializeSync); process.on('SIGTERM', serializeSync); // serialize to disk when process terminates
/*
@tjoen
tjoen / daemon.py
Created November 14, 2017 23:16 — forked from josephernest/daemon.py
Daemon for Python
# From "A simple unix/linux daemon in Python" by Sander Marechal
# See http://stackoverflow.com/a/473702/1422096
#
# Modified to add quit() that allows to run some code before closing the daemon
# See http://stackoverflow.com/a/40423758/1422096
#
# Joseph Ernest, 2016/11/12
import sys, os, time, atexit
from signal import signal, SIGTERM
@tjoen
tjoen / gist:7ca002a556c52fbe42d40ac3a1bbad0f
Created October 14, 2017 22:40 — forked from scarlson/playlist.sh
Bash script to create .m3u playlist files for all mp3s in subdirectories
#!/bin/bash
#
# bash script to create playlist files in music subdirectories
#
# Steve Carlson (steve@scarlson.co)
find . -type d |
while read subdir
do
rm -f *.m3u
@tjoen
tjoen / lazy_jimmy2
Created February 9, 2017 16:59 — forked from zeffii/lazy_jimmy2
# Blender 2.78 (sub 0), Commit date: 2016-09-28 08:41, Hash 0b13b7a
bpy.context.space_data.tree_type = 'SverchCustomTreeType' # Property
bpy.ops.node.new_node_tree() # Operator
bpy.ops.node.add_search(use_transform=True, node_item='9') # Operator
bpy.ops.node.translate_attach_remove_on_cancel(TRANSFORM_OT_translate={"value":(0, 0, 0), "constraint_axis":(False, False, False), "constraint_orientation":'GLOBAL', "mirror":False, "proportional":'DISABLED', "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "texture_space":False, "remove_on_cancel":True, "release_confirm":True}, NODE_OT_attach={}, NODE_OT_insert_offset={}) # Operator
bpy.data.node_groups["NodeTree"].nodes["Random Vector"].count_inner = 28 # Property
bpy.ops.node.add_search(use_transform=True, node_item='130') # Operator
bpy.ops.node.translate_attach_remove_on_cancel(TRANSFORM_OT_translate={"value":(25.
@tjoen
tjoen / README.md
Created April 11, 2016 19:11 — forked from bsergean/README.md
Anti-aliasing (FXAA) with headless-gl and three.js

Aliased

Anti-aliased

Getting the code

@tjoen
tjoen / read-write-file.js
Created October 27, 2015 00:14
Read Write to file with javascript
/// write to file
var txtFile = "c:/test.txt";
var file = new File(txtFile);
var str = "My string of text";
file.open("w"); // open file with write access
file.writeln("First line of text");
file.writeln("Second line of text " + str);
file.write(str);
file.close();
@tjoen
tjoen / gist:74950f3e5dbe70fa567d
Created October 15, 2015 22:33 — forked from kyleondata/gist:3440492
Backbone.js and Handlebars.js example
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<script src="jquery-1.7.2.min.js" ></script>
<script src="handlebars-1.0.0.beta.6.js" ></script>
<script src="underscore-min.js" ></script>
<script src="backbone-min.js" ></script>