Skip to content

Instantly share code, notes, and snippets.

Linux based Python enviroment for Windows systems using WSL

The following document will guide you through to install WSL, Ubuntu distro, python,pyenv and poetry

Install WSL and Linux Distro for Windows Machine

If you are using Linux based system skip these steps for installing wsl & Ubuntu

  1. First you need to Make sure your Windows version is at least Windows 10, version 2004. You can check your Windows version by going to Settings > System > About.
@liorazi
liorazi / Animation+CustomTimingFunctions.swift
Last active May 12, 2024 04:31
Extension to SwiftUI Animation which extends it with more ease timing functions as described in: https://easings.net
import SwiftUI
extension Animation {
public static func easeInSin(duration: Double) -> Animation {
return self.timingCurve(0.47, 0, 0.745, 0.715, duration: duration)
}
public static var easeInSin: Animation = Animation.timingCurve(0.47, 0, 0.745, 0.715)
nothing here
@four0four
four0four / 01-zynq-uart.md
Last active May 12, 2024 04:20
Zynq BootROM Secrets - UART loader

Zynq BootROM Secrets: UART loader

Recently I acquired (md5: ADF639AFE9855EE86C8FAAD216C970D9) the Zynq bootrom, and during the reversing process uncovered some interesting secrets, one of which is an as-of-yet undocumented UART loader. As documented the Zynq bootrom will load from NOR/NAND/SPI flashes, eMMC/SDIO-based storage (unfortunately) not USB, or anything else more complex.

Not sure why Xilinx didn't document this. In my brief testing it is super unreliable if you just spit everything at once - they reset the RX/TX paths during the process, so timing is critical, but that might be the janky meter-long ftdi cable. You can change the baudrate during the process, but I was too lazy to do the math.

Here's the disassembly that made me look twice (that, and checks for the MIO boot_mode[2:0] that weren't specified in the docs :)):

ROM:0000A220 BL              uart_init
@four0four
four0four / 01-zynq-uart-exploit.md
Last active May 12, 2024 04:18
Zynq BootROM Secrets: BootROM dump exploit

Zynq BootROM Secrets: Exposing the bootROM with the UART loader

Last time I wrote about this, I lied a little - There is an interesting bug in the UART loader, and it may have been exactly why Xilinx didn't document it. In short: The UART loader writes the entire UART payload to a location in memory (nominally 0x4_0000). The ROM is architected such that when the boot mode is selected, it registers a callback that is called when the ROM wants more data from the boot device. For the UART loader, this is pretty simple - here's the whole thing:

; void uart_callback(u32 r0_offset, void* r1_dest, i32 r2_nbytes)
ROM:0000A578 PUSH            {R3,LR}
ROM:0000A57C MOV             R3, #uart_buff
ROM:0000A584 MOV             R12, #1
ROM:0000A588 LDR             R3, [R3]
@shigenobuokamoto
shigenobuokamoto / network-mirrored.service
Last active May 12, 2024 04:13
/etc/systemd/system/network-mirrored.service
[Unit]
Wants=network-pre.target
Before=network-pre.target shutdown.target
[Service]
User=root
ExecStart=/bin/sh -ec '\
[ -x /usr/bin/wslinfo ] && [ "$(/usr/bin/wslinfo --networking-mode)" = "mirrored" ] || exit 0;\
echo "\
add chain ip nat WSLPREROUTING { type nat hook prerouting priority dstnat - 1; policy accept; };\
@nimpy
nimpy / calculate_psnr.py
Last active May 12, 2024 04:07
Calculating peak signal-to-noise ratio (PSNR) between two images.
import numpy as np
def calculate_psnr(img1, img2, max_value=255):
""""Calculating peak signal-to-noise ratio (PSNR) between two images."""
mse = np.mean((np.array(img1, dtype=np.float32) - np.array(img2, dtype=np.float32)) ** 2)
if mse == 0:
return 100
return 20 * np.log10(max_value / (np.sqrt(mse)))
@zeljic
zeljic / build_sqlite3_lib.md
Last active May 12, 2024 04:04
Build SQLite3 .lib file on windows

How to build SQLite3 .lib file on Windows 10

  1. Download source from source

    For example: source https://www.sqlite.org/2023/sqlite-amalgamation-3430100.zip

  2. Download binary from binary

    For example: binary https://www.sqlite.org/2023/sqlite-dll-win64-x64-3430100.zip

  3. Extract both archives to the same directory

@nhatnx
nhatnx / curl-error-60-ssl-certificate-unable-to-get-local-issuer-certificate.md
Last active May 12, 2024 04:02
[WAMP] cURL error 60: SSL certificate: unable to get local issuer certificate

Need to do this in both php.ini files !!!

Attention Wamp/Wordpress/windows users. I had this issue for hours and not even the correct answer was doing it for me, because I was editing the wrong php.ini file because the question was answered to XAMPP and not for WAMP users, even though the question was for WAMP.

here's what I did

Download the certificate bundle.

Put it inside of C:\wamp64\bin\php\your php version\extras\ssl