Skip to content

Instantly share code, notes, and snippets.

@rafaelrinaldi
rafaelrinaldi / README.md
Created October 20, 2012 04:45
Command for the native Markdown bundle of TextMate which allows you to preview the current document on Marked.

This is a simple TextMate command that allows you to preview the current document you're editing right on Marked editor.

Installation

  • Go to BundlesBundle EditorShow Bundle Editor (or simply ⌃⌥⌘B):
  • Locate the Markdown bundle then click on it:
  • On the bottom of the window you'll find a plus icon. Click on it then select New Command:
@atog
atog / local_ip.rb
Created November 9, 2012 11:14
Get your local IP address
require 'socket'
def local_ip
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
UDPSocket.open do |s|
s.connect '64.233.187.99', 1
s.addr.last
end
ensure
Socket.do_not_reverse_lookup = orig
@adelevie
adelevie / custom_cell.rb
Created November 17, 2012 18:26
Programmatically customize UITableViewCells in RubyMotion
# code inspired from http://jainmarket.blogspot.com/2009/05/creating-custom-table-view-cell.html
class CustomCell < UITableViewCell
attr_accessor :primaryLabel
attr_accessor :secondaryLabel
def createLabels
@primaryLabel = UILabel.alloc.init
@gregfroese
gregfroese / gist:4124753
Created November 21, 2012 13:04
Posting an image in RubyMotion using BubbleWrap and saving it in Rails
## RubyMotion
imageData = UIImage.UIImageJPEGRepresentation(@image_view.image, 1)
encodedData = [imageData].pack("m0")
data["image"] = encodedData
BW::HTTP.post("http://localhost:3000/upload}", {payload: data}) do |response|
if response.ok?
end
end
1.upto(100) do |i|
puts ''.tap {|output|
output << 'Fizz' if i.modulo(3).zero?
output << 'Buzz' if i.modulo(5).zero?
output << i.to_s if output.empty?
}
end
@colinta
colinta / hozizontal_pan_gesture.rb
Created January 17, 2013 18:49
Only responds to horizontal gestures, within 4 pixels of the starting location.
class HorizontalPanGestureRecognizer < UIPanGestureRecognizer
DirectionPanThreshold = 4
def initWithTarget(target, action: action)
super.tap do
my_reset
end
end
def touchesMoved(touches, withEvent:event)
class MyCustomCell < UITableViewCell
# This method is used by ProMotion to instantiate cells.
def initWithStyle(style_name, reuseIdentifier: reuseIdentifier)
super
stylish
self
end
# A delegate method when the user clicks the Row(it's blue by default)
@jorinvo
jorinvo / commands.md
Last active December 18, 2015 00:09
Scripts um Hubot auf Uberspace zu installieren.Für mehr Infos: http://jorinvogel.wordpress.com/2013/06/02/hubot-auf-uberspace-installieren/
  • hubot image me query - The Original. Queries Google Images for query and returns a random top result.

  • hubot animate me query - The same thing as image me, except adds a few parameters to try to return an animated GIF instead.

  • hubot mustache me url - Adds a mustache to the specified URL.

  • hubot mustache me query - Searches Google Images for the specified query and mustaches it.

  • hubot map me query - Returns a map view of the area returned by query.

  • hubot math me expression - Calculate the given expression.

  • hubot convert me expression to units - Convert expression to given units.

@stefanvermaas
stefanvermaas / app_delegate.rb
Last active March 31, 2016 00:54
To synchronize data between a RubyMotion app and a Rails API I needed a sort of a synchronization helper. This code is a proof of concept for this synchronization helper. It uses RubyMotion and BubbleWrap.
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
# For unit testing the application
return true if RUBYMOTION_ENV == 'test'
# Get the frame for the window
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
# Load all the data from the API
@scottwb
scottwb / Rakefile
Created February 24, 2012 17:21
Rakefile for Middleman with an rsync deploy task.
SSH_USER = 'root'
SSH_HOST = 'www.example.com'
SSH_DIR = '/var/www/html/www.example.com'
desc "Build the website from source"
task :build do
puts "## Building website"
status = system("middleman build --clean")
puts status ? "OK" : "FAILED"
end