Data, Maps, Usability, and Performance

API canvas d3 data geo GeoJSON html5 image JavaScript json maps mysql PHP WordPress

Results for tag: nodejs

Automate Pinterest Pinning with CasperJS

Auto Pin on Pinterest Script

How do you pin photos on Pinterest automatically? I have covered some elements of the Pinterest API before, but I did not expose the endpoints necessary to pin via the API. None of that is yet publicly available but it got me thinking about doing more programmatically on Pinterest in general. What would it take to automate the process of pinning an image automatically? I think a simple solution is to use a headless browser and recreate the steps to make that happen. Lets go over a simple script that will login into Pinterest, retrieve an image from an external source, add pin it to a board with a pin description.
Read more

NodeJS on Google App Engine

Nodejs on Google App Engine

Are you looking for free hosting for your node projects? You could try DigitalOcean but GAE Managed VMs are now in Beta (you can use them without whitelisting) so I wanted to dedicate a quick post on running Node on Google App Engine. It could be a free and easy way to host your node.JS app. Since we are not coding in Java, Python, or Go Lang, we need to setup a custom runtime environment on a Virtual Machine. So, below I will go over installing Managed VMs with Google Cloud SDK and Docker to build and deploy a sample app, written in Node and Express, to Google App Engine.
Read more

Client-Side JavaScript to Node.js

JS to Node

JavaScript is mostly used on the client-side and in the browser, enabling all kinds of dynamic interactions on the page. When Brendan Eich created the language for Netscape in 1995, there were already server side implementations but node.js made it really popular. Node is a cross-platform runtime environment that is event driven and non-blocking and uses the Google V8 JavaScript engine to execute code. So, if you already know JS, you can now code on the server. There are a ton of use cases that this enables but today I want to focus on a simple concept of moving your client-side JavaScript code to Node.JS so that you can hide or protect your JS functions from being visible to end users.
Read more

30 Code Playgrounds and Sharing Tools

code toolbox

Most people know about jsFiddle because it is an amazing tool that allows you to quickly test and share small pieces of code. No wonder my jsFiddle examples post is getting a ton of traffic. But, there are many other awesome web based sandbox testing tools that you might find useful. Did you know that there are SQL and NodeJS sandboxing tools out there? It is so convenient to quickly mess around with code online and collaborate with other programmers. Below you will find some of the best free code playgrounds and sandboxing tools for testing, debugging and sharing your code snippets (I put my favorites in bold).
Read more

Simple installation of NodeJS, PhantomJS, and CasperJS

CasperJS version

I have mentioned using CasperJS for screenshots previously, the awesome navigation scripting and testing utility for PhantomJS (headless webkit browser for NodeJS), but I wanted to cover something that can be a bit painful at times: installation. You can install all three of these on your MAC or Windows OS but I would recommend grabbing a free VM via VirtualBox, loading Ubuntu on it, and doing it in Linux. It’s actually a really simple approach and you will be working in a separate environment.
Read more

10 Interesting updates in PhantomJS 1.7

Updates to PhantomJS

Last week, PhantomJS got an update and you can check out the release notes to see the improvements. I definitly like the generic module update and better cookie handling. Better support for mouse and keyboard related events are also great. But, I am also really looking forward to some of the other features and improvements. These are my top 10:
Read more

Curl with NodeJS

NodeJS Curl function

If you are familiar with Curl, the command line tool for transferring data with URL syntax, you might wonder how can that be done with NodeJS. Well, looking at the nodeJS API, it’s clear that HTTP.request gives you something that looks like a Curl equivalent. But, I want to write the response to a file and do some looping so that I can use an array of URLs instead of just making a request to one URL.
Read more

Viewing and Disabling Cookies in CasperJS and PhantomJS

browser cookies

Today, I have once again been messing around with CasperJS and this time around, I wanted to play around with browser cookies. PhantomJS API Reference has a command line option –cookies-file=/path/to/cookies.txt that specifies the file name to store persistent cookies but I want to disable cookies, not store them. I also want to test and see what the cookies are on the page to verify that they have been disabled.
Read more

Using CasperJS to Make MultiBrowser Screenshots

render screenshots in casperjs

Update: As pointed out in the comments, we are only changing a user-agent string not the rendering engine. IE Conditional comments are enabled through the IE rendering engine so sending an IE user-agent will not give you a real IE screenshot. With that being said, you can use SlimmerJS to render Gecko (browser engine of Mozilla Firefox) screenshots instead of WebKit.

CasperJS is an awesome testing utility for PhantomJS, a headless WebKit browser. In other words, it is something like Selenium, a tool for you to automate a browser, but written in JavaScript instead of Java. It basically allows you to run all kinds of tests on your website and log the information or render screenshots. It comes packaged with a sample script for making a screenshot, but what if you wanted to make a couple screenshots per page based on different browsers (different user agent string).

Well, if you look at the CasperJS API you can see a userAgent example but this example does not work. It is not very obvious at first as the example seems to be working when run (you get the expected print statements in the console). However, if you include a callback on resource requested and retrieve the User-Agent string for each resource, you quickly realize that both tests have been done with the same last user agent string. Look at the output of this example code:
Read more