Skip to content

Instantly share code, notes, and snippets.

@knu
knu / gist:111055
Created May 13, 2009 14:38
How to mass-rename tags and push them with Git
# Rename tags named foo-bar-#.#.# to v#.#.# and push the tag changes
git tag -l | while read t; do n="v${t##*-}"; git tag $n $t; git push --tags ; git tag -d $t; git push origin :refs/tags/$t ; done
@katylava
katylava / git-selective-merge.md
Last active February 27, 2024 10:18
git selective merge

Update 2022: git checkout -p <other-branch> is basically a shortcut for all this.

FYI This was written in 2010, though I guess people still find it useful at least as of 2021. I haven't had to do it ever again, so if it goes out of date I probably won't know.

Example: You have a branch refactor that is quite different from master. You can't merge all of the commits, or even every hunk in any single commit or master will break, but you have made a lot of improvements there that you would like to bring over to master.

Note: This will not preserve the original change authors. Only use if necessary, or if you don't mind losing that information, or if you are only merging your own work.

@chrisroos
chrisroos / gpg-import-and-export-instructions.md
Created September 9, 2011 10:49
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@turicas
turicas / attrdict.py
Created December 22, 2011 16:21
Python class with dict-like get/set item
#!/usr/bin/env python
# coding: utf-8
class AttrDict(object):
def __init__(self, init=None):
if init is not None:
self.__dict__.update(init)
def __getitem__(self, key):
return self.__dict__[key]
@kbaird
kbaird / git_binary_diff_gist
Created May 10, 2012 16:01
Binary diff setup in .git/config
[diff "bz2"]
binary = true
textconv = /bin/bzcat
[diff "gzip"]
binary = true
textconv = /bin/zcat
[diff "tar"]
binary = true
textconv = tar --to-stdout -xf
[diff "tar-bz2"]
@timgaunt
timgaunt / gist:2659362
Created May 11, 2012 12:35
Facebook Like link without cookies or JavaScript
<a id="share-facebook" class="facebook" rel="nofollow" target="_blank" href="http://www.facebook.com/sharer.php?u=http://www.myurl.com" _fcksavedurl="http://www.facebook.com/sharer.php?u=http://www.myurl.com" title="Facebook - Link opens in a new window">Facebook</a>
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active November 17, 2024 13:10
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@kmoormann
kmoormann / IdempotentSQLAlterTableAddColumn.sql
Created September 20, 2012 20:47
Idempotent SQL Alter Table Statements
IF NOT EXISTS
(
SELECT * FROM [information_schema].[columns]
WHERE table_name = 'Customer'
AND table_schema = 'dbo'
AND column_name = 'FavoriteColorId'
)
BEGIN
ALTER TABLE [dbo].[Customer]
ADD FavoriteColorId int
@astraw
astraw / beep.py
Created March 11, 2013 22:02
Simple pushover.net notifier
#!/usr/bin/env python
import httplib, urllib
import argparse
def main():
parser = argparse.ArgumentParser(
description='send pushover.net notification')
parser.add_argument('note', metavar='note', default=['(no note)'], nargs='*')
args = parser.parse_args()
@tylerneylon
tylerneylon / learn.lua
Last active October 22, 2024 01:07
Learn Lua quickly with this short yet comprehensive and friendly script. It's written as both an introduction and a quick reference. It's also a valid Lua script so you can verify that the code does what it says, and learn more by modifying and running this script in your Lua interpreter.
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------