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

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

Miscellaneou$

hack.summit() 2016 virtual conference and hackathon

hack.summit() is a virtual event for developers presented by Pluralsight which will take place “on the wire” on February 22nd-25th, 2016.

This years’ hack.summit() holds three titles:

  • The largest virtual conference in history
  • The largest programming conference in history
  • The largest hackathon in history

and it has some really interesting speakers like programming language creators, open-source contributors, and thought leaders like:

  • JON SKEET – #1 answerer on StackOverflow
  • KENT BECK – Creator of Extreme Programming, creator of TDD
  • DAVID HEINEMEIER HANSSON – Creator of Ruby on Rails
  • JOEL SPOLSKY – Co-founder and CEO of StackOverflow, founder of Trello
  • YEHUDA KATZ – Ember.js author, Rails Core contributor
  • TOM CHI – Creator  of Google Glass
  • BRIAN FOX – Inventor of GNU Bash Shell
  • ORION HENRY – Founder of Heroku
  • ROD VAGG – Node.js Technical Chair and Core Committer
  • and many others…

On top of that, there will be a virtual hackathon on February 20th-21st. One can compete alone or in a team. The prize pool is also worth mentioning 150k$ times :).

This should definitely be interesting so make sure you check it out if you’re into these kind of things…

#hacksummit 2016 #virtual #conference and #hackathon https://t.co/YvMSZ621yh

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

Programming

Technical review of the book Deploying Node.js by Sandro Pasquali

I was a technical reviewer for the book Deploying Node.js:

nodejsCover

This was done via PacktPub, and I must say that this was a great learning experience and I’m glad that I was able to help make this book better. From my experience with the project coordinator Mary Alex I have nothing but good words for them.

Finally, my name in a print book 🙂

nodejsRevieweres

This book covers a lot of ground like how to

  • optimize your code for production
  • use Docker and Vagrant
  • deploy to Heroku, OpenShift and DigitalOcean
  • use Nginx for load balancing
  • use Redis
  • use Gulp, Browserify, npm, Mocha, Chai and Sinon
  • manage deployments with Git, Jenkins and Ansible

Here is the short summary of each chapter:

  • Chapter 1, Appreciating Node
    • what is Node.js and where it excels
  • Chapter 2, Installing and Virtualizing Node Servers
    • teaches you how to create a basic Node.js application and deploy it to Heroku, OpenShift and DigitalOcean
  • Chapter 3, Scaling Node
    • shows vertical and horizontal scaling techniques among which how to use Nginx for load balancing
  • Chapter 4, Managing Memory and Space
    • shows the advantages of microservices
    • shows how to use Redis
  • Chapter 5, Monitoring Applications
    • shows how to effectively monitor your application once it has been deployed
  • Chapter 6, Building and Testing
    • explains how to create a build workflow for your application with full examples of using Gulp, Browserify, and npm
    • shows how to do testing with Mocha, mocking with Sinon, and using PhantomJS for headless browser testing
  • Chapter 7, Deploying and Maintaining
    • shows how to set up a virtualized development environment and manage deployments with Git, Jenkins and Ansible

As said, this book covers a lot of topics and, in my opinion, it is not suited for beginners in the field, but for those who have some experience with Node.js and other tools. However, it’s great that a simple introduction is given to all these topics so that one who is interested more in some particular section, can easily build upon the knowledge gained from the book. The author clearly shows how a Node.js app should be built, tested, monitored, deployed, scaled and maintained.

This book was published in May this year, but I didn’t want to write the review before, so that it wouldn’t seem to be a biased one. Since then I worked as a technical reviewer on two of their Ionic products (one book and one short video), about which I’ll post when they’ll be officially published.

Anyways, I hope this review will help nudge you in taking this book into consideration if you’re looking for how to deploy your Node.js applications.

#Technical #review of the #book #Deploying #Node.js by Sandro Pasquali https://t.co/EUi0shYmn6

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

Books

Man’s search for meaning – Viktor E. Frankl

My notes from the bestseller book Man’s search for meaning by the nazi camp survivor Viktor Frankl, which I marked as favorite and rated  5/5 on my Shelfari account.

He who has the WHY to live can bear with almost any HOW.

