Nikola Brežnjak blog - Tackling software development with a dose of humor
  • Home
  • Daily Thoughts
  • Ionic
  • Stack Overflow
  • Books
  • About me
Home
Daily Thoughts
Ionic
Stack Overflow
Books
About me
  • Home
  • Daily Thoughts
  • Ionic
  • Stack Overflow
  • Books
  • About me
Nikola Brežnjak blog - Tackling software development with a dose of humor
Books

The Antidote – Oliver Burkeman

My favourite quotes from the book The Antidote by Oliver Burkeman:

Inspiration is for amateurs, the rest of us just show up and get to work.

In the effort to try to feel happy is often precisely the thing that makes us miserable, and then it’s our constant efforts to eliminate the negative insecurity, uncertainty, failure of sadness and that is what causes us to feel so insecure, anxious, uncertain or unhappy.

The worst thing about any event is usually your exaggerated believe in its horror. The way to diffuse disbelief is to confront the reality.

When you really face mortality, the ultimate and unavoidable worst case scenario, everything changes. All external expectations, all fear of embarrassment or failure – these things just fall away in the face of death, leaving away what is truly important.

CodeProject, NodeJS

Deploying MEAN.io to Nodejitsu from Windows machine

Disclaimer: I’m in no way affiliated with Nodejitsu or MEAN.io. I’m just documenting my experience with them – problems (and solutions) I’ve faced while trying these new technologies on a Windows machine.

Great, with that off my chest, we can now start. This is a successor post to the previous one: Getting started with Nodejitsu on Windows by deploying a MEN framework, so you may wanna check that too.

MEAN is a fullstack javascript platform for modern web applications.

MongoDB – leading NoSQL database, empowering businesses to be more agile and scalable

Express – minimal and flexible node.js web application framework, providing a robust set of features for building single and multi-page, and hybrid web applications

Angular – lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop

Node.js – a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications

Following the notes on the official website you have to clone the repo, install all the dependencies withnpm  and then run grunt .

git clone http://github.com/linnovate/mean.git

cd mean

npm install

grunt

If you get an error like this:

C:\Users\Nikola\Desktop\mean>grunt
Running "jshint:all" (jshint) task
>> 42 files lint free.

Running "concurrent:tasks" (concurrent) task
Running "nodemon:dev" (nodemon) task
Running "watch" task
Waiting...[nodemon] v1.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node --debug server.js`
debugger listening on port 5858
Express app started on port 3000

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: failed to connect to [localhost:27017]
    at null.<anonymous> (C:\Users\Nikola\Desktop\mean\node_modules\mongoose\node
_modules\mongodb\lib\mongodb\connection\server.js:553:74)
    at EventEmitter.emit (events.js:106:17)
    at null.<anonymous> (C:\Users\Nikola\Desktop\mean\node_modules\mongoose\node
_modules\mongodb\lib\mongodb\connection\connection_pool.js:140:15)
    at EventEmitter.emit (events.js:98:17)
    at Socket.<anonymous> (C:\Users\Nikola\Desktop\mean\node_modules\mongoose\no
de_modules\mongodb\lib\mongodb\connection\connection.js:512:10)
    at Socket.EventEmitter.emit (events.js:95:17)
    at net.js:440:14
    at process._tickCallback (node.js:415:13)
[nodemon] app crashed - waiting for file changes before starting...

make sure that you have MongoDB installed and that you have the mongod.exe running on the default port 27017. Instructions on how to install MongoDB on a Windows machine can be found here: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/, but tl;dr is:

  • download the installation zip package
  • unzip in c:\mongodb
  • create c:\data\db  folder
  • run c:\mongodb\bin\mongod.exe

When you have mongod.exe  started in one command window (I use Console2) and you run grunt  in other you will get this in the “mongo” console:

C:\mongodb\bin>mongod.exe
mongod.exe --help for help and startup options
Tue Mar 11 14:50:24.240 [initandlisten] MongoDB starting : pid=10136 port=27017 dbpath=\data\db\ 64-bit host=Nikola-PC
Tue Mar 11 14:50:24.240 [initandlisten] db version v2.4.9
Tue Mar 11 14:50:24.240 [initandlisten] git version: 52fe0d21959e32a5bdbecdc62057db386e4e029c
Tue Mar 11 14:50:24.240 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_49
Tue Mar 11 14:50:24.240 [initandlisten] allocator: system
Tue Mar 11 14:50:24.240 [initandlisten] options: {}
Tue Mar 11 14:50:24.244 [initandlisten] journal dir=\data\db\journal
Tue Mar 11 14:50:24.244 [initandlisten] recover : no journal files present, no recovery needed
Tue Mar 11 14:50:24.323 [initandlisten] waiting for connections on port 27017
Tue Mar 11 14:50:24.324 [websvr] admin web console waiting for connections on port 28017
Tue Mar 11 14:50:40.982 [initandlisten] connection accepted from 127.0.0.1:58323 #1 (1 connection now open)
Tue Mar 11 14:50:41.014 [initandlisten] connection accepted from 127.0.0.1:58324 #2 (2 connections now open)
Tue Mar 11 14:50:41.024 [initandlisten] connection accepted from 127.0.0.1:58325 #3 (3 connections now open)
Tue Mar 11 14:50:41.024 [initandlisten] connection accepted from 127.0.0.1:58326 #4 (4 connections now open)
Tue Mar 11 14:50:41.025 [initandlisten] connection accepted from 127.0.0.1:58327 #5 (5 connections now open)

and this in the “grunt” console:

C:\Users\Nikola\Desktop\mean>grunt
Running "jshint:all" (jshint) task
>> 42 files lint free.

Running "concurrent:tasks" (concurrent) task
Running "nodemon:dev" (nodemon) task
Running "watch" task
Waiting...[nodemon] v1.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node --debug server.js`
debugger listening on port 5858
Express app started on port 3000

