Skip to content

Instantly share code, notes, and snippets.

View kirilkirkov's full-sized avatar
🎯
Focusing

Kiril Kirkov kirilkirkov

🎯
Focusing
View GitHub Profile
@kirilkirkov
kirilkirkov / Multipart RAR Files
Created October 19, 2015 08:29
What is multipart archive
Hi! I am a complete newbie to RAR files and I want to learn what to do with them. I was just wondering:
What is a multipart RAR file?
1. A multipart RAR file is a standard RAR file, that was split into many smaller parts. This way, very large Archives can be placed on many small mediums, e.g. CDs.
2. The parts of a multipart RAR file are usually named "xyz.part1.rar", "yxz.part2.rar" etc. or "xyz.rar", "xyz.r01", "xyz.r02" etc. Depending on how many parts have been generated, there may be a few or a few hundred of these files.
3. A multipart RAR file can additionally be encrypted and protected by a password. Read more on password protection in the protected RAR files section of this FAQ.
4. BE CAREFUL: Sometimes multipart RAR files are used for phishing. Learn more in the phishing RAR files section of this FAQ.
5. Sometimes a multipart RAR file can be damaged and corrupted. Please take a look at the corrupted RAR files section of this FAQ to learn more.
Hi! I am an absolute beginner and
@kirilkirkov
kirilkirkov / gist:4fb35cffafdcc1b087e4
Last active November 2, 2015 13:01
Relational and Non-Relational Databases (MySQL vs. MongoDB)
When building a custom web application you need to consider the type of database that best suits the data.
Here's a quick guide on the differences between MySQL (Relational) and MongoDB (Non-Relational / NoSQL).
###Data Representation
-MySQL represents data in tables and rows.
-MongoDB represents data as collections of JSON documents.
If you think about it, a JSON document is very much like what you would be
working with in your application layer. If you are using javascript,
it's exactly what you're working with. If you're using PHP, it's just like an associative array.
If you're using python, its just like a dictionary object.
@kirilkirkov
kirilkirkov / gist:839a2fe9f8100d1a4f0e
Created November 19, 2015 16:56
jQuery Touch Pumch - use jQuery UI with mobile
/*!
* jQuery UI Touch Punch 0.2.3
*
* Copyright 2011–2014, Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Depends:
* jquery.ui.widget.js
* jquery.ui.mouse.js
*/
@kirilkirkov
kirilkirkov / gist:2a06fa2d459d397edb0a
Created January 25, 2016 12:59
Build Tree Structure from array
public function getPagesForSpace() {
$arr = array();
$result = $this->query("SELECT * FROM pages ORDER BY id ASC");
if($result !== false) {
while ($row = $result->fetch_assoc()) {
$arr[] = $row;
}
function buildTree(array $elements, $parentId = 0) {
$branch = array();
@kirilkirkov
kirilkirkov / gist:390f347759bd56f24061
Created February 3, 2016 14:23
PHP currency convertor using Google
<?php
function convertCurrency($amount, $from, $to){
$url = "https://www.google.com/finance/converter?a=$amount&from=$from&to=$to";
$data = file_get_contents($url);
preg_match("/<span class=bld>(.*)<\/span>/",$data, $converted);
$converted = preg_replace("/[^0-9.]/", "", $converted[1]);
return round($converted, 3);
}
# Call function
@kirilkirkov
kirilkirkov / gist:58c3c5fbd90729088b43
Created February 23, 2016 13:44
Adding Foreign Key Fails in MySQL (errno 150)
The solution:
The two tables must have the same engine i.e. ENGINE=InnoDB. (can be others: ENGINE=MyISAM works too)
The two tables must have the same charset.
The PK column(s) in the parent table and the FK column(s) must be the same data type. (if the PRIMARY Key in the Parent table is UNSIGNED, be sure to select UNSIGNED in the Child Table field)
The PK column(s) in the parent table and the FK column(s), if they have a define collation type, must have the same collation type;
If there is data already in the foreign key table, the FK column value(s) must match values in the parent table PK columns.
And the child table cannot be a temporary table.
@kirilkirkov
kirilkirkov / gist:d333f77df4f33d76bd5b
Created February 24, 2016 09:11
php fluent interface pattern $obj->method1()->method2();
<?php
class User
{
protected $name;
protected $surname;
protected $password;
public function setName($name)
{
@kirilkirkov
kirilkirkov / gist:9a6ac60c2e35caca1e5eb75dfe33a153
Created April 13, 2016 13:41
Cannot connect to Mail: Can not authenticate to IMAP server: [ALERT] Please log in via your web browser: https://support.google.com/mail/acco
Error when try access gmail from php imap solution:
Login to your gmail account, enable imap.
Let the access here first: https://www.google.com/settings/security/lesssecureapps
Go to: https://accounts.google.com/b/0/DisplayUnlockCaptcha and enable access.
@kirilkirkov
kirilkirkov / gist:b13baec4b5142a527399693f8829547d
Created June 21, 2016 07:20
Difference between png-Interlaced, jpg-progressive AND png-non-Interlaced, jpg-baseline
Interlaced image loads an early degraded version of the whole image as soon as possible and then progressively renders the image to clear state.
Non-interlaced image will load up in tiles showing clear image in each tile as it progresses to load in the image.
For .jpg the interlaced = progressive and not interlaced = baseline.
@kirilkirkov
kirilkirkov / gist:c43a5bdccd9a5c9124c77560ee2ffd04
Last active September 15, 2016 06:29
THIS in javascript, promises, deferred, soap, restful, async-sync load..
this:
Когато се извиква от функция
myFunction = function () {
console.log(this);
};
myFunction();
в този случей ще върне главния window обект
Когато се извиква вътре в обект е референция към съмия него.
var myObject = {