Skip to content

Instantly share code, notes, and snippets.

View tonidy's full-sized avatar

toni dy tonidy

View GitHub Profile
@tonidy
tonidy / author.sh
Last active July 3, 2019 04:58
Change git author name & email
#!/bin/bash
## https://help.github.com/en/articles/changing-author-info
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
@tonidy
tonidy / gist:cfad869bf96e60c67454a41faa64e06f
Last active July 19, 2019 12:27
Install Docker Toolbox with Hyper-V on Windows 8.1
Install Docker Toolbox:
# Docker and DockerMachine are required.
> DockerToolbox-<version>.exe /COMPONENTS="Docker,DockerMachine"
# Edit "Docker Quick Terminal" with this patch -> https://github.com/docker/toolbox/issues/463#issuecomment-335318852
> docker-machine create -d "hyperv" --hyperv-virtual-switch "Network Name" default
//taken from https://blogs.msmvps.com/kenlin/2018/01/18/2694/
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
//These headers are handling the "pre-flight" OPTIONS call sent by the browser
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");
HttpContext.Current.Response.AddHeader("Access-Control-Allow‌​-Credentials", "true");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
#!/bin/sh
# NB: When editing this file, be careful to preserve the original whitespace (especially newlines).
HDXRTME_install_loadstrings_en()
{
HDXRTME_install_yeschoices="yes,YES,Yes,y,Y"
HDXRTME_install_nochoices="no,NO,No,n,N, " # <-- trailing comma+space indicates empty input defaults to N
@tonidy
tonidy / homebrew-install-mkpasswd.md
Last active August 30, 2021 12:34 — forked from mcandre/homebrew-install-mkpasswd.md
Homebrew install mkpasswd
brew tap tonidy/tools-tap
brew install mkpasswd
@tonidy
tonidy / fcos-qemu-demo
Created May 25, 2021 05:41 — forked from mpreu/fcos-qemu-demo
Fedora CoreOS - Example script to setup a FCOS virtual machine using QEMU. Originates from this blog post: https://www.matthiaspreu.com/posts/fedora-coreos-first-steps/.
#!/bin/env bash
set -eo pipefail
#
# Part of an introductory Fedora CoreOS blog post on my website:
# https://www.matthiaspreu.com/posts/fedora-coreos-first-steps/
#
# Script sets up a FCOS virtual machine using QEMU.
#
# Initial user "matthias" with password "test" can be used.
@tonidy
tonidy / Makefile
Last active August 2, 2021 03:25
Merge 2 kubernetes config files
## Using:
## to see newconfig
## make view newconfig=~/new-config.yaml
## to merge configs
## make merge newconfig=~/new-config.yaml
view::
cp ~/.kube/config ~/.kube/config.bak && KUBECONFIG=~/.kube/config:$(newconfig) kubectl config view --flatten > /tmp/config && cat /tmp/config
merge::
cp ~/.kube/config ~/.kube/config.bak && KUBECONFIG=~/.kube/config:$(newconfig) kubectl config view --flatten > /tmp/config && mv /tmp/config ~/.kube/config
@tonidy
tonidy / Info.cshtml
Created October 20, 2021 16:49 — forked from mika76/Info.cshtml
phpinfo like page for .net core
@page
@{
Layout = "";
}
@using System.Linq;
@using System.Collections;
@using System.Reflection;
<html>
@tonidy
tonidy / EnumerablePaginationExtensions.cs
Created January 12, 2022 07:16 — forked from SaxxonPike/EnumerablePaginationExtensions.cs
C# forward pagination extension method
using System.Collections.Generic;
namespace Extensions
{
public static class EnumerablePaginationExtensions
{
public static IEnumerable<IEnumerable<T>> Paginate<T>(this IEnumerable<T> items, int pageSize)
{
var page = new List<T>();
foreach (var item in items)
@tonidy
tonidy / mock.cs
Created January 21, 2022 13:17 — forked from umair-me/mock.cs
Mock Configuration.GetSection
Mock<IConfiguration> configuration = new Mock<IConfiguration>();
configuration.Setup(c => c.GetSection(It.IsAny<String>())).Returns(new Mock<IConfigurationSection>().Object);