Skip to content

Instantly share code, notes, and snippets.

@fengli320
fengli320 / sshd_gitbash.sh
Last active December 21, 2022 06:34
How to setup SSHD in Git Bash
# Precondition: Git for Windows 2.9.0 + Windows 7, other version of Git for Windows & Windows XP and Windows 10 should also be supported
# In /etc/ssh/sshd_config, set UsePrivilegeSeparation to no
# You can also change other settings of SSHD like port in this file
# Generate key pairs
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -q -N ""
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -q -N ""
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -q -N ""
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -q -N ""
#!/usr/bin/env bash
#set -x
# Delete references to SVN branches that no longer exist
# Usage (this will not execute without asking you to confirm the list):
# bin/git-svn-prune.sh
# Started with
# Set your SVN prefix
@fengli320
fengli320 / using_git-svn.md
Created June 9, 2020 00:40 — forked from rickyah/using_git-svn.md
A simple guide to git-svn

#Getting started with git-svn

git-svn is a git command that allows using git to interact with Subversion repositories.git-svn is part of git, meaning that is NOT a plugin but actually bundled with your git installation. SourceTree also happens to support this command so you can use it with your usual workflow.

Reference: http://git-scm.com/book/en/v1/Git-and-Other-Systems-Git-and-Subversion

##Cloning the SVN repository

You need to create a new local copy of the repository with the command

@fengli320
fengli320 / svn_workflow.sh
Created June 11, 2020 13:54 — forked from hendrauzia/svn_workflow.sh
SVN Workflow
# create working directory from trunk
svn checkout http://somedomain.com/repo/trunk
# create a branch
svn copy http://somedomain.com/repo/trunk \
http://somedomain.com/repo//branches/feature-do-awesome-thing \
-m "Created branch to implement feature do awesome thing."
# switch working copy
svn switch ^/repo/branches/feature-do-awesome-thing
@fengli320
fengli320 / gitlab-error-encryption.md
Created August 28, 2020 10:16 — forked from aursu/gitlab-error-encryption.md
GitLab error OpenSSL::Cipher::CipherError () in app/controllers/admin/application_settings_controller.rb:40:in `update'

The issue

It happened after secrets file was lost during GitLab upgrade.

The case described in documentation When the secrets file is lost

But not completely clear.

From log file /var/log/gitlab/gitlab-rails/production.log:

@fengli320
fengli320 / gitea-backup.sh
Created August 29, 2020 07:30 — forked from bst27/gitea-backup.sh
A Gitea backup script for Docker: It creates a .zip backup of Gitea running inside Docker and moves the backup file to the current working directory.
#!/bin/bash
# This script creates a .zip backup of gitea running inside docker and copies the backup file to the current working directory
echo "Creating gitea backup inside docker containter ..."
docker exec -u git -it -w /tmp $(docker ps -qf "name=gitea_server_1") bash -c '/app/gitea/gitea dump -c /data/gitea/conf/app.ini --file /tmp/gitea-dump.zip'
echo "Copying backup file from the container to the host machine ..."
docker cp $(docker ps -qf "name=gitea_server_1"):/tmp/gitea-dump.zip /tmp
@fengli320
fengli320 / CallerInfoAttibuteNet4.cs
Last active April 10, 2021 14:35 — forked from svick/CallerInfoAttibuteNet4.cs
How to use caller info attributes on .Net 4.0
// Visual Studio 2012 or above is required
using System;
using System.Runtime.CompilerServices;
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
public class CallerMemberNameAttribute : Attribute
{
}
@fengli320
fengli320 / async.cs
Created April 13, 2021 23:56 — forked from dgrunwald/async.cs
Async/Await support for .NET 4.0
// Copyright (c) 2012 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
@fengli320
fengli320 / UnitTests.cs
Created April 21, 2021 00:30 — forked from StephenCleary/UnitTests.cs
How StartNew responds to CancellationToken
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class StartNewCancellationTokenUnitTests
{
[TestMethod]
public void CancellationTokenPassedToStartNew_CancelsTaskWithTaskCanceledException()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from ctypes import *
from ctypes.wintypes import *
INVALID_HANDLE_VALUE = -1
CREATE_UNICODE_ENVIRONMENT = 0x00000400