Skip to content

Instantly share code, notes, and snippets.

@kampfgnu
kampfgnu / renameImageCaptureImportedFilesToDate.sh
Last active October 8, 2018 15:09
rename files to their creation date
cd $1
for file in *.{JPG,jpg}
do date=$(stat -f %B $file)
dateFormatted=$(date -r $date +%Y-%m-%d' '%H.%M.%S)
mv $file "$dateFormatted.jpg"
done
for file in *.{MOV,mov}
do date=$(stat -f %B $file)
@kampfgnu
kampfgnu / convertPDFToPNG3x.sh
Created March 4, 2018 09:52
convert vector pdf to iOS image assets
#!/bin/bash -e
# convert vector pdf to iOS image assets
# copy this script to the folder where the pdf files live and run "./convertPDFToPNG3x.sh" in terminal.
# this will generate [filename]@3x.png, [filename]@2x.png and [filename].png images in the same folder
# Ensure we're running in location of script.
cd "`dirname $0`"
@kampfgnu
kampfgnu / git_remove_large_file
Created February 27, 2017 14:42
remove already commited large file from git history
git filter-branch --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch MY-BIG-DIRECTORY-OR-FILE' --tag-name-filter cat -- --all
#!/usr/bin/python
# batch conversion: convert all .wav files in sourceFolder and its subfolders to mp3 or aifc.
# e.g. python convertAudioFiles.py sourceFolder destinationFolder 0
import sys
import os
from glob import glob
from subprocess import call
import shlex
@kampfgnu
kampfgnu / extractAudioFromMp4.py
Last active February 24, 2017 21:23
extract audio from mp4 movie and save as mp3 (using ffmpeg)
#!/usr/bin/python
# batch conversion: extract audio from all mp4's in sourceFolder and its subfolders and save as mp3.
# e.g. python extractAudioFromMp4.py sourceFolder destinationFolder
import sys
import os
from glob import glob
from subprocess import call
import shlex
@kampfgnu
kampfgnu / resizer3x
Created May 15, 2016 09:22
batch resize @3x iOS image assets to @2x and @1x
#!/bin/bash -e
# batch resize @3x iOS image assets to @2x and @1x
# copy this script to the folder where the @3x images files live and run "./resizer3x.sh" in terminal.
# this will generate [filename]@2x.[extension] and [filename].[extension] images in the same folder
# Ensure we're running in location of script.
cd "`dirname $0`"
@kampfgnu
kampfgnu / mkvextractTracks.sh
Last active March 13, 2024 05:19
batch extract subtitles from mkv files
#!/bin/bash -e
# a script that extracts the subtitle file of every mkv movie file and saves it with the same name
# copy to the folder where the mkv files live and run "./mkvextractTracks.sh" in terminal
# options: [trackID]
# example: ./mkvextractTracks.sh 1
#
# info:
# mkvextract is used to extract the subtitles, so mkvtoolnix app (which contains the mkvextract binary) is used:
# https://mkvtoolnix.download/downloads.html
objStringFromBufferGeometry: function (geom) {
var s = '';
var geometry = new THREE.Geometry().fromBufferGeometry( geom );
for (var i = 0; i < geometry.vertices.length; i++) {
var vertex = geometry.vertices[i];
s += 'v '+ vertex.x + ' ' + vertex.y + ' '+ vertex.z + '\n';
}
for (var i = 0; i < geometry.faces.length; i++) {
s += 'f '+ (geometry.faces[i].a+1) + ' ' + (geometry.faces[i].b+1) + ' ' + (geometry.faces[i].c+1);
@kampfgnu
kampfgnu / javascript function to open save dialog of browser to save text to a file
Created August 28, 2015 13:38
javascript function to open save dialog of browser to save text to a file
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'Untitled.obj'
import maya.cmds as cmds
import maya.mel as mel
mopathCurve=cmds.ls(sl=True)
for pathCurve in mopathCurve:
print cmds.arclen(mopathCurve)
cmds.select(pathCurve+'.cv[*]')
pathCvs=cmds.ls(sl=True, fl=True)