I am developing a Bitcoin exchange trading engine. It’s written in C# and ASP.Net MVC4/Razor. The UI layer is service-based using knockout.js and jqGrid to bind to JSON web services. Order processing done in a service process.
Is anyone interested learning more about the design? Update: OK! Graphics below updated and first detail post added.
I think it will take at least 10 posts to document this project:
This post has has the full scoop on the process of migrating blogs from Community Server to WordPress, except for this bit: “ultimately, I just wrote a simple regular expression to reformat all the categories so that their names were in the ID attribute.” Instead of regex, I wrote a a C# script using LINQ to XML:
conststring source =@"D:export.xml";string source =@"D:export.xml";var doc = XDocument.Load(source);var categories =new Dictionary();foreach(var cat in doc.Elements().First().Elements().Descendants().Where(cat => cat.Name.LocalName=="tag")){if(cat.Attribute("id")!=null){
categories.Add(Convert.ToInt32(cat.Attribute("id").Value), cat.Elements().First().Value);}else{int refId;if(int.TryParse(cat.Attribute("ref").Value, out refId))// in case it was already run{
cat.Attribute("ref").Value= categories[refId];}}}
doc.Save(source);
const string source = @"D:export.xml"; string source = @"D:export.xml"; var doc = XDocument.Load(source); var categories = new Dictionary(); foreach (var cat in doc.Elements().First().Elements().Descendants().Where(cat => cat.Name.LocalName == "tag")) { if (cat.Attribute("id") != null) { categories.Add(Convert.ToInt32(cat.Attribute("id").Value), cat.Elements().First().Value); } else { int refId; if (int.TryParse(cat.Attribute("ref").Value, out refId)) // in case it was already run { cat.Attribute("ref").Value = categories[refId]; } } } doc.Save(source);
if %errorlevel% neq 0 exit /b %errorlevel%
REM BUILD OK, GO TO NEXT STEP
if %errorlevel% neq 0 exit /b %errorlevel% REM BUILD OK, GO TO NEXT STEP
Copying build output:
xcopy F:webBetaMisesWebbin* F:webMisesbin /Y
REM /Y don’t prompt for overwrite
REM /S recursive
REM /Z restartable mode
REM /D only copy files newer than those at destination
REM More: http://www.computerhope.com/xcopyhlp.htm
xcopy F:webBetaMisesWebbin* F:webMisesbin /Y REM /Y don’t prompt for overwrite REM /S recursive REM /Z restartable mode REM /D only copy files newer than those at destination REM More: http://www.computerhope.com/xcopyhlp.htm
Suppose you are rendering templated content. Sometimes you want to reference partial views (or actions) in your templates and have them render with attributes provided by your template. One option is to use a Razor templating engine. But I just needed to render partial views based on a custom tag format, so I came up with my own solution:
/// <summary>/// Render parameterized tags as a partial view in MVC3 templates/// Supports tags such as /// </summary>/// The helper./// The content./// privatestaticstring RenderPartialViewTagsInTemplate(HtmlHelper helper, string content){var controls =new Dictionary();
MatchCollection matches = Regex.Matches(content, @"<view: (?S+)(s+(?[^=s]+)=""?(?[^""s]+)""?)*?s*/>", RegexOptions.ExplicitCapture);foreach(Match tag in matches){string viewName = tag.Groups["name"].Value;var routeValues =new RouteValueDictionary();for(int i =0; i { content = content.Replace(c.Key, c.Value);});return content;}
/// <summary> /// Render parameterized tags as a partial view in MVC3 templates /// Supports tags such as /// </summary> /// The helper. /// The content. /// private static string RenderPartialViewTagsInTemplate(HtmlHelper helper, string content) { var controls = new Dictionary(); MatchCollection matches = Regex.Matches(content, @"<view: (?S+)(s+(?[^=s]+)=""?(?[^""s]+)""?)*?s*/>", RegexOptions.ExplicitCapture); foreach (Match tag in matches) { string viewName = tag.Groups["name"].Value; var routeValues = new RouteValueDictionary(); for (int i = 0; i { content = content.Replace(c.Key, c.Value); }); return content; }
column-count was proposed in January 2001, candidate in December 2009. It’s supported in WebKit and Mozilla via extensions and Opera directly, but it’s not in IE9. Y U no support columns IE9? That’s OK, we can work around this with columnizer:
if($.browser.msie&& $.browser.version<10){// am I a hopeless romantic for assuming that IE10 will support it?
$('.multicolumn').columnize({
width:600,
columns:3});}
if ($.browser.msie && $.browser.version < 10) { // am I a hopeless romantic for assuming that IE10 will support it? $('.multicolumn').columnize({ width: 600, columns: 3 }); }
/* Support for Webkit, Mozilla, Opera */
div#multicolumn,.multicolumn{
-moz-column-count:3;
-moz-column-gap:20px;
-webkit-column-count:3;
-webkit-column-gap:20px;column-count:3;column-gap:20px;width:600px;}
/* Support for Webkit, Mozilla, Opera */ div#multicolumn, .multicolumn { -moz-column-count: 3; -moz-column-gap: 20px; -webkit-column-count: 3; -webkit-column-gap: 20px; column-count: 3; column-gap: 20px; width:600px; }
#region don't process the same address twiceif(newEmail.EmailHash==0) newEmail.EmailHash= newEmail.Email.GetSHA1Hash();if(emailsToAdd.Contains(newEmail.EmailHash)){returnfalse;}
emailsToAdd.Add(newEmail.EmailHash);#endregion
#region don't process the same address twice if (newEmail.EmailHash == 0) newEmail.EmailHash = newEmail.Email.GetSHA1Hash(); if (emailsToAdd.Contains(newEmail.EmailHash)) { return false; } emailsToAdd.Add(newEmail.EmailHash); #endregion
For this implementation, I am returning the hash as a 32-bit integer because I am using it for caching, not security. It’s a little faster to use an int32 index than the default 160 hex digest. If avoiding collisions is important (only 4,294,967,295 values in an int32), remove the BitConverter.ToInt32 call and return a string.
It’s for C# 4.0 because it’s an extension method.
Here is the hash class. Call with STRING.GetSHA1Hash().
I keep having to search for these URLs, so here’s a Note To Self:
VSDoc files are a feature of Visual Studio introduced for VS 2008 that provides IntelliSense for JavaScript. You can include it in your project, or you can reference the latest CDN copy of whatever library you use.
When implementing an auto-complete control on your site, you may want to cache the results to keep the database queries to a minimum. Here’s a quick way to do that: