Skip to content

Instantly share code, notes, and snippets.

View robertlyson's full-sized avatar

Robert robertlyson

  • Ministry of Ideas
  • Kraków
View GitHub Profile
@pwillis-els
pwillis-els / Heap_Dump_Java_AWS_ECS.md
Created June 29, 2020 14:13
Dumping heap of a Java process running in AWS ECS

Heap dumping a Java process running in AWS ECS

Note: this guide is designed for AWS ECS services, but starting from Step 4 is functionally equivalent to any Docker container on a Linux host.

Step 1. Look up ECS service

  1. Log into the AWS Console using the appropriate AWS account
  2. Navigate to AWS ECS service clusters (https://console.aws.amazon.com/ecs/home)
  3. Make sure you are in the correct region, if not, switch to the correct region (second drop-down menu in top right corner)
  4. Select the correct cluster (ex: https://console.aws.amazon.com/ecs/home?region=us-east-1#/clusters//services)
  5. In the Services tab, In the 'Filter in this page' text box, type the name of the service
@GetoXs
GetoXs / ServiceCollectionExtentions.cs
Last active March 2, 2024 06:06
Register All Types (with Generic) in .NET Core DependencyInjection
using System;
using System.Linq;
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
public static class ServiceCollectionExtentions
{
public static void AddAllTypes<T>(this IServiceCollection services
, Assembly[] assemblies
, bool additionalRegisterTypesByThemself = false
private static Func<Process, string> GetProcessNameAccessor()
{
var param = Expression.Parameter(typeof(Process), "arg");
var processInfoMember = Expression.Field(param, "processInfo");
var processNameMember = Expression.Field(processInfoMember, "processName");
var lambda = Expression.Lambda(typeof(Func<Process, string>), processNameMember, param);
return (Func<Process, string>)lambda.Compile();
}
@yashdeeph709
yashdeeph709 / ProfilingOverTunnel
Last active January 18, 2024 01:36
How to connect visual vm java profiler over ssh tunnel through bastion/jump server.
Prerequisite : Public Key Setup is required for using this setup
1. First open ~/.ssh/config file and add these lines filling the appropriate details.
This will setup a netcat tunnel through jump server which will forward all your traffic to mail machine.
```
Host <HOSTNAME>
User <USERNAME>
HostName <HOSTNAME>
ProxyCommand ssh <JUMPSERVER-USER>@<JUMPSERVER-ADDR> nc %h %p 2> /dev/null
```
2. ssh -v -D :port: :username:@:hostname:
@jclosure
jclosure / contains_key_or_empty.txt
Created July 3, 2017 05:33
Kibana Painless scripted field checks if field exists or is empty and returns default, otherwise value
if (!doc.containsKey('myfield') || doc['myfield'].empty) { return "unavailable" } else { return doc['myfield'].value }
@viktorklang
viktorklang / ExecutionContextExecutorServiceBridge.scala
Last active June 27, 2022 11:38
Turning an ExecutionContext to an ExecutorService (or rather and ExecutorService AND an ExecutionContext) using Scala 2.10+
/*
Copyright 2013 Viktor Klang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and