Skip to content

Instantly share code, notes, and snippets.

View its-monotype's full-sized avatar
🤙

its-monotype

🤙
  • Earth
View GitHub Profile
@CrookedNumber
CrookedNumber / gist:8964442
Created February 12, 2014 21:02
git: Removing the last commit

Removing the last commit

To remove the last commit from git, you can simply run git reset --hard HEAD^ If you are removing multiple commits from the top, you can run git reset --hard HEAD~2 to remove the last two commits. You can increase the number to remove even more commits.

If you want to "uncommit" the commits, but keep the changes around for reworking, remove the "--hard": git reset HEAD^ which will evict the commits from the branch and from the index, but leave the working tree around.

If you want to save the commits on a new branch name, then run git branch newbranchname before doing the git reset.

@qoomon
qoomon / conventional-commits-cheatsheet.md
Last active April 25, 2025 12:55
Conventional Commits Cheatsheet

Conventional Commit Messages starline

See how a minor change to your commit message style can make a difference.

Tip

Take a look at git-conventional-commits , a CLI util to ensure these conventions, determine version and generate changelogs

Commit Message Formats

Default

@dusekdan
dusekdan / window_helper.py
Created March 15, 2019 16:59
Snippet of python code to help working with Windows under win32gui.
import win32gui
import re
class WindowMgr:
"""Encapsulates some calls to the winapi for window management"""
def __init__ (self):
"""Constructor"""
self._handle = None
@vtenq
vtenq / git-workflow.md
Last active January 20, 2025 12:19
Git workflow with conventional commits and semantic auto release

Git workflow with conventional commits and semantic auto release

This is an adoptation of Git flow by Vincent Driessen with conventional commits and semantic release.

The main concepts

At the core, the development model is greatly inspired by existing models out there. The central repo holds two main branches with an infinite lifetime:

@Zekfad
Zekfad / conventional-commits.md
Last active April 25, 2025 12:56
Conventional Commits Cheatsheet

Quick examples

  • feat: new feature
  • fix(scope): bug in scope
  • feat!: breaking change / feat(scope)!: rework API
  • chore(deps): update dependencies

Commit types

  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Changes to CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore: Changes which doesn't change source code or tests e.g. changes to the build process, auxiliary tools, libraries
@HughParsons
HughParsons / forwardRefHOC.tsx
Created September 9, 2022 00:04
React HOC (higher order component) with forwardRef
import * as React from 'react'
export function HOC<T, P extends {}>(
Component: React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>>
): React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>> {
return React.forwardRef<T, P>(
function ComponentFromHOC(props, ref) {
return (
<Component {...props as React.PropsWithoutRef<P>} ref={ref} />
);
@bennettdams
bennettdams / zod-empty-string-undefined-optional.ts
Last active July 24, 2024 09:15
Zod empty string transformed to `undefined` including handling optional
import { z } from 'zod'
const emptyStringToUndefined = z.literal('').transform(() => undefined)
/**
* Provide a schema and get a schema that is optional and empty strings are transformed to `undefined`.
* When someone removes his input of this field, the then empty string is transformed to `undefined`.
*
* Example:
*
@martinratinaud
martinratinaud / .gitconfig
Last active December 19, 2024 18:45
Awesome Git Configuration
[alias]
# shortcuts
c = commit
co = checkout
cp = cherry-pick
f = fetch
# enhancements
d = diff -- ':!package-lock.json' ':!yarn.lock' # Do not show lock files when diffing
ds = diff --staged -- ':!package-lock.json' ':!yarn.lock' # Do not show lock files when diffing staged files
@levvsha
levvsha / useOnClickOutside.ts
Created May 9, 2023 12:44
useOnClickOutside react hook with TypeScript
function useOnClickOutside(
ref: React.RefObject<HTMLDivElement>,
handler: (event: TouchEvent | MouseEvent) => void,
) {
useEffect(() => {
const listener = (event: TouchEvent | MouseEvent) => {
if (!ref.current || ref.current.contains(event.target as HTMLElement)) {
return;
}
handler(event);
@palashmon
palashmon / Prettify.ts
Created May 13, 2023 16:11
A super useful type helper in TypeScript by Matt Pocock from Twitter
/**
* A TypeScript type alias called `Prettify`.
* It takes a type as its argument and returns a new type that has the same properties as the original type,
* but the properties are not intersected. This means that the new type is easier to read and understand.
*/
type Prettify<T> = {
[K in keyof T]: T[K];
} & {};