Snippets of the day – Saturday, February 22, 2014

Posted on Posted in Snippets

orange-multi-tool

Here are some of the most recently published snippets!

How to check if a Git remote repository is available in python

This simple python code shows how to check if a given Git remote repository is available.

The code invokes the git command ‘git ls-remote’ on the remote URL path as subprocess with Popen and checks the exit code, using the communicate() method.

The command exit status is stored into the ‘returncode’ property.

A value not-equals to ‘0’ means the command returned with errors.

Open the snippet

Author:    lbottaro

Using moment.js in node.js with Typescript

You can easily install the moment.js library in node by using the command (on Mac):

> npm install moment

After that you need to download its type definition from Git/DefinitelyTyped:
https://github.com/borisyankov/DefinitelyTyped/tree/master/moment

To make it work, however you need to add the following to the moment.d.ts :

Open the snippet

Author:    micurs

Using crypto-js in node.js with Typescript

You can easily install the crypto-js library in node by using the command (on Mac):

> npm install crypto-js

After that you need to download its type definition from Git/DefinitelyTyped:

https://github.com/borisyankov/DefinitelyTyped/tree/master/cryptojs

To make it work, however you need to add the following to the cryptojs.d.ts :

Open the snippet

Author:    micurs

Leave a Reply

Your email address will not be published. Required fields are marked *