Skip to content

Instantly share code, notes, and snippets.

View ericktai's full-sized avatar

Erick Tai ericktai

View GitHub Profile
class User < ApplicationRecord
has_many :posts
has_many :comments
# id :integer not null, primary key
# name :string(50) default("")
end
@ericktai
ericktai / ios-geo.md
Created February 19, 2013 21:22
StackMob ios geolocation

Just want the full project? Download Source Code

Objective

Query and return all objects based on their distance from a specified GeoPoint.

Experience Level

Beginner

Estimated time to complete

@ericktai
ericktai / stackmob_oauth2_signing.php
Created December 7, 2012 18:53
OAuth 2.0 in PHP
<?php
namespace Stackmob;
require_once("OAuth.php");
/**
* Many thanks to jobiwankanobi@github and dancali@github for helping each other produce this StackMob OAuth 2.0 Signing PHP example.
*
* This code generates the value of the "Authorization" header to be passed on each request after a user signs in.
* The accessToken is returned from the OAuth 2.0 login request.
*
@ericktai
ericktai / init.js
Created June 15, 2012 18:28
OAuth 2.0 init for the JS SDK
StackMob.init({
appName: '',
clientSubdomain: '',
publicKey: '',
apiVersion: 0
});
@ericktai
ericktai / ChainedCalls.js
Created May 31, 2012 21:52
Chained Calls
/*
For chained functions, simply call the second, third, fourth functions in the "success" callbacks
Callbacks: http://www.stackmob.com/devcenter/docs/Javascript-SDK-API#a-success
These calls will execute in order 1 by 1, not simultaneously.
*/
var user = new StackMob.User({ username: 'chucknorris', password: 'myfists' });
user.login(false, {
@ericktai
ericktai / forgot_password_fix.js
Created May 22, 2012 19:38
Forgot Password fix for JS SDK 0.2.1
StackMob.User = StackMob.User.extend({
forgotPassword : function(options) {
options = options || {};
options['data'] = options['data'] || {};
//fixed the following line. It used to be options['data'][StackMob.loginField]
options['data']['username'] = this.get(StackMob.loginField);
(this.sync || Backbone.sync).call(this, "forgotPassword", this, options);
}
});
@ericktai
ericktai / Init.js
Created May 7, 2012 19:59
Custom User Schema and Fields in JS SDK 0.2.1 and below
/*
These instructions are for JS SDK Version 0.2.1 and below on how to add
custom user object with custom login/password fields. You have to let the
JS SDK know what your primary key and password field is, so we'll do that here.
*/
//Let StackMob know what your username/pw fields are
StackMob.init({
appName: ...,
clientSubdomain: ...,
@ericktai
ericktai / Count.js
Created May 5, 2012 00:07
JS New SDK Features May 2012
var users = new StackMob.Users();
users.count(null, {
success: function(count) {
//count is an integer representing number of all users
}
});
@ericktai
ericktai / sendbinary.html
Created April 24, 2012 19:56
Send Binary File with StackMob
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript" src="http://static.stackmob.com/js/json2-min.js"></script>
<script type="text/javascript" src="http://static.stackmob.com/js/underscore-1.3.0-min.js"></script>
<script type="text/javascript" src="http://static.stackmob.com/js/backbone-0.5.3-min.js"></script>
<script type="text/javascript" src="http://static.stackmob.com/js/stackmob-js-0.1.1-min.js"></script>
<script type="text/javascript">
@ericktai
ericktai / forgot_password.java
Created April 13, 2012 00:43
Forgot and Reset Password for the JS SDK
StackMobCommon.getStackMobInstance().forgotPassword("johndoe", new StackMobCallback() {
@Override public void success(String response) {
//forgotPassword succeeded
}
@Override public void failure(StackMobException e) {
//forgotPassword failed
}
});