Skip to content

Instantly share code, notes, and snippets.

@shichao-an
shichao-an / install_logstash_forwarder.sh
Created January 14, 2015 01:04
Install logstash-forwarder
#!/bin/bash
# Run as root
wget -O - http://packages.elasticsearch.org/GPG-KEY-elasticsearch | apt-key add -
echo 'deb http://packages.elasticsearch.org/logstashforwarder/debian stable main' | tee /etc/apt/sources.list.d/logstashforwarder.list
apt-get update
apt-get install -y logstash-forwarder
update-rc.d logstash-forwarder defaults
@shichao-an
shichao-an / restartfw.sh
Last active August 29, 2015 14:13
Restart firewall on OS X
#!/bin/bash
# Restart firewall on OS X 10.9 and 10.10
# This script only works if you already turned on your firewall
if /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate | grep 'Firewall is disabled.' > /dev/null
then
echo 'Firewall is turned off.' >&2
else
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off && sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
fi
@shichao-an
shichao-an / upload.txt
Created January 20, 2015 18:36
tail -n +1 *.dump > upload.txt
==> 530528_http_-_interface.bilibili.com_playurlappkey=1_cid=792790.dump <==
<?xml version="1.0" encoding="UTF-8"?>
<video>
<result>suee</result>
<timelength>1915660</timelength>
<framecount>34767313</framecount>
<src>400</src>
<letv-args><![CDATA[]]]></letv-args>
<from><![CDATA[sina]]></from>
<durl>
@shichao-an
shichao-an / openssh-lpk.ldif
Created February 3, 2015 22:02
ldapadd -Y EXTERNAL -H ldapi:/// -f openssh-lpk.ldif
dn: cn=openssh-lpk,cn=schema,cn=config
objectClass: olcSchemaConfig
cn: openssh-lpk
olcAttributeTypes: ( 1.3.6.1.4.1.24552.500.1.1.1.13 NAME 'sshPublicKey'
DESC 'MANDATORY: OpenSSH Public key'
EQUALITY octetStringMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )
olcObjectClasses: ( 1.3.6.1.4.1.24552.500.1.1.2.0 NAME 'ldapPublicKey' SUP top AUXILIARY
DESC 'MANDATORY: OpenSSH LPK objectclass'
MAY ( sshPublicKey $ uid )
@shichao-an
shichao-an / common-auth
Created February 4, 2015 00:05
/etc/pam.d/common-auth
#
# /etc/pam.d/common-auth - authentication settings common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of the authentication modules that define
# the central authentication scheme for use on the system
# (e.g., /etc/shadow, LDAP, Kerberos, etc.). The default is to use the
# traditional Unix authentication mechanisms.
#
# As of pam 1.0.1-6, this file is managed by pam-auth-update by default.
@shichao-an
shichao-an / common-account
Created February 4, 2015 00:06
/etc/pam.d/common-account
#
# /etc/pam.d/common-account - authorization settings common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of the authorization modules that define
# the central access policy for use on the system. The default is to
# only deny service to users whose accounts are expired in /etc/shadow.
#
# As of pam 1.0.1-6, this file is managed by pam-auth-update by default.
# To take advantage of this, it is recommended that you configure any
@shichao-an
shichao-an / common-session-noninteractive
Created February 4, 2015 00:13
/etc/pam.d/common-session-noninteractive
#
# /etc/pam.d/common-session-noninteractive - session-related modules
# common to all non-interactive services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of modules that define tasks to be performed
# at the start and end of all non-interactive sessions.
#
# As of pam 1.0.1-6, this file is managed by pam-auth-update by default.
# To take advantage of this, it is recommended that you configure any
#!/bin/bash
set -e
device=${1:-/dev/xvdf}
apt-get install -y xfsprogs
mkfs -t xfs $device
mkdir /vol
echo "$device /vol xfs defaults,noatime 0 0" >> /etc/fstab
mount -a
Kaguya was once a princess of the Lunarians, a race of people living on the Moon. She was exiled to Earth over a thousand years ago for the crime of using the forbidden Hourai Elixir to make herself immortal. Arriving on Earth one day, she was found by a bamboo cutter and dwelt among the humans she had once despised. Though the Lunarians looked upon humans with contempt, Kaguya came to love her new home. Tales of her unearthly beauty led men from all across the land to seek her hand in marriage, Fujiwara no Mokou's father being one of them, but none could successfully complete her trial of the Five Impossible Requests.
The first was to bring her the stone begging bowl of the Buddha from India. The second was to retrieve a jewelled branch from the island of Mount Hourai. The third was to seek the legendary robe of the fire-rat of China. The fourth was to retrieve a colored jewel from a dragon's neck. The final task was to find the legendary Cowry treasure of the swallows. These potent treasures were eventually
@shichao-an
shichao-an / install-docker-ufw.sh
Last active August 29, 2015 14:15
Install Docker on Ubuntu 14.04 with UFW
#!/bin/bash
set -e
apt-get update
# Install iptables-persistent
apt-get install -y iptables-persistent
# Enable UFW forwarding and open TCP port 2375
ufw enable
sed -i 's/\(DEFAULT_FORWARD_POLICY\)="DROP"/\1="ACCEPT"/g' /etc/default/ufw