Skip to content

Instantly share code, notes, and snippets.

View 0xc0d's full-sized avatar

Ali Josie 0xc0d

View GitHub Profile
@0xc0d
0xc0d / poolBench_test.go
Created October 24, 2020 17:29
Benchmark: sync.Pool vs simple allocation
func BenchmarkPool(b *testing.B) {
var p sync.Pool
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
p.Put(1)
p.Get()
}
})
}
@0xc0d
0xc0d / poolExample.go
Last active October 25, 2020 01:20
sync.Pool example
// A dummy struct
type Person struct {
Name string
}
// Initializing pool
var personPool = sync.Pool{
// New optionally specifies a function to generate
// a value when Get would otherwise return nil.
New: func() interface{} { return new(Person) },
@0xc0d
0xc0d / disable-gnome-tracker.sh
Created April 26, 2020 19:58
GNOME's tracker is a CPU and privacy hog.
#!/usr/bin/bash
echo -e "\nHidden=true\n" | sudo tee --append /etc/xdg/autostart/tracker-extract.desktop /etc/xdg/autostart/tracker-miner-apps.desktop /etc/xdg/autostart/tracker-miner-fs.desktop /etc/xdg/autostart/tracker-miner-user-guides.desktop /etc/xdg/autostart/tracker-store.desktop > /dev/null
gsettings set org.freedesktop.Tracker.Miner.Files crawling-interval -2 # Default: -1
gsettings set org.freedesktop.Tracker.Miner.Files enable-monitors false # Default: true
tracker reset --hard
@0xc0d
0xc0d / wordpress-api-media-upload.py
Created April 26, 2020 19:55
upload files using wordpress api and pplication-passwords plugin
#!/usr/bin/env python3
import requests
import json
import base64
user = 'USERNAME'
token = 'WWWW WWWW WWWW WWWW WWWW WWWW' # auth. token from application-passwords plugin
apiVer = 'v2'
@0xc0d
0xc0d / elastic_should.py
Created April 8, 2019 09:21
implementation of Elasticsearch should query in Python 3
def should(sample, conditions, min_should):
return True if len([item for item in conditions if item in sample]) >= min_should else False