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
| ; find the combinations of letters which have the most anagrams | |
| ; word list is from | |
| ; https://raw.githubusercontent.com/dolph/dictionary/master/enable1.txt | |
| (ns anagrams-sort | |
| (:require [clojure.string :as cs]) ) | |
| (def words | |
| (let [ home (System/getenv "HOME") | |
| filename (str home "/Downloads/enable1.txt") | |
| words (->> filename slurp cs/split-lines) | |
| ] words ) |
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
| -- find the combinations of letters which have the most anagrams | |
| import qualified Data.Map as M | |
| import Data.List(words,sortBy,sort,groupBy,map,intercalate) | |
| import Text.Printf(printf) | |
| import System.Environment(getEnv) | |
| type Anagrams = (Int,String,[String]) | |
| printer :: Anagrams -> IO () | |
| printer (len,sortword,words) = putStrLn $ |
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
| -- based on | |
| -- https://stackoverflow.com/questions/4522387/how-can-i-emulate-gos-channels-with-haskell | |
| -- but this version encodes end-of-stream on the communication channel, as a Nothing | |
| -- I could not get Intero or ghc to accept a type-annotation for the helper function, | |
| -- even using the exact inferred type from Intero. | |
| import Control.Monad (forM_) | |
| import Control.Concurrent (forkIO, ThreadId, threadDelay) |
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
| -- based on | |
| -- https://stackoverflow.com/questions/4522387/how-can-i-emulate-gos-channels-with-haskell | |
| -- switched to TChan | |
| -- still does not work right, because it requires a threadDelay between "generate" and "process", | |
| -- of at least 30 to 3000 microseconds to finish queueing the input, | |
| -- because the channel will be empty if the producer can't keep up with the consumer. | |
| import Control.Monad (forM_) | |
| import Control.Concurrent (forkIO, ThreadId, threadDelay) | |
| import Control.Concurrent.STM.TChan (newTChan, readTChan, writeTChan, isEmptyTChan, TChan) |
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
| -- https://stackoverflow.com/questions/4522387/how-can-i-emulate-gos-channels-with-haskell/38277207#38277207 | |
| import Control.Monad | |
| import Control.Concurrent (forkIO, ThreadId, threadDelay) | |
| import Control.Concurrent.Chan (newChan, readChan, writeChan, Chan) | |
| import Control.Concurrent.MVar (newMVar, swapMVar, readMVar, MVar) | |
| data GoChan a = GoChan { chan :: Chan a, closed :: MVar Bool } | |
| go :: IO () -> IO ThreadId | |
| go = forkIO |
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
| // GeneratePbiImportModelQueriesFromDataSource.fsx | |
| // Outline: | |
| // Query tabular model metadata for all tables | |
| // Build queries with DAX SUMMARIZECOLUMNS and PowerQuery's Table.RenameColumns | |
| // open text file in notepad for user to paste from (and add FILTERs as desired) | |
| // Usage: edit the two lines below, then run: | |
| let tabServer = "SSAStabularServerName" | |
| let tabDb = "SSAScatalog" |
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
| let fn = @"C:\Enter\Your\Filename\Here.pbix" | |
| open System.Text.RegularExpressions | |
| #if INTERACTIVE | |
| #r @"System.IO.Compression" | |
| #r @"System.IO.Compression.FileSystem" | |
| #endif | |
| open System | |
| open System.IO | |
| open System.IO.Compression |
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
| // duplicating this PowerShell one-liner in F#: | |
| // (Get-BitLockerVolume C:).EncryptionPercentage[1] | |
| // Or perhaps this slightly longer version: | |
| // while ($true) { Get-BitLockerVolume C: | %{ echo $_.EncryptionPercentage } | | |
| // Tee-Object -FilePath c:\temp\bitlockerstatuslog.txt -Append ; [Console]::Out.Flush() ; sleep 1 } | |
| #r "System.Management" | |
| open System | |
| open System.Management | |
| open System.Linq | |
| let strComputer = "." |
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 | |
| t1.session_id, | |
| CASE WHEN t2.total_elapsed_time > 86400e3 THEN CAST(CAST(t2.total_elapsed_time/86400e3 AS DEC(5,1)) AS VARCHAR(7))+' days' ELSE SUBSTRING(CONVERT(VARCHAR(27),CONVERT(DATETIME,t2.total_elapsed_time/864e5),121),12,15) END AS elapsed, | |
| -- t1.request_id, | |
| t1.task_alloc, | |
| t1.task_dealloc, | |
| -- t2.sql_handle, | |
| -- t2.statement_start_offset, | |
| -- t2.statement_end_offset, | |
| -- t2.plan_handle, |
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
| 'LongestRunningQueries.vbs | |
| 'By Aaron W. West, 7/14/2006 | |
| 'Idea from: | |
| 'http://www.sqlservercentral.com/columnists/rcarlson/scriptedserversnapshot.asp | |
| 'Reference: Troubleshooting Performance Problems in SQL Server 2005 | |
| 'http://www.microsoft.com/technet/prodtechnol/sql/2005/tsprfprb.mspx | |
| Sub Main() | |
| Const MinimumMilliseconds = 1000 | |
| Dim srvname | |
| srvname = "." ' Feel free to place your most used servernname here |