Skip to content

Instantly share code, notes, and snippets.

View hackintoshrao's full-sized avatar
📚
Exploring AI agents on code search and understanding

Karthic Rao hackintoshrao

📚
Exploring AI agents on code search and understanding
View GitHub Profile
@hackintoshrao
hackintoshrao / guess.rs
Created January 18, 2023 07:32
sample to showcase the concept of shadowing in Rust.
fn main() {
println!("Guess the number!");
let secret_number = rand::thread_rng().gen_range(1, 101);
println!("The secret number is: {}", secret_number);
println!("Please input your guess.");
let mut guess = String::new();
{
"data": {
"getInt": 12,
"getString": null
},
"errors": [
{
"message": "Failed to get string!",
}
]
<div id="my-component">
<header>
<!-- children with the `slot="header"` attribute will go here -->
<slot name="header" />
</header>
<main>
<!-- children without a `slot` (or with the `slot="default"`) attribute will go here -->
<slot />
</main>
<footer>
---
export interface Props {
post: any;
}
const { post } = Astro.props;
---
<article class="post-preview">
<header>
<section>
{allPosts.map(p => <BlogPostPreview post={p} />)}
</section>
---
// Import your components in your component script...
import SomeComponent from './SomeComponent.astro';
---
<!-- ... then use them in your HTML! -->
<div>
<SomeComponent />
</div>
function DogPhoto({ breed }) {
const { loading, error, data, refetch } = useQuery(GET_DOG_PHOTO, {
variables: { breed }
});
if (loading) return null;
if (error) return `Error! ${error}`;
return (
function DogPhoto({ breed }) {
const { loading, error, data } = useQuery(GET_DOG_PHOTO, {
variables: { breed },
pollInterval: 500,
});
if (loading) return null;
if (error) return `Error! ${error}`;
return (
function DogPhoto({ breed }) {
const { loading, error, data } = useQuery(GET_DOG_PHOTO, {
variables: { breed },
});
if (loading) return null;
if (error) return `Error! ${error}`;
return (
<img src={data.dog.displayImage} style={{ height: 100, width: 100 }} />