Skip to content

Instantly share code, notes, and snippets.

@ilfuriano
ilfuriano / fix-wsl2-dns-resolution
Created December 22, 2022 10:19 — forked from coltenkrauter/fix-wsl2-dns-resolution
Fix DNS resolution in WSL2
More recent resolution:
1. cd ~/../../etc (go to etc folder in WSL).
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
secondary.
@ilfuriano
ilfuriano / EventObserver.kt
Created January 23, 2021 15:21 — forked from JoseAlcerreca/EventObserver.kt
An Observer for Events, simplifying the pattern of checking if the Event's content has already been handled.
/**
* An [Observer] for [Event]s, simplifying the pattern of checking if the [Event]'s content has
* already been handled.
*
* [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled.
*/
class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> {
override fun onChanged(event: Event<T>?) {
event?.getContentIfNotHandled()?.let { value ->
onEventUnhandledContent(value)
@ilfuriano
ilfuriano / Event.kt
Created January 23, 2021 15:20 — forked from JoseAlcerreca/Event.kt
An event wrapper for data that is exposed via a LiveData that represents an event.
/**
* Used as a wrapper for data that is exposed via a LiveData that represents an event.
*/
open class Event<out T>(private val content: T) {
var hasBeenHandled = false
private set // Allow external read but not write
/**
* Returns the content and prevents its use again.
@ilfuriano
ilfuriano / hgignore.LaTeX
Last active September 11, 2015 08:17 — forked from bertvv/hgignore.LaTeX
Ignore temporary files for a LaTeX project in Mercurial. Works as well as a .gitignore for a Git repository if you drop the line with "syntax: glob".
# Files to ignore in a LaTeX project
syntax: glob
# General files to ignore
*~
*.bak
# Mac os
.DS_Store