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

Speed reading and learning

Since I like to read (like, a lot), I realized I should test my reading speed and as it turned out I’m at an average person reading speed of 230 WPM. That was not a too big of a surprise as I always thought I read slow. Anyways, I decided to take one of those “increase your reading speed classes”, and here are my notes from these lectures:

Inner voice makes us read at the speed as we talk! Subvocalization is the root of all evil.

RAS – Reticular Activating System (example when you’re looking to buy some new phone you’re seeing the phone commercials everywhere, but once you buy it the commercials ‘dissapear’)

TV is passive medium, you can learn something, but you end up forgetting it quite easily.

AVOID SKIPPING BACK – 30% skipping back, save 20% time! – imagine you can’t go back – you will increase attention after you read and thought to yourself “I didn’t understand”, and if the book is good it will repeat the premise.

When brain is on 20 cycles per second then you’re in the “zone”.

METRONOM + POINTER!

First, when you start reading on a higher speed the comprehension drops, but if you force that speed the comprehension will rise up and exceed the previous one.

Eyerobics – open wide, close hard, blink hard, left-right look, all around look, look to the window.

MIN – MAX method – min 1 page per day, max 50, normal 15, but the point is to read everyday!

Check this out: Timothy Ferris: The 4-hour workweek

Pareto principle – 80/20 – 20% efforts => 80% results. 80% additional efforts => 20% results

Tim Doner speaks > 20 languages! Benny Lewis – Fluent in three months

I want to succeed in this course because:

  • I want to be able to read all the books I, now, don’t have the time to read both techincal and fictional
  • I want to learn new things and retain as much information as possible as this will make me a better man, father, software engineer
  • I want to earn more by knowing more
  • I want to help others by knowing more stuff
  • I want to personally grow by knowing more

Neurons and synapses

Hose => Funnel => bucket – order of necessary upgrades goes backwards! So, first you have to improve your memory in your head (bucket) then increase the amount of info going in (funnel) and then increase the speed of increased data that’s going in (hose).

Superlearners create dense connections

Transform concepts and ideas into pictures => so we can remember them better.

Exercise: read an article and try to remember 10 things in a way that you connect them with pictures.

Image types:  fictional, personal, graphical, stereotypical

3 memory stages: encoding, storage, retrieval

30sec pause every 10mins, 1sec pause every paragraph!

Working memory – from this to next level => 1sec pause every paragraph
Short term mem – from this to next level => 30 sec pause every 10 min
Long term mem

Short term memory lasts for about 10 min and if we don’t commit (think git commit) it to a long term memory then we forget it (think git reset –hard HEAD).

High quality markers:

  • are details we can describe in 1-2 words
  • themselves encoded with rich detail
  • clearly & logically interconnected
  • emphasize answers not questions
  • more is better

Go for details => concepts (basically you go bottoms up, so that you remember details and then you connect them in a main story)

Creating markers is the real deal!, practice making detailed markers.

Pre-reading 2,3 sec per page! Make a pre-reading and remember just a few words and then when you start reading you’re eager to answer the questions you formed during pre-reading.

The adult learner requirements

  • use of prior experience and knowledge
  • clear goals and appropriate readiness
  • internal motivation and self direction
  • practical application in their lives
  • understanding of relevance
  • respect 

Adult students become ready to learn when they experience a need to learn in order to cope more satisfyingly with real-life tasks or problems.

Andragogy (Malcom Knowles): teaching adult people how to learn.

Imagine two or three separate columns on the page. Eyes are faster in jumping then in line movements. Jumps are called Sacades –  rapid movements of the eyes between fixation points.

Never ever go back in text. Reading with a card – cover up and drag down.

Push yourself!

Do tests with 250, 350, 500, 700 i 1000 WPM

No pain no gain bro!

If everything seems under control you’re not going fast enough!

Exercise: in 5 seconds do a pre-reading flash 3 times focusing first on left, then middle then right part.

There is no substitute for hard work.
~ T. A. Edison

Memory temple vs mind mapping

Mapping numbers 0-9 to words and then making a sentence out of them.