Success will follow you precisely because you forgot to think of it.

There are things which must cause you to lose your reason, or you have none to lose.

No man should judge, unless he asks himself in absolute honesty weather in the similar situation he might not have done the same.

The sort of person the prisoner became was the result of inner decision and not the result of camp influences alone. Fundamentally, any man can decide what shall become of him.

Life is like being at the dentist. You always think that the worst is still to come, yet it is over already.

Striving  to find meaning in one’s life is the primary motivational force.

Pleasure is, and must remain, a side effect or byproduct and is destroyed and spoiled to the degree to which it is made a goal in itself.

Live as if you were living for a second time and had acted wrongly the first time as you’re about to act now.

But everything great is just as difficult to realize as it is rare to find.

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

Ionic

How to send an email in Ionic framework application?

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 varun:

I have a simple page with 3 textbox and a button like this.

<input type="text" ng-model="name" required >
<input type="text" ng-model="city" required >
<input type="text" ng-model="country" required >

<button class="button button-block button-royal ExploreBtn" ng-click="sendMail();">
Send mail               
</button>

Help me , How to send mail with value in first text-field as subject and other two as body in angular js/ionic.

My answer was rather elaborate:

So, basically the comments to your question are correct – you can’t do this purely in JavaScript, you need to use a backend service for it.

Now, what you would do in your sendMail function is call the service by using Angulars’ $httpservice. You can learn more about $http service from the official documentation.

The call would, for example look like this:

$http({
    method: 'POST',
    url: 'http://your.server.com/sendmail.php',
    data: { mailTo: '[email protected]', msg: 'hello!' }
}).then(function successCallback(response) {
    alert("msg sent!");
}, function errorCallback(response) {
    alert("error with sending a msg");
});

Here you have two important parts:

  • url – where is your service (which will finally send the email) located
  • data – what are you sending to this service endpoint

In my example I’ve put the service url to be sendmail.php which, in end, would be written in PHP. I have to stress out that your backend service can be written in any server-side language you’re familiar with (if you’ll research this topic further make sure you read about the RESTful services).

For the sake of this example, the PHP script (unsecured and just for reference) which uses the mail function to send an email would look something like this:

<?php

$to = $_POST["emailTo"];
$msg = $_POST["msg"];

mail($to, "Some test subject", $msg);

?>

Hope this helps clear the confusion.

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

Miscellaneou$

57th SQL/DEV user group meeting about refactoring and transpilers

I attended our local Microsoft community user group meeting which was about refactoring and transpilers. It’s full proper title (on Croatian) was 57. sastanak SQL/DEV UG Čakovec-Varaždin.

This was 57th meeting in a row, and the presenter Nikola Begedin had two awesome topics (with few notes I took):

Principi i konvencije u refaktoriranju koda (Principles and conventions in code refactoring)

57devug_1

There are typical problems in every code with typical fixes for each of these problems. So, it’s useful to know them in order to be able to detect them early in the code and fix them before they introduce technical debt.

Few of the principles:

  • extract temp to query
  • tell, don’t ask
  • data clump
  • decoupling

You should look to refactor

  • God objects
  • high churn code
  • bugs – “bugs like company”. If a bug appeared at the same function, then refactor it because it’s obviously too cumbersome and the bug will inevitably manifest itself again

Few of the recommended books:

  • Clean Code: A Handbook of Agile Software Craftsmanship
  • Refactoring: Improving the Design of Existing Code
  • Growing Object-Oriented Software, Guided by Tests

Korištenje transpilera (using transpilers)

57devug_2

Transpiler is a source to source compiler. What that means is that it’s basically a tool which translates from one language to another.

Transpilers allow us to write modern JavaScript code, to work with modules, use advanced language features (await, async, arrow functions, …), etc.

Some options that we have today are:

  • Babel
  • Google Traceur
  • Browserify
  • RequireJS

Visual studio 2015 supports Gulp task running via Task Runner Explorer.

The point is that we don’t need these but since sooner or later more and more browsers will support these functions and you can use them already today, I don’t see any reason why not to use all the benefits that they offer.

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

Page 26 of 51« First...1020«25262728»304050...Last »

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