Lädt...


🔧 SnipShot: A Stylish Code Snippet Uploader Using Pinata IPFS


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

This is a submission for the The Pinata Challenge

What I Built

I developed SnipShot, a web application that allows developers to easily create, format, and share beautiful images of their code snippets. The app uses React for the frontend, with Material-UI for a sleek user interface. The core functionality leverages Pinata's IPFS service to store the original code snippets, while also generating stylized images of the formatted code.

Key features include:

  • Support for multiple programming languages
  • Automatic code formatting with customizable indentation
  • Syntax highlighting for improved readability
  • Easy sharing via downloadable images
  • Secure storage of original snippets on IPFS through Pinata

Demo

Check out the live app here and generate awesome images for free: https://snipshot-eta.vercel.app/

Screenshots showcasing the app features:

Landing:
landing

Snippet Uploader and Image Generation Interface:
snippet

Generated snippet image:

generated snippet

My Code

The project is available on GitHub: https://github.com/mitchiemt11/codesnap

Here's a key component of the project, the SnippetRenderer:

import React, { forwardRef } from 'react';
import { Box } from '@mui/material';
import hljs from 'highlight.js';
import 'highlight.js/styles/vs2015.css';
import { Language } from '../types';

interface SnippetRendererProps {
  codeContent: string;
  language: Language;
  spacesPerIndent?: number;
}

const formatCode = (code: string, spacesPerIndent: number): string => {
  // ... [formatCode function implementation]
};

export const SnippetRenderer = forwardRef<HTMLDivElement, SnippetRendererProps>(
  ({ codeContent, language, spacesPerIndent = 2 }, ref) => {
    const formattedCode = formatCode(codeContent, spacesPerIndent);

    return (
      <Box
        ref={ref}
        sx={{
          p: 3,
          backgroundColor: "#1e1e1e",
          color: "#dcdcdc",
          borderRadius: 2,
          display: "none",
          fontFamily: "monospace",
        }}
      >
        <pre>
          <code
            dangerouslySetInnerHTML={{
              __html: hljs.highlight(formattedCode, { language }).value,
            }}
          />
        </pre>
      </Box>
    );
  }
);

SnippetRenderer.displayName = 'SnippetRenderer';

This component is responsible for rendering the formatted and syntax-highlighted code snippet, which is then captured as an image.

More Details

Pinata's IPFS service plays a crucial role in SnipShot. Here's how I utilized Pinata in the project:

  1. Uploading Snippets: When a user submits a code snippet, it's first uploaded to Pinata's IPFS network. This ensures that the original code is securely stored and can be retrieved later if needed.
   const blob = new Blob([codeContent], { type: 'text/plain' });
   const file = new File([blob], `snippet.${language}`, { type: 'text/plain' });
   const upload = await pinata.upload.file(file);
  1. Creating Shareable Links: After uploading, I use Pinata's gateway to create a signed URL for the snippet. This URL can be used to access the original code directly from IPFS.
   await pinata.gateways.createSignedURL({
     cid: upload.cid,
     expires: 30,
   });
  1. Image Generation: While the original snippet is stored on IPFS, I generate a stylized image of the code using HTML5 Canvas. This image is what users can easily share on social media or in documentation.

By using Pinata, SnipShot ensures that code snippets are not only beautifully presented but also securely stored and easily retrievable. This combination of visual appeal and robust storage makes SnipShot a powerful tool for developers looking to share their code in a more engaging way.

cheers

...

🔧 SnipShot: A Stylish Code Snippet Uploader Using Pinata IPFS


📈 137.28 Punkte
🔧 Programmierung

🔧 A decentralized file storage system using PINATA and IPFS


📈 44.24 Punkte
🔧 Programmierung

🔧 A decentralized file storage system using PINATA and IPFS


📈 44.24 Punkte
🔧 Programmierung

🔧 Pinata OG! | Generate beautiful OpenGraph Images with Pinata File API


📈 40.85 Punkte
🔧 Programmierung

🔧 Pinata OG! | Generate beautiful OpenGraph Images with Pinata File API


📈 40.85 Punkte
🔧 Programmierung

🔧 The Pinata Challenge: Pinata File Hub - Seamless File Management & Uploads


📈 40.85 Punkte
🔧 Programmierung

