Skip to content

Instantly share code, notes, and snippets.

View giansalex's full-sized avatar

Giancarlos Salas giansalex

View GitHub Profile
@giansalex
giansalex / versiones-vs.md
Last active November 16, 2017 21:17
Lista de versiones de Visual Studio
var registry = Microsoft.Win32.Registry.ClassesRoot;
var subKeyNames = registry.GetSubKeyNames();
var regex = new System.Text.RegularExpressions.Regex(@"^VisualStudio\.edmx\.(\d+)\.(\d+)$");
foreach (var subKeyName in subKeyNames)
{
    var match = regex.Match(subKeyName);
    if (match.Success)
        Console.WriteLine("V" + match.Groups[1].Value + "." + match.Groups[2].Value);
}
@giansalex
giansalex / saxon-xsl2-cs.md
Created November 19, 2017 17:24
Saxon c# xslt2 transform
using Saxon.Api;

var xslt = new FileInfo(@"C:\path\to\stylesheet.xslt");
var input = new FileInfo(@"C:\path\to\data.xml");
var output = new FileInfo(@"C:\path\to\result.xml");

// Compile stylesheet
var processor = new Processor();
@giansalex
giansalex / program.cs
Created November 22, 2017 21:08
Magick .Net - Optimize on the fly
using System;
using ImageMagick;
using System.IO;
namespace coreImagick
{
class Program
{
static void Main(string[] args)
{
StiReport report1 = new StiReport();
report1.RegData(dataSet1);
report1.Load("SimpleList.mrt");
report1.ReportDescription = "Demostracion de lista de clientes";
// Export PDF
report1.Render(false);
report1.ExportDocument(StiExportFormat.Pdf, "my.pdf");
Process.Start("my.pdf");
@giansalex
giansalex / dotConnect.md
Created February 16, 2018 00:23
Devart dotConnect license executable manually
%Compiler Path%lc /target:myapplication.exe /complist:licenses.licx /i:AssemblyPath/Devart.Data.PostgreSql.dll
@giansalex
giansalex / update-encoding.sql
Created February 22, 2018 20:21
Change encoding existing Postgresql Database
update pg_database set encoding = pg_char_to_encoding('LATIN1') where datname = 'dbname'
@giansalex
giansalex / pg-data-change.md
Last active February 22, 2018 22:57
Change the default PGDATA directory on Windows

PostgreSQL for Windows installs the PGDATA directory by default into C:\Program Files\PostgreSQL\some version\data. This mini-HOWTO explains how to change the default PGDATA directory to another location.

Step 1: Stop The PostgreSQL Service

Close all application that are currently connected to your database, then go to Windows Services Management and stop the PostgreSQL service:
pg services
You should check the task manager to see if any postgresql.exe instances are still running. If so, DO NOT TERMINATE them, instead close all applications that are still connected to the database. Sometimes services like webservers keep persistent connections. In this case you also should stop these services.

Step 2: Change Registry Values

Start the Windows Registry Editor (regedit.exe) and navigate to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\pgsql-some version.

@giansalex
giansalex / profile.md
Last active June 2, 2018 03:40
Asp.net profiler tools
@giansalex
giansalex / counter-down.js
Last active June 7, 2018 15:47
CounterDown - Javascript
function format2(value) {
if (value < 10) return '0' + value;
return value;
}
// Set the date we're counting down to
var countDownDate = 3*60000;
var now = 0;
var element = document.getElementById("demo");
SELECT
pg_terminate_backend(procpid)
FROM
pg_stat_activity
WHERE
-- don't kill my own connection!
procpid <> pg_backend_pid()
-- don't kill the connections to other databases
AND datname = 'database_name'
;