๐
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Setup dependencies for nuget packages" | |
task :dep do | |
package_folder = File.expand_path('src\\packages') | |
packages = FileList["**/packages.config"].map{|f| File.expand_path(f)} | |
packages.each do |file| | |
sh %Q{nuget install #{file} /OutputDirectory #{package_folder}} | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sometimes it's easier to make assumptions about performance as a trade off for simplified code, but why not make it easy to notify us when that assumption is violated? Next step might be StopAndNotify | |
// Usage | |
using (new NotifyIfTakesMoreThan(TimeSpan.FromMinutes(5), "XYZ Import - checking all data instead of more complex code to optimize it")) | |
{ | |
//operation | |
} | |
// Implementation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Approved | |
{ | |
public virtual Guid Id { get; set; } | |
public virtual IEnumerable<Guid> EntryIds { get; set; } | |
} | |
// Mapping, Table specifies the table name to use, element specifies the column the Guid is stored in, KeyColumn specifies the foreign key in the table to link back to the parent Approved item | |
HasMany(x => x.EntryIds) | |
.Table("ApprovedEntryIds") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Approved | |
{ | |
public virtual Guid Id { get; set; } | |
public virtual IEnumerable<Entry> Entries { get; set; } | |
} | |
public class Entry | |
{ | |
public virtual Guid Id { get; set; } | |
public virtual Guid Description { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I run across this type of code often (note ASP.Net MVC) | |
[HttpPost] | |
public string Delete(ObjectId id) | |
{ | |
var record = _Database.Get<Record>(id); | |
if (record == null) | |
{ | |
return "No matching record!"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void METHOD_SCENARIO_EXPECTATION() | |
{ | |
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\""; | |
if(line.Contains(classControlLabel)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | |
$(element).elastic(); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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: target.name" | |
// 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
[Timeout(2000)] | |
public async Task WriteToFile_StreamsChanged() | |
{ | |
using (var watcher = new ObservableFileSystemWatcher(c => { c.Path = TempPath; })) | |
{ | |
var firstChanged = watcher.Changed.FirstAsync().ToTask(); | |
watcher.Start(); | |
File.WriteAllText(Path.Combine(TempPath, "Changed.Txt"), "foo"); |
OlderNewer