Skip to content

Instantly share code, notes, and snippets.

View DogPawHat's full-sized avatar

Ciarán Curley DogPawHat

View GitHub Profile
@DogPawHat
DogPawHat / react-data-fetching R1
Created January 25, 2025 03:36
Deepseek R1's answer to the prompt "How can I fetch data in react?"
<think>
Okay, the user is asking how to fetch data in React. Let me think about the different methods available.
First, the classic approach is using the fetch API. I should explain that. You can use fetch inside useEffect with useState to handle the data, loading, and error states. That's straightforward, especially for someone new to React.
Wait, but maybe they've heard of libraries like Axios. Should I mention that as an alternative? Yeah, it's good to give options. Axios has some advantages like automatic JSON parsing and better error handling.
Also, React Query is a popular library now. It simplifies data fetching, caching, and state management. Including an example with React Query would show a more modern approach. But I need to make sure to note that it's a third-party library, so they might need to install it.
Suspense is another thing. React 18 introduced Suspense for data fetching, but it's still experimental. Maybe mention it briefly as an upcoming feature but advise using stable methods for n
@DogPawHat
DogPawHat / deepseek-r1-new-react-app
Created January 25, 2025 02:37
Deepseek R1 answer to "Can you recommend the best way to create a react app" (January 2025)
<think>
Okay, the user is asking about the best way to create a React app. Let me start by recalling the common methods. There's Create React App (CRA), which has been the go-to for a long time. But I remember that the React team now recommends using a framework like Next.js or using Vite with some templates.
First, I should mention the official React documentation's recommendation. They point towards frameworks, but if someone just wants a simple setup, they might prefer CRA or Vite. Wait, but CRA is still maintained, right? Or did they stop? I think the React docs mention that CRA is no longer the primary tool. Let me check that. Yeah, the React docs now suggest using frameworks or Vite for new projects. So CRA might not be the best anymore, especially since Vite is faster and more modern.
Vite is definitely a strong contender. It uses esbuild and offers a much quicker development server. The templates for React, including TypeScript, are straightforward. So I should present Vite as a top option. Also, Ne
@DogPawHat
DogPawHat / NumberOfOnes.cpp
Created August 1, 2022 20:46
Cassidoo's number of ones in C++ for some reason
#include <iostream>
int numberOfOnes(int val)
{
int count = 0;
// only one digit
auto numberOfOnesCount = [&count](auto& self, int subval)->void {
if (subval < 10) {
if (subval == 1) {
count++;
@DogPawHat
DogPawHat / main.rs
Created May 30, 2022 16:04
all_unique for cassidoo
use std::env;
use std::collections::HashSet;
fn all_unique(maybe_unique: String, ignore_caps: bool) -> bool {
return maybe_unique.len()
== (if ignore_caps {
maybe_unique.to_lowercase()
} else {
maybe_unique
})
@DogPawHat
DogPawHat / machine.js
Last active August 4, 2021 17:13
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@DogPawHat
DogPawHat / limited_imaginations.ex
Created February 24, 2021 08:33
cassidoo string deletion test
defmodule LimitedImaginations do
@spec check_for_deletion(
String.grapheme(),
{:ok, number(), String.t()}
) :: {:ok, number(), String.t()}
@spec every_other(String.t()) :: {:ok, number(), String.t()}
def check_for_deletion(el, {:ok, 0, ""}) do
{:ok, 0, el}
end
@DogPawHat
DogPawHat / machine.js
Created February 10, 2021 19:15
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@DogPawHat
DogPawHat / machine.js
Created February 4, 2021 15:12
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@DogPawHat
DogPawHat / i-can-explain.md
Created January 27, 2020 14:08
Baby's first code mod

Baby's first codemod

What madness is this?

So I was working on a project recently to update the documentation around Storybook, which involves updating to Storybook 5.3

A neat little feature her is the ablity to write stories and documentaiton in MDX, a glorius love child of JSX and Markdown that enables you to put React componetns into a Markdown file and have it come out the other end.

<Meta title="Examples" decorators={[withKnobs]}/>

Keybase proof

I hereby claim:

  • I am dogpawhat on github.
  • I am dogpawhat (https://keybase.io/dogpawhat) on keybase.
  • I have a public key whose fingerprint is 3F3A A7A3 88DA 47E7 2C96 CECE 2245 E042 7BE7 8306

To claim this, I am signing this object: