Skip to content

Instantly share code, notes, and snippets.

View kpcyrd's full-sized avatar

kpcyrd

View GitHub Profile
@kpcyrd
kpcyrd / main.rs
Last active October 21, 2023 12:18
3-2-1 code review html scraping
// updated code for https://github.com/unbeschwert/3-2-1
use std::{fs, io::Write};
use anyhow::{Result, Context};
use dirs::home_dir;
use scraper::{Element, Html, Selector};
static URL: &str = "https://jamesclear.com/3-2-1";
const QUESTION_HEADLINE: &str = "1 QUESTION FOR YOU";
// RUSTFLAGS="-C panic=abort" cargo build --release --target x86_64-unknown-none && ./target/x86_64-unknown-none/debug/hello-world; echo $?
#![no_std]
#![no_main]
use core::arch::asm;
use core::slice;
pub const STDOUT_FILENO: u32 = 1;
#!/usr/bin/env php
<?php
require __DIR__ . '/vendor/autoload.php';
use Aws\S3\S3Client;
$s3 = new S3Client([
'version' => 'latest',
'endpoint' => 'https://s3.eu-central-1.amazonaws.com',
@kpcyrd
kpcyrd / repro.sh
Last active June 26, 2021 20:04
Test repro alpine raspi images
#!/bin/sh
set -ex
## this needs to be run once for ./mkimage.sh to work
# doas cp -v /usr/share/apk/keys/armhf/* /etc/apk/keys/
mkdir -p ~/out
rm -vf ~/out/*/* ~/out/diff.html
for x in 1 2; do
@kpcyrd
kpcyrd / gist:b1abfbc5fe92c3bbce029118ad10a611
Created February 6, 2020 01:31
work in progress gps distance calculation
// Cargo.toml: geo = "0.12.2"
use geo::*;
use geo::prelude::*;
fn main() {
let polygon = Polygon::new(LineString::from(vec![
Point::new(9.764785766601562, 53.63975308945899),
Point::new(9.827270507812, 53.59494998253459),
Point::new(9.9151611328125, 53.663153974456456),
@kpcyrd
kpcyrd / ct-sub-domains-0.1.0.patch
Created March 14, 2019 19:04
rickmer/ct-sub-domains-0.1.0.patch
--- a/ct-sub-domains.lua
+++ b/ct-sub-domains.lua
@@ -6,10 +6,17 @@
function run(domain)
session = http_mksession()
- request = http_request(session, 'GET', 'https://api.certspotter.com/v1/issuances?include_subdomains=true&expand=dns_names&expand=issuer&expand=cert&domain=' .. domain['value'], {
+ request = http_request(session, 'GET', 'https://api.certspotter.com/v1/issuances', {
+ query={
+ include_subdomains='true',
@kpcyrd
kpcyrd / PKGBUILD
Created February 9, 2019 12:50
diesel_cli PKGBUILD
# Maintainer: Philipp A <flying-sheep@web.de>
# Contributor: kpcyrd <git@rxv.cc>
pkgname=diesel_cli
pkgver=1.4.0
pkgrel=1
pkgdesc='CLI for the Diesel crate'
arch=('i686' 'x86_64')
url="http://diesel.rs/"
license=('MIT' 'Apache')
@kpcyrd
kpcyrd / up.sql
Last active December 6, 2018 11:43
sqlite 3.26.0 db corruption regression
-- # steps to reproduce
-- rm -f foo.db; sqlite3 foo.db < up.sql; echo '.schema' | sqlite3 foo.db
--
-- debian stable (works as expected):
-- 3.16.2 2017-01-06 16:32:41 a65a62893ca8319e89e48b8a38cf8a59c69a8209
--
-- archlinux (corrupted database):
-- 3.26.0 2018-12-01 12:34:55 bf8c1b2b7a5960c282e543b9c293686dccff272512d08865f4600fb58238b4f9
CREATE TABLE foo (
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 2ac1bbca..3fbfc5a7 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -55,6 +55,7 @@ splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends'
readonly -a build_options splitpkg_overrides
known_hash_algos=('md5' 'sha1' 'sha224' 'sha256' 'sha384' 'sha512' 'whirlpool')
+secure_hash_algos=('sha224' 'sha256' 'sha384' 'sha512' 'whirlpool')
#!/usr/bin/env python3
import subprocess
import time
import sys
SCANCODES = {
'ESC': [[0x01], [0x81]],
'1': [[0x02], [0x82]], '!': [[0x2A, 0x02], [0x82, 0xAA]],
'2': [[0x03], [0x83]], '@': [[0x2A, 0x03], [0x83, 0xAA]],