Skip to content

Instantly share code, notes, and snippets.

@machuu
machuu / WSL2_VPN_Workaround_Instructions.md
Last active April 18, 2024 23:13
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:

@Kautenja
Kautenja / sftp_pandas.py
Last active January 6, 2023 04:39
Functions for working with remote files using pandas and paramiko (SFTP/SSH).
"""Functions for working with remote files using pandas and paramiko (SFTP/SSH)."""
import pandas as pd
import paramiko
def read_csv_sftp(hostname: str, username: str, remotepath: str, *args, **kwargs) -> pd.DataFrame:
"""
Read a file from a remote host using SFTP over SSH.
Args:
@yzorg
yzorg / trycatchtran.sql
Last active June 19, 2020 12:58 — forked from mishrsud/trycatchtran.sql
SQL TRY-CATCH WITH TRANSACTION
CREATE PROCEDURE [dbo].[spTxnDemo]
@debug int = NULL
, @forceError int = NULL
AS
BEGIN
SET NOCOUNT ON;
SET @debug = ISNULL(@debug, 0);
SET @forceError = ISNULL(@forceError, 0);
BEGIN TRY
BEGIN TRANSACTION MY_TXN;
@ptupitsyn
ptupitsyn / IgniteAsyncStreamExtensions.cs
Last active July 23, 2020 13:19
IgniteAsyncStreams
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cache.Event;
using Apache.Ignite.Core.Cache.Query.Continuous;
namespace IgniteAsyncStreams
{
public static KeyValuePair<ushort, string>[] Parse(Span<byte> message)
{
var values = new List<KeyValuePair<ushort, string>>();
const byte Soh = 1;
const byte Equals = 61;
while (0 < message.Length)
{
var soh = message.IndexOf(Soh);
if (-1 == soh)
break;
@bzerangue
bzerangue / json-to-ndjson.md
Last active January 31, 2024 20:57
JSON to NDJSON

NDJSON is a convenient format for storing or streaming structured data that may be processed one record at a time.

  • Each line is a valid JSON value
  • Line separator is ‘\n’

1. Convert JSON to NDJSON?

cat test.json | jq -c '.[]' > testNDJSON.json
@werneckpaiva
werneckpaiva / KafkaSeekByTimestamp.java
Last active May 4, 2023 17:12
Kafka Consumer - seek by timestamp
// Get the list of partitions
List<PartitionInfo> partitionInfos = consumer.partitionsFor(topicName);
// Transform PartitionInfo into TopicPartition
List<TopicPartition> topicPartitionList = partitionInfos
.stream()
.map(info -> new TopicPartition(topicName, info.partition()))
.collect(Collectors.toList());
// Assign the consumer to these partitions
consumer.assign(topicPartitionList);
// Look for offsets based on timestamp
@bradtraversy
bradtraversy / pipenv_cheat_sheet.md
Last active April 1, 2024 03:09
Pipenv cheat sheet for common commands

Pipenv Cheat Sheet

Install pipenv

pip3 install pipenv

Activate

pipenv shell
@kof
kof / button-hooked.js
Last active November 23, 2021 08:13
Inject styles with custom hooks
const styles = {
button: {
color: 'red'
}
}
const Button = () => {
const {classes} = useStyles(styles)
return <button className={classes.button}>Test<Button>
}
@thorsman99
thorsman99 / InsertNotPresent.sql
Created May 29, 2018 08:12
Inserts only rows not found in destination #sql
Insert into [server].database.dbo.table
select src.* from table src
left join [server].database.dbo.table sta
ON sta.Key = src.Key
where sta.Key IS NULL