Przejdź do głównej zawartości

Posty

Wyświetlanie postów z 2017

Running Microsoft SQL Server on Linux with Docker

Probably you heard that Microsoft Sql Server can only run on Windows machines. Good news - This is not true anymore. You can easily install it on Linux machine too. In this article I show you 2 ways of installing Sql Server on Ubuntu 16 and demonstrate how to connect to the database from remote machine. OPTION 1: Slow way - Manual installation This is the most straightforward way of installing. You download packages and configure Sql Server interactively(you set password, port and choosing installation option - free or paid). This is the step by step instruction from microsoft https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu OPTION 2: Fast way - Running on docker with just 2 pure-command-line commands. My assumption is that your Ubuntu machine has already docker installed. You can check if Docker is already installed by tunning the command: docker. If you don't have docker installed, no problem: before continuing below instruction just install

MongoDB for C# developers - Lesson 1

Today I'll show you what I lerned at Mongo University online course for C# developers after first lesson and passing all homework. I'll show you how you can: - install MongoDB on Windows workstation - switch between databases - display all elements from a collection - add new document to a collection - restore Mongo database from a dump folder. Get MongoDB installer from MongoDB download center: https://www.mongodb.com/download-center After installation of 64 bit version go to C:\Program Files\MongoDB\Server\3.4\bin. You should see there 2 files: -mongo - this is a console application, you can think of it as a client application -mongod - this is a server of database At this point it's useful to add 'C:\Program Files\MongoDB\Server\3.4\bin' to PATH environment variable. Now open the command line and go to C drive. Create the folder by using command: mkdir data\db And now run the server: mondog Important: If you forget adding the data\db fold

Up and running with Laravel

Today I'll show you how to start working with Laravel - a modern PHP framework. After reading this article you'll be able to: - Install XAMPP - Configure Virtual Hosts on Apache - Create your first application in Laravel - Run the application - Start coding As a first step I encourage you to visit Laravel.com to get some background knowledge about Laravel. Laravel is a PHP framework which is build on top of the MVC pattern (MVC stands for Model View Controller). You can find general explanation of MVC design pattern with some code examples written in Java here . I assume that you've already installed XAMPP which has version for Linux, Windows and OS X. Personally I'm using Windows in this tutorial but on each operating system it should work similarly. You can get the installer of XAMPP from this page: https://www.apachefriends.org/pl/index.html. When installer prompts you which options you want to install, you need to select Apache and you are free to

Learning e24cloud.com API

Today I'll show you how to use API in order to create virtual server in the cloud directly from your code. We're going write a script in PHP language and use Amazon SDK API to connect with e24cloud.com, which is the biggest and most modern hosting provider in Poland. First we need to install Amazon SDK http://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/installation.html One important note: We can use the latest version of amazon SDK but we also need to do one trick. We'll use signatureV2 instead ov Signaturev4 as e24cloud doesn't support SitnatureV4 yet. You can download it here: https://github.com/aws/aws-sdk-php-v3-bridge We need to download SDK and the bridge which allows us to use Signaturev2 to the same folder, so that require instruction work seamlessly in the form that I provided in the example below. Then go to your admin panel in e24cloud.com to find two values: a key and a secret. In the following code you need to paste those 2 values.

Xamarin.Forms Previewer

Today I'll show you a tool for every Xamarin developer - Xamarin.Forms Previewer - a tool which will help you to design Xamarin.Forms views faster. First we need a xaml view: The view can't be easier. It contains only one label. Now let's build the project and open Previewer from the View Menu: It should results in displaying the new window which renders your xaml view: Now the most interesting part. Let's add a few labels and change the screen background color. There is no need to save, the design will be changed on the previewer instantly. This is a Xamarin.Forms previewer. I'm using it because it speeds up my view desting loop. I don't need to run the app on emulator or a device to see effects of my changes.

Dependency Injection in .NET Core

Today I explain how Dependency Injection works in .NET Core and I describe 3 methods available in service provider. Up to now if ASP.NET developers wanted to use dependency injection container they had to use Ninject , Autofac or another one. To set these up we had to get NuGet package, install it and configure it in our config filels. Good news - with ASP.NET Core new alternative comes. We don't need Ninject or Autofac anymore, because ASP.NET Core MVC has its own built-in dependency injection container . All set up when new project is created. There is no need to install packages and modifying configuration files. There are 3 methots that we can use to define dependencies in ASP.NET MVC: transient, singleton, scoper Let's open Visual Studio and create new ASP.NET Core MVC application. We'l focus on Startup.cs class where you can see ConfigureServices method. If you want to instruct MVC to use specific class when controller asks for IEventRepository interfa

Xamarin Live Player

