Skip to content

Instantly share code, notes, and snippets.

View JefStat's full-sized avatar

Jeff Statham JefStat

View GitHub Profile
@JefStat
JefStat / gist:3da7ea8f5cc00d246f0f
Last active August 29, 2015 14:07
Queue consumer
public class PollingService
{
private Thread _workerThread;
private AutoResetEvent _finished;
private const int _timeout = 60*1000;
private readonly Queue<Work> _queue = new Queue<Work>();
public void StartPolling()
{
<PropertyGroup>
<CommandLine>$([System.Environment]::CommandLine.Trim().ToLower())</CommandLine>
<IsQuietVerbosity>False</IsQuietVerbosity>
<IsMinimalVerbosity>False</IsMinimalVerbosity>
<IsNormalVerbosity>True</IsNormalVerbosity>
<IsDetailedVerbosity>False</IsDetailedVerbosity>
<IsDiagnosticVerbosity>False</IsDiagnosticVerbosity>
</PropertyGroup>
<PropertyGroup Condition="'$(CommandLine.Contains(&quot;/v&quot;))' == 'True'">
@JefStat
JefStat / getCurrentMethodName.java
Created August 1, 2013 16:52
getCurrentMethodName (wasn't quite working might need it to be static)
private static int getStackTraceIndexForObject(final Object object)
{
// Finds out the index of "this code" in the returned stack trace - funny but it differs in JDK 1.5 and 1.6
int i = 0;
for (final StackTraceElement ste : Thread.currentThread().getStackTrace()) {
++i;
if (ste.getClassName().equals(object.getClass().getName())) {
break;
}
}
@JefStat
JefStat / Terraform api gateway bug
Created May 3, 2016 18:22
Terraform api gateway bug sample
variable "function_hello" {}
resource "aws_api_gateway_rest_api" "Hello" {
name = "Hello World API"
description = "Terraform integration"
}
resource "aws_api_gateway_resource" "Hello" {
rest_api_id = "${aws_api_gateway_rest_api.Hello.id}"
parent_id = "${aws_api_gateway_rest_api.Hello.root_resource_id}"
module.iam.output.lambda_function_role_id - *terraform.GraphNodeConfigResourceFlat
provider.aws - *terraform.graphNodeProvider
root - terraform.graphNodeRoot
module.iam.aws_iam_role.Fake_POS - *terraform.GraphNodeConfigResourceFlat
module.iam.aws_iam_role.gateway_invoke_lambda - *terraform.GraphNodeConfigOutputFlat
module.iam.aws_iam_role_policy.invoke_lambda - *terraform.GraphNodeConfigResourceFlat
module.iam.aws_iam_role_policy.oneClick_lambda_basic_execution_1454641427156 - *terraform.GraphNodeConfigOutputFlat
module.iam.output.api_gateway_role_arn - *terraform.GraphNodeConfigResourceFlat
module.iam.output.lambda_function_role_id - *terraform.GraphNodeConfigResourceFlat
var.apex_function_hello - *terraform.GraphNodeConfigVariable
@JefStat
JefStat / api-gateway.tf
Created May 3, 2016 18:53
cannot create a wildcard lambda function
variable "function_hello" {}
resource "aws_api_gateway_rest_api" "Hello" {
name = "Hello World API"
description = "Terraform integration"
}
resource "aws_api_gateway_resource" "Hello" {
rest_api_id = "${aws_api_gateway_rest_api.Hello.id}"
parent_id = "${aws_api_gateway_rest_api.Hello.root_resource_id}"
provider.aws - *terraform.graphNodeResourceDestroy
aws_api_gateway_rest_api.Hello - *terraform.GraphNodeConfigResource
aws_api_gateway_rest_api.Hello (destroy tainted) - *terraform.graphNodeProvider
aws_api_gateway_rest_api.Hello (destroy) - *terraform.graphNodeResourceDestroy
provider.aws - *terraform.graphNodeResourceDestroy
aws_api_gateway_rest_api.Hello (destroy tainted) - *terraform.graphNodeResourceDestroy
aws_api_gateway_deployment.dev (destroy tainted) - *terraform.graphNodeProvider
aws_api_gateway_deployment.int (destroy tainted) - *terraform.graphNodeResourceDestroy
aws_api_gateway_integration.HelloGet (destroy tainted) - *terraform.graphNodeResourceDestroy
aws_api_gateway_integration.HelloOptions (destroy tainted) - *terraform.graphNodeResourceDestroy
@JefStat
JefStat / MoqExtensions.cs
Created May 7, 2018 13:22 — forked from ngocvantran/MoqExtensions.cs
Extension methods to quickly ignore arguments without repeating It.IsAny<>()
using System;
using System.Linq.Expressions;
using Moq.Language.Flow;
namespace Moq
{
public static class MoqExtensions
{
public static ISetup<T, TResult> SetupIgnoreArgs<T, TResult>(this Mock<T> mock,
Expression<Func<T, TResult>> expression)
@JefStat
JefStat / sumo_logic.config
Last active September 25, 2020 21:15
Elastic Beanstalk Sumo Logic Config
# This will automatically install the Sumo Logic collector on AWS Elastic
# Beanstalk instances. Add this to the .ebextensions folder in your app root
# To add or remove tracked files, simply add or remove source hashes to the
# sources array.
packages:
rpm:
SumoCollector: https://collectors.sumologic.com/rest/download/rpm/64
services:
sysvinit: