This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE TupleSections #-} | |
module Day04 (parse, solveA, solveB) where | |
import Data.Void (Void) | |
import Data.Text (Text) | |
import Data.Bits (shiftL, shiftR) | |
import Data.Bifunctor (first) | |
import Text.Megaparsec (Parsec, many, eof, runParser, errorBundlePretty) | |
import Text.Megaparsec.Char (string, space, char) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Nothing = { kind: "Nothing" }; | |
const Just = (val) => ({ kind: "Just", val: () => val }); | |
function pure(val) { | |
return Just(val); | |
} | |
function fmap(f, x) { | |
return (x.kind == "Nothing") | |
? Nothing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Extract nested type from interface or object type. | |
* | |
* Example usage: | |
* ```ts | |
* type result = CheckNested<["a", "b"], {a: {b: number}}>; | |
* ``` | |
*/ | |
type ExtractNestedType< | |
Props extends any[], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::error::Error; | |
use clap::Parser; | |
use futures::StreamExt; | |
use reqwest::Client; | |
#[derive(clap::Parser)] | |
struct Cli { | |
#[arg(short, long, default_value_t = 1)] | |
count: u32, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function H(n) { | |
function e(t) { | |
if ("string" == typeof t) return function(t){}.constructor("while (true) {}").apply("counter"); | |
(t % 20 == 0) | |
? function() { return !0 }.constructor("debugger").call("action") | |
: function() { return !1 }.constructor("debugger").apply("stateObject"), | |
e(++t) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
use std::fs::OpenOptions; | |
use std::io::{Seek, SeekFrom, Write}; | |
let foo = "hello"; | |
let fat_ptr_ptr = &foo as *const _ as u64; | |
println!("{fat_ptr_ptr}"); | |
println!("before = {foo}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Lista 0 | |
last' :: [a] -> Maybe a | |
last' [] = Nothing | |
last' [x] = Just x | |
last' (_:xs) = last' xs | |
-- Lista 1 | |
suma :: [Double] -> Double | |
suma [] = 0 | |
suma (x:xs) = x + suma xs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.by import By | |
if __name__ == '__main__': | |
driver = webdriver.Firefox(executable_path="./geckodriver") | |
driver.get("https://tohosort.frelia.my/") | |
driver.find_element(By.CSS_SELECTOR, ".starting.start.button").click() | |
while True: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import discord | |
from discord.ext import commands | |
bot = commands.Bot(">>>", self_bot=True) | |
@bot.event | |
async def on_ready(): | |
print("Bot presence t u r n e d on ( ͡° ͜ʖ ͡°)") | |
@bot.command() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char buffer[12]; | |
while (fgets(buffer, sizeof buffer, input) != NULL) | |
{ | |
std::string str = ""; | |
char* ptr = buffer; | |
while (*ptr != NULL) | |
{ | |
str += *ptr++; | |
} | |
std::cout << str; |