Skip to content

Instantly share code, notes, and snippets.

@revirth
revirth / C++_Unreal_Cours_1028.cpp
Last active October 29, 2022 18:40
C++_Unreal_Cours_1028
#include <iostream>
#include <string>
using namespace std;
void Exercise_While_Break()
{
string password;
while (true)
@revirth
revirth / Finding Component.py
Created January 24, 2016 14:40
When I study Vectors on KahnAcademy site, need to make a function to calculate to find a component from 2 vectors
# https://www.khanacademy.org/math/linear-algebra/vectors_and_spaces/vectors/e/adding-vectors-in-magnitude-and-direction-form
def findComponent(v,vR,w,wR):
l = v*math.cos(math.radians(vR))+w*math.cos(math.radians(wR))
r = v*math.sin(math.radians(vR))+w*math.sin(math.radians(wR))
return (l,r)
@revirth
revirth / Stopwatch
Created July 18, 2015 11:27
StopWatch,Timer
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
watch.Start();
// something doing
watch.Stop();
Response.Write(watch.Elapsed.ToString());
@revirth
revirth / Paralle.ForEach.DataTable.cs
Created October 31, 2014 06:02
using Paralle.ForEach to DataTable
[DllImport("kernel32.dll")]
static extern int GetCurrentProcessorNumber();
static void Main(string[] args)
{
DataTable dt = new DataTable();
dt.Columns.Add("n", typeof(int));
var numbers = Enumerable.Range(0, 1000);
Stopwatch sw = new Stopwatch();
sw.Start();
@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
Parallel.ForEach(strings, str=>
{
DataRow row;
lock(table){
row= table.NewRow();
}
MyParser.Parse(str, out row);
lock(table){
table.Rows.Add(row)
#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"
#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)
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
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