пятница, 3 марта 2017 г.

What's the difference between JavaScript and Java?

Lots of people working in IT don't understand that Java and JavaScript are almost completely unrelated to each other. The best explanation how similar they are would be to say in a non-techie way:
Java and Javascript are similar like Car and Carpet are similar. 
or
Java is to JavaScript as ham is to hamster.
One may say "Ham is to Hamster... technically they are both meat...". JavaScript sounds like it has something to do with Java. It doesn’t.

Yes, both are programming languages and belong to the programming world. However, aside from this apparently confusing similarity, the two languages could not be further from the same thing.  Apart from some superficial syntactical similarities, they have nothing in common.

This page will be the page for the guys, who are still asking this kind of question, will redirect them here :)

пятница, 22 июля 2016 г.

Картинка путь предпринимателя и путь стартапера

Попалась на глаза очень замечательная картинка, иллюстрирующая путь предпринимателя и путь стартапера (картинка из интернета, копирайты сохранены).


Согласно статистике, более 90% (девяносто процентов) всех интернет-стартапов заканчиваются неудачей в течение первых 120 (ста двадцати) дней.

четверг, 10 декабря 2015 г.

error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

It seems everyone at least once faced issues with SSL certificates on Mac. That happens after certain period of time, or after another system update, and everything that uses OpenSSL stops to work.

My situation was next: I did system update on OSX El Capitan, plus updated webserver and PHP... and then composer and rest things which are using OpenSSL stopped to operate. On composer update and self-update I was kept getting error messages alike:

bash-3.2# composer self-update
Downloading https://getcomposer.org/version

[Composer\Downloader\TransportException]
The "https://getcomposer.org/version" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed

Investigation showed, that there's no easy way to restore the previous state. So the decision was made to extract certificates from Apple’s Keychain via simple bash script:

cert_file="$( openssl version -d | awk -F'"' '{print $2}' )/cert.pem"
mkdir -p "${cert_file%/*}"
security find-certificate -a -p /Library/Keychains/System.keychain > "$cert_file"
security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain >> "$cert_file"

I hope this article will help someone to do economy of time! Happy coding!


вторник, 29 сентября 2015 г.

Как почистить состояние GIT и удалить теги (clean GIT state and delete GIT tags)

Хотел бы опубликовать список простеньких команд GIT, которые, в принципе, должны быть постоянно под рукой, для возврата гита в исходное состояние, согласно origin, если интенсивно идёт работа с бренчами и тегами.

Для того чтобы почистить все бренчи, которые не существуют больше на remote, но оставить свои локальные, которых нет в origin, в GIT существует простая команда:

git fetch [remote] --prune

# или
 
git remote prune [remote]

Для того, чтобы удалить все теги GIT, которые больше не существуют в origin, но остались локально воспользуйтесь командой:

