Skip to content

Instantly share code, notes, and snippets.

View barrybtw's full-sized avatar
🏠
School stuff

Nicolai Christensen barrybtw

🏠
School stuff
  • Student in Scandinavia
  • Denmark
View GitHub Profile
@barrybtw
barrybtw / Cards.js
Created March 31, 2022 21:23
Mantine & TailwindCSS
import {
useMantineTheme,
Grid,
Card,
Image,
Group,
Text,
Button,
Badge,
} from "@mantine/core";
export default function BlogForm() {
async function handleSubmit(event) {
event.preventDefault();
const form = event.target;
const data = new FormData(form);
const title = data.get("title");
const content = data.get("content");
const blog = { title, content };
const res = await fetch("/api/blog", {
import { auth, googleProvider } from "./firebase";
import { createContext } from "react";
const AuthContext = createContext();
const AuthProvider = () => {
// States we can use to check if user is logged in or not or if there is an error or if the user is loading
const [user, setUser] = useState(null);
const [loading, setLoading] = useState(true);
use rand::Rng;
use std::io;
fn main() {
let secret_number: i32 = rand::thread_rng().gen_range(1..=3);
println!("The secret number is: {}", secret_number);
let computer_choice: &str = if secret_number == 1 {
"rock"
} else if secret_number == 2 {
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"github.com/bwmarrin/discordgo"
)
func Respond(s *discordgo.Session, i *discordgo.InteractionCreate, content string) {
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: content,
Flags: 1 << 6,
},
})
if err != nil {
log.Printf("Error sending message to discord: %v", err)
C:\Code\rust-cli>cargo check
Checking rust-cli v0.1.0 (C:\Code\rust-cli)
error[E0277]: `Languages` doesn't implement `std::fmt::Display`
--> src\main.rs:30:16
|
30 | .items(&languages)
| ----- ^^^^^^^^^^ `Languages` cannot be formatted with the default formatter
| |
| required by a bound introduced by this call
|
@barrybtw
barrybtw / main.rs
Last active October 27, 2022 14:00
success
use dialoguer::{theme::ColorfulTheme, Select};
use strum::{Display, EnumIter, IntoEnumIterator};
#[derive(Debug, EnumIter, Display, Clone, Copy)]
enum Languages {
TypeScript,
JavaScript,
}
#[derive(Debug, EnumIter, Display, Clone, Copy)]
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> src\prompts\packages_prompt.rs:21:42
|
13 | / pub fn ask_packages() -> Vec<Packages> {
14 | | let package_list: Vec<_> = Packages::iter().collect();
15 | |
16 | | let selection = MultiSelect::with_theme(&ColorfulTheme::default())
... |
21 | | .interact_on_opt(&Term::stdout())?;
| | ^ cannot use the `?` operator in a function that returns `Vec<packages_prompt::Packages>`
fn get_name() -> String {
let name = dialoguer::Input::new()
.with_prompt("What is your name?")
.interact()
.expect("Name failed");
name
}