Skip to content

Instantly share code, notes, and snippets.

View geapi's full-sized avatar

Georg Apitz geapi

View GitHub Profile
# stolen from http://github.com/cschneid/irclogger/blob/master/lib/partials.rb
# and made a lot more robust by me
# this implementation uses erb by default. if you want to use any other template mechanism
# then replace `erb` on line 13 and line 17 with `haml` or whatever
module Sinatra::Partials
def partial(template, *args)
template_array = template.to_s.split('/')
template = template_array[0..-2].join('/') + "/_#{template_array[-1]}"
options = args.last.is_a?(Hash) ? args.pop : {}
options.merge!(:layout => false)
def get_bread_crumb(url)
begin
breadcrumb = ''
so_far = '/'
elements = url.split('/')
for i in 1...elements.size
so_far += elements[i] + '/'
if elements[i] =~ /^[0-9]*$/
def get_bread_crumb(request, separator = " » ", breadcrumb = [], so_far = '/')
url = request.respond_to?(:request_uri) ? request.request_uri : request
elements = url.split('/')
elements.each_with_index do |element, i|
is_last = i == elements.size - 1 # whether this is the last item or not
so_far += element + '/' # the URL for this element
breadcrumb << # append this element to the breadcrumb
case element
var findWhat = Lilypad.Folder;
if(this.getPath('selection.firstObject') instanceof Lilypad.File){
var findWhat = Lilypad.File;
}
=>
var findWhat = (this.getPath('selection.firstObject') instanceof Lilypad.File)? Lilypad.File: Lilypad.Folder;
someController = SC.Controller.create({
isTypeCheckCreator: function(type){
return function(name){
return (name.toLowerCase().indexOf(type)!= -1);
}
},
isJPG: this.isTypeCheckCreator('.jpg'),
isPNG: this.isTypeCheckCreator('.png')
valueBinding: SC.Binding.transform(function(value, binding) {
return "how many: %@" .fmt(value);
}).from('MyApp.arrayController.length')
fooBinding: 'MyApp.controller.name',
barBinding: 'MyApp.aryController.length',
value: function() {
return "The array named %@ has length %@".fmt(this.get('foo'), this.get('bar'));
}.property('foo', 'bar').cacheable()
@geapi
geapi / gist:1897925
Created February 24, 2012 05:09
carousel for three button states, see: http://dl.usebar.org/lm/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<title>jCarousel three state button</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<!-- jCarousel library -->
<script type="text/javascript">
(function(g){var q={vertical:!1,rtl:!1,start:1,offset:1,size:null,scroll:3,visible:null,animation:"normal",easing:"swing",auto:0,wrap:null,initCallback:null,setupCallback:null,reloadCallback:null,itemLoadCallback:null,itemFirstInCallback:null,itemFirstOutCallback:null,itemLastInCallback:null,itemLastOutCallback:null,itemVisibleInCallback:null,itemVisibleOutCallback:null,animationStepCallback:null,buttonNextHTML:"<div></div>",buttonPrevHTML:"<div></div>",buttonNextEvent:"click",buttonPrevEvent:"click", buttonNextCallback:null,buttonPrevCallback:null,itemFallbackDimension:null},m=!1;g(window).bind("load.
@trcarden
trcarden / gist:3295935
Created August 8, 2012 15:28
Rails 3.2.7 SSL Localhost (no red warnings, no apache config)
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@millermedeiros
millermedeiros / osx_setup.md
Last active June 26, 2024 22:08
Mac OS X setup

Setup Mac OS X

I've done the same process every couple years since 2013 (Mountain Lion, Mavericks, High Sierra, Catalina) and I updated the Gist each time I've done it.

I kinda regret for not using something like Boxen (or anything similar) to automate the process, but TBH I only actually needed to these steps once every couple years...