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

REWORK – Jason Fried and David Hansson

My notes from the great book REWORK by Jason Fried and David Hansson which I rated 5/5 on my Goodreads account. Yes, they merged Shelfari (which I loved) with Goodreads (which I don’t like too much) and I guess I need some adjustment period.

If you build software, every error message is marketing.

Workaholics aren’t heroes. They don’t save the day, they just use it up. The real hero is home because she figured out a faster way.

What you do is what matters, not what you think or say or plan.

Plus, if you’re a copycat, you can never keep up. You’re always in a passive position. You never lead; you always follow. You give birth to something that’s already behind the times—just a knockoff, an inferior version of the original. That’s no way to live.

What you do is what matters, not what you think or say or plan.

Working without a plan may seem scary. But blindly following a plan that has no relationship with reality is even scarier.

Unless you are a fortune-teller, long-term business planning is a fantasy.

There are four-letter words you should never use in business. They’re not fuck or shit. They’re need, must, can’t, easy, just, only and fast. These words gets in the way of healthy communication.

Until you actually start making something, your brilliant idea is just that, an idea.

Press Releases are spam.

Think about it this way: If you had to launch your business in two weeks, what would you cut out?

My notes from the awesome #book #Rework by Fried and Hansson https://t.co/H5eTr7CjeF pic.twitter.com/cSne01TMpI

— Nikola Brežnjak (@HitmanHR) February 2, 2016

Ionic

How to test Cordova plugins without device

In this StackOverflow question I answered which Cordova plugins you can test without the actual device.

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 Chris Lawrence:

I think I know the answer to this question already but thought I would throw it out there incase there was a workaround….

Just built a ionic app with ngcordova, which works fine and I have tested on my android device and deployed to playstore.

Just in the process of deploying to the apple app store. I currently don’t have an apple ios physical device to test the cordova plugins.

I am using sms, camera and local notification. These as far as am aware cannot be tested in the ios simulator in xcode.

Don’t really want to spend £400 on a tablet to test one app.. any one had the same problem and found a means of testing?

My answer was:

You can test plugins in iOS simulator.

edit: I just stumbled upon the official documentation where it states that even with Ionic View you can test these plugins:

  • com.brodysoft.sqlitePlugin 1.0.3 “Brodysoft SQLitePlugin”
  • com.ionic.keyboard 1.0.3 “Keyboard”
  • com.phonegap.plugins.barcodescanner 1.1.0 “BarcodeScanner”
  • org.apache.cordova.battery-status 0.2.12 “Battery”
  • org.apache.cordova.camera 0.3.4 “Camera”
  • org.apache.cordova.console 0.2.12 “Console”
  • org.apache.cordova.device 0.2.13 “Device”
  • org.apache.cordova.device-motion 0.2.11 “Device Motion”
  • org.apache.cordova.device-orientation 0.3.10 “Device Orientation”
  • org.apache.cordova.dialogs 0.2.11 “Notification”
  • org.apache.cordova.geolocation 0.3.11 “Geolocation”
  • org.apache.cordova.globalization 0.3.3 “Globalization”
  • org.apache.cordova.network-information 0.2.14 “Network Information”
  • org.apache.cordova.vibration 0.3.12 “Vibration”
  • org.chromium.zip 1.0.0 “Zip”

How to #test #Cordova plugins without device https://t.co/iKTKzYyTfI

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

Books

The Way of Kings – Brandon Sanderson

My notes from the truly awesome book The Way of Kings by Brandon Sanderson. This is a huge book, but nevertheless packed with action. As a matter of a fact, Brandon Sanderson along with Patrick Rothfuss is now my favorite fantasy author.

The purpose of a storyteller is not to tell you how to think, but to give you questions to think upon.

Life before Death. Strength before Weakness. Journey before Destination.

Sometimes the prize is not worth the costs. The means by which we achieve victory are as important as the victory itself.

Expectations were like fine pottery. The harder you held them, the more likely they were to crack.

To lack feeling is to be dead, but to act on every feeling is to be a child.

In the end, all men die. How you lived will be far more important to the Almighty than what you accomplished.

Somebody has to start. Somebody has to step forward and do what is right, because it is right.

Too many of us take great pains with what we ingest through our mouths, and far less with what we partake of through our ears and eyes.

Authority doesn’t come from a rank. Where does it come from? From the men who give it to you. That’s the only way to get it.

There are two kinds of people in this world, son. Those who save lives, and those who take lives. And what of those who protect and defend? Those who save lives by taking lives? That’s like trying to stop a storm by blowing harder. Ridiculous. You can’t protect by killing.

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

Miscellaneou$

5 Great Places to Find Top Freelancer Software Engineers

