Skip to content

Instantly share code, notes, and snippets.

@xhit
xhit / parseduration.go
Created August 8, 2020 05:59
Golang ParseDuration with days and weeks
package main
import (
"errors"
"fmt"
"time"
)
func main() {
dur, _ := ParseDuration("1.000000001s")
@jaytaylor
jaytaylor / delete-from-v2-docker-registry.md
Last active September 11, 2025 15:46
One liner for deleting images from a v2 docker registry

One liner for deleting images from a v2 docker registry

Just plug in your own values for registry and repo/image name.

registry='localhost:5000'
name='my-image'
curl -v -sSL -X DELETE "http://${registry}/v2/${name}/manifests/$(
    curl -sSL -I \
        -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
@SerhoLiu
SerhoLiu / safe_rotating_file_handler.py
Last active May 30, 2024 08:54
Python multiprocessing safe RotatingFileHandler
import multiprocessing
from logging.handlers import RotatingFileHandler
class SafeRotatingFileHandler(RotatingFileHandler):
"""
多进程下 RotatingFileHandler 会出现问题
"""
_rollover_lock = multiprocessing.Lock()
@morrxy
morrxy / golang-framework.md
Created April 27, 2017 06:04
[go语言框架选择问题] #tags: golang

go框架选择观点与分类

因为go的标准库net/http功能非常全,所以关于go语言的框架使用有三种观点:

  1. 不用框架:

    因为go的标准库net/http功能非常全。只需要用一个完成路由和路由参数的库,加上海量的能满足任何需求(比如session什么的)的中间件就行了。目的是代码里始终使用net/http,保持最大的兼容性。不需要为了符合框架去写一些奇怪的shim程序。

  2. 轻量级框架:

@patrickmmartin
patrickmmartin / PYTHON_DEFAULT.md
Created February 5, 2017 09:48
update-alternatives for python3 on Ubuntu

Ubuntu 16 default python is almost python 3

Loads of solutions exist, but for changing the system default, alias is not the way to go.

$ update-alternatives --list python update-alternatives: error: no alternatives for python

@aldeed
aldeed / fix_ios_errors.md
Last active February 13, 2020 10:06
Fix iOS Project Swift Errors

Fix iOS Project Swift Errors

In order to build the iOS app in the latest XCode, you need to convert the project to Swift 3.0. After you do this, when you try to run or archive the project, you will get a bunch of errors. This section explains how to fix them.

IMPORTANT NOTE: Fix all the RED errors. There will also be yellow triangles and the option to "update to recommended settings". Do NOT fix these things and do NOT update to recommended settings.

Info from Apple on what has changed in Swift: http://adcdownload.apple.com/Developer_Tools/Xcode_8_beta_6/Release_Notes_for_Xcode_8_beta_6.pdf ("New in Xcode 8 beta 6 - Swift Compiler" section on page 8)

"NSURL" is not implicitly convertible to "URL"

@FatalCatharsis
FatalCatharsis / test.cpp
Last active July 28, 2021 15:03
A poco http example
Poco::JSON::Object obj;
obj.set("name", "blah");
obj.set("language", "english");
Poco::URI uri("http://the-uri-you-want-to-request-from");
std::string path(uri.getPathAndQuery());
if (path.empty()) path = "/";
HTTPClientSession session(uri.getHost(), uri.getPort());
HTTPRequest request(HTTPRequest::HTTP_POST, path, HTTPMessage::HTTP_1_1);
@dtjm
dtjm / join_test.go
Last active May 20, 2025 06:16
Benchmarking various ways of concatenating strings in Go
package join
import (
"fmt"
"strings"
"testing"
)
var (
testData = []string{"a", "b", "c", "d", "e"}
@t-mat
t-mat / poco-https.cpp
Created October 23, 2014 16:39
POCO : https example
#include "Poco/Exception.h"
#include "Poco/StreamCopier.h"
#include "Poco/URI.h"
#include "Poco/URIStreamOpener.h"
#include "Poco/Net/HTTPStreamFactory.h"
#include "Poco/Net/HTTPSStreamFactory.h"
#include "Poco/Net/AcceptCertificateHandler.h"
#include "Poco/Net/InvalidCertificateHandler.h"
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active January 6, 2026 22:36
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k