Skip to content

Instantly share code, notes, and snippets.

Avatar
I may be slow to respond.

Andrew Bender adamanthil

I may be slow to respond.
View GitHub Profile
@adamanthil
adamanthil / gemp-recursive-runtime-error.log
Created Aug 1, 2018
Triggered stack overflow error post-react in battle on GEMP
View gemp-recursive-runtime-error.log
2018-08-01 00:44:51,896 ERROR SwccgoHttpRequestHandler:368 - Error while processing request
java.lang.StackOverflowError
at java.util.LinkedList.addAll(LinkedList.java:406)
at java.util.LinkedList.addAll(LinkedList.java:385)
at com.gempukku.swccgo.filters.Filters.sameCardId(Filters.java:14248)
at com.gempukku.swccgo.filters.Filters.changeToFilter(Filters.java:74)
at com.gempukku.swccgo.filters.Filters.convertToFilters(Filters.java:16665)
at com.gempukku.swccgo.filters.Filters.and(Filters.java:14115)
at com.gempukku.swccgo.logic.modifiers.MayDeployAsReactToTargetModifier.<init>(MayDeployAsReactToTargetModifier.java:44)
at com.gempukku.swccgo.logic.modifiers.MayDeployAsReactToTargetModifier.<init>(MayDeployAsReactToTargetModifier.java:33)
View vpn-setup.sh
#!/bin/sh
#
# voodoo-vpn.sh: Amazon EC2 user-data file for automatic configuration of a VPN
# on a Ubuntu server instance. Tested with 12.04.
#
# See http://www.sarfata.org/posts/setting-up-an-amazon-vpn-server.md
#
# DO NOT RUN THIS SCRIPT ON YOUR MAC! THIS IS MEANT TO BE RUN WHEN
# YOUR AMAZON INSTANCE STARTS!
#
View delete-unused-aws-security-groups.sh
#!/bin/bash
# Finds and deletes unused aws security groups, following template for determining unused groups here:
# https://stackoverflow.com/a/24704644
region=$1
comm -23 <(aws ec2 describe-security-groups --query 'SecurityGroups[*].GroupId' \
--output text --region $region | tr '\t' '\n'| sort) \
<(aws ec2 describe-instances --query 'Reservations[*].Instances[*].SecurityGroups[*].GroupId' \
@adamanthil
adamanthil / insert-sample-pivot-data.sql
Last active Sep 19, 2016
Inserts sample data for a hypothetical book sales database used for demonstrating methods of writing PIVOT queries in PostgreSQL. Assumes schema described here: http://bender.io/2016/09/18/dynamic-pivot-tables-with-json-and-postgresql
View insert-sample-pivot-data.sql
---------------------------------------------------------------------
-- Assumes book, customer, and sale tables in the requisite format
---------------------------------------------------------------------
INSERT INTO book VALUES (1, 'The Martian', 'Andy Weir', 2014, 'Science Fiction', 14.88);
INSERT INTO book VALUES (2, 'Augustus: First Emperor of Rome', 'Adrian Goldsworthy', 2014, 'History', 24.29);
INSERT INTO book VALUES (3, 'Ready Player One', 'Ernest Cline', 2011, 'Science Fiction', 9.69);
INSERT INTO book VALUES (4, 'The Hitchhiker''s Guide to the Galaxy', 'Douglas Adams', 1979, 'Science Fiction', 7.19);
INSERT INTO book VALUES (5, 'The Girl with All the Gifts', 'M. R. Carey', 2014, 'Dystopian Fiction', 11.48);
INSERT INTO book VALUES (6, 'Predictably Irrational', 'Dan Ariely', 2008, 'Behavioral Economics', 9.52);
@adamanthil
adamanthil / create-self-signed-ssl-cert.sh
Created Feb 25, 2016
Series of shell commands to create a self-signed SSL cert for use in a dev environment.
View create-self-signed-ssl-cert.sh
# Create self signed cert
# Reference: http://www.akadia.com/services/ssh_test_certificate.html
# Create key (will prompt for a passphrase. This password will be removed later for convenience)
openssl genrsa -des3 -out server.key 2048
# Generate CSR
openssl req -new -key server.key -out server.csr
# Remove key passphrase
@adamanthil
adamanthil / osx-install-php-composer.sh
Created Feb 10, 2016
Install PHP Composer globally on OSX
View osx-install-php-composer.sh
# Install php composer on OSX:
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin
# Add alias in .bashrc / .zshrc etc:
alias composer='php /usr/local/bin/composer.phar'
@adamanthil
adamanthil / brand-table-hierarchical-query.sql
Created Jun 22, 2015
An adjusted query to return nested objects in a brand database. Fixes issue where two separate joins caused additional values in aggregates.
View brand-table-hierarchical-query.sql
--use images and logos tables
with images as (
select
im.brand,
json_agg(
row_to_json(
(select r from (select im.name, im.path as poster) r)
)
) as images
from images im
@adamanthil
adamanthil / load-json.as
Last active Aug 29, 2015
Loads some JSON into a dynamic text field
View load-json.as
import flash.events.Event
import flash.net.URLLoader;
import flash.net.URLRequest;
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest();
request.contentType = "application/json";
request.url="http://jsonip.com/";
loader.load(request);
@adamanthil
adamanthil / csvtojson-large-file-issue.js
Created Aug 13, 2014
The following javascript should stop triggering events before running through the entire sample csv file using the csvtojson module. See issue: https://github.com/Keyang/node-csvtojson/issues/28
View csvtojson-large-file-issue.js
var importIndex = 0;
var csvConverter = new Converter({ constructResult:false });
var fileStream = fs.createReadStream('large-csv-sample.csv');
csvConverter.on('record_parsed',function(rowObj, rowArray, rowIndex){
var rowId = rowArray[0];
var fileNum = rowArray[1];
importIndex++;
console.log(rowId, importIndex);
@adamanthil
adamanthil / large-csv-sample.csv
Created Aug 13, 2014
Sample CSV File that does not trigger 'record_parsed' events for all rows when using the csvtojson library. See issue: https://github.com/Keyang/node-csvtojson/issues/28
View large-csv-sample.csv
ID Number
0157181 8002
0157741 6523
0158106 11339
0158685 1246589927
0159044 10240
0159470 6320
0161143 1246588356
0161144 1246589434
0162198 9277