You can now take a look at your application by visiting localhost:3000 in your browser: meanHomeView the signup screen: meanSignup and signin screen: meanSignin

Ship it

In order to deploy to Nodejitsu, you have to login to Nodejitsu (jitsu login ) and then run jitsu deploy . At this point I got an error like this:

info:    Starting app mean
error:   Error running command deploy
error:   Errors occured while starting the application
error:   Error output from application. This is usually a user error.
error:   grunt-cli: The grunt command line interface. (v0.1.13)
error:
error:   Fatal error: Unable to find local grunt.
error:
error:   If you're seeing this message, either a Gruntfile wasn't found or grunt
error:   hasn't been installed locally to your project. For more information about
error:   installing and configuring grunt, please see the Getting Started guide:
error:
error:   http://gruntjs.com/getting-started
error:
error:   Error starting application. This could be a user error.
error:   info: Running start for app.
error:   info: Cleaning /opt/run
error:   info: Fetching application snapshot...
error:   info: Application snapshot fetched.
error:   info: Unpacking snapshot...
error:   info: Reading `package.json`...
error:   info: Starting application...
error:   info: Spawn: start --min-uptime 2000 -o /opt/run/forza.log -- forza -h multiplex.nodejitsu.com -p 8556 --start-log /opt/run/start.log --app-user hitman666 --app-name mean -- node node_modules/grunt-cli/bin/grunt
error:   info: `aeternum` pid: 63258
error:   info: Writing pidfile: /root/app.pid
error:   info: Tailing forza log: /opt/run/start.log
error:   info: Tail closing..
error:   info: Retry # 1 with 1000ms interval
error:   info: Tailing forza log: /opt/run/start.log
error:   info: Tail closing..
error:   info: Success:start

and naturally, I went looking if someone had a similar issue and it turns out someone on Stackoverflow asked this question. The OP (original poster) did find a solution him self and he said:

The gist of it was I had to move all grunt, karma, and forever dependencies to my devDependencies in the package.json file and change my start to “node server”.

Now, I tried to communicate with the OP to get some more info, but strangely no reply (yet). I figured it out myself in the end and this is how my package.json  file looks like now:

{
  "name": "mean",
  "description": "MEAN - A fullStack javascript framework powered by  MongoDB, ExpressJS, AngularJS, NodeJS.",
  "version": "0.1.2-1",
  "private": false,
  "repository": {
    "type": "git",
    "url": "https://github.com/linnovate/mean.git"
  },
  "engines": {
    "node": "0.10.x",
    "npm": "1.3.x"
  },
  "scripts": {
    "start": "node server.js",
    "test": "node node_modules/grunt-cli/bin/grunt test",
    "postinstall": "node node_modules/bower/bin/bower install"
  },
  "dependencies": {
    "express": "~3.4.7",
    "bower": "~1.2.8",
    "grunt-cli": "~0.1.11",
    "connect-mongo": "~0.4.0",
    "connect-flash": "~0.1.1",
    "consolidate": "~0.10.0",
    "swig": "~1.3.2",
    "mongoose": "~3.8.3",
    "passport": "~0.1.18",
    "passport-local": "~0.1.6",
    "passport-facebook": "~1.0.2",
    "passport-twitter": "~1.0.2",
    "passport-github": "~0.1.5",
    "passport-google-oauth": "~0.1.5",
    "passport-linkedin": "~0.1.3",
    "lodash": "~2.4.1",
    "forever": "~0.10.11",
    "view-helpers": "~0.1.4",
    "mean-logger": "0.0.1"
  },
  "devDependencies": {
    "grunt-env": "~0.4.1",
    "grunt-cli": "~0.1.11",
    "grunt-contrib-watch": "latest",
    "grunt-contrib-jshint": "latest",
    "grunt-karma": "~0.6.2",
    "grunt-nodemon": "0.2.0",
    "grunt-concurrent": "latest",
    "grunt-mocha-test": "latest",
    "karma": "~0.10.4",
    "karma-coffee-preprocessor": "~0.1.0",
    "karma-coverage": "~0.1.0",
    "karma-script-launcher": "~0.1.0",
    "karma-chrome-launcher": "~0.1.0",
    "karma-firefox-launcher": "~0.1.0",
    "karma-html2js-preprocessor": "~0.1.0",
    "karma-jasmine": "~0.1.3",
    "karma-requirejs": "~0.2.0",
    "karma-phantomjs-launcher": "~0.1.0",
    "forever": "~0.10.11",
    "supertest": "0.8.2",
    "should": "2.1.1"
  },
  "subdomain": "hitman666-mean2"
}

