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 / NoPostback.cs
Created June 27, 2018 15:30
MVC Model Validation - have a property that doesn't get posted back. Sourced
[Editable(false)]
public string MyProperty {get;set;}
// OR
// If you want a readonly public property of a class use:
public string MyProperty {get; private set;}
@csharpforevermore
csharpforevermore / ShowValidationExceptions.cs
Created June 27, 2018 10:06
MVC.NET - list out all the validation errors for a submitted form
public void Main(){
#if (!RELEASE && !PRODUCTION)
// this code is only called if we are compiling on a non-live configuration
GetLogErrors();
#endif
}
/// <summary>
/// Debug method to show what validation errors exist
@csharpforevermore
csharpforevermore / click-every-film-not-in-watchlist.js
Created June 23, 2018 22:20
IMDB - adds every film on page that is not in a watchlist to your current watchlist.
$('.wl-ribbon.poster.not-inWL').each(function(e){this.click(function(){console.log('Clicked!')})});
@csharpforevermore
csharpforevermore / pdconcat.py
Created June 16, 2018 15:07 — forked from phobson/pdconcat.py
funky pandas concat
import numpy
import pandas
numpy.random.seed(0)
index1 = pandas.MultiIndex.from_product(
[['A'], ['b'], ['one', 'two']],
names=['City', 'Street', 'House']
)
index2 = pandas.MultiIndex.from_product(
@csharpforevermore
csharpforevermore / join.py
Created June 16, 2018 15:03 — forked from finswimmer/join.py
Join multiple pandas dataframes
import glob
import sys
import pandas
def read_filenames(names):
for arg in names:
if "*" in arg:
for file in glob.glob(arg):
yield file
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@csharpforevermore
csharpforevermore / linspace.py3
Created June 16, 2018 14:22
Python 3 - linspace function example
# np.linspace(start, stop, num)
np.linspace(2.0, 3.0, num=5)
array([ 2.0, 2.25, 2.5, 2.75, 3.0])
@csharpforevermore
csharpforevermore / LambdaExample.py
Created June 16, 2018 14:10
Lambda functions in Python
double = lambda x: x * 2
print(double(5))
# output: 10
@csharpforevermore
csharpforevermore / ConsoleWriteLineAtPosition.cs
Created June 12, 2018 14:49
C# - print string of text at a specific position on the screen. Research for the Rogue-style game.
Console.SetCursorPosition(20, 0);
Console.WriteLine("Hello");
Console.SetCursorPosition(20, 2);
Console.WriteLine("World");
Console.ReadLine();
@csharpforevermore
csharpforevermore / whatAppLocksThisFolder.ps1
Created June 2, 2018 13:01
Is this folder in use and which application is locking the folder for me?
IF((Test-Path -Path $FileOrFolderPath) -eq $false) {
Write-Warning "File or directory does not exist."
}
Else {
$LockingProcess = CMD /C "openfiles /query /fo table | find /I ""$FileOrFolderPath"""
Write-Host $LockingProcess
}