Skip to content

Instantly share code, notes, and snippets.

View sokil's full-sized avatar
🇺🇦
sapere aude

sokil

🇺🇦
sapere aude
View GitHub Profile
@sokil
sokil / portForward.sh
Last active June 21, 2017 20:41
Port forward
# https://habrahabr.ru/post/331348/
# https://habrahabr.ru/post/122445/
# open local port on remote machine
ssh -R 9000:localhost:9000 remoteHost
# open remote port on local machine
ssh -L 9000:localhost:9000 remoteHost
@sokil
sokil / ssl_exp_check.sh
Last active April 25, 2017 11:00
SSL expiration check
#!/bin/bash
echo | openssl s_client -servername server.com -connect server.com:443 2>/dev/null | openssl x509 -noout -dates
@sokil
sokil / git_day_log.sh
Created March 30, 2017 08:30
Git daily log in all branches
#!/bin/bash
# Useage:
# $ git_day_log 2017-03-30
git log --all --after="$1 00:00:00" --before="$1 23:59:59" --author="Sokil"
@sokil
sokil / curl_timing.sh
Last active August 25, 2022 20:16
curl request timing
#!/bin/bash
# https://curl.haxx.se/docs/manpage.html
# time_appconnect The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed. (Added in 7.19.0)
# time_connect The time, in seconds, it took from the start until the TCP connect to the remote host (or proxy) was completed.
# time_namelookup The time, in seconds, it took from the start until the name resolving was completed.
# time_pretransfer The time, in seconds, it took from the start until the file transfer was just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved.
# time_redirect The time, in seconds, it took for all redirection steps including name lookup, connect, pretransfer and transfer before the final transaction was started. time_redirect shows the complete execution time for multiple redirections. (Added in 7.12.3)
# time_starttransfer The time, in seconds, it took from the start until the first byte was j
@sokil
sokil / fixture.sh
Created March 16, 2017 10:16
Add values to mysql table
#!/bin/bash
mysql_config_file="~/connection.cfg";
startOffset=$1;
endOffset=$2;
chunkSize=$3;
for ((i=$startOffset; i<=$endOffset; i=$i+$chunkSize));
do
values="";
@sokil
sokil / this.cpp
Created February 20, 2017 06:46
Refer to object inside object
class MyClass {
public:
MyClass(int a) : var(a)
{ }
void printInfo() {
cout << var<<endl;
cout << this->var<<endl;
cout << (*this).var<<endl;
}
private:
@sokil
sokil / columnRenderer.php
Created February 8, 2017 08:38
Render list by columns
<?php
function renderListByColumns(array $list, $columnCount = 4, $columnSize = 50)
{
sort($list);
$size = count($list);
$rowSize = ceil($size / $columnCount);
// pad types array
@sokil
sokil / event.ics
Created January 19, 2017 06:29
Event attachment in mail
BEGIN:VCALENDAR
VERSION:1.0
BEGIN:VEVENT
TZID:Europe/Kiev
DTSTART:20170121T110000
DTEND:20170121T130000
LOCATION:Київ, вул. Хрещатик, 36
DESCRIPTION:Форум громадських проектів міста Києва. Ярмарок громадських проектів 2.0.
SUMMARY:Форум громадських проектів міста Києва.
ORGANIZER;CN=Kyiv Smart City:MAILTO:[email protected]
@sokil
sokil / substr.sh
Last active June 24, 2022 15:05
xargs substring
#!/bin/bash
# get all files
find . -type f | sort | xargs -I{} bash -c 'echo ${1:2}' -- {}
# get tracked git files
git ls-files | sort
# ignored git files
git status --ignored .
@sokil
sokil / cur_dir.sh
Created January 13, 2017 14:14
cur_dir.sh
#!/bin/bash
FILE=$(readlink -f $0);
DIR=$(dirname $FILE)
echo $FILE
echo $dir