After making this change I deployed my application once more, and everything went without an error, but when I browsed it on Nodejitsu I got an error

502 Reached max retries limit

I realized that I don’t have a correct MongoDB connection string, and in order to change this I had to edit the file production.js which is in the config/env/  folder.MongoDBconnectionString

I copied the MongoDB connection string from Nodejitsu’s admin dashboard (I wrote about how to set this in my previous post: Getting started with Nodejitsu on Windows by deploying a MEN framework).

After this change I deployed my app again, and now everything was working, yay!

CodeProject, NodeJS

Deploying MongoDB and Node.js application on OpenShift

This is a post about getting started with OpenShift Online on a Windows machine by deploying a MongoDB, Node.js and RockMongo application for free. The reason why this wasn’t a title is that it’s just too darn long :). Cool, with getting that off my chest, we can now start…

OpenShift Online – Red Hat’s public cloud application development and hosting platform that automates the provisioning, management and scaling of applications so that you can focus on writing the code for your business, startup, or next big idea.

If you’ve tried OpenShift, you may have come across this offical how-to video only to find it completely useless. The accompanying official blog post is way better but still lacks some exact example code on, for example, how to connect to MongoDB from Node.js. Read on to see how I did it.

First, you have to create a new OpenShift account in case you don’t have one already.

Once you login to the site you get a nice looking dashboard and in order to create a new application you could click on the Add application button:
openshift_login

which would then offer really a lot of options:
openshift_applist

Setting up WordPress is easy as clicking the WordPress icon and naming your app on the next page:
openshift_wp
and clicking the Create Application button. After the process finishes (few mins) you get the instructions on how to alter the application:
openshift_wp_done
Basically, you clone the application’s source code with git and after doing some changes you push them back. At this point, all you have to do is visit the link of your newly created application (you can see the link in your Applications tab in the OpenShift admin interface) and you’ll get the WordPress init install screen:
openshift_wp_isntall

If you ever installed WordPress before everything should be familiar from now on. And there you have it – you have WordPress installed in a matter of few clicks.

Keep calm and roll up your sleves

You may be wondering where’s the MongoDB and Node.js from the title? Hack on…

So, we saw how easy it was to create an app from web admin interface, but since we’re devs and we loove terminal (don’t we ;)) we’re gonna take a different route here. OpenShift offers the OpenShift Client tools aka rhc. In order to install rhc you first have to have Ruby installed, and the easiest way to do this on a Windows machine is to install the RubyInstaller:

openshift_rubyinstaller

Just click the big red download button and I’m sure you now how to take it from there. Important note though, while installing just make sure that you check the Add Ruby executables to your PATH option:
openshift_rubypath

After the installation is done you can fire up your terminal (I use Console 2, and you can see my settings here: Customize Console 2 on Windows machine) and run

gem install rhc

and once this is done just run rhc setup  (this is an important part for us Windows users, as the official documentation on Installing OpenShift RHC Client Tools says we should only run rhc , and that does not work – as noted by the comments on that post).

Now we can use rhc to create a new application. To create a new application named myTest with Node.js and MongoDB you have to run:

rhc app create myTest nodejs-0.10 mongodb-2.4

and you’ll get an output similar to this:

C:\Users\Nikola\Desktop>rhc app create myTest nodejs-0.10 mongodb-2.4
DL is deprecated, please use Fiddle
Application Options
-------------------
Domain:     chavo
Cartridges: nodejs-0.10, mongodb-2.4
Gear Size:  default
Scaling:    no

Creating application 'myTest' ... done

  MongoDB 2.4 database added.  Please make note of these credentials:

   Root User:     admin
   Root Password: ..bip..Bip..
   Database Name: mytest

Connection URL: mongodb://$OPENSHIFT_MONGODB_DB_HOST:$OPENSHIFT_MONGODB_DB_PORT/

Waiting for your DNS name to be available ... done

Cloning into 'mytest'...
The authenticity of host 'mytest-chavo.rhcloud.com (54.235.21.98)' can't be established.
RSA key fingerprint is cf:ee:77:cb:0e:fc:02:d7:72:7e:ae:80:c0:90:88:a7.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'mytest-chavo.rhcloud.com,54.235.21.98' (RSA) to the list of known hosts.
Enter passphrase for key '/c/Users/Nikola/.ssh/id_rsa':
remote: Counting objects: 21, done.
remote: Compressing objects: 100% (17/17), done.
Receiving objects: 100% (21/21), 20.22 KiB, done.ceiving objects:  90% (19/21)

Your application 'mytest' is now available.

  URL:        http://mytest-chavo.rhcloud.com/
  SSH to:     [email protected]
  Git remote: ssh://[email protected]/~/git/mytest.git/
  Cloned to:  C:/Users/Nikola/Desktop/mytest

