Category Archives: Programming

Installing R and Shiny on Cloud 9

I wanted to see if I could run an instance of RStudio’s Shiny server on Cloud 9 and after a bit of finagling with the right set of steps to get it set up I have an instance running. Here’s what I did starting from a workspace using the stock HTML template.

strefethen:~/workspace/ $ sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list
strefethen:~/workspace/ $ gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
strefethen:~/workspace/ $ sudo apt-get update
strefethen:~/workspace/ $ sudo su - \
-c "R -e \"install.packages('shiny', repos='https://cran.rstudio.com/')\""
strefethen:~/workspace/ $ sudo su - -c "R -e \"install.packages('shiny', repos='https://cran.rstudio.com/')\""
strefethen:/etc/shiny-server $ sudo shiny-server
[2016-09-02 02:25:04.460] [INFO] shiny-server - Shiny Server v1.4.4.801 (Node.js v0.10.46)
[2016-09-02 02:25:04.463] [INFO] shiny-server - Using config file "/etc/shiny-server/shiny-server.conf"
[2016-09-02 02:25:04.535] [WARN] shiny-server - Running as root unnecessarily is a security risk! You could be running more securely as non-root.
[2016-09-02 02:25:04.539] [INFO] shiny-server - Starting listener on 0.0.0.0:8081

I need to look into the user “shiny” to see about fixing the above warning. Then edit /etc/shiny-server/shiny-server.conf and change the port from 3838 -> 8081 so Cloud 9 will server the content and start the server:

sudo shiny-server

Browse to http://<project-name>-<username>.c9users.io:8081/ and you should see:

Default Shiny app running on Cloud 9

React Native bundle loading failing on a physical device

I’m building a React Native application and recently updated to v0.31.0 and at first things were working well debugging on the device benefiting from a feature of the react-native-xcode.sh script. The script copies your Dev machine’s IP address to a text file called ip.txt which is used for establishing the connection to your machine from your device since localhost points to the wrong place. Here’s the line of code in ./node_modules/react-native/packager/react-native-xcode.sh:

echo "$IP.xip.io" &gt; "$DEST/ip.txt"

Continue reading

From Google Sheets to an Automated Shiny Dashboard (Part I)

Over the past several months I’ve been building what’s become a large Google Sheet (which is now at the 2M cell limit) tracking Find&Save Cash Dash offers. Like a lot of data projects this one started out small but over many months grew to a point where it no longer makes sense to cut/paste SQL data into a Google Sheet for pivot tables and charts. I wanted a solution that could pull data from REST APIs, MSSQL and Postgres and present data in an internal dashboard. Unfortunately, Google Sheet’s JDBC support doesn’t include Postgres otherwise Google Apps Script might have been a viable choice for automating data collection notwithstanding size limitations. Finally, another issue with Sheets was that I couldn’t seem to get pivot tables to resize automatically as more data was added. So, 3 strikes and Google Sheets was out.

Continue reading

Plotting Weekly Mobile Retention from the Localytics API using R and ggplot2

Part of building mobile web apps is understanding the myriad of mobile analytics and in part visualizing the data to shed light on trends that my otherwise be difficult to see in tabular data or even a colorful cohort table. I’ve been building a dashboard using R, RStudio, Shiny, and Shiny Dashboards aggregating data from MSSQL, Postgres, Google Analytics, and Localytics.
Continue reading

Fetching Localytics API Data in R and working with the JSON result

Recently, I’ve been building a dashboard for Find&Save using R, RStudio and Shiny Dashboards and one of our core mobile metrics is 30 day active users for both iOS and Android which I can get from Localytics (our analytics platform) via their API. Googling around I found I’m not reinventing the wheel (via SO) though I did run into a problem where the response failed to convert properly thus the post.

Here’s the original function from SO with some slight tweaks for my needs:
Continue reading

ReactNativeJNI: Check failed: *m_isDestroyed JSCExecutor::destroy() must be called before its destructor

Short post to get this indexed as we didn’t find it elsewhere on the web.

