This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<string> Split(string str, int iterateCount) | |
{ | |
var words = new List<string>(); | |
for (int i = 0; i < str.Length; i += iterateCount) | |
if (str.Length - i >= iterateCount) | |
words.Add(str.Substring(i, iterateCount)); | |
else | |
words.Add(str.Substring(i, str.Length - i)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[SuppressMessage("ReSharper", "InconsistentNaming")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP FUNCTION IF EXISTS [dbo].[LEVENSHTEIN] | |
GO | |
CREATE FUNCTION [dbo].[LEVENSHTEIN](@left VARCHAR(100), | |
@right VARCHAR(100)) | |
RETURNS INT | |
AS | |
BEGIN | |
DECLARE @difference INT, | |
@lenRight INT, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT STUFF(STUFF(13961201, 5, 0, '/'), 8, 0, '/') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class JEncyptor | |
{ | |
public static Tuple<string, string> CreateKeyPair() | |
{ | |
var cspParams = new CspParameters { ProviderType = 1 }; | |
var rsaProvider = new RSACryptoServiceProvider(1024, cspParams); | |
var publicKey = Convert.ToBase64String(rsaProvider.ExportCspBlob(false)); | |
var privateKey = Convert.ToBase64String(rsaProvider.ExportCspBlob(true)); | |
return new Tuple<string, string>(privateKey, publicKey); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SynchronizationContext ctx = SynchronizationContext.Current; | |
int count = 0; | |
Parallel.ForEach(collection, (item) => | |
{ | |
ComputeYourStuff(item); | |
Interlocked.Increment(ref count); | |
ctx.Post(d => { progressBar.Value = count; }, null); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ManagementEventWatcher watcher = new ManagementEventWatcher(); | |
WqlEventQuery query = new WqlEventQuery("SELECT * FROM Win32_DeviceChangeEvent"); | |
watcher.EventArrived += Watcher_EventArrived; | |
watcher.Query = query; | |
watcher.Start(); | |
watcher.WaitForNextEvent(); | |
private static void Watcher_EventArrived(object sender, EventArrivedEventArgs e) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void button1_Click() | |
{ | |
var scope = new ManagementScope("root\\CIMV2") {Options = {EnablePrivileges = true}}; | |
try | |
{ | |
var query = new WqlEventQuery | |
{ | |
EventClassName = "__InstanceCreationEvent", | |
WithinInterval = new TimeSpan(0, 0, 1), | |
Condition = @"TargetInstance ISA 'Win32_USBControllerdevice'" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void GetInfo() | |
{ | |
var domain = new PrincipalContext(ContextType.Domain); | |
Console.WriteLine("Domain.Name: " + domain.Name); | |
Console.WriteLine("Domain.UserName: " + domain.UserName); | |
Console.WriteLine("Domain.ConnectedServer: " + domain.ConnectedServer); | |
Console.WriteLine("Domain.ContextType: " + domain.ContextType); | |
Console.WriteLine("Domain.Options: " + domain.Options); | |
Console.WriteLine("Domain.Container: " + domain.Container); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH CTE AS | |
( | |
SELECT * | |
,ROW_NUMBER() OVER | |
( | |
PARTITION BY [CreditVerifierRoleId],[CreditRuleJobGroupId],[CreditGrade],[SalaryRate],[AveragingRate],[AveragingMonthDuration],[MaxCredit],[MaxGuaranteePerCustomer],[CreditRuleType],[BeginDate],[EndDate],[CreatedOn],[CreatedBy],[ModifiedOn],[ModifiedBy] | |
ORDER BY [CreditVerifierRoleId],[CreditRuleJobGroupId],[CreditGrade],[SalaryRate],[AveragingRate],[AveragingMonthDuration],[MaxCredit],[MaxGuaranteePerCustomer],[CreditRuleType],[BeginDate],[EndDate],[CreatedOn],[CreatedBy],[ModifiedOn],[ModifiedBy] | |
) AS RN | |
FROM [QTasBankDatabase].[Loan].[CreditRules] | |
) |