A collection of programming & webdesign
Java
Print Datatype to Console

Here's how to print the datatype of an object or a primitive value to the console:

  1. Object:
    Object myobject = “new”;    // note: String is an object
... read more
JavaScript
jQuery toggle with Flexbox

If you want to toggle a container which is a flexbox, one  of the easiest ways, in fact, is to surround your flex container with a standard block container and then use the toggle function on the block container, like so:

... read more
C#
Modifiers

Modifiers in C#:

  • internal (default for classes)
  • private (default for methods, variables)
C#
C# Printing Strings

There are three ways of printing strings in C#:

  1. The “classic” way:
    Console.WriteLine("Hello " + world);
  2. Using a placeholder:
    Console.WriteLine("Hello {0}", world);
  3. Using $:
    Console.WriteLine($"Hello {world}, today is {date_time}");
C#
Classes

A class should always have a constructor. The constructor initiates the data members.

The keyword this references to current class data members.

Structure of a class:

  1. includes
  2. parameters
  3. constructor
  4. methods
... read more
C#
OOP

OOP is based on 4 pillars:

  1. Abstraction: makes process/functionality abstract
  2. Polymorphism: one entity, many forms
  3. Encapsulation: protect methods and variables
  4. Inheritance

There's also OOAD. OOAD is object-oriented analysis and design. It's a technical approach for analyzing an ddesigning an application, system, or business by applying OOP as well as using visual modeling.

C++
Single and double quotes

Whereas in some programming languages it doesn't matter if you use single or double quotes, it matters highly in C++ (and some others, such as Java, also). For example, if you're a webdeveloper and write a function in JavaScript, you can even mix them and it will still work and give you the right output (as long as you don't use single ones at the beginning and doubles at the end of the same string).

... read more
JavaScript
JS time format HH:mm

Just because I couldn't believe it… obviously there's no easier way in JavaScript to show the time in HH:mm (e.g. 11:05) then to build the string yourself, using if-conditions and adding the zero manually where needed:

... read more
C++
Initializing variables

While in Java, for example, you get an error if you want to run a function which contains a variable that hasn't been initialized  java: variable x might not have been initialized , not so in C++ and that can be tricky.

In C++ variables which haven't been initialized get random values which can or will almost always lead to unexpected results.

... read more
Laravel
Laravel maintenance mode

While working on a live Laravel project it might be useful to set the page in a maintenance mode, so that users visiting it, won't see any errors while work's in progress.

For this, practically just log into the server where your project is located, navigate to your project folder and there use the command  php artisan down . This sets your application in a maintenance mode. What people visiting your page then will see is a standard Laravel maintenance page.

... read more
Laravel
Laravel passing several variables to view

There are several ways of passing multiple variables to a view in Laravel:

1. Using with()

... read more
Laravel
Laravel defaults xampp & mamp

Xampp:

APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=my_db
DB_USERNAME=root
DB_PASSWORD=

... read more
Laravel
Laravel date language

Obviously, there are several methods of setting up the language of a date in Laravel. I was finally successful with the following one:

1. AppServiceProvider:

public function register()
    {
        setlocale(LC_TIME, config('app.locale'));
    }

... read more
Laravel
Laravel run app on different port

Just because I keep forgetting this command -

if you wish to open your Laravel application not on the standard 8000 port but on a different one, use this:

 php artisan serve --port=1234 

Also handy if you've got several applications running at the same time.

Laravel
Different uses of with() in Laravel

In Laravel you can use the with() method to pass data to a view for example.

But there are different ways of this with() method as for how the passed parameters are treated by the system in the view they've been passed to:

... read more
Laravel
Laravel routes

Something important when creating routes in Laravel is never to use routes consisting of variables only. Make them unique, like so -

Don't:  /{id}/{title} 

Do:  /cat/{id}/{title} 

Laravel
Laravel resources via public

What do you put in resources, what in public?

The resources folder:

  • css
  • js (new files have to be included in webpackmix file, too)

Access via:  ("../js/yourfile.js") 

... read more
Laravel
Use of npm in Laravel to manage CSS

For your CSS in Laravel you can either use the public folder or use the resources/css folder and npm to manage and compile your CSS.

For this, do the following:

... read more
Version Control
Git Installation & First Setup

Here are the steps to be followed installing and setting up Git on a Windows machine using a GitHub account:

Download and install the latest version of Git.

Set your username in Git:

  • open Git Bash
... read more