Skip to content

Instantly share code, notes, and snippets.

View lambdacpp's full-sized avatar

He Yuan lambdacpp

  • Zhiyisoft Co.
  • Chengdu,Sichuan
View GitHub Profile
# removes trailing slashes (prevents SEO duplicate content issues)
if (!-d $request_filename)
{
rewrite ^/(.+)/$ /$1 permanent;
}
# removes trailing "index" from all controllers
if ($request_uri ~* index/?$)
{
rewrite ^/(.*)/index/?$ /$1 permanent;
@lambdacpp
lambdacpp / gist:f3315bd605178c22c75b
Created August 29, 2015 07:33
nginx服务default文件配置(替换_new_host_)
server {
listen 80;
client_max_body_size 20M;
server_name _new_host_.cdu.edu.cn;
charset UTF-8;
index default.html default.htm default.php index.html index.htm index.php;
set $root /var/www/_new_host_/wwwroot/public/www;
markdown_string = 'Markdown *String* '
uri = URI('https://api.github.com/markdown/raw')
https = Net::HTTP.new(uri.host,uri.port)
https.use_ssl = true
req = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'text/plain'})
req.body = markdown_string
res = https.request(req)
@lambdacpp
lambdacpp / create_vm_by_template.sh
Last active December 23, 2015 15:39
使用模板创建虚拟机的脚本
#!/bin/sh
template_name="Debian 7 Template"
default_vlan=101
Usage()
{
echo "$0 new_vm_name [vlan_id]"
echo " vlanid default 101"
}
#! /bin/sh
echo "CPU temp :"
sysctl -a |egrep -E "cpu\.[0-9]+\.temp"
echo
echo "HDD temp :"
for i in $(sysctl -n kern.disks)
do
DevTemp=`smartctl -a /dev/$i | awk '/Temperature_Celsius/{print $0}' | awk '{print $10 "C"}'`
DevSerNum=`smartctl -a /dev/$i | awk '/Serial Number:/{print $0}' | awk '{print $3}'`
DevName=`smartctl -a /dev/$i | awk '/Device Model:/{print $0}' | awk '{print $3}'`
#!/bin/bash
# Script to install a debian wheezy template on xcp 1.1 and above, or
# Citrix (TM) Xenserver 5.6 and above.
# Copyright (C) 2012 Arne-Kristian Hingst - All Rights Reserved
# Permission to copy and modify is granted under the eupl license
# http://ec.europa.eu/idabc/servlets/Docbb6d.pdf?id=31979
# Last revised 04/04/2013
#
# Add your favourite mirror here