22-24 mins power nap (this I have been conducting for the past 2 months now and I recommend it to everyone!)

Refresh learned after 1 week, month, 3 months and you’ll never forget it!

Some apps that may help with speed reading: https://github.com/ds300/jetzt, http://www.spritzinc.com/ (and my blog post on Spritz).

Bottom line, my speed is now at a solid 450 WPM which is almost 100% more than when I started – yay for me! If you’re skeptic about this as I was (fearing your understanding will go down) just give it a try and decide for yourself if this is something worth pursuing – IMHO it is.

Books

A Short History of Nearly Everything – Bill Bryson

My favourite quotes from the book A Short History of Nearly Everything by Bill Bryson:

Once in a great while, and few times in history, a human mind produces observation so acute and so unexpected that people can’t quite decide which is more amazing, the fact or the thinking of it.

Scientists dealt with this paradox in the handiest possible way – they ignored it.

Sometimes world just isn’t ready for a good idea.

The good news appears is that it takes an awful lot to extinguish species. The bad news is good news can never be counted on.

Three stages in scientific discovery: 1: people deny that it’s true. 2: then they deny that it’s important. 3: finally they credit the wrong person.

It’s an unnerving thought that we may be the living universe’s supreme achievement and its worst nightmare simultaneously.

CodeProject, JavaScript

Simple official Spritz API usage

TL;DR: See it in action here or here, and official site here.

Spritz – change the way people read and make communication faster, easier, and more effective.

So, there has been a lot of buzz about this lately and today I too got my API key to test this out. I must say that using Spritz is really easy, and they have a very good documentation with examples so I will keep this short.

After you register to their developer program you will get your API key. A simple use case to get you started is to make a HTML document with the following content:

<!DOCTYPE html>
<html>
<head>
	<script type="text/javascript" src="jquery-2.1.0.min.js"></script>
	<script type="text/javascript">
        var SpritzSettings = {
            clientId: "4aac1453ff37b364f",
            redirectUri: "http://www.nikola-breznjak.com/codez/spritz/login_success.html",
        };
    </script>

 	<script type="text/javascript" src="spritz.min.js"></script>
</head>

<body>
    <h1>Spritz test</h1>

  	<div data-role="spritzer"></div>

    <div>This is some demo text that will be Spritzt</div>
  	</div>
</body>
</html>

Important things to note here are that Spritz uses jQuery and you have to use your clientId and put this rediretUri file to your server (on which you host the domain with which you registered your Spritz application).

A little more advanced example is here: http://www.nikola-breznjak.com/codez/spritz/ (you can just view the source of it and I’m sure you’ll know how to take it from there).

Worth noting is that there are some open source versions of this like Open Spritz, though I think this one is way better as it has whole research and the science behind it.

Using this on a simple HTML page was, well, simple. I tried to incorporate this into my wordpress blog (the one you’re reading right now), and though it works nicely when I put the code in the index.php file (the main template file which lists all of the posts), it does not work when I put the same exact code to the single.php (template for showing specific posts). The error that I’m getting in the latter case is this:

Unable to spritz: Unable to retrieve contentVersion, contentId=5343e07be4b063e2752c379b: HTTP call failed, status: 500, message: Internal Server Error

So, if someone got the same error, how did you go about it?

Books

The Cuckoo’s Calling – Robert Galbraith

My favourite quotes from the book The Cuckoo’s Calling by Robert Galbraith aka J.K.Rowling:

There were other routes to woman’s intimacy than to admire her figure in tight dress.

And the best plan is, as the popular saying was, to profit by the folly of others.

He’s about five fucking feet too short to model.

Lose some weight, he told Strike as a parting shot, and I’ll send you something XXL.

The dead can only speak through the mouths of those left behind, and through the signs they left scattered behind them.

He’s not sane, which isn’t to say he’s not a clever fucker.

CodeProject, PHP

POST JSON Data With PHP cURL wrapper class

PHP biceps cURL 🙂

Following is the PHP cURL wrapper class which I use to make GET and POST requests. The examples are below. Disclamer:  be sure that you have permission to scrape and use the content you’re after.

This code is also available on GitHub at this link: https://github.com/Hitman666/PHPcURLWrapper

Class code and simple GET request

//CurlWrapper_static.php

class CurlWrapper {
    private static $useragents = array(            
        "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36",
        "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; WOW64; Trident/4.0; SLCC1)",
        "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0",
        "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/537.75.14"
    );

	private static $cookiesFile = "curlCookies.txt";

    private static function getUserAgent() {
    	$rand = rand(0, count(self::$useragents) - 1);

    	return self::$useragents[$rand];
    }

    public static function SendRequest($url, $ref = "", $type = "GET", $postData = "", $headers = "", $proxy = "") {
        $useragent = self::getUserAgent();

        $ch = curl_init();
		curl_setopt($ch, CURLOPT_URL,$url);
		curl_setopt($ch, CURLOPT_TIMEOUT,120);
		curl_setopt($ch, CURLOPT_USERAGENT, self::getUserAgent());

		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_AUTOREFERER, true);

		curl_setopt($ch, CURLOPT_COOKIEJAR, realpath(self::$cookiesFile)); 
		curl_setopt($ch, CURLOPT_COOKIEFILE, realpath(self::$cookiesFile));

		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        //options
        if ($ref != "") {
            curl_setopt($ch, CURLOPT_REFERER, $ref);
        }

		if ($proxy != "") {
			curl_setopt($ch, CURLOPT_PROXY, $proxy);
		}

		if ($type == "POST"){
			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
			curl_setopt($ch, CURLOPT_POST, true);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
		}

		if ($headers != ""){
			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
		}

        $result = curl_exec($ch);
		curl_close($ch);

		return $result;
	}
}

Simple GET request:

require("CurlWrapper_static.php");

$googleHTML = CurlWrapper::SendRequest('https://www.google.com');
echo $googleHTML;

If you’re a firm non-static lover here’s a “normal” class:

//CurlWrapper_nonStatic.php

class CurlWrapper{    
    private $_useragents = array(            
        "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36",
        "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; WOW64; Trident/4.0; SLCC1)",
        "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0",
        "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/537.75.14"
    );

	private $_cookiesFile = "curlCookies.txt";

    private function getUserAgent(){
    	$rand = rand(0, count($this->_useragents));

    	return $useragents[$rand];
    }

    public function SendRequest($url, $ref = "", $type = "GET", $postData = "", $headers = "", $proxy = "") {
        $useragent = $this->getUserAgent();
        echo $useragent;

        $ch = curl_init();
		curl_setopt($ch, CURLOPT_URL,$url);
		curl_setopt($ch, CURLOPT_TIMEOUT,120);
		curl_setopt($ch, CURLOPT_USERAGENT, $useragent);

		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_AUTOREFERER, true);

		curl_setopt($ch, CURLOPT_COOKIEJAR, realpath($this->_cookiesFile)); 
		curl_setopt($ch, CURLOPT_COOKIEFILE, realpath($this->_cookiesFile));

		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        //options
        if ($ref != "") {
            curl_setopt($ch, CURLOPT_REFERER, $ref);
        }

		if ($proxy != "") {
			curl_setopt($ch, CURLOPT_PROXY, $proxy);
		}

		if ($type == "POST"){
			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
			curl_setopt($ch, CURLOPT_POST, true);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
		}

		if ($headers != ""){
			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
		}

        $result = curl_exec($ch);
		curl_close($ch);

		return $result;
	}
}

How to use it with simple GET request:

require("CurlWrapper_nonStatic.php");

$curl = new CurlWrapper();
$googleHTML = $curl->SendRequest('https://www.google.com');
echo $googleHTML;

JSON POST request

Here’s an example of sending a JSON POST request to imaginitive URL ‘http://service.com/getData.json’ with some data array:

	require("CurlWrapper_static.php");

	$cookieSettingUrl = 'http://service.com/';
	$cookie = CurlWrapper::SendRequest($cookieSettingUrl);

	$data = array(
		"year" => 2014,
		"day" => 3,
                "month" => 4,
		"id" => 20
    );
	$postData = json_encode($data);

	$jsonUrl = 'http://service.com/getData.json';
	$headers = array('Accept: application/json','Content-Type: application/json');

	$resultsHTML = CurlWrapper::SendRequest($jsonUrl, $cookieSettingUrl, "POST", $postData, $headers);
	$resultsJson = json_decode($resultsHTML);
	var_dump($resultsJson);

Important to note is that you have to add proper $headers array, and that you json_encode your data array as shown when POSTing to a service which expects JSON data.

Cookies

The reason why I first used these two lines:

$cookieSettingUrl = 'http://service.com/';
$cookie = CurlWrapper::SendRequest($cookieSettingUrl);

is to set any cookies (and you will find that some services do this) that may be needed to be sent along with the request to ‘http://service.com/getData.json’. Cookies are set to ‘curlCookies.txt’ in the CurlWrapper_* class. You can change this to your liking, and you have to make sure that you set proper permissions for this file.

Hope this proves useful to someone.

Linux

How to use crontab in specific use cases

Here I will post non standard and ‘out of the ordinary’ crontab settings. A note to myself (ANTM): crontab file in Centos is located in /etc/crontab. Lets start:

Run a cron job every 5 minutes but starting from minute 3.

Surely you can go about this like so:

3,8,13,18,23,28,33,38,43,48,53,58 * * * * /bin/mycommand

but there’s much cleaner way of doing it:

3-59/5 * * * * /bin/mycommand

More info can be found on this Stack Overflow question and also another option is suggested here and goes like this:

*/5+3 * * * * /bin/mycommand

Similarly

Run a cron job every 5 minutes

*/5 * * * * /bin/mycommand

 

Books

The Woodcutter – Reginald Hill

My favourite quotes from the book The Woodcutter by Reginald Hill:

He was certainly very good to talk to, meaning of course he was a good listener.

The written word and gave them to see a physical existence.

The evidence was overwhelming. The jury took 20 minutes to find you guilty. 12 strangers, 12 citizens picked of the street. In this world we’re unfortunate to live in, and especially in this septic aisle we live on, where squalid politicians conspire with a squalid press to feed a half educated and wholly contemplated public on a diet of meritorious trivia. I’m sure it will be possible to concourt enough evidence to persuade 12 strangers that Nelson Mandela was a canibal.

Only a fool lives in a house another fool can throw him out of any time he likes.

Only climbers or real idiots climb up there without the rope.

Johnny could do just about anything until someone told him what to do.

Life was a struggle if you left yourself at the mercy of feelings.

Not exactly thinking but aware that there were thoughts in the room that might keep you awake were you foolish enough to think them.

Universities are full of books, but hard cash is always in short supply.

Grim necessity makes strange bed fellows.

Today’s lie will sell more than yesterday’s truth.

There is neither happiness nor misery in the world, only the comparison of one state with the other.
Only the man who has plumb the depths of misfortune is capable of scaling the heights of joy. To grasp how good it is to live, you must have been driven to long for death. Live then and be happy, dear children of my heart and never forget: until the day arrives when God in his mercy unveils the future to man, all of human wisdom lives in these two words: WAIT and HOPE.

Most relationships end with deceit, your’s began with it.

Phaser

Make a Flappy Bird clone with Phaser

Flappy Bird – no info as anyone who may be reading this knows about it 😉

Phaser – open source desktop and mobile HTML5 game framework supporting both JavaScript and TypeScript

This is basically just an addition to the great 3 series tutorial (part 1, part 2, part 3) from LessMilk’s blog and hereby I thank him for them.

The original tutorial makes the bird (square) jump by pressing the space key, whilst to make the bird jump on a mouse click (or tap on mobile devices) all you have to do is replace the

var space_key = this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);

in the menu.js  file with:

var space_key = this.game.input;

Also, I added the crash sound (original file from here) in the hit_pipe  function:

if (this.bird.alive == false){
    this.crash_sound.play();
    return;
}

which I’ve defined in the create  function:

this.crash_sound = this.game.add.audio('crash');

of the file play.js .

You can download this changed code from Github, and try out the game here.

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!

Page 49 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