git fetch --prune [remote] +refs/tags/*:refs/tags/*

Таким образом, если ваш remote имеет название origin, тогда команды примут следующий вид

git fetch --prune origin +refs/tags/*:refs/tags/*
git fetch origin --prune

среда, 3 сентября 2014 г.

Сodeigniter нашёл нового хозяина

Практически год прошёл с момента, когда EllisLab объявили о своих намерениях о прекращении поддержки CodeIgniter как отдельного продукта и старте поиска новых хозяев для проекта. Этого шага многие ожидали, ExpressionEngine выродился в самостоятельную единицу и уже больше не пересекался с CodeIgniter и поддержка двух движков для EllisLab не имела никакого экономического обоснования.
И вот недавно в официальном твитере, проскочила интригующая реплика, о том что нашли новый дом для CI:
Whew! Lengthy search and process is winding down. @codeigniter has a new home. Details will follow soon.
Интрига держится до сих пор, других официальных сообщений со стороны EllisLab пока не поступало. Очень интересно, кто же, всё-таки, будет новым хозяином столь популярного фреймворка!
___
Update: проект был передан British Columbia Institute of Technology

пятница, 19 октября 2012 г.

CodeIgniter: Affected Rows fix on DB insert/update batch functions

During last phase of the development on another CodeIgniter based project, I did import/export functionality, and used Active Record’s insert/update batch functions.

I figured out, that CodeIgniter’s core with CI_VERSION=2.1.2 doesn’t allow you to calculate the number of affected rows on batch functions. That’s the function to get the affected rows doesn’t work when using the batch insert or update functions. More details posted in the issue https://github.com/EllisLab/CodeIgniter/issues/126, it was opened a year ago, though in the open state still.

I decided to fix that myself, patched the native CI’s Active Record Class. From now the batch functions could return the number of affected rows instead of only TRUE. If everything worked but no records were affected the function would return 0. When there's an error in the parameters passed it will return FALSE, so no confusion here.

Here are the methods I patched, so you could freely use them or just send that to CI’s devs to fix that issue in the newer versions of the framework:

    /**
     * Insert_Batch
     *
     * Compiles batch insert strings and runs the queries
     * (affected rows fix by WebAurum (http://webaurum.blogspot.com),
     * for more information see issue https://github.com/EllisLab/CodeIgniter/issues/126 )
     *
     * @param    string    the table to retrieve the results from
     * @param    array    an associative array of insert values
     * @return    object
     */
    public function insert_batch($table = '', $set = NULL)
    {
        if ( ! is_null($set))
        {
            $this->set_insert_batch($set);
        }

        if (count($this->ar_set) == 0)
        {
            if ($this->db_debug)
            {
                //No valid data array. Folds in cases where keys and values did not match up
                return $this->display_error('db_must_use_set');
            }
            return FALSE;
        }

        if ($table == '')
        {
            if ( ! isset($this->ar_from[0]))
            {
                if ($this->db_debug)
                {
                    return $this->display_error('db_must_set_table');
                }
                return FALSE;
            }

            $table = $this->ar_from[0];
        }
            
        $affected_rows = 0;

        // Batch this baby
        for ($i = 0, $total = count($this->ar_set); $i < $total; $i = $i + 100)
        {

            $sql = $this->_insert_batch($this->_protect_identifiers($table, TRUE, NULL, FALSE), $this->ar_keys, array_slice($this->ar_set, $i, 100));

            //echo $sql;

            $this->query($sql);

            $affected_rows += $this->affected_rows();
        }

        $this->_reset_write();


        return $affected_rows;
    }

    /**
     * Update_Batch
     *
     * Compiles an update string and runs the query
     * (affected rows fix by WebAurum (http://webaurum.blogspot.com),
     * for more information see issue https://github.com/EllisLab/CodeIgniter/issues/126 )

     *
     * @param    string    the table to retrieve the results from
     * @param    array    an associative array of update values
     * @param    string    the where key
     * @return    object
     */
    public function update_batch($table = '', $set = NULL, $index = NULL)
    {
        // Combine any cached components with the current statements
        $this->_merge_cache();

        if (is_null($index))
        {
            if ($this->db_debug)
            {
                return $this->display_error('db_must_use_index');
            }

            return FALSE;
        }

        if ( ! is_null($set))
        {
            $this->set_update_batch($set, $index);
        }

        if (count($this->ar_set) == 0)
        {
            if ($this->db_debug)
            {
                return $this->display_error('db_must_use_set');
            }

            return FALSE;
        }

        if ($table == '')
        {
            if ( ! isset($this->ar_from[0]))
            {
                if ($this->db_debug)
                {
                    return $this->display_error('db_must_set_table');
                }
                return FALSE;
            }

            $table = $this->ar_from[0];
        }

        $affected_rows = 0;

        // Batch this baby
        for ($i = 0, $total = count($this->ar_set); $i < $total; $i = $i + 100)
        {
            $sql = $this->_update_batch($this->_protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->ar_set, $i, 100), $this->_protect_identifiers($index), $this->ar_where);

            $this->query($sql);

            $affected_rows += $this->affected_rows();
        }

        $this->_reset_write();

        return $affected_rows;
    }

Рекоммендую

Попробуйте надёжный хостинг от Scala Hosting