4 Jun 2015, 12:02pm

leave a comment

  • Anzeige
  • Excellent photos free to be reused

    Look­ing for great pho­tos for your next project or pre­sen­ta­tion? And you enjoy to be on the legal side of life? Check out this great web­sites with free stock photography!

    Excel­lent qual­ity: Pex­els, Life of Pix, Stocksnap.io, Unsplash,
    Grati­sog­ra­phy (by Ryan McGuire).

    Good qual­ity: Cup­cake.

    Good, but…
    A bit com­pli­cated to browse: Neg­a­tive Space, Great shots food, but the licens­ing is not exactly clear: Food­ies Feed.

    And it’s all free to use via the Cre­ative Com­mons Zero license (aka CC0). Even for com­mer­cial projects… and if you need even with­out attri­bu­tion. Great stuff — tru­ely free. :)

    Sources: Slideshare blog and others.

    19 Jul 2014, 9:21pm

    leave a comment

  • Anzeige
  • Copying MongoDB from meteor.com

    I started deploy­ing my lat­est Meteor app umeedoo.net to my own VPS and wanted to use the data from my beta sys­tem hosted at umeedoo.meteor.com.
    First of all, I was sur­prised how sim­ple and easy it was to deploy using Meteor Up (MUP). Some weeks before, I spend an entire day on installing the Meteor envi­ron­ment on a Debian machine — now it’s less than 15 min­utes! One caveat though, it did not work for me on Debian, I had to drop my pre­vi­ous Debian VM and replaced it with Ubuntu as MUP depends on Upstart and it seems rather tricky to replace Debian’s SysVinit with Upstart. Ok, dif­fer­ent story, but a biiig thanks to Arun­oda for the great work on MUP!!

    So, how to db.copyDatabase(); the data from the orig­i­nal DB to yours?

    The method sig­na­ture is db.copyDatabase("[app-name]_meteor_com", "[your-db-name]", "[meteor-mongo-domain]", "[username]", "[password]");
    I’ll assume “app” to be the app name for sim­plic­ity.
    Gen­eral approach: get the Mon­goDB URL, extract all the para­me­ters above, log into your own Mon­goDB instal­la­tion and use db.CopyDatabase(); to move the data over.

    All com­mands need to be exe­cuted on the same machine. (FYI, the user­name and pass­word get auto­mat­i­cally gen­er­ated and it did not work to get the URL on my machine and use the user­name and pass­word on the server… strange though)
    Thus, install Meteor on your server curl https://install.meteor.com/ | sh.
    Then, get the Mon­goDB URL meteor mongo --url app.meteor.com
    It will look like this mongodb://client-fd532e7d:683a9a4e-1604-5729-07fd-df1ba7dcbbf9@production-db-a2.meteor.io:27017/app_meteor_com
    The parts are

    • user­name: client-fd532e7d
    • pass­word: 683a9a4e-1604-5729-07fd-df1ba7dcbbf9
    • meteor-mongo-domain: production-db-a2.meteor.io:27017

    Start a Mon­goDB CLI by typ­ing mongo.
    In my case, the data­base cre­ated by the app and MUP was called “admin” (i.e. [your-db-name]=“admin”). How to find yours? Use “show dbs” in the Mon­goDB CLI to see which one is yours.
    Then write “use [your-db-name]” to switch to your DB.
    And finally, using the data from above: db.copyDatabase("app_meteor_com", "admin", "production-db-a2.meteor.io:27017", "client-2fbeb6ef", "1bd44ece-b3fa-7d1b-0046-83b917927f35");
    will copy the data over in a few sec­onds.
    When I tried first, I got an error about a dupli­cate key (the deployed app had cre­ated some data already), drop­ping the entire DB fixed it. Also, the user­name and pass­word are valid for a short time only, so maybe hav­ing to ter­mi­nals open is a good idea.

    Ref­er­ences: Cloning Mon­goDB, Meteor dump, Clone DB from meteor.com, Copy DB from one server to another

    11 Feb 2014, 7:19pm

    leave a comment

  • Anzeige
  • Match.Optional for null

    Secur­ing my Meteor app, I came across a strange quirk of Match.Optional of the “check” pack­age.
    Exam­ple (in CoffeeScript)

      test: (x) -> check x, Match.Optional String

    I expected the match to be suc­cess­ful when call­ing the method like this:

    Meteor.call 'test', undefined

    But instead, I got a “Match failed” excep­tion. After debug­ging for a bit, it turned out that the undefined becomes a null when it arrives on the server.
    Which is odd, of course—but also annoy­ing as the check x, Match.Optional String fails for null (only undefined or String are accept­able).
    To over­come this, here is a new Match.Optional that does the trick:

    Match.OptionalOrNull = (pattern) -> Match.OneOf undefined, null, pattern

    Also, I keep won­der­ing: what’s the pur­pose of mak­ing Match.Optional fail on null in the first place?