TL;DR: This post is leaned toward how and where someone would find freelancer software engineers. Nevertheless, you can also check these sites out in order to find a great place to work at.

Finding the right freelancer developer for your project can be a daunting task, especially for those without much development experience. There are always a couple of considerations to keep in mind:

  • What particular skills are you looking for?
  • What’s the length of the job you have in mind?
  • What sort of personality and habits mesh best with your work environment?
  • How soon do you need a developer?

Once you’ve sorted out these questions, rather than walk down the street and hope that you bump into a solid software engineer, it’s generally best to use a hiring website. Though the list below is by no means extensive, these sites are great places to find developers for whatever sort of project you’re working on. Check them out, and see what works best for you!

Toptal

Unlike other freelance marketplaces, Toptal focuses on working only with elite software engineers and only with clients who have the budget and need for top talent. Toptal screens both clients and developers, and only accepts those that they feel will thrive within its community.

Besides English and personality tests, Toptal puts prospective developers through a battery of timed tests, live interviews, and sample projects to make sure they’re the best of the best. Clients will work very closely with Toptal’s team to make sure their needs are fully understood and met. Clients also can enjoy a no-risk trial period of up to 2 weeks, and if they’re not fully satisfied that the engagement will proceed according to plan, they won’t pay, and Toptal will cover costs out of their pocket.

 

Rent a Coder

Rent a Coder allows you to post a project for free, and then wait until you receive bids to decide whom to employ. By using a reverse-auction method, through which developers compete to offer the lowest price for the job, you’re guaranteed to get a competitive price.

Though the initial post is free, you can’t share contact details unless you pay for membership. One downside of Rent a Coder, aside from its somewhat unprofessional website, is that there’s no verification process: Rent a Coder doesn’t have a screening system for determining good developers, so you run the risk of getting someone who’s not up to the task. You also can’t make payment over the website, which is a bit inconvenient.

 

Hirable

What immediately stands out about Hirable’s website is its sleekness; unlike many hiring websites, Hirable’s is professional, user-friendly, and clean. Once you sign up, you can see profiles of different developers with their skills, location, contact information, website, and workplace preferences.

Though there’s no independent verification, you can definitely get a feel for different sorts of developers by sorting through some profiles and picking out the skills you need. What’s unique about Hirable is their “availability” feature: you can see whether developers are currently hirable, will be hirable soon, or are busy, so you get your project done as quickly as possible. Ultimately, while Hirable might not get you the best developer in the world, it’ll definitely get you a solid one within a convenient time frame.

 

Workmarket

Workmarket makes it incredibly easy to hire developers from all over the United States. Their website and process is fairly easy to use, and helps you organize all your tools into a single dashboard.

They also offer several screening tools, including their Learning Management System, and give you access to background checks. One advantage of Workmarket is that it automatically adds freelancer engineers to your queue who match your needs. You can pay employees however you want, and even see other customers’ ratings to determine which freelancers have the best record.

Workmarket’s website also has some useful information about how to hire freelancers, along with some interesting webinars. While Workmarket certainly offers better support than Rent a Coder, it doesn’t appear to offer access to developers from outside of the U.S., unlike Toptal, which probably reduces its talent pool. Still, it’s definitely a great option for those looking to hire local developers who come well-recommended.

 

10x Management

10x Management, which you may have seen on Ted Talks, helps connect you with some of the best tech talent from around the globe. Like Toptal, they have their own verification process, and they choose from 1,000’s of applicants to determine the best developers.

After matching you with a developer, they’ll offer support for the entirety of the job. For anyone not convinced, you can read their “Case Studies” section to see how successful businesses have used their services. Also, they have a phenomenal blog with some tips on tech, hiring, and software engineering. Ultinately, 10x Management is a great option for those looking to get the best tech talent available.

5 Great Places to Find #Top #Freelancer #Software #Engineers @toptalllc https://t.co/IolMNr8XPY pic.twitter.com/o2eLK1ZmDi

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

Ionic2

Posting data from Ionic 2 app to a PHP server

TL;DR

This is the simplest example which shows how to POST data from an Ionic 2 app to a PHP server.

The tutorial covering the Ionic version 2 can be found here. The tutorial covering the Ionic version 3 can be found here.

Quickstart

To see it in action:

    1. Clone the finished project from Github
    2. Make sure you’ve got the newest Ionic beta CLI (see below for instructions)
    3. Run ionic serve
    4. You should see something like this:
      ionic2ServerPost

