Skip to content

Instantly share code, notes, and snippets.

View lemon-li's full-sized avatar

Le Li lemon-li

  • KingSoft
  • Beijing
  • 07:30 (UTC +08:00)
View GitHub Profile
@lemon-li
lemon-li / bc4trialreset.cmd
Created December 1, 2023 06:31 — forked from zsoumya/bc4trialreset.cmd
Beyond Compare 4 Trial Reset
reg delete "HKCU\Software\Scooter Software\Beyond Compare 4" /v CacheID /f
// Swift's untyped errors are a goddam PiTA. Here's the pattern I use to try to work around this.
// The goal is basically to try to guarantee that every throwing function in the app throws an
// ApplicationError instead of some unknown error type. We can't actually enforce this statically
// But by following this convention we can simplify error handling
enum ApplicationError: Error, CustomStringConvertible {
// These are application-specific errors that may need special treatment
case specificError1
case specificError2(SomeType)
@lemon-li
lemon-li / install-salt-minion.sh
Created March 14, 2022 02:06 — forked from zhiguangwang/install-salt-minion.sh
Install salt-minion on Ubuntu
#!/bin/bash
set -e
SALT_VERSION='3001'
if [ -z "$1" ]; then
echo 'Please run this script with argument <salt-master address>'
exit 1
fi
@lemon-li
lemon-li / graceful.go
Last active April 18, 2022 02:07 — forked from aladhims/graceful_shutdown.go
Graceful Shutdown Go App
package graceful
import (
"context"
"log"
"os"
"os/signal"
"sync"
"syscall"
"time"
@lemon-li
lemon-li / ..build-protobuf-3.0.0.md
Created February 10, 2022 13:55 — forked from petewarden/..build-protobuf-3.0.0.md
Script used to build Google Protobuf 3.0.0 for use with Xcode 7 / iOS 9. Builds all supported architectures and produces a universal binary static library.

Google Protobuf 3.0.1 - Mac OS X and iOS Support

The script in this gist will help you buid the Google Protobuf library for use with Mac OS X and iOS. Other methods (such as homebrew or direct compilation) have issues that prevent their use. The libraries built by this script are universal and support all iOS device architectures including the simulator.

This gist was adapted from the original at https://gist.github.com/BennettSmith/7150245, and updated to deal with Xcode 7 and iOS 9, and download protobuf version 3.0.0.

@lemon-li
lemon-li / README.md
Created May 10, 2021 04:00 — forked from zhiguangwang/README.md
Extending Linux file system after resizing EBS volume

Extend partition on root volume

sudo growpart /dev/nvme0n1 1

Extend file system on root volume

ext4

@lemon-li
lemon-li / jenkins-home-git.sh
Created April 11, 2021 10:38 — forked from cenkalti/jenkins-home-git.sh
Backup Jenkins home periodicallly with git.
#!/bin/bash
# Setup
#
# - Create a new Jenkins Job
# - Mark "None" for Source Control Management
# - Select the "Build Periodically" build trigger
# - configure to run as frequently as you like
# - Add a new "Execute Shell" build step
# - Paste the contents of this file as the command
@lemon-li
lemon-li / gist:5b6d69ce67aa23fa98352f0e4f5e4257
Created February 27, 2021 10:39
Switch OpenSSL TLS security level from 2 to 1
RUN sed 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/' /etc/ssl/openssl.cnf > /etc/ssl/openssl.cnf.changed \
&& mv /etc/ssl/openssl.cnf.changed /etc/ssl/openssl.cnf
Let [tag] = any tag in upstream repo
git fetch upstream --tags
git push origin --tags
@lemon-li
lemon-li / gist:bb5b5d9b7ce203345b6c943791198408
Created December 2, 2020 12:02 — forked from sebsto/gist:6af5bf3acaf25c00dd938c3bbe722cc1
Start VNCServer on Mac1 EC2 Instance
# YouTube (english) : https://www.youtube.com/watch?v=FtU2_bBfSgM
# YouTube (french) : https://www.youtube.com/watch?v=VjnaVBnERDU
#
# On your laptop, connect to the Mac instance with SSH (similar to Linux instances)
#
ssh -i <your private key.pem> ec2-user@<your public ip address>
#
# On the Mac