Skip to content

Instantly share code, notes, and snippets.

View kenee's full-sized avatar

Ken kenee

View GitHub Profile
@kenee
kenee / opsinit.bat
Created March 5, 2013 03:30
运维项目目录初始化
rem 运维项目目录结构初始化
md "安全评估"
md "变更管理"
md "部署配置"
md "合同服务内容"
md "事件管理"
md "数据库管理"
md "月报"
md "运维报告"
@kenee
kenee / gist:5203117
Created March 20, 2013 08:19
iis7安装脚本
@echo off
echo 正在添加IIS功能,这可能需要几分钟时间...
start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;IIS-ASP;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-ServerSideIncludes;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-ODBCLogging;IIS-Security;IIS-BasicAuthentication;IIS-WindowsAuthentication;IIS-DigestAuthentication;IIS-ClientCertificateMappingAuthentication;IIS-IISCertificateMappingAuthentication;IIS-URLAuthorization;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;IIS-LegacyScripts;IIS-LegacySnapIn;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvi
@kenee
kenee / gist:5231681
Created March 24, 2013 12:19
varchar转nvarchar
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[p_set]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[p_set]
GO
/*--将所有的表中,数值类型由char,varchar改为nchar,nvarchar
--*/
/*--调用示例:
exec p_set
@kenee
kenee / gist:5231710
Created March 24, 2013 12:25
根据条批量删除表
DECLARE @Table NVARCHAR(30)
DECLARE tmpCur CURSOR FOR
SELECT name FROM sys.objects WHERE TYPE='U' AND name LIKE N'HSUPA%'
OPEN tmpCur
FETCH NEXT FROM tmpCur INTO @Table
WHILE @@FETCH_STATUS = 0
BEGIN
DECLARE @sql VARCHAR(100)
SELECT @sql = 'drop table ' + @Table
@kenee
kenee / gist:5300926
Created April 3, 2013 12:49
根据hosts文件分发ssh key
#!/bin/bash
# This program is part of LNNPP: http://code.google.com/p/lnmpp
ssh_port_ready=''
ip=''
main () {
gen_rsa_id
cat /etc/hosts | grep -v ^# | grep -v ^$ | while read line
do
#!/bin/sh
#
# chkconfig: - 85 15
# description: Startup script for the server of Rabbitmq
#
RABBITMQ=/usr/local/rabbitmq
SBIN=$RABBITMQ/sbin/rabbitmq-server
CONTROL=$RABBITMQ/sbin/rabbitmqctl
PID=$RABBITMQ/var/lib/rabbitmq/mnesia/rabbit@`hostname -s`.pid
#!/bin/sh
TSUNG=/usr/local/tsung/bin/tsung
CONF=/data/httpd/tsung/etc/test.d.xml
LOG=/data/httpd/tsung/log
/usr/bin/screen -d -m $TSUNG -f $CONF -l $LOG start
@kenee
kenee / gist:5865740
Created June 26, 2013 08:29
php get self
function selfURL() {
$s = empty($_SERVER["HTTPS"]) ? ''
: ($_SERVER["HTTPS"] == "on") ? "s"
: "";
$protocol = $this->strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? ""
: (":".$_SERVER["SERVER_PORT"]);
return $protocol."://".$_SERVER['SERVER_NAME'].$port.dirname($_SERVER['REQUEST_URI'])."/";
}
function strleft($s1, $s2) {
@kenee
kenee / php_daemon.php
Created June 26, 2013 16:41
double fork
<?php
/*
PHP forked daemon
Standalone PHP binary must be compiled with --enable-sockets and --enable-pcntl
Dave M. -2002
Online Services USA
*/
define(DEBUG,true);
require dirname(__FILE__)."/../../config/config.php";
@kenee
kenee / gist:6069320
Created July 24, 2013 09:56
根据满查询多少排序
grep "use shop" /var/lib/mysql/slow.log | awk '{print $2}' | awk -F\; '{print $1}' | sort | uniq -c | sort -nr