Conversion of numerics to/from database Real

I am writing data from MMA (, Win 10 home 64 bit) to a Microsoft SQL Server/T-SQL database and am having considerable trouble controlling precision.

The target column in the database has data type real (as shown in SQLServer Management Studio) and reading back in MMA from SQLColumns[] as e.g.

SQLColumn[{“Data_Smoothed”, “Stats_Mean”}, “DataTypeName” -> “real”, “DataLength” -> 24, “Default” -> Null, “Nullable” -> 1]

I wish to use Real as it is only 4-bytes and has ample range for my purposes. Microsoft datatype documentation says the range of real is – 3.40E + 38 to -1.18E – 38, 0 to 1.18E – 38 to 3.40E + 38 but I cannot work out how to coerce precision suitably on output values to write so that they read back “correctly”.

How can I process numeric values for use in SQLUpdate so that the readback is exactly the value written to within a certain precision?

Conversion comparison between users who navigate from autocomplete vs. submitting from the search form

Recently I came across the way Instagram does their search. Basically they give you results in the autocomplete but disable the ability to actually submit the form and be navigated to your traditional search results page. I found this interesting for the fact with millions of possible users or posts, they are confident the user will find what they’re looking for in no more than a dozen results. Is there any evidence that supports that whether users choose more from autocomplete over navigating to a results page?

Get done your all kinds of stuffs related to data entry, ms office and conversion from pdf to any for $5

I have done data entry jobs like: Data entry, data operation, excel data entry, pdf to word conversion etc similar kinds of work locally without any freelancing platform. I will done the work with the less amount of money then the other seller in the given time with 100% quality assurance and that’s my promise just because I want to provide and want a chance to show my service to my clients. Please feel free to negotiate. Thanks.

by: tawabhridoy
Created: —
Category: Data Entry
Viewed: 243

What is “Role Conversion” actually do on SharePoint 2016 on-premise?

We have a SP2016 (16.0.4327.1000 build, Release candidate) installed. I checked there is no Distrubuted Cache service setup. So I set it up on 2 WFE server. After that I change the role of WFE servers to “Custom”. I found nothing have changed but I am not sure. All services on WFE have same status before conversion.

May I know what is “Role conversion” actually perform beside change the naming?

P.S. by some project restriction I cannot patch the farm at this moment.

How do I put the output of this temperature-based conversion loop with a table?

” .$ x. ” Celsius
“; echo “” .$ f. ” Fahrenheit
“; echo “” .$ k. ” Kelvin
“; echo “” .$ r. ” Rankine
“; } else if ( $ x >= 16 && $ x ” .$ x. ” Celsius
“; echo “” .$ f. ” Fahrenheit
“; echo “” .$ k. ” Kelvin
“; echo “” .$ r. ” Rankine
“; } else if ( $ x>30){ echo “” .$ x. ” Celsius
“; echo “” .$ f. ” Fahrenheit
“; echo “” .$ k. ” Kelvin
“; echo “” .$ r. ” Rankine
“; } } ?>

