Skip to content

Instantly share code, notes, and snippets.

Avatar

Jian Li kidlj

View GitHub Profile
@devtdeng
devtdeng / verify_certificate.go
Last active Nov 10, 2021
Verify a certificate with chain with golang crypto library
View verify_certificate.go
package main
import (
"crypto/x509"
"encoding/pem"
"io/ioutil"
"log"
"os"
)
@Phlow
Phlow / pagination-collection.liquid
Last active May 3, 2021
If you need pagination for a collection in a Jekyll theme, you can use the following Liquid logic which works also on Github pages
View pagination-collection.liquid
{% comment %}
#
# I modified the original code from http://anjesh.github.io/2015/01/25/collection-pagination-working-github-pages/
#
# Make a collection in _config.yml and create the folder _your_collection in your root.
#
# collections:
# your_collection:
# output: true
# permalink: /:collection/:title/
@tonysneed
tonysneed / Mac OS X: Open in Visual Studio Code
Last active Dec 14, 2021
Add a command to Finder services in Mac OSX to open a folder in VS Code
View Mac OS X: Open in Visual Studio Code
- Open Automator
- File -> New -> Service
- Change "Service Receives" to "files or folders" in "Finder"
- Add a "Run Shell Script" action
- Change "Pass input" to "as arguments"
- Paste the following in the shell script box: open -n -b "com.microsoft.VSCode" --args "$*"
- Save it as something like "Open in Visual Studio Code"
@Phlow
Phlow / jekyll-sorted-category-for-loop-alphabetical-date.liquid
Last active Jun 11, 2021
Jekyll (Liquid) for loop to sort posts by category in alphabetical or date-based or similiar order.
View jekyll-sorted-category-for-loop-alphabetical-date.liquid
{% comment %}
#
# Change date order by adding '| reversed'
# To sort by title or other variables use {% assign sorted_posts = category[1] | sort: 'title' %}
#
{% endcomment %}
{% assign sorted_cats = site.categories | sort %}
{% for category in sorted_cats %}
{% assign sorted_posts = category[1] | reverse %}
<h2 id="{{category[0] | uri_escape | downcase }}">{{category[0] | capitalize}}</H2>
@nooop3
nooop3 / shadowsocks-client.service
Created Oct 28, 2015
Shadsocks client service for CentOS 7. Touch file /etc/shadowsocks/config.json, and copy this to /etc/systemd/system/shadowsocks-client.service. After of all, type systemctl start shadowsocks-client and systemctl enable shadowsocks-client to add it to startup.
View shadowsocks-client.service
[Unit]
Description=Shadowsocks Client
After=network.target
[Service]
Type=forking
PIDFile=/run/shadowsocks/ss-client.pid
PermissionsStartOnly=yes
ExecStartPre=/bin/mkdir -p /run/shadowsocks
ExecStartPre=/bin/chown root:root /run/shadowsocks
@denji
denji / golang-tls.md
Last active Jan 27, 2022 — forked from spikebike/client.go
Simple Golang HTTPS/TLS Examples
View golang-tls.md

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@ethagnawl
ethagnawl / .inputrc
Last active May 5, 2021
Display Vim mode in Bash prompt
View .inputrc
# requires >= Bash 4.3
# note: the prompt will not be updated if you use a custom PS1 which contains a newline character
set editing-mode vi
set keymap vi-command
set show-mode-in-prompt on
# if it's configured correctly, your prompt will be prefixed with a `+` while in insert mode and a `:` when in command mode.
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active Jan 21, 2022
how to delete a git tag locally and remote
View git-tag-delete-local-and-remote.sh
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@jedschneider
jedschneider / gh-pages-tips.md
Created Jun 7, 2012
github pages tips for jekyll wiki
View gh-pages-tips.md

Working With Github Pages

The FAQ maintained by Github covers most stumbling blocks, some other tips and tricks supplied here.

Gitignore

Add _site to .gitignore. The generated site should not be uploaded to Github since its gets generated by github.

Working With Code Partials

@icyleaf
icyleaf / post-receive.sh
Created Sep 6, 2010
git autodeploy script when it matches the string "[deploy]"
View post-receive.sh
#!/bin/sh
#
# git autodeploy script when it matches the string "[deploy]"
#
# @author icyleaf <icyleaf.cn@gmail.com>
# @link http://icyleaf.com
# @version 0.1
#
# Usage:
# 1. put this into the post-receive hook file itself below