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 / 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 / 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 / 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 / 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
@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 / screen.sh
Last active August 1, 2016 14:07
Screen commands in linux
screen -S "my screen name"
# Ctrl-A + D will detach you from that screen
# Show the list of available screens
screen -r
# To reattach to that screen
screen -r "screen id"
@thebentern
thebentern / s3-upload.ps1
Last active August 1, 2016 14:23
S3 Uploader Powershell
$key = "mykey"
$secretKey = "mysecretkey"
$bucketName = "bucketName"
Set-AWSCredentials -AccessKey $key -SecretKey $secretKey -StoreAs MyProfileName
foreach ($file in Get-ChildItem "D:\Exceed Extracts\Batch")
{
if ($file.Length -gt 0)
{