Study/Linux2012. 9. 19. 17:48



sendmail 로 메일 보낼때


CNAME 으로 위임된 도메인으로 보낼경우

CNAME으로 위임된 도메인으로 메일이 날아감


방지하기 위해서

sendmail.cf에서 아래를 True로 수정


define(`confDONT_EXPAND_CNAMES'.`True')


버전에 따라서는


DontExpandCnames=True


Posted by 영혼도둑
Study/Mssql2012. 6. 27. 08:49

[제목]

Index 생성 관련 lock 관련 Guide 요청

[요약]

--문제

Index 생성 관련 lock 관련 Guide 요청

[진행 사항]

Step 1 ) A(Source) Table 에서 B Table Data 복사 (SELECT INTO or INSERT SELECT )

Step 2 ) B TablePK를 포함한 Index 생성

Step 3 ) A Table에 대해서 아래 Query를 이용해서 Access 여부 확인

Step 4 ) Step 3에서 A Table Access가 없는 경우 A TableA_Org Rename

Step 5 ) B Table A Table으로 Rename

SELECT * FROM

(

SELECT R.session_id, SUBSTRING(S.text, (R.statement_start_offset/2)+1,

((CASE R.statement_end_offset

WHEN -1 THEN DATALENGTH(S.text)

ELSE R.statement_end_offset

END - R.statement_start_offset)/2) + 1)

AS SQL

FROM sys.dm_exec_requests AS R

cross apply sys.dm_exec_sql_text(r.sql_handle) AS S

WHERE R.session_id > 50 AND R.session_id <> @@SPID

) AS S

WHERE S.SQL like '%table_name%'


Posted by 영혼도둑
Study/JavaScript2008. 10. 29. 16:38


function makeRGB(){
    colors = new Array(14)
        colors[0]="0"
        colors[1]="1"
        colors[2]="2"
        colors[3]="3"
        colors[4]="4"
        colors[5]="5"
        colors[5]="6"
        colors[6]="7"
        colors[7]="8"
        colors[8]="9"
        colors[9]="a"
        colors[10]="b"
        colors[11]="c"
        colors[12]="d"
        colors[13]="e"
        colors[14]="f"

        digit = new Array(5)
        color=""
        for (i=0;i<6;i++){
            digit[i]=colors[Math.round(Math.random()*14)]
            color = color+digit[i]
        }
        return color
}
Posted by 영혼도둑
Study/Mssql2008. 9. 26. 11:16

sp_configure

sp_configure 'show advanced options',1
RECONFIGURE
GO
sp_configure 'max server memory', 6144
RECONFIGURE
GO
sp_configure 'show advanced options',0
RECONFIGURE
GO


Posted by 영혼도둑
Study/Mssql2008. 9. 26. 07:19
http://laigo.tistory.com/62

오늘 hotfix 적용하면서 발생한 문제 해결법
Posted by 영혼도둑
Study/Mssql2008. 9. 22. 17:16
use master
SELECT TOP 50
        (qs.total_logical_reads + qs.total_logical_writes) /qs.execution_count as [Avg IO],
            SUBSTRING(qt.text,qs.statement_start_offset/2,
            (case when qs.statement_end_offset = -1
            then len(convert(nvarchar(max), qt.text)) * 2
            else qs.statement_end_offset end -qs.statement_start_offset)/2)
        as query_text,
        qt.dbid, dbname=db_name(qt.dbid),
        qt.objectid,
        qs.sql_handle,
        qs.plan_handle
FROM sys.dm_exec_query_stats qs
cross apply sys.dm_exec_sql_text(qs.sql_handle) as qt
ORDER BY
       [Avg IO] DESC
Posted by 영혼도둑
Study/Mssql2008. 9. 22. 16:58


declare @dbid int
select @dbid = db_id()
select objectname=object_name(s.object_id), s.object_id
    , indexname=i.name, i.index_id
    , user_seeks, user_scans, user_lookups, user_updates
from sys.dm_db_index_usage_stats s,
    sys.indexes i
where database_id = @dbid
and objectproperty(s.object_id,'IsUserTable') = 1
and i.object_id = s.object_id
and i.index_id = s.index_id
order by (user_seeks + user_scans + user_lookups + user_updates) asc


declare @dbid int
select @dbid = db_id()
select objectname=object_name(s.object_id), s.object_id
    , indexname=i.name, i.index_id
    , user_seeks, user_scans, user_lookups, user_updates
from sys.dm_db_index_usage_stats s,
    sys.indexes i
