Skip to content

Instantly share code, notes, and snippets.

@machuu
machuu / WSL2_VPN_Workaround_Instructions.md
Last active June 24, 2024 16:36
Workaround for WSL2 network broken on VPN

Overview

Internet connection and DNS routing are broken from WSL2 instances, when some VPNs are active.

The root cause seems to be that WSL2 and the VPN use the same IP address block, and the VPN routing clobbers WSL2's network routing.

This problem is tracked in multiple microsoft/WSL issues including, but not limited to:

@BrandonIrizarry
BrandonIrizarry / .Xresources
Created December 31, 2020 16:51
A minimal but useful Xterm configuration file.
! Make communicating with other applications via the clipboard easy
xterm*selectToClipboard: true
! Important - if you leave out 'renderFont', 'faceName' and such won't work. See:
! https://superuser.com/questions/463414/how-to-get-truetype-fonts-to-display-in-xterm-from-a-xresources-file/575108#575108
xterm*renderFont: true
xterm*faceName: monospace
xterm*faceSize: 20
! Some sample configuration settings, to test whether xterm was
Readme: In the following pseudo code, [] indicates a subroutine.
Sometimes I choose to write the subroutine inline under the [] in order to maintain context.
One important fact about the way rollbacks are handled here is that we are storing state for every frame.
In any real implementation you only need to store one game state at a time. Storing a game
state for every frame allows us to only rollback to the first frame where the predicted inputs don't match the true ones.
==Constants==
MAX_ROLLBACK_FRAMES := Any Positive Integer # Specifies the maximum number of frames that can be resimulated
FRAME_ADVANTAGE_LIMIT := Any Positive Integer # Specifies the number of frames the local client can progress ahead of the remote client before time synchronizing.
@PasanBhanu
PasanBhanu / CheckNetwork.java
Last active July 25, 2023 13:28
Check Internet Connection in Android (API Level 29) Using Network Callback
/*
You need to call the below method once. It register the callback and fire it when there is a change in network state.
Here I used a Global Static Variable, So I can use it to access the network state in anyware of the application.
*/
// You need to pass the context when creating the class
public CheckNetwork(Context context) {
this.context = context;
}
@brendano
brendano / log_logistic.py.md
Last active March 8, 2020 14:12
numerically stable implementation of the log-logistic function

Binary case

This is just the middle section of Bob Carpenter's note for evaluating log-loss via the binary logistic functoin https://lingpipe-blog.com/2012/02/16/howprevent-overflow-underflow-logistic-regression/

The logp function calculates the negative cross-entropy:

    dotproduct( [y, 1-y],  [logP(y=1), logP(y=0)] )

where the input s is the beta'x log-odds scalar value. The trick is to make this numerically stable for any choice of s and y.

@Pulimet
Pulimet / AdbCommands
Last active June 27, 2024 12:24
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
@stkent
stkent / android-bluetooth-low-energy-resources.md
Last active February 8, 2024 16:22
Android Bluetooth Low Energy (BLE) Resources
@danielrmeyer
danielrmeyer / configure.sh
Created July 31, 2017 18:07
build emacs in your home dir on minimal server without X and stuff
make
./configure --prefix=/home/<yourhome>/ --with-x-toolkit=no --with-xpm=no --with-jpeg=no --with-png=no --with-gif=no --with-tiff=no
make install
@dolaameng
dolaameng / variable_rnn_torch.py
Last active December 31, 2021 05:19
Variable Length Sequence for RNN in pytorch Example
import torch
import torch.nn as nn
from torch.autograd import Variable
batch_size = 3
max_length = 3
hidden_size = 2
n_layers =1
# container
const int MAXN = 100005, MAXC = 26;
struct aho_corasick{
int trie[MAXN][MAXC], piv; // trie
int fail[MAXN]; // failure link
int term[MAXN]; // output check
void init(vector<string> &v){
memset(trie, 0, sizeof(trie));
memset(fail, 0, sizeof(fail));
memset(term, 0, sizeof(term));