In this article I'll show how to install and use Xamarin Live Player. The tool called Xamarin Live Player is a new mobile application and let's you show and modify your Xamarin application on the fly and see effects in your phone or tablet immediately. First you have to install the newest Visual Studio 2017 preview 15.3. Next we need to download Xamarin Updater: https://marketplace.visualstudio.com/items?itemName=Xamarin.XamarinUpdater Then follow the instruction: here . When Visual studio is set up we need to install new software on our mobile device. You can find Xamarin Live Player in Google Play store: Next let's go to the Visual Studio 2017 and create a new Xamarin.Forms project: Now we should see a new device called "Life Player" in our list. Let's click the green arrow button: You'll be presented with pop-up windows with QR Code. Now take your mobile phone where you've installed Xamarin Live Player and scan the code that Visu

How MongoDB + good programming practices saved my time

Today I'll show you how in I'm using MongoBD in web service part of Perfect Life application. I'll show how using good programming practices saves time. I switch database to brand new instance of mongoDB . And I did it. And all that you'll see today was made within one hour. Interested? Keep reading... As you know I tend to use interface to connect components in my application. It helps me to keep components loosely coupled. For example I use dependency injection where controller uses IWeightRecord Repository. Using interfaces this way makes it easy to switch my repository to something else. In my case I'd like to create a new repository that depends on Mongo database instead of in-memory repository that uses Dictionary. As the reault my data won't be deleted in case of web application restart. This is my target. So first I'm adding a new Nuget package to my WebAPI application. The package is called MongoDB.Driver . Next step is to create a new

Create your own server in the cloud in 30 seconds!

Hello every one! Today I'll show you how e24cloud.com cana help you to get your own virtual machine running in less that 30 seconds . I guess your concern can be if it's possible at all. Well, a few years ago it was possible to get a virtual machine with fixed size of disk, fixed size of RAM memory and fixed processor performance. So configuration of your machine was static from the moment you purchased the server. You wasn't allowed to do any change in size of disk for example. Of course you could upgrade your server but if was often one way action cause you couldn't downgrade. Today it's much different. You can host your machines, storage, databases in the cloud based hosting provider and you can change anything in the time. This is so flexible. Let's say you are the owner of online shop. You know that each year in the period preceding Christmas sales grow up by 500% and your virtual machine which hosts your store is not sifficient and will be overlo

Learning MongoDB

NoSQL databases are getting really popular lately. I decided to learn it and build solid skills that will let me using noSql databases in commercial projects. The choice that I made is MongoDB. I have a friend who knows the topic very well and I'm of the opinion that it's easier to learn a new technology of your choice when you can look to help from someone trusted, at least on the beginning. So I've just started and in this article I describe the installation process on Ubuntu Linux. I use Ubuntu 14. If you have a chance to worh with the same operating system and want to install Mongo, you can follow the instruction: 1. Import public key for apt package manager: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 2. Create a file: echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list 3. Reload package data

How to call webAPI service in Xamarin?

In the last few weeks I worked on the web service written in ASP.NET Core. I had a plan to connect the Xamarin application to this web service. Today I'll show you how you can connect your Xamarin app to web service located anywhere in the cloud. First we need to have a web service deployed, which is our server-side part of the system. I describe how to create a web service in ASP.NET COre in my previous post: . Today I'll demonstrate how it works from client perspective, in our case it's Xamarin.Forms application but web application or desktop application can use exactly the same code. This is the great benefit of using C# language - we can use the same code on multiple platforms. OK, I bet you're interested in the code. Let's jump to the code. This is the final version of the client class that I can use to save and retrieve data from web service: The class design is straightforward. It has 2 public methods which encapsulate 2 functionalities: adding s

Perfect Life app - test your software like google

As far as we talk about automated tests there are 3 levels of testing: 1. Unit tests 2. Integration tests 3. System tests Google propose another test classification, but it can be mapped directly to the above 3 points. So google uses 3 following test levels: 1. Small test 2. Medium tests 3. Large tests Google also defines how to keep the balance between test types. Here it is: 1. Small test - 70% 2. Medium tests - 20% 3. Large tests - 10% Today I'll show you how in my Perfect Life application I'm doing integration tests. In small project i think medium/integration test should play important role and I'd dedicate 50% of my tests to integration. Let's jump into the code. This is a client class placed in Xamarin application, that is responsible for calling .NET Core web service: This is a test for this class. Note it calls real web service: So for small project to keep test balance I would follow the following proportion: 1. Small test - 45% 2. Med

.NET Core - where are my nuget packages?

When you create your first application in ASP.NET Core in Visual Studio 2017 you can be surprised. It's worth to mention one fundamental change in comparison to the previous version of .NET. The most striking difference you'll notice is missing packages.config file. I promise, there's no reason to be worried. Continue reading and you'll get the idea of how Nuget packages are managed in .NET Core projects. The question you can ask yourself is "where are my Nuget packages defined?" I admit that there's no packages.config file in the project anymore but there's an alternative place. what is this place? Just look at the .csproj file: As you can see that there is an element in the XML file which contains a number of elements. These are the current project dependencies. Now all project configuration (including nuget packages) are defined in one file which I find convenient solution.

Postępy prac - usluga sieciowa w ASP.NET Core

