Skip to content

Instantly share code, notes, and snippets.

View obrassard's full-sized avatar

Olivier Brassard obrassard

View GitHub Profile
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace JokesAPI
{
public class DadJokeService
{
public class FiboGenerator implements Iterable<BigInteger>, Iterator<BigInteger> {
BigInteger avantDernier = BigInteger.ZERO;
BigInteger avantAvantDernier = BigInteger.ONE ;
@Override
public Iterator<BigInteger> iterator() {
return this;
}
public class Repository<T> where T : class
{
private DbSet<T> m_dbset;
private BaremoContext m_context;
public Repository(DbSet<T> dbset, BaremoContext context)
{
m_dbset = dbset;
m_context = context;
}
@obrassard
obrassard / locations.sql
Created October 28, 2018 20:08
SQL statement to find locations within a X distance of another location (with lat / lng)
# https://gis.stackexchange.com/questions/31628/find-points-within-a-distance-using-mysql
SET @lat = 45.536264;
SET @long = -73.493025;
SELECT
id, name, (
6371 * acos (
cos ( radians(@lat) )
* cos( radians( lat ) )
@obrassard
obrassard / sha.cs
Created November 5, 2018 23:11
SHA-256 & SHA-512 Hashing Utility in C#
using System;
using System.Text;
namespace System.Security.Cryptography;
{
public static class SHA
{
public static string sha256(string inputString)
{
SHA256 sha256 = SHA256.Create();
byte[] bytes = Encoding.UTF8.GetBytes(inputString);
@obrassard
obrassard / Chart.cs
Last active November 17, 2018 01:45
Exemple d'intégration de Chart.Js en ASP.NET Mvc
using System.Collections.Generic;
namespace ChartJs.Models
{
public class Chart
{
public string[] labels { get; set; }
public List<Datasets> datasets { get; set; }
public static Chart CreateLineChart(string datasetName, string[] labels, int[] values)
export {};
declare global {
interface String {
isNotEmpty(): boolean;
}
}
String.prototype.isNotEmpty = function () {
return (this.trim() !== '');

Setup Virtual Host and configure HTTPS with Certbot on Ubuntu

A little walkthrough to setup a new apache virtual host with an HTTPS certificate on Ubuntu.

How to setup a new Virtual Host

Install apache2

sudo apt-get update
@obrassard
obrassard / node-apache.md
Last active October 3, 2019 19:35
Host a Node.js app alongside apache sites

Host a Node.js app alongside apache sites

Walkthrough to setup apache vhost proxy towards a Node.js app + HTTPS on Ubuntu.

Requirements

  • Apache 2
  • Certbot
  • Node.js
  • A new domain / subdomain
@obrassard
obrassard / portainer-dokku.md
Created January 23, 2020 01:34 — forked from woudsma/portainer-dokku.md
TLS secured TCP exposed Docker daemon on Dokku host - setup

TLS secured TCP exposed Docker daemon on Dokku host - setup

  1. Create certificates
  2. Edit Docker options
  3. Restart Docker
  4. Copy client certificates from host
  5. (optional) Add remote endpoint in Portainer

Tested on a standard $5/mo DigitalOcean VPS running Ubuntu 16.04.