This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#how to make a silly image like thing for use in datagrids like DevExpress. Friday snap special | |
from PIL import Image | |
image = Image.open('C:\Downloadstmp\LeftAktarian75 - Copy.bmp').convert('L') # Convert to grayscale | |
image = image.resize((64, 64)) | |
# Threshold value to distinguish between '1' and ' ' | |
threshold = 128 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///In an effort to get some kind of intuition around what an octonion even is - I'm not a mathematician! - I asked GPT4 for help. | |
///During this conversation it gave me the outline of an octonion in C#. Running with this, I prompted for the main operations and built | |
///this up, sparked by the fact there wasn't an implementation out there (according to GPT4 - which probably is not true). | |
///Still, posting this up for my future reference as I'm interested in the notion of using such in a neural network | |
///Though I'm more likely to review abstracts of others who have actually code such CNNs already! :) | |
public struct Octonion | |
{ | |
public double w, x, y, z, u, v, t, s; // the eight components of the octonion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
# Define the UserExamStore class | |
class UserExamStore: | |
def __init__(self, id, name, date, exams=None, languages=None, formats=None): | |
self.id = id | |
self.name = name | |
self.date = date | |
self.exams = exams if exams is not None else set() | |
self.languages = languages if languages is not None else set() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
# Define the UserExamStore class | |
class UserExamStore: | |
def __init__(self, id, name, date): | |
self.id = id | |
self.name = name | |
self.date = date | |
self.exams = [] | |
self.languages = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This code generates a sequence of random numbers and applies a transformation to each number, | |
such that the probability of the number being transformed to 1 increases as the sequence progresses. | |
This is done using a Markov chain with a transition matrix that depends on the sequence index. | |
```csharp | |
// Install TensorFlow.NET NuGet package | |
#load "nuget: TensorFlow.NET, 0.11.0" | |
using System; | |
using System.Collections.Generic; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''This code just saved 6700 mergecodes across to the db in a few second compared to long minutes via EF :) | |
Public Shared Sub SaveMany(Items As List(Of BranchContact)) | |
If Items Is Nothing Then Return | |
Using db As New LogIQEntities | |
Dim chunkedItems = ChunkData(Items, 500) 'I've not tested to see the upper/lower bounds of benefits/deficits on this figure :P | |
For Each chunkedList In chunkedItems | |
Dim Query = New StringBuilder | |
For Each i In chunkedList | |
Query.Append($"update BranchContacts set Mergecodes = '{i.Mergecodes}' where Emailid = {i.Emailid} and Branch = '{i.Branch}';") | |
Next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ICrud //Used to allow the texttemplate in the Model Layer to work. Needs a revisit. | |
{ | |
int Id { get; set; } | |
} | |
public abstract class BaseModel : INotifyPropertyChanged | |
{ | |
protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null) | |
{ | |
if (Equals(storage, value)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#@ include file="EF.Reverse.POCO.Core.ttinclude" #> | |
<# | |
// v2.35.0 | |
// Please make changes to the settings below. | |
// All you have to do is save this file, and the output file(s) is/are generated. Compiling does not regenerate the file(s). | |
// A course for this generator is available on Pluralsight at https://www.pluralsight.com/courses/code-first-entity-framework-legacy-databases | |
// Main settings ********************************************************************************************************************** | |
Settings.ConnectionStringName = "RedDiamondConnectionString"; // Searches for this connection string in config files listed below in the ConfigFilenameSearchOrder setting | |
// ConnectionStringName is the only required setting. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#@ include file="EF.Reverse.POCO.Core.ttinclude" #> | |
<# | |
//*** Line 402 - 407 Marked //*** for the Private field code mods. Also included are the common static methods we add (379 - 385) | |
//*** Please note the Interface ICrud is merely for the static methods ( is just int Id { get; set; } ) | |
//*** Appropriate Baseclass and (if wanted) Generic Save is in another gist. | |
// v2.35.0 | |
// Please make changes to the settings below. | |
// All you have to do is save this file, and the output file(s) is/are generated. Compiling does not regenerate the file(s). | |
// A course for this generator is available on Pluralsight at https://www.pluralsight.com/courses/code-first-entity-framework-legacy-databases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For the model layer I use Automapper (for use in MVC Projects) so this file will need you to have successfully compiled a datalayer DLL and make it available. | |
It will add attributes that it finds from the Datalayer file (these were inserted via the custom Datalayer T4 file). | |
I had plenty of fun with reflection to make this work, but it does make adding new tables quite trivial! | |
<#@ template debug="true" hostspecific="true" language="C#"#> | |
<#@ output extension=".cs"#> | |
<#@ assembly name="System.Core"#> |
NewerOlder