Skip to content

Instantly share code, notes, and snippets.

@da-moon
da-moon / Setup-WSL2SSH.ps1
Last active September 6, 2024 02:12
Powershell script to setup SSH server in WSL so that Windows users can SSH into WSL. It can be useful for "remote" development with Editors such as Lapce or Zed
# Flexible WSL2 SSH Setup Script with Distribution Detection
# Ensure running as Administrator
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "Please run this script as Administrator!"
Exit
}
# Function to get the default WSL distribution
function Get-DefaultWSLDistribution {
@da-moon
da-moon / build-zed.ps1
Last active September 19, 2024 01:13
Powershell script to build and setup latest version of zed on windows
# Zed Build and Update Script for Windows
# This script builds or updates Zed from source and sets up a command-line interface.
# Enable strict mode
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
# Configuration
$ZedRepo = "https://github.com/zed-industries/zed.git"
$BuildDir = "$env:USERPROFILE\zed-build"
@da-moon
da-moon / README.md
Created July 13, 2024 16:06 — forked from MichaelCurrin/README.md
GitHub GraphQL - Get files in a repository

Get GitHub Files

Get the metadata and content of all files in a given GitHub repo using the GraphQL API

You might want to get a tree summary of files in a repo without downloading the repo, or maybe you want to lookup the contents of a file again without download the whole repo.

The approach here is to query data from GitHub using the Github V4 GraphQL API.

About the query

@da-moon
da-moon / 00.howto_install_phantomjs.md
Created July 8, 2024 21:44 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@da-moon
da-moon / readme.txt
Created July 4, 2024 00:59 — forked from ANRCorleone/readme.txt
Ubuntu 22.04 + Hyper V + Enhanced Session mode + XRDP PulseAudio
Credits
# https://c-nergy.be/blog/?p=13655
# https://askubuntu.com/questions/844245/how-to-compile-latest-pulseaudio-with-webrtc-in-ubuntu-16-04
# https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list
# https://unix.stackexchange.com/questions/65167/enable-udev-and-speex-support-for-pulseaudio
# https://rudd-o.com/linux-and-free-software/how-to-make-pulseaudio-run-once-at-boot-for-all-your-users
# https://gist.github.com/rkttu/35ecab5604c9ddc356b0af4644d5a226
# Installation and Enhanced session
# follow steps on the post below, I installed Ubuntu 22.04 on a Windows 11 machine
git log --pretty=format:"@%ad ~~%s~~" --date=short --shortstat \
| tr "\n" " " \
| tr "@" "\n" \
| grep -v 'skip ci' \
| grep -v 'deps' \
| grep -v 'dependencies' \
| sed -En 's/ ~~.*~~ /,/p'

After long searching I did not find a good description of how to set up Syncthing that works exclusively via CLI without using a Web browser on the devices.

This is useful for example on a headless Raspberry Pi without proxying web-traffic through SSH or with port-forwarding limitations. In this example we will want to share the default folder from Machine A with Machine B

Machine A Machine B
@da-moon
da-moon / vimeo-download.py
Created March 12, 2023 14:14 — forked from alexeygrigorev/vimeo-download.py
Downloading segmented video from vimeo
import requests
import base64
from tqdm import tqdm
master_json_url = 'https://178skyfiregce-a.akamaihd.net/exp=1474107106~acl=%2F142089577%2F%2A~hmac=0d9becc441fc5385462d53bf59cf019c0184690862f49b414e9a2f1c5bafbe0d/142089577/video/426274424,426274425,426274423,426274422/master.json?base64_init=1'
base_url = master_json_url[:master_json_url.rfind('/', 0, -26) + 1]
resp = requests.get(master_json_url)
content = resp.json()