Skip to content

Instantly share code, notes, and snippets.

View rfaisal's full-sized avatar

Faisal Rahman rfaisal

  • Facebook
  • Vancouver, BC
View GitHub Profile
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)
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;
var a = 10;
var b = a + 1;
a = 20;
console.log(b);
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);
/***
* 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
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",
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);
// 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."});
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);
};
{
"user": {
"level": "authenticated",
"userId": "Facebook:892394872"
},
"identities": {
"facebook": {
"userId": "Facebook:892394872",
"accessToken": "CAAHn34BO0R0BAPO...",
"device": "android",