Skip to content

Instantly share code, notes, and snippets.

Avatar

Demis Bellot mythz

View GitHub Profile
View unary invoke
static Task<TResponse> Execute<TRequest, TResponse>(this Channel channel, TRequest request, string serviceName, string methodName,
CallOptions options = default, string? host = null)
where TRequest : class
where TResponse : class
=> Execute<TRequest, TResponse>(new DefaultCallInvoker(channel), request, serviceName, methodName, options, host);
static async Task<TResponse> Execute<TRequest, TResponse>(this CallInvoker invoker, TRequest request, string serviceName, string methodName,
CallOptions options = default, string? host = null)
where TRequest : class
where TResponse : class
{
View thread-pools.md

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.

@int128
int128 / README.md
Last active Nov 28, 2022
Watching build mode on Create React App
View README.md

Create React App does not provide watching build mode oficially (#1070).

This script provides watching build mode for an external tool such as Chrome Extensions or Firebase app.

How to Use

Create a React app.

Put the script into scripts/watch.js.

@coryt
coryt / ThrottlePlugin.cs
Created Jan 26, 2015
ServiceStack plugin to throttle api requests
View ThrottlePlugin.cs
public class ThrottlePlugin : IPlugin
{
/// <param name="redisHost">host name</param>
/// <param name="redisPort">port</param>
/// <param name="redisPassword">password</param>
public ThrottlePlugin(string redisHost, int redisPort, string redisPassword = null)
{
_redisClient = new RedisClient(redisHost, redisPort, redisPassword);
}
@charlessolar
charlessolar / gist:4826cd1af0fabfac5b8f
Last active Mar 14, 2018
Servicestack OAuth JWT Verification
View gist:4826cd1af0fabfac5b8f
this.GlobalRequestFilters.Add((httpReq, httpResp, requestDto) =>
{
var header = httpReq.Headers["Authorization"];
if( header.IsNullOrEmpty() ) {
httpResp.StatusCode = (int)HttpStatusCode.Unauthorized;
httpResp.EndRequest();
}
try
View snk.ps
exec { & $tools_dir\ildasm.exe /NOBAR /OUT="$dist_dir\net40\AutoMapper.il" "$dist_dir\net40-un\AutoMapper.dll" }
exec { & $framework_dir\ilasm.exe /QUIET /KEY="$source_dir\AutoMapper.snk" /DLL="$dist_dir\net40\AutoMapper.dll" /RESOURCE="$dist_dir\net40\AutoMapper.res" "$dist_dir\net40\AutoMapper.il" }
@zelid
zelid / gist:6965002
Last active Nov 3, 2022
Examples of BulkInsert for PostgreSQL, MySQL and MS SQL using ServiceStack OrmLite. Work in progress...
View gist:6965002
public static void BulkInsertNpgsql<T>(this IDbConnection dbConn, IEnumerable<T> list, IEnumerable<string> insertFields = null)
{
if (list == null) return;
if (list.Count() < 1) return;
var objWithAttributes = list.FirstOrDefault();
var modelDef = OrmLiteConfig.GetModelDefinition(objWithAttributes.GetType());
if (insertFields == null) insertFields = new List<string>();
@eevee
eevee / spabs.md
Last active Apr 14, 2022
tabs to spaces
View spabs.md
@munificent
munificent / gist:6136198
Created Aug 1, 2013
For kicks, I scraped Github's language pages and sorted them by rank
View gist:6136198
#1 JavaScript
#2 Ruby
#3 Java
#4 Shell
#5 Python
#6 PHP
#7 C
#8 C++
#9 Perl
#10 CoffeeScript
@aaronlerch
aaronlerch / gist:5664860
Created May 28, 2013
ServiceStack self-host workaround for VirtualPathUtility exception. If you're self-hosting recent versions of ServiceStack (3.9.45+) and serving Razor views, you'll notice that @href (which is a wrapper around Url.Content) fails with app-relative paths that start with "~/". Add the following to your startup code to work around it.
View gist:5664860
var domain = Thread.GetDomain(); // or AppDomain.Current
domain.SetData(".appDomain", "yep");
domain.SetData(".appVPath", "/");
domain.SetData(".appPath", domain.BaseDirectory);
if (String.IsNullOrWhiteSpace(domain.GetData(".appId") as string))
{
domain.SetData(".appId", "1");
}
if (String.IsNullOrWhiteSpace(domain.GetData(".domainId") as string))
{