Run 'rhc show-app myTest' for more details about your app.

If you’re concerned about that ‘DL is deprecated, please use Fiddle‘, don’t be as it’s a mere warning as they say on Stackoverflow (or if you want to explore this topic further make sure you check this question on SO).

If you get an error saying that there’s no such cartridge you will get a list of all the available cartridges which you can use, so just adjust the above command accordingly

C:\Users\Nikola\Desktop>rhc app create
DL is deprecated, please use Fiddle
When creating an application, you must provide a name and a cartridge from the
list below:

Short Name      Full name
==========      =========
diy-0.1         Do-It-Yourself 0.1
jbossas-7       JBoss Application Server 7
jbosseap-6      JBoss Enterprise Application Platform 6
jenkins-1       Jenkins Server
nodejs-0.10     Node.js 0.10
nodejs-0.6      Node.js 0.6
perl-5.10       Perl 5.10
php-5.3         PHP 5.3
zend-5.6        PHP 5.3 with Zend Server 5.6
php-5.4         PHP 5.4
zend-6.1        PHP 5.4 with Zend Server 6.1
python-2.6      Python 2.6
python-2.7      Python 2.7
python-3.3      Python 3.3
ruby-1.8        Ruby 1.8
ruby-1.9        Ruby 1.9
jbossews-1.0    Tomcat 6 (JBoss EWS 1.0)
jbossews-2.0    Tomcat 7 (JBoss EWS 2.0)
jboss-vertx-2.1 Vert.x 2.1

Please specify the name of the application and the web cartridge to install
Usage: rhc app-create <name> <cartridge> [... <cartridge>] [... VARIABLE=VALUE]
[-n namespace]
Pass '--help' to see the full list of options

Keep on rockin’ on

MongoDB is an open-source document database, and the leading NoSQL database. In order to add RockMongo MongoDB administration, which is a web front-end for interacting with your MongoDB, you have to execute this command:

rhc cartridge add rockmongo

after which you get an output similar to this:

C:\Users\Nikola\Desktop\mytest>rhc cartridge add rockmongo
DL is deprecated, please use Fiddle
Using rockmongo-1.1 (RockMongo 1.1) for 'rockmongo'
Adding rockmongo-1.1 to application 'mytest' ... done

rockmongo-1.1 (RockMongo 1.1)
-----------------------------
  Gears:          Located with mongodb-2.4, nodejs-0.10
  Connection URL: https://mytest-chavo.rhcloud.com/rockmongo/

Please make note of these MongoDB credentials:
  RockMongo User: admin
  RockMongo Password: ..i.aint.telin'..
URL: https://mytest-chavo.rhcloud.com/rockmongo/

If you login to RockMongo by using the username and pass provided you will get a simple but useful interface:
openshift_rockmongo

However, if you prefer to do it via shell, you can do this:

rhc ssh

and after that start interactive command-line interface by typing mongo :

[mytest-chavo.rhcloud.com 532812f94382eca22b000657]\> mongo
MongoDB shell version: 2.4.6
connecting to: 127.9.197.130:27017/admin
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/
Questions? Try the support group
        http://groups.google.com/group/mongodb-user

Now let’s select a database, which will be same as your app’s name.

> use mytest
switched to db mytest

To insert some record we can do something like this:

> var a = {"user":"nikola", points:10};
> db.scores.insert(a);

and check if it was successfully inserted:

> db.scores.find();
{ "_id" : ObjectId("53284189d6e5e4aedb1fbafd"), "user" : "nikola", "points" : 10 }

To query this information with Node.js you first have to install mongojs with npm install mongojs . Then open up the server.js  file (it is in the root folder of your application) and add these lines in the self.createRoutes  object:

self.routes['/db'] = function(req, res) {
    var mongojs = require('mongojs');
    var dbName = "/mytest";
    var connection_string = process.env.OPENSHIFT_MONGODB_DB_USERNAME + ":" +  process.env.OPENSHIFT_MONGODB_DB_PASSWORD + "@" + process.env.OPENSHIFT_MONGODB_DB_HOST + dbName;
    var db = mongojs(connection_string, ['scores']);
    var books = db.collection('scores');

    db.scores.find(function(err, docs) {
       res.send(docs); 
    });
};

All aboard, and ready to take-off

Now it’s time to add the changes to the staging state with git add . (you may wanna check Git if this looks daunting). You can check the status of the files with git status . To commit the changes you have to execute:  git commit -a -m “Added code to talk to db” and finally git push  to send the changes to OpenShift for deployment.

Now, if you followed this tutorial, on the link http://mytest-chavo.rhcloud.com/db (notice this db here, and ofc exact link would reflect to your app) you should get this output:

openshift_dboutput

And a quick closing with with one useful command to get the overview of the app settings:

