Skip to content

Instantly share code, notes, and snippets.

View perguth's full-sized avatar
🎈

Per Guth perguth

🎈
View GitHub Profile
@zOrg1331
zOrg1331 / wireguard_layer2.md
Last active April 19, 2025 16:23
wireguard, wireguard layer 2, wireguard over TCP

Intro

This note describes how to connect two networks/devices/VMs over public network using Wireguard with Layer 2 support (ARP, IPv6 link-local, etc).

This can also be achieved using SSH and its "tap" tunnel, however, it does not provide the same level of latency and bandwidth as full-blown VPN such as Wireguard.

In addition, this note describes how to tunnel Wireguard over TCP connection. This may be of use if you encounter firewall in-between so, for instance, you can use TCP port 443 only.

Objective

@tdegrunt
tdegrunt / keyboardLayout.json
Last active January 27, 2025 01:36
Visual Studio Code (vscode/code) Colemak keyboard layout
{
"layout": {
"id": "com.apple.keylayout.Colemak",
"localizedName": "Colemak",
"lang": "en"
},
"rawMapping": {
"KeyA": {
"value": "a",
"valueIsDeadKey": false,
@cosbgn
cosbgn / Find if your user is in the EU (Geolocation api javascript)
Created November 11, 2019 11:56
Find if user is in the EU without any extra API or server-side code or IP Address
// You can easily find out if the user is in the EU calculating the offset from GMT.
// It's not a perfect method but for simple use cases it works perfectly
// It also catches all Africa
const offset = new Date().getTimezoneOffset();
// 0 is GMT and - 120 is Finland -
// It should catch all the EU - However it also catches most of Africa so use it carefully!
@perguth
perguth / computer
Last active July 23, 2019 14:01
Sleep host when Mosh is idle. Wake up on reconnect.
#!/bin/sh
wake-computer
echo 🚀 Connecting Mosh.
mosh [email protected]
@drwpow
drwpow / smooth-scrolling.js
Last active November 2, 2024 03:53
Performant, 60FPS smooth scrolling in Vanilla JavaScript using requestAnimationFrame
/**
* @param {number} yPos Pixels from the top of the screen to scroll to
* @param {number} duration Time of animation in milliseconds
*/
const scrollTo = (yPos, duration = 600) => {
const startY = window.scrollY;
const difference = yPos - startY;
const startTime = performance.now();
const step = () => {
@jan-warchol
jan-warchol / sync-history.sh
Last active January 3, 2025 14:37
Synchronize history across bash sessions
# Synchronize history between bash sessions
#
# Make history from other terminals available to the current one. However,
# don't mix all histories together - make sure that *all* commands from the
# current session are on top of its history, so that pressing up arrow will
# give you most recent command from this session, not from any session.
#
# Since history is saved on each prompt, this additionally protects it from
# terminal crashes.
var hypercore = require('hypercore')
var ram = require('random-access-memory')
var feed = hypercore(ram)
feed.append('hello world')
@mattiaslundberg
mattiaslundberg / Ansible Let's Encrypt Nginx setup
Last active January 30, 2025 19:01
Let's Encrypt Nginx setup with Ansible
Ansible playbook to setup HTTPS using Let's encrypt on nginx.
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS.
The server pass A rating on [SSL Labs](https://www.ssllabs.com/).
To use:
1. Install [Ansible](https://www.ansible.com/)
2. Setup an Ubuntu 16.04 server accessible over ssh
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder)
@bgromov
bgromov / git-reset-author.sh
Created June 23, 2016 17:50
Git: reset author for ALL commits
#!/bin/sh
# Credits: http://stackoverflow.com/a/750191
git filter-branch -f --env-filter "
GIT_AUTHOR_NAME='Newname'
GIT_AUTHOR_EMAIL='new@email'
GIT_COMMITTER_NAME='Newname'
GIT_COMMITTER_EMAIL='new@email'
" HEAD
@ldong
ldong / download_egghead_videos.md
Last active December 7, 2023 16:16
download egghead videos

Download videos from egghead

Go to the egghead website, i.e. Building a React.js App

run

$.each($('h4 a'), function(index, video){
  console.log(video.href);
});