This file contains hidden or 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
// (string, swift, bytes, data, buffer, cstring) | |
print("--- using nulTerminated ---") | |
let x : String = "hello" | |
let buf = x.nulTerminatedUTF8 | |
print(buf) | |
print("\n--- using [UInt8] ---") | |
let buf2 : [UInt8] = [UInt8](x.utf8) | |
print(buf2) |
This file contains hidden or 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
#import "JPUtils.h" | |
extern void | |
JPUpdateDelegates(id<JPManagerDelegate,JPDeviceDelegate> aDelegate) | |
{ | |
JPManager *manager = [JPManager sharedManager]; | |
[manager setDelegate:aDelegate]; | |
for(JPDevice *dev in [manager connectedDevices]) | |
{ | |
[dev setDelegate:aDelegate]; |
This file contains hidden or 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
How? | |
~$ which rvm | |
~$ alias | grep 'rvm=' | |
~$ rvm --version | |
rvm 0.1.32 by Wayne E. Seguin ([email protected]) [http://rvm.beginrescueend.com/] | |
This file contains hidden or 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
module Truncate | |
# only add ellipsis on a word boundary, do not break a word | |
def truncate(char_num) | |
# return a new string | |
self.gsub(/((?:.|\n){#{char_num}}[\w.]*)((?:.|\n)*)/) {$2.empty? ? $1 : $1 + '...'} | |
end | |
end | |
class String | |
include Truncate |
This file contains hidden or 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 'net/smtp' | |
require 'rubygems' | |
require 'tlsmail' | |
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE) | |
class GMailer | |
SMTP_ADDR = 'smtp.gmail.com' | |
def initialize(opts = {}) | |
unless opts[:login] && opts[:password] |
NewerOlder