Skip to content

Instantly share code, notes, and snippets.

@willurd
willurd / web-servers.md
Last active April 28, 2024 21:38
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
// http://docs.groovy-lang.org/latest/html/documentation/grape.html
// http://mvnrepository.com/artifact/org.codehaus.groovy.modules.http-builder/http-builder/0.7.1
groovy.grape.Grape.grab(group:'org.codehaus.groovy.modules.http-builder', module:'http-builder', version:'0.7.1')
import groovyx.net.http.HTTPBuilder
@taoyuan
taoyuan / npm-using-https-for-git.sh
Last active April 27, 2024 01:22
Force git to use https:// instead of git://
# npm using https for git
git config --global url."https://github.com/".insteadOf git@github.com:
git config --global url."https://".insteadOf git://
# npm using git for https
git config --global url."git@github.com:".insteadOf https://github.com/
git config --global url."git://".insteadOf https://
@zapstar
zapstar / openssl_2way_auth.sh
Last active March 20, 2024 21:07
Steps to create CA, server and client keys + certificates for SSL 2-way authentication
# Move to root directory...
cd /
mkdir keys
cd keys
# Generate a self signed certificate for the CA along with a key.
mkdir -p ca/private
chmod 700 ca/private
# NOTE: I'm using -nodes, this means that once anybody gets
# their hands on this particular key, they can become this CA.
@lummie
lummie / enum.go
Last active May 2, 2024 13:13
Golang Enum pattern that can be serialized to json
package enum_example
import (
"bytes"
"encoding/json"
)
// TaskState represents the state of task, moving through Created, Running then Finished or Errorred
type TaskState int
@meirbon
meirbon / Dell XPS 15 9560 Manjaro Setup instructions
Last active March 31, 2024 01:21
Small, quick guide to set up Manjaro on the XPS 15 9560
# 1. First of all of course get Manjaro:
https://manjaro.org/get-manjaro/
# I recommend using Etcher to copy the image to your USB:
https://etcher.io/
# 2. Before installing make sure:
# - Secure boot is disabled in BIOS
# - Your SSD, HDD or NVME drive is set to AHCI instead of RAID
# - Fastboot should be on Auto or minimal, but this shouldn't matter to much
@myniva
myniva / printTaskInputs.gradle
Last active August 8, 2023 11:22
Prints all inputs of the various tasks of a Gradle project
task printTaskInputs {
doLast {
project.getTasks().each { task ->
println "--------------------------------------------------------------------------------"
println " Task '${project.name}:${task.name}'"
println "--------------------------------------------------------------------------------"
println ""
println "File inputs:"
task.inputs.files.each {
@t27
t27 / linux-oom-killer-fixes.md
Last active April 23, 2024 22:07
Dealing with the Linux OOM Killer

Dealing with the Linux OOM Killer at the program level

Do this in cases when you dont want to change the os-level settings, but only want to disable the OOM killer for a single process. This is useful when youre on a shared machine/server.

The OOM killer uses the process level metric called oom_score_adj to decide if/when to kill a process. This file is present in /proc/$pid/oom_score_adj. The oom_score_adj can vary from -1000 to 1000, by default it is 0.

You can add a large negative score to this file to reduce the probability of your process getting picked and terminated by OOM killer. When you set it to -1000, it can use 100% memory and still avoid getting terminated by OOM killer.