Skip to content

Instantly share code, notes, and snippets.

View brazilnut2000's full-sized avatar

Jon Crowell brazilnut2000

View GitHub Profile
@brazilnut2000
brazilnut2000 / .block
Created May 8, 2018 03:40
Stacked Bar Chart
license: mit
height: 700
@brazilnut2000
brazilnut2000 / .block
Created May 8, 2018 03:39
Positive-Negative Bar Chart
license: gpl-3.0
@brazilnut2000
brazilnut2000 / .block
Created May 8, 2018 03:38
Normalized Stacked Bar Chart
license: gpl-3.0
@brazilnut2000
brazilnut2000 / .block
Created May 8, 2018 03:36
Brushable Horizontal Bar Chart - I
height: 540
@brazilnut2000
brazilnut2000 / .block
Created May 8, 2018 03:34
Morphing Curve: Radial Gradient
license: gpl-3.0
@brazilnut2000
brazilnut2000 / backupsqlserverwithpowershell.ps1
Created April 11, 2018 18:35
Backup SQL Server Database with Powershell
# Install SQL Server PowerShell module
# https://docs.microsoft.com/en-us/sql/powershell/download-sql-server-ps-module
Install-Module -Name SqlServer
# Backing Up SQL Server Databases is Easier in PowerShell than T-SQL
# http://www.sqlservercentral.com/articles/PowerShell/151510/
Get-SqlDatabase -ServerInstance [SERVERNAME]\SQLEXPRESS |
Where { $_.Name -eq '[DATABASENAME]' } |
Backup-SqlDatabase -BackupFile "c:\temp\[FILE PREFIX]$(Get-Date -UFormat %Y%m%d_%H%M).bak" -Script
@brazilnut2000
brazilnut2000 / random number.js
Created February 1, 2018 22:50
Get a random number between 0 and whatever upper-range you specify
function randomNumber(range) {
return Math.round(Math.random() * range);
}
// Usage:
console.log(`This is a random number from 0 to 20: ${randomNumber(20)}`);
@brazilnut2000
brazilnut2000 / SQL: convert extended events file into table.sql
Created May 26, 2017 19:09
Convert an Extended Events .xel file into a queryable table in SQL Server
-- convert all .xel files in a given folder to a single-column table
-- (alternatively specify an individual file explicitly)
select event_data = convert(xml, event_data)
into #eeTable
from sys.fn_xe_file_target_read_file(N'd:\killme\extended events\*.xel', null, null, null);
-- select from the table
select * from #eeTable
-- and click on a hyperlink value to see the structure of the xml
@brazilnut2000
brazilnut2000 / SQL:RestoreAndRenameFromBackup.sql
Created March 31, 2017 21:11
Create a copy of a database by restoring and renaming from a backup
-- SOURCE: http://stackoverflow.com/questions/6267273/how-to-restore-to-a-different-database-in-sql-server
-- Get the files, note the logical names of the .mdf and .ldf files
restore filelistonly from disk='E:\MSSQL\Backup\NewProjectExplorer\NewProjectExplorer_20170330.bak'
-- Restore and rename the backup
restore database [NewName] from disk = 'E:\MSSQL\Backup\NewProjectExplorer\NewProjectExplorer_20170330.bak'
with
move '[LogicalNameForMdf]' to 'E:\MSSQL\[NewName].mdf',
move '[LogicalNameForLdf]' to 'E:\MSSQL\[NewName]_log.ldf'
@brazilnut2000
brazilnut2000 / PsBackupSqlServer.ps1
Created March 22, 2016 22:58
Back up a SQL Server database, regardless of version (certain versions don't support scheduled backups via SSMS)
$instanceName = "[db instance name goes here]"
$server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instanceName
$databasename = "[db name goes here]"
$timestamp = Get-Date -Format yyyyMMddHHmmss
$backupfolder = "[full path to backup folder]"
$backupfile = "$($databasename)_Full_$($timestamp).bak"
$fullBackupFile = Join-Path $backupfolder $backupfile
Backup-SqlDatabase `