Skip to content

Instantly share code, notes, and snippets.

View bbarry's full-sized avatar

Bill Barry bbarry

  • Ren Inc
  • Pennsylvania
View GitHub Profile
/*
Implemented pseudocode available at
http://en.wikipedia.org/wiki/Mersenne_twister
as an asm.js module to learn about asm.js
*/
function MersenneTwister(stdlib, foreign, heap) {
"use asm";
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication11 {
/*
output (cpu: i7 920)
Starting Benchmark
Running iteration: 1000/1000
Running 1000000 sub-iterations - Time Taken: 00:00:00.0043953
Running 1000000 sub-iterations - Time Taken: 00:00:00.0037585
Test 1
Average Time: 00:00:00.0043999
Invalid Operations: 750007614 (75.001 %)
@bbarry
bbarry / quicksort.cs
Created April 2, 2015 19:32
quicksort experiments
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
@bbarry
bbarry / gist:710816
Created November 22, 2010 22:11
hits
import MetagenomeDB as mdb
names = ['check1', 'check2', 'check3']
def run():
c = mdb.Collection.find_one({"name": "NL10_1002_vRNA:contigs-strict"})
output=[]
for sequence in c.list_sequences():
if (not "alignments" in sequence):
continue
@bbarry
bbarry / gist:1885328
Created February 22, 2012 14:22
Dnn Additional Tab Settings module
public partial class PageSettings : System.Web.UI.UserControl {
protected override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
if (Page.IsPostBack && PageUtil.IsPageValidated() && Page.IsValid &&
Page.Request.Params.Get(Page.postEventSourceID).Contains("cmdUpdate")) {
//cmdUpdate_click postback event occurred
var Tabs = new TabsController();
Tabs.UpdateTabSetting(TabId, "MyNewSetting", MySetting.Text);
}
@bbarry
bbarry / slidemessage.js
Created July 6, 2012 12:53
code review 13377
//http://codereview.stackexchange.com/questions/13377/jquery-drawer-with-tab
/*
preference: rename jquery instance variables to start with $
*/
$(function () {
var $message = $('#message'),
$tab = $('#tab'),
$droid = $message.find('.droid'),
speed = 300;
@bbarry
bbarry / consoleapp.cs
Last active October 14, 2015 17:06
use reflection emit to create a class with a static and instance member that have the same name
//example emit code borrowed and lightly modified from http://www.c-sharpcorner.com/uploadfile/puranindia/reflection-and-reflection-emit-in-C-Sharp/
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;
namespace ConsoleApplication12 {
// declare the interface
@bbarry
bbarry / Nullabletestprogram.cs
Created November 1, 2015 00:51
`a is int?` compiles
using System;
using NullableInt = System.Nullable<int>;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("null:");
@bbarry
bbarry / Tuples.cs
Last active November 8, 2015 02:37
playing with tuples
namespace JustATest
{
// public struct InheritingTuple(int A, int B) : (int, int)(A, B);
// same: public struct InheritingTuple(int A, int B) : (int A, int B)(A, B);
// same, better?: public struct InheritingTuple(int A, int B) : (int A: A, int B: B);
// compiles as:
// public struct InheritingTuple(int A, int B) : ValueTuple<int, int>(A, B);
// should this be allowed?
// I think no: ValueTuple<T...> structs sealed?
// where would attribute go?