If you want to make it work from your server:

  1. Make sure you’ve got the newest Ionic beta CLI (see below for instructions)
  2. Clone the finished project from Github
  3. Upload the PHP/api.php file to your server
  4. In the app/pages/home/home.js file adjust the link variable (line #18) to point to your server
  5. Run ionic serve

Getting started with Ionic 2

By now you probably have heard that Ionic is in beta for its version 2, which closely follows Angular 2.

You can find a lot more Ionic 2 related tutorials on my friend Gajotres site.

To install the Ionic SDK and create Ionic 2 projects, you need to install the latest beta release:

npm install -g ionic@beta

You don’t need to worry about this messing up your current ionic CLI since the beta release has all the functionality to work with both V1 and V2 projects.

Step by step on how to create this yourself from scratch

  1. Create a new blank Ionic project with:
    ionic start Ionic2ServerSendTest blank --v2
  2. Copy the following code in app/pages/home/home.html file:
    <ion-navbar *navbar>
        <ion-title>
            Home
        </ion-title>
    </ion-navbar>
    
    <ion-content padding>
        <ion-list>
            <ion-input floating-label>
                <ion-label>Username</ion-label>
                <input type="text" name="username" [(ngModel)]="data.username">
            </ion-input>
    
            <button round block (click)="submit()">Submit to server</button>
        </ion-list>
    
        <ion-card>
            <ion-card-header>
                Response
            </ion-card-header>
            
            <ion-card-content>
                <b>{{data.response}}</b>
            </ion-card-content>
        </ion-card>
    </ion-content>
    

    Here you basically created a form with an username input field and with a button which acts as a submit button.

    As you can see, the syntax is a bit different since Ionic2 uses Angular2. Once the button is clicked AngularJS should handle it within the submit() function which we will define in our app/pages/home/home.js file (shown below).

    Input username uses  the new syntax for ng-model as well, and it binds to the variable data.username, so that you can then use it in your submit() function (shown below).

    Also, components are a bit different in Ionic now, and I encourage you can take a look at the official documentation.

  3. On your server, create an api.php file with the following content:
    <?php
        //http://stackoverflow.com/questions/18382740/cors-not-working-php
        if (isset($_SERVER['HTTP_ORIGIN'])) {
            header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
            header('Access-Control-Allow-Credentials: true');
            header('Access-Control-Max-Age: 86400');    // cache for 1 day
        }
    
        // Access-Control headers are received during OPTIONS requests
        if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
    
            if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
                header("Access-Control-Allow-Methods: GET, POST, OPTIONS");         
    
            if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
                header("Access-Control-Allow-Headers:        {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
    
            exit(0);
        }
    
    
        //http://stackoverflow.com/questions/15485354/angular-http-post-to-php-and-undefined
        $postdata = file_get_contents("php://input");
        if (isset($postdata)) {
            $request = json_decode($postdata);
            $username = $request->username;
    
            if ($username != "") {
                echo "Server returns: " . $username;
            }
            else {
                echo "Empty username parameter!";
            }
        }
        else {
            echo "Not called properly with username parameter!";
        }
    ?>

    As you can see from the code, the first part is explained in detail in this StackOverflow question, and it basically solves the CORS issue that you would otherwise run into.

    The second part, explained in detail in this StackOverflow question,  deals with the way you POST data from Ionic to your PHP server. The gist is that since we POSTed in a JSON format, we have to json_decode  the data that comes to your PHP server.

  4. In app/pages/home/home.js file adjust the link variable to point to the file on your server
  5. In app/pages/home/home.js file copy the following content:
    import {Page} from 'ionic/ionic';
    import {Http} from 'angular2/http';
    
    @Page({
        templateUrl: 'build/pages/home/home.html',
    })
    
    export class HomePage {
        constructor(http: Http) {
            this.data = {};
            this.data.username = '';
            this.data.response = '';
    
            this.http = http;
        }
    
        submit() {
            var link = 'http://nikola-breznjak.com/_testings/ionicPHP/api.php';
            var data = JSON.stringify({username: this.data.username});
            
            this.http.post(link, data)
            .subscribe(data => {
                this.data.response = data._body;
            }, error => {
                console.log("Oooops!");
            });
      }
    }

    Again, as I said, some (a lot) of things have changed in Angular 2, and at first glance you really may not like it (tbh, I know I didn’t). But, that will change with usage, so no worries.

    First thing that we do here is we import Page and Http components from Ionic and Angular, respectively. Then we’re setting the Page templateUrl to our home.html file.

    Inside the HomePage class we now have a constructor where we’re setting some default values. Important to note, see how we’re passing in Http via the constructor parameter. Again, I won’t go into details of using this, as I mentioned you can take a look at a lot more in depth tutorials on Gajotres.

    Inside the submit function we use the http service to post to our API endpoint with some data. Make note of how we use subscribe to handle data once it  arrives.

  6. Run ionic serve  from the root directory of your Ionic app
  7. Hope this tutorial helps you in starting your journey towards (Ionic + Angular)_2
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

Page 25 of 51« First...1020«24252627»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