RethinkDb without deep nested - rethinkdb

I would like to remove a sequence of objects 4 levels down, in this case I want to remove Level3
Root
Level1
Level2
Level3
I am able to remove Level1 by using this logic
r.table("TableName").get("4045").without({'Root':'Level1'})
However if I specify
r.table("TableName").get("4045").without({'Root':'Level1':'Level2':'Level3'}) I get SyntaxError: Unexpected token ':'
Please let me know how I can remove Level3.

I am assuming you have a nested json object, so the correct syntax would be something like this:
r.table("TableName").get("4045").without({'Root':{'Level1':{'Level2':{'Level3':true}}}})
link to the documentation: https://rethinkdb.com/api/javascript/without

Related

JSON_HEX_AMP option required for Laravel LengthAwarePaginator->toJson() when used as Vue.js component prop?

Here's the super short version of what's happening, as far as I can tell. Debugging this has been a pain, and I'm not sure if this is a Laravel issue or a Vue.js issue (leaning toward Vue.js). Here goes...
I'm using a LengthAwarePaginator object to retrieve data to pass to a Vue.js component as a property. (This is unorthodox, and I plan to convert it to a fetch() method in the component when I have a proper API set up.)
<my-component :items="{{ $paginator->toJson() }}"></my-component>
When my $paginator data contains an item with a string field that contains " -- e.g. Plumber cut pipe 4" from end -- Vue.js completely fails to render my component.
However, if instead of " the field uses a raw ", everything works just fine -- e.g. Plumber cut pipe 4" from end.
I was alerted to this issue by a Vue.js parse error: avoid using JavaScript keyword as property name: "for" in expression .... I believe I received this error because of subsequently broken syntax that made a string use of 'for' look like a property name.
It's almost like Vue.js is double-converting the resulting &quot; to " when it reads the property, and the resulting extra " turns string data into a property name. This makes no sense though, since the raw " allows proper parsing.
My work-around, while I try to understand why this is even broken at all, has been to assign my property like this:
<my-component :items="{{ $paginator->toJson(JSON_HEX_AMP) }}"></my-component>
Does anyone understand why this is happening? Why is this an unsafe string in this context: Plumber cut pipe 4" from end ???

How do I use the appProperties with the ruby api-client

I can't determine how to add custom properties or search for them.
Everything I have tried is giving me a Error - #<Google::Apis::ClientError: invalid: Invalid query> when I attempt to search for them. I can successfully complete other queries but I don't know if the client is setup to work with appProperties (or even properties at all).
Basically I just need the correct syntax for searching and adding since it doesn't appear to be in the documentation.
Assuming you already have a reference to an authorized DriveService, you can search based on appProperties using a q-parameter (documented here), like this:
file_list = drive.list_files(
q: "appProperties has { key='my_app_key' and value='my_val' }",
fields: 'files(id, name, appProperties)',
spaces: 'drive')
If you omit the fields parameter then the search will still work but the properties themselves won't be returned.
Updating appProperties is definitely arcane and the documentation is opaque. What you need is the ID of the file, and a File value object as a container for the attributes to update. Something like this:
new_app_properties = { 'my_app_key' => 'my_val' }
update_f = Google::Apis::DriveV3::File.new(app_properties: new_app_properties)
drive.update_file(file_id, update_f)

if page has selector - Capybara

I'm trying to implement a simple piece of logic that says if element exists on page do something`
The issue I am facing is that if the element doesn't exist then the find method provided returns an exception and will fail my test.
(Capybara::ElementNotFound)
so for example I want to do something like:
if page.find(".element")
do something
end
If the element doesn't exist then the test should just carry on as normal.
Is there a way to do this?
Consider using something like this:
if page.has_css?('selector')
do something
end
This method is described here

simplexml_load_file with xPath returns empty array

Getting XML from this URL:
$xml = simplexml_load_file('http://geocode-maps.yandex.ru/1.x/?geocode=37.71677,55.75208&kind=metro&spn=1,1&rspn=1');
print_r($xml) shows that XML loaded, but xpath always returns empty array. I tried:
$xml->xpath('/');
$xml->xpath('/ymaps');
$xml->xpath('/GeoObjectCollection');
$xml->xpath('/ymaps/GeoObjectCollection');
$xml->xpath('//GeoObjectCollection');
$xml->xpath('precision');
Why I got empty array? Hope I just missing something easy.
It might be rather easy, but I guess it is also the most common mistake in the history of XML: You are forgetting namespaces!
A lot of elements in the given XML are changing the default namespace and you have to consider that in your XPath.
You can first register your namespace like so:
$xml->registerXPathNamespace('y', 'http://maps.yandex.ru/ymaps/1.x');
$xml->registerXPathNamespace('a', 'http://maps.yandex.ru/attribution/1.x');
and then you can query your data:
$xml->xpath('//y:ymaps/y:GeoObjectCollection');

Get [Messages] values in InnoSetup's language file

I know I can easily get messages inside
[CustomMessages]
AdditionalIcons=blablabla
using this code:
ExpandConstant('{cm:AdditionalIcons}');
which gets the AdditionalIcons string message. However, how can I get messages inside this?
[Messages]
ButtonNext=huhu
ButtonInstall=bubu
What I need is to get the ButtonNext, ButtonInstall and other values, and it is NOT possible to get those values using code like this:
ExpandConstant('{cm:ButtonNext}');
How can I query those values?
Related links
Inno Setup Script tips
Try
SetupMessage(msgButtonNext);
In general, the name of the constant to use (in this case msgButtonNext) is msg + the name of the message (string concatination).

Resources