Skip to content

Instantly share code, notes, and snippets.

@segor
segor / Lock.gs
Last active November 9, 2021 05:08
Wraps LockService with retry logic and fixes the "Too many LockService operations" Error. https://issuetracker.google.com/issues/112384851
/**
* Wraps LockService with retry logic and fixes the "Too many LockService operations" Error. https://issuetracker.google.com/issues/112384851
*/
class Lock {
constructor(lock) {
this._lock = lock;
}
waitLock(timeoutInMillis) {
return Lock._retry(() => this._lock.waitLock(timeoutInMillis));
@segor
segor / Dockerfile
Created November 19, 2018 10:53
.net + core dump + lldb
FROM microsoft/dotnet:2.1.6-aspnetcore-runtime-stretch-slim
# Install debugging tools
## Install GDB (to create core dumps) and process tools
RUN apt-get update && apt-get -y install \
gdb \
procps
## Install LLDB debugger
RUN apt-get -y install lldb-4.0
// persissted data
public class Company{
public int Id {get; set}
public string Name {get; set}
}
public class ProductContext : DbContext
{
public DbSet<Company> Companies { get; set; }
}
@segor
segor / gist:1146668314c42b9cf73f
Created April 30, 2015 15:20
How to check if a TCP port is available for listening
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
public bool TcpPortIsAvailableForListening(int port)
{
IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();
IPEndPoint[] tcpEndPointArray = ipGlobalProperties.GetActiveTcpListeners();
var isUnavailable = tcpEndPointArray.Any(endPoint => endPoint.Port == port);