coding, javascript, nodejs

Parse Server – providing ip of a client

Very handy code that can be used for analytics (reversing to approximate location)

let ip = request.headers[‘x-forwarded-for’] || request.connection.remoteAddress || request.socket.remoteAddress || request.connection.socket.remoteAddress;

This is for cloud defined functions for your custom rest API

Share This:

javascript, mobile

Requesting permission for android using React Native

A great new way of requesting and checking for permission on android is no longer challenging.

Available in RN 33+

https://github.com/facebook/react-native/commit/0fb2ccfcc3e6babe28d7d1bcf4635ef2f9191eb1

Permissions you can request that will prompt a user:

this.PERMISSIONS = {
READ_CALENDAR: ‘android.permission.READ_CALENDAR’,
WRITE_CALENDAR: ‘android.permission.WRITE_CALENDAR’,
CAMERA: ‘android.permission.CAMERA’,
READ_CONTACTS: ‘android.permission.READ_CONTACTS’,
WRITE_CONTACTS: ‘android.permission.WRITE_CONTACTS’,
GET_ACCOUNTS: ‘android.permission.GET_ACCOUNTS’,
ACCESS_FINE_LOCATION: ‘android.permission.ACCESS_FINE_LOCATION’,
ACCESS_COARSE_LOCATION: ‘android.permission.ACCESS_COARSE_LOCATION’,
RECORD_AUDIO: ‘android.permission.RECORD_AUDIO’,
READ_PHONE_STATE: ‘android.permission.READ_PHONE_STATE’,
CALL_PHONE: ‘android.permission.CALL_PHONE’,
READ_CALL_LOG: ‘android.permission.READ_CALL_LOG’,
WRITE_CALL_LOG: ‘android.permission.WRITE_CALL_LOG’,
ADD_VOICEMAIL: ‘com.android.voicemail.permission.ADD_VOICEMAIL’,
USE_SIP: ‘android.permission.USE_SIP’,
PROCESS_OUTGOING_CALLS: ‘android.permission.PROCESS_OUTGOING_CALLS’,
BODY_SENSORS: ‘android.permission.BODY_SENSORS’,
SEND_SMS: ‘android.permission.SEND_SMS’,
RECEIVE_SMS: ‘android.permission.RECEIVE_SMS’,
READ_SMS: ‘android.permission.READ_SMS’,
RECEIVE_WAP_PUSH: ‘android.permission.RECEIVE_WAP_PUSH’,
RECEIVE_MMS: ‘android.permission.RECEIVE_MMS’,
READ_EXTERNAL_STORAGE: ‘android.permission.READ_EXTERNAL_STORAGE’,
WRITE_EXTERNAL_STORAGE: ‘android.permission.WRITE_EXTERNAL_STORAGE’,
};

Share This:

coding, rambling

CoffeeScript is gone, what do recruiters think about this?

CoffeeScript emerged years ago in an alternative to spaghetti code written by tired/junior/bored/rushed developers. Javascript can become messy very quickly and there are many ways of creating modules, classes and attempting to have clear expression of callbacks. Not to mention handling errors , encapsulating classes, etc.

CoffeeScript solved a lot of those issues. It provided a shorter syntax to e.g. Checking if variable is null and undefined in one short syntax. It created an easy to understand structure of creating classes and a ton of helper methods. It took inspiration from Ruby language and it worked.

It required a few tools but it wasn’t very hard to integrate into team’s development cycle. In fact some would argue (i did) that it created a value through more structure.

A lot of job posts started to include CoffeeScript which may be perceived as a separate technology by recruiters (granted it does require a bit of learning but not much).

Today ES6 generation of javascript renders CoffeeScript redundant and because its basically a hack , it never meant to stick around. TypeScript promoted by microsoft and others provides amazing type checking , casting and many valuable features .

A short lived technology (i personally have developed a few things using it ) will leave some confused .

 

Share This:

cloud, coding, mobile, nodejs

Mobile app built in 24 hours for banking

I have participated individually in a hackathon organized by a bank and had a concept in mind that would help bank customers chat with an advisor competent in their field.

I’ve built a platform that had a real time chat, a browser based web app that would be more suitable for Customer Support or Advisor (also a mobile app was available if they were on the go).

The pitch:

Simplifying issue resolution for customers by matching them to advisors and saving time for both sides.

 

I have open sourced my solution with screenshots.

Available here

Share This:

javascript

Animations and transitions on websites need to be smooth

Today, there are many gorgeous sites designed with animations and modern browser support in mind. We’re not talking about video but rather pictures and popups gliding on the screen to show you something important. You probably see previews or an app or a picture that  shows content that’s easy on the eye.

Even with a modern computer or mobile devices, these animations be appear choppy. I will describe solution to this:

 

Velocity is an animation engine with the same API as jQuery’s $.animate(). It works with and without jQuery. It’s incredibly fast, and it features color animation,transforms, loops, easings, SVG support, and scrolling. It is the best of jQuery and CSS transitions combined.

Velocity was built to augment where Jquery and Jquery Transit have left off. See CSS transitions that use your video card.

 

You can find velocity.js here Velocity JS code and documentation

Share This:

cloud, javascript

Using MomentJs Timezone in Parse.Cloud.code

Parse Cloud Code comes with a few handy modules, however momentjs presently is very old (1.x) on parse cloud code. Here are the steps how to integrate momentjs and momentjs-timezone (latest and greatest).

Step 1

Within your project copy momentjs.js (version 2.X) and moment-timezone.js file to /cloud directory.

Step 2

Modify moment-timezone.js first few lines:


(function (root, factory) {
"use strict";

module.exports = factory(require(‘cloud/moment.js’));

}(this, function (moment) {

What this does is loads your updated momentJs for moment-timezone to use

Step 3

Use the updated script within your code like this


var moment = require('cloud/moment-tz');

Share This:

architecture, cloud

Azure cli provides powerful tools before Portal is finally polished

But first , the tricky part is using Azure’s CLI tool . I would suggest using node version:

Installing : npm -g install azure-cli

Once you’re done, they require you to upload .publishsettings file , oddly named its also not easily accessible. Run the following command

azure account download

Above command will actually open a browser and if you’re logged in (azure) you will be able to download it.

Next step is importing it

azure account import filename.publishsettings

 

At this point you want to switch to Resource Manager mode, its a newer API architecture where everything is configurable via JSON structure and this is inline with new Portal management. The following command will switch you to that mode:

azure config mode arm

Few more handy resources when dealing with azure-cli

Using the Azure CLI for Mac, Linux, and Windows with Azure Service Management

Share This:

coding

VisualStudio online doesnt use ssh, here is a tip

MS Visual Studio online was something new to me. It definitely is targeted for those using Visual Studio as product, however for those of us that us Atom or Sublime we’re a bit stuck.

VSS online doesn’t support ssh , so don’t bother looking for it.

What you’ll need to do is:

1. Setup alternate credentials (username and password ) This can be done in profile window

2. git clone http://<yourproject>.visualstudio.com/….

3.  git config credential.helper store

4. Make changes and push, it will prompt you for credentials but they will be saved and you won’t be prompted again

ps. keep in mind that credentials are saved in a file (hidden) and shouldn’t be exposed, hence the alternate credentials so that your MS account isnt exposed.

Voila

Share This:

Uncategorized

Oracle Mysql Cluster 7.4 features

I’ve explored the features of Mysql Cluster 7.2 and 7.3 and now Oracle is coming out with 7.4 with very nice improvements.

This is yet another reason to go for baremetal (softlayer or others) and setup 4 node machine (or more) and enjoy the features of fairly priced or free mysql cluster.

These are the features listed from a Webinar :

 

  • Performance enhancements: MySQL Cluster 7.4 delivers a 50 percent performance improvement over MySQL Cluster 7.3 for Read-Only workloads and 40 percent improvement for Read/Write operations. Performance improvements are available through SQL or any of the native NoSQL APIs supported by MySQL Cluster. New records of 200 Million NoSQL Queries Per Second (QPS) and 2.5 Million SQL QPS were established.
  • New geographic redundancy features for high availability across data centers: The latest release provides rollback of any conflicting transactions – enabling full active-active, update-anywhere replication between geographically distant clusters, with applications able to send reads and writes to any site without compromising on consistency.
  • Faster online maintenance and recovery operationsincluding the ability to roll out software upgrades as much as 5x faster.
  • Enhanced distributed monitoring of memory usage and database operations.

Share This:

architecture, coding

Open sourcing my lottery server

2007 project involving Message Driven Beans (EJB) running on Enterprise Java container (Jboss or Glassfish) where games are processed and “played” as they come in through the Queue allowing scalability and consistency.

 

Source code for both game logic and EJB server can be found on github:

Github to Lottery Server

Share This: