Skip to content

Instantly share code, notes, and snippets.

View SQLvariant's full-sized avatar

Aaron Nelson SQLvariant

View GitHub Profile
@shashank291
shashank291 / stockLotsExport.md
Last active January 5, 2022 14:42
Export Fidelity Stock Lots to TSV file

Description

I used the below script to export my Fidelity share lot information in one file. By default, Fidelity requires going to each individual stock page to get this info which can be painstaking.

Instructions

Fair warning that you should understand the code you're running, and I make no guarantees as to the correctness of the script or the data downloaded, and I assume no liabilities if you decide to run this code. Now that that's out of the way, to get your aggregate share lot information:

Go to your Individual account on Fidelity, under Positions tab, and open the console(Ctrl+Shift+J on most browsers). Then you can run the following script that will gather all your stock lot information and download it in a TSV file. I suggest you read through it and verify it as a common precaution. Here's the script:

const domParser = new DOMParser();

# USE THIS SCRIPT TO UPLOAD LARGE .PBIX FILES TO POWER BI REPORT SERVER
#
# I needed to manually construct the form-data as PowerShell doesn't appear to have full support for
# this yet, though it appears to be coming soon.
#CREDENTIALS
[string]$userName = 'BIWIN\MS'
[string]$userPassword = 'xxxxxxxxxxxxx'
[securestring]$secStringPassword = ConvertTo-SecureString $userPassword -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($userName, $secStringPassword)
@SQLvariant
SQLvariant / Query_DB2.ps1
Created November 20, 2020 16:12
Uploaded via PowerShell
$dbName="SAMPLE"
$server="not.my.localhost"
#Define connection string for the database
$cn = new-object system.data.OleDb.OleDbConnection("server=$($server);Provider=IBMDADB2;DSN=$($dbName);trusted_connection=true;");
#Define data set for first query
$ds = new-object "System.Data.DataSet" "ds"
#Define query to run
$q = "select * from hello_world"
# Define data object given the specific query and connection string
@Jaykul
Jaykul / Measure-CommandEx.ps1
Last active June 22, 2022 05:29
We need a better Measure-Command which can show averages
function Measure-CommandEx {
<#
.SYNOPSIS
A from-scratch approach to timing command execution using Stopwatch
#>
[CmdletBinding()]
param(
# The command to test (accepts value from pipeline)
[Parameter(ValueFromPipeline)]
[ScriptBlock[]]$Command,
-- TRANSLATE() and STRING_SPLIT() work with SQL Server 2016+, STRING_AGG() with 2017+.
-- language_id=1033 is English (simplified)
SELECT STRING_AGG(REPLACE(TRANSLATE(s.[value] COLLATE database_default, '():.,-/='';', '**********'), '*', ''), ' ')
FROM sys.messages AS msg
CROSS APPLY STRING_SPLIT(msg.[text], ' ') AS s
WHERE msg.language_id=1033
--AND s.[value] COLLATE database_default NOT IN ('the', 'is', 'to', 'not', 'a', 'for', 'in', 'be', 'of', 'or', 'cannot', 'and')
AND s.[value] COLLATE database_default NOT LIKE '%[%@=]%'
GROUP BY msg.message_id
@rjmholt
rjmholt / CellFindingVisitor.cs
Created August 11, 2020 16:47
PowerShell AST visitor to break up a file by comments
using System;
using System.Collections.Generic;
using System.Management.Automation.Language;
public class ScriptExtent : IScriptExtent
{
private readonly IScriptPosition _start;
private readonly IScriptPosition _end;
@stummsft
stummsft / Set-SqlTlsCertificate.ps1
Created April 5, 2019 00:00
Programmatically set the TLS certificate to be used by a given SQL Server Instance
function Set-SqlTlsCertificate {
[CmdletBinding(SupportsShouldProcess=$true)]
param (
[Parameter()]
[Alias("CN", "MachineName")]
[String[]]$ComputerName = "localhost",
[Parameter()]
[String[]]$InstanceName,
@halkyon
halkyon / cleanup-win10.ps1
Last active February 6, 2024 09:09
Cleanup Windows 10 Powershell script
##
## Windows 10 cleanup script.
## Remove dodgy tracking settings, unneeded services, all apps, and optional features that come with Windows 10. Make it more like Windows 7.
## NOTE: this was tested on Creators Update (1703) and Fall Creators Update (1709). Some of this may not work as expected on newer versions.
##
## Instructions
## 1. Run this script (under Powershell as Administrator):
## powershell -ExectionPolicy Bypass .\cleanup-win10.ps1
## 2. Let it run through, you may see a few errors, this is normal
## 3. Reboot
param
(
[String] [Parameter(Mandatory)]
$SolutionFile,
#this is the evironment that is in the Solution config to read where things need to go (TEST/DEV/QA/Prodution)
#for example - C:\tfs2013\Test Automated Deployment Sharepoint.rptproj
[string] [Parameter(Mandatory)] $Environment,
#this is the name of the Datasource as it exists in Sharepoint without the .rsds extension
[string] [Parameter(Mandatory)] $DataSource,
#This is the connection string that will be set for the report data source.
#Requires -Version 5.0
#------------------------------------------------------------------------
# Source File Information (DO NOT MODIFY)
# Source ID: 8967ce63-8512-4998-b597-b65331d6a9f6
# Source File: subscriptionExporter.psf
#------------------------------------------------------------------------
#region File Recovery Data (DO NOT MODIFY)
<#RecoveryData:
d00BAB+LCAAAAAAABACMu9eOs0CbLnreUt/Dr/+U0ZhosDQzEjlHk8/IGUwy4ep39QTtJe0tzfpa
beHPVLnqDU8A+t+cIpu+xXJxyZb8AxyszTT++z/Rf0X++R+/P//4x7+ZS1M1Y9ILTV8YyVD8x7qn