Skip to content

Instantly share code, notes, and snippets.

View hramos's full-sized avatar

Héctor Ramos hramos

View GitHub Profile
@hramos
hramos / blocks_do_not_work_like_this_irl.m
Created December 14, 2011 21:55
Compile time check for blocks that is of no use when min. target < 4.0 anyway
#ifdef NS_BLOCKS_AVAILABLE
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
#endif
// background stuff
#ifdef NS_BLOCKS_AVAILABLE
dispatch_sync(dispatch_get_main_queue(), ^(void) {
#endif
// main thread stuff
@hramos
hramos / parse_date_property_object_create.rb
Created December 12, 2011 03:30
Create new Parse object with Date property
APPLICATION_ID = ENV['PARSE_APPLICATION_ID']
MASTER_KEY = ENV['PARSE_MASTER_KEY']
someDateTime = Time.new
ddYear = someDateTime.year
ddMonth = "%02d" % someDateTime.month
ddDay = "%02d" % someDateTime.day
curl_command = "curl --user #{APPLICATION_ID}:#{MASTER_KEY} -X POST -H \"Content-Type: application/json\" -d \'{\"someDate\":{\"__type\": \"Date\", \"iso\": \"#{ddYear}-#{ddMonth}-#{ddDay}T12:00:00.000Z\"},\"someIdentifier\":\"51\"}\' https://api.parse.com/1/classes/MyParseClassObject"
@hramos
hramos / parse_resource_issue_1.rb
Created December 11, 2011 22:44
parse_resource query for PFObject with DateTime column
# Class setup. We already have quite a few rows of data in Parse
# someDate is a DateTime column
# someIdentifier is a String column
class MyParseClassObject < ParseResource::Base
fields :someDate, :someIdentifier
validates_presence_of :someIdentifier
end
MyParseClassObject.where(:someIdentifier => "51").all
@hramos
hramos / checkpush.sh
Created November 2, 2011 17:10
Check Push-enabled app before submission
Via @tapbot_paul https://twitter.com/#!/tapbot_paul/status/91681340344381441
codesign -dvvvv --entitlements - Tweetbot.app
Original:
Ugh freaking provisioning profiles. PSA check your push app with the following. codesign -dvvvv --entitlements - Tweetbot.app
@hramos
hramos / prpitches
Created October 15, 2011 00:07
pr startupweekend pitches
1. stackoverflow-learn-programming-videos/aggr
2. global game geography
3. table-order
4. ?
5. control de energia, gastos energéticos
6. vieques - finanzas, restauración de crédito (needs legal assistance and web dev)
7. miguel - mala experiencia en taxi. incentivos para taxistas dar milla extra (pr lo hace mejor). tweet tip! Twitter Tips. Usar #tags para calcular que taxicabs ganan propinas.
8. imagine it - pasajes virtuales. designer, prog, legal
9. tareas
@hramos
hramos / PFRequest_0.2.15_snippet.m
Created September 27, 2011 03:08
Parse SDK 0.2.15 is blocking main thread when preparing to upload a PFObject with lots of data. Moving this to a background thread avoids UI freeze
// original file: PFRequest.m
- (void)buildAndSignPostBody {
for (NSString *key in self.command.params) {
[self setPostValue:[self.command.params objectForKey:key] forKey:key];
}
// This also ensures that posts are not empty, which would break various things
[self setPostValue:[NSString stringWithFormat:@"i%@", PARSE_VERSION] forKey:@"v"];
<% if current_user.fanpages.include?(fanpage) %>
<%= link_to image_tag("trackstar-selected-icon.png", :width => "24", :height => "24")%>
<% else %>
<%= link_to image_tag("trackstar-unselected-icon.png", :width => "24", :height => "24")%>
<% end %>
<% form_for fanpage do |form| %>
<%= image_submit_tag("trackstar-selected-icon.png") %>
<% end %>
@hramos
hramos / superfeedrgowalla.rb
Created March 5, 2011 16:28
superfeedr lssnr
def parse_superfeedr_checkin
json_response = Hash.new # parse from superfeedr
checkin_url = "" #get from superfeedr
user_id = "" # get from superfeedr
user = User.find(user_id) # else could get username from superfeedr and fetch by_nickname
if user
checkin = user.checkins.find_by_url(checkin_url) || user.checkins.create_with_superfeedr_response(json_response)
end
end
@hramos
hramos / superfeedrgowalla.rb
Created March 5, 2011 16:23
Sample of how to parse superfeedr gowalla checkin objects
def self.create_with_superfeedr_response(json_response)
create! do |checkin|
checkin.activity_url = json_response["activity_url"]
checkin.user_id = json_response["user_id"]
if json_response["object"]
spot_hash = Hash.new
#spot_hash["image_url"] = ?
spot_hash["lat"] = json_response["geo"]["coordinates"][0]
spot_hash["lng"] = json_response["geo"]["coordinates"][1]
spot_hash["name"] = json_response["object"]["title"]