Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
;-)

Yurii De dejurin

💭
;-)
  • Si-ɑR
  • 127.0.0.1
View GitHub Profile
@dejurin
dejurin / index.html
Created Nov 11, 2015 — forked from inanimatt/index.html
Count online users
View index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Pinger test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
@dejurin
dejurin / centos_python.sh
Created Dec 23, 2016 — forked from selfboot/centos_python.sh
CentOS 6.8: Install Python 2.7.10, pip, virtualenv, and virtualenvwrapper on CentOS
View centos_python.sh
#!/bin/bash
# According to:
# How To Set Up Python 2.7.6 and 3.3.3 on CentOS 6.4
# https://www.digitalocean.com/community/tutorials/how-to-set-up-python-2-7-6-and-3-3-3-on-centos-6-4
yum -y update
yum groupinstall -y 'development tools'
yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel
yum install xz-libs
wget http://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz
@dejurin
dejurin / python27_on_centos65.md
Created Dec 29, 2016 — forked from dalegaspi/python27_on_centos65.md
Installing Python 2.7 on CentOS 6.5
View python27_on_centos65.md

Installing Python 2.7 on Centos 6.5

Centos 6.* comes with Python 2.6, but we can't just replace it with v2.7 because it's used by the OS internally (apparently) so you will need to install v2.7 (or 3.x, for that matter) along with it. Fortunately, CentOS made this quite painless with their Software Collections Repository

sudo yum update # update yum
sudo yum install centos-release-scl # install SCL 
sudo yum install python27 # install Python 2.7

To use it, you essentially spawn another shell (or script) while enabling the newer version of Python:

@dejurin
dejurin / googleSuggestAutocomplete.js
Last active Sep 4, 2017
Javascript Google Suggest Autocomplete
View googleSuggestAutocomplete.js
function getQueryGoogle(obj, callback) {
var id = "i" + Math.random().toString(36).slice(2);
getQueryGoogle[id] = function(data) {
callback(obj, data);
delete getQueryGoogle[id];
};
// Google clients1
loadScript("//clients1.google.com/complete/search?client=firefox&q=" + encodeURIComponent(obj.value) + "&callback=getQueryGoogle." + id);
// Yahoo
/*
@dejurin
dejurin / MY_html_helper.php
Created Sep 4, 2017
[CodeIgniter] Modified functions: link_tag, meta
View MY_html_helper.php
<?php
if (!function_exists('link_tag')) {
/**
* Link.
*
* Generates link to a CSS file
*
* @param mixed stylesheet hrefs or an array
* @param string rel
@dejurin
dejurin / getScheme.php
Created Sep 28, 2017
[PHP] get scheme from _SERVER
View getScheme.php
<?php
$scheme = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] === 1)) ? 'https://':'http://';
@dejurin
dejurin / scrollToTop.js
Created Sep 28, 2017
document.body.scrollTop for Safari, Chrome
View scrollToTop.js
/*
* Tested
* MacOS [Safari, 11.0 (12604.1.38.1.7)]
* > console.log(window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0)
* [Log] 1173
* < undefined
* MacOS [Chrome, 61.0.3163.100, (64 bit)]
View offsetTop.js
function getOffset(el) {
if (typeof el !== 'undefined') {
if (el.getBoundingClientRect()) {
var box = el.getBoundingClientRect(),
body = document.body,
docElem = document.documentElement,
scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop,
clientTop = docElem.clientTop || body.clientTop || 0,
top = box.top + scrollTop - clientTop;
return Math.round(top);
@dejurin
dejurin / Lang_detect.php
Created Oct 4, 2017
Language detection library for CodeIgniter
View Lang_detect.php
<?php
/**
* Lang_detect Class.
*
* Language detection library for CodeIgniter.
*
* @author La2ha
*
* @version 1.0
@dejurin
dejurin / get_file_extension.php
Created Nov 25, 2017
Get extension of file if you have only string (filename.ext)
View get_file_extension.php
function get_file_extension($filename)
{
/*
* "." for extension should be available and not be the first character
* so position should not be false or 0.
*/
$last_dot_pos = strrpos($filename, '.');
if ( !$last_dot_pos ) return false;
return substr($filename, $last_dot_pos + 1);
}