W ostatnim tygodniu osiągnąłem kilka kluczowych celów: 1. Stworzenie serwisu internetowego w ASP.NET Core 2. Stworzenie testów jednostkowych dla serwisu 3. Wdrożenie aplikacji na serwerze produkcyjnym (C# działa oczywiście na Linuxie) 4. Stworzenie definicji builda na serwerze Visual Studio Team Services 5. Zdobyłem praktykę w łączeniu projektów ASP.NET 4.5 i .NET Core 6. Utworzenie na serwerze Apache reverse proxy do serwera Kestrel A teraz najciekawsze: zobaczmy kod. Kontroler naszego serwisu w ASP.NET Core prezentuje się następująco: Repozytorium, które wstrzykujemy do kontrolera i wykorzystujemy w testach odwołuje się do kolekcji przechowywanej w pamięci serwera. Jest to świetny sposób do wykorzystania w testach - zamiast łączyć się z bazą trzymamy wszystkie dane w pamięci fizycznej. Technikę tę wykorzystać można również do cache'owania danych, ale o tym kiedy indziej. Oto kod repozytorium: Zauważmy, że repozytorium powinno korzystać ze statycznych właściwości

ASP.NET Core MVC - wdrożenie na Linuxie krok po kroku

Dzisiaj skupimy się na wdrożeniu aplikacji ASP.NET Core MVC. Po przeczytaniu tego artykułu będziesz potrafił uruchomić swoją pierwszą aplikację ASP.NET Core na maszynie wirtualnej z systemem Ubuntu 14. Załóżmy, że mamy nasza aplikację gotową i chcemy ją uruchomić. Jak najłatwiej to zrobić? Podczas debugowania możemy roboczo wykorzystać Visual Studio do uruchomienia aplikacji na IIS Express. Jednak w warunkach produkcyjnych kiedy chcemy wdrożyć aplikację na systemie Linux, musimy poszukać innego rozwiązania. Dlaczego? Bo Linux nie będzie obsługiwał ani visual Studio ani IIS Express, ponadto jeśli korzystamy z Continuous Deployment, to chcemy wdrożenie robić z poziomu konsoli. Jak pisałem w poprzednich postach, wraz z nadejściem ASP.NET Core MVC, mamy możliwość wdrażania aplikacji napisanych w C# na platformie Linux. To niezwykle istotne, bo przynosi ogromne korzyści, choćby dlatego, że ceny hostingu są kilka razy niższe dla maszyn z Linuxem niż z Windowsem. 1) Framework-depen

Perfect Life - usługa oparta o Web API w .NET Core

Dzisiaj pokażę jak skonfigurowałem mój web service Weight, który będzie wywoływała aplikacja mobilna Perfect Life w celu zapisania(i odczytania) wagi użytkownika na serwerze. Dotychczas tworzyłem usługi w ASP.NET 4 i umieszczałem na Azure. Mógłbym tak zrobić i tym razem, ale stawiam na rozwój i chcę użyć ASP.NET MVC Core i Visual Studio 2017. Jak zacząć? Tworzymy nowy projekt w Visual Studio. Będzie to aplikacja webowa ASP.NET Core. Po utworzeniu projektu dodajemy następujące linie w pliku .csproj(pamiętajmy, że Microsoft wycofał się ostatecznie z pliku project.json wracając do formatu XML). Konfiguracja pakietów wygląda tak: Jeśli wystartujemy naszą aplikację na serwerze IIS a następnie spróbujemy wywołać usługę za pomocą Postmana, albo dowolnej przeglądarki www, to otrzymamy błąd 406. Aby ten problem rozwiązać dodajemy następujący fragment w klasie Srartup: Wstępnie kontroler dla mojej usługi obejmuje dwie metody: POST - akcja będzie służyć do zapisu wagi przez użytkown

Fotorelacja z pilskiej konferencji MeeTTech

W minioną środę w Pile odbyła się kolejna edycja konferencji MeeTTech, której jestem współorganizatorem. Opowiem dzisiaj trochę o tym co się działo. 1. Liczby Na początku przedstawię kilka liczb. Odwiedziło nas ponad 60 osób. Na wydarzenie na Eventbrite zarejestrowało się 56 osób. Co jest o 1 więcej niż podczas poprzedniej edycji. Biorąc pod uwagę, że na promocję mieliśmy niecały tydzień, jest to świetny wynik. Co Ważne, więcej niż połowa zapisujących się osób trafiła na stronę Eventbrite przez Facebooka. 2. Miejsce Konferencja odbyła się w pilskim Inwest Parku przy ul. Dąbrowskiego 8. Ostatnim razem konferencja odbywała się w Sali Beżowej, która była wypełniona po brzegi obecnymi bądź przyszłymi programistami. Teraz mieliśmy do dyspozycji większą salę - kuluary. A wyglądało to tak: 3. Pierwsza prelekcja - Alan Sierhej Jako pierwszy wystąpił Alan Sierhej, programista na codzień pracujący w STX Next w Pile, ze swoim tematem dotyczącym pozycjonowania stron internetowy