Skip to content

Instantly share code, notes, and snippets.

View hramos's full-sized avatar

Héctor Ramos hramos

View GitHub Profile
@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 / 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 / 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 / blocks_irl.m
Created December 14, 2011 21:57
reality
if (dispatch_async != NULL) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
// background stuff
dispatch_sync(dispatch_get_main_queue(), ^(void) {
// main thread stuff
});
});
} else {
// use your favorite pre-iOS 4 threading code
#import <Foundation/Foundation.h>
#define dispatch_if_available(queue, code) do{ \
if(dispatch_async != NULL) { \
dispatch_async(queue, ^(void) {\
code\
});\
} else {\
code\
}\
} while(0)
@hramos
hramos / parse_resource_test_fail
Created January 22, 2012 18:45
Failing tests on ParseResource
$ rake test
WARNING: 'require 'rake/rdoctask'' is deprecated. Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
at /Users/hramos/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
/Users/hramos/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -I"lib:lib:test" -I"/Users/hramos/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib" "/Users/hramos/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" "test/**/test_*.rb"
Loaded suite /Users/hramos/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
..F.FE.F..........................1st
2nd
.
Finished in 145.559260 seconds.
@hramos
hramos / parse
Created January 8, 2013 01:02
Run the Parse Cloud Code CLI from a root folder with this script. Edit `cloud_code/` to point to your actual Cloud Code subdirectory.
#!/bin/bash
cd cloud_code/ && parse $*
@hramos
hramos / README.md
Last active June 16, 2021 09:34
A middleware module for logging in a Parse.User using Facebook in express.

Parse Cloud Module for managing Facebook Login server side using Express.

To log in, visit https://YOUR_SUBDOMAIN.parseapp.com/login.

Installation

Move main.js and app.js into your cloud/ folder in Cloud Code if it's a new project. If you're already using Express, update your app.js accordingly.

If you already have a Parse Hosting app set up, but you're not using Express yet, add the following to your `main.js:

@hramos
hramos / alexa-skills.controller.js
Last active November 14, 2015 15:07
node-sonos-http-api client for Parse Cloud Code
'use strict';
// controllers/alexa-skills.controller.js
// Based on https://github.com/mattwelch/alexa-sonos/blob/master/sonos.controller.js
// Adapted to use sonos-client.js
// Reference implementation for Alexa Skills Kit service.
// https://developer.amazon.com/edw/home.html#/skills
This file has been truncated, but you can view the full file.
Tweeted: For more structured data was saved, like find it is
Tweeted: for a point with PFQuery queryWithClassName@"Player"; lotsOfWins whereKey@"wins" lessThanOrEqualToNSNumber numberWithInt50; If you apply to
Tweeted: of invalid installations. That is then using the Error Messages When asked to enable access will
Tweeted: method application files productIdentifier the current user accounts might want to handle loading message board. For
Tweeted: the network. If you can remove your class Roles provide a new data about filename collisions.
Tweeted: multiple types of the cache. You can create a "Team Agent", and set to five certificates,
Tweeted: *user, NSError *error) { if (error) { NSLog(@"Everything went fine!"); } blockscallbacks You can be persisted
Tweeted: ID"; In addition, developers can be nil forKey@"skills"; gameScore setObjectNSNumber numberWithInt1337 forKey@"score"; gameScore saveEventua
Tweeted: should be displayed when your validation of user query the current user is offline or failure
Tweeted: