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 / gist:20e10d9eb21dea6020db
Created September 12, 2015 08:56
Convert the first character of "word" to uppercase (Multi Byte Helper For CodeIgniter)
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
function mb_ucfirst($str, $encoding = "UTF-8", $lower_str_end = false) {
$first_letter = mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding);
$str_end = "";
if ($lower_str_end) {
$str_end = mb_strtolower(mb_substr($str, 1, mb_strlen($str, $encoding), $encoding), $encoding);
@kirilkirkov
kirilkirkov / gist:f881d407aef2a99d084a
Last active September 15, 2015 12:25
Какво е cURL и как се работи с него
Какво е CURL ?
cURL е инструмент за прехвърляне на информация от и към сървър чрез използването на някой от поддържаните протоколи (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP). Програмата е направена да работи без намеса на потребителия.
cURL също поддържа proxy, user authentication, FTP ъплоад, HTTP post, SLL връзки, кукита, файлов трансфер, металинк и много други функции.
Статус на операциите
cURL обикновенно показва статуса на текущата операция, количество на прехвърлената информация, бързина на прехвърляне, очаквано време за приключване и други.
@kirilkirkov
kirilkirkov / gist:0617098daca9dd28646c
Created October 15, 2015 14:09
Photoshop vs Illustrator: Raster vs Vector
Understanding the differences between Illustrator and Photoshop
can range from confusing to downright frustrating for those who are
new to graphics and image editing. Which application should you use
for your project? Should you use a combination of the two together, or
just stick with one? Having a household name as Photoshop does, many people
simply turn to Photoshop for all their work, but that may not be the best
choice for all your graphics work.
It really boils down to having an understanding not only of what you wish to achieve,
but also having a firm grasp on the key differences between Photoshop and Illustrator;
@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:0240037f8df40bf8af46
Created September 8, 2015 13:55
Работа с 'Dig' под Linux
Dig (domain information groper) е програма за Linux също както е nslookup за Windows. Тя е малко по мощна. Тук са описани някои възможности за използването и, заявки към различни nameserver-и, заявки към специфични записи на nameserver (A, AAAA, MX, CNAME, TXT) и други.
Инсталиране на dig
Ако работите с Red Hat базирана дистрибуция (centos, fedora, red hat), може да използвате yum:
yum install bind-utils
За всяка Debian базирана е apt-get:
@kirilkirkov
kirilkirkov / gist:e134198d0493dd0bc69a
Created August 27, 2015 13:44
CORS (Cross-Origin Resource Sharing) - Ajax Request to another domain
<h2>CORS (Cross-Origin Resource Sharing)</h2>
<p>When you do a cross-origin request, the browser sends <code>Origin</code> header with the current domain value.</p>
<pre>
Origin: http://zinoui.com</pre>
<p>When the server receives the request, check whether the origin header is within the allowed list, and sends a response with <code>Access-Control-Allow-Origin</code></p>
<pre>