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
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.

NodeJS

Can’t install gulp.js or update npm past version 1.2.32

My problem started with not being able to install gulp. I checked my npm version (npm –version ) and saw I have version 1.2.32 whilst the time of this writing the newest version was 1.4.3. After countless trying of commands like

npm cache clean
npm update -g npm
npm update
npm install gulp -g

and reinstalling Node.js from official site I realized that even though I removed my Node.js installation from C:\Program Files\nodejs  I still had it in C:\Program Files (x86). Doh! :/ So, after I removed both installations, I redownloaded the exe file from Nodejs.org and installed to C:\nodejs. After this, when I ran npm install gulp everything went well. However, when I tried to install it globally (npm install gulp -g ) I got:

npm ERR! peerinvalid The package generator-karma does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants generator-karma@~0.6.0
npm ERR! peerinvalid Peer [email protected] wants generator-karma@>=0.6.0

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\nodejs\\\\node.exe" "C:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "gulp-util" "-g"
npm ERR! cwd C:\Users\Nikola\Desktop\skeleton
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code EPEERINVALID
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\Nikola\Desktop\skeleton\npm-debug.log
npm ERR! not ok code 0

Then I uninstalled npm uninstall -g generator-karma and npm uninstall -g generator-angular , and gulp installed fine.

 

Heroku, NodeJS, Windows

Getting Started with Node.js on Heroku on a Windows machine

Heroku is a cloud platform as a service supporting several programming languages which lets app developers spend their time on their application code, not managing servers, deployment, ongoing operations, or scaling…

If you tried to get your feet wet with Heroku by deploying Node.js application, you must have come across this article on Heroku’s documentation (and you also may have run into problems when starting Foreman if you’re on a Windows machine – read onward to see how I’ve solved it).

Obviously, first you have to make an account on Heroku, then install Heroku toolbelt (it gives you git, foreman, and heroku command line interface) for your environment (in my case Windows):
herokuToolbelt

Fire up your command prompt (I use Console2) and run heroku login . You need to have Node.js installed (in case you don’t you can download it here).

Write some Node.js app and put it in app.js file:

//app.js
var express = require("express");
var app = express();

app.get('/', function(req, res) {
  res.send('Every day in every way I\'m serving more requests');
});

var port = Number(process.env.PORT || 5000);
app.listen(port, function() {
  console.log("Listening on " + port);
});

If you have  package.json  file then Heroku will recognize your app as Node.js app. In order to create it, run npm init  in the root directory of your app. The npm init utility will walk you through creating a package.json file by asking few questions. If you already made your repository on GitHub and cloned it locally then npm init command in this folder will recognize that too and add:

"repository": {
    "type": "git",
    "url": "https://github.com/yourUsername/appName.git"
}

If you wish, you can freely clone my test app from Github: https://github.com/Hitman666/herokuTestApp.git

Next, install dependencies from your code (in app.js  example the required module is express). Use npm install <pkg> –save  to install a package and save it as a dependency in the package.json file. In my example that would be one command:

npm install express --save

 

You have to set a Procfile, which is a text file in the root directory of your application, to explicitly declare what command should be executed to start a web dyno. In our case this would be the contents of Procfile:

web: node app.js

Now you should be able to start your application locally using Foreman (installed as part of the Heroku Toolbelt) by running foreman start .

But here the party started :/

In my case foreman didn’t start at all, and after a lot of searching, I managed to solve it in few steps. First, I updated my Ruby installation:

gem update --system --source http://rubygems.org/

Then, according to this StackOverflow post I installed former version of foreman:

gem uninstall foreman
gem install foreman -v 0.61

Finally, I added Ruby’s bin folder (Ruby which, in my case, is in C:\Program Files (x86)\Heroku\ruby-1.9.2\bin) to my PATH variable.

Ok, almost there! Lets add our app to git (you should skip the git init command if you already cloned your app from GitHub):

git init
git add .
git commit -m "init"

and finally, lets deploy it to Heroku:

heroku create
git push heroku master

To open the app in your browser run heroku open . To push the changes to GitHub you have to execute git push origin master.

*Now that your app is up and running on heroku (my link) you may want to prevent it from going to sleep mode. Some suggestions on how to achieve this are in this post on StackOverflow (I went with UptimeRobot).

**At some point, as I was fiddling with the apps on Heroku’s website, I deleted all apps and then the git push heroku master  command from my console was not working anymore, so I had to do:

git remote rm heroku
heroku create
git push heroku master

***Also, I wanted to rename my app and that can be done easily:

heroku apps:rename NEWNAME

 

Page 50 of 51« First...102030«48495051»

Recent posts

  • When espanso Breaks on Long Replacement Strings (and How to Fix It)
  • 2024 Top Author on dev.to
  • Hara hachi bun me
  • Discipline is also a talent
  • Play for the fun of it

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$ (78)
    • 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