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
"platform": "cmdSwitch2", | |
"name": "CMD Switch", | |
"switches": [{ | |
"name" : "Projector", | |
"on_cmd": "sudo echo -ne \"* 0 IR 001\r\" > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AL00M6F3-if00-port0", | |
"off_cmd": "sudo echo -ne \"* 0 IR 002\r\" > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AL00M6F3-if00-port0", | |
"state_cmd": ": $(rm ~/.projector;timeout 2s cat < /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AL00M6F3-if00-port0 > ~/.projector & sleep 0.5;sudo echo -ne \"* 0 Lamp ?\r\" > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AL00M6F3-if00-port0; sleep 1.5) && grep 'Lamp 1' ~/.projector", | |
"polling": true, | |
"interval": 5, | |
"timeout": 4000, |
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
devran@ubuntu:~/projects/Hello$ swift | |
Welcome to Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 778f82939c). Type :help for assistance. | |
1> import Foundation | |
2> CG | |
Available completions: | |
CGFloat | |
CGPoint | |
CGRect | |
CGRectEdge | |
CGSize |
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
struct MediaItem { | |
var duration: Int? | |
var title: String? | |
var urlString: String? | |
static func parseM3U(contentsOfFile: String) -> [MediaItem]? { | |
var mediaItems = [MediaItem]() | |
contentsOfFile.enumerateLines({ line, stop in | |
if line.hasPrefix("#EXTINF:") { | |
let infoLine = line.stringByReplacingOccurrencesOfString("#EXTINF:", withString: "") |
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
struct NumberComposition { | |
var value: Int | |
var numbers: [Int] | |
var composition: [Int] { | |
return generateComposition() | |
} | |
init(of value: Int, fromNumbers numbers: [Int]) { | |
self.value = value | |
self.numbers = numbers |
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 'RMagick' | |
include Magick | |
width = 500 | |
height = 500 | |
start_color = "#333" | |
end_color = "#000" | |
fill = Magick::GradientFill.new(0, 0, height, height, start_color, end_color) |
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
# Create a file, call it "Gemfile" and write these 3 lines, then save it: | |
source "https://rubygems.org" | |
gem 'sinatra' | |
gem 'nokogiri' | |
# Run | |
bundle install | |
# from your terminal | |
# Create a file called "app.rb" and paste the follow lines (and run it with "ruby app.rb": |
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
# UPDATED - IT WORKS | |
# Thanks to "kuadrosx"! | |
# #mongoid on chat.freenode.net | |
class Conversation | |
include Mongoid::Document | |
field :name | |
embeds_many :messages, as: :messagable, :class_name => 'ConversationMessage' | |
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
# nslog with message | |
NSLog("Message from watch received: %@", message) | |
2014-02-21 10:47:01.514 OnTelly Remote[1298:60b] Message from watch received: { | |
2 = "<PBNumber 0x1650ba50> { value: 41, width: 4, signed: Y }"; | |
} | |
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
// Objective-C | |
uuid_t myAppUUIDbytes; | |
NSUUID *myAppUUID = [[NSUUID alloc] initWithUUIDString:@"226834ae-786e-4302-a52f-6e7efc9f990b"]; | |
[myAppUUID getUUIDBytes:myAppUUIDbytes]; | |
# Ruby | |
myAppUUIDbytes = Array.new(16, 0) | |
myAppUUID = NSUUID.alloc.initWithUUIDString("226834ae-786e-4302-a52f-6e7efc9f990b") | |
myAppUUID.getUUIDBytes(myAppUUIDbytes) |
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
Teacup::Stylesheet.new(:iphone) do | |
# enable orientations on the root view | |
style do | |
left 0 | |
top 0 | |
width 320 | |
height 480 | |
backgroundColor :lightyellow.uicolor | |
portrait true |