Skip to content

Instantly share code, notes, and snippets.

@toryano0820
toryano0820 / wsl2-ubuntu-map-win-localhost.sh
Last active May 11, 2024 03:32
For WSL2: Fixes "Connection Refused" issue when accessing Windows localhost services. Run with "sudo sh wsl2-ubuntu-map-win-localhost.sh" !!! Remember to backup "/etc/hosts" just in case !!!
nameserver=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}') # find nameserver
[ -n "$nameserver" ] || "unable to find nameserver" || exit 1 # exit immediately if nameserver was not found
echo "##### nameserver found: '$nameserver'"
localhost_entry=$(grep -v "127.0.0.1" /etc/hosts | grep "\slocalhost$") # find localhost entry excluding 127.0.0.1
if [ -n "$localhost_entry" ]; then # if localhost entry was found
echo "##### localhost entry found: '$localhost_entry'"
sed -i "s/$localhost_entry/$nameserver localhost/g" /etc/hosts # then update localhost entry with the new $nameserver
else # else if entry was not found
echo "##### localhost entry not found"
echo "$nameserver localhost" >> /etc/hosts # then append $nameserver mapping to localhost
@yiboyang
yiboyang / xclip aliases for startup scripts
Last active May 11, 2024 03:31
A few xclip aliases to simplify copying/pasting
# to simplify life, install xclip and append the following lines to your .bashrc
alias "c=xclip" # copy to X clipboard (register *)
alias "cs=xclip -selection clipboard" # copy to system wide clipboard (register +)
alias "v=xclip -o" # output copied content (paste)
alias "vs=xclip -o -selection clipboard" # paste from system wide clipboard (equivalent to `v -selection clipboard`)
# examples:
# copy to X:
# go to the same directory in terminal 2 as in terminal 1
# Terminal 1:
@Ryonez
Ryonez / (Unofficial) Discord server rules suggestions list.md
Last active May 11, 2024 03:28
(Unofficial) Discord server rules suggestions list

Discord

(Unofficial) Discord server rules suggestions list

Author's Note

I'll start off with letting you know this is a fork from someone else. However, for some bizarre reason, this is the one everyone finds, so I better get round to updating this. Credit to Cristiano#2233 for the original idea.

Also, I've had a lot of people saying the rules are to strict. If you pick all the rules here, you're right, it would be very strict. However the rules below are guidelines! They are there for you to pick the ones you desire, you can ignore ones you don't want. Hopefully they might help with rules you wouldn't have thought of otherwise.

@proudlygeek
proudlygeek / nfs-tunnel.md
Last active May 11, 2024 03:25
Mount NFS Folder via SSH Tunnel

1. Install NFS on Server

Install the required packages (Ubuntu 12.04):

apt-get install nfs-kernel-server portmap

2. Share NFS Folder

Open the exports file:

vim /etc/exports
@sruf
sruf / Country lookup by country code
Last active May 11, 2024 03:24
Country lookup by country code
=IF(ISNA(VLOOKUP(LEFT(A1,8),'Country codes'!A:B,2,FALSE)),
IF(ISNA(VLOOKUP(LEFT(A1,7),'Country codes'!A:B,2,FALSE)),
IF(ISNA(VLOOKUP(LEFT(A1,6),'Country codes'!A:B,2,FALSE)),
IF(ISNA(VLOOKUP(LEFT(A1,5),'Country codes'!A:B,2,FALSE)),
IF(ISNA(VLOOKUP(LEFT(A1,4),'Country codes'!A:B,2,FALSE)),
IF(ISNA(VLOOKUP(LEFT(A1,3),'Country codes'!A:B,2,FALSE)),
IF(ISNA(VLOOKUP(LEFT(A1,2),'Country codes'!A:B,2,FALSE)),,
VLOOKUP(LEFT(A1,2),'Country codes'!A:B,2,FALSE)),
VLOOKUP(LEFT(A1,3),'Country codes'!A:B,2,FALSE)),
VLOOKUP(LEFT(A1,4),'Country codes'!A:B,2,FALSE)),

Optlam.js - 3.4 million IPS

// ~~~~~~~~~~~~~~~~~~~~~~ Optlam.js ~~~~~~~~~~~~~~~~~~~~~~
// An optimal λ-calculus normalizer written in JavaScript.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Optlam.js is a simple, optimal (in Levy's sense) λ-calculus evaluator using
// interaction nets. It is, currently, as far as I know, the fastest
// implementation of functions in the world. It uses Lamping's Abstract
// Algorithm - that is, the so called (and problematic) "oracle" is avoided
@edokeh
edokeh / index.js
Last active May 11, 2024 03:20
佛祖保佑,永无 BUG
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \
@rubenmoya
rubenmoya / middleware.rb
Created April 22, 2019 14:41
Rails middleware to convert request params and response data from camelCase to snake_case
module CaseConverter
class Transformations
class << self
def transform(value)
case value
when Array then value.map { |item| transform(item) }
when Hash then value.deep_transform_keys! { |key| transform(key) }
when String then camelize(value)
else value
end
@Klerith
Klerith / instalaciones-react.md
Last active May 11, 2024 03:19
Instalaciones recomendadas para el curso de React con Sockets
@defulmere
defulmere / settings.py
Last active May 11, 2024 03:18
How to override an old sqlite3 module with pysqlite3 in django settings.py
# ⚠️ USE AT YOUR OWN RISK
# first: pip install pysqlite3-binary
# then in settings.py:
# these three lines swap the stdlib sqlite3 lib with the pysqlite3 package
__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
DATABASES = {