Skip to content

Instantly share code, notes, and snippets.

@gleox
gleox / svgfixer.js
Created August 10, 2016 07:05 — forked from leonderijke/svgfixer.js
Fixes references to inline SVG elements when the <base> tag is in use.
/**
* SVG Fixer
*
* Fixes references to inline SVG elements when the <base> tag is in use.
* Firefox won't display SVG icons referenced with
* `<svg><use xlink:href="#id-of-icon-def"></use></svg>` when the <base> tag is on the page.
*
* More info:
* - http://stackoverflow.com/a/18265336/796152
* - http://www.w3.org/TR/SVG/linking.html
diff --git a/Makefile b/Makefile
index b670978..ece7ac3 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,7 @@ CC=gcc
DEBUG?=-g3
#OPTIMIZATION?=-O2
WARN?=-Wall -Wshadow -Wpointer-arith -Wmissing-declarations -Wnested-externs
+OPTIONS?=-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
@gleox
gleox / TrimEndZero.cs
Last active May 7, 2018 10:14
Trim end zero characters for a number string.
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
@gleox
gleox / web.config
Created May 9, 2018 03:02
A IIS rewrite rule for SPA
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="pages" enabled="true" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="/" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_URI}" matchType="Pattern" pattern="/(api|static)(.*)$" ignoreCase="true" negate="true" />
@gleox
gleox / get_third_wednesday.cs
Last active December 27, 2018 09:09
How to find the third Wednesday of the month of the specific time
using System;
// see: https://stackoverflow.com/questions/5421972/how-to-find-the-3rd-friday-in-a-month-with-c
namespace Demo
{
public class ScheduleTimeService
{
/// <summary>
/// How to find the third Wednesday of the month of the specific time
/// </summary>
@gleox
gleox / web.config
Created August 27, 2018 07:15
Web.config for /.well-known/ directory in an ASP.net application
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".*" mimeType="text/plain" />
</staticContent>
</system.webServer>
</configuration>
@gleox
gleox / web.config
Created August 27, 2018 07:17
Web.config for reverse proxy in an acme application
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Reverse Proxy to acme" stopProcessing="true">
<match url="(.*)"/>
<action type="Rewrite" url="http://localhost:8000/{R:1}"/>
</rule>
</rules>
@gleox
gleox / DotEnvHelper.cs
Created December 29, 2018 07:01
DotEnvHelper.cs
using System;
using System.IO;
using System.Text;
using System.Threading;
namespace Utils
{
public class DotEnvHelper
{
private static int _initialized;
@gleox
gleox / Hex.cs
Created March 13, 2019 03:30
Helper to convert byte array(blob) to hex string.
using System;
namespace FipsTest
{
public static class Hex
{
public const string HexDigits = "0123456789abcdef";
private static char[] _lowerDigits;
private static char[] _upperDigits;
@gleox
gleox / cred.go
Last active July 25, 2020 09:33
TP-LINK路由器登录的RSA加密实现
package tplink
import (
"git.4z.ee/gleox/tplink/tplink/rsa"
)
const (
modulus = "D1E79FF135D14E342D76185C23024E6DEAD4D6EC2C317A526C811E83538EA4E5ED8E1B0EEE5CE26E3C1B6A5F1FE11FA804F28B7E8821CA90AFA5B2F300DF99FDA27C9D2131E031EA11463C47944C05005EF4C1CE932D7F4A87C7563581D9F27F0C305023FCE94997EC7D790696E784357ED803A610EBB71B12A8BE5936429BFD"
exponent = "010001"
)