Skip to content

Instantly share code, notes, and snippets.

View tecnocrata's full-sized avatar
:octocat:
Working from home

Enrique Ortuño tecnocrata

:octocat:
Working from home
View GitHub Profile
@tecnocrata
tecnocrata / gist:5358844
Last active December 16, 2015 01:59
Busca objetos dentro los nombres de columnas en T-SQL
select
o.name,c.name
from sys.columns c
inner join sys.objects o on c.object_id=o.object_id
where c.name Like '%bus_no%'
order by o.name,c.column_id
-- for query tables use sys.tables
-- for query stored procedures use sys.procedures
@tecnocrata
tecnocrata / gist:8721074
Created January 30, 2014 22:11
Como usar un DockPanel en WPF, Algo similar al StackPanel
<DockPanel LastChildFill="True">
<ProgressBar x:Name="pgrBar" Visibility="Hidden" DockPanel.Dock="Bottom" IsIndeterminate="True" Height="20"></ProgressBar>
<WebBrowser Name="webControl" />
</DockPanel>
@tecnocrata
tecnocrata / gist:8955392
Created February 12, 2014 13:17
Determine if I'm running on 64 bits (How to detect Windows 64-bit platform with .NET?)
//http://stackoverflow.com/questions/336633/how-to-detect-windows-64-bit-platform-with-net
bool is64BitProcess = (IntPtr.Size == 8);
bool is64BitOperatingSystem = is64BitProcess || InternalCheckIsWow64();
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool IsWow64Process(
[In] IntPtr hProcess,
[Out] out bool wow64Process
@tecnocrata
tecnocrata / gist:9091713
Created February 19, 2014 13:14
Paginacion en SQL Server
--Recibiendo PageIndex y PageSize
SELECT TOP (PageSize)
[Extent1].[Id] AS [Id],
[Extent1].[Capacidad] AS [Capacidad],
[Extent1].[Ubicacion] AS [Ubicacion]
FROM ( SELECT [Extent1].[Id] AS [Id], [Extent1].[Capacidad] AS [Capacidad], [Extent1].[Ubicacion] AS [Ubicacion], row_number() OVER (ORDER BY [Extent1].[Id] ASC) AS [row_number]
FROM [dbo].[Mesa] AS [Extent1]
)  AS [Extent1]
WHERE [Extent1].[row_number] > PageSize*(PageIndex-1)
@tecnocrata
tecnocrata / gist:9102457
Created February 19, 2014 21:53
Single Instance of WPF Application
First you can start by removing the StartupUri attribute from the App.Xaml file so that it looks like this...
<Application x:Class="SingleInstance.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</Application>
After that, you can go to the App.xaml.cs file and change it so it looks like this...
public partial class App
@tecnocrata
tecnocrata / gist:9731881
Last active August 29, 2015 13:57
Patrón para ejecución de procesos largos con notificación-actualización de UI de resultados parciales
//Ambas soluciones estan propuestas por Jorge Fioranelli: jorge.fioranelli@gmail.com
public interface IStep
{
event EventHandler<StepEventArgs> Started;
event EventHandler<StepEventArgs> Finished;
void Execute();
}
@tecnocrata
tecnocrata / gist:ada047d78d36df4eebda
Created June 6, 2014 14:09
Solving PriorityManagement-by-RoutingMode>1:XXX>2:YYY regex
//PriorityManagement-by-RoutingMode>1:XXX>2:YYY
private string ResolveNamePattern(string name)
{
var globalpattern = "(?<PName>.*)-by-(?<Criteria>.*)-(?<Conditions>>.*)";
if (!Regex.IsMatch(name, globalpattern, RegexOptions.IgnoreCase)) return name;
var globalregex = new Regex(globalpattern, RegexOptions.IgnoreCase);
var parameterName = globalregex.Match(name).Groups["PName"].Value;
var criteria = globalregex.Match(name).Groups["Criteria"].Value;
@tecnocrata
tecnocrata / gist:e69abbff5295bdf19849
Created July 23, 2014 20:50
Comment / Uncomment C# Code
private string CommentSelection(string selected)
{
var result = string.Empty;
try
{
var lineMatches = Regex.Matches(selected, ".*", RegexOptions.Multiline);
foreach (var lineMatch in lineMatches)
{
if (string.IsNullOrEmpty(lineMatch.ToString())) continue;
result = result + @"//" + lineMatch.ToString();
@tecnocrata
tecnocrata / Errors
Created December 23, 2014 15:48
Solving a problem with Assemblies in SQL
Changed database context to 'master'.
Changed database context to 'MyDataBase'.
Running pre-deploy script.
Changed database context to 'MyDataBase'.
Warning: The Microsoft .NET Framework assembly 'system.enterpriseservices, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a, processorarchitecture=amd64.' you are registering is not fully tested in the SQL Server hosted environment and is not supported. In the future, if you upgrade or service this assembly or the .NET Framework, your CLR integration routine may stop working. Please refer SQL Server Books Online for more details.
Warning: The Microsoft .NET Framework assembly 'system.directoryservices, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a, processorarchitecture=msil.' you are registering is not fully tested in the SQL Server hosted environment and is not supported. In the future, if you upgrade or service this assembly or the .NET Framework, your CLR integration routine may stop working. Please refer SQL Server Books
@tecnocrata
tecnocrata / web1.config
Last active April 30, 2020 14:30
Enable WCF Tracing in whatever serverxxx .config file
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true" >
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="xml"/>