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
MessagesApplication *imessage = [SBApplication applicationWithURL:[NSURL URLWithString:@"file:///Applications/Messages.app"]]; | |
MessagesTextChat *target = nil; | |
NSString *targetid = @"iMessage;-;"; //append phone or email .. | |
for( MessagesTextChat *chat in [[imessage chats] get]) | |
{ | |
if([[chat.id description] isEqualToString:targetid]) | |
{ | |
target = chat; | |
} | |
} |
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
# via http://jablan.radioni.ca/post/4982485974/parsing-search-query-in-ruby | |
def parse_query s | |
s.scan(/((\S+)\:\s?)?([+-])?(("(.+?)")|(\S+))/).map{|match| | |
Hash[ | |
[nil, :prefix, :plusminus, nil, nil, :phrase, :word].zip(match).select(&:all?) | |
] | |
} | |
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
/* | |
* HQL would look something like this: | |
* | |
* from Person p join fetch p.addresses address | |
* where exists ( | |
* from Address addr left join addr.state st | |
* where addr.personId = p.id | |
* and st.abbreviation = :abbreviation | |
* ) | |
*/ |
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
# RSpec matcher to spec delegations. | |
# | |
# Usage: | |
# | |
# describe Post do | |
# it 'delegates name to Author' do | |
# expect subject.to delegate(:name).to(:author).with_prefix # post.author_name | |
# end | |
# it 'delegates month to creation date' do | |
# expect subject.to delegate(:month).to :created_at |
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
module Attributes | |
def has_attributes(*key_names) | |
key_names.each do |key_name| | |
define_method key_name do | |
instance_variable_get("@attributes")[key_name] | |
end | |
define_method "#{key_name}=" do |value| | |
instance_variable_get("@attributes")[key_name] = value | |
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
# to generate your dhparam.pem file, run in the terminal | |
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
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
module ActiveRecord | |
# Allows embedding of ActiveRecord models. | |
# | |
# Embedding other ActiveRecord models is a composition of the two | |
# and leads to the following behaviour: | |
# | |
# - Nested attributes are accepted on the parent without the _attributes suffix | |
# - Mass assignment security allows the embedded attributes | |
# - Embedded models are destroyed with the parent when not appearing in an update again | |
# - Embedded documents appears in the JSON output |
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 Evacuation < ActiveRecord::Base | |
def self.notify_person_found | |
connection.execute "NOTIFY evac, #{connection.quote 'found person'}" | |
end | |
def self.on_person_found |
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 Evacuation < ActiveRecord::Base | |
def self.notify_person_found | |
connection.execute "NOTIFY evac, #{connection.quote 'found person'}" | |
end | |
def self.on_person_found |
OlderNewer