While working to ship a new release of the Find&Save Android app we ran into a crash on launch which only occurred in our release build. The crash was in JSCExecutor.cpp which is part of React Native and left very few hints as to what was wrong with no call stack, Crashlytics logs etc. The only error we had was:

ReactNativeJNI: Check failed: *m_isDestroyed JSCExecutor::destroy() must be called before its destructor
Continue reading

Upgrading an iOS project from Xcode 6 to 7

At work I’m in the midst of upgrading Find&Save to Xcode 7 and in this post I thought I would capture the issues I ran into while migrating our app to the latest build tools. I decided to keep my Xcode 6 install by renaming it “Xcode 6” and installing Xcode 7 along side it and all that worked pretty seamlessly (though keep reading because the AppStore updates will bite you). Once installed I opened our project workspace and hit Project | Build and thus began the journey of our migration.
Continue reading

Setting up debugging for Google AppEngine projects in Eclipse

When I made the move from Windows to OSX and Python development one of the things I wanted to experiment with has been Google’s AppEngine. I installed the SDK and setup the plugin for Eclipse but ran into a few issues I wanted to make note of since I think other could probably benefit from it as well. I’ll mention I’m on OSX 10.6.8 using Eclipse for Java Version Helios SR 2.

Creating a new AppEngine project in Eclipse

With the plugin installed you get an AppEngine project template listed under PyDev.

Screen shot 2011-08-30 at 8.48.55 PM

Clicking Next displays the standard Eclipse dialog for a new project where you enter the name and optionally a few other project settings. However, it’s the dialog after that where I had my first question where you’re prompted for the Google App Engine Directory which in my case corresponds to:

/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/

Google instructions for development in Eclipse didn’t answer this question and it wasn’t immediately obvious to me. At any rate, once this path is set correctly you’ll immediately see a list of AppEngine modules to be included on the PYTHONPATH:

Screen shot 2011-08-30 at 9.14.38 PM

Configuring the Project’s Python Interpreter

After I successfully created the AppEngine project I wanted to look at the appengine-boilerplate for HTML5 which is based on HTML5 boilerplate which is well worth checking out. Next, I used the Google AppEngine Console to create a new application called “helloworld954” then copied the boilerplate files into my project and edited the app.yaml file to set the application name:

application: helloworld954

I then ran the project and everything looked ok but when I hit the page from the browser (http://localhost:8080) I got:

ImportError: No module named cgi

Which I subsequently discovered more information about here.

Now, IIRC my MacBook Pro came with Python 2.6 as the default version though v2.5 was installed as well and given AppEngine is, as of this writing, based on v2.5 I figured rather than tweaking dev_appserver.py as mentioned on that prior link I figured I’d first try the proper Python version. I right clicked my project from the package explorer and selected Properties then clicked the PyDev – Interpreter/Grammar option then clicked the “Click here to configure an interpreter not listed” link (blue link below).

Screen shot 2011-08-30 at 9.36.44 PM

Next, on the preferences dialog (which I won’t screenshot here as it’s too big) I clicked New… and added a new interpreter option for “Python v2.5” with a path of:

/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python

Btw, I think I tried the symlink but that wasn’t allowed (again, I think).

At any rate, once I saved those changes voila the boilerplate project started working. Ah, one step I overlooked was setting up a debug configuration for this project:

Screen shot 2011-08-30 at 9.49.13 PM

The main module for the application has to be Google’s dev_apperser.py file which is located here on my machine:

/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/dev_appserver.py

Also, under the (x)= Agruments tab I set the Program Arguments to “.” for the current working directory and for “Working Directory” I selected “Other” with a value of “$(workspace_loc:starterkit}” Note, starterkit is the name of my project.

The final result:

Screen shot 2011-08-30 at 9.53.42 PM

Hopefully, this helps someone else, it will certainly help me months from now when I trying to do the same thing again so I won’t have try and recall all these steps.

OAuth 2.0 reference for Facebook development

As I mentioned, I’m working on Facebook support which involves the transition to the new $g(OAuth 2) authentication. What I’m going to do here, for myself if no one else, is keep a list of links I’ve found related to the topic. Without further adieu:

Of course, feel free to leave a comment with anything useful you’ve found.