Skip to content

Instantly share code, notes, and snippets.

View sanmai's full-sized avatar

Alexey Kopytko sanmai

View GitHub Profile
@sanmai
sanmai / hide-referer.conf
Last active December 26, 2023 01:35
Hide referer header for outbound links with the power of nginx. For this to work you must use it within a https-enabled server.
# Usage:
# https://www.example.com/hide-referer?http://en.wikipedia.org/wiki/HTTP_referer
server {
server_name www.example.com;
listen 80;
listen 443 ssl;
ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
@sanmai
sanmai / example.xml
Last active August 16, 2023 12:53
Генератор данных по товарам в формате YML
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE yml_catalog SYSTEM "shops.dtd">
<yml_catalog date="2016-03-14 18:03">
<shop>
<name>Shop Name</name>
<company>Company Name</company>
<url>https://www.example.com/</url>
<currencies>
<currency id="RUR" rate="1"/>
<currency id="USD" rate="81.00"/>
@sanmai
sanmai / YandexNotification.php
Created August 8, 2012 08:31
PHP class to send Yandex.Money HTTP notifications
<?php
/**
* PHP class to send Yandex.Money HTTP notifications
* @author sanmai
* @license MIT
*
* Usage:
*
* $notification = new YandexNotification();
* // Set notification properties as you need
@sanmai
sanmai / Count Code lines.sh
Created October 5, 2020 05:16 — forked from amitchhajer/Count Code lines
Count number of code lines in git repository per user
git ls-files | xargs -n1 git blame --line-porcelain | sed -n 's/^author //p' | sort -f | uniq -ic | sort -nr
@sanmai
sanmai / Makefile
Last active October 8, 2022 21:23
Trying to force `--jobs` with GNU Make 4.1
CPUS ?= $(shell nproc)
MAKEFLAGS += --jobs=$(CPUS)
all:
@echo \'$(MAKEFLAGS)\' must have --jobs=$(CPUS)
@sanmai
sanmai / merge_dna_files.rb
Created August 15, 2022 02:54 — forked from plashchynski/merge_dna_files.rb
Tool to merge 23andme and Ancestory.com raw dna files
#!/usr/bin/ruby
#
# Usage:
# ruby ./merge_dna_files.rb file,file1,file2... > merged_file.txt
#
# Example:
# ruby ./merge_dna_files.rb AncestryDNA.txt genome_John_Doe_v4_Full_20170428065226.txt > merged_raw.txt
#
# Supports 23andMe, AncestryDNA, and Genes for Good 23andMe compatible file formats.
# The result will be in 23andMe file format.
@sanmai
sanmai / proxy.conf
Last active July 22, 2022 10:58
Proxy GET requests to arbitrary hosts with nginx and secure_link
#$ URI=www.google.com/images/errors/robot.png
#$ SECRET=secret
#$ echo -n $URI$SECRET | md5sum
#649465bd9b4c3cf30ed8a24a89dbd203 -
#$ curl -sI http://proxy.example.net/proxy/$(echo -n $URI$SECRET | md5sum | sed 's/[^0-9a-f]//g')/$URI | grep Content-Length:
#Content-Length: 6327
server {
server_name proxy.example.net;
listen [::]:80;
@sanmai
sanmai / UIImage+Scale.h
Last active January 20, 2021 23:23
If you just want an UIImage smaller and don't care about exact sizing, this category is for you. It extends the UIImage class to support scaling. Methods should be pretty self-explanatory.
// Created by Alexey Kopytko in 2013.
// Public domain with no warranty whatsoever.
// Extends the UIImage class to support scaling
@interface UIImage (Scale)
- (UIImage *)imageScaledToQuarter;
- (UIImage *)imageScaledToHalf;
- (UIImage *)imageScaledToScale:(CGFloat)scale;
- (UIImage *)imageScaledToScale:(CGFloat)scale
# add to .profile
set-title () {
# If the length of string stored in variable `PS1_BAK` is zero...
# - See `man test` to know that `-z` means "the length of STRING is zero"
if [[ -z "$PS1_BAK" ]]; then
# Back up your current Bash Prompt String 1 (`PS1`) into a global backup variable `PS1_BAK`
PS1_BAK="$PS1"
fi
@sanmai
sanmai / dumpchain.pl
Last active December 1, 2020 13:14
Dumps the whole certificate chain for a server in purposes of OCSP stapling
#!/usr/bin/perl
use strict;
use warnings;
# install libio-socket-ssl-perl to get this
use IO::Socket::SSL;
my $hostname = shift or die "Usage: $0 www.example.com\n";
IO::Socket::SSL->new(
PeerHost => "$hostname:443",