Skip to content

Instantly share code, notes, and snippets.

View ststeiger's full-sized avatar
😎
Back from holidays

Stefan Steiger ststeiger

😎
Back from holidays
  • Switzerland
View GitHub Profile
@ststeiger
ststeiger / ghostxps.sh
Created October 22, 2015 14:49 — forked from manuelmorales/ghostxps.sh
Installing GhostPDL (with GhostXPS) on Ubuntu Oneiric
sudo apt-get install libxext-dev libxt-dev
wget http://downloads.ghostscript.com/public/ghostpdl-9.05.tar.bz2
tar xjf ./ghostpdl-9.05.tar.gz
cd ghostpdl-9.05/
./configure
echo '#define HAVE_SYS_TIME_H' >> xps/obj/gconfig_.h
make xps
./xps/obj/gxps -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -r150 -o /tmp/a.pdf ~/POWERPOINT.xps
@ststeiger
ststeiger / Add_FK.sql
Created October 23, 2015 09:27
Fault-tolerant adding of foreign_key
IF 0 < (
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND TABLE_SCHEMA = 'dbo'
AND TABLE_NAME = 'T_SYS_Language_Forms'
)
BEGIN
-- Check for NULL values in the primary-key column
IF 0 = (SELECT COUNT(*) FROM T_SYS_Language_Forms WHERE LANG_UID IS NULL)
@ststeiger
ststeiger / SplitString.sql
Last active October 23, 2015 10:18
Splitting a string in SQL without needing a function:
-- You can split a string in SQL without needing a function:
DECLARE @bla varchar(MAX)
SET @bla = 'BED40DFC-F468-46DD-8017-00EF2FA3E4A4,64B59FC5-3F4D-4B0E-9A48-01F3D4F220B0,A611A108-97CA-42F3-A2E1-057165339719,E72D95EA-578F-45FC-88E5-075F66FD726C'
-- http://stackoverflow.com/questions/14712864/how-to-query-values-from-xml-nodes
SELECT
x.XmlCol.value('.', 'varchar(36)') AS val
FROM
(
@ststeiger
ststeiger / Makefile.golang
Created October 23, 2015 17:53 — forked from dnishimura/Makefile.golang
Makefile for Golang projects
# Makefile for a go project
#
# Author: Jon Eisen
# site: joneisen.me
#
# Targets:
# all: Builds the code
# build: Builds the code
# fmt: Formats the source files
# clean: cleans the code
@ststeiger
ststeiger / visor-archivos-online.md
Created November 11, 2015 13:18 — forked from izazueta/visor-archivos-online.md
Google Docs Viewer & Office Web Apps Viewer

Google Docs Viewer

Only files under 25 MB can be previewed with the Google Drive viewer.

Google Drive viewer helps you preview over 16 different file types, listed below:

  • Image files (.JPEG, .PNG, .GIF, .TIFF, .BMP)
  • Video files (WebM, .MPEG4, .3GPP, .MOV, .AVI, .MPEGPS, .WMV, .FLV)
  • Text files (.TXT)
  • Markup/Code (.CSS, .HTML, .PHP, .C, .CPP, .H, .HPP, .JS)
  • Microsoft Word (.DOC and .DOCX)
@ststeiger
ststeiger / CountDistinctWindowFn_Emulation.sql
Created December 18, 2015 11:29
Count DISTINCT OVER emulation
;WITH baseTable AS
(
SELECT 'RM1' AS RM, 'ADR1' AS ADR
UNION ALL SELECT 'RM1' AS RM, 'ADR1' AS ADR
UNION ALL SELECT 'RM2' AS RM, 'ADR1' AS ADR
UNION ALL SELECT 'RM2' AS RM, 'ADR2' AS ADR
UNION ALL SELECT 'RM2' AS RM, 'ADR2' AS ADR
UNION ALL SELECT 'RM2' AS RM, 'ADR3' AS ADR
UNION ALL SELECT 'RM3' AS RM, 'ADR1' AS ADR
@ststeiger
ststeiger / LinkedServerSynonyms.sql
Last active December 18, 2015 11:40
Synonym creation for database mirroring via linked server (does not work for function-objects)
-- 0a) Create Linked server
-- 0b) Enable SPs for linked server
-- EXEC sp_serveroption @server='CORDB2008R2', @optname='rpc', @optvalue='true'
-- EXEC sp_serveroption @server='CORDB2008R2', @optname='rpc out', @optvalue='true'
-- 1 Create database
-- 2 Create types
-- 3 Create table-synonyms
@ststeiger
ststeiger / NumberSeries.sql
Created January 25, 2016 16:10
Create a number series in SQL
DECLARE @start int
DECLARE @end int
SET @start = 3
SET @end = 4
;WITH CTE AS
@ststeiger
ststeiger / CreateSchema.sql
Created January 28, 2016 14:06
Create Schema if not exists
--DROP SCHEMA [Import2]
IF NOT EXISTS (SELECT name FROM sys.schemas WHERE name = N'Import2')
EXECUTE('CREATE SCHEMA [Import2] AUTHORIZATION [dbo]')
;
@ststeiger
ststeiger / Select_from_StoredProcedure.sql
Last active February 2, 2016 16:10
SQL-SELECT from stored procedure
/*
exec sp_RPT_DATA_REM_Stundenuebersicht
@in_mandant=N'0'
,@in_sprache=N'de'
,@in_standort=N'8adddbda-442b-4de4-a89e-a4e863ad7a72'
,@in_gebaeude=N'00000000-0000-0000-0000-000000000000'
,@in_portofolio_raum=N'00000000-0000-0000-0000-000000000000'
,@in_subportofolio_raum=N'00000000-0000-0000-0000-000000000000'
,@in_strasse=N'Alle'
,@in_geschoss=N'00000000-0000-0000-0000-000000000000'