Skip to content

Instantly share code, notes, and snippets.

View HeLiBloks's full-sized avatar

Henrik Lindgren HeLiBloks

  • Stockholm
View GitHub Profile
USE database;
GO
SELECT t.name AS t_name,
SCHEMA_NAME(schema_id) AS s_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
--WHERE c.name LIKE '%ID'
ORDER BY s_name, t_name;
@HeLiBloks
HeLiBloks / Pivot.snippet
Created January 14, 2016 16:52 — forked from craibuc/Pivot.snippet
Sql Server Management Studio (SSMS) 2012, Pivot, surround snippet.
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<_locDefinition xmlns="urn:locstudio">
<_locDefault _loc="locNone" />
<_locTag _loc="locData">Title</_locTag>
<_locTag _loc="locData">Description</_locTag>
<_locTag _loc="locData">Author</_locTag>
<_locTag _loc="locData">ToolTip</_locTag>
<_locTag _loc="locData">Default</_locTag>
</_locDefinition>
@HeLiBloks
HeLiBloks / generate_date.sql
Created January 11, 2016 10:02 — forked from rudiv/generate_date.sql
Generate Date Table SQL Server
-- This will insert X years worth of data into a Date table. All fields are INT apart from DayName and DateTime (NVARCHAR(10) and DATE respectively)
-- Update 19/12 now uses ISO Week Number
-- Define start (base) and end dates
DECLARE @basedate DATETIME = '20111101', @enddate DATETIME = '20150101';
DECLARE @days INT = 0, @date DATETIME = '20110101', @maxdays INT = DATEDIFF(dd, @basedate, @enddate);
WHILE @days <= @maxdays
BEGIN
SET @date = DATEADD(dd, @days, @basedate);
@HeLiBloks
HeLiBloks / WindowsServer12R2Labb
Last active October 7, 2016 18:07
BoxStarter
###
# wget https://gist.githubusercontent.com/HeLiBloks/db58ff3978ed6ad8b171/raw/5d34ed59c4e760d22b309de4285bca391f55e1bd/WindowsServer12R2Labb
##
Set-ExplorerOptions -showHidenFilesFoldersDrives -showProtectedOSFiles
Enable-RemoteDesktop
Install-WindowsUpdate -AcceptEula
Update-ExecutionPolicy Unrestricted
### See for details
@HeLiBloks
HeLiBloks / .vimrc.smal
Last active April 2, 2016 09:38
.vimrc
" Modeline and Notes"{
" vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker="{,"} foldlevel=0 foldmethod=marker filetype=vim noswapfile spell:
"}
let g:python_host_prog='/usr/bin/python2.7'
let g:python3_host_prog = '/usr/bin/python3'
set nocompatible " be iMproved, required
filetype off " required
@HeLiBloks
HeLiBloks / .vimperatorrc
Last active August 29, 2015 14:20
.vimperatorrc
source! ~/.vimperatorrc.local
set editor=gvim -f
" vim: set ft=vimperator:
set hintmatching
set hlsearch
set ignorecase
"#set wildmode=auto
" cpt=1
@HeLiBloks
HeLiBloks / snippet TSQL CREATE USER
Last active January 20, 2016 18:17
SQL_SERVER snipSnap
--GRANT ALL SQL SERVER
USE master;
go
use [the db];
CREATE LOGIN theUser WITH PASSWORD = 'ComplexPassword01';
CREATE USER theUser FOR LOGIN theUser;
GRANT BACKUP DATABASE, BACKUP LOG, CREATE DEFAULT, CREATE FUNCTION, CREATE PROCEDURE, CREATE RULE, CREATE TABLE, CREATE VIEW,CREATE DATABASE,CONTROL,ALTER
@HeLiBloks
HeLiBloks / alias.ps1
Created March 9, 2015 10:34
Aliases for PS
New-Alias -Name grep -Description grep Select-String
@HeLiBloks
HeLiBloks / .vimrc
Last active August 29, 2015 14:16
.vimrc file for nix
set nocompatible " be iMproved, required
filetype off " required
" " set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" " alternatively, pass a path where Vundle should install plugins
" "call vundle#begin('~/some/path/here')
" " let Vundle manage Vundle, required
@HeLiBloks
HeLiBloks / ssisssasssrs
Created March 5, 2015 19:33
SSIS SSRS SSAS snippets
//## timeStamp
(DT_STR,4,1252) DatePart("yyyy",getdate()) +
Right("0" + (DT_STR,4,1252) DatePart("m",getdate()),2) +
Right("0" + (DT_STR,4,1252) DatePart("d",getdate()),2) +
Right("0" + (DT_STR,4,1252) DatePart("hour",getdate()),2) +
Right("0" + (DT_STR,4,1252) DatePart("minute",getdate()),2) +
Right("0" + (DT_STR,4,1252) DatePart("second",getdate()),2)