Mongoexport error: “too many positional options”

Had a quick task where I needed to export results of a mongo query into a CSV file.

Mongoexport command comes in very handy in this case.

I constructed my query:

mongoexport -h -d mydb -u myusername -p mypassword 
-c coll_name -q {tag:/mytagname/,count:{$gte:10}} -f tag,tag_date,count 
--csv -o test.csv

And when I ran it, got this error “too many positional options”

Some google groups suggest that you need to remove the space between -p and password, but it was actually fixed in the latest version.

The problem was caused by the lack quotes around my query – they need to be there. So the correct one looks like this:

mongoexport -h -d mydb -u myusername -p mypassword
-c coll_name -q '{tag:/mytagname/,count:{$gte:10}}' -f tag,tag_date,count 
--csv -o test.csv

Also, “-f” values (for field names) need to be comma-separated, no spaces.

Mobile: responsive, adaptive or optimized?

This is a question that we hear a lot lately: will my new website be mobile-optimized?

And before answering this question, letâ??s make sure all parties mean the same thing when they ask for â??mobile-optimizedâ?.

Hereâ??s how we at 360i define it:

Websites can be mobile-friendly and mobile-optimized.

Mobile-friently vs mobile-optimized

A mobile-friendly website is the SAME website that you see on a desktop browser or a mobile browser. Nothing in the layout of the site changes, but all content is viewable on mobile. So your users browsing from smartphones can still read and access all of your content. Most websites can be called mobile-friendly, except for sites built with Flash – they will not show on iPhone Safari browsers.

Generally, there is not much additional work in this case, just follow best practices when youâ??re building a mobile-friendly site:

  • use descriptive, semantic markup (appropriate header tags for headers, donâ??t include text as part of images)
  • minimize image file sizes for slower mobile connection
  • avoid Flash and advanced JavaScript/CSS animations

A mobile-optimized website provides a DIFFERENT experience when viewed in a mobile browser. The reason for this is to address the smaller screen size and provide the best user experience to your visitors who are on mobile devices.

Responsive vs adaptive design

There are two ways you can create a mobile-optimized experience:

1) Responsive website
Responsive design is a SINGLE FLUID design for all devices and screen sizes. Your page elements can be re-arrranged based on the screen size, but they are still same elements.


This is usually done with use of media quieries in CSS, and looks like this (very simplified example):

/* --------------- Tablet ------------- */

