Skip to content

Instantly share code, notes, and snippets.

Shichao An shichao-an

Block or report user

Report or block shichao-an

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@shichao-an
shichao-an / setup-ldap-client.sh
Last active Nov 11, 2019
Setup OpenLDAP client server with SSH access
View setup-ldap-client.sh
#!/bin/bash
# vim: softtabstop=4 shiftwidth=4 expandtab fenc=utf-8 spell spelllang=en cc=120
set -e
# Check Ubuntu release
[ "$(lsb_release -sc)" = "trusty" ] || {
echo 'This script should be run on Ubuntu 14.04.' >&2
exit 1
}
@shichao-an
shichao-an / build_mysql.sh
Last active Aug 4, 2019
Build and install MySQL 5.1 from source on Ubuntu 14.04
View build_mysql.sh
#!/bin/bash
# Run as root
set -e
apt-get update
apt-get install -y build-essential
apt-get install -y libncurses5-dev
useradd mysql
@shichao-an
shichao-an / setup-nss-ldapd.sh
Last active Jun 7, 2019
Setup nss-ldapd (OpenLDAP client) with SSH access
View setup-nss-ldapd.sh
#!/bin/bash
# vim: softtabstop=4 shiftwidth=4 expandtab fenc=utf-8 spell spelllang=en cc=120
set -e
# Check Ubuntu release
[ "$(lsb_release -sc)" = "trusty" ] || {
echo 'This script should be run on Ubuntu 14.04.' >&2
exit 1
}
@shichao-an
shichao-an / gist:8992bd6e03582dc474f5d86b6b2aa440
Last active Mar 29, 2019 — forked from psayre23/gist:c30a821239f4818b0709
Runtime Complexity of Java Collections
View gist:8992bd6e03582dc474f5d86b6b2aa440
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
@shichao-an
shichao-an / authors-prog.sh
Last active Aug 24, 2018
Script for git svn --authors-prog argument (author name conversion)
View authors-prog.sh
#!/usr/bin/env bash
# Script for converting author from SVN to Git, used as an argument for
# --authors-prog
# Example:
# "foo.bar" will be "Foo Bar <foo.bar@example.com>"
# "not-human" will be "not-human <not-human@example.com>"
set -e
EMAIL_DOMAIN=example.com
@shichao-an
shichao-an / tmpdownloads.plist
Created Apr 24, 2018
Create a Downloads directory on macOS startup/login
View tmpdownloads.plist
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.loginscript</string>
<key>ProgramArguments</key>
<array>
<string>/bin/mkdir</string>
<string>-p</string>
<string>/private/tmp/Downloads</string>
</array>
@shichao-an
shichao-an / common-password
Created Feb 4, 2015
/etc/pam.d/common-password
View common-password
#
# /etc/pam.d/common-password - password-related modules common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of modules that define the services to be
# used to change user passwords. The default is pam_unix.
# Explanation of pam_unix options:
#
# The "sha512" option enables salted SHA512 passwords. Without this option,
@shichao-an
shichao-an / ebs_lvm.sh
Created Aug 26, 2014
Create LVM on EBS
View ebs_lvm.sh
#!/bin/bash
ebs_disk="/dev/xvdf"
ebs_partition="/dev/xvdf1"
vg_name="vg"
pv_name="pv1"
mount_point="/mnt"
# Create a primary partition on $ebs_disk using all space
View setup-audit.sh
#!/bin/bash
# Setup and enable auditd
# MUST REBOOT AFTER SETUP
#
# FUNCTIONALITIES:
#
# * Auditing user TTY
# aureport --tty
#
# * Auditing root commands (real uid)
@shichao-an
shichao-an / ldap_disable_bind_anon.ldif
Created Feb 3, 2015
Ubuntu and LDAP: force authentication during a bind request
View ldap_disable_bind_anon.ldif
# ldapadd -Y EXTERNAL -H ldapi:/// -f ldap_disable_bind_anon.ldif
dn: cn=config
changetype: modify
add: olcDisallows
olcDisallows: bind_anon
dn: cn=config
changetype: modify
add: olcRequires
olcRequires: authc
You can’t perform that action at this time.