Skip to content

Instantly share code, notes, and snippets.

View zhiguangwang's full-sized avatar

Zhiguang Wang zhiguangwang

View GitHub Profile
@snigdhasjg
snigdhasjg / uom-swagger.yml
Last active February 19, 2024 08:54
Shows how discriminator can be used
openapi: 3.0.3
info:
title: Unit of measure
description: Gives ratio
version: "0.0.1"
servers:
- url: 'https://uom.com/v1'
tags:
- name: UOM
description: Unit of measure
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="melefans@gmail.com"
CORRECT_NAME="lemon-li"
CORRECT_EMAIL="lile1@kingsoft.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
@rise-worlds
rise-worlds / For Mac 4.2.6 unlimited trial.md
Last active May 7, 2024 01:46 — forked from satish-setty/trial.md
Beyond Compare 4 license for Windows, Mac, Linux

for 4.2.4 or higher, 4.2.5,4.2.6,4.3.7, it's works, this is the way which makes Always in evaluation mode.

  1. open Terminal, go to the dir : cd /Applications/Beyond Compare.app/Contents/MacOS
  2. change the name BCompare to BCompare.bak: mv BCompare BCompare.bak
  3. touch a file name BCompare , and chmod a+ux BCompare : touch BCompare && chmod a+ux BCompare
  4. open BCompare with text editor, insert the script :
#!/bin/bash
rm "/Users/$(whoami)/Library/Application Support/Beyond Compare/registry.dat"
"`dirname "$0"`"/BCompare.bak $@
@soulmachine
soulmachine / jwt-expiration.md
Last active April 9, 2024 04:12
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

@schmichael
schmichael / nomad-consul-tls.md
Last active September 4, 2022 12:56
Nomad+Consul TLS Story

Nomad+Consul TLS Story

See https://github.com/schmichael/nomad-tls for sample configs.

Nomad issues

  • Consul uses ssl instead of tls config parameters
  • Consul uses verify_ssl instead of verify_tls
  • consul.cert_file should specify that it's the client certificate used for mutual authentication.
  • consul.{ca,cert,key}_file should default to tls.{ca,cert,key}_file
@ravibhure
ravibhure / git_rebase.md
Last active April 3, 2024 08:38
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream

@Jimmy-Xu
Jimmy-Xu / shadowsocks_privoxy_tsocks.md
Last active April 29, 2022 15:00
shadowsocks+privoxy/tsocks

shadowsocks + privoxy/tsocks

  • shadowsocks: service, socks proxy
  • privoxy: service, convert socks proxy to http proxy
  • tsocks: tool, use socks proxy for any command line

Usage

tested under ubuntu14.04

@Jimmy-Xu
Jimmy-Xu / sslocal
Created February 4, 2016 06:20
/etc/init.d/sslocal
#!/bin/bash
set -e
### BEGIN INIT INFO
# Provides: sslocal
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
@petewarden
petewarden / ..build-protobuf-3.0.0.md
Last active September 27, 2022 08:19 — forked from BennettSmith/..build-protbuf-2.5.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.

@dialt0ne
dialt0ne / get_aws_dns_ip.sh
Created December 17, 2015 22:44
Get AmazonProvidedDNS IP address from the EC2 meta-data
MAC_ADDR=`curl -s http://169.254.169.254/latest/meta-data/mac`
CIDR_FULL=`curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MAC_ADDR}/vpc-ipv4-cidr-block`
CIDR_BASE=`echo ${CIDR_FULL} | cut -d/ -f1 | cut -d\. -f1-3`
LAST_OCTET=`echo ${CIDR_FULL} | cut -d/ -f1 | cut -d\. -f4`
DNS_OCTET=`expr ${LAST_OCTET} + 2`
DNS_IP="${CIDR_BASE}.${DNS_OCTET}"
echo $DNS_IP