Skip to content

Instantly share code, notes, and snippets.

View sponomarev's full-sized avatar
🔴
Offline

Sergey Ponomarev sponomarev

🔴
Offline
View GitHub Profile
@sponomarev
sponomarev / ddos.sh
Created September 15, 2014 07:13
Usefull commands when you are under ddos
# Позволяет получить общую картину: распределение уникальных IP, с которых идут запросы, кол-во запросов с одного IP и т.д.
tail -f /var/log/nginx/nginx.access.log | cut -d ' ' -f 1 | logtop
# Покажет распределение какой-либо строки по IP в логе.
grep "&key=" /var/log/nginx/nginx.access.log | cut -d ' ' -f 1 | sort | uniq -c | sort -n | tail -n 30
# С какого ip сколько запросов
netstat -ntu | awk '{print $5}'| cut -d: -f1 | sort | uniq -c | sort -nr | more
@sponomarev
sponomarev / convert.sh
Created October 17, 2014 09:22
convert any source video to fixed size flv with coloured letterboxes
# params: $input, $output, $width, $height, $color
# for landscape (normal) orientation
ffmpeg -y -i $input -vcodec flv1 -vf "scale=iw*min($width/iw\,$height/ih):ih*min($width/iw\,$height/ih), pad=$width:$height:($width-iw*min($width/iw\,$height/ih))/2:($height-ih*min($width/iw\,$height/ih))/2:color=$color" -vb 4000k -acodec mp3 -ar 44100 -ab 320k -vsync 1 -async 1 $output
# for portrait orientation
ffmpeg -y -i $input -vcodec flv1 -vf "transpose=1, scale=iw*min($width/iw\,$height/ih):ih*min($width/iw\,$height/ih), pad=$width:$height:($width-iw*min($width/iw\,$height/ih))/2:($height-ih*min($width/iw\,$height/ih))/2:color=$color" -vb 4000k -acodec mp3 -ar 44100 -ab 320k -vsync 1 -async 1 $output
@sponomarev
sponomarev / documents.rb
Last active August 29, 2015 14:17 — forked from dhh/documents.rb
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
### Keybase proof
I hereby claim:
* I am sponomarev on github.
* I am bufo_alvarius (https://keybase.io/bufo_alvarius) on keybase.
* I have a public key ASAOXoZrbrgw1juODSiV0ro3I2sZftnZbFg3FCJmPyChBQo
To claim this, I am signing this object:
@sponomarev
sponomarev / rinkeby.txt
Last active August 16, 2017 08:19
My Rinkeby testnet address
0x6aCD39459093E3d0D44e70878c52EE2ab047F5ba
@sponomarev
sponomarev / lock_monitor.sql
Created November 24, 2017 16:20
PG Lock monitor
CREATE VIEW lock_monitor AS
(SELECT COALESCE(blockingl.relation::regclass::text,blockingl.locktype) AS locked_item, now() - blockeda.query_start AS waiting_duration, blockeda.pid AS blocked_pid, blockeda.query AS blocked_query, blockedl.mode AS blocked_mode, blockinga.pid AS blocking_pid, blockinga.query AS blocking_query, blockingl.mode AS blocking_mode
FROM pg_catalog.pg_locks blockedl
JOIN pg_stat_activity blockeda ON blockedl.pid = blockeda.pid
JOIN pg_catalog.pg_locks blockingl ON( ((blockingl.transactionid=blockedl.transactionid)
OR (blockingl.relation=blockedl.relation
AND blockingl.locktype=blockedl.locktype) )
AND blockedl.pid != blockingl.pid)
JOIN pg_stat_activity blockinga ON blockingl.pid = blockinga.pid
AND blockinga.datid = blockeda.datid
1password
adobe-acrobat-reader
atom
blockblock
coconutbattery
cyberduck
daisydisk
dashlane
deluge
docker
@sponomarev
sponomarev / alias_matchers.md
Created July 10, 2018 13:38 — forked from JunichiIto/alias_matchers.md
List of alias matchers in RSpec 3

This list is based on aliases_spec.rb.

You can see also Module: RSpec::Matchers API.

matcher aliased to description
a_truthy_value be_truthy a truthy value
a_falsey_value be_falsey a falsey value
be_falsy be_falsey be falsy
a_falsy_value be_falsey a falsy value
#!/usr/bin/env ruby
require 'time'
start = Time.now
ARGF.read.each_line do |line|
now = Time.now
prev ||= now
$stdout.puts "#{now.iso8601} #{ now - start }s #{ now - prev }s #{line}"
@sponomarev
sponomarev / main.go
Created September 24, 2018 03:10
Golang context to cancel HTTP request and response
package main
import (
"context"
"fmt"
"io"
"log"
"net/http"
"time"
)