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 / divs_changing(Carousel)
Created July 17, 2015 13:39
Simple div changing like Carousel. JS gets all divs with class game and rotate him. Compatibility Tested in jscc.info .
@kirilkirkov
kirilkirkov / get_highlight
Created July 17, 2015 13:40
Return highlight hex color for string. Can be used in loop. Return same color for same strings and different for others
<?php
function get_highlight($str) {
$colors = array('#ccddee', '#ffdddd', '#ddccee',
'#ddeecc', '#eeccdd', '#cceedd',
'#eeddcc', '#ddddff', '#ddffdd');
shuffle($colors);
static $prev_color = '';
static $arr = array();
if (!in_array($str, $arr)) {
$arr[] = $str;
@kirilkirkov
kirilkirkov / popUp
Created July 17, 2015 13:41
ReSizable popup with cookies for one time opening
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
</head>
<body>
<!-- Popup -->
<div id="overlay" style="display:none; position: fixed; width: 100%; height: 100%; background-color: black; z-index:1101; opacity:0.7; filter: alpha(opacity=70); top:0; left:0;"></div>
<div id="popup" style="display:none; z-index:1101; position: fixed; width:100%; max-width:700px; height:100%; max-height:572px; top: 50%; left: 50%; margin-top: -286px; margin-left: -350px;">
<a href="#" style="color:#fff; float:right; font-weight:bold;" onClick="setCookie()">Close <span class="glyphicon glyphicon-remove"></span></a>
<div style="width:700px; height:572px; background-color:#000;"></div>
@kirilkirkov
kirilkirkov / rgb_den
Created July 17, 2015 13:41
Give rgb color and percent and function will return you same color but brighter according to percent. From 0% to 100%. Example: <?php echo rgb_gen('64,128,0', '50%'); ?>
<?php
function rgb_gen($rgb, $percent) {
$cleaned_percent = preg_replace("/\..*|%/", "", $percent);
$rgb_increment = 100 - $cleaned_percent;
$rgb_arr = explode(',', $rgb);
$rgb_arr[0] + $rgb_increment <= 255 ? $rgb_arr[0]+=$rgb_increment : $rgb_arr[0] = 255;
$rgb_arr[1] + $rgb_increment <= 255 ? $rgb_arr[1]+=$rgb_increment : $rgb_arr[1] = 255;
$rgb_arr[2] + $rgb_increment <= 255 ? $rgb_arr[2]+=$rgb_increment : $rgb_arr[2] = 255;
$new_rgb = implode(',', $rgb_arr);
return $new_rgb;
@kirilkirkov
kirilkirkov / prepare.php
Created July 27, 2015 14:31
Example about prepare statements. No SQL Injections... no bugs, be safe
<?php
$servername = "localhost";
$username = "root";
$password = "toor";
$dbname = "test";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
@kirilkirkov
kirilkirkov / pagination_helper.php
Created July 28, 2015 07:48
Bootstrap pagination helper for CodeIgniter
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
function pagination($url, $rowscount, $per_page) {
$ci = & get_instance();
$ci->load->library('pagination');
$config = array();
$config["base_url"] = base_url($url);
$config["total_rows"] = $rowscount;
$config["per_page"] = $per_page;
@kirilkirkov
kirilkirkov / ajax_scoll_loading.php
Created July 28, 2015 13:02
Ajax loading elements with scoll. More comfortably from pagination in some situations!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
</head>
<body>
@kirilkirkov
kirilkirkov / query.sql
Last active August 29, 2015 14:26
Get num of categories for every type..
SELECT SUM(IF(category_id=1,1,0)) as category_one, SUM(IF(category_id=2,1,0)) as category_two, SUM(IF(category_id=3,1,0)) as category_three, SUM(IF(category_id=4,1,0)) as category_four, SUM(IF(category_id=5,1,0)) as category_five, SUM(IF(category_id=6,1,0)) as category_six, SUM(IF(category_id=7,1,0)) as category_seven, SUM(IF(category_id=8,1,0)) as category_eight, SUM(IF(category_id=9,1,0)) as category_nine, SUM(IF(category_id=10,1,0)) as category_ten, SUM(IF(category_id=11,1,0)) as category_eleven, SUM(IF(category_id=12,1,0)) as category_twelve FROM my_table
@kirilkirkov
kirilkirkov / gist:2ec13e7613b2905ed152
Created August 31, 2015 14:24
Ubuntu problem VirtualBox USB "Add device filter" doesnt work. Dont find any usb.
You probably have a permission issue. Add your user ID to group vboxusers with this command: sudo usermod -a -G vboxusers $USER, log off, log on and try again.
@kirilkirkov
kirilkirkov / gist:81fb325786facc256d4a
Created September 10, 2015 12:14
Какво е WGet и как се работи с нея
Какво е WGet ?
wget е съкращение от "web get". Това е command-line програма която се използва за сваляне на файлове от интернет.
Синтакс
wget [option]... [URL]...
Подробно описание