C:\Users\Nikola\Desktop\mytest>rhc app show
DL is deprecated, please use Fiddle
mytest @ http://mytest-chavo.rhcloud.com/ (uuid: 532812f94382eca22b000657)
--------------------------------------------------------------------------
  Domain:     chavo
  Created:    10:33 AM
  Gears:      1 (defaults to small)
  Git URL:    ssh://[email protected]/~/git/mytest.git/
  SSH:        [email protected]
  Deployment: auto (on git push)

  mongodb-2.4 (MongoDB 2.4)
  -------------------------
    Gears:          Located with nodejs-0.10, rockmongo-1.1
    Connection URL: mongodb://$OPENSHIFT_MONGODB_DB_HOST:$OPENSHIFT_MONGODB_DB_PORT/
    Database Name:  mytest
    Password:       ..ccc...
    Username:       admin

  nodejs-0.10 (Node.js 0.10)
  --------------------------
    Gears: Located with mongodb-2.4, rockmongo-1.1

  rockmongo-1.1 (RockMongo 1.1)
  -----------------------------
    Gears:          Located with mongodb-2.4, nodejs-0.10
    Connection URL: https://mytest-chavo.rhcloud.com/rockmongo/

And this is it, now it’s your time to make something useful with it!

Quick tips

Console 2 arrow keys not working

All of a sudden my arrow keys stopped working – up  and down keys scrolled the screen up and down, while left and right  had no effect. I found the solution here and basically all that you have to do is disable Scroll Lock on your keyboard! Pretty weird stuff, if I may add…

PHP

Simple PHP XML parser using SimpleXML

Say you have a simple XML file books.xml  that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<books>
	<book>
		<author>
			<name>Nikola</name>
			<surname>Brežnjak</surname>
		</author>
		<title>Some awesome book title</title>
		<year>2014</year>
	</book>

	<book>
		<author>
			<name>Patrick</name>
			<surname>Rothfuss</surname>
		</author>
		<title>Doors of stone</title>
		<year>20xx</year>
	</book>
</books>

and you want to get all the names of the authors, you can use SimpleXML:

<?php
	$xml = simplexml_load_file("books.xml");
	var_dump($xml);

	$data = array();
	foreach ($xml as $book){
		$data[] = (string)$book->author->name;
	}

	var_dump($data);
?>

The output in this case will look like this:
PHPsimpleXMLoutput

Books

Random English quotes from notebook #1

Every time I read a book I write quotes to my notebook, but also when I come across some good random quote I put it in as well. Just recently I filled up one of my “quote notebooks” so now I’ll post all the quotes from this notebook that are not “book specific” but instead spread throughout this notebook randomly. Not all books I read are in English, as you can see in the image, but I’ll be posting just those here…

And the day you finally decide to love will be the day that I have given up on chasing you.

Everyone is expendable.

The girl changed you and you don’t even know it.

Maybe God has a bigger plan for me then I have for myself.

There is no such thing as an ex con.

How do you pick up the threads of an old life? How do you go on, when in your heart you begin to understand that there is no going back? There are some things that time cannot mend.

Relationships are like glass. Sometimes it’s better to leave them broken them to hurt yourself putting in back together.

They say that people come in your life for a reason.

Enemy of my enemy is my friend.

Love till you hate, strong do you break.

You’ll learn, she said. Though it did not sound as an encouragement.

What if you were told that you could make a fortune just by pushing a button on a box? By pressing the button will simultaneously cause the death of another human being somewhere in the world. Someone you don’t know. Would you still push the button?!

When I do good I feel good. When I do bad, I feel bad. That’s my religion.

How much I missed simply because I was afraid of missing.

If I had a list of all the people that might come to visit me in prison, your name would be at the bottom. Somewhere below Jesus Christ and Scooby Doo.

The love is nothing, to be loved is something, to love and be loved is everything.

You’re just jealous because the voices are talking to me.

Pain is temporary pride is forever!

She’s the kind of woman that would rather go to sleep then to tap out.

If God made everything then he must be from China.

You don’t love a woman because she’s beautiful, she’s beautiful because you love her.

True love does not have a happy ending. True love doesn’t have an ending.

Come, live in my heart, and pay no rent.

Enjoy life but to be attentive. Don’t think there are no beast just because the forest is silent.

Hi, I’m a spider and I can make your girlfriend scream louder than you can.

I have learned to never assume too much when it comes to form users.

If you cant explain it to a six-year-old, you don’t understand it yourself.

When you really love someone age, distance, height, weight is just a darn number.

I’ve missed more than 9000 shots in my career. I lost almost 300 games. 26 times have been trusted to take the game winning shot and missed. I’ve failed over and over again in my life. And that is why I succeed.

It’s not that we don’t like you, we hate you. Period!

Hacker. Dropout. CEO.

I don’t get it why do people always assume the worst, when you tell them you’re a drug dealer.

Someday, and that day may never come, I may call upon you to do a service for me. But, until that day, accept this as a gift.

Life is so short, so why think about dying?

They killed God because he smiled on them.

They’ll bury it so deep it’ll be easier to reach if you start digging in China.

Why do we never know ourselves the way we think we do.

Once you know what you’re looking for, the rest comes easy.

