This is a simple TextMate command that allows you to preview the current document you're editing right on Marked editor.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HorizontalPanGestureRecognizer < UIPanGestureRecognizer | |
DirectionPanThreshold = 4 | |
def initWithTarget(target, action: action) | |
super.tap do | |
my_reset | |
end | |
end | |
def touchesMoved(touches, withEvent:event) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
-
hubot image me
query
- The Original. Queries Google Images forquery
and returns a random top result. -
hubot animate me
query
- The same thing asimage 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 byquery
. -
hubot math me
expression
- Calculate the given expression. -
hubot convert me
expression
tounits
- Convert expression to given units.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |