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
Miscellaneou$

Makers vs Consumers – don’t hate, donate

When was the last time you contributed to some open source project? Did you ever even click on that little star on Github? Or, when was the last time you showed support to the people who work for free on these projects that you take for granted and use daily for your (commercial) projects!?

A lot of people in the software development world started saying $hit about the makers of certain open source projects. That is really not the route you want to take as a professional, so please stop it. I really won’t go any deeper than that, because if they don’t understand that that’s not nice/moral/right, then I see no hope for them to ever grow as persons or developers.

If you indeed find something that’s lacking, instead of complaining

make a freaking meaningful pull request!

For all those who are complaining that “it’s hard to keep up with all the change in the web development world with all these new tools and hundred ways of doing the same thing” I only have one thing to say:

You don’t need to jump into every new framework that comes out. However, you do need to (in your chosen field) adapt, grow, or walk away. It’s really not for everyone. If you’re not willing to daily invest time to hone your skills as a developer then I have to conclude that you came into this field for all the wrong reasons!

Below is the awesome video on this topic by the awesome Mattias P Johansson (@mpjme). You should check out his videos, he has a really good series (presented in a fresh and fun way) about JavaScript.

All in all, dear people:

don’t hate, donate!

And, dear makers, don’t get discouraged, because without you these ungrateful consumers will, well, be worthlessly lost…

#Makers vs #Consumers – don't hate, donate. Eye opening​ video by @mpjme https://t.co/2IxIvzYMgq

— Nikola Brežnjak (@HitmanHR) January 19, 2016

Ionic, Stack Overflow

Ionic – how to handle when external api server is offline?

In this StackOverflow question I answered how to handle when external API server is offline.

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

As you may know, I’m really into Ionic framework lately and am helping out on StackOverflow with the knowledge I gained so far with the framework. I’m currently #3 in the top All time answerers list.

I answered this question by user Rflujowa:

I’m writing a app in ionic. The app relies on external api’s. I’ve made multiple functions to test the connection, to my own server, and my own server handles the api calls. My own server is needed for this because of ip-whitelistening.

All works well, but now i want to disable the application if the result from my own server is false. I make a call to test the connection everytime the app starts.

What is the best way to handle this with angular/ionic?

1 thought i had myself is to redirect to a landingpage, if no connection is available.

Any tips are welcome.

My answer was:

Yes, basically what you planned to do is OK.

So, just after your app loads up, check if the connection is available (you can read more about how to do that in my detailed post How to check network information change with Ionic framework), and if not then you can change the state to some page where it would clearly let the user know that “Currently the link to the server is not working” (or some better notification).

Also, probably you would want to put a refresh button on that page, so that one could click it and the whole availability process would be checked again (basically same as if someone restarted your app).

Hope this helps.

How to handle when external #API server is offline in @ionicframework? https://t.co/FSGt6AoXCQ

— Nikola Brežnjak (@HitmanHR) January 19, 2016

Books

Night School: Wake up to the power of sleep – Richard Wiesman

My notes from the great book Big Magic: Creative Living Beyond Fear by Richard Wiesman, which will definitely banish some false presumptions that we may have:

Hypnagogic myoclonic twitch -70% of people experience it

Deep sleep – you won’t wake up unless you smell burning – someone says your name, or you hear a very loud noise

We spend 50% in the light sleep, 20% in deep sleep, 25% in REM, 5% in brief awakenings

Humans have internal clock inside them

The king sleeps on his back, the sage on his side and the rich man on his belly.

Create your own bat cave

The main problem with common sense is that it is not so common.

For night terrors and sleepwalking wake the child up 20 minutes before the episodes usually start. Give them a glass of water and read them a bedtime story. Repeating this 10 days in a row reduces night terrors by two thirds.

Power napping FTW!

If you wake up at 6 AM then the perfect naptime is 1:30 PM.

Drink caffeinated drink just before dozing off. It will work it’s magic about after 20 minutes, just as you wake up.

Add some nice smell in your bedroom.

Image rehearsal therapy 

Banish blue light

Positive imagery and the paradox principal

Make a list of worries

Don’t cram the night before, get a good night sleep

Fly east flight early, fly west fly late

Napping is awesome

Describe dream and use as a basis for change

Pre-sleep suggestion

My notes from the #book Night School: wake up to the power of #sleep by Richard Wiesman – https://t.co/QW8MbWMw1S pic.twitter.com/3ekxKNpnTk

— Nikola Brežnjak (@HitmanHR) January 18, 2016

Ionic, Stack Overflow

I made it to the top of StackOverflow’s all time answerers list for Ionic tag

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow, and I tend to contribute regularly (am currently in the top 0.X%).

As you may know, I’m really into Ionic framework and am helping out on StackOverflow with the knowledge I gained so far with the framework.

Finally, I reached my goal and made it to the #1 position in the top All time answerers list, and finally, obtained my first “ionic” tag badge:

soIonicTag

See you at the golden badge 😉

I made it to the #top of #StackOverflow's all time answerers list for @ionicframework tag https://t.co/X8iR2gi7DD pic.twitter.com/awmvGnHljQ

— Nikola Brežnjak (@HitmanHR) January 14, 2016

Ionic, NodeJS, Stack Overflow

How to run Node.js server in Ionic mobile app?

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

As you may know, I’m really into Ionic framework lately and am helping out on StackOverflow with the knowledge I gained so far with the framework. I’m currently #1 in the top All time answerers list.

I answered this question by user Shubham:

I am making an app using MEAN and ionic framework where nodejs is a middleware to connect to the database(mongoDb). I need to run the nodejs server using node server.js and the app using ionic serve. This is my server.js.

var express          = require('express'),
app              = express(),
bodyParser       = require('body-parser'),
mongoose         = require('mongoose'),
CohortController =require('./www/server/controller/CohortController');

mongoose.connect('mongodb://localhost:27017/persistent');

app.use(bodyParser());

app.get('/api/cohorts',CohortController.list);
app.post('/api/cohorts',CohortController.create);

app.listen(3000,function(){
console.log('Listening...');
})

Now this is my app.js. I use http://localhost:3000 to get the JSON.

app.controller('CohortController',['$scope','$resource',
  function($scope,$resource){
    var Cohort=$resource('http://localhost:3000/api/cohorts');
    Cohort.query(function(results){
      $scope.cohorts=results;
    });
    $scope.cohorts=[];

    $scope.createCohort= function () {
      var cohort=new Cohort();
      cohort.name=$scope.CohortName;
      cohort.id=$scope.CohortId;
      cohort.$save(function(result){
        $scope.cohorts.push(result);
        $scope.CohortName='';
        $scope.CohortId='';
      });
    }
  }]);

How can I run the node server when I convert it into a mobile application? How the application will use the API?

My answer was:

You will have to have your Node.js app running on a server which you would then access (from your Ionic app) via it’s public IP. So, you wouldn’t use http://localhost:3000 to get the JSON, instead you would use something like http://123.456.789.123:3000.

But, usually, this is not the way you would do it (with the port 3000). What you would additionally do is put (for example) Nginx in front of your Node.js app (see an example here) in order to serve your api from the standard HTTP port (80).

So, basically, you can’t actually “run Node.js server in Ionic app” – the way you do it is run the Node.js app separate from Ionic and expose its functionality via a standardized API (usually these days RESTis what you would want to achieve) which you then “consume” via Ionic’s (well, to be exact, it’s actually Angular’s) $resource module.

Hope this helps clear things up a bit.

How to run #Node.js server in #Ionic mobile app? https://t.co/8SOUYGM3Vf

— Nikola Brežnjak (@HitmanHR) January 12, 2016

Books

Work rules – Laszlo Block

My notes from the book Big Magic: Creative Living Beyond Fear by Laszlo Block, which I rated 5/5 and marked as my favorite on my Shelfari account.

Only when companies took steps to give employees more freedom did performance improved.

By offering more wages just means you get more applicants, not that you get better applicants.

Most assessment happens in the first three or four minutes of an interview, with the remaining time spent confirming that bias.

I’m in great shape, I spent $500 on my gym membership this month.

The presence of a huge training budget is not evidence that you’re investing in your people, it’s evidence you failed to hire deride people to begin with.

To Jeff Dean NP means No Problemo.

Academic performance didn’t predict job performance.

Don’t debate what’s the best background color for the ad – just run the experiment.

If you’re achieving all your goals, you’re not setting them aggressively enough.

Use meetings to ask questions, rather than dictate answers.

Deliberate practice – intentionally repetitions of similar small desks with immediate feedback, correction and experimentation. Break things down into small digestible pieces with a clear feedback and do them again and again.

It’s hard work to have be ranges were someone can make 10 times more then the other person, but it’s much harder to see your highest potential walk out of the door.

I have discovered men will risk their lives or even die for ribbons. – Napoleon

The bigger the dish, the more we eat, and the less satisfied we feel.

https://twitter.com/HitmanHR/status/686167992330268672

Ionic, Stack Overflow

Connect to MongoDB remote server with Ionic

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

As you may know, I’m really into Ionic framework lately and am helping out on StackOverflow with the knowledge I gained so far with the framework. I’m currently #1 in the top All time answerers list.

I answered this question by user Antifa:

I’m trying to develop an application in phonegap/ionic and I want to use a remote database to store my data. I want to use MongoDB. I already tried lots of ways such as this quick start guide.

By using this I can connect to DB but this is pure node.js and the require() function cannot be recognized when I try to add this code to an ionic starter app. Maybe require is not supported in ionic

Is there a way that can achieve it in Ionic?

Please let me know if you want some more information.

My answer was:

The thing is; you can’t connect Ionic to MongoDB directly. No, there’s not workaround, no magic involved, it’s just not the way this is supposed to work. Ionic works on top of Angular and Angular is a frontend framework.

However, the way you should do it is that you basically create a (RESTful) API on your server side.

Most likely this will be made with Node.js which will talk directly to MongoDB and query it. A framework very well suited for this (you actually may be using it already) is Express.

After you write your (RESTful) API then you can consume it through your services in Angular by using Angular’s $resource object.

Sure, this is not a step by step answer, and it seems you’re just starting in this area, so you have some learning do to on your part (REST, RESTful, $resource, services…), but I wish you good luck and if you’ll have any more specific questions, don’t hesitate to ask them.

https://twitter.com/HitmanHR/status/684267579976904704

Miscellaneou$

Friend on a hand

Below is my submission for the Bug writing competition in original Croatian, and in my best attempt to translate to English (fixes are welcome). However, they must have thought I was joking or something, and they didn’t even take a look at it. Anyways, here’s a story with my 1+ year experience with my Fitbit:

English version:

We formed our friendship just before you wrote the article “Me in numbers” in your Bug magazine. That made me happy because you assured me that I’m a successful trend followed, like any real gadget enthusiast.

I wear it on my wrist, and it doesn’t bother me any second of my 8-hour work on my other Friend – Computer, but we won’t talk about him now because after all this isn’t his 5 minutes of fame.

First of all, I wouldn’t want to label him as a mere piece of hardware, because, in a very short period that I own him, he became my Friend Hardware.

Not only does he count the number of steps I make in a day, but he also counts my total sleeping time. His friend Application (which, btw, works great on any worthwhile mobile phone or browser) shows me which period of time I was restless during the sleep, and with this, I can see the quality of my sleep and the time it took me to fall to sleep.

It also allows me to enter the data about the food that I eat, the amount of water that I drink, and my current desired weight. Based on my activity, it calculates how many calories I spend, and how much more would I have to burn to stay in the fitness beast mode – bye bye personal trainers.

Hardware vibration mode wakes me up in the morning at the time allocated in the Application, so that I don’t wake up my child and wife early in the morning at 5 AM when I go for a run before work. Hardware sends me weekly accomplishments via the Application and it shows me how I stack up against my other “living” friends.

My FitBit Flex <3

Original Croatian version:

Mi smo oformili naše prijateljstvo taman prije nego što ste Vi u Bugu imali temu “Ja u brojkama”. To me razveselilo jer ste mi time potvrdili da uspješno pratim trendove kao svaki pravi gadget entuzijast.

Nosim ga oko svog zapešća i ne smeta mi ni trenutka u mojih 8 sati rada za mojim drugim prijateljem Računalom, ali sada nećemo o njemu jer je to ipak njegovih 5 minuta.

Prije svega, ne bih htio da se njega oslovljava samo kao neki obični hardware, jer je on u kratkom roku što ga imam postao moj prijatelj Hardver.

Ne samo što mi mjeri broj koraka koje napravim u danu, već mi mjeri i ukupno vrijeme spavanja. Njegova prijateljica Applikacija (koja, usput budi rečeno, radi na svakom iole spomena vrijednom mobitelu ili browseru) mi omogućuje uvid u period kad sam bio nemiran tokom sna, te time mogu vidjeti kvalitetu sna i vrijeme koje mi je bilo potrebno da zaspim.

Također mi omogućuje da unesem podatke o hrani koju jedem, količini vode koju popijem, te svojoj trenutnoj i željenoj težini. Ovisno o mojoj aktivnosti računa koliko kalorija potrošim, te koliko bi još morao da ostanem u fitness beast modu – bye bye osobni treneri.

