Skip to content

Instantly share code, notes, and snippets.

View ccpu's full-sized avatar

cyrus ccpu

  • Planet Earth, Milky Way
View GitHub Profile
@ccpu
ccpu / git-mv-with-history
Created January 9, 2021 11:17 — forked from emiller/git-mv-with-history
git utility to move/rename file or folder and retain history with it.
#!/bin/bash
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
# with different name and the same content.
public class test
{
[Theory, TestData]
public void make_this_populate_a_controller( TestController SUT)
{
var actionResult = SUT.Get("hello");
var x = "";
}
}
@ccpu
ccpu / ExceptionFilter.cs
Created December 9, 2020 18:05 — forked from Ciantic/ExceptionFilter.cs
Exception Middleware vs Exception Filter both return ObjectResult, ASP.NET Core
using System;
using Microsoft.AspNetCore.Mvc.Filters;
namespace Example
{
public class ApiExceptionFilter : Attribute, IExceptionFilter
{
public void OnException(ExceptionContext context)
{
if (context.Exception is Exception) {
@ccpu
ccpu / AutoMigration.cs
Created November 25, 2020 13:37 — forked from lakeman/AutoMigration.cs
Automatic database migration with EF Core 3.0
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Design;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
using Microsoft.EntityFrameworkCore.Storage;
@ccpu
ccpu / ffmpeg_mkv_mp4_conversion.md
Created November 24, 2020 12:47 — forked from jamesmacwhite/ffmpeg_mkv_mp4_conversion.md
Easy way to convert MKV to MP4 with ffmpeg

Converting mkv to mp4 with ffmpeg

Essentially just copy the existing video and audio stream as is into a new container, no funny business!

The easiest way to "convert" MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost, it is also a fairly quick process and requires very little CPU power. The main factor is disk read/write speed.

With ffmpeg this can be achieved with -c copy. Older examples may use -vcodec copy -acodec copy which does the same thing.

These examples assume ffmpeg is in your PATH. If not just substitute with the full path to your ffmpeg binary.

Single file conversion example

@ccpu
ccpu / typescriptreact.json
Created November 16, 2020 12:23 — forked from StrongerMyself/typescriptreact.json
vs-code tsx snippets
{
"tsx-test-filename": {
"prefix": "tsx-test-filename",
"body": [
"${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}",
],
"description": "TSX filename"
},
"tsx": {
/* This uses a modified version of puppeteer-to-istanbul and v8-to-istanbul */
// There are a lot of diffs here but most of it is just prettier changes :(
// https://github.com/istanbuljs/puppeteer-to-istanbul/compare/master...Friss:master
// Mostly just converting it to handle the new async v8-to-istanbul code. Also fetches sourcemaps if availabile.
// https://github.com/istanbuljs/v8-to-istanbul/compare/source-maps...Friss:source-maps
// Tweaks to parse the path out to webpack files that I recreated based on the source maps.
@ccpu
ccpu / languages.json
Created September 18, 2019 08:18 — forked from piraveen/languages.json
List of languages in JSON format. Thx to Phil Teare => http://stackoverflow.com/questions/3217492/list-of-language-codes-in-yaml-or-json
{
"ab":{
"name":"Abkhaz",
"nativeName":"аҧсуа"
},
"aa":{
"name":"Afar",
"nativeName":"Afaraf"
},
"af":{
@ccpu
ccpu / RPi-aria2-with-webui.sh
Created August 26, 2019 11:33 — forked from akaxxi/RPi-aria2-with-webui.sh
Install Aria2 and webui on Raspberry Pi with one simple script.
#!/bin/sh
DOWNLOAD_DIR="${HOME}/MiniDLNA"
CONFIG_DIR="${HOME}/.aria2"
RPC_TOKEN="changeIt"
RPC_PORT="6800"
change_apt_source(){
if [ -f /etc/apt/sources.list ]; then
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: monitoring-influxdb
namespace: kube-system
spec:
replicas: 1
template:
metadata:
labels: