Skip to content

Instantly share code, notes, and snippets.

@jeffhuangtw
jeffhuangtw / SoftKeyboard.java
Last active August 29, 2015 14:27 — forked from felHR85/SoftKeyboard.java
A solution to catch show/hide soft keyboard events in Android http://felhr85.net/2014/05/04/catch-soft-keyboard-showhidden-events-in-android/
/*
* Author: Felipe Herranz ([email protected])
* Contributors:Francesco Verheye ([email protected])
* Israel Dominguez ([email protected])
*/
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import android.os.Handler;
@jeffhuangtw
jeffhuangtw / .js
Created July 30, 2015 02:38
parse duplicate save bug sample code
Parse.Cloud.define("testSave", function(request, response) {
var id = request.params.class1Id;
var query = new Parse.Query('Class1');
query.include('Class2Pointer');
query.get(id).then(function (Class1) {
var Class2 = Class1.get('Class2Pointer');
Class2.set('text', 'snoopy');
// test 1: this will have duplicate save two times
Class2.set('Class1Pointer', Class1);
// test 2: this will save once
@jeffhuangtw
jeffhuangtw / gist:67d2c2a33eeb3c6644ce
Created February 26, 2015 02:30
parse cloud code sample code
Parse.Cloud.beforeSave("Posts", function(request, response) {
if (request.object.existed()) {
return response.success(); // the Post already exist, this must be an Update action
}
// do a query to "Posts" to check the oldest related "Posts" to current user
var query = new Parse.Query("Posts");
query.equalTo("PostUser", Parse.User.current());
query.equalTo("Topic", YOUR_REFERENCED_TOPIC_OBJECT); // assume you are want to reference it by pointer
query.descending("createdAt");
@jeffhuangtw
jeffhuangtw / gist:01ea94bc0cb801f67272
Created February 25, 2015 03:17
Parse.com cloud code to prevent users from making duplicate submissions
Parse.Cloud.beforeSave("Requests", function(request, response) {
var postObj = new Parse.Object("Posts");
postObj.set("objectId", request.object.get("Post_Pointer"));
var query = new Parse.Query("Requests");
query.equalTo("Post_Pointer", postObj);
query.equalTo("Requester", Parse.User.current());
query.first({
success: function(object) {
if (object) {