Skip to content

Instantly share code, notes, and snippets.

View ChrisMoney's full-sized avatar

Chris Weathers ChrisMoney

  • Onevested
  • St. Louis, MO
View GitHub Profile
@ChrisMoney
ChrisMoney / unit-test.cs
Created July 7, 2016 15:02
Unit Test using MS Test
//*************************
// Use Unit Test Generator to click on any method to create a Test Method stub
// *************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CardDispenser;
@ChrisMoney
ChrisMoney / command-bytes.c#
Created June 29, 2016 14:29
C# - Read Command Bytes
void IMD1000A.Process(Command cmd, System.IO.Ports.SerialPort _serialPort)
{
try
{
if (!_serialPort.IsOpen)
_serialPort.Open();
LastError = CommandErrorCode.OK;
byte[] cmdPacket = cmd.CommandPacket;
@ChrisMoney
ChrisMoney / validation.vb
Last active May 25, 2016 19:22
ASP.NET Validation on Markup Side
<%@ Page Language="vb" %>
<script runat=server>
public sub CheckID(source as Object, args as ServerValidateEventArgs)
args.IsValid = args.Value.substring(0, 1).tolower() <> "a"
end sub
public sub OnSubmit(source as Object, e as EventArgs)
if Page.IsValid then
' Now we can perform our transaction.
@ChrisMoney
ChrisMoney / entityFramework.cs
Last active May 25, 2016 17:37
Entity Framework using Collection or ADO.NET Datatable (Code First) Without MVC
public class Product {
private string modelNumber;
public string ModelNumber {
get { return modelNumber; }
set { modelNumber = value; }
}
private string modelName;
public string ModelNumber {
@ChrisMoney
ChrisMoney / in_memory_table.sql
Created April 25, 2016 13:34
SQL - In Memory Table
CREATE DATABASE imoltp
GO
--------------------------------------
-- create database with a memory-optimized filegroup and a container.
ALTER DATABASE imoltp ADD FILEGROUP imoltp_mod CONTAINS MEMORY_OPTIMIZED_DATA
ALTER DATABASE imoltp ADD FILE (name='imoltp_mod1', filename='c:\data\imoltp_mod1') TO FILEGROUP imoltp_mod
ALTER DATABASE imoltp SET MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT=ON
GO
@ChrisMoney
ChrisMoney / closure.js
Created April 25, 2016 13:29
Javascript - Closure
var add = (function () {
var counter = 0;
return function () {return counter += 1;}
})();
add();
add();
add();
// the counter is now 3
@ChrisMoney
ChrisMoney / extendjs.js
Created April 6, 2016 19:02
ExtendJS code
<head>
<script src="http://cdn.extendjs.org/0.2.3/extend.min.js"></script>
...
</head>
//Create MyClass by extending Class.
var MyClass = Class.extend(function(){
//Classes can have constructors
this.constructor = function(){
@ChrisMoney
ChrisMoney / delegate.cs
Last active September 30, 2015 22:22
C# - Delegate, similar to an anonymous function
//Define the delegate
public delegate int Calculate (int value1, int value2);
//a method, that will be assigned to delegate objects having the EXACT signature of the delegate
public int add(int value1, int value2)
{
return value1 + value2;
}
//a method, that will be assigned to delegate objects having the EXACT signature of the delegate
public int sub( int value1, int value2)
@ChrisMoney
ChrisMoney / 3-dimensional-list.cs
Last active April 21, 2016 15:12
3 (Three) Dimensional List - CS
// Another simple way would be to create a class which has a constructor to hold the three strings
public class PairedValues
{
// These are just simple ways of creating a getter and setter in c#
public string value1 { get; set; }
public string value2 { get; set; }
public string value3 { get; set; }
// A constructor which sets all your getters and setters
public PairedValues(string Value1, string Value2, string Value3)
@ChrisMoney
ChrisMoney / hash.cs
Last active September 21, 2015 16:13
Hash - C#
using System;
using System.Collections;
class Program
{
static Hashtable GetHashtable()
{
Hashtable hashtable = new Hashtable();
hashtable.Add(300, "Carrot");