@media only screen and (max-width: 1024px) {
     /* your styles for tablet here */

/* ------------- Smartphone ------------- */

@media only screen and (max-width: 480px) {
    /* your styles for smartphone here */ 

2) Adaptive website
Adaptive websites present users with DIFFERENT designs, depending on the device and screen size.

This is accomplished by detecting the device (by checking the User-Agent header), which can be done either in JavaScript or server side. Hereâ??s a good site with script snippets for mobile browser detection.

Usually, once a mobile browser is detected, the site redirects to a mobile version.


Obviously, creating a mobile-optimized website (responsive or adaptive) would require more work, because you would have to either create a design that scales fluidly (for responsive sites), or create multiple design versions (for adaptive sites).

Here are some additional resources that help you understand these concepts:

1000 fans love MayNovember!

I’d like to applaud to my best friend Ohn for reaching 1000+ fans on Instagram! Girl – you rock!

For those of you who don’t know, Ohn runs a fun, vintage-inspired and affordable online boutique from the heart of NYC! Her unique style is the source of inspiration and admiration, and 1000+ Instagrammers agree! !

Hugo kudos to Ohn on working full-time, running the store and having fun! Check out for amazing jewelry, stylish clothing and accessories. Flat-rate shipping anywhere in the world, Facebook fans get extra discount!

And – new Fall collection coming soon, it’s time to refresh your wardrobe for the new season!

Fun Friday

Wow what a day at work, lots of love and fun projects.

A couple of weeks ago I put together a hosting recommendation our Bravo team (and we also did a bunch of other projects earlier), and look what I found today on my desk! A tshirt and an autographed Top Chef cookbook!


Such a cool and sweet gift! I will have to cook something out of that book, how about this intriguing dessert:

The thing that cracked me up: this “orgasm” requires tapioca pillows, takes 3 hours and requires chilling overnight! :D

This one looks super yummy too:

Also, my insights team told me today that they were able to use the CSV file (genereated by my quick/dirty python script) and make some neat charts out of it!

And, to make it even better, I’ve finally got a bit of time to add URL parsing feature to my app, tested and deployed it. Wish more days were so focused and fun!

Web performance meetup notes

Today’s meetup was pretty damn good!

The speaker was a former Yahoo developer, who now runs his own startup on gathering performance metrics for clients (LogNormal, using Boomerang).

The talk reminded me of a really fun class in school, where a teacher would start from the basics, then ask questions to make students think before revealing the answer.

Philip started with explaining what latency is (network latency in our case), how packets travel between client and server, what factors attribute to the response time shown when you do a ping request.

Some of my favorite bits were:

  • network throughput vs network bandwidth:

    bandwidth: overall capacity of network connection = what the ISP is advertising and selling to you

    throughput: what you actually get, given factors like usage by other people, etc. So know what you’re paying for!

  • and a question about planes: is it smarter to travel on a 737 that has a capacity of 150 people or 747 which has capacity of 400? The answer is, if you want to board and deplane faster, go with 737 – less people and luggage to load/unload

Then he moved on to explain how he runs tests using JavaScript in browsers to determine how fast the network is.

He also touched on some advanced topics:

  • under-the-hood browser specifics: how many requests you could send at a time (used to be 2) and how speedier modern browsers adjust that number (it’s around 10 now), and apparently Opera Mini is the fastest mobile browser right now.
  • shared tips on working around DNS lookups by setting up a wildcard DNS entry
  • provided comparison charts of US network speeds vs India – majority of India still has up to 2mbps connections, compared to up to 10mbps in US

Full deck, courtesy of Philip

Thank you Sergey for organizing and Philip for sharing great info!

Python > write to a CSV file with Twitter API lookups

As I wrote a couple days ago, I had a quick task at hand, where I needed to populate a CSV column with data from Twitter (lookup tweets given their IDs and find out source of each tweet).

First attempt to do it with node.js (for the sake of speed, plus I love node) did not quite work. So I decided to fallback on Python and write a quick and dirty script to scarlett johansson pokies get Pokies it done, forgetting about events and async calls.

The sample can be found on Github.

I’m still eager to get this done with node, so I can hook it up to Dropbox API and process those files automatically whenever the insights team needs them. And going to Python made me realize how awesome NPM for node really is! Painless module installs and a variety of modules to choose from – love!

Node.js: parsing CSV file and populating a column from Twitter API

I was trying to implement a simple script that would read data from a .csv file, then do a lookup for each row hitting Twitter API, then fill that additional info (API response) into a new column. Sounds pretty simple.

Found this great node-csv module that makes parsing and writing into a .csv file super easy.

Twitter API connection was also an easy part.

But try connecting those two and write into a file. Nada.

The reason it’s not working is because the ‘transform’ function included in node-csv finishes before all the data transform is complete. And in my case I need it to wait for the HTTP response to come back. I read that people have similar issues when writing into a database.

So I went and submitted an issue to the repo owner, who replied within hours, which is very nice. Hope that it’s actually doable. Meanwhile, I tried using another CSV parser module called ya-csv, and ran into the same result. Looks like both use similar methods to read and write data, and do not include support for data transform/write callbacks.

I googled it, and looks like people are creating async loops to get around this issue, but I’m gonna do it in Python first to save time, then try that loop workaround and compare results.

.htaccess attacks on WordPress

I wrote about a strange case of .htaccess hijacking a few months ago, and recently found that my files again were injected with some garbage redirects to Russian sites (would you stop already, fellow Russians?)

If you’re running a WordPress site and ran into a similar problem, here are some notes on resolving it:

  • first and foremost, edit the .htaccess file and remove all the junk redirects. It is usually at the top of the file
  • apparently, the common way for injections like this is to sneak in is via wp-content/plugins directory. I found it was true for me, because I happened to have some old client work on my hosting server, and in one of the WordPress directories, some unknown plugin folder was found (named in a real suspicious way, something like “zasdgsdrs”)

    I would suggest inspecting your plugin folders and removing any weird looking stuff. Also disable and delete plugins that you don’t use, and check carefully before installing any new ones.

  • make sure your .htaccess file has proper permissions (644 is recommended)
  • make sure youre WordPress is up-to-date, upgrate to the latest stable version
  • it’s a good idea to also change passwords as recommended by WordPress
  • and if you’re still paranoid, read through the FAQ docs

And a couple of useful related links:

I wonder if this also has anything to do with hosting providers. Any thoughts from fellow WordPress-runners?

Why I love Heroku

I first used Heroku to deploy and host Facebook apps, and Iâ??m a big fan ever since.

Lately, Iâ??ve been doing development with node.js and since Heroku supports it (wonder if they were first to offer it), it was a no-brainer:

  • deployment via command line with git: nice way to enforce best dev practices
  • package management with NPM – everything will be fetched and installed for you
  • built-in SSL support on * subdomains
  • easy monitoring: just type ‘heroku logs’
  • easy scaling: just type ‘ps:scale web=x’ or ‘ps:scale worker=x’
  • support of environment variables: one example – running multiple instances from the same git repo
  • pretty good docs and tutorials
  • tons of add-ons: you are free to do pretty much anything (I use Mongolab add-on for Mongo hosting)
  • affordable!

Nodejitsu is another service focusing on node.js primarily, but Iâ??ve been reluctant to switch because I just like Heroku so much.

Itâ??s also super cool that they support multiple environments via buildpacks, Iâ??d love to look under the hood and find out how they made it work (and hereâ??s a great post describing their polyglot platform in high-level)

In contrast to the one-language-per-career programmer, today’s up-and-coming developers can often utilize many languages effectively. Borrowing a term from linguistics, we can call these versatile new developers “polyglot programmers.”

For the latest Show&Tell demo, I talked about benefits of using Heroku (as one of the PaaS options) for rapid deployment and easy hosting, so hereâ??s the deck.

This week Iâ??m working on a recommendation chart for cloud hosting, so Iâ??ll share that as well soon.