Skip to content

Instantly share code, notes, and snippets.

@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active June 3, 2024 09:38
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized

Docker Hub 镜像加速器

国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。Docker 官方和国内很多云服务商都提供了国内加速器服务。

Dockerized 实践 https://github.com/y0ngb1n/dockerized

配置加速地址

Ubuntu 16.04+、Debian 8+、CentOS 7+

@maxclav
maxclav / tinyURL.go
Last active June 3, 2024 09:36
Simple Key Generation (using base62 encoded hash) for Tiny URL in Go (GoLang).
package tinuURL
import (
"crypto/md5"
"fmt"
"time"
"github.com/google/uuid"
"github.com/jxskiss/base62"
)
@DanielSWolf
DanielSWolf / Program.cs
Last active June 3, 2024 09:32
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
using System;
using System.Threading;
static class Program {
static void Main() {
Console.Write("Performing some task... ");
using (var progress = new ProgressBar()) {
for (int i = 0; i <= 100; i++) {
progress.Report((double) i / 100);
@wojteklu
wojteklu / clean_code.md
Last active June 3, 2024 09:31
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@worldbeater
worldbeater / enumerate-and-replace.vba
Last active June 3, 2024 09:30
A Visual Basic for Applications (VBA) code for finding all references (e.g. [42], [2—3, 4]) and increasing their numbers based on the preconfigured N and M values. Useful when inserting a new reference into the beginning of the bibliography of a large DOCX.
Sub Highlight(Phrase As String)
Application.ScreenUpdating = False
With ActiveDocument
With .Range
With .Find
.ClearFormatting
.replacement.ClearFormatting
.Format = False
.Forward = True
.Wrap = wdFindStop
@NameOfTheDragon
NameOfTheDragon / filament_dryer.cfg
Last active June 3, 2024 09:29
Klipper macros for drying filament using the heated build plate of a 3D printer
; An idea for using the heated bed of a 3D printer as a filament dryer.
; Adds GCODE command: START_DRYER TIME=T TEMPERATURE=C
; (T is time in seconds, C is bed temperature in Celsuis)
; To stop drying early, use STOP_DRYER.
; Also defined some utility macros: DRY_PLA, DRY_PETG and DRY_ABS.
; Edit these with your own preferred defaults.
[gcode_macro START_DRYER]
description: Start the heated bed filament dryer.
gcode:
/**
* Cross-browser support for caretPositionFromPoint.
* This returns a `CaretPosition` like object instead
* of a CaretPosition, since we can't create it for
* browsers that don't support this API.
*/
function caretPositionFromPoint(x: number, y: number): {
offsetNode: Node;
offset: number;
getClientRect(): ClientRect | DOMRect;
@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active June 3, 2024 09:25
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active June 3, 2024 09:24
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: