I load multiple pages using the same type provider, HtmlProvider:
type Article = HtmlProvider<"https://en.wiktionary.org/wiki/giraffe">
let sheepArticle = Article.Load "https://en.wiktionary.org/wiki/sheep"
let koalaArticle = Article.Load "https://en.wiktionary.org/wiki/koala"
let pandaArticle = Article.Load "https://en.wiktionary.org/wiki/panda"
...
Is it anyhow possible to configure the provider so that the web client underneath is reused there?
I haven't found nothing on that in the docs. I do a lot of similar calls, so that would be a significant optimization.
There is no way to configure the HtmlProvider to do this automatically behind the scenes, but you can easily create your own WebClient to download the pages and then use the Parse method of the provided type (rather than using Load to download and parse it):
type Article = HtmlProvider<"https://en.wiktionary.org/wiki/giraffe">
let wc = new WebClient()
let sheepArticle = Article.Parse(wc.DownloadString("https://en.wiktionary.org/wiki/sheep"))
let koalaArticle = Article.Parse(wc.DownloadString("https://en.wiktionary.org/wiki/koala"))
let pandaArticle = Article.Parse(wc.DownloadString("https://en.wiktionary.org/wiki/panda"))
Related
We are using the Autodesk Forge Viewer DiffTool extension, but we need to change one of the texts:
Every tutorial shows how add localization to your own extension, but I couldn't find how to change a translation in an existing extension you are using.
Moreover, without knowing what the translation key is, I would have "guess" it, which isn't really great either.
So, how do I change the translation for this text?
There is no supported way to hook into the translation service of the Viewer to change the text. If the translation is wrong, please let us know, and we can fix that on our side.
If you want to change the text for some other reasons, then one thing you could do is wait for the initialization of the extension's UI and change the button's content using DOM APIs:
let extensionConfig = {}
extensionConfig['mimeType'] = 'application/vnd.autodesk.revit'
extensionConfig['primaryModels'] = [model1]
extensionConfig['diffModels'] = [model2]
extensionConfig['diffMode'] = 'overlay'
extensionConfig['versionA'] = '2'
extensionConfig['versionB'] = '1'
extensionConfig['onInitialized'] = () => {
let button = document.getElementById("diffFacetsRemovedButton");
let label = button.nextSibling;
label.innerHTML = label.innerHTML.replace("Odebrat", "Něco jiného");
}
viewer.loadExtension('Autodesk.DiffTool', extensionConfig);
I'm currently building a tool to migrate from a document management system to use SharePoint Online. The main challenge I'm facing is to preserve the details of document authors and creating time. I have checked bunch of of code online but I didn't get success with any of them.
Here are the approaches I used
SharePoint Rest API
Microsoft Graph API
CSOM (using console application)
Here is the code I have so far in CSOM but I'm still not able to update the Author field
li["Title"] = "Update from CSOM";
li["Created"] = DateTime.Now.AddYears(-5);
li["Author"] = author.Id;
li.UpdateOverwriteVersion();
clientContext.ExecuteQuery();
Any idea for how to do this, or if there is any other approach to achieve my goal?
The code works when I did test in my environment.
using (ClientContext context = new ClientContext("https://xxx.sharepoint.com/sites/lee"))
{
string s = "password";
SecureString passWord = new SecureString();
foreach (var c in s)
passWord.AppendChar(c);
context.Credentials = new SharePointOnlineCredentials("admin#xxx.onmicrosoft.com", passWord);
var author = context.Web.EnsureUser("Lee#xxx.onmicrosoft.com");
context.Load(author);
context.ExecuteQuery();
var _List = context.Web.Lists.GetByTitle("List1");
var li = _List.GetItemById(1);
li["Title"] = "Update from CSOM";
li["Created"] = DateTime.Now.AddYears(-5);
li["Author"] = author.Id;
li.UpdateOverwriteVersion();
context.ExecuteQuery();
}
You will need to update the Author and Editor fields at the same time in order to update the CreatedBy field. If you wish to update additional fields at the same time you can. Using SystemUpdate() does not update the Modified date whereas Update() does update the Modified date. See abbreviated sample below.
FieldUserValue userValue = new FieldUserValue();
User newUser = cc.Web.EnsureUser("newAuthor#xxx.onmicrosoft.com");
cc.Load(newUser);
cc.ExecuteQuery();
userValue.LookupId = newUser.Id;
item["Author"] = userValue;
item["Editor"] = userValue;
item.SystemUpdate();
cc.ExecuteQuery();
I'm working with an application that has 3 ini files in a somewhat irritating custom format. I'm trying to compile these into a 'standard' ini file.
I'm hoping for some inspiration in the form of pseudocode to help me code some sort of 'compiler'.
Here's an example of one of these ini files. The less than/greater than indicates a redirect to another section in the file. These redirects could be recursive.. i.e. one redirect then redirects to another. It could also mean a redirect to an external file (3 values are present in that case). Comments start with a # symbol
[PrimaryServer]
name = DEMO1
baseUrl = http://demo1.awesome.com
[SecondaryServer]
name = DEMO2
baseUrl = http://demo2.awesome.com
[LoginUrl]
# This is a standard redirect
baseLoginUrl = <PrimaryServer:baseUrl>
# This is a redirect appended with extra information
fullLoginUrl = <PrimaryServer:baseUrl>/login.php
# Here's a redirect that points to another redirect
enableSSL = <SSLConfiguration:enableSSL>
# This is a key that has mutliple comma-separated values, some of which are redirects.
serverNames = <PrimaryServer:name>,<SecondaryServer:name>,AdditionalRandomServerName
# This one is particularly nasty. It's a redirect to another file...
authenticationMechanism = <Authenication.ini:Mechanisms:PrimaryMechanism>
[SSLConfiguration]
enableSSL = <SSLCertificates:isCertificateInstalled>
[SSLCertificates]
isCertificateInstalled = true
Here's an example of what I'm trying to achieve. I've removed the comments for readability.
[PrimaryServer]
name = DEMO1
baseUrl = http://demo1.awesome.com
[SecondaryServer]
name = DEMO2
baseUrl = http://demo2.awesome.com
[LoginUrl]
baseLoginUrl = http://demo1.awesome.com
fullLoginUrl = http://demo1.awesome.com/login.php
enableSSL = true
serverNames = DEMO1,DEMO2,AdditionalRandomServerName
authenticationMechanism = valueFromExternalFile
[SSLConfiguration]
enableSSL = <SSLCertificates:isCertificateInstalled>
[SSLCertificates]
isCertificateInstalled = true
I'm looking at using ini4j (Java) to achieve this, but am by no means fixed on using that language.
My main questions are:
1) How can I handle the recursive redirects
2) How am I best to handle the redirects that have an additional string, e.g. serverNames
3) Bonus points for any suggestions about how to handle the external redirects. No big deal if that part isn't working just yet.
So far, I'm able to parse and tidy up the file, but I'm struggling with these redirects.
Once again, I'm only hoping for pseudocode. Perhaps I need more coffee, but I'm really puzzled by this one.
Thanks in advance for any suggestions.
I'm using Google-Mobile-Ads-SDK (7.8.1) to load some ads like this:
let bannerView = GADSearchBannerView(adSize:kGADAdSizeFluid)
bannerView.adUnitID = "pub-Super-Secret"
bannerView.frame = CGRectMake(0,0,CGRectGetWidth(self.advertismentContainer.bounds),0)
bannerView.autoresizingMask = .FlexibleWidth
bannerView.delegate = self
bannerView.adSizeDelegate = self
self.advertismentContainer.addSubview(bannerView)
let request = GADDynamicHeightSearchRequest()
request.query = searchTerm
request.numberOfAds = 3
request.adTestEnabled = true
request.clickToCallExtensionEnabled = true
request.setAdvancedOptionValue("false", forKey:"domainLinkAboveDescription")
request.setAdvancedOptionValue("false", forKey:"sellerRatings")
request.setAdvancedOptionValue("false", forKey:"siteLinks")
request.setAdvancedOptionValue("sellerFirst", forKey:"adLayout")
bannerView.loadRequest(request)
I'm refering to the official documentation to find what parameters I can send. Sure enough, there is adLayout parameter, which is exactly what I need:
By default, adLayout is disabled. If you wish to enable it, use this
line of code:
'adLayout' : 'sellerFirst'
Unfortunately, it comes with a star, but the star is never explained in the document I linked. I have tried to use the sellerFirst layout, but it doesn't work. Is it possible to use this parameter in the iOS SDK? The ads load fine but the adLayout parameter has no effect.
Turns out that there are 2 problems:
adLayout parameter needs to be enabled for the specific client-id, so if you want to use it you need to contact Google and ask them to enable it for you.
at the moment, this parameter is only available for the web clients, I was told that on iOS and Android it's still work in progress.
I'm using the F# data provider to load csv files. For some reason, not in my control, they occasionally change the file to a gzip. (e.g. MyFile.txt could also be MyFile.text.gz)
So, I have this and it works just fine
let fl = CSV.load("MyFile.txt")
What I need to be able to do is if this errors with file not found, I need it to look for the alternate name.
let fl = CSV.load("MyFile.txt.gz")
I've tried a try...with block
try
let fl = CSV.load("MyFile.txt")
with
let fl = CSV.load("MyFile.txt.gz")
It won't let me use let keyword in this fashion. I even tried
try
let fl = CSV.load("MyFile.txt")
with
CSV.load("MyFile.txt.gz") -> fl
With C#, this would be pretty straight forward. Thanks in advance for any assistance.
You can use something like:
let fl =
try CSV.load("MyFile.txt")
with _ -> CSV.load("MyFile.txt.gz")
But I believe a better solution would be to check if the file exists first.