Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Wasin Thonkaew haxpor

🎯
Focusing
View GitHub Profile
View wsl2_ciscoanyconnect_workaround.md

WSL 2 Cisco AnyConnect Networking Workaround

Overview

WSL 2 uses a Hyper-V Virtual Network adapter. Network connectivity works without any issue when a VPN is not in use. However when a Cisco AnyConnect VPN session is established Firewall Rules and Routes are added which breaks connectivity within the WSL 2 VM. This issue is tracked WSL/issues/4277

Below outline steps to automatically configure the Interface metric on VPN connect and update DNS settings (/etc/resolv.conf) on connect/disconnect.

Manual Configuration

Set Interface Metrics

@alexandreelise
alexandreelise / install-gcc-9.sh
Created Mar 7, 2020
Install gcc 9 on Ubuntu LTS 12.04,14.04,16.04 and 18.04
View install-gcc-9.sh
#!/usr/bin/env sh
sudo apt-get update -y && \
sudo apt-get upgrade -y && \
sudo apt-get dist-upgrade -y && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt-get update -y && \
sudo apt-get install gcc-9 g++-9 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9 && \
@tuxutku
tuxutku / opencl-amd_aur_ubuntu
Last active Aug 25, 2021
bash implementation of opencl-amd AUR package, Install opencl amdgpu amdgpu-pro opencl only. Supports ubuntu and others with standard prefix
View opencl-amd_aur_ubuntu
#!/bin/bash
#To get up-to-date variables from aur, run this script with a random option (Ex: ./opencl-amd_aur_ubuntu.txt asdaf)
if [ "$1" = "$a" ]
then
prefix='amdgpu-pro-'
postfix='-ubuntu-20.04'
major='21.10'
minor='1247438'
amdver='2.4.100'
@beatfactor
beatfactor / install_nginx_macos_source.md
Last active Sep 17, 2021
Install Nginx on Mac OS from source (without brew)
View install_nginx_macos_source.md

Install Nginx on Mac OS from source

no Homebrew required

1. Download Nginx

$ cd /usr/local/src
$ curl -OL http://nginx.org/download/nginx-1.12.2.tar.gz
$ tar -xvzf nginx-1.12.2.tar.gz && rm nginx-1.12.2.tar.gz
@aldemirenes
aldemirenes / android_build_run.sh
Last active Aug 28, 2021
Shell scripts for Android development without needing to use Android Studio
View android_build_run.sh
#!/bin/sh
package_name=$1
./gradlew assembleDebug
adb -d install -r app/build/outputs/apk/app-debug.apk
adb shell monkey -p "$package_name" -c android.intent.category.LAUNCHER 1
./logcat.sh "$package_name"
@dentechy
dentechy / WSL-ssh-server.md
Last active Aug 28, 2021
A step by step tutorial on how to automatically start ssh server on boot on the Windows Subsystem for Linux
View WSL-ssh-server.md

How to automatically start ssh server on boot on Windows Subsystem for Linux

Microsoft partnered with Canonical to create Bash on Ubuntu on Windows, running through a technology called the Windows Subsystem for Linux. Below are instructions on how to set up the ssh server to run automatically at boot.

  1. Edit the /etc/ssh/sshd_config file by running the command sudo vi /etc/ssh/sshd_config and do the following
    1. Change Port to 2222 (or any other port above 1000)
    2. Change PasswordAuthentication to yes. This can be changed back to no if ssh keys are setup.
  2. Restart the ssh server:
    • sudo service ssh --full-restart
  3. With this setup, the ssh server must be turned on every time you run Bash on Ubuntu on Windows, as by default it is off. Use this command to turn it on:
@cmoulton
cmoulton / URLSession Calls in Swift 4
Last active Aug 27, 2021
URLSession Calls in Swift 4
View URLSession Calls in Swift 4
func makeGetCall() {
// Set up the URL request
let todoEndpoint: String = "https://jsonplaceholder.typicode.com/todos/1"
guard let url = URL(string: todoEndpoint) else {
print("Error: cannot create URL")
return
}
let urlRequest = URLRequest(url: url)
// set up the session
@alistairewj
alistairewj / install-postgres-10-ubuntu.md
Last active Aug 26, 2021
Install PostgreSQL 10 on Ubuntu
View install-postgres-10-ubuntu.md

Install PostgreSQL 10 on Ubuntu

This is a quick guide to install PostgreSQL 10 - tested on Ubuntu 16.04 but likely can be used for Ubuntu 14.04 and 17.04 as well, with one minor modification detailed below.

(Optional) Uninstall other versions of postgres

To make life simple, remove all other versions of Postgres. Obviously not required, but again, makes life simple. If you have data in your previous version of postgres that you'd like to retain, then this is not recommended. Instead, you'll have to use pg_upgrade or pg_upgradecluster.

@jackc
jackc / results.txt
Created Jul 21, 2017
github.com/jackc/go_db_bench results
View results.txt
$ PGHOST=/var/run/postgresql go test -bench . -benchmem
BenchmarkPgxNativeSelectSingleShortString-8 100000 17873 ns/op 292 B/op 6 allocs/op
BenchmarkPgxStdlibSelectSingleShortString-8 100000 20602 ns/op 907 B/op 24 allocs/op
BenchmarkPgSelectSingleShortString-8 100000 17451 ns/op 120 B/op 8 allocs/op
BenchmarkPqSelectSingleShortString-8 100000 22604 ns/op 832 B/op 25 allocs/op
BenchmarkRawSelectSingleShortValue-8 100000 15735 ns/op 6 B/op 0 allocs/op
BenchmarkPgxNativeSelectSingleShortBytes-8 100000 17808 ns/op 314 B/op 7 allocs/op
BenchmarkPgxStdlibSelectSingleShortBytes-8 100000 20891 ns/op 933 B/op 25 allocs/op
BenchmarkPqSelectSingleShortBytes-8 50000 22005 ns/op 856 B/op 26 allocs/op
BenchmarkPgxNativeSelectSingleRow-8 100000 21577 ns/op 478 B/
@kharrison
kharrison / SwiftIntegerGuide.swift
Created Feb 17, 2017
Swift Integer Quick Guide
View SwiftIntegerGuide.swift
// -------------------------------------
// Swift Integer Quick Guide
// -------------------------------------
// Created by Keith Harrison http://useyourloaf.com
// Copyright (c) 2017 Keith Harrison. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//