Skip to content

Instantly share code, notes, and snippets.


Randle csharpforevermore

View GitHub Profile
csharpforevermore / Ideas.txt
Last active Oct 11, 2022
Programming Projects / Coding Golf
View Ideas.txt
* 2D games - Atari
Interesting projects
Pure CSS RPG (
csharpforevermore / commands.txt
Created Sep 21, 2022
Encoding mp4 videos using FFMPEG
View commands.txt
FFMPEG is used to reduce size of videos and compress
To reduce size
• ffmpeg -i .\inputvideo.mp4 -vcodec libx265 -crf 28 outputvideo.mp4
To compress audio
• ffmpeg -i .\2.mp4 -filter_complex "[0]dynaudnorm[a]" -map 0:v -map "[a]" -map 0:a -c:v copy -c:a:1 copy 3.mp4
csharpforevermore / JsonConvertExtension.cs
Last active Mar 29, 2022
Newtonsoft.Json's JsonConvert TryParse extension method - as per Stack Overflow article
View JsonConvertExtension.cs
using Newtonsoft.Json;
public static class JsonConvertHelper
public static bool TryParseJson<T>(this string @this, out T result)
bool success = true;
var settings = new JsonSerializerSettings
Error = (sender, args) => { success = false; args.ErrorContext.Handled = true; },
csharpforevermore / Index.cshtml
Created Sep 26, 2021
Example of JavaScript plugin jQuery connecting to MVC ApiController
View Index.cshtml
@using MyWebAPjQuery.WebAPI.Controllers
<div class="jumbotron">
<h1>ASP.NET jQuery to Web API AJAX call</h1>
<p class="lead">This sentence has a class that denotes it as a lead phrase.</p>
<div class="row">
<div class="col-md-4">
<h2>My MVC API AJAX Call</h2>
<form id="form1">
Name :- <input type="text" name="name" id="name" value="Chris" />
csharpforevermore / test_connection.ps1
Created Aug 30, 2021
How to test your connection string using Powershell
View test_connection.ps1
$conn = New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = "Server=(local);Database=Sample;Integrated Security=True;"
csharpforevermore / gist:383c91e37d5ad030c9dae7ae1834d878
Created Aug 30, 2021
How to test your connection string using Powershell
View gist:383c91e37d5ad030c9dae7ae1834d878
$conn = New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = "Server=(local)\SQLEXPRESS;Database=SampleDatabase;Integrated Security=True;"
csharpforevermore / EnterInteger.cs
Created Aug 28, 2021
User input for an integer
View EnterInteger.cs
int X;
String Result = Console.ReadLine();
while(!Int32.TryParse(Result, out X))
Console.WriteLine("Not a valid number, try again.");
Result = Console.ReadLine();
csharpforevermore / ClassParser.cs
Created Jul 22, 2021
Lists out the methods of the class Student
View ClassParser.cs
public void GetMethodsUsingReflection()
MethodInfo[] methodInfos = typeof(Student).GetMethods();
foreach (MethodInfo methodInfo in methodInfos)
Response.Write(Environment.NewLine + methodInfo.Name);
csharpforevermore / AssertionExamples.cs
Last active Jun 25, 2021
Examples of NUnit and Moq assertions
View AssertionExamples.cs
public void SetUp()
_MockRepository = new MockRepository(MockBehavior.Strict);
_MockLogger = _MockRepository.Create<ILogger<TagController>>();
_MockTagManager = _MockRepository.Create<ITagManager>();
_MockApplicationConfigManager = _MockRepository.Create<IApplicationConfigManager>();
View changeindex.js
function detach(element) {
return element.parentElement.removeChild(element);
function move(src, dest, isBefore) {
dest.insertAdjacentElement(isBefore ? 'beforebegin' : 'afterend', detach(src));
function children(element, selector) {
return element.querySelectorAll(selector);