where database_id = @dbid 
and objectproperty(s.object_id,'IsUserTable') = 1
and i.object_id = s.object_id
and i.index_id = s.index_id
and object_name(s.object_id)= 'mt_member'
order by (user_seeks + user_scans + user_lookups + user_updates) asc


Posted by 영혼도둑
Study/Mssql2008. 9. 12. 10:56
dbcc useroptions

ALTER DATABASE testdb
    SET READ_COMMITTED_SNAPSHOT ON;

SELECT NAME, SNAPSHOT_ISOLATION_STATE,
SNAPSHOT_ISOLATION_STATE_DESC, IS_READ_COMMITTED_SNAPSHOT_ON
FROM SYS.DATABASES
Posted by 영혼도둑
Study/Php2008. 9. 11. 16:21

이미지 Resize 하기

기존 이미지중 6K 가 넘는 이미지를 Resize해야 하는 이슈가 있어서

이미지를 GDLib 이용해서 리사이징 하기로 함

find . -size +6k -type f -exec cp -r {} /tmp/image/ \;
( 우선 데이타를 한곳으로 몰고)

#!/usr/bin/php -q

// gd에 사용될 임시 변수들
$IsTrueColor = false;
$Extension = null;

// 이미지를 로딩하는 함수입니다.
function GDImageLoad($filename)
{
global $IsTrueColor, $Extension;

if( !file_exists($filename) ) return false;

$image_type = exif_imagetype($filename);

switch( $image_type )
{
case IMAGETYPE_JPEG: // JPEG일경우
$im = imagecreatefromjpeg($filename);
$Extension = "jpg";
break;
case IMAGETYPE_GIF: // GIF일 경우
$im = imagecreatefromgif($filename);
$Extension = "gif";
break;
case IMAGETYPE_PNG: // png일 경우
$im = imagecreatefrompng($filename);
$Extension = "png";
break;
default:
break;
}

$IsTrueColor = @imageistruecolor($im);

return $im;
}

// 이미지 크기를 줄입니다.
function GDImageResize($src_file, $dst_file, $width = NULL, $height = NULL, $type = NULL, $quality = 75)
{
global $IsTrueColor, $Extension;

$im = GDImageLoad($src_file);

if( !$im ) return false;

if( !$width ) $width = imagesx($im);
if( !$height ) $height = imagesy($im);

if( $IsTrueColor && $type != "gif" ) $im2 = imagecreatetruecolor($width, $height);
else $im2 = imagecreate($width, $height);

if( !$type ) $type = $Extension;

imagecopyresampled($im2, $im, 0, 0, 0, 0, $width, $height, imagesx($im), imagesy($im));

if( $type == "gif" )
{
imagegif($im2, $dst_file);
}
else if( $type == "jpg" || $type == "jpeg" )
{
imagejpeg($im2, $dst_file, $quality);
}
else if( $type == "png" )
{
imagepng($im2, $dst_file);
}

imagedestroy($im);
imagedestroy($im2);

return true;
}

GDImageResize('1631.jpg', '1631.jpg', '104', '104');
?>

위 소스를 이용 resizing 함... 냐하핫

Posted by 영혼도둑
Study/Python2008. 9. 11. 16:20

파이썬으로 로그 삭제하기

#! /usr/local/bin/python

import os
from datetime import *

tempPath = '/Log'
tempList = os.listdir(tempPath)

tempDate = datetime.today()
#tempTargetDate = tempDate - timedelta( days=14 )
tempTargetDate = tempDate - timedelta( weeks=5 )



##### START #####

print '\n'

###
for tempFolder in tempList :

tempList2 = os.listdir(tempPath + '/' + tempFolder)

print '\n##### ' + tempFolder + '\n'

for tempFile in tempList2 :
tempFileDate = datetime.fromtimestamp( os.path.getmtime( tempPath + '/' + tempFolder + '/' + tempFile ) )

if tempFileDate < tempTargetDate:

###
### WARNING WARNING WARNING WARNING WARNING
### WARNING WARNING WARNING WARNING WARNING
### WARNING WARNING WARNING WARNING WARNING
###
### os.remove(tempPath + '/' + tempFolder + '/' + tempFile)
###
### WARNING WARNING WARNING WARNING WARNING
### WARNING WARNING WARNING WARNING WARNING
### WARNING WARNING WARNING WARNING WARNING
###

print tempPath + '/' + tempFolder + '/' + tempFile + ' ----- is deleted.'

else:
print tempPath + '/' + tempFolder + '/' + tempFile

###

print '\n'
print 'today is\t\t', tempDate
print '\nand THE TARGET DATE is\t', tempTargetDate

###

print '\nhello, world. = )\n'

##### END OF POEM #####
Posted by 영혼도둑