Skip to content

Instantly share code, notes, and snippets.

View dacur's full-sized avatar

David Curtis dacur

  • Raleigh, North Carolina
View GitHub Profile
@gunjanpatel
gunjanpatel / revert-a-commit.md
Last active August 23, 2024 22:41
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@dkniffin
dkniffin / terminal_cheatsheet.md
Last active April 21, 2021 06:50
Terminal 101/Cheat sheet/rosetta stone

The goal of this gist is to provide a list of the most common/useful shell commands.

Commands

command stands for common usage description
man manual man display the man page for the given comand. If you're wondering how to use any command, this is the go-to place for help. It provides information about what the command does, how to use it, what flags it has, and lots more.
<command> --help While it's not an actual command, I thought it'd be useful to include it. While man will get you the most thorough information about a command, many commands don't provide man pages. Also sometimes it's useful to get a less verbose help message. In those cases, --help/-h is what you want.
<command> -h ^ see above ^
cd change directory cd move to the given directory
@GregBaugues
GregBaugues / token.rb
Last active July 11, 2022 02:21
Google API OAuth 2.0 refresh token (Ruby on Rails)
# The OAuth access token provided by the Google API expires in 60 minutes. After expiration,
# you must exchange a refresh token for a new access token. Unfortunately, the the Google API
# ruby gem does not include a method for refreshing access tokens.
# You can read up on how to refresh an access token here:
# https://developers.google.com/accounts/docs/OAuth2WebServer#refresh
# This Token model implements that process. It's based off of a Token model that can be created
# by running:
# rails g model Token token:text refresh_token:string expires_at:datetime
@davidcelis
davidcelis / pagination.rb
Created June 30, 2013 20:14
Consuming Link header pagination in Ruby
# Link: <http://example.com/resources?page=2>; rel="next", <http://example.com/resources?page=5>; rel="last"
links = {}
headers['Link'].split(',').each do |link|
link.strip!
parts = link.match(/<(.+)>; *rel="(.+)"/)
links[parts[2]] = parts[1]
end
@rstacruz
rstacruz / index.md
Last active November 3, 2023 09:56
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')