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 / docker.md
Last active July 5, 2019 14:30
Docker - steps to publish

Steps

Build

Go DockerFile's directory, run:

docker build -t local/myimage .

Build

@giansalex
giansalex / docker-php-ext-install.md
Last active October 13, 2024 20:15
docker-php-ext-install Reference
RUN apt update
RUN apt upgrade -y
RUN apt install -y apt-utils
RUN a2enmod rewrite
RUN apt install -y libmcrypt-dev
RUN apt install -y libicu-dev
RUN docker-php-ext-install -j$(nproc) intl
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ 
@giansalex
giansalex / nssm-service.md
Last active July 22, 2020 01:05
Nssm Service Manager Configuration - Run php webserver as Windows Service

Service name is 'PHP001'.

Install

nssm install PHP001

withou GUI

nssm install PHP001 C:\xampp\php\php.exe -S 127.0.0.1:8099
@giansalex
giansalex / read-file-postgresql.md
Created January 13, 2018 18:59
Read file and insert data to field - PostgreSQL

First

Create function

create or replace function bytea_import(p_path text, p_result out bytea) 
                   language plpgsql as $$
declare
  l_oid oid;
  r record;
begin
 p_result := '';
@giansalex
giansalex / ProxySoap.php
Last active September 27, 2023 06:49
Use SoapClient PHP with proxy for HTTP/HTTPS connections
<?php
$parameters = [
'proxy_host' => "127.0.0.1",
'proxy_port' => 8888,
'stream_context' => stream_context_create(
array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
@giansalex
giansalex / php-background.php
Created January 21, 2018 23:09
Execute $cmd in the background (no cmd window) without PHP waiting for it to finish, on both Windows and Unix.
<?php
function execInBackground($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec($cmd . " > /dev/null &");
}
}