Skip to content

Instantly share code, notes, and snippets.

module RubyMotionQuery
module Stylers
class UIPageControlStyler < UIControlStyler
# Your custom styler methods here
def current_page
view.currentPage
end
def current_page=(value)
@mattsgarrison
mattsgarrison / ST7565_Image_Previewer.rb
Created February 9, 2011 22:00
Quick way to previewing what a given image will look like on the ST7565 LCD display.
require 'mini_magick'
image = MiniMagick::Image.open("big_color.jpg")
image.resize"128x64^" #resize but retain aspect ratio
image.depth 1
image.format 'bmp'
image.colorspace 'gray'
image.write "grayscale.bmp"
@mattsgarrison
mattsgarrison / vim_movement_training.vimrc
Created April 21, 2011 13:33
Unbind the cursor keys in insert, normal and visual modes.
for prefix in ['i', 'n', 'v']
for key in ['<Up>', '<Down>', '<Left>', '<Right>']
exe prefix . "noremap " . key . " <Nop>"
endfor
endfor
@mattsgarrison
mattsgarrison / autodj.bookmarklet.js
Created August 23, 2011 20:02 — forked from azoff/autodj.bookmarklet.js
Turntable.fm DJ Script
javascript:(function(g,d,f){if(f)d.info("Session found:",f);else return d.warn("No session found!");var h={check:10,wait:500},b=g.autodj={api:g[f],available:function(a){return b.api.taken_dj_map[a]<0},spot:function(){return b.api.become_dj.data("spot")},become:function(a){b.api.callback("become_dj",a)},waiter:function(a){return function(){return b.available(a)?(b.become(a),a):(d.info("Waiting..."),-1)}},seated:function(a){return b.api.djs[a]&&b.api.djs[a][0]===b.api.myuserid},wait:function(a,c){var e=c!==void 0,
a=a||h.check,c=c||b.spot();b.seated(c)?d.warn("Spot",c,"taken!"):(e&&d.error("Spot",c,"missed. Restarting..."),d.info("Polling @",a,"ms"),b.check(a,b.waiter(c)))},check:function(a,c){setTimeout(function(){var e=c.call(b);e>0?(d.warn("Spot",e,"open..."),setTimeout(function(){b.wait(a,e)},h.wait)):b.check(a,c)},a)}}})(window,console,function(g,d,f,h,b,a,c,e,i,j,k){try{return g(d)[f](h)[b][a][c][e]()[i](j)[k]}catch(l){return null}}(jQuery,".invite_dj","data","events","click",0,"handler","toString","match
@mattsgarrison
mattsgarrison / vim setup
Created August 30, 2011 19:40
vim setup instructions
sudo apt-get install git vim-nox
cd
git clone git@github.com:mattsgarrison/Dotfiles.git
ln -s ~/Dotfiles/vimrc ~/.vimrc
vim
@mattsgarrison
mattsgarrison / date_time.coffee
Created December 28, 2011 16:07 — forked from markbates/date_time.coffee
Example: Rails-style date/time helpers in CoffeeScript (added days)
Number::seconds = ->
@ * 1000
Number::minutes = ->
@seconds() * 60
Number::minute = Number::minutes
Number::hours = ->
@minutes() * 60
@mattsgarrison
mattsgarrison / find_large_files.sh
Created January 5, 2012 05:01
Finding the largest files on your *nix system
find . -size +20000k -exec du -h {} \;
@mattsgarrison
mattsgarrison / bootstrap-paged-navar.js
Created January 12, 2012 14:46
CoffeeScript and JavaScript results to enhance Twitter Bootstrap navbar's "active" tab for multiple pages (essentially supplanting scrollspy).
// Generated Output from CoffeeScript
jQuery(function() {
var a, b, c, d, e;
d = $(".topbar .nav a"), e = [];
for (b = 0, c = d.length; b < c; b++)
a = d[b], e.push(function(a) {
if (window.location.pathname === a.pathname)
return $(a).parent().toggleClass("active")
}(a));
return e
@mattsgarrison
mattsgarrison / _post.html.erb
Created May 9, 2012 15:35
Adding Gists to RefineryCMS-Blog
<%-# This is the default way the file puts post content on the page. %>
<%= @post.body.html_safe %>
<%-# This is the replacement for that line. %>
<%= raw @post.body.html_safe.gsub(/\[gist:(\d+)(\,)(.+)\]/,"<script src='https://gist.github.com/\\1.js?file=\\3'></script>") %>
@mattsgarrison
mattsgarrison / Rakefile
Created June 2, 2012 18:29
RubyMotion Rakefile configured for submitting to the App Store.
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
require 'bubble-wrap'
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'Chatoms'
app.version = "2.0"
app.deployment_target = '5.1'
app.identifier = "com.iconoclastlabs.chatoms"