Skip to content

Instantly share code, notes, and snippets.

View romanitalian's full-sized avatar
🎯
Focusing

roman romadin romanitalian

🎯
Focusing
View GitHub Profile
@romanitalian
romanitalian / 000-default.conf
Created March 26, 2016 21:53
/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
@romanitalian
romanitalian / example_com__test_com.sh
Last active March 26, 2016 22:01
Последовательность комманд/действий для создания виртуальных хостов: example.com and test.com
sudo rm -rf /var/www/example.com/public_html
sudo rm -rf /var/www/test.com/public_html
sudo mkdir -p /var/www/example.com/public_html
sudo mkdir -p /var/www/test.com/public_html
sudo chown -R ubuntu:ubuntu /var/www/example.com/public_html
sudo chown -R ubuntu:ubuntu /var/www/test.com/public_html
@romanitalian
romanitalian / duplicateFileFinder.py
Created October 3, 2016 20:18
Help to find duplicate files in folder and sub-foldes
#!/usr/bin/python
import os
import sys
def getUniqueKey(fp):
"""
Calculate unique as integer value of last date-time changed of file and his size
:param fp:
:return:
@romanitalian
romanitalian / how_many_days_in_month.js
Created October 9, 2016 09:22
Как одной математической формулой по номеру месяца посчитать количество дней в нем?
function f(x) { return 28 + (x + Math.floor(x/8)) % 2 + 2 % x + 2 * Math.floor(1/x); }
@romanitalian
romanitalian / array_filter_by_keys.php
Last active February 8, 2019 15:55
Фильтруем массив по ключам
<?php
// PHP 5.6+
/**
* Фильтруем массив по ключам
*/
function arrayFilterByKeys($_rows, $_filter_keys)
{
$fk = array_fill_keys($_filter_keys, true);
$filter = function($key) use ($fk) {return isset($fk[$key]) && $fk[$key];};
@romanitalian
romanitalian / array_filter_by_values.php
Created October 17, 2016 11:30
Фильтруем массив по значениям
<?
$rows = array('a' => 1, 'b' => 2);
$f = array(2 => true);
function array_filter_by_values($_rows, $_filter_keys) {
$filter = function($key) use ($_filter_keys) {return isset($_filter_keys[$key]) && $_filter_keys[$key];};
$out = array_filter($_rows, $filter);
return $out;
}
@romanitalian
romanitalian / ri
Last active October 23, 2016 08:03
hello
Nice GistLog: https://gistlog.co/romanitalian/718c32270ba813f6d67c4f71c0215c3b
@romanitalian
romanitalian / go_clickhouse_test.go
Created August 7, 2017 19:07
Code: 73, Message: Unknown format TSVWithNamesAndTypes
package main
import (
"github.com/mailru/go-clickhouse"
"time"
"database/sql"
"log"
)
func main() {
@romanitalian
romanitalian / haversine.sql
Last active September 28, 2017 14:14 — forked from carlzulauf/haversine.sql
PostgreSQL function for haversine distance calculation, in miles
-- Haversine Formula based geodistance in miles (constant is diameter of Earth in miles)
-- Based on a similar PostgreSQL function found here: https://gist.github.com/831833
-- Updated to use distance formulas found here: http://www.codecodex.com/wiki/Calculate_distance_between_two_points_on_a_globe
CREATE OR REPLACE FUNCTION public.geodistance(alat double precision, alng double precision, blat double precision, blng double precision)
RETURNS double precision AS
$BODY$
SELECT asin(
sqrt(
sin(radians($3-$1)/2)^2 +
sin(radians($4-$2)/2)^2 *
@romanitalian
romanitalian / pi.txt
Created November 11, 2017 09:54
Value of the number π (4248156 digital)
This file has been truncated, but you can view the full file.
3.1415926535897932384626433832795028841971693993751058209749445923078164062862
089986280348253421170679821480865132823066470938446095505822317253594081284811
174502841027019385211055596446229489549303819644288109756659334461284756482337
867831652712019091456485669234603486104543266482133936072602491412737245870066
063155881748815209209628292540917153643678925903600113305305488204665213841469
519415116094330572703657595919530921861173819326117931051185480744623799627495
673518857527248912279381830119491298336733624406566430860213949463952247371907
021798609437027705392171762931767523846748184676694051320005681271452635608277
857713427577896091736371787214684409012249534301465495853710507922796892589235
420199561121290219608640344181598136297747713099605187072113499999983729780499