The man who passes the sentence should swing the sword.

It’s uncomfortable to focus so intensely on what you’re bad at,” Spiegel told me. “So the way people usually study chess is they read a book about chess, which can be fun and often intellectually amusing, but it doesn’t actually translate into skill. If you really want to get better at chess, you have to look at your games and figure out what you’re doing wrong.

Spiegel wrote on her blog: The first day and a half was pretty bad. I was on a complete rampage, going over every game and being a huge bitch all the time: saying things like “THAT IS COMPLETELY UNACCEPTABLE!!!” to 11-year-olds for hanging pieces or not having a reason for a move. I said some amazing things to kids, including “You can count to two, right? Then you should have seen that!!” and “If you are not going to pay more attention, you should quit chess, because you are wasting everyone’s time.” By the end of round three I was starting to feel like an abusive jerk and was about to give up and be fake nice instead. But then in round four everyone took more than an hour and started playing well. And I really believe that’s why we seem to win girls’ nationals sections pretty easily every year: most people won’t tell teenage girls (especially the together, articulate ones) that they are lazy and the quality of their work is unacceptable. And sometimes kids need to hear that, or they have no reason to step up.

CodeProject, NodeJS

Getting started with Nodejitsu on Windows by deploying a MEN framework

Disclaimer: I’m in no way affiliated with Nodejitsu or any of the frameworks that I listed below in the post. I’m just documenting my experience with them – problems (and solutions) I’ve faced while trying these new technologies on a Windows machine.

MEN – MongoDB, Express, Node.js, and if you think MEN is not mean enough, take a look at the post on Deploying MEAN.io to Nodejitsu from Windows machine.

Nodejitsu is a cloud platform as a service based on Node.js and serves Node.js applications on their platform. Signup is free, you don’t have to enter billing info in order to try 2 months free (yes, databases work too!), just click on the “Do not select a product now” button:
nodejitsuFreeSignup
After signing up you get a confirmation mail like this:

Welcome to Nodejitsu!
Your Nodejitsu account is activated and ready to go!
username: userName
To confirm your account, install the latest jitsu:
sudo npm install jitsu -g
and then run:
jitsu users confirm userName big-h@5h
This will allow you to deploy applications with:
jitsu deploy

Setting up databases in the web admin interface is easy as you only have to literally click one button after deciding which database type and provider you want:
nodejitsuDatabases

Hackaton starters are gaining momentum  and there are quite a few of them already like:

  • Hackaton starter
  • Drywall
  • DozerJS
  • Skeleton
  • MEAN – only one which offers Angular out of the box (a follow up post on this is here)

I decided to try out Skeleton, mainly because I liked the “just right” Goldilocks reference 🙂

So, as the site suggests, you first have to installnodemon , gulp  andmocha , then clone the github repo, npm & bower install everything and you’re done:

# Install global dependencies
npm install -g nodemon gulp mocha

# Clone the repoo (and fetch only the latest commits)
git clone --depth=1 [email protected]:dstroot/skeleton.git
cd skeleton

# Install local dependencies
npm install
bower install

# Start everything up with Gulp 
# (builds the assets and starts the app with nodemon)
gulp

Everything works for you? Great! For the rest of unlucky ones, you may got (like me) after running gulp :

gulp

module.js:340
    throw err;
          ^
Error: Cannot find module 'jshint-stylish'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (C:\Users\Nikola\Desktop\skeleton\gulpfile.js:22:21)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

I tried npm install jshint-stylish , and ran gulp again:

C:\Users\Nikola\Desktop\skeleton>gulp
[gulp] Using gulpfile C:\Users\Nikola\Desktop\skeleton\gulpfile.js
[gulp] Starting 'clean'...
[gulp] Finished 'clean' after 11 ms
[gulp] Starting 'styles'...
[gulp] Starting 'scripts'...
[gulp] Starting 'images'...
[gulp] Finished 'images' after 2.75 ms
[gulp] Starting 'lint'...
[gulp] Finished 'lint' after 192 ms
[gulp] Starting 'watch'...
[gulp] Finished 'watch' after 151 ms
[gulp] Starting 'develop'...
[gulp] Finished 'develop' after 1.68 ms
[gulp] Live reload server listening on: 35729
[gulp] gulp-notify: [Gulp notification] Clean task complete

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Incorrect OS. node-notify requires Mac OS 10.8 or higher
    at C:\Users\Nikola\Desktop\skeleton\node_modules\gulp-notify\node_modules\no
