Skip to content

Instantly share code, notes, and snippets.

import MainGridLayout from "../layouts/MainGridLayout.astro";
import {i18n} from "../i18n/translation";
import I18nKey from "../i18n/i18nKey";
import {exec} from "node:child_process";
import {readFile, access} from "node:fs/promises";
import * as typst from "typst";
import {DOMParser} from "xmldom";
@pawarherschel
pawarherschel / cv.astro
Created April 17, 2024 13:59
cursed fuckin method to embed my cv, downloads the git repo in node_modules and then compiles the typst code
import MainGridLayout from "../layouts/MainGridLayout.astro";
import {i18n} from "../i18n/translation";
import I18nKey from "../i18n/i18nKey";
import {exec} from "child_process";
import * as typst from "typst";
import * as fs from "node:fs";
import {DOMParser} from "xmldom";
#[derive(serde::Deserialize, serde::Serialize, Debug, Clone, Default)]
#[serde(crate = "rocket::serde")]
struct Day06Output {
elf: u64,
#[serde(rename = "elf on a shelf")]
elf_on_a_shelf: u64,
#[serde(rename = "shelf with no elf on it")]
shelf_with_no_elf_on_it: u64,
}
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 17 columns, instead of 5. in line 7.
Address,Line,Source/Assembly,CYCLES_NOT_IN_HALT,RETIRED_INST,CPI,RETIRED_BR_INST (PTI),RETIRED_BR_INST_MISP (PTI),%RETIRED_BR_INST_MISP,RETIRED_BR_INST_MISP_RATE,RETIRED_BR_INST_MISP_RATIO,RETIRED_BR_INST_RATE,RETIRED_INDIRECT_BR_INST_MISP (PTI),RETIRED_NEAR_RETURNS (PTI),RETIRED_NEAR_RETURNS_MISP (PTI),RETIRED_TAKEN_BR_INST (PTI),RETIRED_TAKEN_BR_INST_MISP (PTI)
,33,let oc = &ray.origin - &self.center;,1173000000,1064500000,1.10,139.15,1.64,1.18,,0.01,0.14,,51.46,0.05,110.66,0.89
0x3f305,33,"add rdx, 0x10",11750000,14000000,0.84,133.93,,,,,0.13,,42.86,,103.57,
0x3f309,33,"mov qword ptr [rbp + 0xb8], rdx",,500000,,50.00,,,,,0.05,,,,,
0x3f310,33,"mov qword ptr [rbp + 0x1e8], r8",6000000,5750000,1.04,126.09,8.70,6.90,,0.07,0.13,,43.48,,104.35,
0x3f317,33,"mov qword ptr [rbp + 0x1f0], rdx",12500000,11250000,1.11,142.22,,,,,0.14,,71.11,,115.56,
0x3f31e,33,"mov qword ptr [rbp + 0x758], r8",15000000,11750000,1.28,159.57,4.26,2.67,,0.03,0.16,,38.30,,125.53,2.13
0x3f325,33,"mov qword ptr [rbp + 0x760], 0",93500000,86
use makepad_widgets::KeyCode::ReturnKey;
use makepad_widgets::*;
#[derive(Live)]
pub struct App {
#[live]
ui: WidgetRef,
#[rust]
input: Option<String>,
class Vec2 {
/*
* A 2D vector
* @param x The x coordinate
* @param y The y coordinate
*/
constructor(x, y) {
this.x = x
this.y = y
}
class Vec2 {
/*
* A 2D vector
* @param x The x coordinate
* @param y The y coordinate
*/
constructor(public x: number, public y: number) {}
}
class Line {
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub enum Token<'a> {
Word(&'a str, bool),
Colon,
Negation,
Whitespace,
Empty,
}
# our algorithm first finds the next required number and then adds it to the score
# so we need to subtract from the number we initially want to add
# we need first even to be 2, so we subtract 2 from 2
current_even = 2 - 2
# we need first odd to be 1, so we subtract 2 from 1
current_odd = 1 - 2
# we need first prime to be 2, so we subtract 1 from 2
current_prime = 2 - 1
# according to the problem statement, the score starts at 0
// test_case_name , function_name , input_to_function , expected_output
// test_kattis_wheresmyinternet_1, wheresmyinternet, "2 1\n2 1".to_string() , "Connected".to_string();
// test_kattis_wheresmyinternet_2, wheresmyinternet, "6 4\n1 2\n2 3\n3 4\n5 6".to_string(), "5\n6".to_string();
// test_kattis_wheresmyinternet_3, wheresmyinternet, "4 3\n2 3\n4 2\n3 4".to_string() , "2\n3\n4".to_string();
pub fn wheresmyinternet(input: String) -> String {
let mut lines = input.split('\n');
let (first, rest) = (lines.next().unwrap().to_owned(), lines);
let (no_houses, _) = first.split_once(' ').unwrap();
let no_houses = no_houses.parse::<usize>().unwrap();