This file contains hidden or 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 Solution(object): | |
| def countSmaller(self, nums): | |
| """ | |
| :type nums: List[int] | |
| :rtype: List[int] | |
| """ | |
| idx = [0 for x in range(len(nums))] | |
| for i in range(len(nums)): | |
| idx[i] = (nums[i], i) | |
This file contains hidden or 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
| var a = Rx.Observable.create(function(observer) { | |
| setInterval(function() { | |
| var curA = Math.floor((Math.random() * 100) + 1); | |
| console.log("Current value of a " + curA); | |
| observer.onNext(curA); | |
| }, 3000); | |
| }); | |
| var b = 0; | |
| a.subscribe(function(val) { | |
| b=val+1; |
This file contains hidden or 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
| var a = 10; | |
| var b = a + 1; | |
| a = 20; | |
| console.log(b); |
This file contains hidden or 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
| MobileServiceClient.prototype.uploadBlob=function(blob, sasUrl, callBack){ | |
| var xhr = Titanium.Network.createHTTPClient(); | |
| xhr.setTimeout(this.REQUEST_TIMEOUT); | |
| xhr.onload=function() { | |
| var o = JSON.parse(this.responseText); | |
| if(o && o['error']) callBack(o['error'],null); | |
| else callBack(null,o); | |
| }; | |
| xhr.onerror= function(e) { | |
| callBack(e,null); |
This file contains hidden or 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
| /*** | |
| * Handles uploading an image to a specified url | |
| */ | |
| class ImageUploaderTask extends AsyncTask<Void, Void, Boolean> { | |
| private String mUrl; | |
| public ImageUploaderTask(String url) { | |
| mUrl = url; | |
| } | |
| @Override |
This file contains hidden or 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
| var async = require('async'), | |
| https = require('https'), | |
| querystring = require('querystring'), | |
| jwt = require('../shared/jwt'), | |
| crypto = require('crypto'), | |
| app_db = [{ | |
| app_id: "1415462058699647", | |
| app_secret: "can-be-used-for-additional-security" | |
| }, { | |
| app_id: "536422093082909", |
This file contains hidden or 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
| var https = require('https'), | |
| querystring = require('querystring'), | |
| jwt = require('../shared/jwt'), | |
| user_db = [{ | |
| user_name: "rfaisal", | |
| password: "123456", | |
| user_id: "8798af78d" | |
| }]; | |
| exports.register = function (api) { | |
| api.post('self', self); |
This file contains hidden or 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
| // call: /api/encrypt?app_secret=my_app_secret&access_token=my_access_token | |
| var crypto = require('crypto'); | |
| exports.get = function(request, response) { | |
| if(request.query.access_token && request.query.app_secret){ | |
| var cipher = crypto.createCipher('aes256', request.query.app_secret); | |
| var encrypted = cipher.update(request.query.access_token, 'utf8', 'hex') + cipher.final('hex'); | |
| response.send(statusCodes.OK,{"encrypted_access_token":encrypted}); | |
| } | |
| else{ | |
| response.send(statusCodes.INTERNAL_SERVER_ERROR,{"error":"both app_secret and access_token is required."}); |
This file contains hidden or 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
| var async = require('async'), | |
| https = require('https'), | |
| querystring = require('querystring'), | |
| jwt = require('../shared/jwt'), | |
| crypto = require('crypto'), | |
| app_secret = 'CH..'; // get it from foursquare | |
| exports.register = function (api) { | |
| api.post('foursquare', foursquare); | |
| }; |
This file contains hidden or 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
| { | |
| "user": { | |
| "level": "authenticated", | |
| "userId": "Facebook:892394872" | |
| }, | |
| "identities": { | |
| "facebook": { | |
| "userId": "Facebook:892394872", | |
| "accessToken": "CAAHn34BO0R0BAPO...", | |
| "device": "android", |
NewerOlder