Hardver me ujutro budi laganim vibriranjem u vrijeme zadano u Aplikaciji, tako da ne probudim svoje dijete i ženu ujutro u 5 sati kad idem trčati prije posla. Hardver mi preko Aplikacije tjedno šalje email sa pregledom postignuća za prošli tjedan a i prikazuje mi koliko sam dobar u odnosu na druge “žive” prijatelje.

Moj FitBit Flex <3

Oh, btw, the strap broke after more than a year of non-stop usage (showers included), but I bought a cheap replacement on eBay and it’s holding up just fine…

#Friend on a #hand #fitbit https://t.co/QiGaU2I4q3

— Nikola Brežnjak (@HitmanHR) January 4, 2016

NodeJS

How to check for outdated packages via npm

In this post I’ll show you the modules which help in finding the outdated packages via npm. This is an excerpt from the book Deploying Node.js by Sandro Pasquali. I was a technical reviewer for this book and you can read my review here.

This command will list globally installed packages:

npm root -g

 

This following command will give a full list of other dependencies in a tree list:

npm list --global

There are also some aliases to this command like ls, la. You can learn more about it from the official documentation.

 

This command will list outdated packages:

npm outdated

 

A very useful global tool for performing these sorts of checks is npm-check, which delivers more detailed information.  You can install it with npm install npm-check  and run it simply by running npm-check. It tells you what modules are out of date and provides a link to the package’s documentation so you can decide if you want the update.

 

To remove packages that are installed but no longer listed in package.json file you can use the command npm prune. Note that this is simply a technique for cleaning up the node_modules folder within an individual package’s folder; it is not a smart, global tool for removing unused packages across the entire tree.

 

The dependency-check module is a great tool for finding unnecessary packages. Once you install it you run it like this:

dependency-check package.json --unused

and, if some modules aren’t used you’ll get a message like:

Fail! Modules in package.json not used in code: express

The entry point to your application has to be listed in package.json, as dependency-check needs to know the root of your application.

 

The npm dedupe module attempts to reduce the number of redundant package installs, “flattening” the tree, and therefore reducing install time.

How to check for #outdated #packages via #npm #nodejs #node.js https://t.co/bNJ8aiGBmm

— Nikola Brežnjak (@HitmanHR) December 30, 2015

Ionic, Stack Overflow

How to run Ionic serve permanently?

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

As you may know, I’m really into Ionic framework lately and am helping out on StackOverflow with the knowledge I gained so far with the framework. I’m in the top All time answerers list.

I answered this question by user Santhosh Aineri:

I am using Ionic framework for one application. The code is on a linux server. I am running the application using ionic serve command through putty.

But, the problem is if I close the putty the application is stopped. Is there any way to run the ionic serve permanently as a daemon process?

My answer was:

I’m suspecting you’re trying to do this because you want to serve your Ionic app as a web app, correct?

In that case – you don’t have to run ionic serve permanently. All you have to do is take all the code from the www folder and place it in the http folder (or any other which is valid for your system) of your web server.

So, basically, spin up apache (or nginx) and serve the code from the Ionic’s www folder. Basically, ionic serve command does the same thing – it spins up a local web server and serves the content from the www folder. It does that for faster local testing.

You can take a look at this SO question for more info on how to deploy Ionic as a website.

How to run #Ionic #serve #permanently? https://t.co/7mbxGdSHFi

— Nikola Brežnjak (@HitmanHR) December 29, 2015

Page 25 of 51« First...1020«24252627»304050...Last »

Recent posts

  • Discipline is also a talent
  • Play for the fun of it
  • The importance of failing
  • A fresh start
  • Perseverance

Categories

  • Android (3)
  • Books (114)
    • Programming (22)
  • CodeProject (35)
  • Daily Thoughts (77)
  • Go (3)
  • iOS (5)
  • JavaScript (127)
    • Angular (4)
    • Angular 2 (3)
    • Ionic (61)
    • Ionic2 (2)
    • Ionic3 (8)
    • MEAN (3)
    • NodeJS (27)
    • Phaser (1)
    • React (1)
    • Three.js (1)
    • Vue.js (2)
  • Leadership (1)
  • Meetups (8)
  • Miscellaneou$ (77)
    • Breaking News (8)
    • CodeSchool (2)
    • Hacker Games (3)
    • Pluralsight (7)
    • Projects (2)
    • Sublime Text (2)
  • PHP (6)
  • Quick tips (40)
  • 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