Skip to content

Instantly share code, notes, and snippets.

View thebentern's full-sized avatar

Ben Meadors thebentern

View GitHub Profile
@thebentern
thebentern / autopropertyintializer.cs
Last active November 16, 2015 14:03
C# 6 presentation
// Old busted
private int count = 0;
public int Count
{
get
{
return count;
}
set
{
@thebentern
thebentern / PostBuildNugetPack.cmd
Last active December 13, 2015 19:54
Post-build Nuget Pack and copy to local Nuget store
if $(ConfigurationName) == Release (
nuget pack "$(ProjectDir)$(ProjectName).nuspec"
xcopy "$(TargetDir)*.nupkg" "C:\LocalNuget" /y
) ELSE (
echo "Skipping nuget pack"
)
@thebentern
thebentern / DumpTablesSamplesInCSV.ps1
Last active December 24, 2015 21:52
Dump all of the tables in a given database into CSVs
$database = 'MyDatabaseName'
$instance = 'localhost\SQLEXPRESS'
$tables = Invoke-SqlCmd -Query "SELECT TABLE_NAME FROM [$database].INFORMATION_SCHEMA.Tables" -ServerInstance $instance -Database 'msdb'
foreach ($table in $tables) {
$tableName = $table.TABLE_NAME
Invoke-SqlCmd -Query "SELECT TOP 50 * FROM [$tableName]" -ServerInstance $instance -Database $database |
ConvertTo-Csv -Delimiter '|' -NoType |
ForEach-Object {$_.Replace('"','')}|
Out-file "C:\DATA\$tableName.csv"
@thebentern
thebentern / FindColumn.sql
Created December 24, 2015 13:44
Find Column by name in Database
SELECT c.name AS ColName, t.name AS TableName
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE c.name LIKE '%MyName%'
@thebentern
thebentern / crap.ps1
Last active January 5, 2016 19:01
Unchuck git repo
$reader = [System.IO.File]::OpenText("GitChuck.txt")
try {
cd C:\Users\Source\MyRepo
for(;;) {
$line = $reader.ReadLine()
if ($line -eq $null) { break }
if($line -like '*bin*' -Or $line -like '*obj*' -Or $line -like '*suo*' -Or $line -like '*user*') {
git rm --cached $line
}
}
@thebentern
thebentern / flux.js
Last active December 31, 2016 15:19
Scrape FLUX
// Scrape visible task numbers
$('[id^="task-"] > div > span > span.key.ng-scope > a:visible').map(function() {
return $(this).text()
})
.get()
.join('\n');
// Scrape visible task numbers stories
$('[id^="task-"]> div > div.title.flux-lg-6.flux-order-lg-1.flux-md-12.flux-order-xs-4.flux-xs-12 > div:visible').map(function() {
return $(this).text()
@thebentern
thebentern / SQL-To-DataTable.cs
Last active February 13, 2016 21:39 — forked from hanssens/SQL-To-DataTable.cs
[C#] SQL Query to Databable to CSV
// Simple example for
// 1.) Read a sql server query to datatable;
// 2.) Export it to .csv
class Program
{
static void Main(string[] args)
{
var connectionString = @"data source=bla bla bla";
var selectQuery = "select * from my-table;";
@thebentern
thebentern / list-usb-devices.ps1
Last active August 26, 2022 23:01
List connected USB devices with powershell
gwmi Win32_USBControllerDevice |%{[wmi]($_.Dependent)} | Sort Manufacturer,Description,DeviceID | Ft -GroupBy Manufacturer Description,Service,DeviceID
@thebentern
thebentern / chocolate-bar.cmd
Last active April 13, 2016 15:19
Chocolatey Bar
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
::Dev platforms and languages
choco install vcredist2010 --confirm
choco install nodejs.install --confirm
choco install ruby --confirm
choco install python2 --confirm
choco install redis-64 --confirm
choco install docker --confirm
@thebentern
thebentern / openssl-pem-to-crt.cmd
Created April 5, 2016 01:47
Convert PEM to CRT
openssl x509 -outform der -in your-cert.pem -out your-cert.crt