Skip to content

Instantly share code, notes, and snippets.

View AndrewBarfield's full-sized avatar

Andrew Barfield AndrewBarfield

View GitHub Profile
@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 / 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: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: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: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 / 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 / Web-Worker-Script-for-"Calculating-Pi-in-a-Web-Worker".markdown
Created December 29, 2014 19:50
Web Worker Script for "Calculating Pi in a Web Worker"
@AndrewBarfield
AndrewBarfield / Bootstrap-Image-Video-Gallery-.markdown
Created December 29, 2014 20:02
Bootstrap Image/Video Gallery

HTML5 Web Terminal

A console for the Web written in completely in JavaScript. The console supports Web versions of some Linux commands. This work is based, in part, on earlier work by Eric Bidelman.

A Pen by Andrew Mitchell Barfield on CodePen.

License.

@AndrewBarfield
AndrewBarfield / HTML5-Web-Terminal-Script.markdown
Created December 31, 2014 16:52
HTML5 Web Terminal Script

HTML5 Web Terminal Script

A console for the Web written in completely in JavaScript. The console supports Web versions of some Linux commands. This work is based, in part, on earlier work by Eric Bidelman.

A Pen by Andrew Mitchell Barfield on CodePen.

License.