Skip to content

Instantly share code, notes, and snippets.

@gerrit
gerrit / gist:67896785094a6ba016fe
Created August 25, 2015 21:07
Sketch Plugin API questions
## Reordering layers
I'm working on a command that creates a rectangle in the background of a text layer (with slightly larger dimensions than the text). For that, I need to manipulate the generated layer's z-order, but couldn’t find anything to that extent in the docs. `group.layers()`, as an `MSArray`, also doesn’t expose methods that could do the trick such as `exchangeObjectWithIndex:withIndex:`.
As a workaround I'm using a [technique lifted from sketch-style-inventory][INV]: calculating the offset of two layers and then doing a bunch of `NSApp.sendAction_to_from('moveForward:', nil, context.doc);` calls. But that seems hacky at best, feels like there should be a proper API for the common usecase of wanting to manipulate z-order of layers (or is there an undocumented way?).
## Expanding frames
The [MSRect docs][MSRECT] have a code example for `expandBy:` that I tried to emulate, but failed, that method doesn’t seem to exist on either `MSRect` or `GKRect`:
getScript = jQuery.getScript;
jQuery.getScript = ( resources, callback )->
deferreds = []
counter = 0
for resource in resources deferreds.push getScript( resource, -> counter++ )
jQuery.when.apply( null, deferreds ).then -> callback && callback();
deps = [
"http://documentcloud.github.com/backbone/backbone-min.js",
#!/usr/bin/env ruby
# encoding: utf-8
# Developed using Ruby 1.9.3, should run under any version of Ruby 1.9
# Create a small command line game in Ruby that does the following:
#
#- Player 1 enters a letter. The program uses the google api to search for that
# letter and outputs the number of search results. - Player 2 adds a letter.
# The program displays the whole series of letters and outputs the number of
@gerrit
gerrit / environment.rb
Created November 10, 2011 18:24
dally errors on heroku cedar stack
require 'active_support/cache/dalli_store23'
config.cache_store = :dalli_store
config.middleware.use ::Radiant::Cache,
:metastore => "memcached://#{ENV['MEMCACHE_SERVERS']}:11211/meta",
:entitystore => "memcached://#{ENV['MEMCACHE_SERVERS']}:11211/body"
@gerrit
gerrit / screensize.rb
Created October 13, 2011 08:03 — forked from matthewtodd/gist:728014
Resize an OSX display with RubyCocoa.
require 'osx/cocoa'
include OSX
class Screen
class << self
def resize(width, height, &block)
new.resize(width, height, &block)
end
end
@gerrit
gerrit / gist:1283690
Created October 13, 2011 08:03 — forked from matthewtodd/gist:728014
Resize an OSX display with RubyCocoa.
require 'osx/cocoa'
class Screen
class << self
def resize(width, height, &block)
new.resize(width, height, &block)
end
end
def initialize(screen = OSX::CGMainDisplayID())
require 'less'
module Jekyll
class Less < Converter
safe true
priority :low
def matches(ext)
ext =~ /less/i
end
==> Downloading http://kernel.org/pub/software/scm/git/git-1.7.3.1.tar.bz2
File already downloaded and cached to /Users/gerrit/Library/Caches/Homebrew
==> make prefix=/usr/local/Cellar/git/1.7.3.1 install
Exit status: 2
http://github.com/mxcl/homebrew/blob/master/Library/Formula/git.rb#L31
==> Environment
HOMEBREW_VERSION: 0.7
HEAD: 09a02645fcf1aa3313f631174016e36917539a6e
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by libvorbis configure 1.3.1, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ ./configure --disable-debug --disable-dependency-tracking --prefix=/usr/local/Cellar/libvorbis/1.3.1
## --------- ##
## Platform. ##
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"