Skip to content

Instantly share code, notes, and snippets.

View peti2001's full-sized avatar

Peter Karakas peti2001

  • CodersRank
  • Debrecen, Hungary
View GitHub Profile
@peti2001
peti2001 / context-in-go.go
Created July 3, 2020 08:52
Some example how to use context in Go
package main
import (
"context"
"log"
"sync"
"time"
)
type abTestVariant struct{}
// Given a bson MongoDB query
q := bson.M{
"$match": bson.M{
"skill": bson.M{
"$regex": "^cookie",
"$options": "-i",
},
},
}
// The following script will convert it into JSON
@peti2001
peti2001 / find_wrong_character.sh
Created December 3, 2019 20:13
Solution for: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 35: ordinal not in range(128)
grep -r -P '[^\x00-\x7f]' /etc/apache2 /etc/letsencrypt /etc/nginx
@peti2001
peti2001 / how-to-use-wget.sh
Last active June 29, 2019 14:10
How to use wget to save a page to your disk recursively
# Auth is required
wget --no-cookies --header "Cookie: XSRF-TOKEN=token; laravel_session=session" --recursive --no-clobber --page-requisites --html-extension --convert-links --domains example.com --no-parent --reject-regex=example.com/logout http://example.com
# No auth
wget --no-cookies --no-clobber --page-requisites --html-extension --convert-links --domains example.com --no-parent http://example.com/
@peti2001
peti2001 / create_repository.json
Last active March 31, 2019 15:53
Create repository in ElasticSearch backed up with Google Cloud Storage
PUT _snapshot/backup1
{
"type": "gcs",
"settings": {
"bucket": "codersrank",
"base_path": "backup"
}
}