Skip to content

Instantly share code, notes, and snippets.

$Path = $env:TEMP
$Installer = "chrome_installer.exe"
Invoke-WebRequest "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile $Path$Installer
Start-Process -FilePath $Path$Installer -Args "/silent /install" -Verb RunAs -Wait
Remove-Item $Path$Installer
@dsect
dsect / GetS3ClientFromLocalCreds.cs
Last active May 24, 2021 11:47
.NET Amazon Creds Running Locally - from Profile
// if profiles are mfa-enabled - add AWSSDK.SecurityToken Nuget package
// otherwise - will encounter runtime error
private static IAmazonS3 GetAmazonS3()
{
if (Debugger.IsAttached)
{
var sharedFile = new SharedCredentialsFile();
sharedFile.TryGetProfile("Your Profile Name", out var profile);
AWSCredentialsFactory.TryGetAWSCredentials(profile, sharedFile, out var credentials);
$Ec2Instances = @()
$Instances = (Get-EC2Instance -Filter `
@(
@{name = "tag:MyFirstTag"; values = "FirstTagValue" },
@{name = "tag:MySecondTag"; values = @("SecondTagValue1"; "SecondTagValue2") }
)
).Instances
foreach ($Instance in $Instances) {
import base64
import hashlib
from Crypto import Random
from Crypto.Cypher import AES
import sys
if len(sys.argv) != 4:
print: ("Usage: simple_decrypt <Plaintext-KMS-DEK> <IV> <Encrypted-BAK-filename>")
sys.exit(1)
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="RollingFileAppender" />
</root>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="C:\Logs\MyLog-%property{machineName}.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
using (var sqlBulkCopy = new SqlBulkCopy(connectionString, SqlBulkCopyOptions.Default))
{
const int timeout = 1200;
sqlBulkCopy.BulkCopyTimeout = timeout;
sqlBulkCopy.BatchSize = 50000;
sqlBulkCopy.DestinationTableName = "dbo.MyTable";
sqlBulkCopy.NotifyAfter = 1000000;
sqlBulkCopy.SqlRowsCopied += SqlBulkCopy_SqlRowsCopied;
private void Copy(string sourceCommandText, string destinationTableName, IEnumerable<SqlBulkCopyColumnMapping> columnMappings)
{
using (var sqlBulkCopy = new SqlBulkCopy(_destinationConnectionString, SqlBulkCopyOptions.Default))
{
const int timeout = 1200;
sqlBulkCopy.BulkCopyTimeout = timeout;
sqlBulkCopy.BatchSize = 50000;
sqlBulkCopy.DestinationTableName = destinationTableName;
sqlBulkCopy.NotifyAfter = 1000000;
@dsect
dsect / NinjectBindings.cs
Created May 22, 2019 16:42
Ninject and Log4Net
using System;
using System.IO;
using log4net;
using Ninject.Modules;
namespace NinjectSample
{
public class NinjectBindings : NinjectModule
{
public override void Load()
@dsect
dsect / shopRiteCoupons.js
Last active September 6, 2022 22:18
TamperMonkey script for clipping ShopRite.com online coupons
// ==UserScript==
// @name coupons.shoprite.com
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://shop-rite-web-prod.azurewebsites.net/
// @grant none
// @require http://code.jquery.com/jquery-3.3.1.min.js
// ==/UserScript==