Skip to content

Instantly share code, notes, and snippets.

import React from "react";
import styled, { ThemeProvider } from "styled-components";
const Container = styled.div`
display: flex;
flex-direction: column;
width: 100vw;
height: 100vh;
align-items: center;
justify-content: center;
import React, { createContext, useState } from "react";
import { ThemeProvider } from "styled-components";
export const ThemeContext = createContext({});
const DarkModeProvider = ({ children }) => {
const [mode, setMode] = useState("light");
const toggleMode = () => {
const newMode = mode === "light" ? "dark" : "light";
import { createContext } from "react";
const ThemeContext = createContext({});
export default ThemeContext;
import React from "react";
import styled from "styled-components";
const Container = styled.div`
display: flex;
flex-direction: column;
width: 100vw;
height: 100vh;
align-items: center;
justify-content: center;
@btodts
btodts / CreateCRGitLabCloudflare.ps1
Last active February 3, 2020 11:53
CreateCRGitLabCloudflare.ps1
param (
[Parameter(Mandatory = $True)]
[string]$Description,
[Parameter(Mandatory = $True)]
[string]$Subject,
[Parameter(Mandatory = $True)]
[string]$JiraAuthKey
)
$DueDate = (Get-Date).ToString("yyyy-MM-dd'T'HH:mm:ss'.000+0100'")
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseExceptionHandler(errorApp =>
{
errorApp.Run(async context =>
{
var exceptionHandlingFeature = context.Features.Get<IExceptionHandlerPathFeature>();
if (exceptionHandlingFeature?.Error is GuardException ex)
public static class Guard
{
public static void GuidNotEmpty(Guid argument, string argumentName)
{
if (argument == Guid.Empty)
throw new GuardException(argumentName, "Guid should not be empty.");
}
public static void StringNotNullOrEmpty(string argument, string argumentName)
{
public sealed class GuardException : Exception
{
public string ArgumentName { get; }
public GuardException(string argumentName, string message)
: base(message)
{
ArgumentName = argumentName;
}
}
public static class Guard
{
public static void GuidNotEmpty(Guid argument, string argumentName)
{
if (argument == Guid.Empty)
throw new ArgumentException("Guid should not be empty.", argumentName);
}
public static void StringNotNullOrEmpty(string argument, string argumentName)
{
[HttpPost]
public async Task<IActionResult> Post(Guid id, string name)
{
Guard.GuidNotEmpty(id, nameof(id));
Guard.StringNotNullOrEmpty(name, nameof(name));
// handle the request
}