Code Snippets

30 seconds of code provides a curated collection of short code snippets for all your development needs. Our collection spans many topics, ranging from simple coding problems to theoretical concepts and development techniques.

  • Date difference in days

    Calculates the day difference between two dates.

    Python, Date · Oct 28, 2020

  • Days from now

    Calculates the date of n days from today.

    Python, Date · Oct 28, 2020

  • Fibonacci

    Generates a list, containing the Fibonacci sequence, up until the nth term.

    Python, Math · Nov 2, 2020

  • Find key of value

    Finds the first key in the provided dictionary that has the given value.

    Python, Dictionary · Nov 2, 2020

  • Date is weekday

    Checks if the given date is a weekday.

    Python, Date · Nov 2, 2020

  • Date is weekend

    Checks if the given date is a weekend.

    Python, Date · Nov 2, 2020

  • Key in dictionary

    Checks if the given key exists in a dictionary.

    Python, Dictionary · Oct 16, 2020

  • Unique elements in list

    Returns the unique elements in a given list.

    Python, List · Sep 15, 2020

  • Apply function when true

    Tests a value, x, against a testing function, conditionally applying a function.

    Python, Function · Nov 9, 2020

  • Apply the latest stash

    Applies the latest stash.

    Git, Repository · Apr 13, 2021

  • Apply a stash

    Applies a specific stash.

    Git, Repository · Apr 13, 2021

  • Change the remote URL

    Changes the URL of the remote repository.

    Git, Repository · Apr 13, 2021

  • Commit without running git hooks

    Creates a new commit skipping the pre-commit and commit-msg hooks.

    Git, Commit · Apr 13, 2021

  • Create a new repository

    Initializes a new git repository, setting up all the configuration files needed by git.

    Git, Repository · Apr 13, 2021

  • Delete a stash

    Deletes a specific stash.

    Git, Repository · Apr 13, 2021