Skip to content

Instantly share code, notes, and snippets.

View zarzax's full-sized avatar

Mark Young zarzax

View GitHub Profile
@zarzax
zarzax / convert_yaml_to_json_locales.rb
Created November 16, 2010 14:00
convert YAML into JSON i18n internationalization locale files
# Transform a YAML i18n local files into JSON object.
# suitable when using Rails YAML for javascript UI translations.
#
# This takes files DIR_ROOT/locale and outputs DIR_ROOT/js/locale
# filenames are determined by YAML filename.
#
# Mark Young @zarzax Nov 2010
#
# Transforms YAML en.yml:
# en:
@zarzax
zarzax / menu_helper.rb
Created November 15, 2010 18:48
provide a current_controller? helper useful in creating menu
#
# A rails helper snippet I find helpful for building main navigation
# when you want to highlight main pages (controllers) when browser
# requests a subpage.
#
# eg. current request '/users/1/edit' but we want to highlight
# the menu link to '/users'. current_page? will be false but
# the current_controller? function will be true
#
!sprite_image_default_width ||= 17px
!sprite_image_default_height ||= 17px
!sprite_image_default_margin ||= 1px
!sprite_image ||= "silk-sprite.png"
//use with image from http://github.com/zarzax/silk-sass-mixin/blob/master/images/silk-sprite.png
// Simplest use: +silk-sprite("icons-32.png", 1)
=silk-sprite(!img, !col, !row = 1, !width = !sprite_image_default_width, !height = !sprite_image_default_height, !margin = !sprite_image_default_margin)
!x = ((!col - 1) * -!width) - ((!col - 1) * !margin)