Skip to content

Instantly share code, notes, and snippets.

View csharpforevermore's full-sized avatar
🏠
Working from home

Randle csharpforevermore

🏠
Working from home
View GitHub Profile
@csharpforevermore
csharpforevermore / Ideas.txt
Last active October 11, 2022 12:48
Programming Projects / Coding Golf
* 2D games - Atari
*
Interesting projects
Pure CSS RPG (https://codepen.io/medrupaloscil/pen/arvzBG)
@csharpforevermore
csharpforevermore / commands.txt
Created September 21, 2022 14:22
Encoding mp4 videos using FFMPEG
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
csharpforevermore / JsonConvertExtension.cs
Last active March 29, 2022 21:38
Newtonsoft.Json's JsonConvert TryParse extension method - as per Stack Overflow article https://stackoverflow.com/questions/23906220/deserialize-json-in-a-tryparse-way
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
csharpforevermore / Index.cshtml
Created September 26, 2021 12:52
Example of JavaScript plugin jQuery connecting to MVC ApiController
@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>
<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
csharpforevermore / test_connection.ps1
Created August 30, 2021 14:57
How to test your connection string using Powershell
$conn = New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = "Server=(local);Database=Sample;Integrated Security=True;"
$conn.Open()
$conn.Close()
@csharpforevermore
csharpforevermore / gist:383c91e37d5ad030c9dae7ae1834d878
Created August 30, 2021 14:56
How to test your connection string using Powershell
$conn = New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = "Server=(local)\SQLEXPRESS;Database=SampleDatabase;Integrated Security=True;"
$conn.Open()
$conn.Close()
@csharpforevermore
csharpforevermore / EnterInteger.cs
Created August 28, 2021 15:10
User input for an integer
int X;
String Result = Console.ReadLine();
while(!Int32.TryParse(Result, out X))
{
Console.WriteLine("Not a valid number, try again.");
Result = Console.ReadLine();
}
@csharpforevermore
csharpforevermore / ClassParser.cs
Created July 22, 2021 01:56
Lists out the methods of the class Student
public void GetMethodsUsingReflection()
{
MethodInfo[] methodInfos = typeof(Student).GetMethods();
foreach (MethodInfo methodInfo in methodInfos)
{
Response.Write(Environment.NewLine + methodInfo.Name);
}
}
@csharpforevermore
csharpforevermore / AssertionExamples.cs
Last active June 25, 2021 06:24
Examples of NUnit and Moq assertions
[SetUp]
public void SetUp()
{
_MockRepository = new MockRepository(MockBehavior.Strict);
_MockLogger = _MockRepository.Create<ILogger<TagController>>();
_MockTagManager = _MockRepository.Create<ITagManager>();
_MockApplicationConfigManager = _MockRepository.Create<IApplicationConfigManager>();
}
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);