Skip to content

Instantly share code, notes, and snippets.

View Warrenn's full-sized avatar

Warrenn Enslin Warrenn

  • Busyweb
  • South Africa
View GitHub Profile
@Warrenn
Warrenn / conv.sql
Created September 18, 2020 16:39
SQL UTF8
iconv -f utf-16 -t utf-8 sqlerrors.log > sqlerrors-utf8.log
@Warrenn
Warrenn / AddClientHeader.cs
Last active September 10, 2020 18:04
Add custom client interceptions for any client WebRequest
// <configuration>
// <system.net>
// <webRequestModules>
// <add prefix="http"
// type="UserAgentRequestCreator, namespace, Version=1.0.0.0,
// Culture=neutral, PublicKeyToken=9999999999999999"
// />
// </webRequestModules>
// </system.net>
// </configuration>
Path.GetFullPath(new Uri(Path.Combine(Environment.CurrentDirectory, @"..\..\")).LocalPath);
@Warrenn
Warrenn / locationofscript.sh
Created June 12, 2020 10:22
get the location of the script from wherever
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
@Warrenn
Warrenn / fast_SQL_Count.sql
Created June 9, 2020 13:48
fast count of rows
SELECT @count = SUM(p.rows)
FROM sys.partitions AS p
INNER JOIN sys.tables AS t
ON p.[object_id] = t.[object_id]
INNER JOIN sys.schemas AS s
ON t.[schema_id] = s.[schema_id]
WHERE p.index_id IN (0,1) -- heap or clustered index
AND t.name = N'tablename'
AND s.name = N'dbo';
function Disable-IEESC
{
$AdminKey = “HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}”
Set-ItemProperty -Path $AdminKey -Name “IsInstalled” -Value 0
$UserKey = “HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}”
Set-ItemProperty -Path $UserKey -Name “IsInstalled” -Value 0
Stop-Process -Name Explorer
Write-Host “IE Enhanced Security Configuration (ESC) has been disabled.” -ForegroundColor Green
}
Disable-IEESC
@Warrenn
Warrenn / InParallel.cs
Last active April 27, 2020 07:58
extension to append an array in parallel
public static IEnumerable<TAggregate> InParallel<TSource, TAggregate>(
this IEnumerable<TSource> source,
Func<TSource, Task<IEnumerable<TAggregate>>> parallelTask) =>
InParallel(source, parallelTask, k => k);
public static IEnumerable<TAggregate> InParallel<TSource, TAggregate, TKey>(
this IEnumerable<TSource> source,
Func<TSource, Task<IEnumerable<TAggregate>>> parallelTask,
Func<TSource,TKey> keySelector)
@Warrenn
Warrenn / Force_MFA
Last active September 15, 2020 11:14
Force_MFA policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowViewAccountInfo",
"Effect": "Allow",
"Action": [
"iam:ListVirtualMFADevices",
"iam:GetAccountPasswordPolicy"
],
@Warrenn
Warrenn / showcurrency.ts
Created October 22, 2019 08:41
show currency
showCurrency(value: number, precision: number, seperator: string, decimalSeperator: string): string {
const stringValue = `${value || 0}`
const parts = stringValue.split('.')
let numeric = `${parts[0]}`
if (seperator) numeric = numeric.replace(/(\d)(?=(\d{3})+(?!\d))/g, `$1${seperator}`)
let decimal = `${parts[1] || 0}`
if (precision > 0) decimal = decimal.padEnd(precision, '0')
decimalSeperator = decimalSeperator || '.'
return `${numeric}${decimalSeperator}${decimal}`
}
@Warrenn
Warrenn / bloc-module.ts
Last active July 25, 2019 07:35
ts traversal
interface Declaration {
transforms: { [key: string]: (ctx: any) => void }
asyncs: { [key: string]: (ctx: any) => Promise<void> }
middlewares: { (ctx: any): void }[]
context: { [key: string]: (config: any) => ((state: any) => any) }
state: any
}
export default <Declaration>{
transforms: {