Skip to content

Instantly share code, notes, and snippets.

View mikaelweave's full-sized avatar
🔥

Mikael Weaver mikaelweave

🔥
View GitHub Profile
@mikaelweave
mikaelweave / drop_table_if_exists.sql
Last active November 9, 2017 16:51
Drops a temporary (temp) SQL table if it exists #sql
IF OBJECT_ID('dbo.Scores', 'U') IS NOT NULL DROP TABLE dbo.Scores;
@mikaelweave
mikaelweave / javascript_resources.md
Last active August 29, 2015 14:07 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@mikaelweave
mikaelweave / SQL Combine rows into one
Last active November 9, 2017 16:51
Multiple Rows into One
(select stuff(
(
select distinct ', ' + rtrim(pak_value)
from e_pstor
where e_pstor.ptype_id = '{55266899-ca35-4690-afaa-9af9b3b98ab2}' /* Code: Pharmacy Supplemental Clinical Rationale */
and e_pstor.source_id = e_note.ct_id
and e_pstor.pak_value > ''
order by ', ' + rtrim(pak_value)
for xml path(''),type).value('.','varchar(max)'),1,1,'')
) AS Pharmacy_Supplemental_Clinical_Rationale_value
@mikaelweave
mikaelweave / Recycle All App Pools
Last active November 9, 2017 16:50
Recycle all application pools on a server
Write-Host ""
Write-Host "Starting App Pool Recycle...." -ForegroundColor Magenta
& $env:windir\system32\inetsrv\appcmd list apppools /state:Started /xml | & $env:windir\system32\inetsrv\appcmd recycle apppools /in
Write-Host "Recycle Complete" -ForegroundColor Magenta
Write-Host ""
@mikaelweave
mikaelweave / convert date time.sql
Last active November 9, 2017 16:50
Convert SQL DATETIME to superior human DATETIME
SELECT
FORMAT(GETDATE(), 'g'),
CONVERT(VARCHAR(32), CAST(GETDATE() AS DATE), 101) AS d,
REPLACE(REPLACE(RIGHT(CAST(GETDATE() AS DATETIME), 7), 'AM', ' AM'), 'PM', ' PM') AS t
@mikaelweave
mikaelweave / delete_multiple_rows.sql
Last active August 29, 2015 14:10
Delete multiple rows on row at a time
IF OBJECT_ID('tempdb..#TEMP') IS NOT NULL DROP TABLE #TEMP
--This will work since each delete is done as a single row
SELECT RowNum = ROW_NUMBER() OVER(ORDER BY ct_id), ct_id
INTO #TEMP
FROM ct_note where ntype_id IN('{d94f685c-84ec-49b2-8e0f-ebaf9f6e609f}', '{afbf6d79-6d77-41e6-8790-9505e9b9ed82}', '{6cad622d-c3b7-4907-b62a-a882902ee4e4}')
DECLARE @MaxRownum INT
SET @MaxRownum = (SELECT MAX(RowNum) FROM #TEMP)
@mikaelweave
mikaelweave / blank_stored_procedure_template.sql
Last active January 22, 2016 22:25
Template for a blank MS-SQL (T-SQL) stored procedure.
IF OBJECT_ID('MySproc', 'P') IS NOT NULL
DROP PROC MySproc
GO
CREATE PROC MySproc
AS
BEGIN
[CODE HERE]
END
@mikaelweave
mikaelweave / SQL find table by name.sql
Created March 19, 2015 23:03
Scan all SQL tables in a database by name
SELECT
name
FROM
ices.sys.tables
WHERE
name LIKE '%Line%'
AND is_ms_shipped = 0;
@mikaelweave
mikaelweave / drop_view_if_exists.sql
Created April 7, 2015 18:06
Drop SQL View if it exists
IF EXISTS(SELECT * FROM sys.views WHERE name = 'e_note' AND schema_id = SCHEMA_ID('dbo'))
DROP VIEW dbo.e_note
GO
@mikaelweave
mikaelweave / compare_two_date_ranges
Created April 9, 2015 18:34
SQL logic for comparing two date ranges
FROM - http://stackoverflow.com/questions/325933/determine-whether-two-date-ranges-overlap
Let ConditionA Mean DateRange A Completely After DateRange B
(True if StartA > EndB)
Let ConditionB Mean DateRange A Completely Before DateRange B
(True if EndA < StartB)
Then Overlap exists if Neither A Nor B is true
( If one range is neither completely after the other,
nor completely before the other, then they must overlap)