Skip to content

Instantly share code, notes, and snippets.


Wes Higbee g0t4

View GitHub Profile
g0t4 / gist:4271057
Created Dec 12, 2012
Mongodb editing file information with c# driver
View gist:4271057
//Easier to just pull the file collection and edit the files documents, just be careful, example:
public void SaveMetadata(string id, MetadataJson metadata)
var gridFs = FilesContext.GetGridFs();
var files = gridFs.Database.GetCollection(gridFs.Settings.FilesCollectionName);
var file = files.FindOneById(new BsonObjectId(id));
var metadataDocument = file["metadata"].AsBsonDocument;
metadataDocument.Set("comment", metadata.comment ?? string.Empty);
g0t4 / gist:4271829
Created Dec 12, 2012
Why manually replace crap over and over, why not write code to do it if it saves time :)
View gist:4271829
var path = @"..\..\..\View.spark";
var code = File.ReadAllLines(path);
for (int lineNumber = 0; lineNumber < code.Length; lineNumber++)
var line = code[lineNumber];
var classControlLabel = "class=\"control-label\"";
g0t4 / ko.elastic.binder.js
Created Apr 15, 2013
knockoutjs binder for jquery elastic plugin
View ko.elastic.binder.js
require(['knockout', 'jquery.elastic'], function (ko) {
ko.bindingHandlers.elastic = {
// todo probably should make this destroy when the element is destroyed.
update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
g0t4 / ko.typeahead.binder.js
Created Apr 15, 2013
knockoutjs binder for bootstrap typeahead
View ko.typeahead.binder.js
// FYI YMMV this was just a first pass and I know it has some issues at times that I need to workout
// usage
// source: a function that takes the query (text entered by user) and a callback (process), if source is synchronous it should return the results and ignore the callback, otherwise it should return nothing and use the callback to return the results
// selectedId: the model property to bind the id to
// value: the model property to bind the text value of the selection to
// data-bind="typeahead: { source: App.view.targets.typeAheadSource, selectedId: target._id }, value:"
// note I also use this little helper class to wrap up all this functionality
// it takes a url to query the results for asynchrnous data sets and has an init method to call to query the data initially.
View Reactive Testing With AsyncAwait
public async Task WriteToFile_StreamsChanged()
using (var watcher = new ObservableFileSystemWatcher(c => { c.Path = TempPath; }))
var firstChanged = watcher.Changed.FirstAsync().ToTask();
File.WriteAllText(Path.Combine(TempPath, "Changed.Txt"), "foo");
g0t4 /
Last active Jan 18, 2017
docker cli usefulness -> converting ascii art into nice images - > nice workflow for creating visuals and flexible outputs with asciidoctor in a container
# this docker image comes preloaded with many extensions!
# docs for asciidoctor-diagram extension
# volume mount for current working directory, to ready table.adoc and write resultant output file
# function to hide away the docker run and volume plumbing, treat like it is installed locally :)
asciidoctor() { docker run --rm -v $(pwd):/documents asciidoctor/docker-asciidoctor asciidoctor "$@" ; }
g0t4 /
Last active May 18, 2017
Docker Swarm Mode Getting Started Workshop

Shortened URL to access this gist:

All scripts work in bash and should work in powershell except as noted

clone this gist

git clone local-folder
g0t4 /
Last active Aug 15, 2018
Getting Started with .NET Core: for Windows Developers
g0t4 / docker-compose.yml
Created May 18, 2016
TeamCity Docker Compose setup
View docker-compose.yml
version: '2'
image: sjoerdmulder/teamcity
- 8111:8111
image: sjoerdmulder/teamcity-agent