Skip to content

Instantly share code, notes, and snippets.

View zz's full-sized avatar
💭
I may be slow to respond.

ZZ zz

💭
I may be slow to respond.
  • Japan
View GitHub Profile
@zz
zz / check_backup.pl
Created August 9, 2012 10:23 — forked from n8v/check_backup.pl
Nagios Plugin for checking a backup file for existence, age and size.
#!/usr/bin/perl
### check_backup.pl
# By Nathan Vonnahme, Sept 2011
# An example for "Writing Custom Nagios Plugins in Perl" at the Nagios
# World Conference North America 2011.
# I. Prologue
#!/usr/bin/env python2
import re, sys, os, urllib
re_songs = re.compile(r'\'sid\': \'(.+?)\', \'sname\': \'(.+?)\'')
re_name = re.compile(r'\\&.+?;')
template_wgets = 'wget -nv -c -O "%s" %s'
durl = 'http://yinyueyun.baidu.com/data/cloud/downloadsongfile\?songIds\=%s\&rate\=320'
def modified_sname(sname):
sname = sname.replace('\\'', '\'')
curl --socks5 127.0.0.1:7070 http://cn.nytimes.com/ 2>/dev/null | grep -o '<a href="[^"]\+" title="[^"]\+"' | sed -e 's/<a href="//g' | sed -e 's/" title="/ /g' | sed -e 's/"//g' | while read url title
do if [[ ${url:0:5} != "http:" ]]
then
url="http://cn.nytimes.com$url"
fi
echo $url | mail -s "$title" [email protected]
done
# Nginx can serve FLV/MP4 files by pseudo-streaming way without any specific media-server software.
# To do the custom build we use 2 modules: --with-http_secure_link_module --with-http_flv_module
# This module "secure-link" helps you to protect links from stealing away.
#
# NOTE: see more details at coderwall: http://coderwall.com/p/3hksyg
cd /usr/src
wget http://nginx.org/download/nginx-1.5.13.tar.gz
tar xzvf ./nginx-1.5.13.tar.gz && rm -f ./nginx-1.5.13.tar.gz
@zz
zz / tls-client
Last active August 29, 2015 14:14 — forked from michaljemala/tls-client.go
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"io/ioutil"
"log"
"net/http"
)
@zz
zz / hipchat.js
Last active August 29, 2015 14:14 — forked from hakobera/hipchat.js
/**
* HipChat client for Google Apps Script.
* This code is based on node-hipchat https://github.com/nkohari/node-hipchat/blob/master/lib/hipchat.js
*/
(function(global) {
var HipChatClient = (function () {
HipChatClient.prototype.host = 'api.hipchat.com';
function HipChatClient(apikey) {
@zz
zz / client.go
Last active August 29, 2015 14:15 — forked from spikebike/client.go
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"log"
)
@zz
zz / CoreOS swap
Last active August 29, 2015 14:18 — forked from kacinskas/CoreOS swap
# swith to sudo
sudo -i
# create swap
touch /2GiB.swap
chattr +C /2GiB.swap
fallocate -l 2048m /2GiB.swap
chmod 600 /2GiB.swap
mkswap /2GiB.swap

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
# force HTTP to HTTPS - /etc/nginx/conf.d/nonssl.conf
server {
listen 80;
server_name jira.example.com;
access_log off;
return 301 https://$server_name$request_uri;
}
# /etc/nginx/conf.d/jira.conf
server {