Skip to content

Instantly share code, notes, and snippets.

@odan
odan / nginx-php-windows-setup.md
Last active May 4, 2024 02:16
Nginx and PHP Setup on Windows

Nginx and PHP Setup on Windows

For local development you could also use Nginx with PHP as an replacement for XAMPP.

Install Nginx

@odan
odan / xampp_php7_xdebug.md
Last active April 17, 2024 05:36
Installing Xdebug for XAMPP
@odan
odan / remove-namespaces-xml.php
Last active March 29, 2024 09:34
Remove all namespaces from XML in PHP (dirty hack)
<?php
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML(file_get_contents(__DIR__ . '/demo.xml'));
$dom = removeAllNamespaces($dom);
$dom->save('demo-out.xml');
using System;
using System.Collections.Generic;
using System.Globalization;
// CultureInfo culture = new CultureInfo("en-US");
// Full-date notation as defined by RFC 3339, section 5.6, for example, 2024-03-28
string date1 = string.Format("{0:yyyy}-{0:MM}-{0:dd}", DateTime.Now);
Console.WriteLine(date1);
@odan
odan / soap-xmldsig.md
Created June 1, 2021 14:23
Sign SOAP messages with xmlseclibs

Sign SOAP messages with xmlseclibs

Requirements

  • PHP 7.4+
  • OpenSSL

Generating Public and Private Keys

First we have to create a private key for signature creation, and a public key for verification.

Creating a ASP.NET Core Web API from scratch

Requires .NET 8 SDK

dotnet new sln -o MyApi
cd MyApi

dotnet new webapi -o MyApi

Convert video to a Twitter-friendly format

Simple, but with minimum modification:

ffmpeg -i "input.mp4" -pix_fmt yuv420p -vcodec libx264 "output.mp4"

Resizes the video and may better support encodings:

@odan
odan / mysq_uuid_v4.md
Last active January 12, 2024 01:11
Generating UUID v4 in MySQL

Generating UUID v4 in MySQL

SELECT
  LOWER(
    CONCAT(
      # 1th and 2nd block are made of 6 random bytes
      HEX(RANDOM_BYTES(4)),
      '-',
 HEX(RANDOM_BYTES(2)),

File Operations in C++

Reading a file into a string variable

#include <iostream>
#include <fstream>
using namespace std;

fstream file("file.name.xml", fstream::in);