Skip to content

Instantly share code, notes, and snippets.

View DominicFinn's full-sized avatar
💭
Whirring away

Dominic Finn DominicFinn

💭
Whirring away
View GitHub Profile
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
@DominicFinn
DominicFinn / thisworkbook.vb
Last active January 4, 2016 00:39
Bit of code to stop a worksheet from saving until the cells provided have something in them. // code is VBA :-/
Dim msg As String
Dim cancel As Boolean
Private Sub Workbook_BeforeSave(ByVal SaveAsUi As Boolean, cancel As Boolean)
CheckAndMark "B42", "Cell B42 must be filled in with a NAME before saving."
CheckAndMark "b51", "Cell B51 needs a random number"
If cancel Then
MsgBox msg
@DominicFinn
DominicFinn / HappyController.cs
Created January 20, 2014 17:03
The sad controller is tightly coupled to a specific implementation of the management class. We need to be coding against interfaces. This grants us at least two major wins: 1. We can refactor / improve the management class without worrying about the controller, we just need to ensure the interface is still satisfied. 2. We can test different par…
public sealed class HappyController : Controller {
private IManagement management;
public HappyController(IManagement management) {
this.management = management
}
[HttpGet]
public ViewResult LooselyCoupleThings() {
@DominicFinn
DominicFinn / XOR-Demo.cs
Created December 20, 2013 23:53
A little XOR calculation demo created as I am working through the Pluralsight course http://pluralsight.com/training/Courses/Description/introduction-to-machine-learning-encog This example relies on the Encog libs which are available on Nuget.
using Encog.Engine.Network.Activation;
using Encog.ML.Data.Basic;
using Encog.Neural.Networks;
using Encog.Neural.Networks.Layers;
using Encog.Neural.Networks.Training.Propagation.Resilient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@DominicFinn
DominicFinn / JPanelEvents.java
Created November 1, 2013 14:26
An Example of hooking up events for a JPanel
package examples;
import javax.swing.JPanel;
public class MyWindow extends javax.swing.JFrame {
//The static main is the entrance to the program
public static void main(String args[]) {
System.out.println("loading");
bookings.bookingPresenter = function($div, eventsBus) {
// Handle page events and user interaction here. Delegate the functionality on the bus.
// query the Dom on the smallest element you can, i.e. never do $('').find for everything
var $form = $div.find('#orderForm');
$div.find('.orderButton').click(function(e) {
e.preventDefault()
@DominicFinn
DominicFinn / DbGateway.cs
Created September 11, 2013 15:46
General idea of ado.net dataaccess
namespace Domain.Repositories.Database
{
public sealed class DbGateway : IDbGateway
{
public DataSet DataSetQueryFromStoredProcedure(string storedprocedure, Dictionary<string, object> paramaters)
{
var dataSet = new DataSet();
var connectionString = ConfigurationManager.ConnectionStrings.GetConnectionString("Connection");
using (var sqlConnection = new SqlConnection(connectionString))
@DominicFinn
DominicFinn / code.cs
Created September 4, 2013 11:58
Bit of code for John
protected void CreateReportButton_Click(object sender, EventArgs e)
{
DateTime startDate, endDate;
if (FormValid(out startDate, out endDate))
{
this.GenerateReport(startDate, endDate);
}
}
@DominicFinn
DominicFinn / ClientController.cs
Last active December 21, 2015 21:29
Example file
public class ClientsController : BaseApiController
{
private readonly IClientManagement clientManagement;
public ClientsController(IClientManagement clientManagement)
{
this.clientManagement = clientManagement;
}
public IEnumerable<ClientViewModel> Get()
$.getJSON("/Lookups/SomeLookupAPIEndpoint", "", function(data) {
//do something with data....
//if data is a collection..
$(data).each(function() {
// ....
})
});