vendredi 21 juillet 2017

How to generate a C# entity of an SQL Server table

  Aucun commentaire

Hey, wassuuuuuuup 😆😆😝😝

Here is a trick for generating a C# entity of an SQL Server table.

For doing this, just execute the following SQL script... Don't forget to replace TableName in red with the name of the table...

declare @TableName sysname = 'TableName'
declare @Result varchar(max) = 'public class ' + @TableName + '
select @Result = @Result + '
    public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; }
        replace(, ' ', '_') ColumnName,
        column_id ColumnId,
            when 'bigint' then 'long'
            when 'binary' then 'byte[]'
            when 'bit' then 'bool'
            when 'char' then 'string'
            when 'date' then 'DateTime'
            when 'datetime' then 'DateTime'
            when 'datetime2' then 'DateTime'
            when 'datetimeoffset' then 'DateTimeOffset'
            when 'decimal' then 'decimal'
            when 'float' then 'float'
            when 'image' then 'byte[]'
            when 'int' then 'int'
            when 'money' then 'decimal'
            when 'nchar' then 'string'
            when 'ntext' then 'string'
            when 'numeric' then 'decimal'
            when 'nvarchar' then 'string'
            when 'real' then 'double'
            when 'smalldatetime' then 'DateTime'
            when 'smallint' then 'short'
            when 'smallmoney' then 'decimal'
            when 'text' then 'string'
            when 'time' then 'TimeSpan'
            when 'timestamp' then 'DateTime'
            when 'tinyint' then 'byte'
            when 'uniqueidentifier' then 'Guid'
            when 'varbinary' then 'byte[]'
            when 'varchar' then 'string'
            else 'UNKNOWN_' +
        end ColumnType,
            when col.is_nullable = 1 and in ('bigint', 'bit', 'date', 'datetime', 'datetime2', 'datetimeoffset', 'decimal', 'float', 'int', 'money', 'numeric', 'real', 'smalldatetime', 'smallint', 'smallmoney', 'time', 'tinyint', 'uniqueidentifier')
            then '?'
            else ''
        end NullableSign
    from sys.columns col
        join sys.types typ on
            col.system_type_id = typ.system_type_id AND col.user_type_id = typ.user_type_id
    where object_id = object_id(@TableName)
) t
order by ColumnId
set @Result = @Result  + '
print @Result

Original Source :

Read More

vendredi 14 juillet 2017

[06/2017] Bookmark of the Month

  Aucun commentaire
Read More

jeudi 8 juin 2017

How to setup a Cron Job on Ubuntu?

  Aucun commentaire

Hey, Wasuuuuuuup 😝

Today we will learn how to setup / start a Cron Job on Ubuntu.

What is a cron job ?

The software utility Cron is a time-based job scheduler in Unix-like computer operating systems. People who set up and maintain software environments use cron to schedule jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals. It typically automates system maintenance or administration—though its general-purpose nature makes it useful for things like downloading files from the Internet and downloading email at regular intervals.[1] The origin of the name cron is from the Greek word for time, χρόνος (chronos).[2] (Ken Thompson, author of cron, has confirmed this in a private communication with Brian Kernighan.)  [By Wikipedia - Read more ...]
We understand now that a cron is a task executed each and every [time interval].

 How to setup my own cron job?

To setup your own cron, you should run the following command :
crontab -e
Then add your task line. Let's take as example this line:
* * * * * /path/to/command 
The task above executes a command each and every minute...

Cron jobs time interval can be customized, read more ...

Hope this article helps you to setup your first cron 😉

Read More

[FIX] Why the "< ?" tag is not working on php ?

  Aucun commentaire

Heeey, Wassuuuuuuuuuup....

Today we will fix the "<?" tag problem in PHP.

If you are one of those that faced that problem, you probably didn't enabled the "short_open_tag" in your php.ini file by setting the value of the option "short_open_tag" to "On"

To fix the problem you should follow these step.
  1. Locate the php.ini file

    In order to enable the "short_open_tag" option, you must find the php.ini file in your server.
    If you know the location of php.ini file in your server, you an skip this step.
    To locate, create a new file (infos.php) in your html directory:
    nano infos.php
    And parse this line :
    <?php phpinfo(); ?>
    Open your navigator and go to your infos.php page :
    Now you can see the path of the php.ini file, for me it's : /etc/php5/fpm/php.ini
  2. Change the short_open_tag option

    Now as you are able to locate the php.ini file, you can open it with your preferred editor, I use "nano" .
    nano (your php.ini path)
    Then you will see the "short_open_tag = Off", fix the problem  by setting it to :
    short_open_tag = On
Note : You must restart your php service (apache or php-fpm) in order to apply changes.

That's it! hope it works for you 😉

Read More

mardi 6 juin 2017

[FIX] Call to undefined method mysqli_stmt::get_result

  Aucun commentaire

Great to see you again,

Today we're gonna fix the problem that shows the message "Call to undefined method mysqli_stmt::get_result".

I actually faced that problem when I was trying to install nginx + php5-fpm + php5-mysql in my server, everything worked for me, except that method "get_result".

So, like any beginner 😅 I googled'it, and I found that I have to install this package "php5-mysqlnd" using the following command:
apt-get install php5-mysqlnd
Hope it works for your  !

Read More

jeudi 29 décembre 2016

Show "Next Line Button" on Android Keyboard

  Aucun commentaire

Hey, wassup?

For Android Developers, here is a little piece of code of How to show the Next Line
on on keyboard while editing text on the Edit Text component


Hope it works :D

Read More

lundi 12 décembre 2016

[Linux] Install, Configure and Use NGINX on Ubuntu

  Aucun commentaire

Hello everyone,

Installing NGINX on Ubuntu is very easy, just follow the following commands:
sudo apt-get update
sudo apt-get install nginx 
For those who want to install NGINX but they have Apache pre-installed in their Linux, and they can't access to NGINX files and web pages, here's a solution:
Apache uses the :80 as a default port, and NGINX do so, to fix this problem we must change the NGINX port to something else, let's take :90 as example.

Here's a few lines that help you to change NGINX default port:
vi /etc/nginx/sites-available/default
Change the lines :
server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

To :
server {
        listen 90 default_server;
        listen [::]:90 default_server ipv6only=on;
 Then save the file ... and restart NGINX service by typing the command below:
service nginx restart
That's it!

Now go the address : http://ip_of_your_server:90  (change ip_of_your_server with your server ip)
Then you should get this page :

To add files & web pages go to this directory:
cd /usr/share/nginx/html/

Read More