`bind’ no implicit conversion of Fixnum into String (TypeError)

Quando meu script chama a lib do snmp manager.rb ocorre esse erro. Alguém saberia informar como posso corrigir isso?

/usr/local/rvm/gems/ruby-2.1.0/gems/snmp-1.3.2/lib/snmp/manager.rb:544:in bind' : no implicit conversion of Fixnum into String (TypeError) from /usr/local/rvm/gems/ruby-2.1.0/gems/snmp-1.3.2/lib/snmp/manager.rb: 544:ininitialize’ from /usr/local/rvm/gems/ruby-2.1.0/gems/snmp-1.3.2/lib/snmp/manager.rb: 590:in new' from /usr/local/rvm/gems/ruby-2.1.0/gems/snmp-1.3.2/lib/snmp/manager.rb: 590:increate_transport’ from /usr/local/rvm/gems/ruby-2.1.0/gems/snmp-1.3.2/lib/snmp/manager.rb: 622:in initialize' from /usr/local/rvm/gems/ruby-2.1.0/gems/fluent-plugin-snmptrap-0.0.1/li b/fluent/plugin/in_snmptrap.rb:20:innew’ from /usr/local/rvm/gems/ruby-2.1.0/gems/fluent-plugin-snmptrap-0.0.1/li b/fluent/plugin/in_snmptrap.rb:20:in configure' from /usr/local/rvm/gems/ruby-2.1.0/gems/fluentd-1.6.0/lib/fluent/plugin .rb:164:inconfigure’ from /usr/local/rvm/gems/ruby-2.1.0/gems/fluentd-1.6.0/lib/fluent/root_a gent.rb:320:in add_source' from /usr/local/rvm/gems/ruby-2.1.0/gems/fluentd-1.6.0/lib/fluent/root_a gent.rb:160:inblock in configure’ from /usr/local/rvm/gems/ruby-2.1.0/gems/fluentd-1.6.0/lib/fluent/root_a gent.rb:156:in each' from /usr/local/rvm/gems/ruby-2.1.0/gems/fluentd-1.6.0/lib/fluent/root_a gent.rb:156:inconfigure’ from /usr/local/rvm/gems/ruby-2.1.0/gems/fluentd-1.6.0/lib/fluent/engine .rb:131:in configure' from /usr/local/rvm/gems/ruby-2.1.0/gems/fluentd-1.6.0/lib/fluent/engine .rb:96:inrun_configure’ from /usr/local/rvm/gems/ruby-2.1.0/gems/fluentd-1.6.0/lib/fluent/superv isor.rb:804:in run_configure' from /usr/local/rvm/gems/ruby-2.1.0/gems/fluentd-1.6.0/lib/fluent/superv isor.rb:581:indry_run’ from /usr/local/rvm/gems/ruby-2.1.0/gems/fluentd-1.6.0/lib/fluent/superv isor.rb:599:in supervise' from /usr/local/rvm/gems/ruby-2.1.0/gems/fluentd-1.6.0/lib/fluent/superv isor.rb:504:inrun_supervisor’ from /usr/local/rvm/gems/ruby-2.1.0/gems/fluentd-1.6.0/lib/fluent/comman d/fluentd.rb:314:in <top (required)>' from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/ core_ext/kernel_require.rb:54:inrequire’ from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/ core_ext/kernel_require.rb:54:in require' from /usr/local/rvm/gems/ruby-2.1.0/gems/fluentd-1.6.0/bin/fluentd:8:in‘ from /usr/local/rvm/gems/ruby-2.1.0/bin/fluentd:23:in load' from /usr/local/rvm/gems/ruby-2.1.0/bin/fluentd:23:in‘ from /usr/local/rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:24:in eva l' from /usr/local/rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:24:in

Recursive conversion from ExpandoObject to Dictionary – rework

Because my original question was lacking many details, I have been advised to ask a new question.
I will repeat the important parts of the original question and add examples etc to hopefully make it clear.

For my blazor library which is a modification of this awesome library I have to convert an ExpandoObject into a Dictionary<string, object> since ExpandoObjects aren’t serialized properly in the newest preview versions of dotnet-core. See my question related to this for more details.

For this new question I have already improved my code with recommendations from this and this answer on my previous question.

This is my current (and hopefully already better) approach. I have added summaries to more clearly show my intent but I’m sure these could be improved as well since I’m not very good at documenting my code.
Also worth mentioning if it’s not clear, these changes did not affect the program and everything still works.

/// <summary> /// This method is specifically used to convert an <see cref="ExpandoObject"/> with a Tree structure to a <see cref="Dictionary{string, object}"/>. /// </summary> /// <param name="expando">The <see cref="ExpandoObject"/> to convert</param> /// <returns>The fully converted <see cref="ExpandoObject"/></returns> private static Dictionary<string, object> ConvertExpandoObjectToDictionary(ExpandoObject expando) => RecursivelyConvertIDictToDict(expando);  /// <summary> /// This method takes an <see cref="IDictionary{string, object}"/> and recursively converts it to a <see cref="Dictionary{string, object}"/>.  /// The idea is that every <see cref="IDictionary{string, object}"/> in the tree will be of type <see cref="Dictionary{string, object}"/> instead of some other implementation like <see cref="ExpandoObject"/>. /// </summary> /// <param name="value">The <see cref="IDictionary{string, object}"/> to convert</param> /// <returns>The fully converted <see cref="Dictionary{string, object}"/></returns> private static Dictionary<string, object> RecursivelyConvertIDictToDict(IDictionary<string, object> value) =>     value.ToDictionary(         keySelector => keySelector.Key,         elementSelector =>         {             // if it's another IDict just go through it recursively             if (elementSelector.Value is IDictionary<string, object> dict)             {                 return RecursivelyConvertIDictToDict(dict);             }              // if it's an IEnumerable check each element             if (elementSelector.Value is IEnumerable<object> list)             {                 // go through all objects in the list                 // if the object is an IDict -> convert it                 // if not keep it as is                 return list                     .Select(o => o is IDictionary<string, object>                         ? RecursivelyConvertIDictToDict((IDictionary<string, object>)o)                         : o                     );             }              // neither an IDict nor an IEnumerable -> it's fine to just return the value it has             return elementSelector.Value;         }     );  

Something I didn’t mention in detail is why I need this conversion in the first place. This is also the reason this answer probably wont help :/

I’ll explain it with a simplified example:

public void Demo() {     SomeConfig config = new SomeConfig     {         Options = new SomeOptions   // it can contain complex types         {             SomeInt = 2,            // it can contain primative types             SomeString = null,                   Axes = new List<Axis>   // it can contain complex lists             {                 new Axis(),                 new Axis                 {                     SomeString = "axisString"                 }             }         },         Data = new SomeData         {             Data = new List<int> { 1, 2, 3, 4, 5 },     // it can contain primative lists             SomeString = "asdf",             SomeStringEnum = MyStringEnum.Test          // it can contain objects with custom parsing (for JSON.NET, not the parsing that's done when invoking the JS sadly         }     };      // now there are three options for invoking the javascript (I invoke it using IJSRuntime.InvokeAsync)      // this does not work because there are still nulls and the StringEnum will be parsed as an object instead of string (     // parses it correctly because of the custom converter but .net does not as it just sees an object)     InvokeJavascript(config);      // the nulls are gone and the StringEnum is parsed correctly but      // this does not work because .Net (NOT JSON.NET) has to convert the parameter to json which is not possible if the object is an ExpandoObject     InvokeJavascript(StripNulls(config));      // this does work because .Net can serialize a Dictionary but not an ExpandoObject.      // the nulls are still gone and the StringEnum is parsed correctly     InvokeJavascript(ConvertExpandoObjectToDictionary(StripNulls(config)));  }  /// <summary> /// Returns an object that is equivalent to the given parameter but without any null members. /// <para>This method is necessary because of the custom parsing for string enums and because for server-side blazor projects,  /// the interop doesn't work if there are null values (no idea why, this really should be fixed sometime in the future)</para> /// </summary> private static ExpandoObject StripNulls(SomeConfig chartConfig) {     // Serializing with the custom serializer settings remove null members     // this cleanChartConfigStr doesn't contain a single null value and also the StringEnums are parsed as strings instead of objects because I use JSON.NET here     string cleanChartConfigStr = JsonConvert.SerializeObject(chartConfig, JsonSerializerSettings);      // Get back an ExpandoObject with the clean config - having an ExpandoObject allows us to add/replace members regardless of type     // which is necessary for preserving the DotNetObjectRefs (see below). Also if it were to be parsed back to the original Type (SomeConfig)      // the null values would return (and the string enums would throw errors since I've only implemented writing json but that could be fixed)     dynamic clearConfigExpando = JsonConvert.DeserializeObject<ExpandoObject>(cleanChartConfigStr, new ExpandoObjectConverter());      /*      * There are DotNetObjectRefs in the config which are manually being restored here and assigned to the right property in the dynamic config      */      return clearConfigExpando; }  // serializer settings for to ignore all the null values and use the CamelCaseNamingStrategy private static readonly JsonSerializerSettings JsonSerializerSettings = new JsonSerializerSettings {     NullValueHandling = NullValueHandling.Ignore,     ContractResolver = new DefaultContractResolver     {         NamingStrategy = new CamelCaseNamingStrategy(true, false)     } };  

I can show you the difference when looking at the json that get produced when invoking the javascript with different objects:

Directly invoking the javascript with the SomeConfig instance from the demo results in this json code being used in the javascript:

{     "options": {         "someInt": 2,         "someString": null,         "axes": [             {                 "someString": null             },             {                 "someString": "axisString"             }         ]     },     "data": {         "data": [             1,             2,             3,             4,             5         ],         "someString": "asdf",         "someStringEnum": {}     } } 

First parsing it with custom parsing (using JSON.NET), then reading it back as ExpandoObject (using JSON.NET) and converting that to a Dictionary<string, object> results in the following json being used:

{     "options": {         "someInt": 2,         "axes": [             {},             {                 "someString": "axisString"             }         ]     },     "data": {         "data": [             1,             2,             3,             4,             5         ],         "someString": "asdf",         "someStringEnum": "someTestThing"     } } 

Note that both of these json string were not produced by but by .net itself when invoking the javascript using IJSRuntime.InvokeAsync.

The json of the second option is in this example exactly the same as the intermediate json cleanChartConfigStr in the StripNulls method. This cleanChartConfigStr does not contain the functions and DotNetObjectRefs which are added to the ExpandoObject later on in the StripNulls method. When using JSON.stringify to print the json-string of that ExpandoObject (that’s the json-string I showed you), you won’t see those functions/DotNetObjectRefs either but this time because JSON.stringify doesn’t print them, not because there are non-existent.
I mention this because otherwise you might think that the cleanChartConfigStr as json-object would be equal to the json-object produced by the ExpandoObject which is not true (because of those functions and DotNetObjectRefs).

I feel like this part was confusing, I hope you understand what’s going on.

Here are the remaining classes needed for the code to compile:

class SomeConfig {     public SomeOptions Options { get; set; }     public SomeData Data { get; set; } }  class SomeOptions {     public int SomeInt { get; set; }      public string SomeString { get; set; }      public List<Axis> Axes { get; set; } }  class SomeData {     public List<int> Data { get; set; }      public string SomeString { get; set; }      public MyStringEnum SomeStringEnum { get; set; } }  class Axis {     public string SomeString { get; set; } }  [JsonConverter(typeof(JsonStringEnumConverter))] class MyStringEnum {     public static MyStringEnum Test => new MyStringEnum("someTestThing");       private readonly string _value;     private MyStringEnum(string stringRep) => _value = stringRep;     public override string ToString() => _value; }  class JsonStringEnumConverter : JsonConverter<MyStringEnum> {     public sealed override bool CanRead => false;     public sealed override bool CanWrite => true;      public sealed override MyStringEnum ReadJson(JsonReader reader, Type objectType, MyStringEnum existingValue, bool hasExistingValue, JsonSerializer serializer)     {         throw new NotImplementedException("Don't use me to read JSON");     }      public override void WriteJson(JsonWriter writer, MyStringEnum value, JsonSerializer serializer)     {         // ToString was overwritten by StringEnum -> safe to just print the string representation         writer.WriteValue(value.ToString());     } } 

Now, I have put a lot of time and effort in this question and I hope now there’s enough detail. As already mentioned, the real code (not this small demo example) is available on github. The most important file for this question would be ChartJsInterop.cs.

Once again I’m mostly interested in the recursive solution to convert those ExpandoObjects. However I’m happy for any critisism so please also mention every small thing that bugs you 🙂