Skip to content

Instantly share code, notes, and snippets.

View dlsniper's full-sized avatar

Florin Pățan dlsniper

View GitHub Profile
@dlsniper
dlsniper / main.go
Created March 29, 2015 11:19
HTTPS server in go using COMODO Wildcard SSL certificate (exported as nginx bundle)
package main
import (
"crypto/rand"
"crypto/tls"
"crypto/x509"
"io/ioutil"
"log"
mr "math/rand"
"net/http"
@dlsniper
dlsniper / wrapper.go
Created September 18, 2016 20:45
Dependency injection in Go via wrapping the function
package main
import "log"
type printerFunc func(message string, args ...interface{})
func helloWrapper(p printerFunc) func(string, ...interface{}) {
return func(message string, arguments ...interface{}) {
p(message, arguments...)
}
@dlsniper
dlsniper / cross-compile-go.bash
Created October 13, 2017 21:45
Cross compile Go for Raspberry Pi 3
cd ~
git clone git@github.com:golang/go.git gotip
cd gotip/src
export GOROOT_BOOTSTRAP=/usr/local/go
env GOOS=linux GOARCH=arm GOARM=7 ./make.bash
@dlsniper
dlsniper / custom.go
Last active June 6, 2023 08:03
Custom logger based on slog
// The code in this file is partially taken from the
// golang.org/x/exp/slog@v0.0.0-20230522175609-2e198f4a06a1
//
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package logger
import (
@dlsniper
dlsniper / make.log
Created May 5, 2022 17:44
/var/lib/dkms/nvidia/470.86/build/make.log
/var/lib/dkms/nvidia/470.86/build/make.log
DKMS make.log for nvidia-470.86 for kernel 5.17.5-76051705-generic (x86_64)
Thu May 5 20:05:59 EEST 2022
make[1]: Entering directory '/usr/src/linux-headers-5.17.5-76051705-generic'
test -e include/generated/autoconf.h -a -e include/config/auto.conf || ( \
echo >&2; \
echo >&2 " ERROR: Kernel configuration is invalid."; \
echo >&2 " include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
@dlsniper
dlsniper / poor horse.json
Created July 19, 2015 21:29
just another attack
{
"remote_addr":"***",
"name":"home",
"status_code":200,
"method":"GET",
"request_uri":"/",
"headers":{
"Cache-Control":[
"no-cache"
],
@dlsniper
dlsniper / tutorial.md
Last active February 28, 2020 07:56
How to build nginx from sources on Ubuntu
export LANGUAGE="en_US.UTF-8" 
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
locale-gen en_US.UTF-8 
dpkg-reconfigure locales

apt-get install unzip libpcre3 libpcre3-dev libssl-dev libpcrecpp0 zlib1g-dev debhelper dh-systemd libgeoip-dev autotools-dev libgd2-noxpm-dev libluajit-5.1-dev libmhash-dev libpam0g-dev libperl-dev po-debconf libexpat-dev libxslt1-dev
@dlsniper
dlsniper / fetchFileWatcher.sh
Created February 12, 2020 07:04
Get the contents of the Linux File Watcher component for JetBrains IDEs
#!/usr/bin/env bash
mkdir ~/jbFileWatcher
cd ~/jbFileWatcher
wget https://raw.githubusercontent.com/JetBrains/intellij-community/master/native/fsNotifier/linux/fsnotifier.h
wget https://raw.githubusercontent.com/JetBrains/intellij-community/master/native/fsNotifier/linux/inotify.c
wget https://raw.githubusercontent.com/JetBrains/intellij-community/master/native/fsNotifier/linux/main.c
wget https://raw.githubusercontent.com/JetBrains/intellij-community/master/native/fsNotifier/linux/make.sh
wget https://raw.githubusercontent.com/JetBrains/intellij-community/master/native/fsNotifier/linux/util.c
@dlsniper
dlsniper / cmd.sh
Last active November 18, 2019 17:47
small repo track all packages
#!/usr/bin/env bash
go get -u smallrepo.com/sml
GOPATH=/path/to/gopath sml track cloud.google.com/go collectd.org dmitri.shuralyov.com/app/changes dmitri.shuralyov.com/html/belt dmitri.shuralyov.com/route/github dmitri.shuralyov.com/scratch dmitri.shuralyov.com/service/change dmitri.shuralyov.com/state dmitri.shuralyov.com/website/gido git.apache.org/thrift.git github.com/AaronO/go-git-http github.com/AlekSi/pointer github.com/AndreasBriese/bbloom github.com/BurntSushi/toml github.com/DataDog/datadog-go github.com/Knetic/govaluate github.com/NYTimes/gziphandler github.com/PuerkitoBio/gocrawl github.com/PuerkitoBio/goquery github.com/PuerkitoBio/purell github.com/PuerkitoBio/urlesc github.com/RoaringBitmap/roaring github.com/Shopify/sarama github.com/TrueFurby/go-callvis github.com/Unknwon/cae github.com/VividCortex/gohistogram github.com/Yawning/chacha20 github.com/adtac/go-akismet github.com/afex/hystrix-go github.com/alcortesm/tgz github.com/alecthomas/chroma github.com/alecthomas/gometalinter github.com/
@dlsniper
dlsniper / go.mod
Created November 4, 2019 06:37
Sample Web App
module github.com/dlsniper/dockerdev
go 1.11
require github.com/jackc/pgx/v4 v4.1.2