Skip to content

Instantly share code, notes, and snippets.

View achalddave's full-sized avatar

Achal Dave achalddave

View GitHub Profile
@achalddave
achalddave / rm.sh
Last active December 19, 2015 05:49
optimal idiot proofing
function rm {
if [[ "$1" == "-rf" ]] ; then
echo "If you really want to delete this, say 'I may be an idiot'."
read var
if [[ "$var" != 'I may be an idiot' ]] ; then
echo "Nope, you didn't write that correctly"
return
fi
fi
rm "$@"
@achalddave
achalddave / backup.sh
Created April 22, 2013 00:34
Naive Bash Backup
SRCDIR=src
DSTDIR=dst
# copy recursively (-r) updated (-u) files, preserve (-p) attributes if
# possible
$(echo "cp -R -u -p $SRCDIR/* $DSTDIR")
# hack? psh
for file in $(find $DSTDIR/*) ; do
[ ! -e "$SRCDIR/${file#*/}" ] && echo "Removing $file" && rm $file
struct Test {
Point3f x;
void setXStack(float a, float b, float c) {
x = Point3f(a, b, c)
}
void setXHeap(float a, float b, float c) {
x = *(new Point3f(a, b, c));
}
@echo off
C:\Windows\SysWOW64\cmd.exe /c ""C:\Program Files (x86)\Git\bin\sh.exe" --login -i"
@achalddave
achalddave / Snap-SVG-Current.js
Created December 5, 2012 04:28
Current Snap SVG Rasterizing
function readImage(aFile) {
var pic = new Image(),
frd = new FileReader();
while (!target.droppedImage) {
target = target.parent;
}
pic.onload = function () {
canvas = newCanvas(new Point(pic.width, pic.height));
canvas.getContext('2d').drawImage(pic, 0, 0);
target.droppedImage(canvas, aFile.name);
@achalddave
achalddave / designbookmarklet.js
Created July 11, 2012 05:56
A design bookmarklet I picked up somewhere
javascript:function%20fnStartDesign(sUrl){var%20nScript=document.createElement('script');nScript.setAttribute('language','JavaScript');nScript.setAttribute('src',sUrl);document.body.appendChild(nScript);}fnStartDesign('http://www.sprymedia.co.uk/design/design/media/js/design-loader.js');