Skip to content

Instantly share code, notes, and snippets.

View AndrewBarfield's full-sized avatar

Andrew Barfield AndrewBarfield

View GitHub Profile
@AndrewBarfield
AndrewBarfield / CacheableJsonStore.js
Last active December 23, 2015 00:29
A cacheable JSON Store using sessionStorage for Ext JS 3.4.x.x
Ext.namespace('COMPANYNAME.data');
COMPANYNAME.data.CacheableJsonStore = Ext.extend(Ext.data.Store, {
storageKeyName: null, // (string) sessionStorage key name
constructor: function (config) {
Ext.data.JsonStore.superclass.constructor.call(this, Ext.apply(config, {
reader: new Ext.data.JsonReader(config)
@AndrewBarfield
AndrewBarfield / gist:2567393
Created May 1, 2012 11:12
C#: System.Reflection.Assembly: Getting the executing assembly's name
public static class ProductInfo
{
public static string GetName()
{
string name = "";
Assembly assembly = null;
try
{
assembly = System.Reflection.Assembly.GetExecutingAssembly();
@AndrewBarfield
AndrewBarfield / gist:2557544
Created April 30, 2012 11:39
C#: Automating MS Excel to create a new Workbook and fill it with data
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Interop.Excel;
using System.Runtime.InteropServices;
namespace ExcelTest
{
class Program
@AndrewBarfield
AndrewBarfield / gist:2557343
Created April 30, 2012 10:54
C#: Converting an image to Base64 / Data URI scheme
private void B64Encode()
{
Image a = new Bitmap( @".../path/to/image.png" );
using ( MemoryStream ms = new MemoryStream() )
{
// Convert Image to byte[]
a.Save( ms, a.RawFormat );
byte[] imageBytes = ms.ToArray();
@AndrewBarfield
AndrewBarfield / gist:2557331
Created April 30, 2012 10:49
C#: Windows Forms: Using a BackgroundWorker with a progress bar
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
@AndrewBarfield
AndrewBarfield / gist:2557312
Created April 30, 2012 10:45
C#: Calculating prime numbers using the Standard (Naive) Method
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StandardMethod
{
class Program
{
@AndrewBarfield
AndrewBarfield / Output.txt
Created April 30, 2012 10:27
C#: Calculate the Exponential Function exp(x) using Taylor Expansion
CSC 340 Scientific Computing
Calculate exp(3.7) using Taylor's Expansion
Andrew M. Barfield
Thursday, January 15, 2009
1:56:36 PM
Answer calculated in 29 iterations.
exp(3.7) = 40.447
@AndrewBarfield
AndrewBarfield / Output.txt
Created April 30, 2012 10:18
C#: Calculating machine epsilon for a Float and Double
CSC 340 Scientific Computing
Machine Epsilon Homework
Andrew M. Barfield
Wednesday, January 14, 2009
3:15:29 PM
Float:
01) 0.5
02) 0.25
@AndrewBarfield
AndrewBarfield / gist:2556928
Created April 30, 2012 09:51
C#: Working with the Stack class
using System;
using System.Collections;
namespace StackExample {
class Program {
static void Main(string[] args) {
// Creates and initializes a new stack
Stack stackColl = new Stack();
@AndrewBarfield
AndrewBarfield / gist:2556924
Created April 30, 2012 09:49
C#: How to perform Numerical Integration
using System;
namespace NumericalIntegration {
class Program {
static void Main(string[] args) {
int iterations = 100000;
double x, start, end, dist, sum = 0, sumT = 0;
Console.Write( "Input range start: " );
start = double.Parse( Console.ReadLine() );