Skip to content

Instantly share code, notes, and snippets.

rogerwalt / gist:7300568
Created Nov 4, 2013
Windows PowerShell: Create Profile and add Alias to Notepad++ to it.
View gist:7300568
# create profile
New-Item -path $profile -type file -force
# open it with notepad
notepad $profile
# add alias to notepad++ to it
Set-Alias npp "C:\Program Files (x86)\Notepad++\notepad++.exe"
View promise.js
const fileNames = ['one.js', 'two.scss', 'three.scss'];
const getAllFileNames = () => new Promise((resolve, reject) => { resolve(fileNames) })
const filterScssFiles = (fileNames) => new Promise((resolve, reject) => resolve(fileNames.filter(fileName => fileName.endsWith('.scss'))))
getAllFileNames().then(fileNames => filterScssFiles(fileNames))
.then(scssFileNames => console.log(scssFileNames))
.catch(err => console.error(err))
rogerwalt /
Last active Oct 3, 2018
Cleans stale git branches (removed on remote and merged local branches)
git remote prune origin
git branch --merged | egrep -v "(^\*|master|dev)" | xargs -r git branch -d
View gist:184f5a1cfc00556ff48498d1b996304b
(´ ͡༎ຶ ͜ʖ ͡༎ຶ )
(╯°□°)╯︵ ┻━┻
  \\ my
   \( ͡° ͜ʖ ͡°)
    > ⌒ヽ
   /   へ\
   /  / \\last
View gist:96fccfc67eeaa8c7883d3984e7870cd8
Workaround from snabb,
My current workaround is to do the following tricks every time I start my workplace VPN:
1. Find out the link number (a.k.a. interface index) of the ISP interface: systemd-resolve --status or ip l.
2. Connect the VPN.
3. Remove DNS settings from the ISP interface (using the link number from step 1) by sending a D-Bus command to systemd-resolved. This is an example using link number 2: sudo busctl call org.freedesktop.resolve1 /org/freedesktop/resolve1 org.freedesktop.resolve1.Manager SetLinkDNS 'ia(iay)' 2 0
4. Inspect with systemd-resolve --status to ensure that only the correct DNS servers are there.
Apparently there isn't any simple cli tool for managing systemd-resolved's settings. That busctl command isn't very user-friendly. :)
rogerwalt /
Created Apr 12, 2018
jspm debug output!
NODE_DEBUG=cluster,net,http,fs,tls,module,timers jspm install
rogerwalt / promise.test.js
Last active Feb 6, 2018
How to jest promises
View promise.test.js
* example how to test promises using jest.
function getPromise() {
return new Promise(function (success, reject) {
setTimeout(function() {
success('job is done');
}, 200);
rogerwalt /
Created Jan 30, 2017
Interactive rebase merge

on branch feature_interview:

  • $ git checkout develop
  • $ git pull
  • $ git checkout feature_interview
  • $ git checkout -b pr_feature_interview
  • $ git rebase -i develop squash all commits, remain one pick
  • $ git commit --ammend (or use git-cola) to change last commit message
  • $ git push origin and create pull request
View gist:749e7663e840eadb638777c052ac488e
# Generate a CA key and certificate with SHA1 digest
openssl genrsa 2048 > ca-key.pem
openssl req -sha1 -new -x509 -nodes -days 3650 -key ca-key.pem > ca-cert.pem
# Create server key and certficate with SHA1 digest, sign it and convert
# the RSA key from PKCS #8 (OpenSSL 1.0 and newer) to the old PKCS #1 format
openssl req -sha1 -newkey rsa:2048 -days 730 -nodes -keyout server-key.pem > server-req.pem
openssl x509 -sha1 -req -in server-req.pem -days 730 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pem
openssl rsa -in server-key.pem -out server-key.pem
rogerwalt / gist:76ddf7057af2ed97580b383e3b66d82c
Created Jul 14, 2016
create a self-signed ssl certificate
View gist:76ddf7057af2ed97580b383e3b66d82c
# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;