Skip to content

Instantly share code, notes, and snippets.

View gsw945's full-sized avatar
🙏
buddha-like coding

玖亖伍 gsw945

🙏
buddha-like coding
View GitHub Profile
@Horusiath
Horusiath / Program.cs
Last active November 24, 2020 05:45
An interfaced generic-aware Akka.NET actor implementation
using System;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Configuration;
namespace AkkaDemos
{
public interface IGreeter
{
Task<string> Greet(IGreeter who);
@lvxianchao
lvxianchao / npm.taobao.sh
Last active October 26, 2025 09:55
设置 npm 和 yarn 的镜像源为淘宝镜像源
# ==========================================================
# NPM
# ==========================================================
npm set registry https://registry.npmmirror.com # 注册模块镜像
npm set disturl https://npmmirror.com/mirrors/node # node-gyp 编译依赖的 node 源码镜像
## 以下选择添加
npm set sass_binary_site https://registry.npmmirror.com/mirrors/node-sass # node-sass 二进制包镜像
npm set electron_mirror https://registry.npmmirror.com/mirrors/electron/ # electron 二进制包镜像
@xcaptain
xcaptain / AuthzMiddleware.cs
Last active September 6, 2021 09:57
casbinnet asp dotnet core setup
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using TodoApi.Services;
namespace TodoApi.Middlewares
{
public class AuthzMiddleware
{
private readonly RequestDelegate _next;
@Horusiath
Horusiath / Demo.cs
Last active November 24, 2020 06:04
Custom Akka.NET Streams graph stage for prefetching elements, when the buffer comes close to the empty
using Akka.Streams;
using Akka.Streams.Stage;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Demo
{
sealed class PreFetch<T> : GraphStage<SourceShape<T>>
@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active September 11, 2026 14:23
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized
@setu1421
setu1421 / UploadUtilityHelper.cs
Created April 6, 2019 06:41
Utility helper for uploading large files to AWS S3 bucket
public class UploadUtilityHelper
{
private readonly string bucketName = ConfigurationManager.AppSettings["BucketName"];
private static readonly RegionEndpoint bucketRegion = RegionEndpoint.USEast1;
public string UploadChunk(string fileName, string uploadId, int chunkIndex, int chunkMax, Stream stream, string prevETags)
{
var response = "";
try
@Egor-Skriptunoff
Egor-Skriptunoff / utf8_filenames.lua
Last active April 4, 2026 09:14
UTF-8 filenames on Windows in pure Lua
------------------------------------------------------------------------------------------------------------------------------
-- Module: utf8_filenames
------------------------------------------------------------------------------------------------------------------------------
-- Filename: utf8_filenames.lua
-- Version: 2019-07-13
-- License: MIT (see at the end of this file)
-- This module modifies standard Lua functions so that they work with UTF-8 filenames on Windows:
-- io.open
-- io.popen
@bitinn
bitinn / pre-commit
Last active September 5, 2024 06:50
pre-commit hook to prevent large file on git commit (and allow git-lfs tracked binary files to pass through)
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
# Redirect output to stderr.
@Bernardoow
Bernardoow / SWAGGER_SETTINGS
Created November 10, 2018 19:47
Django Rest Swagger
SWAGGER_SETTINGS = {
'SECURITY_DEFINITIONS': {
'api_key': {
'type': 'apiKey',
'in': 'header',
'name': 'Authorization'
}
},
'CUSTOM_HEADERS': {
'HTTP_AUTHORIZATION': 'Token a476957f3c20a3a262a760fc2194569315ea5670'
@frankhu-2021
frankhu-2021 / PrettifyJSON
Last active February 14, 2025 18:58
PrettyPrint JSON with .NET using Newtonsoft.Json
using Newtonsoft.Json;
public static string JsonPrettify(string json)
{
using (var stringReader = new StringReader(json))
using (var stringWriter = new StringWriter())
{
var jsonReader = new JsonTextReader(stringReader);
var jsonWriter = new JsonTextWriter(stringWriter) { Formatting = Formatting.Indented };
jsonWriter.WriteToken(jsonReader);