Skip to content

Instantly share code, notes, and snippets.

View AGBrown's full-sized avatar

Andrew Brown AGBrown

View GitHub Profile
@AGBrown
AGBrown / fetch_forks.ps1
Created May 10, 2019 07:49
Recursively fetch all forks for a git repo
function Get-BasicAuthCreds {
param([string]$Username,[string]$Password)
$AuthString = "{0}:{1}" -f $Username,$Password
$AuthBytes = [System.Text.Encoding]::Ascii.GetBytes($AuthString)
return [Convert]::ToBase64String($AuthBytes)
}
function fetch-forks ($orig, $Creds) {
#Write-host $orig.forks_url
#Write-host $Creds
@AGBrown
AGBrown / SubsetSum.cs
Created March 18, 2018 19:38 — forked from riyadparvez/SubsetSum.cs
Implementation of subset sum problem using dynamic programming approach in C#.
public static bool SubsetSum(IEnumerable<int> list, int s)
{
var arr = list.ToArray();
Array.Sort(arr);
var a = arr.Where(i => i < 0).Sum();
var b = arr.Where(i => i > 0).Sum();
if(a > s || b < s)
{
return false;
}
@AGBrown
AGBrown / jail.local
Created May 14, 2015 09:06
fail2ban filter and jail for quassel (http://bugs.quassel-irc.org/issues/1356)
[quassel]
enabled = true
port = 4242
filter = quassel
logpath = /var/log/quassel/core.log
maxretry = 5
package testing;
import java.util.List;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.type.TypeFactory;
public class TypeReferenceTest {
// used inside ObjectMapper
@AGBrown
AGBrown / text\AltConverter.java
Last active August 29, 2015 14:15
Caliper benchmark code for int[] -> String in Java (ref: http://stackoverflow.com/a/28611711/1945631 )
package text;
/** Converter that uses bit-shifting to lookup each nibble in a fixed hex
* encoding array, yielding higher performance
* @author Andrew Brown
*/
public class AltConverter implements IntArrToStringConverter {
final protected static char[] encoding = "0123456789ABCDEF".toCharArray();
public String convertToString(int[] arr) {
char[] encodedChars = new char[arr.length * 4 * 2];