de-notifier\lib\terminal-notifier.js:46:25
    at Object.module.exports.isMacOSX (C:\Users\Nikola\Desktop\skeleton\node_mod
ules\gulp-notify\node_modules\node-notifier\lib\utils.js:24:12)
    at Notifier.notify (C:\Users\Nikola\Desktop\skeleton\node_modules\gulp-notif
y\node_modules\node-notifier\lib\terminal-notifier.js:44:11)
    at module.exports (C:\Users\Nikola\Desktop\skeleton\node_modules\gulp-notify
\lib\report.js:17:5)
    at Transform._flush (C:\Users\Nikola\Desktop\skeleton\node_modules\gulp-noti
fy\lib\notify.js:41:5)
    at Transform.<anonymous> (C:\Users\Nikola\Desktop\skeleton\node_modules\gulp
-notify\node_modules\through2\node_modules\readable-stream\lib\_stream_transform
.js:130:12)
    at Transform.g (events.js:180:16)
    at Transform.EventEmitter.emit (events.js:92:17)
    at finishMaybe (C:\Users\Nikola\Desktop\skeleton\node_modules\gulp-notify\no
de_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:363:12)

    at endWritable (C:\Users\Nikola\Desktop\skeleton\node_modules\gulp-notify\no
de_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:370:3)

As the message says (note also on their website),  gulp notify , which uses node-notify  is not supported on Windows. The way I solved this was that I removed all of the .pipe(notify({ onLast: true, message: ‘Scripts task complete’ }))  lines from gulpfile.js, but it still wasn’t enough! Running lint job made the gulp fail, so I removed that to and woila then it all worked.

A note (though you can look this up on the official github page also) on how to setup Google login by:

  • Visit Google Cloud Console
  • Click CREATE PROJECT button
  • Enter Project Name, then click CREATE
  • Then select APIs & auth from the sidebar and click on Credentials tab
  • Click CREATE NEW CLIENT ID button
    • Application Type: Web Application
    • Authorized Javascript origins: http://localhost:3000
    • Authorized redirect URI: http://localhost:3000/auth/google/callback
  • Copy and paste Client ID and Client secret keys into config/config.js

:exclamation:Note: When you ready to deploy to production don’t forget to add your new url to Authorized Javascript origins and Authorized redirect URI, e.g. http://my-awesome-app.nodejitsu.com and http://my-awesome-app.nodejitsu.com/auth/google/callback respectively. The same goes for other providers.

Deploying to Nodejitsu is done by firstly  loging in and then executing jitsu deploy:

C:\Users\Nikola\Desktop\skeleton>jitsu login
info:    Welcome to Nodejitsu hitman666
info:    jitsu v0.13.15, node v0.10.26
info:    It worked if it ends with Nodejitsu ok
info:    Executing command login
prompt: username:  (hitman666)
prompt: password:
info:    Authenticated as hitman666
info:    Nodejitsu ok

C:\Users\Nikola\Desktop\skeleton>jitsu deploy

Boom, your app is live on Nodejitsu server and it should look like this (ofc YMMV in term of link):
skeletonWelcomeScreen

Quick tips

Customize Console 2 on Windows machine

If you’re using Console 2, and I don’t know why you wouldn’t want to btw, you probably wanted to customize it. Here is an excellent post by Scott Hanselman on how to do it:http://www.hanselman.com/blog/Console2ABetterWindowsCommandPrompt.aspx.

To change settings you have to right-click in the main console and click Edit | Settings.

The settings that I have used from his blog are:

  • I’ve set Desktop as my startup directory under Console – Startup Directory
  • I hid the menu, status bar and toolbar under Appearance | More
  • I’ve set the font to Consolas, but font only 12, as 15 (as he suggests) looks way too big on my screen. No experimentation with matrix colors or transparency.
  • I’ve set the option so that when I select with the mouse the selection gets coppied into the clipboard by selecting “Copy on Select” under Behavior
  • Hotkeys, changed the New Tab 1 hotkey to Ctrl-T
  • Hotkeys, changed Paste to Ctrl-V
  • Do not use Ctrl-C as Copy Selection or you will not be able to break some command that keeps running after you run it (like grunt for example). And besides if you used my settings then you already have a “Copy on Select” option set. More info here: http://sourceforge.net/p/console/bugs/401/

edit (18.3.2014): So, it turned out I wanted to be matrix cool :), so I went to change the color of the font, but to no avail. Finally I figured out that actually the grey color needed to be changed to green and not white as I was doing. Here’s an image to make thing clearer:
console2_color

Quick tips

Git push origin master could not read username for http://github.com

If you clone your project on another computer and try to do:

git push origin master

and you get and error like:

fatal: could not read Username for ‘https://github.com’: No such file or directory

then you can solve this by executing the following command:

git remote set-url origin [email protected]:username/repo.git

where, of course,username  and repo  depend on your settings.

For more info, check this StackOverflow question.

 

Books

The Wise Man’s Fear – Patrick Rothfuss

My favorite quotes from the book The Wise Man’s Fear by Patrick Rothfuss:

I don’t care what they talk, I care what they say.

There was an art to choosing your projects in fishery. It didn’t matter if you made the brightest sympathy lamp or the most efficient heat funnel in the history of artificing until someone bought it you wouldn’t make a bent penny of commission.

Most things fail with the age. Our hands and basks stiffen, our eyes dim, skin roghens and our beauty fades. The only exception is the voice. Properly cared for a voice does nothing but grow sweeter with age and constant use.

We love what we love. So, yes, it had flaws, so what does that had to matter when it comes to the matters of the heart. We love what to love. Reason does not enter into it. In many ways unwise love is the truest love. Anyone can love a thing ‘because’. That’s as easy as putting a penny in your pocket. But to love something ‘despite’, to know the flaws, and love them too. That is rare end pure and perfect.

Why Auri? Because she doesn’t have anyone else, and neither do I. If we don’t look out for each other – who will?

The desire for a knowledge shapes the mind

The second was some rather bad poetry, but it was short and I forced my way through gritting my teeth and occasionally closing one eye, so it is not to damage the entirety of my brain.

If we didn’t have impressive sounding names no one would take us seriously.

You’d be amazed how similar arrogance and confidence look at first glance. And he was generous and rich – which is a nice combination.

Clothes do not make a man, but you need a proper costume if you want to play the part.

They were the best sort of friends. The sort everyone hopes for but no one deserves.

When you’re around it’s easy to forget all the bad parts of my life – who I am – it’s nice to take a vacation from myself every once in a while. You’re my safe harbor in an endless stormy sea. You’re my shady willow on a sunny day. You’re sweet music in a distant room. You’re unexpected cake on a rainy day. You’re my bright penny on the roadside, you are worth more than the moon on the long night walk. You are sweet wine in my mouth, a song in my throat and laughter in my heart. You’re too good for me. You are a luxury I cannot afford. Despite this I insist you come with me today, I will buy you dinner and spend hours waxing rhapsodic landscape of wonder that is you.

Lord woman, if I had tits like yours I’d own half the world by now.

Poetry is a song without music. The song without music is like a body without soul.

Too much looking can get in the way of seeing.

The world needs people like you. You get things done. Not always the best or most sensible way but it gets done. You’re a rare creature. You know exactly what to do. You don’t hesitate – you just see and react.

That’s another problem with power. If you possess too much people don’t date point out your mistakes.

I’ll need to know more about her. Trying to court a woman without knowing her would be worse than foolish.

History tends to be rather dry, but everyone enjoys story.

It’s hard to long for something that is always there. Absence feeds affection.

A secret of the mouth is like a stone in a boot. At first you’re barely aware of it, then grows irritating, then intolerable. Secrets of the mouth grow larger the longer you keep them swelling until they press against your lips. They fight to be let free. Secrets of the heart are different. They are private and painful and we want nothing more than to hide them from the world. They do not swell or press against the mouth, they live in the heart and a longer they are kept the heavier they become. He complains that it’s better to have a mouthful of poison than the secret of a heart. Any fool will spit out poison, but we support these painful treasures. We swallow hard against them every day, forcing them deep inside us. There they sit, growing heavier – given the time they cannot help but crush the heart that holds them.

Nothing in the world is harder than convincing someone of an unfamiliar truth.

Only a fool worries over what he can’t control

Half of seeming clever is keeping your mouth shut at the right times.

Boys are always wearing beards hoping it will make them men.

Leader is not the muscle leader is a mind.

I learned more from a month on the road then I had in three years of classes. No man is brave that has never walked a hundred miles. If you want to know the truth of who you are walk until not a person knows your name. Travel is the great leveler, a great teacher. Bitter as medicine, cruder than glass. Long stretch of road will teach you more about yourself than 100 years of quiet introspective.

But sometimes the best help a person can find is helping someone else.

If a leg goes bad you need to cut it off, and some folks need killing.

They did important things. They made hard choices that no one else was willing to do. That sort of thing frightens people.

It’s one thing to enjoy story but it’s quite another to take it for the truth.

Page 50 of 52« First...102030«49505152»

Recent posts

  • SendGrid Phishing Scam Attempts
  • Retrospective Questions
  • When espanso Breaks on Long Replacement Strings (and How to Fix It)
  • 2024 Top Author on dev.to
  • Hara hachi bun me

Categories

  • Android (3)
  • Books (114)
    • Programming (22)
  • CodeProject (36)
  • Daily Thoughts (78)
  • Go (3)
  • iOS (5)
  • JavaScript (128)
    • Angular (4)
    • Angular 2 (3)
    • Ionic (61)
    • Ionic2 (2)
    • Ionic3 (8)
    • MEAN (3)
    • NodeJS (27)
    • Phaser (1)
    • React (1)
    • Three.js (1)
    • Vue.js (3)
  • Leadership (1)
  • Meetups (8)
  • Miscellaneou$ (80)
    • Breaking News (8)
    • CodeSchool (2)
    • Hacker Games (3)
    • Pluralsight (7)
    • Projects (2)
    • Sublime Text (2)
  • PHP (6)
  • Quick tips (41)
  • Servers (8)
    • Heroku (1)
    • Linux (3)
  • Stack Overflow (81)
  • Unity3D (9)
  • Windows (8)
    • C# (2)
    • WPF (3)
  • Wordpress (2)

"There's no short-term solution for a long-term result." ~ Greg Plitt

"Everything around you that you call life was made up by people that were no smarter than you." ~ S. Jobs

"Hard work beats talent when talent doesn't work hard." ~ Tim Notke

© since 2016 - Nikola Brežnjak