Skip to content

Instantly share code, notes, and snippets.

View yanxurui's full-sized avatar

Xurui Yan yanxurui

View GitHub Profile
@anthonywu
anthonywu / graceful_auto_reconnect.py
Created January 29, 2012 01:25
Gracefully handle a PyMongo AutoReconnect
import functools
import pymongo
import logging
import time
MAX_AUTO_RECONNECT_ATTEMPTS = 5
def graceful_auto_reconnect(mongo_op_func):
"""Gracefully handle a reconnection event."""
@functools.wraps(mongo_op_func)
@jstangroome
jstangroome / Get-RemoteSSLCertificate.ps1
Last active June 12, 2024 16:09
PowerShell script to retrieve the public X509 certificate from a remote TLS endpoint
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[string]
$ComputerName,
[int]
$Port = 443
)
@koenpunt
koenpunt / chosen-bootstrap.css
Last active March 11, 2023 01:01
Bootstrap 3.0 theme for Chosen
select.form-control + .chosen-container.chosen-container-single .chosen-single {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;
@hehongwei44
hehongwei44 / demo.js
Created August 21, 2014 11:49
通过数组,拓展字符串拼接容易导致性能的问题。
function StringBuffer() {
this.__strings__ = new Array();
}
StringBuffer.prototype.append = function (str) {
this.__strings__.push(str);
return this;
}
StringBuffer.prototype.toString = function () {
return this.__strings__.join("");
}
@DavydLiu
DavydLiu / Mac-Port-Forwarding-OS-X.md
Last active January 17, 2019 16:13
Mac Port forwarding on OS X Yosemite 10.10 and above

##1. Create the anchor file:

sodu vim /etc/pf.anchors/com.liuxingruo

Inside the anchor file, enter:

rdr pass on lo0 inet proto tcp from any to self port 80 -> 127.0.0.1 port 9191
rdr pass on en0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 9191
rdr pass on en1 inet proto tcp from any to any port 80 -> 127.0.0.1 port 9191
@abravalheri
abravalheri / commit.md
Last active June 21, 2024 05:50 — forked from stephenparish/commit.md
RFC: Git Commit Message Guidelines

Commit Message Guidelines

In the last few years, the number of programmers concerned about writing structured commit messages have dramatically grown. As exposed by Tim Pope in article readable commit messages are easy to follow when looking through the project history. Moreover the AngularJS contributing guides introduced conventions that can be used by automation tools to automatically generate useful documentation, or by developers during debugging process.

This document borrows some concepts, conventions and even text mainly from these two sources, extending them in order to provide a sensible guideline for writing commit messages.

@htp
htp / curl-websocket.sh
Last active May 14, 2024 21:24
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@arthurattwell
arthurattwell / aliases-windows-.bashrc.sh
Last active June 10, 2023 03:01
Aliases for OSX Terminal and Windows command-prompt
#########################################
# Terminal aliases
# OSX: Save/add this to ~/.bash_profile
# Ubuntu: Add this to ~/.bashrc
# Windows Git Bash: Add this to ~/.bashrc
#########################################
# Uncomment one of the following two options
# - This for OSX:
# alias aliedit="code ~/.bash_profile"
@leonoverweel
leonoverweel / informatics-staff.md
Last active September 28, 2023 09:58
University of Edinburgh Informatics Academic Staff (October 2018)
Name Position Groups Personal Page Publications
Stefano Albrecht Lecturer in Artificial Intelligence Centre for Intelligent Systems and their Applications, Institute of Perception, Action and Behaviour Personal page link Publications link
Cristina Alexandru Research Associate Centre for Intelligent Systems and their Applications, Institute for Language, Cognition and Computation Personal page link Publications link
Paul Anderson Research Fellow Centre for Intelligent Systems and their Applications Personal page link [Publications link](http://www.research.ed.ac.uk/portal/en/persons
@leonoverweel
leonoverweel / exc-review.md
Last active December 12, 2018 14:21
Extreme Computing Exam Review