Skip to content

Instantly share code, notes, and snippets.

Ivan sitano

Block or report user

Report or block sitano

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sitano
sitano / for_keys_go_issue2.go
Created Mar 15, 2018
env GOSSAFUNC=keys go build for_keys_go_issue2.go
View for_keys_go_issue2.go
package main
import "fmt"
type S struct {
b [8]byte
}
func keys(m map[S]struct{}) [][]byte {
var z [][]byte
View for_key_issues1.go
package main
import "fmt"
type S struct {
b [8]byte
}
func main() {
mmap := map[S]struct{}{
@sitano
sitano / overthewire_wargames_behemoth.md
Created Mar 13, 2018
overthewire_wargames_behemoth
View overthewire_wargames_behemoth.md

Level 0

ssh behemoth0@behemoth.labs.overthewire.org -p 2221

password: eatmyshorts flag: aesebootiv hint: password is protected by the xor func memfrob from <string.h>

memfrob - frobnicate (encrypt) a memory area

@sitano
sitano / realloc.c
Last active Nov 5, 2017
undefined behavior with realloc
View realloc.c
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int* p = (int *)malloc(sizeof(int));
int* q = (int *)realloc(p, sizeof(int));
*p = 1;
*q = 2;
if (p == q)
@sitano
sitano / brackets_split.go
Created Oct 19, 2017
parallel brackets sequence verification
View brackets_split.go
package main
import "fmt"
type res struct {
s []byte
l int
r int
}
@sitano
sitano / rds-pgsql-replica-lag.md
Last active Jun 8, 2017
how to measure amazon rds postgresql replica lag
View rds-pgsql-replica-lag.md

What to do when replica creation fails stopping streaming, trying to recover WAL from the archive

Calculate XLOG entries distance between master and replica with:

on master:

> select pg_xlogfile_name(pg_current_xlog_flush_location()), pg_current_xlog_insert_location(), pg_current_xlog_location();

on slave:

@sitano
sitano / read-only.sql
Created Jun 8, 2017
PostgreSQL create read only user
View read-only.sql
-- Create a group
CREATE ROLE readonly WITH LOGIN;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readonly;
@sitano
sitano / xms-http-test.go
Created Jan 16, 2017
Test web server written in go
View xms-http-test.go
package main
import (
"flag"
"log"
"math/rand"
"net/http"
"time"
)
@sitano
sitano / 500ms-fetcher.go
Last active Jan 18, 2017
Parallel fetcher with time limit constraints example, go
View 500ms-fetcher.go
// Ivan Prisyazhnyy <john.koepi@gmail.com>, 2017
//
// Ambiguities:
// - "URL syntax correctness" is not explicitly defined. Should, I
// interpret it, like it has to match rfc1738/rfc3986? I will go
// with the simplest solution - URL is valid if parsed by util.URL.
// - Various behaviors for edge cases (i.e. meeting bad data, unstable
// network, too much data) are not well defined. If external service
// returns 4/5xx code, it could be retried and etc.
// - Answering always within 500 milliseconds - this is the biggest
@sitano
sitano / nginx.upstreams.lua
Last active Mar 20, 2017
openresty check upstreams status example
View nginx.upstreams.lua
location = /status {
default_type text/plain;
content_by_lua '
local ok, upstream = pcall(require, "ngx.upstream")
if not ok then
error("ngx_upstream_lua module required")
end
local get_primary_peers = upstream.get_primary_peers
You can’t perform that action at this time.