Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<dependencies>
from django.utils.http import urlquote
from functools import wraps
from django.utils.decorators import available_attrs
from django.contrib.auth import REDIRECT_FIELD_NAME
from common.shortcuts import render_json
from django.http import HttpResponseRedirect
def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME):
"""
MODIFIED from django/contrib/auth/decorators.py - now returns our custom JSON-failure
@rtyley
rtyley / IndexPackPerformanceTest.java
Created December 9, 2010 22:00
jgit pack-indexing performance test
package org.eclipse.jgit.transport;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.RepositoryTestCase;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@rtyley
rtyley / IndexPackPerformanceTest.java
Created December 28, 2010 00:35
Perf test for I1d9b3a8b: IndexPack: Use stack-based recursion for delta resolution
package org.eclipse.jgit.transport;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.lib.*;
import org.eclipse.jgit.revwalk.RevBlob;
import org.eclipse.jgit.storage.file.PackFile;
import org.eclipse.jgit.util.JGitTestUtil;
import org.eclipse.jgit.util.NB;
import org.eclipse.jgit.util.TemporaryBuffer;
@rtyley
rtyley / gist:1118177
Created August 1, 2011 14:03
Git loose objects - Experimental format header vs Gzip header checksum
// 0ttt1000
// 0iii1000
def monkey(t: Int, w: Int) = (t<<12) + (8<<8) + (w << 4) + (8)
for (t <- 1 to 4; windowBit <- 0 to 7) {
val header = monkey(t,windowBit)
println(t, windowBit, header, "%04X" format header, header % 31 == 0)
}
@rtyley
rtyley / environment
Created November 25, 2011 18:11
Setting up a new Ubuntu box
M2_HOME=/tools/maven/current
ANDROID_HOME=/tools/android-sdk-linux
IDEA_JDK=/usr/lib/jvm/jdk1.7.0_01
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
@rtyley
rtyley / gist:3853105
Created October 8, 2012 15:25
sketchy attempt to do retries with dispatch
def getWithRetries(retries: Int) : Promise[Either[Throwable, String]] = {
Http(url OK as.Response(r => r.getResponseBody)).either.map {
_ match {
case fail: Left[Throwable, String] =>
println("Download attempt failed - remaining retries: "+retries+" : " + fail.a.getMessage)
if (retries > 0) {
Thread.sleep(5000 / retries)
getWithRetries(retries - 1)() // probably bad?
} else fail
case s => s
@rtyley
rtyley / get-500-biggest-blobs.sh
Last active September 13, 2022 10:54
Gets the top 500 biggest blobs in your repo, ordered by size they occupy when compressed in the packfile
git verify-pack -v .git/objects/pack/*.idx | grep blob | cut -c1-40,48- | cut -d' ' -f1,3 | sort -n -r --key 2 | head -500 > top-500-biggest-blobs.txt
@rtyley
rtyley / get-blob-filenames.sh
Last active October 13, 2015 13:28
Gets a list of all blobs ever contained in your repo, along with their associated filename (quite slow)
git verify-pack -v .git/objects/pack/*.idx | grep tree | cut -c1-40 | xargs -n1 -iX sh -c "git ls-tree X | cut -c8- | grep ^blob | cut -c6-" | sort | uniq
@rtyley
rtyley / replace-with-sha.sh
Created December 4, 2012 12:18
Accepts a list of 'bad' blob ids, and replaces them with a 'xxx.REMOVED.sha' placeholder
#! /usr/bin/env sh
TREEDATA=$(git ls-tree -r $2 | grep ^.......blob | cut -c13-)
while IFS= read -r line ; do
echo "$TREEDATA" | grep ^$line | cut -c42- | xargs -n1 -iX sh -c "echo $line > 'X.REMOVED.sha' && rm 'X'" &
done < $1
wait