Skip to content

Instantly share code, notes, and snippets.

View dejurin's full-sized avatar
💭
;-)

YURII D. dejurin

💭
;-)
  • Si-ɑR
  • București, România 🇷🇴
  • 20:35 (UTC +03:00)
View GitHub Profile
@dejurin
dejurin / index.html
Created November 11, 2015 12:31 — forked from mattattui/index.html
Count online users
<!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 December 23, 2016 20:57 — forked from selfboot/centos_python.sh
CentOS 6.8: Install Python 2.7.10, pip, virtualenv, and virtualenvwrapper on CentOS
#!/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 December 29, 2016 00:32 — forked from dalegaspi/python27_on_centos65.md
Installing Python 2.7 on CentOS 6.5

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 September 4, 2017 15:40
Javascript Google Suggest Autocomplete
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 September 4, 2017 15:49
[CodeIgniter] Modified functions: link_tag, meta
<?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 September 28, 2017 19:57
[PHP] get scheme from _SERVER
<?php
$scheme = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] === 1)) ? 'https://':'http://';
@dejurin
dejurin / scrollToTop.js
Created September 28, 2017 19:59
document.body.scrollTop for Safari, Chrome
/*
* 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)]
@dejurin
dejurin / Lang_detect.php
Created October 4, 2017 17:04
Language detection library for CodeIgniter
<?php
/**
* Lang_detect Class.
*
* Language detection library for CodeIgniter.
*
* @author La2ha
*
* @version 1.0
@dejurin
dejurin / get_file_extension.php
Created November 25, 2017 21:44
Get extension of file if you have only string (filename.ext)
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);
}
@dejurin
dejurin / .htaccess
Last active December 7, 2017 16:52
htaccess: redirect HTTP to HTTPS with without WWW
// without wwww
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]
// with www
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]