Instantly share code, notes, and snippets.

Diego Gangl diegogangl

View GitHub Profile
diegogangl /
Last active Jun 29, 2017
A simple function to get indices around an index "i" in a diamond shape. Returns a list of indices usable for a 2D grid in a flat list.
def get_indices_diamond(i, radius, side):
""" Get indices around i in a diamond shape """
indices = []
indices += [i + j for j in range(radius + 1)]
indices += [i - j for j in range(1, radius + 1)]
for step in range(1, radius):
indices += [i + side * step + j for j in range(radius - (step - 1))]
diegogangl /
Created Mar 25, 2017
Remove dates from jekyll post files using git mv
Remove dates from jekyll post files
This is a small script made to remove dates from jekyll files using
the 'git mv' command.
It expects files to be in the format YYYY-MM-DD-NAME.EXT.
diegogangl /
Created Apr 4, 2016
Change resolution for all scenes in Blender
import bpy
for scene in
scene.render.resolution_x = 1920
scene.render.resolution_y = 1080
diegogangl /
Created Sep 23, 2015
Disable numlock and keep it numeric
# This little beauty turns on the numeric
# keypad and disables the numlock key.
# Requires the numlockx program
sleep 0.5
numlockx on && xmodmap -e "keycode 77 = """
diegogangl /
Created Sep 8, 2015
Helper module for custom icons in Blender API (2.75)
Copyright (C) 2015 Diego Gangl
Created by Diego Gangl. This file is part of Mirage.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
diegogangl / zajalSaveFrames.rb
Created May 11, 2012
A little snippet you can put in your draw function to save every frame to your desktop (or any other path).
View zajalSaveFrames.rb
# Save frames to png images in Zajal 0.3.3
def saveFrames
image = grab_screen
path = '/Users/yourName/Desktop/frame_ ' + frame.to_s() + '.png' path )
diegogangl / zajalAnimation.rb
Created May 11, 2012
A simple animation in Zajal 0.3.3, a circle that grows and shrinks over time.
View zajalAnimation.rb
# Simple animation example
# in Zajal
sizeBase = 0
speed = 0.05
setup do
title "Simple Circle"
framerate 60
smoothing true
diegogangl / ScrolltoBottom.js
Created Apr 26, 2012
Simple function to smooth-scroll to the bottom of the page with a basic ease
View ScrolltoBottom.js
// -------------------------------------------------------------------------------
// Metodo scrollear al final de la pagina
scrollToBottom : function()
var acceleration = 1;
var totalOffset = 0;
var step = 1;
var scrollTimer = setInterval( function()
diegogangl / currentTaxonomy.php
Created Apr 10, 2012
[Wordpress 3.3] I've found that wp_list_categories doesn't highlight the current category if it's a taxonomy term (and you're in a taxonomy archive), this little snippet fixes that.
View currentTaxonomy.php
// Get the term id first
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
$currentTerm = $term->term_taxonomy_id;
// This is how you'd use it in your template
wp_list_categories( array(
'taxonomy' => 'YOUR_TAXONOMY',