Skip to content

Instantly share code, notes, and snippets.

View victory-sokolov's full-sized avatar
🎯
Focusing

Viktor Sokolov victory-sokolov

🎯
Focusing
View GitHub Profile
@victory-sokolov
victory-sokolov / scroll-indicator.html
Last active November 23, 2023 14:43
Scroll indicator design
<!DOCTYPE html>
<html>
<head><head>
<body>
<header class="scroller"></header>
<main>
content must be longer than 100vh
</main>
@victory-sokolov
victory-sokolov / shorten_url.py
Last active November 23, 2023 14:42
Shorten Url with tinyurl
from urllib.request import urlopen
url = "https://facebook.com"
data = urlopen("http://tinyurl.com/api-create.php?url="+url)
shorten_url = data.readlines()[0].decode()
print(shorten_url)
@victory-sokolov
victory-sokolov / css_shortcuts.css
Created December 4, 2018 11:31
Some css shortcuts
// disallow select content on the page
.no-select {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@victory-sokolov
victory-sokolov / getIP.php
Last active November 23, 2023 14:41
Get user IP Address
<?php
function getIP()
{
if ($_SERVER['HTTP_CLIENT_IP'])
$visitorIP[] = $_SERVER['HTTP_CLIENT_IP'];
if ($_SERVER['HTTP_X_FORWARDED'])
$visitorIP[] = $_SERVER['HTTP_X_FORWARDED'];
if ($_SERVER['HTTP_X_FORWARDED_FOR'])
$visitorIP[] = $_SERVER['HTTP_X_FORWARDED_FOR'];
@victory-sokolov
victory-sokolov / getPageLanguage.php
Last active November 23, 2023 14:41
PHP Function that returns page language
<?php
function getLang(array $request, $default)
{
return
!empty($request['get']['lang']) ? $request['get']['lang'] :
(!empty($request['cookie']['lang']) ? $request['cookie']['lang'] :
(!empty($request['session']['lang']) ? $request['session']['lang'] :
(!empty($request['server']['HTTP_ACCEPT_LANGUAGE']) ? substr($request['server']['HTTP_ACCEPT_LANGUAGE'], 0, 2) : $default)));
}
.image {
position: relative;
background: #f5f5f5;
max-width: 100%;
max-height: 100%;
overflow: hidden;
}
.image:after {
@victory-sokolov
victory-sokolov / equal_height.css
Last active January 21, 2019 09:23
Equal Height
.row {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
flex-wrap: wrap;
}
.row > [class*='col-'] {
display: flex;
@victory-sokolov
victory-sokolov / getCssStyle.js
Last active November 23, 2023 14:39
return css property font-size
const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName];
getStyle(document.querySelector('p'), 'font-size'); // '16px'
@victory-sokolov
victory-sokolov / excel-to-pdf.py
Created December 31, 2019 09:26
Converts xlsx,csv to PDF file
# Note Microsoft Excel must be installed
from openpyxl import Workbook, load_workbook
from win32com.client import Dispatch
path = os.path.dirname(os.path.abspath(__file__))
o = Dispatch("Excel.Application")
o.Visible = False
o.DisplayAlerts = False
@victory-sokolov
victory-sokolov / split_list_n_parts.py
Created January 6, 2020 12:41
Split list into n parts
def chunks(lst, n):
for i in range(0, len(lst), n):
yield lst[i:i + n]
lst = [1,3,5,6,7,9,5,4,2,3,5,6,7,4,3]
res = list(chunks(lst, 3))
print(res) # [[1, 3, 5], [6, 7, 9], [5, 4, 2], [3, 5, 6], [7, 4, 3]]