Skip to content

Instantly share code, notes, and snippets.

View miknight's full-sized avatar

Michael Knight miknight

View GitHub Profile
@miknight
miknight / recover_source_code.md
Created March 15, 2017 03:26 — forked from simonw/recover_source_code.md
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
### Keybase proof
I hereby claim:
* I am miknight on github.
* I am miknight (https://keybase.io/miknight) on keybase.
* I have a public key whose fingerprint is 82D1 3673 B5B5 86BD 1FDD 865C F677 D857 8431 BA77
To claim this, I am signing this object:
@miknight
miknight / related-posts-thumbnails.php
Created January 8, 2011 17:40
Around line 250. Added NextGen Gallery support to Related Posts Thumbnails WordPress plugin.
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
MutableIssue issue = componentManager.getIssueManager().getIssueObject("TEST-1")
return issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Epic"))
# Steps to compile Passenger against the MacPorts version of Apache on OS X:
Chewbacca% sudo -s
Chewbacca# export APXS2=/opt/local/apache2/bin/apxs
Chewbacca# passenger-install-apache2-module
<html>
<head>
<title>Label Checkbox Test</title>
</head>
<body>
<form>
<label for="checker">click me</label>
<input type="checkbox" id="checker" />
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char* argv[]) {
char *pStrings[2];
pStrings[1] = (char*)malloc(100);
memset(pStrings[1], 0, 100);
pStrings[1][0] = 'c';
// MarioRogic, mrog212
// Wed15-Bugle
// 29/07/09
// Lab02: analyse dna sequences
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int getLineCount(FILE * pFile);
#!/bin/bash
# Replaces PHP function calls date_format() with date() and date_create() with strtotime() to maintain PHP 5.1 compatibility.
for file in `grep -Rin date_format * | grep -v '.svn' | grep -v 'convert.sh' | grep -v 'test.php' | cut -d: -f1 | sort -u`; do
echo "Replacing calls in $file";
#ruby -pe 'gsub(/date_format\(date_create\((.+)\), \"(.+)\"\)/, "date(\"\\2\", strtotime(\\1))")' < $file > $file.temp1
ruby -pe 'gsub(/date_create\((.+?)\)/, "strtotime(\\1)")' < $file > $file.temp1
ruby -pe 'gsub(/date_format\((.+?), \"(.+?)\"\)/, "date(\"\\2\", \\1)")' < $file.temp1 > $file.temp2
rm $file.temp1
@miknight
miknight / gist:137904
Created June 30, 2009 00:17
~/.vimrc
set nocompatible
syn on
set linebreak
set hlsearch
set bg=dark
set sw=4
set ts=4
set bs=2
set si
set expandtab