Skip to content

Instantly share code, notes, and snippets.

View formix's full-sized avatar

Jean-Philippe Gravel formix

  • Formix Consulting
  • Saint-Honoré-De-Chicoutimi, Saguenay, Quebec, Canada
  • LinkedIn in/jpgravel
View GitHub Profile
@formix
formix / SUID.cs
Last active April 2, 2020 23:43
64 bits Sufficiently Unique Id Generator
/****************************************************************************
* Copyright 2009-2020 Jean-Philippe Gravel, P. Eng. PSEM
* Conversion to C# from https://gist.github.com/formix/d9521fd49cbeee305e2a
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
var extend = require("util")._extend;
module.exports.example1 = function() {
return {
characteristics: {
length: extend(new Char("length"), {
validate: validateLength
@formix
formix / EmptyHtml5.html
Last active July 15, 2016 18:16
Empty HTML 5 template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
<!--
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
-->
</head>
@formix
formix / .vimrc
Last active December 14, 2022 01:31
My vimrc file
set nocompatible " Disable vi-compatibility
set t_Co=256
map <F6> :tabe<Space>
map <F7> :tabp<CR>
map <F8> :tabn<CR>
colorscheme xoria256
set expandtab tabstop=4 shiftwidth=4
@formix
formix / EasyCrypt.cs
Last active March 18, 2022 17:42
EasyCrypt: An Obfuscation C# Class
/****************************************************************************
* Copyright 2009-2018 Jean-Philippe Gravel, P. Eng., PSEM
*
* Modified 07/31/16 - Jean-Philippe Gravel (@formixian) - Changed the class
* def to static instead of being an instance class.
* - Changed license to Apache 2.0
* 02/08/18 - Added Obfuscate and Clarify methods
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@formix
formix / CustomBasicAuthentication.cs
Last active March 30, 2016 01:27
.NET Custom Basic Authentication
using System;
using System.IO;
using System.Text;
using System.Web;
namespace BasicAuthenticationFlashTalk
{
public class BasicAuthenticationModule : IHttpModule
{
@formix
formix / BasicAuthenticationFilter.java
Created March 29, 2016 23:25 — forked from neolitec/BasicAuthenticationFilter.java
HTTP Basic authentication Java filter
package com.neolitec.examples;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@formix
formix / SUID.java
Last active February 26, 2018 18:09
64 bits Sufficiently Unique Id Generator
/****************************************************************************
* Copyright 2009-2015 Jean-Philippe Gravel, P. Eng. CSDP
*
* Modified 4/7/16 - Jean-Philippe Gravel (@formix) - Moved random number
* generator into the method "if" statement.
*
* Modified 6/8/15 - Osric Wilkinson (@Moosemorals) - No point messing with
* random seeds. Just use SecureRandom.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@formix
formix / xd2md.cs
Last active January 17, 2024 21:13
Generates Markdown From VisualStudio XML documentation files
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
namespace Formix.Utils
{
class Program
@formix
formix / wordwrap.js
Last active March 4, 2021 15:20
JavaScript Word Wrap
/**
* Wrap text to a maximum of 78 char per line. Indent the text using the number
* of spaces specified by indent.
*/
function wrap(text, indent) {
if (!text) {
console.log();
return;
}