Skip to content

Instantly share code, notes, and snippets.

View yanickrochon's full-sized avatar

Yanick Rochon yanickrochon

  • Québec, Canada
View GitHub Profile
@yanickrochon
yanickrochon / next-url.ts
Last active February 16, 2023 00:02
Get server side page full URL for Next.js
import { IncomingMessage } from "http";
const basePath = process.env.NEXT_PUBLIC_BASE_PATH ?? "";
export type RequestURL = URL & {
basePath: string;
};
const getFromMeta = (req: IncomingMessage) => {
const meta = Object.getOwnPropertySymbols(req).find(
@yanickrochon
yanickrochon / SignaturePad.jsx
Last active September 8, 2022 19:02
Material UI integration of react-signature-canvas (https://github.com/agilgur5/react-signature-canvas)
import React, { useEffect, useRef, useState } from 'react';
import PropType from 'prop-types';
import { makeStyles } from '@material-ui/core/styles';
import classNames from 'classnames';
import Fade from '@material-ui/core/Fade';
import FormControl from '@material-ui/core/FormControl';
import IconButton from '@material-ui/core/IconButton';
import InputLabel from '@material-ui/core/InputLabel';
@yanickrochon
yanickrochon / flexboxgrid.css
Last active December 4, 2016 00:12
This, to me, solves the issue of horizontal scroll bars with Flexbox Grid. As long as Grid wraps the page content, everything seems to be fine so far.
:root {
--gutter-width: 1;
--gutter-compensation: calc((var(--gutter-width) * 0.5) * -1);
--half-gutter-width: calc((var(--gutter-width) * 0.5));
--container-sm: 46.5em;
--container-md: 63em;
--container-lg: 74em;
}
@custom-media --sm-viewport only screen and (min-width: 48em);
@yanickrochon
yanickrochon / User.cs
Created November 28, 2013 13:51
Example my "issue" with C#'s naming convention. While most modern language have a "camel case" convention, C# uses an "upper camel case" (or "pascal case") convention. This cause problem when translating from, let say, JavaScript (JSON), or XML into C#.
public class User {
// composed class
public enum UserRole {
Guest = 0,
Subscriber = 1,
Supervisor = 2,
Editor = 3,
Publisher = 4,
Administrator = 5