Skip to content

Instantly share code, notes, and snippets.

@revirth
revirth / CopyUntrackedFiles.bat
Last active December 11, 2015 08:58
Copy Untracked Files
@echo off
cd %1
git ls-files -m > %2.txt
echo 'done' %2.txt
// http://goo.gl/UWuR3W
IEnumerable<string> numbers = Enumerable.Range(1, 100).Select(x = > x.ToString("D3"));
foreach(var n in numbers)
Console.WriteLine(n);
//
// 001
// 002
@revirth
revirth / jqGrid.AvoidPageNumber.js
Last active August 29, 2015 13:56
[JS.jqGrid] avoid insert greater number than total page's
//
// jquery.jqGrid.src.js
//
//
// setPager = function (pgid, tp){
// ...................
// ............
// .....
$('input.ui-pg-input',"#"+pgcnt).keypress( function(e) {
-- http://msdn.microsoft.com/ko-kr/library/ms189741.aspx
SELECT TOP 20 query_stats.query_hash AS "Query Hash",
SUM(query_stats.total_worker_time) / SUM(query_stats.execution_count)/1000 AS "Avg CPU Time",
MIN(query_stats.statement_text) AS "Statement Text"
FROM
(SELECT QS.*,
SUBSTRING(ST.text, (QS.statement_start_offset/2) + 1,
((CASE statement_end_offset
WHEN -1 THEN DATALENGTH(ST.text)
use master;
-- database_connection_stats
select database_name, cast(start_time as varchar(20)), cast(end_time as varchar(20)),
success_count, total_failure_count, connection_failure_count, terminated_connection_count, throttled_connection_count
from sys.database_connection_stats
where database_name = 'DB Name'
order by start_time desc
use master;
-- database_connection_stats daily, hourly
select database_name, cast(end_time as varchar(13)) end_date,
SUM(success_count) success_count, SUM(total_failure_count) total_failure_count, SUM(connection_failure_count) connection_failure_count,
SUM(terminated_connection_count) terminated_connection_count, SUM(throttled_connection_count) throttled_connection_count
from sys.database_connection_stats
where database_name = 'DB Name'
group by database_name, cast(end_time as varchar(13))
having SUM(total_failure_count) > 10
#http://stackoverflow.com/questions/12460950/how-to-pass-credentials-to-the-send-mailmessage-command-for-sending-emails
$EmailTo = "[email protected]"
$EmailFrom = "[email protected]"
$Subject = "Test"
$Body = "Test Body"
$SMTPServer = "smtp.gmail.com"
$filenameAndPath = "C:\CDF.pdf"
$SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$Subject,$Body)
$attachment = New-Object System.Net.Mail.Attachment($filenameAndPath)
#http://irisclasson.com/2013/10/16/how-do-i-query-a-sql-server-db-using-powershell-and-how-do-i-filter-format-and-output-to-a-file-stupid-question-251-255/
$dataSource = ".\SQLEXPRESS"
$user = "user"
$pwd = "1234"
$database = "Test"
$connectionString = "Server=$dataSource;uid=$user; pwd=$pwd;Database=$database;Integrated Security=False;"
$query = "SELECT * FROM Person"
Parallel.ForEach(strings, str=>
{
DataRow row;
lock(table){
row= table.NewRow();
}
MyParser.Parse(str, out row);
lock(table){
table.Rows.Add(row)
@revirth
revirth / ZipToListMoreThan2Elements.scala
Created October 30, 2014 02:47
ZipToListMoreThan2Elements
// 2개 이상의 요소를 List로 만들기
(List(1,2,3),List(4,5,6),List(7,8,9)).zipped.toList // List((1,4,7), (2,5,8), (3,6,9))
(List(1,2,3),List("a","b","c"),List("!","@","#")).zipped.toList // List((1,a,!), (2,b,@), (3,c,#))
// http://stackoverflow.com/questions/1664439/can-i-zip-more-than-two-lists-together-in-scala