🔧 Pinata CLI: A CLI Application for the Pinata.Cloud Files Interface


📈 40.85 Punkte
🔧 Programmierung

🕵️ CVE-2023-23277 | Snippet-box 1.0.0 Form Field Snippet code cross site scripting (Issue 57)


📈 40.62 Punkte
🕵️ Sicherheitslücken

🔧 Effortless Image Tag Generation: Streamline Your Workflow with Pinata and IPFS


📈 40.17 Punkte
🔧 Programmierung

🔧 Created a dApp storing data on Pinata - IPFS


📈 40.17 Punkte
🔧 Programmierung

🔧 StashIt: Your Game Assets Storage Hub | Powered by Pinata 🪅 IPFS SDK


📈 40.17 Punkte
🔧 Programmierung

🔧 StashIt: Your Game Assets Storage Hub | Powered by Pinata 🪅 IPFS SDK


📈 40.17 Punkte
🔧 Programmierung

🔧 PinataShot: Multimodal LLaMA 3.2 Screenshot Categorization on Pinata IPFS


📈 40.17 Punkte
🔧 Programmierung

🕵️ Wolf CMS 0.8.3.1 Add SNippet /?/admin/snippet/add cross site scripting


📈 37.36 Punkte
🕵️ Sicherheitslücken

🕵️ Frog CMS 0.9.5 Edit Snippet admin/ snippet[name] cross site scripting


📈 37.36 Punkte
🕵️ Sicherheitslücken

🕵️ High CVE-2021-34084: S3-uploader project S3-uploader


📈 31.22 Punkte
🕵️ Sicherheitslücken

🕵️ WebCam 7 + Imgbb Uploader Bot - Automatic webcam capture uploader


📈 31.22 Punkte
🕵️ Hacking

🕵️ Media Uploader - File Uploader


📈 31.22 Punkte
🕵️ Sicherheitslücken

🎥 Predict the output of this C code snippet using pointer arithmetic and notation. Go!


📈 26.01 Punkte
🎥 Videos

🔧 Building a Code Snippet Library with Readwise, Obsidian, and Visual Studio Code


📈 25.2 Punkte
🔧 Programmierung

🔧 14 Code Snippet Image Generators to Turn Your Code into Stunning Visuals 😍🧑‍💻


📈 25.2 Punkte
🔧 Programmierung

🔧 Creating a Code Snippet in VS Code to Increase Productivity


📈 25.2 Punkte
🔧 Programmierung

🔧 Integrating a VS Code Like Editor in NextJS | Code Snippet Sharing App Series


📈 25.2 Punkte
🔧 Programmierung

🔧 How to create VS Code code snippet


📈 25.2 Punkte
🔧 Programmierung

🔧 Building a Chat with PDFs using Pinata,OpenAI,, and Streamlit


📈 24.5 Punkte
🔧 Programmierung

🕵️ Using Ghidra to Reverse Engineer Viva Pinata for Windows


📈 24.5 Punkte
🕵️ Reverse Engineering

🔧 FileShare| A FileSharing Platform built using Next.js and Pinata Files API


📈 24.5 Punkte
🔧 Programmierung

🔧 Image Annotation for AI Model training using Pinata


📈 24.5 Punkte
🔧 Programmierung

🔧 How to Deploy a Next JS App on IPFS (InterPlanetary File System) and automate using Fleek


📈 23.81 Punkte
🔧 Programmierung

📰 More phishing campaigns are using IPFS network protocol


📈 23.81 Punkte
📰 IT Security Nachrichten

📰 Attackers Using IPFS for Distributed, Bulletproof Malware Hosting


📈 23.81 Punkte
📰 IT Security Nachrichten

📰 Researchers Warns of Increase in Phishing Attacks Using Decentralized IPFS Network


📈 23.81 Punkte
📰 IT Security Nachrichten

🎥 Can you tidy up this snippet of Dart code? Go!


📈 21.94 Punkte
🎥 Videos

🔧 Build a simple code snippet manager with Neon’s serverless driver, Clerk, and Nextjs


📈 21.94 Punkte
🔧 Programmierung

🔧 Create a Custom VS Code Snippet


📈 21.94 Punkte
🔧 Programmierung

matomo