Skip to content

Instantly share code, notes, and snippets.

View Fintan's full-sized avatar

Fintan Fintan

View GitHub Profile
import bpy
import random
import mathutils
def rnd(fromVal, toVal):
return random.randrange(fromVal, toVal) + random.random()
def ranVec(fromVal, toVal):
x = rnd(fromVal, toVal);
@Fintan
Fintan / add_cam_track_to_cube.py
Created February 2, 2019 22:22
add tracking camera at cursor in Blender
import bpy
cursorLoc = bpy.context.scene.cursor_location
# create camera at cursor
cam = bpy.data.cameras.new("Camera")
cam_ob = bpy.data.objects.new("Camera", cam)
cam_ob.location = cursorLoc
# add to default collection
@Fintan
Fintan / switch_camera.py
Created January 25, 2019 20:09
Randomly switch camera in the Blender viewport
import bpy
import random
objects = bpy.context.selectable_objects;
cameras = []
for obj in objects:
if type(obj.data) == bpy.types.Camera:
cameras.append(obj)
const pathTypes = {
SIMPLE: 'ends_with_simple_attribute',
ARRAY: 'ends_with_array',
ARRAY_ITEM: 'ends_with_array_item',
ATTR_ON_ARRAY_ITEM: 'ends_with_attribute_on_array_item'
};
function getPathType(path) {
let type;
if(/[[0-9]].[\w]*$/.test(path)) {
@Fintan
Fintan / cdn_script_loader.js
Created August 29, 2018 08:29
load CDN libraries with fallback options
/**
* Asynchronously loads a script
* A src with fallback/s, can be defined as an array of paths.
*
* @param src {String|Array<String>} the script to load
* @param containerEl {HTMLElement} element to append script tag
* @return {Promise}
*/
const loadScript = ({ src, containerEl }) => {
let srcs;
@Fintan
Fintan / directory_contents.sh
Last active November 2, 2017 15:19
output the contents of the current directory in a single space delimited string
contents=''; for entry in ./*; do contents+=" $entry"; done; echo "$contents"
@Fintan
Fintan / gist:f2e784140b3dbdf2124f6c976d5e6e43
Created November 2, 2017 15:01
output the contents of the current directory in a single space delimited string
str=''; for entry in ./*; do str+=" ./$entry"; done; echo "$str"
@Fintan
Fintan / commands.sh
Created November 1, 2016 11:15
Useful commands
#get a list of all files in a directory with a recursive search. Show ful file path and file size in order of size
find . -type f -exec ls -lh {} \;| awk '{print $6, $10}' | sort -n
To use alternate credentials for a single operation, use the --username and --password switches for svn.
To clear previously-saved credentials, delete ~/.subversion/auth. You'll be prompted for credentials the next time they're needed.
These settings are saved in the user's home directory, so if you're using a shared account on "this laptop", be careful - if you allow the client to save your credentials, someone can impersonate you. The first option I provided is the better way to go in this case. At least until you stop using shared accounts on computers, which you shouldn't be doing.
To change credentials you need to do:
@Fintan
Fintan / TTS.sh
Last active July 27, 2016 18:54
Create voice recordings of text with Ubuntu
#dependencies
sudo apt-get install libttspico-utils
sudo apt-get install ffmpeg
#generate wav from text
pico2wave -w=out.wav -l=en-GB "Hello there"
#convert wav to mp3
ffmpeg -i ./out.wav -b:a 160k -metadata artist=homebrook ./out.mp3 -y