George Opritescu

Developer from somewhere

typescript instantiate generic type

function buildObject<T>(type: { new(): T } ): T {
  return new type();
}
Read More

starting out with facebook flow

npm install flow-bin
./node_modules/flow-bin/vendor/flow init
./node_modules/flow-bin/vendor/flow

Example app can be viewed here

Read More

string compare in javascript

"string".localeCompare("other_string");
Read More

custom npm scripts

You can define your own scripts in package.json, like:

  "scripts": {
    "fix-tags": "node app.js tags/index.html"
  }

and you can run them like this:

npm run-script fix-tags
Read More

install bower components on heroku build

Make sure you have bower added as a dependency in package.json, and then add the following script as postinstall:

"scripts": {
  "postinstall": "./node_modules/bower/bin/bower install"
}
Read More

asset digest in node.js

node-static-asset can help with this.

Like the docs say, add this to your app:

var express = require('express');
var app = express();
var staticAsset = require('static-asset');
app.use(staticAsset(__dirname + "/public/") );
app.use(express.static(__dirname + "/public/") );

And then in the view, use it like this:

script(type="text/javascript", src=assetFingerprint("/javascripts/jquery.min.js") )
Read More

view autoloaded paths

ActiveSupport::Dependencies.autoload_paths
Read More

array in rails yaml translation files

en:
  your:
     translation_array:
       - value1
       - value2
Read More