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
| namespace System { | |
| // Little-Endian based approaches most likely do not work on big-endian hardware. | |
| // Code based on examples found in | |
| // Bit Twiddling hacks: | |
| // https://graphics.stanford.edu/~seander/bithacks.html | |
| // Chess programming wiki: | |
| // https://chessprogramming.wikispaces.com/BitScan | |
| public static class Bits | |
| { |
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 table if exists #seq | |
| --;with t(date,status) as ( | |
| -- select convert(date,dateadd(d,row_number() over (order by @@dbts),{d'2018-12-31'})) | |
| -- ,abs(sign(BINARY_CHECKSUM(newid())%2)) | |
| --from string_split(REPLICATE('1,',30),',') a | |
| --) | |
| --select * into #seq from t | |
| select s1.date |
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
| from typing import List | |
| import functools | |
| T9 = ['','','abc','def','ghi','jkl','mno','pqrs','tuv','wxyz'] | |
| def T9Words(word:int)->List[str]: | |
| return functools.reduce(lambda results,elem: [r+d for r in results for d in T9[int(elem)]],str(word),['']) |
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
| declare @i varchar(max)='1'+replicate(',1',3999),@d datetime2 = sysdatetime(),@_ int | |
| --slow | |
| select @_=i.value('.','int') | |
| from ( | |
| select a=convert(xml,'<i>'+replace(@i,',','</i><i>')+'</i>') | |
| ) a | |
| cross apply a.nodes('./i') x(i) | |
| select datediff(ms,@d,sysdatetime()); | |
| select @d=sysdatetime(); | |
| --fast |
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
| create function fn_workday(@start datetime,@daysToAdd int) | |
| returns table | |
| with schemabinding as | |
| return select workday=dateadd(d,@daysToAdd + ((abs(@daysToAdd)+d-2)/5)*2*sign(@daysToAdd)-d/7,@start) | |
| from (select d= 4 - sign(@daysToAdd)*(4-datepart(dw,@start))) x; |
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
| namespace Adapter | |
| { | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using System.Data.Common; | |
| using System.Runtime.CompilerServices; | |
| using System; | |
| public class DbDataReaderAdapter : DbDataReader | |
| { |
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 dateadd(d,offset,eo_2_months) | |
| from ( | |
| select last_day(dateadd(month,-2,CURRENT_TIMESTAMP),month) | |
| ) z(eo_2_months) | |
| cross join (values(1),(2),(3),(4),(5),(6),(7))o(offset) | |
| where dayofweek(dateadd(d,offset,eo_2_months))=3 | |
| order by 1 | |
| offset 0 rows fetch next 1 row only |
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
| id | value | |
|---|---|---|
| 0138C2 | tmp_na_combattest_region | |
| 013B05 | tmp_na_pathing1_region | |
| 01EE7C | audiotestregion | |
| 02194B | dmo_na_dangerunibox_region | |
| 0270AD | tmp_na_footstep_region | |
| 037B60 | tmp_na_qaautomation_region | |
| 03CD90 | tmp_na_clobberabletestregion | |
| 0695F8 | out_dalentarth_region | |
| 069A3D | dmo_m1 |
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
| function save_to_file(filename, data) | |
| if io then | |
| io.output(filename) | |
| io.write(data) | |
| io.flush() | |
| end | |
| end | |
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 Utils | |
| { | |
| public static Func<Task<T>> Debounce<T>(Func<T> method, int ms = 250, CancellationTokenSource? src = null) => delegate | |
| { | |
| Interlocked.Exchange(ref src, new CancellationTokenSource())?.Cancel(); | |
| return Task.Delay(ms, src!.Token).ContinueWith(_ => method(), TaskContinuationOptions.OnlyOnRanToCompletion); | |
| }; | |
| } |