Skip to content

Instantly share code, notes, and snippets.

@Skarlso
Skarlso / main.go
Created February 16, 2019 21:31
Golang SSH connection with hostkey verification
package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"golang.org/x/crypto/ssh"
kh "golang.org/x/crypto/ssh/knownhosts"
@extremecoders-re
extremecoders-re / vmware-no-vmem.md
Last active April 6, 2024 08:09
Boost VMWare Performance by disabling vmem files.

Prevent creation of vmmem files in VMware (Windows)

Issue

VMWare creates .vmem files to back the guest RAM. On the host this causes disk thrashing especially during powering on and off the guest.

Solution

Add the following lines to the .vmx file to prevent creation of .vmem files. This will reduce disk IO and VM performance will improve especially on non-SSD disks.

@researcx
researcx / config_audio.md
Last active February 16, 2024 17:36
Linux System-wide Audio Tuning [24bit 192 kHz HD Audio + A=432 Hz Tuning + Equalizer]

24bit 192 kHz HD Audio + A=432 Hz Tuning + Equalizer

High-quality sampling

ALSA

echo 'defaults.pcm.rate_converter "speexrate_best"' | tee -a .asoundrc
sudo alsactl restore

PulseAudio

sudo echo 'default-sample-format = s24le' | sudo tee -a /etc/pulse/daemon.conf
sudo echo 'default-sample-rate = 192000' | sudo tee -a /etc/pulse/daemon.conf
@swankjesse
swankjesse / MoshiKotlinExample.kt
Created May 14, 2017 17:15
Demo how to use Moshi with Kotlin
import com.squareup.moshi.Json
import com.squareup.moshi.KotlinJsonAdapterFactory
import com.squareup.moshi.Moshi
import com.squareup.moshi.Rfc3339DateJsonAdapter
import java.util.Date
val json = """
{
"url": "https://api.github.com/repos/square/okio/issues/156",
"id": 91393390,
@rodaine
rodaine / fast.go
Last active October 11, 2018 19:06
Code snippets for my blog post "The X-Files: Controlling Throughput with rate.Limiter" (http://rodaine.com/2017/05/x-files-time-rate-golang/)
// RateLimit middleware limits the throughput to h using TickerLimiter
// configured with the provided rps and burst. The request will idle
// for the passed in wait before cancelling if there is a queue.
func RateLimit(rps, burst int, wait time.Duration, h http.HandlerFunc) http.HandlerFunc {
l, _ := TickerLimiter(rps, burst)
return func(w http.ResponseWriter, r *http.Request) {
t := time.NewTimer(wait)
select {
case <-l:
@erikvip
erikvip / reset-display.md
Last active March 3, 2024 19:37
Reinstall default graphics driver on Ubuntu

Remove installed nvidia driver & reset to default graphics driver

On Ubuntu 15.10, after installing the nvidia proprietary driver, it didn't quite work as expected...going down to older version made it work, but graphics were slow. Run the below to reset back to the original graphics setup.

sudo apt-get purge nvidia-*
sudo apt-get install --reinstall xserver-xorg-video-intel libgl1-mesa-glx libgl1-mesa-dri xserver-xorg-core
sudo dpkg-reconfigure xserver-xorg

# May not have any alternatives configured (ok to skip)

sudo update-alternatives --remove gl_conf /usr/lib/nvidia-current/ld.so.conf

@iamralch
iamralch / compress.go
Last active April 16, 2023 03:04
ZIP archives in Golang
import (
"archive/zip"
"io"
"os"
"path/filepath"
"strings"
)
func zipit(source, target string) error {
zipfile, err := os.Create(target)
@husobee
husobee / scanval.go
Last active December 16, 2022 18:44
scanner valuer example
package main
import (
"database/sql"
"database/sql/driver"
"errors"
"fmt"
_ "github.com/mattn/go-sqlite3"
)
@josdirksen
josdirksen / server.go
Created February 20, 2015 12:28
Simple HTTP Server in Go using mongoDB and channels
package main
import (
"encoding/json"
"fmt"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"io"
"math/rand"
"net/http"
@denji
denji / golang-tls.md
Last active July 1, 2024 05:41 — forked from spikebike/client.go
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)