Skip to content

Instantly share code, notes, and snippets.

View bardware's full-sized avatar

Bernhard Döbler bardware

View GitHub Profile
Ember.Handlebars.helper('filesize', function(value) {
if (typeof value === 'undefined') {
return null;
}
var i,
filesize,
units = ['B', 'KB', 'MB', 'GB', 'TB'];
for (i = 0; i < units.length; i++) {
if (value < 1024) {
filesize = Math.floor(value) + units[i];
@bardware
bardware / SortableBindingList.vb
Created March 18, 2016 23:33 — forked from wcabus/SortableBindingList.vb
SortableBindingList is a list that supports sorting its items and filtering them.
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Reflection
Imports System.Linq
Imports System.Linq.Dynamic
''' <summary>
''' SortableBindingList is a list that supports sorting its items and filtering them.
''' When binding a <see cref="System.Collections.Generic.List(Of T)"/> to a <see cref="System.Windows.Forms.DataGridView"/>, you can not sort by clicking on the columns
''' or filter the list. With this list, you can.
@bardware
bardware / .eslintrc
Created June 4, 2016 22:50 — forked from cletusw/.eslintrc
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
@bardware
bardware / EncodeRFC3986.cfm
Last active July 20, 2018 15:41 — forked from Leigh-/EncodeRFC3986.cfm
Comparison of EncodeForURL, URLEncodedFormat and EncodeRFC3986 (UDF)
<cfscript>
/**
* URI encoding per RFC 3986, which has treats the following as unreserved: ALPHA / DIGIT / "-" / "." / "_" / "~"
* @text Text to encode
* @returns URI encoded text
*/
public function encodeRFC3986(required string text) {
// Requires CF10+
Local.encoded = encodeForURL(arguments.text);
// Reverse encoding of tilde "~"
@bardware
bardware / gotcha.md
Created December 28, 2023 22:38 — forked from sheastrickland/gotcha.md
BlockingCollection with Parallel.ForEach with a Partitioner

Lesson Learnt, Streaming Producer / Consumer issue using:

BlockingCollection<T> and Parallel.ForEach(_blockingCollection.GetConsumingEnumerable

Beware default Partitioner algo, which is chunking and buffering.

The GetConsumingPartitioner heading covers it, and also the first comment from Stephen Toub totally nails it. We implemented similar to what commenter Hernan pointed out. Stephen Toub Blog

My absolute saviour, NoBuffering in: