Skip to content

Instantly share code, notes, and snippets.

View klumsy's full-sized avatar

Karl Prosser klumsy

  • Pushpay Inc
  • Seattle , WA
View GitHub Profile
@klumsy
klumsy / Batch2.cs
Created August 5, 2013 20:00
my previous batch function wasn't always in parallel. This one seems to work properly and foces the parallelism plus gives you an option on the parallelism settings.
public static IEnumerable<T1> Batch2<T, T1>(
this IEnumerable<T> list,
int batchSize,
int maxParallelism,
Func<IEnumerable<T>, IEnumerable<T1>> action)
{
int i = 0;
return (
from item in list
group item by (int)i++ / batchSize
@klumsy
klumsy / batchextmethod.cs
Created June 19, 2013 00:12
C# extension method that can take an action that takes in a list.. so f(x) where x is a list, and break it up into batches of a certain size and do that action against each batch, either in serial or parallel.
public static IEnumerable<T1> Batch<T,T1>(
this IEnumerable<T> list,
int batchSize,
Func<IEnumerable<T>, IEnumerable<T1>> action,
bool processInParallel = false)
{
int i = 0;
var grpqry = from item in list
group item by (int)i++ / batchSize
into part
@klumsy
klumsy / booksofbible.rb
Created June 11, 2013 02:44
Code i wrote to that the dramatized audio bible (word of promise) i bought and downloaded as MP3 and rename the title to something that can be displayed as a whole on the Iphone , and also generate a CSV file of chapters and minutes for my curiousity.
require "rubygems"
require "mp3info"
require "csv"
chapterarray = []
#Dir.glob("/Users/klumsy/Downloads/bible/01_Genesis/*.mp3") do |f|
Dir.glob("/Users/klumsy/Downloads/bible/**/*.mp3") do |f|
Mp3Info.open(f) do |mp3info|
title = mp3info.tag.title
puts title