Skip to content

Instantly share code, notes, and snippets.

@yuhan0
yuhan0 / auto_annotate.py
Created April 4, 2018 03:51
Adds keyword-argument style parameters to Grasshopper components. Copy and paste this code into an empty GhPython component, it should automatically setup input parameters
"""
Adds annotations to internalized input parameters for all components on the canvas.
using the format `X=Y`. Completely reversible via toggling the `enable` input.
Default enabled types are Boolean, Integer, Number, String, Interval, and Plane,
connect a Value List to the `types` input to enable others.
"""
from Grasshopper.Kernel import Types, Parameters, GH_Component
from Grasshopper.Kernel.Special import GH_ValueList, GH_ValueListItem, GH_ValueListMode
this = ghenv.Component
@stevetrask
stevetrask / sourcetree-reverse
Created July 20, 2015 18:28
Return the file to a previous state in sourcetree
If you want to return the file to a previous state, there are a number of ways to do this.
Option 1:
Right-click the file (in any view) and pick 'Log Selected'. This gives you a history just of that file.
Pick the commit in the list which represents the state at which you want the file to be returned to. So this would be the commit before the changes you wanted to reverse
Right-click this commit and select "Reset To Commit"
Note, you can also do this in the main log view (right-click the file in a commit and pick "Reset To Commit", but it's easier to find the commit you want when you use the file-specific log.
@cormacrelf
cormacrelf / wordcount.vim
Created May 13, 2014 17:04
The best vim status line word count function. Grabs count from g<C-g> output, counts inside visual selections, and only re-runs itself when a buffer is modified, if it hasn't run yet, if we're in visual at all, or if we have changed modes since last run.
function! WordCount()
let currentmode = mode()
if !exists("g:lastmode_wc")
let g:lastmode_wc = currentmode
endif
" if we modify file, open a new buffer, be in visual ever, or switch modes
" since last run, we recompute.
if &modified || !exists("b:wordcount") || currentmode =~? '\c.*v' || currentmode != g:lastmode_wc
let g:lastmode_wc = currentmode
let l:old_position = getpos('.')