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 / ExecuteScritpAsAdmin.ps1
Created March 13, 2019 17:16
Execute PowerShell script as admin
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
@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 / bash_tips.sh
Last active November 23, 2023 14:39
Bash Tips/Tricks
# find folder location by folder name
dir=$(sudo find $HOME -type d -name folderName)
cd $dir
# print file data that starts from specific text
cat .flake8 | sed -n -e '/exclude = /,$p'
@victory-sokolov
victory-sokolov / driver_options.py
Last active November 23, 2023 14:39
Selenium Driver options
''' Firefox Driver options '''
options = webdriver.FirefoxOptions()
# disable push notifications
options.set_preference("dom.push.enabled", False)
# maximize window size
driver.maximize_window()
@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;
.image {
position: relative;
background: #f5f5f5;
max-width: 100%;
max-height: 100%;
overflow: hidden;
}
.image:after {
@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)));
}
@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 / 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 / word_count.php
Last active November 23, 2023 14:42
PHP count words in string
<?php
function wordCount() {
$description = "Hello there";
$string = preg_replace('/\s+/', ' ', trim($description));
$words = explode(" ", $string);
return count($words);
}