Skip to content

Instantly share code, notes, and snippets.

View jshields's full-sized avatar
🦥

Joshua Shields jshields

🦥
View GitHub Profile
@lifuzu
lifuzu / revert_a_merge.md
Created April 2, 2014 01:47
revert a merge commit that's already pushed to remote branch

The -m option specifies the parent number. This is because a merge commit has more than one parent, and Git does not know automatically which parent was the mainline, and which parent was the branch you want to un-merge.

When you view a merge commit in the output of git log, you will see its parents listed on the line that begins with Merge:

commit 8f937c683929b08379097828c8a04350b9b8e183
Merge: 8989ee0 7c6b236
Author: Ben James <ben@example.com>
Date:   Wed Aug 17 22:49:41 2011 +0100

Merge branch 'gh-pages'
@maxicecilia
maxicecilia / ipythonrc
Created April 22, 2014 18:38
default ipythonrc example
# -*- Mode: Shell-Script -*- Not really, but shows comments correctly
# $Id: ipythonrc,v 1.4 2003/05/16 06:53:42 fperez Exp $
#***************************************************************************
#
# Configuration file for IPython -- ipythonrc format
#
# The format of this file is simply one of 'key value' lines.
# Lines containing only whitespace at the beginning and then a # are ignored
# as comments. But comments can NOT be put on lines with data.
@kyokley
kyokley / bandit_hook.md
Last active June 28, 2018 06:33
Checking for Python Security Vulnerabilities with VIM

Checking for Python Security Vulnerabilities with VIM (Buffer Pre-write Hook Part 3)

Introduction

To continue my series of vim pre-write hooks, I wanted to add a new check for security static analysis failures. To see the progression of the series, please check out my other gists.

Back to security... In my office, we use OpenStack's Bandit static analysis tool. If you're not familiar with it, you should check it out. It's pretty nifty.

Getting Started

@ayubmalik
ayubmalik / gpg-encrypt.go
Last active July 21, 2024 16:20
Golang encrypt file using GPG openpgp. Use standard go libs.
package main
/**
Example hack to encrypt a file using a GPG encryption key. Works with GPG v2.x.
The encrypted file e.g. /tmp/data.txt.gpg can then be decrypted using the standard command
gpg /tmp/data.txt.gpg
Assumes you have **created** an encryption key and exported armored version.
You have to read the armored key directly as Go cannot read pubring.kbx (yet).
@kyokley
kyokley / py23_check.md
Last active July 7, 2018 13:29
Dynamically set Python2/3 version in Syntastic

Determining Python 2/3 Version in VIM

Introduction

I am a big fan of the syntastic package. In python, it is useful for viewing both Pyflakes and Bandit errors. However, this only works if syntastic knows what python interpreter to use. Not everyone is fortunate enough to have upgraded all of their software to python3. For reasons out of my control, I end up spending most of my time writing python2 code. This means that the times when I finally get to write python3, all of my syntax checking is broken. How cool would it be to have VIM determine what version of python to use automatically? So, begins my grand experiment...

Prerequisites

For this to work, I will be using a virtualenv for python2 and one for python3. It's not absolutely necessary to use virtualenvs but I definitely recommend it. Setting up virtualenvs is out of the scope of this gist but make sure that each virtualenv

@matthewearl
matthewearl / smblevextract.py
Last active May 19, 2024 22:12
Super Mario Bros Level Extractor
#!/usr/bin/env python3
#
# Copyright (c) 2018 Matthew Earl
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions: