WSL2 uses Hyper-V for networking. The WSL2 network settings are ephemeral and configured on demand when any WSL2 instance is first started in a Windows session. The configuration is reset on each Windows restart and the IP addresses change each time. The Windows host creates a hidden switch named "WSL" and a network adapter named "WSL" (appears as "vEthernet (WSL)" in the "Network Connections" panel). The Ubuntu instance creates a corresponding network interface named "eth0".
Assigning static IP addresses to the network interfaces on the Windows host or the WSL2 Ubuntu instance enables support for the following scenarios:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check these threads before proceeding: | |
# https://github.com/microsoft/WSL/discussions/5857 | |
# https://github.com/microsoft/WSL/issues/5821 | |
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) { | |
$CmdLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments | |
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CmdLine | |
Exit | |
} | |
# Restart the Host Network Service | |
Restart-Service -Force -Name hns |
Install, build and debug a react native app in WSL2 (Windows Subsystem for Linux) and Ubuntu.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2022, Mysten Labs, Inc. | |
// SPDX-License-Identifier: Apache-2.0 | |
module nfts::marketplace_nofee { | |
use sui::tx_context::{Self, TxContext}; | |
use sui::object::{Self, UID, ID}; | |
use sui::transfer; | |
use sui::dynamic_object_field as ofield; | |
use sui::coin::{Self, Coin}; | |
use sui::balance::{Self, Balance}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn transfer_from_account_we_own( | |
src: &mut AccountInfo, // we better own this account though | |
dst: &mut AccountInfo, | |
amount: u64, | |
) -> ProgramResult { | |
**src.try_borrow_mut_lamports()? = src | |
.lamports() | |
.checked_sub(amount) | |
.ok_or(ProgramError::InvalidArgument)?; | |
**dst.try_borrow_mut_lamports()? = dst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as BufferLayout from "buffer-layout"; | |
import { | |
AccountInfo, | |
ASSOCIATED_TOKEN_PROGRAM_ID, | |
Token, | |
TOKEN_PROGRAM_ID, | |
u64, | |
} from "@solana/spl-token"; | |
import { Connection, PublicKey } from "@solana/web3.js"; | |
import { BN } from "bn.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// remove some meta tags from WordPress | |
remove_action('wp_head', 'wp_generator'); | |
function remove_dns_prefetch( $hints, $relation_type ) { | |
if ( 'dns-prefetch' === $relation_type ) { | |
return array_diff( wp_dependencies_unique_hosts(), $hints ); | |
} | |
return $hints; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin element($name) { | |
@at-root #{&}__#{$name}{ | |
@content; | |
} | |
} | |
@mixin modifier($name) { | |
@at-root #{&}--#{$name} { | |
@content; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mixins | |
.has(@element; @content) { | |
&__@{element} { | |
@content(); | |
} | |
} | |
.variant(@modifier; @content) { | |
&--@{modifier} { | |
@content(); |
NewerOlder