Skip to content

Instantly share code, notes, and snippets.

@axrwkr
axrwkr / MSSQL Version Info.sql
Last active February 8, 2016 12:38
MS SQL Version Info
SELECT
CASE
WHEN CAST(SERVERPROPERTY('ProductVersion') AS VARCHAR(20)) LIKE '8.00.%' THEN 'Microsoft SQL Server 2000'
WHEN CAST(SERVERPROPERTY('ProductVersion') AS VARCHAR(20)) LIKE '9.00.%' THEN 'Microsoft SQL Server 2005'
WHEN CAST(SERVERPROPERTY('ProductVersion') AS VARCHAR(20)) LIKE '10.00.%' THEN 'Microsoft SQL Server 2008'
WHEN CAST(SERVERPROPERTY('ProductVersion') AS VARCHAR(20)) LIKE '10.50.%' THEN 'Microsoft SQL Server 2008 R2'
WHEN CAST(SERVERPROPERTY('ProductVersion') AS VARCHAR(20)) LIKE '11.0%' THEN 'Microsoft SQL Server 2012'
WHEN CAST(SERVERPROPERTY('ProductVersion') AS VARCHAR(20)) LIKE '12.0%' THEN 'Microsoft SQL Server 2014'
END Product,
SERVERPROPERTY('ProductVersion') [Product Version],
@axrwkr
axrwkr / List COLLACTION.sql
Created September 18, 2015 13:56
List collations for all columns in all tables
-- Find Collation of SQL Server Database
SELECT DATABASEPROPERTYEX('<database-name>', 'Collation')
-- list column collations
SELECT o.name, C.name, collation_name
FROM sys.columns C
INNER JOIN sys.objects O
ON O.object_id = c.object_id
WHERE O.type = 'U'
AND collation_name IS NOT NULL
@axrwkr
axrwkr / convert
Created July 21, 2015 08:24
Convert m4a to mp3 at 96k
ffmpeg -i "in.m4a" -ab 96k "out.mp3"
@axrwkr
axrwkr / radiant date tag.rb
Created April 29, 2015 14:53
Radiant CMS date tag
tag 'date' do |tag|
page = tag.locals.page
format = (tag.attr['format'] || '%A, %B %d, %Y')
time_attr = tag.attr['for']
date = if time_attr
case
when time_attr == 'now'
Time.zone.now
when Page.date_column_names.include?(time_attr)
page[time_attr]
@axrwkr
axrwkr / broscript.js
Last active August 29, 2015 14:08 — forked from CS1000/broscript.js
Paste in SO chat room console bro:
(function() {
"use strict";
var chat = document.getElementById('chat');
function parseNode(node) {
if (node.classList
&& node.classList.contains('message')
&& !node.classList.contains('pending')
&& !node.querySelector('.onebox')
@axrwkr
axrwkr / scope_operator.cpp
Created April 13, 2014 20:21
C++ Scope Operator
/*
on os x compile with
clang++ scope_operator.cpp -o scope_operator
on windows compile with
cl /EHsc scope_operator.cpp
on linux compile with
g++ scope_operator.cpp -o scope
*/
@axrwkr
axrwkr / structure_pointers.cpp
Last active August 29, 2015 13:59
C/C++ Structure Reference and Structure De-Reference operators
/*
on os x compile with
clang++ structure_pointers.cpp -o structure_pointers
on windows compile with
cl /EHsc structure_pointers.cpp
on linux compile with
g++ structure_pointers.cpp -o structure_pointers
*/
@axrwkr
axrwkr / pointers.cpp
Last active August 29, 2015 13:59
C++ Reference and Dereference Operators
/*
on os x compile with (install xcode and command line tools)
clang++ pointers.cpp -o pointers
on windows compile with (install visual studio)
cl /EHsc pointers.cpp
on linux compile with (apt-get install g++)
g++ pointers.cpp -o pointers
*/
@axrwkr
axrwkr / xml dml delete examples.sql
Created April 11, 2014 14:46
xml dml delete examples
DECLARE @myDoc xml
SET @myDoc = '<?Processing Instructions for=EXE.exe ?>
<root>
<!-- instructions for the 1st work center -->
<country LocationID="10"
GDP="1.1"
GNI=".2" >Some text 1
<city id="1">London</city>
<city>Manchester</city>
<city id="3">Liverpool</city>
@axrwkr
axrwkr / permissions.sql
Created April 2, 2014 09:33
list database object with user and role permissions
select schema_name(o.schema_id) as [Schema_Name]
, o.name as [object_name]
, u.name as [principal_name]
, u.type_desc as [principal_type]
, r.minor_id, r.permission_name, r.state_desc
, o.schema_id, o.principal_id as [alt_owner], o.type_desc
from sys.database_permissions r
Left Join sys.database_Principals u
ON r.grantee_principal_id = u.principal_id
Left Join sys.all_objects o