Skip to content

Instantly share code, notes, and snippets.

@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'
@kampfgnu
kampfgnu / gist:5362858
Last active December 16, 2015 02:29
init empty git repo on my ubuntu machine
//server side:
GIT_DIR=project.git git init
cd project.git
git --bare update-server-info
cp hooks/post-update.sample hooks/post-update
//on client side:
git clone ssh://<username>@<remote-git-hostname>/path/to/dir.git
//on first push to master:
@kampfgnu
kampfgnu / rename_git_branch
Created April 24, 2013 08:19
rename git branch
//First, in your working tree, locally rename master to something else.
git branch -m master old-dev
//Renaming a branch does work while you are on the branch, so there's no need to checkout something else.
//Then, locally rename the maintenance branch (2.63-branch) to master:
git branch -m 2.63-branch master
//Now, time to mess with the remote. Just in case you screw up, you might want to make sure you have a current backup. First, //delete the remote's master:
git push origin :master
@kampfgnu
kampfgnu / push_remote_and_upstream
Created April 24, 2013 08:10
push local git branch to remote and set upstream
git push origin <branchname>
git branch --set-upstream <branchname> origin/<branchname>
@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
#!/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 / 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
@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 / gist:12043ae747e06c9dc55c05aa5d49dcc2
Created November 26, 2018 17:21
list size of subfolders larger or equal 1 GB
du -h -d 1 | grep '[0-9]G\>'
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)