<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by William Pepple on Medium]]></title>
        <description><![CDATA[Stories by William Pepple on Medium]]></description>
        <link>https://medium.com/@williampepple?source=rss-1e6093bc45bc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DvV_Vus8oK_0-qOJT8coxg.jpeg</url>
            <title>Stories by William Pepple on Medium</title>
            <link>https://medium.com/@williampepple?source=rss-1e6093bc45bc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 16:55:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@williampepple/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to build simple GraphQL CRUD APIs using TypeScript, TypeORM, Apollo Server, and PostgreSQL.]]></title>
            <link>https://medium.com/@williampepple/how-to-build-simple-graphql-crud-apis-using-typescript-typeorm-apollo-server-and-postgresql-89f143a9360f?source=rss-1e6093bc45bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/89f143a9360f</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[typeorm]]></category>
            <category><![CDATA[apollo-server]]></category>
            <category><![CDATA[graphql]]></category>
            <dc:creator><![CDATA[William Pepple]]></dc:creator>
            <pubDate>Thu, 12 Nov 2026 10:31:01 GMT</pubDate>
            <atom:updated>2026-11-12T10:31:01.927Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eUjW-Ct6ejOuucS7dob8zA.jpeg" /><figcaption>Code Editor</figcaption></figure><h3>Introduction</h3><p>GraphQL is a good fit when your client needs flexible data fetching but your backend still wants a clear, typed contract.</p><p>In this guide, we will build a small CRUD API for posts using TypeScript, TypeORM, Apollo Server, and PostgreSQL.</p><p>The final API will let us create, read, update, and delete posts through GraphQL operations.</p><h3>What we are building</h3><p>We will keep the domain intentionally small: a single Post entity with a title, content, publication flag, and timestamps.</p><p>That gives us enough surface area to cover the patterns that matter without hiding the core ideas behind a large example app.</p><p>By the end, the project will have these pieces:</p><ul><li>A PostgreSQL database connection managed by TypeORM.</li><li>A Post entity mapped to a database table.</li><li>GraphQL types, queries, and mutations.</li><li>Resolvers that call the database through TypeORM repositories.</li><li>An Apollo Server endpoint you can test in a browser or API client.</li></ul><h3>Prerequisites</h3><p>You will need Node.js, npm, PostgreSQL, and a basic understanding of TypeScript.</p><p>You should also have a PostgreSQL database available locally or through a hosted provider.</p><p>The examples below use npm, but the same setup works with pnpm or yarn if you prefer those tools.</p><h3>Create the project</h3><p>Start with a new folder and initialize a TypeScript project.</p><pre>mkdir graphql-crud-api<br>cd graphql-crud-api<br>npm init -y</pre><p>Install the runtime dependencies.</p><pre>npm install @apollo/server graphql typeorm pg reflect-metadata dotenv</pre><p>Then install the development dependencies.</p><pre>npm install -D typescript ts-node-dev @types/node</pre><p>Create a TypeScript configuration file.</p><pre>npx tsc --init</pre><p>Update the important compiler options so decorators and Node-style modules work correctly.</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;target&quot;: &quot;ES2020&quot;,<br>    &quot;module&quot;: &quot;CommonJS&quot;,<br>    &quot;moduleResolution&quot;: &quot;Node&quot;,<br>    &quot;rootDir&quot;: &quot;src&quot;,<br>    &quot;outDir&quot;: &quot;dist&quot;,<br>    &quot;strict&quot;: true,<br>    &quot;esModuleInterop&quot;: true,<br>    &quot;experimentalDecorators&quot;: true,<br>    &quot;emitDecoratorMetadata&quot;: true,<br>    &quot;skipLibCheck&quot;: true<br>  }<br>}</pre><h3>Add the project scripts</h3><p>Open package.json and add scripts for development, build, and production startup.</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;dev&quot;: &quot;ts-node-dev --respawn --transpile-only src/index.ts&quot;,<br>    &quot;build&quot;: &quot;tsc&quot;,<br>    &quot;start&quot;: &quot;node dist/index.js&quot;<br>  }<br>}</pre><p>The dev script restarts the server whenever you change the source files.</p><h3>Configure the database</h3><p>Create a .env file in the project root.</p><pre>DATABASE_URL=postgres://postgres:postgres@localhost:5432/graphql_crud<br>PORT=4000</pre><p>Use your own username, password, host, port, and database name if they are different.</p><p>Now create the source folder.</p><pre>mkdir src</pre><p>Add src/data-source.ts.</p><pre>import &quot;reflect-metadata&quot;;<br>import { DataSource } from &quot;typeorm&quot;;<br>import { Post } from &quot;./entities/Post&quot;;</pre><pre>export const AppDataSource = new DataSource({<br>  type: &quot;postgres&quot;,<br>  url: process.env.DATABASE_URL,<br>  synchronize: true,<br>  logging: false,<br>  entities: [Post],<br>});</pre><p>The synchronize option is convenient while learning because TypeORM creates the table for us.</p><p>For production systems, use migrations instead. Automatic schema sync can change your database in ways you did not intend.</p><h3>Create the Post entity</h3><p>Make a folder for entities.</p><pre>mkdir src/entities</pre><p>Create src/entities/Post.ts.</p><pre>import {<br>  Entity,<br>  PrimaryGeneratedColumn,<br>  Column,<br>  CreateDateColumn,<br>  UpdateDateColumn,<br>} from &quot;typeorm&quot;;</pre><pre>@Entity()<br>export class Post {<br>  @PrimaryGeneratedColumn(&quot;uuid&quot;)<br>  id!: string;</pre><pre>  @Column({ length: 160 })<br>  title!: string;</pre><pre>  @Column(&quot;text&quot;)<br>  content!: string;</pre><pre>  @Column({ default: false })<br>  published!: boolean;</pre><pre>  @CreateDateColumn()<br>  createdAt!: Date;</pre><pre>  @UpdateDateColumn()<br>  updatedAt!: Date;<br>}</pre><p>This class is both a TypeScript model and a database mapping.</p><p>Each decorator tells TypeORM how to create and read the corresponding database column.</p><h3>Define the GraphQL schema</h3><p>GraphQL needs a schema that describes the operations clients can call and the data those operations return.</p><p>Create src/schema.ts.</p><pre>export const typeDefs = `#graphql<br>  type Post {<br>    id: ID!<br>    title: String!<br>    content: String!<br>    published: Boolean!<br>    createdAt: String!<br>    updatedAt: String!<br>  }</pre><pre>  input CreatePostInput {<br>    title: String!<br>    content: String!<br>    published: Boolean<br>  }</pre><pre>  input UpdatePostInput {<br>    title: String<br>    content: String<br>    published: Boolean<br>  }</pre><pre>  type Query {<br>    posts: [Post!]!<br>    post(id: ID!): Post<br>  }</pre><pre>  type Mutation {<br>    createPost(input: CreatePostInput!): Post!<br>    updatePost(id: ID!, input: UpdatePostInput!): Post!<br>    deletePost(id: ID!): Boolean!<br>  }<br>`;</pre><p>The Query type handles reads. The Mutation type handles writes.</p><p>Inputs keep mutation arguments organized, especially as your objects grow.</p><h3>Add the resolvers</h3><p>Resolvers contain the actual behavior behind the schema.</p><p>Create src/resolvers.ts.</p><pre>import { GraphQLError } from &quot;graphql&quot;;<br>import { AppDataSource } from &quot;./data-source&quot;;<br>import { Post } from &quot;./entities/Post&quot;;</pre><pre>type CreatePostInput = {<br>  title: string;<br>  content: string;<br>  published?: boolean;<br>};</pre><pre>type UpdatePostInput = Partial&lt;CreatePostInput&gt;;</pre><pre>const postRepository = () =&gt; AppDataSource.getRepository(Post);</pre><pre>async function findPostOrThrow(id: string) {<br>  const post = await postRepository().findOneBy({ id });</pre><pre>  if (!post) {<br>    throw new GraphQLError(&quot;Post not found&quot;, {<br>      extensions: { code: &quot;NOT_FOUND&quot; },<br>    });<br>  }</pre><pre>  return post;<br>}</pre><pre>export const resolvers = {<br>  Query: {<br>    posts: async () =&gt; {<br>      return postRepository().find({ order: { createdAt: &quot;DESC&quot; } });<br>    },<br>    post: async (_: unknown, { id }: { id: string }) =&gt; {<br>      return postRepository().findOneBy({ id });<br>    },<br>  },</pre><pre>  Mutation: {<br>    createPost: async (_: unknown, { input }: { input: CreatePostInput }) =&gt; {<br>      const post = postRepository().create({<br>        title: input.title,<br>        content: input.content,<br>        published: input.published ?? false,<br>      });</pre><pre>      return postRepository().save(post);<br>    },</pre><pre>    updatePost: async (<br>      _: unknown,<br>      { id, input }: { id: string; input: UpdatePostInput }<br>    ) =&gt; {<br>      const post = await findPostOrThrow(id);<br>      postRepository().merge(post, input);<br>      return postRepository().save(post);<br>    },</pre><pre>    deletePost: async (_: unknown, { id }: { id: string }) =&gt; {<br>      const result = await postRepository().delete(id);<br>      return result.affected === 1;<br>    },<br>  },<br>};</pre><p>Notice that the schema stays focused on the API contract, while the resolver file handles database behavior.</p><p>That separation keeps the API easier to change as the app grows.</p><h3>Start Apollo Server</h3><p>Now wire everything together in src/index.ts.</p><pre>import &quot;dotenv/config&quot;;<br>import { ApolloServer } from &quot;@apollo/server&quot;;<br>import { startStandaloneServer } from &quot;@apollo/server/standalone&quot;;<br>import { AppDataSource } from &quot;./data-source&quot;;<br>import { resolvers } from &quot;./resolvers&quot;;<br>import { typeDefs } from &quot;./schema&quot;;</pre><pre>async function bootstrap() {<br>  await AppDataSource.initialize();</pre><pre>  const server = new ApolloServer({<br>    typeDefs,<br>    resolvers,<br>  });</pre><pre>  const { url } = await startStandaloneServer(server, {<br>    listen: { port: Number(process.env.PORT) || 4000 },<br>  });</pre><pre>  console.log(`GraphQL API ready at ${url}`);<br>}</pre><pre>bootstrap().catch((error) =&gt; {<br>  console.error(error);<br>  process.exit(1);<br>});</pre><p>The server initializes the database first, then starts Apollo.</p><p>That order matters because resolvers depend on the TypeORM data source.</p><h3>Run the API</h3><p>Make sure your PostgreSQL database exists, then start the development server.</p><pre>npm run dev</pre><p>Open the printed URL, usually <a href="http://localhost:4000,">http://localhost:4000,</a> and Apollo Sandbox should load.</p><p>You can now run your first mutation.</p><pre>mutation CreatePost {<br>  createPost(<br>    input: {<br>      title: &quot;Learning GraphQL with TypeScript&quot;<br>      content: &quot;This post was created through a GraphQL mutation.&quot;<br>      published: true<br>    }<br>  ) {<br>    id<br>    title<br>    published<br>    createdAt<br>  }<br>}</pre><p>Copy the returned id, then query a single post.</p><pre>query GetPost($id: ID!) {<br>  post(id: $id) {<br>    id<br>    title<br>    content<br>    published<br>    createdAt<br>    updatedAt<br>  }<br>}</pre><p>Use this variables object.</p><pre>{<br>  &quot;id&quot;: &quot;paste-the-id-here&quot;<br>}</pre><p>You can also fetch every post.</p><pre>query GetPosts {<br>  posts {<br>    id<br>    title<br>    published<br>    createdAt<br>  }<br>}</pre><h3>Update and delete posts</h3><p>Run an update mutation to change only the fields you need.</p><pre>mutation UpdatePost($id: ID!) {<br>  updatePost(<br>    id: $id<br>    input: {<br>      title: &quot;Updated GraphQL CRUD Post&quot;<br>      published: false<br>    }<br>  ) {<br>    id<br>    title<br>    published<br>    updatedAt<br>  }<br>}</pre><p>Then delete a post with its id.</p><pre>mutation DeletePost($id: ID!) {<br>  deletePost(id: $id)<br>}</pre><p>Returning a Boolean for deletion keeps the example simple.</p><p>In a larger API, you may prefer returning the deleted object or a structured payload with an error field.</p><h3>Recommended project structure</h3><p>At this point, the project should look like this.</p><pre>graphql-crud-api/<br>  src/<br>    entities/<br>      Post.ts<br>    data-source.ts<br>    index.ts<br>    resolvers.ts<br>    schema.ts<br>  .env<br>  package.json<br>  tsconfig.json</pre><p>This structure is small enough for a tutorial, but it can grow naturally.</p><p>As your API expands, split resolvers by feature and move input types into their own files.</p><h3>Validation and production notes</h3><p>The example above is intentionally minimal, so there are a few things you should add before using this pattern in production.</p><p>First, validate input. GraphQL checks types, but it will not enforce business rules such as title length or forbidden words.</p><p>Second, add authentication and authorization. Not every user should be able to create, update, or delete every record.</p><p>Third, replace synchronize with migrations. Migrations make database changes explicit, reviewable, and repeatable.</p><p>Fourth, add tests for resolvers. Resolver tests give you fast confidence that the API contract still matches the database behavior.</p><h3>Conclusion</h3><p>You now have a working GraphQL CRUD API built with TypeScript, TypeORM, Apollo Server, and PostgreSQL.</p><p>The important pattern is simple: entities describe the database, the schema describes the API, and resolvers connect the two.</p><p>Once that separation feels natural, adding new models becomes much less intimidating.</p><p>From here, good next steps are adding users, protecting mutations, introducing migrations, and deploying the API behind a real client.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89f143a9360f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Convert Any Video to MP3 or WAV Locally for Free with FFmpeg]]></title>
            <link>https://medium.com/@williampepple/convert-any-video-to-mp3-or-wav-locally-for-free-with-ffmpeg-c2d49f485904?source=rss-1e6093bc45bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2d49f485904</guid>
            <category><![CDATA[ffmpeg]]></category>
            <category><![CDATA[audio]]></category>
            <category><![CDATA[audio-engineering]]></category>
            <dc:creator><![CDATA[William Pepple]]></dc:creator>
            <pubDate>Wed, 14 Oct 2026 10:55:44 GMT</pubDate>
            <atom:updated>2026-10-14T10:55:44.515Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nAl0qzp5jPoH3Ipsx460oQ.png" /></figure><p>If you have a video file and only need the audio, you do not need an online converter, a paid app, or a cloud upload. You can do the whole conversion locally, for free, with FFmpeg.</p><p>FFmpeg is a powerful open-source command-line tool for working with video and audio files. It can extract audio from almost any video format and save it as .mp3, .wav, .m4a, .flac, and many others.</p><p>The biggest advantage: your files stay on your computer.</p><h3>Why Use FFmpeg?</h3><p>Online converters are convenient, but they come with trade-offs. You may have to upload private files, wait for a server to process them, deal with file size limits, or sit through ads and pop-ups.</p><p>FFmpeg avoids all of that.</p><p>With FFmpeg, you can:</p><ul><li>Convert videos locally</li><li>Extract audio without uploading anything</li><li>Process large files</li><li>Batch convert multiple videos</li><li>Choose audio quality and format</li><li>Use it completely free</li></ul><p>Once installed, the actual conversion usually takes one command.</p><h3>Install FFmpeg</h3><p>On macOS with Homebrew:</p><pre>brew install ffmpeg</pre><p>On Windows with Chocolatey:</p><pre>choco install ffmpeg</pre><p>Or with winget:</p><pre>winget install Gyan.FFmpeg</pre><p>On Ubuntu or Debian:</p><pre>sudo apt update<br>sudo apt install ffmpeg</pre><p>To confirm it is installed, run:</p><pre>ffmpeg -version</pre><p>If you see version information, you are ready.</p><h3>Convert a Video to MP3</h3><p>To extract audio from a video and save it as an MP3:</p><pre>ffmpeg -i input.mp4 output.mp3</pre><p>Replace input.mp4 with your video file name and output.mp3 with the name you want for the audio file.</p><p>Example:</p><pre>ffmpeg -i interview.mp4 interview.mp3</pre><p>That command reads the video, extracts the audio, and encodes it as an MP3 file.</p><h3>Choose MP3 Quality</h3><p>For better control over quality, use -q:a.</p><pre>ffmpeg -i input.mp4 -q:a 2 output.mp3</pre><p>Lower values mean better quality. A good range is:</p><pre>0 = highest quality<br>2 = very good quality<br>5 = decent quality<br>9 = lowest quality</pre><p>For most uses, this is a solid choice:</p><pre>ffmpeg -i input.mp4 -q:a 2 output.mp3</pre><h3>Convert a Video to WAV</h3><p>WAV files are larger than MP3 files, but they are uncompressed and useful for editing, archiving, transcription workflows, or audio production.</p><p>To convert a video to WAV:</p><pre>ffmpeg -i input.mp4 output.wav</pre><p>Example:</p><pre>ffmpeg -i lecture.mov lecture.wav</pre><p>If you want a standard WAV format with 44.1 kHz audio:</p><pre>ffmpeg -i input.mp4 -ar 44100 output.wav</pre><p>For 48 kHz, which is common in video production:</p><pre>ffmpeg -i input.mp4 -ar 48000 output.wav</pre><h3>Extract Audio Without Re-encoding</h3><p>Sometimes the video already contains audio in a format you want to keep. If you do not need MP3 or WAV specifically, you can copy the audio stream without re-encoding:</p><pre>ffmpeg -i input.mp4 -vn -acodec copy output.m4a</pre><p>The -vn option tells FFmpeg to ignore the video stream.</p><p>This is faster and preserves the original audio quality, but it only works when the output format supports the original audio codec.</p><h3>Convert Only Part of a Video</h3><p>To extract audio from a specific section, use -ss for the start time and -t for the duration.</p><p>Example: extract 60 seconds starting at the 2-minute mark:</p><pre>ffmpeg -ss 00:02:00 -i input.mp4 -t 00:01:00 output.mp3</pre><p>You can also make a WAV clip:</p><pre>ffmpeg -ss 00:02:00 -i input.mp4 -t 00:01:00 output.wav</pre><h3>Batch Convert Multiple Videos</h3><p>If you have many .mp4 files in one folder, you can convert them all.</p><p>On macOS or Linux:</p><pre>for file in *.mp4; do<br>  ffmpeg -i &quot;$file&quot; &quot;${file%.mp4}.mp3&quot;<br>done</pre><p>On Windows PowerShell:</p><pre>Get-ChildItem *.mp4 | ForEach-Object {<br>  ffmpeg -i $_.FullName &quot;$($_.BaseName).mp3&quot;<br>}</pre><p>For WAV instead:</p><pre>Get-ChildItem *.mp4 | ForEach-Object {<br>  ffmpeg -i $_.FullName &quot;$($_.BaseName).wav&quot;<br>}</pre><h3>MP3 vs WAV: Which Should You Use?</h3><p>Use MP3 when you want a smaller file that is easy to share, upload, or store. It is great for podcasts, voice notes, music previews, and general listening.</p><p>Use WAV when you want maximum quality or plan to edit the audio afterward. WAV files are much larger, but they preserve more detail because they are uncompressed.</p><p>A simple rule:</p><pre>Use MP3 for listening and sharing.<br>Use WAV for editing and production.</pre><h3>Final Thoughts</h3><p>FFmpeg may look intimidating at first because it runs in the terminal, but for converting video to audio, the commands are simple.</p><p>For MP3:</p><pre>ffmpeg -i input.mp4 -q:a 2 output.mp3</pre><p>For WAV:</p><pre>ffmpeg -i input.mp4 output.wav</pre><p>That is all you need to convert videos into audio locally, privately, and for free.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2d49f485904" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL vs. NoSQL Databases: Choosing the Right Tool for the System]]></title>
            <link>https://medium.com/@williampepple/sql-vs-nosql-databases-choosing-the-right-tool-for-the-system-0bd3c58dd540?source=rss-1e6093bc45bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/0bd3c58dd540</guid>
            <category><![CDATA[nosql]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[William Pepple]]></dc:creator>
            <pubDate>Tue, 13 Oct 2026 11:19:00 GMT</pubDate>
            <atom:updated>2026-10-13T11:19:00.398Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q5Cc1DpnLDEOyPdFRAGdUA.jpeg" /></figure><p>Databases sit at the center of most modern software systems. Whether an application is storing user accounts, financial transactions, product catalogs, chat messages, analytics events, or social media posts, it needs a reliable way to organize and retrieve data.</p><p>Two of the most common database categories are <strong>SQL databases</strong> and <strong>NoSQL databases</strong>. Both are powerful, but they are built around different assumptions. Understanding the difference between them helps developers choose the right database for the kind of system they are building.</p><h3>What Is a SQL Database?</h3><p>SQL databases are relational databases. They store data in structured tables made up of rows and columns. Each table represents a type of entity, such as users, orders, products, or payments. Relationships between tables are usually defined through keys.</p><p>For example, an e-commerce system might have one table for customers, one for orders, and another for order items. These tables can be connected so the system knows which customer placed which order and which products were included.</p><p>SQL databases use <strong>Structured Query Language</strong>, or SQL, to read and manipulate data. Popular SQL databases include PostgreSQL, MySQL, Microsoft SQL Server, Oracle Database, and SQLite.</p><p>The major strength of SQL databases is structure. They are excellent when data needs to be consistent, predictable, and strongly connected.</p><h3>What Is a NoSQL Database?</h3><p>NoSQL databases are non-relational databases. Instead of requiring data to fit into fixed tables, they allow more flexible data models. NoSQL databases can store data as documents, key-value pairs, wide-column records, or graphs.</p><p>A document database, for example, might store a user profile as one JSON-like document containing the user’s name, preferences, settings, and recent activity. This can make NoSQL databases convenient when the shape of the data changes often.</p><p>Popular NoSQL databases include MongoDB, Cassandra, Redis, DynamoDB, Couchbase, and Neo4j.</p><p>The major strength of NoSQL databases is flexibility and scalability. They are often used when systems need to handle large volumes of data, fast writes, distributed infrastructure, or rapidly changing data structures.</p><h3>The Major Difference</h3><p>The biggest difference between SQL and NoSQL databases is how they model data.</p><p>SQL databases are best when data is highly structured and relationships matter. They enforce schemas, meaning the database expects data to follow a defined format. This helps protect data quality and makes complex queries easier.</p><p>NoSQL databases are best when data is flexible, large-scale, or less relational. They often allow developers to store data in a format closer to how the application uses it. This can improve speed and development flexibility, especially in systems with changing requirements.</p><p>In simple terms:</p><p><strong>SQL databases prioritize structure, consistency, and relationships.</strong></p><p><strong>NoSQL databases prioritize flexibility, scale, and performance across distributed systems.</strong></p><h3>When SQL Databases Are the Best Fit</h3><p>SQL databases are well suited for systems where accuracy and consistency are critical.</p><p>Financial systems are a classic example. A banking application needs to make sure money is never accidentally duplicated, lost, or recorded incorrectly. If one account is debited, another account must be credited reliably. SQL databases are strong in these situations because they support transactions and consistency guarantees.</p><p>SQL databases are also a good fit for business applications such as inventory systems, customer relationship management platforms, booking systems, enterprise software, and reporting tools. These systems usually have clear relationships between entities and require precise querying.</p><p>A SQL database is usually the better choice when:</p><ul><li>The data has a clear structure.</li><li>Relationships between records are important.</li><li>Complex queries and reports are needed.</li><li>Data consistency matters more than extreme flexibility.</li><li>The system handles transactions, payments, orders, or records of truth.</li></ul><h3>When NoSQL Databases Are the Best Fit</h3><p>NoSQL databases are often better for systems that need flexibility, speed, or massive scale.</p><p>For example, a social media platform may need to store posts, comments, likes, notifications, and user activity at enormous volume. The structure of that data may change over time as new features are added. A NoSQL database can make it easier to scale horizontally and handle large amounts of fast-moving data.</p><p>NoSQL databases are also useful for real-time analytics, content management, recommendation systems, IoT data, caching, messaging, and applications with highly variable data.</p><p>A NoSQL database is usually the better choice when:</p><ul><li>The data structure changes frequently.</li><li>The system needs to scale across many servers.</li><li>The application handles huge volumes of reads or writes.</li><li>Data is naturally stored as documents, key-value pairs, or graphs.</li><li>Speed and flexibility are more important than complex relational queries.</li></ul><h3>It Is Not Always Either-Or</h3><p>In real-world systems, SQL and NoSQL are often used together.</p><p>An online store might use PostgreSQL for orders and payments, because those records need strong consistency. The same system might use Redis for caching, Elasticsearch for search, and MongoDB for flexible product metadata.</p><p>This approach is called using the right database for the right job. Instead of forcing every kind of data into one system, modern applications often combine multiple storage technologies based on the needs of each feature.</p><h3>Final Thought</h3><p>SQL and NoSQL databases are not enemies. They are different tools designed for different kinds of problems.</p><p>SQL databases are ideal when the system needs structure, relationships, transactions, and reliability. NoSQL databases are ideal when the system needs flexibility, speed, distribution, and large-scale data handling.</p><p>The best database choice depends on the system being built. A good engineer does not ask, “Which database is better?” Instead, they ask, “What does this system need most?”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0bd3c58dd540" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handling Arrays in TypeORM and PostgreSQL.]]></title>
            <link>https://medium.com/@williampepple/handling-arrays-in-typeorm-and-postgresql-c039aa97ef56?source=rss-1e6093bc45bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/c039aa97ef56</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[typeorm]]></category>
            <category><![CDATA[arrays]]></category>
            <dc:creator><![CDATA[William Pepple]]></dc:creator>
            <pubDate>Thu, 08 Oct 2026 16:31:02 GMT</pubDate>
            <atom:updated>2026-10-08T16:31:02.138Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d5LuiUvwaLnJFXsE_frjqw.jpeg" /><figcaption>A Programmer writing code.</figcaption></figure><p><em>Have you ever tried to send arrays to the Backend and had issues with validating/handling arrays? Hold my drink, I will show you how to do so.</em></p><p>First things first, let me introduce Jsonb to you, Have you ever tried to send arrays to the backend and had issues validating or handling them? Hold my drink, I will show you how to do it.First things first, let me introduce `jsonb`. `jsonb` is a PostgreSQL data type used to store JSON data in a binary format. It is efficient, flexible, and very useful when you need to store structured data like arrays or objects.In TypeORM, `jsonb` is especially handy when you want to save an array without creating a separate table.</p><p><strong>The Problem</strong></p><p>Let’s say you are building an API where users can add multiple tags to a post. The request body may look like this:</p><pre><br>{<br>  &quot;title&quot;: &quot;My first post&quot;,<br>  &quot;tags&quot;: [&quot;nestjs&quot;, &quot;typeorm&quot;, &quot;postgresql&quot;]<br>}</pre><p>At first, you might think:</p><p>“Okay, I will just save tags as an array.”</p><p>But depending on how your entity is configured, PostgreSQL and TypeORM may not handle it the way you expect.</p><p>You may run into validation errors, migration issues, or weird behavior when trying to save and retrieve the data.</p><h3>The Simple Fix: Use jsonb</h3><p>Instead of fighting with PostgreSQL array types, you can store the value as jsonb.</p><p>Here is an example entity:</p><pre>import { Column, Entity, PrimaryGeneratedColumn } from &#39;typeorm&#39;;</pre><pre>@Entity()<br>export class Post {<br>  @PrimaryGeneratedColumn(&#39;uuid&#39;)<br>  id: string;</pre><pre>  @Column()<br>  title: string;</pre><pre>  @Column({<br>    type: &#39;jsonb&#39;,<br>    default: [],<br>  })<br>  tags: string[];<br>}</pre><p>With this setup, TypeORM will store the tags field as JSON data in PostgreSQL.</p><p>That means this:</p><pre>[&#39;nestjs&#39;, &#39;typeorm&#39;, &#39;postgresql&#39;]</pre><p>will be saved properly and returned as an array when you fetch the record.</p><h3>Validating the Array</h3><p>If you are using NestJS, you should also validate the incoming request body.</p><p>Here is an example DTO:</p><pre>import { IsArray, IsString, ArrayNotEmpty } from &#39;class-validator&#39;;</pre><pre>export class CreatePostDto {<br>  @IsString()<br>  title: string;</pre><pre>  @IsArray()<br>  @ArrayNotEmpty()<br>  @IsString({ each: true })<br>  tags: string[];<br>}</pre><p>Let’s break this down.</p><p>@IsArray() ensures that tags is actually an array.</p><p>@ArrayNotEmpty() ensures that the array is not empty.</p><p>@IsString({ each: true }) ensures that every item inside the array is a string.</p><p>So this will pass:</p><pre>{<br>  &quot;title&quot;: &quot;Learning TypeORM&quot;,<br>  &quot;tags&quot;: [&quot;backend&quot;, &quot;database&quot;]<br>}</pre><p>But this will fail:</p><pre>{<br>  &quot;title&quot;: &quot;Learning TypeORM&quot;,<br>  &quot;tags&quot;: &quot;backend&quot;<br>}</pre><p>And this will also fail:</p><pre>{<br>  &quot;title&quot;: &quot;Learning TypeORM&quot;,<br>  &quot;tags&quot;: [&quot;backend&quot;, 123]<br>}</pre><h3>Saving the Data</h3><p>Once your entity and DTO are ready, saving the data is straightforward.</p><pre>async createPost(createPostDto: CreatePostDto) {<br>  const post = this.postRepository.create(createPostDto);</pre><pre>  return await this.postRepository.save(post);<br>}</pre><p>TypeORM will take the array from the request body and save it into the jsonb column.</p><p>No extra conversion is needed.</p><h3>Fetching the Data</h3><p>When you fetch the record, TypeORM returns the tags field as an array.</p><pre>const post = await this.postRepository.findOne({<br>  where: { id },<br>});</pre><pre>console.log(post.tags);</pre><p>The output will be:</p><pre>[&#39;nestjs&#39;, &#39;typeorm&#39;, &#39;postgresql&#39;]</pre><p>This makes it easy to use the data directly in your application.</p><h3>When Should You Use jsonb?</h3><p>Use jsonb when the array belongs directly to the record and does not need its own relationship.</p><p>Good examples include:</p><pre>tags: string[];<br>permissions: string[];<br>metadata: object;<br>socialLinks: object[];<br>settings: object;</pre><p>But if the array represents real entities with their own fields, relationships, or queries, you should consider using a separate table.</p><p>For example, if each tag has an id, name, slug, and is shared across many posts, then a Tag entity with a relationship is better.</p><h3>jsonb vs simple-array</h3><p>TypeORM also has a simple-array column type.</p><p>Example:</p><pre>@Column(&#39;simple-array&#39;)<br>tags: string[];</pre><p>This stores the array as a comma-separated string.</p><p>So this:</p><pre>[&#39;nestjs&#39;, &#39;typeorm&#39;, &#39;postgresql&#39;]</pre><p>becomes something like this in the database:</p><pre>nestjs,typeorm,postgresql</pre><p>It works for very basic arrays, but it has limitations.</p><p>If your values contain commas, things can get messy.</p><p>That is why I prefer jsonb for most real-world use cases.</p><h3>Querying jsonb Arrays</h3><p>You can also query jsonb columns in PostgreSQL.</p><p>For example, if you want to find posts that contain a specific tag:</p><pre>const posts = await this.postRepository<br>  .createQueryBuilder(&#39;post&#39;)<br>  .where(&#39;post.tags @&gt; :tag&#39;, {<br>    tag: JSON.stringify([&#39;nestjs&#39;]),<br>  })<br>  .getMany();</pre><p>The @&gt; operator checks whether the jsonb column contains the given value.</p><p>So if a post has this:</p><pre>[&quot;nestjs&quot;, &quot;typeorm&quot;, &quot;postgresql&quot;]</pre><p>It will match when you search for:</p><pre>[&quot;nestjs&quot;]</pre><h3>Final Thoughts</h3><p>Handling arrays in TypeORM does not have to be stressful.</p><p>If you only need to store and retrieve an array, jsonb is usually a clean and practical option.</p><p>You get proper array support, better flexibility than simple-array, and fewer headaches when working with structured data.</p><p>So the next time you need to send arrays to your backend, validate them properly, store them as jsonb, and keep it moving.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c039aa97ef56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a simple task manager in Golang using Buffalo framework.]]></title>
            <link>https://medium.com/@williampepple/build-a-simple-task-manager-in-golang-using-buffalo-framework-ee224b0d2a77?source=rss-1e6093bc45bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee224b0d2a77</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[bufallo]]></category>
            <dc:creator><![CDATA[William Pepple]]></dc:creator>
            <pubDate>Fri, 02 Oct 2026 15:20:42 GMT</pubDate>
            <atom:updated>2026-10-02T15:20:42.323Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sYdEPVfxSn1fD70NhZVVIQ.png" /></figure><p>Go is a buzzing language people talk about on the internet. If you have learned the basics and want to build a simple backend app, this guide will walk you through one with Buffalo.</p><p>Hold my coffee and let us dive right into it.</p><h3>What we are building</h3><p>In this tutorial, we will build a small task manager with Buffalo. The app will let us create tasks, list them on a page, mark them as done, and delete the ones we no longer need.</p><p>The point is not to build the next productivity unicorn. The point is to touch the parts you need in most backend apps: routing, handlers, models, migrations, forms, templates, and database queries.</p><p>Buffalo is useful because it gives Go developers a Rails-like workflow. You still write Go, but you also get a project generator, database tooling, hot reload, templates, and a familiar app structure.</p><h3>Prerequisites</h3><p>Before we start, make sure you have Go installed and working on your machine.</p><p>Buffalo also needs the Buffalo CLI. On macOS you can install it with Homebrew:</p><pre>brew install gobuffalo/tap/buffalo</pre><p>On Windows, you can use Scoop or Chocolatey:</p><pre>scoop install buffalo<br># or<br>choco install buffalo</pre><p>You can also install it with Go:</p><pre>go install github.com/gobuffalo/cli/cmd/buffalo@latest</pre><p>If you plan to use SQLite, install Buffalo with SQLite support and make sure you have a C compiler available:</p><pre>go install -tags sqlite github.com/gobuffalo/cli/cmd/buffalo@latest</pre><p>Confirm the CLI is available:</p><pre>buffalo version</pre><h3>Create the Buffalo project</h3><p>Now create a new app. I will call mine task_manager:</p><pre>buffalo new task_manager --db-type sqlite3</pre><p>Move into the project folder:</p><pre>cd task_manager</pre><p>Buffalo creates a full project structure for you. The most important folders for this tutorial are:</p><p>actions/ contains route handlers. models/ contains database models. templates/ contains Plush templates. migrations/ contains database changes.</p><p>Run setup, then start the development server:</p><pre>buffalo setup<br>buffalo dev</pre><p>Open http://localhost:3000. If you see the Buffalo welcome page, your app is alive.</p><h3>Create the Task model</h3><p>Our task model needs three fields: a title, a description, and a boolean that says whether the task is completed.</p><p>Generate the model and migration:</p><pre>buffalo generate model task title:string description:text completed:bool</pre><p>This creates a model file and migration files. Open the generated migration and make sure the default value for completed is false if your generated file does not already do that.</p><p>Run the migration:</p><pre>buffalo pop migrate</pre><p>Buffalo uses Pop for database work. In Buffalo projects, Pop commands are available under buffalo pop, so you do not need to install Soda separately for this tutorial.</p><h3>Add routes</h3><p>Open actions/app.go. This is where the application routes are registered.</p><p>Add the routes for the task manager:</p><pre>app.GET(&quot;/&quot;, TasksIndex)<br>app.GET(&quot;/tasks/new&quot;, TasksNew)<br>app.POST(&quot;/tasks&quot;, TasksCreate)<br>app.PUT(&quot;/tasks/{task_id}/complete&quot;, TasksComplete)<br>app.DELETE(&quot;/tasks/{task_id}&quot;, TasksDelete)</pre><p>The first route shows all tasks. The second shows the form. The third creates a task. The fourth marks a task as completed. The fifth deletes a task.</p><h3>Write the handlers</h3><p>Create a new file named actions/tasks.go.</p><pre>package actions</pre><pre>import (<br>    &quot;net/http&quot;</pre><pre>    &quot;github.com/gobuffalo/buffalo&quot;<br>    &quot;github.com/gobuffalo/pop/v6&quot;<br>    &quot;github.com/pkg/errors&quot;<br>    &quot;task_manager/models&quot;<br>)</pre><pre>func TasksIndex(c buffalo.Context) error {<br>    tx := c.Value(&quot;tx&quot;).(*pop.Connection)<br>    tasks := &amp;models.Tasks{}</pre><pre>    if err := tx.All(tasks); err != nil {<br>        return errors.WithStack(err)<br>    }</pre><pre>    c.Set(&quot;tasks&quot;, tasks)<br>    return c.Render(http.StatusOK, r.HTML(&quot;tasks/index.plush.html&quot;))<br>}</pre><pre>func TasksNew(c buffalo.Context) error {<br>    c.Set(&quot;task&quot;, &amp;models.Task{})<br>    return c.Render(http.StatusOK, r.HTML(&quot;tasks/new.plush.html&quot;))<br>}</pre><pre>func TasksCreate(c buffalo.Context) error {<br>    tx := c.Value(&quot;tx&quot;).(*pop.Connection)<br>    task := &amp;models.Task{}</pre><pre>    if err := c.Bind(task); err != nil {<br>        return errors.WithStack(err)<br>    }</pre><pre>    if err := tx.Create(task); err != nil {<br>        c.Set(&quot;task&quot;, task)<br>        return c.Render(http.StatusUnprocessableEntity, r.HTML(&quot;tasks/new.plush.html&quot;))<br>    }</pre><pre>    c.Flash().Add(&quot;success&quot;, &quot;Task created successfully.&quot;)<br>    return c.Redirect(http.StatusSeeOther, &quot;/&quot;)<br>}</pre><pre>func TasksComplete(c buffalo.Context) error {<br>    tx := c.Value(&quot;tx&quot;).(*pop.Connection)<br>    task := &amp;models.Task{}</pre><pre>    if err := tx.Find(task, c.Param(&quot;task_id&quot;)); err != nil {<br>        return errors.WithStack(err)<br>    }</pre><pre>    task.Completed = true</pre><pre>    if err := tx.Update(task); err != nil {<br>        return errors.WithStack(err)<br>    }</pre><pre>    return c.Redirect(http.StatusSeeOther, &quot;/&quot;)<br>}</pre><pre>func TasksDelete(c buffalo.Context) error {<br>    tx := c.Value(&quot;tx&quot;).(*pop.Connection)<br>    task := &amp;models.Task{}</pre><pre>    if err := tx.Find(task, c.Param(&quot;task_id&quot;)); err != nil {<br>        return errors.WithStack(err)<br>    }</pre><pre>    if err := tx.Destroy(task); err != nil {<br>        return errors.WithStack(err)<br>    }</pre><pre>    c.Flash().Add(&quot;success&quot;, &quot;Task deleted.&quot;)<br>    return c.Redirect(http.StatusSeeOther, &quot;/&quot;)<br>}</pre><p>The handlers follow a simple pattern. Get the database connection, load or bind the model, perform the database action, and render or redirect.</p><p>This is the kind of rhythm that makes Buffalo pleasant. Once you understand one handler, the next one feels familiar.</p><h3>Create the templates</h3><p>Now create the folder templates/tasks.</p><p>Add templates/tasks/index.plush.html:</p><pre>&lt;h1&gt;Tasks&lt;/h1&gt;</pre><pre>&lt;p&gt;<br>  &lt;a href=&quot;/tasks/new&quot;&gt;New task&lt;/a&gt;<br>&lt;/p&gt;</pre><pre>&lt;%= for (task) in tasks { %&gt;<br>  &lt;article&gt;<br>    &lt;h2&gt;&lt;%= task.Title %&gt;&lt;/h2&gt;<br>    &lt;p&gt;&lt;%= task.Description %&gt;&lt;/p&gt;</pre><pre>    &lt;%= if (task.Completed) { %&gt;<br>      &lt;p&gt;Status: Done&lt;/p&gt;<br>    &lt;% } else { %&gt;<br>      &lt;form action=&quot;/tasks/&lt;%= task.ID %&gt;/complete&quot; method=&quot;POST&quot;&gt;<br>        &lt;input type=&quot;hidden&quot; name=&quot;_method&quot; value=&quot;PUT&quot;&gt;<br>        &lt;button type=&quot;submit&quot;&gt;Mark as done&lt;/button&gt;<br>      &lt;/form&gt;<br>    &lt;% } %&gt;</pre><pre>    &lt;form action=&quot;/tasks/&lt;%= task.ID %&gt;&quot; method=&quot;POST&quot;&gt;<br>      &lt;input type=&quot;hidden&quot; name=&quot;_method&quot; value=&quot;DELETE&quot;&gt;<br>      &lt;button type=&quot;submit&quot;&gt;Delete&lt;/button&gt;<br>    &lt;/form&gt;<br>  &lt;/article&gt;<br>&lt;% } %&gt;</pre><p>Add templates/tasks/new.plush.html:</p><pre>&lt;h1&gt;New task&lt;/h1&gt;</pre><pre>&lt;form action=&quot;/tasks&quot; method=&quot;POST&quot;&gt;<br>  &lt;div&gt;<br>    &lt;label for=&quot;title&quot;&gt;Title&lt;/label&gt;<br>    &lt;input id=&quot;title&quot; name=&quot;Title&quot; type=&quot;text&quot; value=&quot;&lt;%= task.Title %&gt;&quot;&gt;<br>  &lt;/div&gt;</pre><pre>  &lt;div&gt;<br>    &lt;label for=&quot;description&quot;&gt;Description&lt;/label&gt;<br>    &lt;textarea id=&quot;description&quot; name=&quot;Description&quot;&gt;&lt;%= task.Description %&gt;&lt;/textarea&gt;<br>  &lt;/div&gt;</pre><pre>  &lt;button type=&quot;submit&quot;&gt;Create task&lt;/button&gt;<br>&lt;/form&gt;</pre><p>The hidden _method inputs are important because browser forms only support GET and POST directly. Buffalo can use that field to treat the request as PUT or DELETE.</p><h3>Run the app</h3><p>Start the server again:</p><pre>buffalo dev</pre><p>Visit http://localhost:3000. Create a task, mark it as done, then delete it.</p><p>If something fails, run:</p><pre>buffalo routes<br>buffalo pop migrate status</pre><p>buffalo routes confirms the paths your app knows about. buffalo pop migrate status helps you see whether the database migration actually ran.</p><h3>A small improvement</h3><p>The app works, but it trusts any input. For a real project, add validation so users cannot create empty tasks.</p><p>Open the generated task model in models/task.go and add validation inside the Validate method:</p><pre>func (t *Task) Validate(tx *pop.Connection) (*validate.Errors, error) {<br>    return validate.Validate(<br>        &amp;validators.StringIsPresent{Field: t.Title, Name: &quot;Title&quot;},<br>    ), nil<br>}</pre><p>You may need to import Buffalo validators if they are not already in the file:</p><pre>&quot;github.com/gobuffalo/validate/v3&quot;<br>&quot;github.com/gobuffalo/validate/v3/validators&quot;</pre><p>Now empty task titles will fail validation before they reach the database.</p><h3>Where to go next</h3><p>You now have a working CRUD-style Buffalo app. It is simple, but it has the skeleton of many real applications.</p><p>From here, you can add user authentication, task due dates, filtering, pagination, or an API endpoint that returns tasks as JSON.</p><p>You can also improve the interface with Bootstrap, Tailwind, or plain CSS. The backend does not care. That is one nice thing about Buffalo: it gives you structure without forcing every design decision.</p><h3>Conclusion</h3><p>Buffalo makes Go backend development feel less empty at the beginning of a project. Instead of wiring every folder, route, template, and database tool by hand, you get a productive starting point.</p><p>If you already know basic Go and want to build web apps, Buffalo is worth trying. Build this task manager first, break it a few times, fix it, then add one feature of your own.</p><p>That is how the framework starts to make sense.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee224b0d2a77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use React Date Picker to specify dates on your React project.]]></title>
            <link>https://medium.com/@williampepple/how-to-use-react-date-picker-to-specify-dates-on-your-react-project-3b16f34e5ee4?source=rss-1e6093bc45bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b16f34e5ee4</guid>
            <dc:creator><![CDATA[William Pepple]]></dc:creator>
            <pubDate>Tue, 29 Sep 2026 03:11:01 GMT</pubDate>
            <atom:updated>2026-09-29T03:11:01.650Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uiNZuN_KdbqYyvGPrW9dXw.jpeg" /></figure><p>React Date picker is a great module for working with dates on your React Project, more often than not, new users get a bit confused when they use it for the first time, the goal of this article is to make the encounter less troubling.😊</p><h3>How to get started</h3><p>You have to first of all install react-date-picker on your project. If you use npm, type in the following command in your terminal:</p><pre>npm install react-date-picker</pre><p>If you use yarn, type in the following command in your terminal:</p><pre>yarn add react-date-picker</pre><h3>Importing React Date Picker</h3><p>After installing the package, the next thing is to import it into the component where you want to use it. You will also need to import the default stylesheet, because it gives the date picker its basic layout and design.</p><pre>import DatePicker from &#39;react-date-picker&#39;;<br>import &#39;react-date-picker/dist/DatePicker.css&#39;;<br>import &#39;react-calendar/dist/Calendar.css&#39;;</pre><p>If the styles do not show up after importing the component, check that both CSS files are included. A lot of first-time errors come from importing the component but forgetting the stylesheet.</p><h3>Creating the date picker component</h3><p>React Date Picker works like most React form inputs. You keep the selected value in state, then pass that value into the DatePicker component.</p><p>Here is a simple example:</p><pre>import { useState } from &#39;react&#39;;<br>import DatePicker from &#39;react-date-picker&#39;;<br>import &#39;react-date-picker/dist/DatePicker.css&#39;;<br>import &#39;react-calendar/dist/Calendar.css&#39;;</pre><pre>function App() {<br>  const [value, setValue] = useState(new Date());</pre><pre>  return (<br>    &lt;div&gt;<br>      &lt;h2&gt;Select a date&lt;/h2&gt;<br>      &lt;DatePicker onChange={setValue} value={value} /&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><pre>export default App;</pre><p>In the code above, value is the current selected date, while setValue updates the date whenever the user chooses another one. The new Date() value makes today’s date the default selected date.</p><h3>Working with an empty date</h3><p>Sometimes you may not want any date to be selected when the page first loads. In that case, you can start with null instead of new Date().</p><pre>const [value, setValue] = useState(null);</pre><p>Then use it the same way:</p><pre>&lt;DatePicker onChange={setValue} value={value} /&gt;</pre><p>This is useful for forms where the user must choose a date by themselves, for example a booking form, registration form, or appointment form.</p><h3>Setting a minimum and maximum date</h3><p>You can also stop users from selecting dates outside a specific range. For example, if you do not want users to select a past date, you can set minDate to today.</p><pre>&lt;DatePicker<br>  onChange={setValue}<br>  value={value}<br>  minDate={new Date()}<br>/&gt;</pre><p>You can also add a maximum date:</p><pre>&lt;DatePicker<br>  onChange={setValue}<br>  value={value}<br>  minDate={new Date()}<br>  maxDate={new Date(2026, 11, 31)}<br>/&gt;</pre><p>One thing to remember is that JavaScript months start from 0. January is 0, February is 1, and December is 11. So new Date(2026, 11, 31) means December 31, 2026.</p><h3>Changing the date format</h3><p>React Date Picker allows you to control how the selected date appears by using the format prop.</p><pre>&lt;DatePicker<br>  onChange={setValue}<br>  value={value}<br>  format=&quot;dd/MM/y&quot;<br>/&gt;</pre><p>This will display the date in day/month/year format. You can change it depending on what your project needs.</p><h3>Getting the selected date</h3><p>Because the selected date is stored in state, you can use it anywhere in your component. For example, you can display the selected date under the picker.</p><pre>{value &amp;&amp; &lt;p&gt;You selected: {value.toDateString()}&lt;/p&gt;}</pre><p>You can also send the value to an API, save it in a database, or include it as part of a form submission.</p><h3>Conclusion</h3><p>React Date Picker makes it easy to add date selection to a React project. Once you understand the basic pattern of keeping the selected date in state and passing it into the DatePicker component, it becomes very simple to use.</p><p>You can start with a basic picker, then improve it by adding minimum dates, maximum dates, custom formats, and form submission logic depending on what your project requires.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b16f34e5ee4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Concatenate in SQL]]></title>
            <link>https://medium.com/@williampepple/how-to-concatenate-in-sql-cd9e13038f66?source=rss-1e6093bc45bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd9e13038f66</guid>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[William Pepple]]></dc:creator>
            <pubDate>Mon, 28 Sep 2026 12:55:42 GMT</pubDate>
            <atom:updated>2026-09-28T12:55:42.517Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fQN9qXDrp2m0HHaoxttZrg.png" /></figure><p>Concatenation is the process of joining two or more values into one string. In SQL, it is useful when you want to combine names, build readable labels, format addresses, or return a single display column from multiple fields.</p><p>The idea is simple, but the syntax changes depending on the database you use. In this article, we will look at how concatenation works in MySQL and PostgreSQL, with examples you can copy and run.</p><h3>What Is Concatenation?</h3><p>Concatenation means joining values together.</p><p>For example, imagine you have a first_name column and a last_name column. Instead of returning them separately, you can combine them into one column called full_name.</p><pre>SELECT CONCAT(first_name, &#39; &#39;, last_name) AS full_name<br>FROM users;</pre><p>If first_name is &#39;Ada&#39; and last_name is &#39;Lovelace&#39;, the result will be:</p><pre>Ada Lovelace</pre><h3>MySQL Concatenation</h3><p>In MySQL, the most common way to concatenate strings is with the CONCAT() function. It accepts two or more values and returns one combined string.</p><pre>SELECT CONCAT(&#39;Hello, &#39;, &#39;World!&#39;) AS concatenated_column;</pre><p>The result is:</p><pre>Hello, World!</pre><p>You can also concatenate column values:</p><pre>SELECT CONCAT(first_name, &#39; &#39;, last_name) AS full_name<br>FROM users;</pre><p>One important thing to know: in MySQL, if any value passed to CONCAT() is NULL, the whole result becomes NULL.</p><pre>SELECT CONCAT(&#39;Hello, &#39;, NULL) AS message;</pre><p>This returns NULL, not Hello,.</p><h3>Using CONCAT_WS() in MySQL</h3><p>MySQL also provides CONCAT_WS(), which means “concatenate with separator.” It is useful when you want to place the same separator between multiple values.</p><pre>SELECT CONCAT_WS(&#39;, &#39;, &#39;Hello&#39;, &#39;World&#39;, &#39;again&#39;) AS message;</pre><p>The result is:</p><pre>Hello, World, again</pre><p>The first argument is the separator. The remaining arguments are the values you want to join.</p><p>CONCAT_WS() is especially useful for names, addresses, tags, and comma-separated labels because it can make your query easier to read.</p><h3>PostgreSQL Concatenation</h3><p>In PostgreSQL, you can concatenate strings with the || operator.</p><pre>SELECT &#39;Hello, &#39; || &#39;World!&#39; AS concatenated_column;</pre><p>The result is:</p><pre>Hello, World!</pre><p>You can also use it with table columns:</p><pre>SELECT first_name || &#39; &#39; || last_name AS full_name<br>FROM users;</pre><p>This joins first_name, a space, and last_name into one output column.</p><p>PostgreSQL also supports a CONCAT() function, but the || operator is commonly used and easy to recognize once you get used to it.</p><h3>Handling NULL Values</h3><p>NULL values can change the result of a concatenation. In MySQL, CONCAT() returns NULL if any argument is NULL. In PostgreSQL, the || operator also returns NULL if one side of the operation is NULL.</p><p>To avoid this, use COALESCE(). It lets you provide a fallback value when a column is NULL.</p><p>MySQL example:</p><pre>SELECT CONCAT(&#39;Hello, &#39;, COALESCE(NULL, &#39;nobody!&#39;)) AS message;</pre><p>PostgreSQL example:</p><pre>SELECT &#39;Hello, &#39; || COALESCE(NULL, &#39;nobody!&#39;) AS message;</pre><p>Both examples return:</p><pre>Hello, nobody!</pre><p>You can use the same idea with table columns:</p><pre>SELECT CONCAT(<br>  COALESCE(first_name, &#39;&#39;),<br>  &#39; &#39;,<br>  COALESCE(last_name, &#39;&#39;)<br>) AS full_name<br>FROM users;</pre><p>This prevents one missing value from breaking the whole result.</p><h3>A Practical Example</h3><p>Suppose you have a products table with name, category, and sku columns. You can create a readable product label from those values.</p><p>MySQL:</p><pre>SELECT CONCAT_WS(&#39; - &#39;, name, category, sku) AS product_label<br>FROM products;</pre><p>PostgreSQL:</p><pre>SELECT name || &#39; - &#39; || category || &#39; - &#39; || sku AS product_label<br>FROM products;</pre><p>The output could look like this:</p><pre>Laptop Stand - Accessories - LS-204</pre><p>This kind of formatting is useful when building reports, dashboards, exports, or readable search results.</p><h3>Conclusion</h3><p>Concatenation in SQL helps you combine multiple values into one readable string. In MySQL, you will usually use CONCAT() or CONCAT_WS(). In PostgreSQL, you can use the || operator, and in many cases you can also use CONCAT().</p><p>The main thing to watch out for is NULL. When a value might be missing, use COALESCE() so your query returns a useful result instead of an unexpected NULL.</p><p>Once you understand these patterns, concatenation becomes one of those small SQL skills that makes your query results much cleaner and easier to work with.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd9e13038f66" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Automate Downward Merge PRs on GitHub Actions]]></title>
            <link>https://medium.com/@williampepple/how-to-automate-downward-merge-prs-on-github-actions-73a25b71159d?source=rss-1e6093bc45bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/73a25b71159d</guid>
            <dc:creator><![CDATA[William Pepple]]></dc:creator>
            <pubDate>Wed, 23 Sep 2026 20:16:01 GMT</pubDate>
            <atom:updated>2026-09-23T20:16:01.746Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EhGtJrn6Z42pEwBZ" /><figcaption>Code</figcaption></figure><p>Let’s say you quickly did a hotfix on your production environment to solve an issue or a bug. There is a probability that doing this over and over might leave room for errors, especially if the corrected feature is also supposed to be available on your staging, testing, or development environment.</p><p>One way to reduce that risk is to automate your downward merge process.</p><p>In this article, we will walk through how to create a GitHub Actions workflow that automatically opens a pull request from your production branch into a lower environment branch whenever production receives a new change.</p><h3>What is a downward merge?</h3><p>A downward merge is the process of moving changes from a higher environment branch into a lower environment branch.</p><p>For example, your branch structure might look like this:</p><pre>production -&gt; staging -&gt; development</pre><p>If you merge a hotfix directly into production, you do not want that fix to live only there. The same fix should usually move downward into staging and development so every environment stays aligned.</p><p>Without automation, someone has to remember to create those pull requests manually. That works for a while, but it becomes easy to forget when the team is moving fast.</p><h3>Why automate it?</h3><p>Automating downward merge PRs helps you:</p><ul><li>Keep branches in sync after hotfixes</li><li>Reduce repeated manual work</li><li>Avoid missing production fixes in lower environments</li><li>Make the merge process visible through pull requests</li><li>Give your team a chance to review conflicts before merging</li></ul><p>The important part is that the workflow should not silently merge code for you. It should create a pull request, then let your normal review and CI process take over.</p><h3>The GitHub Actions workflow</h3><p>Create a workflow file in your repository at:</p><pre>.github/workflows/downward-merge.yml</pre><p>Then add the following configuration:</p><pre>name: Create Downward Merge PR</pre><pre>on:<br>  push:<br>    branches:<br>      - production</pre><pre>permissions:<br>  contents: write<br>  pull-requests: write</pre><pre>jobs:<br>  create-downward-merge-pr:<br>    runs-on: ubuntu-latest</pre><pre>    steps:<br>      - name: Checkout repository<br>        uses: actions/checkout@v4</pre><pre>      - name: Create pull request from production to staging<br>        uses: repo-sync/pull-request@v2<br>        with:<br>          source_branch: production<br>          destination_branch: staging<br>          pr_title: &quot;chore: merge production into staging&quot;<br>          pr_body: |<br>            This pull request was created automatically after a change was pushed to production.</pre><pre>            Please review the changes and resolve any conflicts before merging.<br>          github_token: ${{ secrets.GITHUB_TOKEN }}</pre><p>With this workflow, every push to the production branch triggers GitHub Actions. The workflow checks out the repository and creates a pull request from production into staging.</p><h3>How it works</h3><p>The workflow listens for pushes to production:</p><pre>on:<br>  push:<br>    branches:<br>      - production</pre><p>That means it only runs when production changes. If a developer pushes to staging or development, this workflow will not run.</p><p>Next, the workflow defines the permissions it needs:</p><pre>permissions:<br>  contents: write<br>  pull-requests: write</pre><p>These permissions allow the action to read and write repository contents and create pull requests using the built-in GitHub token.</p><p>Finally, the pull request action receives the source and destination branches:</p><pre>source_branch: production<br>destination_branch: staging</pre><p>In plain English, this says: create a PR that merges production into staging.</p><h3>Extending it to multiple branches</h3><p>If your flow is production -&gt; staging -&gt; development, you can add another step to create a second PR from staging to development.</p><pre>- name: Create pull request from staging to development<br>  uses: repo-sync/pull-request@v2<br>  with:<br>    source_branch: staging<br>    destination_branch: development<br>    pr_title: &quot;chore: merge staging into development&quot;<br>    pr_body: |<br>      This pull request was created automatically to keep development aligned with staging.<br>    github_token: ${{ secrets.GITHUB_TOKEN }}</pre><p>However, be careful with this setup. If production was hotfixed and staging has not merged that change yet, creating a staging-to-development PR immediately may not include the new production changes.</p><p>A safer option is to create only the production-to-staging PR first. After that PR is reviewed and merged, another workflow can create the staging-to-development PR.</p><p>Here is what that second workflow might look like:</p><pre>name: Create Staging to Development PR</pre><pre>on:<br>  pull_request:<br>    types:<br>      - closed<br>    branches:<br>      - staging</pre><pre>permissions:<br>  contents: write<br>  pull-requests: write</pre><pre>jobs:<br>  create-development-pr:<br>    if: github.event.pull_request.merged == true<br>    runs-on: ubuntu-latest</pre><pre>    steps:<br>      - name: Checkout repository<br>        uses: actions/checkout@v4</pre><pre>      - name: Create pull request from staging to development<br>        uses: repo-sync/pull-request@v2<br>        with:<br>          source_branch: staging<br>          destination_branch: development<br>          pr_title: &quot;chore: merge staging into development&quot;<br>          pr_body: |<br>            This pull request was created automatically after staging received new changes.<br>          github_token: ${{ secrets.GITHUB_TOKEN }}</pre><p>This keeps the flow more predictable: production updates staging first, then staging updates development after the first PR has actually been merged.</p><h3>Handling existing pull requests</h3><p>One thing to keep in mind is that automation can create duplicate pull requests if the action or workflow is not configured carefully.</p><p>Before using this in a busy repository, test it in a small repo or non-critical branch setup. Also check the action’s documentation for options that control duplicate PR behavior, labels, reviewers, and conflict handling.</p><p>You can also add labels to make automated PRs easy to identify:</p><pre>pr_label: &quot;automated-pr,downward-merge&quot;</pre><p>That way, your team can quickly filter these PRs in GitHub.</p><h3>Recommended branch protection rules</h3><p>This workflow is most useful when combined with branch protection rules. For example, you can require:</p><ul><li>At least one approval before merging</li><li>CI checks to pass before merging</li><li>Conversation resolution before merging</li><li>No direct pushes to staging or development</li></ul><p>This gives you the best of both worlds: automation creates the PR, but humans and CI still control what gets merged.</p><h3>Final thoughts</h3><p>Hotfixes are sometimes unavoidable. What matters is making sure those fixes do not get trapped in production and forgotten.</p><p>By using GitHub Actions to create downward merge pull requests, you make the process visible, repeatable, and easier for your team to trust. The workflow does not need to be complicated. Start with one branch pair, test it properly, and then extend it as your release process grows.</p><p>Automation should remove the repetitive work, not remove review. A small workflow like this can save your team from branch drift and make production hotfixes much easier to manage.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73a25b71159d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[String Methods in JavaScript]]></title>
            <link>https://medium.com/@williampepple/string-methods-in-javascript-b03df24f4fc7?source=rss-1e6093bc45bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/b03df24f4fc7</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <dc:creator><![CDATA[William Pepple]]></dc:creator>
            <pubDate>Mon, 21 Sep 2026 17:00:20 GMT</pubDate>
            <atom:updated>2026-09-21T17:00:20.593Z</atom:updated>
            <content:encoded><![CDATA[<p>There are various string methods in JavaScript that the average JavaScript developer should know about. Hold my cup of coffee and let us dive straight into it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d2dVs9zU-iHOUn8C07PkNg.jpeg" /></figure><p>A string is simply a collection of characters wrapped in quotes. It can be a name, a sentence, an email address, or even an empty value.</p><p>Example:</p><pre>const myName = &quot;William&quot;;<br>const sentence = &quot;JavaScript is fun&quot;;</pre><p>Now let us look at some useful string methods and properties.</p><h3>length</h3><p>The length property is used to check how many characters are contained in a string.</p><pre>const myString = &quot;Example&quot;;</pre><pre>console.log(myString.length);</pre><pre>// Answer: 7</pre><p>The length property also counts white spaces. If you have a string like “The World” and you run .length on it, you will get 9.</p><pre>const myString = &quot;The World&quot;;</pre><pre>console.log(myString.length);</pre><pre>// Answer: 9</pre><p>Explanation: “The” has 3 characters, the space counts as 1 character, and “World” has 5 characters. 3 + 1 + 5 = 9.</p><h3>substring()</h3><p>The substring() method extracts characters from a string between two positions and returns the extracted part as a new string.</p><pre>const word = &quot;JavaScript&quot;;<br>const result = word.substring(0, 4);</pre><pre>console.log(result);</pre><pre>// Answer: Java</pre><p>The first argument is where the extraction starts. The second argument is where it stops, but the character at that second position is not included.</p><p>Another example:</p><pre>const word = &quot;Developer&quot;;<br>const result = word.substring(3, 7);</pre><pre>console.log(result);</pre><pre>// Answer: elop</pre><p>One important thing to note is that substring() does not accept negative values the same way slice() does.</p><pre>const word = &quot;JavaScript&quot;;</pre><pre>console.log(word.substring(-4));</pre><pre>// Answer: JavaScript</pre><p>Explanation: negative values are treated like 0 in substring().</p><h3>substr()</h3><p>The substr() method also extracts part of a string, but it works differently from substring(). The first argument is the starting position, while the second argument is the number of characters you want to extract.</p><pre>const word = &quot;JavaScript&quot;;<br>const result = word.substr(4, 6);</pre><pre>console.log(result);</pre><pre>// Answer: Script</pre><p>Explanation: start from index 4, then collect 6 characters.</p><p>Another example:</p><pre>const word = &quot;Frontend&quot;;<br>const result = word.substr(0, 5);</pre><pre>console.log(result);</pre><pre>// Answer: Front</pre><p>Note: substr() still works in many browsers, but it is considered old. In modern JavaScript, slice() and substring() are usually better choices.</p><h3>slice()</h3><p>The slice() method extracts a part of a string and returns it as a new string. It can take one argument or two arguments.</p><p>Two arguments example:</p><pre>const mySlice = &quot;Harmattan&quot;;<br>const slicedPart = mySlice.slice(3, 7);</pre><pre>console.log(slicedPart);</pre><pre>// Answer: matt</pre><p>Explanation: the first argument is the index of the first character you want, while the second argument is the index after the last character you want.</p><p>One argument example:</p><pre>const mySlice = &quot;Harmattan&quot;;<br>const slicedPart = mySlice.slice(3);</pre><pre>console.log(slicedPart);</pre><pre>// Answer: mattan</pre><p>When slice() receives only one argument, it starts from that index and continues to the end of the string.</p><p>slice() can also accept negative values.</p><pre>const language = &quot;JavaScript&quot;;</pre><pre>console.log(language.slice(-6));</pre><pre>// Answer: Script</pre><p>Explanation: a negative value counts from the end of the string.</p><h3>replace()</h3><p>The replace() method replaces part of a string with another value. It returns a new string and does not change the original string.</p><pre>const message = &quot;I love Java&quot;;<br>const newMessage = message.replace(&quot;Java&quot;, &quot;JavaScript&quot;);</pre><pre>console.log(newMessage);</pre><pre>// Answer: I love JavaScript</pre><p>By default, replace() changes only the first match.</p><pre>const text = &quot;cat, cat, cat&quot;;<br>const result = text.replace(&quot;cat&quot;, &quot;dog&quot;);</pre><pre>console.log(result);</pre><pre>// Answer: dog, cat, cat</pre><p>If you want to replace all matches, you can use replaceAll().</p><pre>const text = &quot;cat, cat, cat&quot;;<br>const result = text.replaceAll(&quot;cat&quot;, &quot;dog&quot;);</pre><pre>console.log(result);</pre><pre>// Answer: dog, dog, dog</pre><h3>toLowerCase()</h3><p>The toLowerCase() method converts a string to lowercase letters.</p><pre>const greeting = &quot;HELLO WORLD&quot;;</pre><pre>console.log(greeting.toLowerCase());</pre><pre>// Answer: hello world</pre><p>This is useful when you want to compare values without worrying about capital letters.</p><pre>const email = &quot;USER@EMAIL.COM&quot;;</pre><pre>console.log(email.toLowerCase());</pre><pre>// Answer: user@email.com</pre><h3>toUpperCase()</h3><p>The toUpperCase() method converts a string to uppercase letters.</p><pre>const greeting = &quot;hello world&quot;;</pre><pre>console.log(greeting.toUpperCase());</pre><pre>// Answer: HELLO WORLD</pre><p>Another example:</p><pre>const name = &quot;william&quot;;</pre><pre>console.log(name.toUpperCase());</pre><pre>// Answer: WILLIAM</pre><h3>concat()</h3><p>The concat() method joins two or more strings together.</p><pre>const firstName = &quot;John&quot;;<br>const lastName = &quot;Doe&quot;;</pre><pre>const fullName = firstName.concat(&quot; &quot;, lastName);</pre><pre>console.log(fullName);</pre><pre>// Answer: John Doe</pre><p>You can also use the + operator or template literals, but concat() is still good to know.</p><pre>const language = &quot;Java&quot;;<br>const fullLanguage = language.concat(&quot;Script&quot;);</pre><pre>console.log(fullLanguage);</pre><pre>// Answer: JavaScript</pre><h3>trim()</h3><p>The trim() method removes whitespace from both sides of a string.</p><pre>const username = &quot;   William   &quot;;</pre><pre>console.log(username.trim());</pre><pre>// Answer: William</pre><p>This is very useful when working with form inputs because users can accidentally add spaces before or after their text.</p><pre>const email = &quot;   user@email.com   &quot;;</pre><pre>console.log(email.trim());</pre><pre>// Answer: user@email.com</pre><h3>padStart()</h3><p>The padStart() method adds characters to the beginning of a string until it reaches a certain length.</p><pre>const number = &quot;5&quot;;<br>const paddedNumber = number.padStart(3, &quot;0&quot;);</pre><pre>console.log(paddedNumber);</pre><pre>// Answer: 005</pre><p>This is useful when formatting numbers, dates, or IDs.</p><pre>const day = &quot;9&quot;;</pre><pre>console.log(day.padStart(2, &quot;0&quot;));</pre><pre>// Answer: 09</pre><h3>padEnd()</h3><p>The padEnd() method adds characters to the end of a string until it reaches a certain length.</p><pre>const text = &quot;Hi&quot;;<br>const result = text.padEnd(5, &quot;.&quot;);</pre><pre>console.log(result);</pre><pre>// Answer: Hi...</pre><p>Another example:</p><pre>const username = &quot;user&quot;;</pre><pre>console.log(username.padEnd(8, &quot;_&quot;));</pre><pre>// Answer: user____</pre><h3>charAt()</h3><p>The charAt() method returns the character at a particular index in a string.</p><pre>const word = &quot;JavaScript&quot;;</pre><pre>console.log(word.charAt(0));</pre><pre>// Answer: J</pre><p>Another example:</p><pre>const word = &quot;JavaScript&quot;;</pre><pre>console.log(word.charAt(4));</pre><pre>// Answer: S</pre><p>Remember that JavaScript starts counting from index 0, not index 1.</p><h3>charCodeAt()</h3><p>The charCodeAt() method returns the Unicode number of the character at a particular index.</p><pre>const letter = &quot;A&quot;;</pre><pre>console.log(letter.charCodeAt(0));</pre><pre>// Answer: 65</pre><p>Another example:</p><pre>const word = &quot;JavaScript&quot;;</pre><pre>console.log(word.charCodeAt(0));</pre><pre>// Answer: 74</pre><p>This method is not something you will use every day, but it is helpful when working with character codes.</p><h3>split()</h3><p>The split() method splits a string into an array.</p><pre>const sentence = &quot;I love JavaScript&quot;;<br>const words = sentence.split(&quot; &quot;);</pre><pre>console.log(words);</pre><pre>// Answer: [&quot;I&quot;, &quot;love&quot;, &quot;JavaScript&quot;]</pre><p>The value you pass into split() tells JavaScript where to cut the string.</p><pre>const fruits = &quot;apple,banana,mango&quot;;<br>const result = fruits.split(&quot;,&quot;);</pre><pre>console.log(result);</pre><pre>// Answer: [&quot;apple&quot;, &quot;banana&quot;, &quot;mango&quot;]</pre><p>You can also split every character by passing an empty string.</p><pre>const word = &quot;Code&quot;;</pre><pre>console.log(word.split(&quot;&quot;));</pre><pre>// Answer: [&quot;C&quot;, &quot;o&quot;, &quot;d&quot;, &quot;e&quot;]</pre><h3>Accessing characters with index</h3><p>A string is index-based, which means each character has a position. The first character is at index 0.</p><pre>const word = &quot;JavaScript&quot;;</pre><pre>console.log(word[0]);</pre><pre>// Answer: J</pre><pre>console.log(word[4]);</pre><pre>// Answer: S</pre><p>This is a quick way to get a character from a string.</p><h3>indexOf()</h3><p>The indexOf() method returns the position of the first occurrence of a value in a string.</p><pre>const sentence = &quot;I love JavaScript&quot;;</pre><pre>console.log(sentence.indexOf(&quot;love&quot;));</pre><pre>// Answer: 2</pre><p>If the value is not found, indexOf() returns -1.</p><pre>const sentence = &quot;I love JavaScript&quot;;</pre><pre>console.log(sentence.indexOf(&quot;Python&quot;));</pre><pre>// Answer: -1</pre><p>This is useful when checking if a string contains something.</p><h3>lastIndexOf()</h3><p>The lastIndexOf() method returns the position of the last occurrence of a value in a string.</p><pre>const sentence = &quot;JavaScript is fun and JavaScript is powerful&quot;;</pre><pre>console.log(sentence.lastIndexOf(&quot;JavaScript&quot;));</pre><pre>// Answer: 26</pre><p>Another example:</p><pre>const text = &quot;one two one two&quot;;</pre><pre>console.log(text.lastIndexOf(&quot;two&quot;));</pre><pre>// Answer: 12</pre><h3>startsWith()</h3><p>The startsWith() method checks if a string begins with a certain value. It returns true or false.</p><pre>const website = &quot;https://example.com&quot;;</pre><pre>console.log(website.startsWith(&quot;https&quot;));</pre><pre>// Answer: true</pre><p>Another example:</p><pre>const name = &quot;William&quot;;</pre><pre>console.log(name.startsWith(&quot;Will&quot;));</pre><pre>// Answer: true</pre><h3>endsWith()</h3><p>The endsWith() method checks if a string ends with a certain value. It also returns true or false.</p><pre>const fileName = &quot;profile.jpg&quot;;</pre><pre>console.log(fileName.endsWith(&quot;.jpg&quot;));</pre><pre>// Answer: true</pre><p>Another example:</p><pre>const email = &quot;user@gmail.com&quot;;</pre><pre>console.log(email.endsWith(&quot;@gmail.com&quot;));</pre><pre>// Answer: true</pre><h3>Conclusion</h3><p>String methods make it easier to work with text in JavaScript. You can use them to count characters, cut strings, replace words, change letter cases, clean user input, split sentences, and check how a string starts or ends.</p><p>The more you practice these methods, the more natural they become. Try creating your own strings and testing each method in your browser console or code editor.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b03df24f4fc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Understanding Crates in Rust: The Building Blocks of Rust Applications]]></title>
            <link>https://medium.com/@williampepple/understanding-crates-in-rust-the-building-blocks-of-rust-applications-103a91cd3e8d?source=rss-1e6093bc45bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/103a91cd3e8d</guid>
            <category><![CDATA[rust-programming-language]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[William Pepple]]></dc:creator>
            <pubDate>Mon, 21 Sep 2026 16:50:52 GMT</pubDate>
            <atom:updated>2026-09-21T16:50:52.326Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HJr5ATziAx4eiM1mvKWbIQ.jpeg" /></figure><p>Rust crates are the foundation of Rust’s package system. They help you organize code, share reusable functionality, and build applications with Cargo.</p><p>Rust is a systems programming language known for performance, safety, and concurrency. One reason Rust scales well across projects is its package management model, which is centered around crates.</p><p>In this article, we’ll look at what crates are, how they work, and why they matter in everyday Rust development.</p><h3>What Is a Crate in Rust?</h3><p>A <strong>crate</strong> is the smallest compilation unit in Rust. A crate can be one of two main types:</p><ul><li><strong>Binary crate:</strong> an executable program.</li><li><strong>Library crate:</strong> reusable code that other programs can depend on.</li></ul><p>Crates let Rust developers organize, share, and reuse code efficiently. They are similar to packages in ecosystems like npm for JavaScript or gems for Ruby.</p><h3>Types of Crates</h3><h3>Binary crates</h3><p>Binary crates compile into executable programs, such as command-line tools, servers, or desktop applications.</p><p>A binary crate must include a main() function as its entry point. Examples include CLI tools like ripgrep or a Rust web server.</p><h3>Library crates</h3><p>Library crates provide reusable functionality, but they do not compile directly into executable programs.</p><p>They usually define functions, structs, traits, and modules that other crates can use. Examples include serde for serialization and tokio for async runtime support.</p><h3>How Crates Work</h3><h3>Creating a crate</h3><p>You can create a new crate with Cargo:</p><pre>cargo new my_project --lib # Creates a library crate<br>cargo new my_project       # Creates a binary crate</pre><p>Cargo generates the basic project structure for you:</p><ul><li>Cargo.toml, which contains metadata and dependencies.</li><li>A src directory with either lib.rs for libraries or main.rs for binaries.</li></ul><h3>Publishing and using crates</h3><p>Rust crates are published on <a href="https://crates.io/">crates.io</a>, Rust’s official package registry.</p><p>To use a crate, add it to your Cargo.toml file:</p><pre>[dependencies]<br>serde = &quot;1.0&quot;</pre><p>Then import it in your Rust code:</p><pre>use serde::{Serialize, Deserialize};</pre><h3>Crate hierarchies and modules</h3><p>Crates can be split into modules for better organization:</p><pre>// Inside src/lib.rs<br>mod utils {<br>    pub fn helper() {<br>        println!(&quot;Helper function!&quot;);<br>    }<br>}</pre><p>Modules help manage scope and visibility. The pub keyword makes items accessible outside the module.</p><h3>Why Are Crates Important?</h3><ul><li><strong>Code reusability:</strong> You can depend on well-maintained crates instead of rewriting common functionality.</li><li><strong>Modularity:</strong> Large projects can be split into smaller crates for better maintainability.</li><li><strong>Ecosystem growth:</strong> Crates.io hosts libraries for web development, game development, embedded systems, tooling, and more.</li><li><strong>Dependency management:</strong> Cargo handles versioning and transitive dependencies efficiently.</li></ul><h3>Best Practices for Working With Crates</h3><ul><li><strong>Keep crates focused:</strong> A crate should do one thing well.</li><li><strong>Use semantic versioning:</strong> Follow the MAJOR.MINOR.PATCH format for releases.</li><li><strong>Document your crate:</strong> Use /// documentation comments and provide examples.</li><li><strong>Optimize compile time:</strong> Avoid unnecessary dependencies when possible.</li></ul><h3>Conclusion</h3><p>Crates are the backbone of Rust’s ecosystem. They make Rust projects modular, reusable, and easier to maintain.</p><p>Whether you’re building a small script or a large application, learning how to use crates well will make your Rust journey smoother.</p><h3>Further Reading</h3><ul><li><a href="https://doc.rust-lang.org/cargo/">The Cargo Book</a></li><li><a href="https://crates.io/">crates.io</a></li><li><a href="https://doc.rust-lang.org/book/ch07-00-managing-growing-projects-with-packages-crates-and-modules.html">Rust module system</a></li></ul><p>Happy coding in Rust! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=103a91cd3e8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>