Skip to content

Instantly share code, notes, and snippets.

View HeLiBloks's full-sized avatar

Henrik Lindgren HeLiBloks

  • Stockholm
View GitHub Profile
## sed ish
$a -replace "([A-z])(23)","$1,$2"
##seq 1 10
1..10
##loop
for ($i=0;$i -lt 10; $i++) { echo $i }
##copy files recursive
@HeLiBloks
HeLiBloks / cSHARPsnippets.cs
Last active August 29, 2015 14:16
C# snippets
//##show message box
MessageBox.Show(Dts.Variables["YourVariableNameHere"].Value.ToString());
//regexMatch [[:number:]]
Regex.Match(Row.var, @"\d+").Value
//
Regex.Match(Row.var, @"[A-Za-z]+").Value
//date 09/12/1980
@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)
@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 / alias.ps1
Created March 9, 2015 10:34
Aliases for PS
New-Alias -Name grep -Description grep Select-String
@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 / 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 / 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>
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 / 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