Skip to content

Instantly share code, notes, and snippets.

View rage-shadowman's full-sized avatar

Ralph Jennings rage-shadowman

View GitHub Profile
@rage-shadowman
rage-shadowman / pre-push.sh
Last active May 6, 2019 18:07 — forked from fwielstra/pre-push
A pre-push git hook which runs a gradle test task
#!/bin/sh -e
#
# to install this hook, create a symbolic link in the projects .git/hooks folder
#
# i.e. - from the .git/hooks directory, run
# $ ln -s /location/of/git-hooks/pre-push.sh pre-push
#
# to skip the tests, run with the --no-verify argument
# i.e. - $ 'git push --no-verify'
@rage-shadowman
rage-shadowman / ChainableFuture.java
Last active February 24, 2017 04:10
An attempt at a safe CompletionStage/Future class. You will need to use CompletableFuture in your own code and complete it (either successfully or exceptionally) as you normally would, but then you can wrap it in a SafePromise to return something less dangerous to your callers.
package com.rage.shadowman.promise;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.BiConsumer;
@rage-shadowman
rage-shadowman / MomentJsDateFormatHelper.java
Last active August 29, 2015 14:12
MomentJsDateFormatHelper that I use with jknack's handlebars.java project.
import com.github.jknack.handlebars.Helper;
import com.github.jknack.handlebars.Options;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.IOException;
import java.io.InputStream;
@rage-shadowman
rage-shadowman / git-backup-svn-based-repo.sh
Last active December 22, 2015 12:19
Create a backup git repo for a git-svn clone. To restore from such a backup, see: https://gist.github.com/rage-shadowman/6471961
#!/bin/sh
if [ "$#" -ne 1 ]
then
echo 'Usage: $0 <existing-bare-git-repo>'
exit 1
fi
if ! git ls-remote "$1" > /dev/null 2>&1
then
@rage-shadowman
rage-shadowman / git-clone-svn-based-repo.sh
Last active December 22, 2015 12:19
Script to clone a git-svn backup repo. To create the backup repo, see: https://gist.github.com/rage-shadowman/6472005
#!/bin/sh
#
# git-clone-svn-based-repo.sh:
#
# clones a git-svn based repo including all SVN commits without pounding
# the SVN server for hours (just a quick refresh taking seconds)
#
usage_exit ()
{
@rage-shadowman
rage-shadowman / pre-receive
Last active January 12, 2016 23:27
This is a git pre-receive hook for backups of git-svn clones to keep from pushing anything to the backup repository that doesn't have a git-svn-id (reject anything that did not get dcommitted first). Recommended for backups created using: https://gist.github.com/rage-shadowman/6472005
#!/bin/sh
. git-sh-setup
read oldValue newValue refName
if ! git log -1 $newValue | grep -q '^ git-svn-id: '
then
echo "Must not commit to Git unless already dcommitted to SVN!"
exit 1
fi
@rage-shadowman
rage-shadowman / git-svn-diff.sh
Last active August 28, 2017 10:02 — forked from markjaquith/git-svn-diff.sh
fixed bug with diff of newly added files
#!/bin/bash
#
# git-svn-diff originally by (http://mojodna.net/2009/02/24/my-work-git-workflow.html)
# modified by mike@mikepearce.net
# modified by aconway@[redacted] - handle diffs that introduce new files
# modified by t.broyer@ltgt.net - fixes diffs that introduce new files
# modified by m@rkj.me - fix sed syntax issue in OS X
# modified by rage-shadowman - cleaned up finding of SVN info and handling of path parameters
# modified by tianyapiaozi - cleaned up some diff context lines
#
@rage-shadowman
rage-shadowman / jQuery-based-marquee.js
Last active December 15, 2015 21:09 — forked from remy/gist:2484402
Updated jQuery marquee plugin by Remy Sharp to handle window resize events. This has been tested only on horizontal right-to-left scrolling text. Theoretically it should work for vertical scrolling and left-to-right, but I have no use for that so I have not tested that behavior.
/**
* author Remy Sharp
* url http://remysharp.com/tag/marquee
*
* Ralph Jennings. 4/5/2013.
* Added support for "resize" event. If triggered, marquee is resized according to
* its parent's width and scroll position is updated accordingly.
*/
(function ($) {