Skip to content

Instantly share code, notes, and snippets.

View georgepaoli's full-sized avatar

George Paoli georgepaoli

View GitHub Profile
@georgepaoli
georgepaoli / sp_async_execute.sql
Created August 25, 2016 18:34
Asynchronous Execution of T-SQL command, MSSQL (by Antonin Foller)
/*
sp_async_execute - asynchronous execution of T-SQL command or stored prodecure
2012 Antonin Foller, Motobit Software, www.motobit.com
URL FONT: http://www.motobit.com/tips/detpg_async-execute-sql/
*/
CREATE PROCEDURE sp_async_execute(@sql varchar(4000), @jobname varchar(200) = null,
@database varchar(200)= null, @owner varchar(200) = null ) AS BEGIN
SET NOCOUNT ON;
declare @id uniqueidentifier
@georgepaoli
georgepaoli / find_text_in_sp.sql
Created August 25, 2016 18:40
Find text or command in a stored procedure, MSSQL (by Antonin Foller)
-- URL FONT: http://www.motobit.com/tips/detpg_sql-find-text-stored-procedure/
-- =============================================
-- Author: Antonin Foller, www.foller.cz
-- Create date: 2007-09-19
-- Description: Search a text in stored procedure source code.
-- @text - any text to find, search is done by like '%text%'
-- @dbname - database where to search,
-- - if omitted, all databases in the SQL server instance
-- =============================================
ALTER PROCEDURE [dbo].[find_text_in_sp]
@georgepaoli
georgepaoli / Manager IIS from ServerManager .NET class
Created August 26, 2016 12:35
Microsoft.Web.Administration in IIS 7
From https://blogs.msdn.microsoft.com/carlosag/2006/04/17/microsoft-web-administration-in-iis-7/
Creating a Site
ServerManager iisManager = new ServerManager();
iisManager.Sites.Add(“NewSite”, “http”, “*:8080:”, “d:\\MySite”);
iisManager.Update();
This basically creates an instance of the ServerManager class and uses the Add method in the Sites collection to create a new site named “NewSite” listening at port 8080 using http protocol and content files are at d:\MySite.
One thing to note is that calling Update is a requirement since that is the moment when we persist the changes to the configuration store.
After running this code you have now a site that you can browse using http://localhost:8080
-- Pegar a data removendo a HH:MM:SS:mmm
SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))
-- ou
SELECT convert(DATETIME, floor(convert(FLOAT(24), GETDATE())))
-- SQL Server Date Formats (http://www.sql-server-helper.com/tips/date-formats.aspx)
SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 103), '/', '') AS [DDMMYYYY]
-- Convert rows in concatenaded string list
SELECT STUFF((SELECT ',''' + field + ''''
@georgepaoli
georgepaoli / tcp-ip-socket-server.cs
Last active January 9, 2017 20:28
TCP/IP Socket Server
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace Host
{
@georgepaoli
georgepaoli / tcp-ip-socket-client.cs
Created January 9, 2017 20:28
TCP/IP - Socker Client
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace Client
{
class Program
@georgepaoli
georgepaoli / rfc-sap-dotnet.cs
Created June 22, 2017 13:33
Exemplo de integração com SAP via RFC em C#
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SAP.Middleware.Connector;
namespace exemplo
{
@georgepaoli
georgepaoli / project.csproj
Created August 11, 2017 18:25
Custom build version number in dotnet
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="BeforeBuild">
<!-- https://stackoverflow.com/a/6472195/2076784 -->
<PropertyGroup>
<Year>$([System.DateTime]::Now.ToString("yyyy"))</Year>
<Month>$([System.DateTime]::Now.ToString("MM"))</Month>
<Date>$([System.DateTime]::Now.ToString("dd"))</Date>
<Time>$([System.DateTime]::Now.ToString("HHmm"))</Time>
<AssemblyFileVersionAttribute>[assembly:System.Reflection.AssemblyFileVersion("$(Year).$(Month).$(Date).$(Time)")]</AssemblyFileVersionAttribute>
@georgepaoli
georgepaoli / Angular HTTP Interceptor.js
Created August 28, 2017 20:53
Angular HTTP Interceptor Sample
// Create HTTP interceptor (https://docs.angularjs.org/api/ng/service/$http - Interceptors topic)
App.factory('AuthInterceptor', ['$window', '$q', '$location', function ($window, $q, $location) {
return {
request: function (config) {
config.headers = config.headers || {};
config.headers.ContentType = 'application/json; charset=UTF-8';
if (myGlobalVar.getToken()) {
// populate header custom fields
config.headers.Authorization = 'Bearer ' + myGlobalVar.getToken().access_token;
config.headers.iduser = myGlobalVar.getToken().iduser;
@georgepaoli
georgepaoli / vs2012.vssettings
Created September 21, 2017 12:19
My VS 2012 Settings
<UserSettings>
<ApplicationIdentity version="11.0"/>
<ToolsOptions>
<ToolsOptionsCategory name="Environment" RegisteredName="Environment">
<ToolsOptionsSubCategory name="Documents" RegisteredName="Documents" PackageName="Visual Studio Environment Package">
<PropertyValue name="ShowMiscFilesProject">false</PropertyValue>
<PropertyValue name="AutoloadExternalChanges">false</PropertyValue>
<PropertyValue name="CheckForConsistentLineEndings">true</PropertyValue>
<PropertyValue name="SaveDocsAsUnicodeWhenDataLoss">false</PropertyValue>
<PropertyValue name="InitializeOpenFileFromCurrentDocument">true</PropertyValue>