I need to get in my raw Nexus v3 repository every files that contains a '-' character
Ive found how to use storageFacet to make some queries but I cant find how to use a regex with it:
def repo = repository.repositoryManager.get("myRepo")
StorageFacet storageFacet = repo.facet(StorageFacet)
def tx = storageFacet.txSupplier().get()
tx.begin()
Iterable<Component> components =
tx.findComponents(Query.builder().where('name = ').param('/^.*\b([-]+)\b.*$').build(), [repo])
tx.commit()
tx.close()
It works when I put a string name instead of param('/^.\b([-]+)\b.$') .
If you have any documentation about how this query system works I will be more than happy to read it.
I finaly used a Like %-%
But I still dont know how to use a Regex in this case.
Related
I'm trying to write my own Jekyll plugin to construct an api query from a custom tag. I've gotten as far as creating the basic plugin and tag, but I've run into the limits of my programming skills so looking to you for help.
Here's my custom tag for reference:
{% card "Arbor Elf | M13" %}
Here's the progress on my plugin:
module Jekyll
class Scryfall < Liquid::Tag
def initialize(tag_name, text, tokens)
super
#text = text
end
def render(context)
# Store the name of the card, ie "Arbor Elf"
#card_name =
# Store the name of the set, ie "M13"
#card_set =
# Build the query
#query = "https://api.scryfall.com/cards/named?exact=#{#card_name}&set=#{#card_set}"
# Store a specific JSON property
#card_art =
# Finally we render out the result
"<img src='#{#card_art}' title='#{#card_name}' />"
end
end
end
Liquid::Template.register_tag('cards', Jekyll::Scryfall)
For reference, here's an example query using the above details (paste it into your browser to see the response you get back)
https://api.scryfall.com/cards/named?exact=arbor+elf&set=m13
My initial attempts after Googling around was to use regex to split the #text at the |, like so:
#card_name = "#{#text}".split(/| */)
This didn't quite work, instead it output this:
[“A”, “r”, “b”, “o”, “r”, “ “, “E”, “l”, “f”, “ “, “|”, “ “, “M”, “1”, “3”, “ “]
I'm also then not sure how to access and store specific properties within the JSON response. Ideally, I can do something like this:
#card_art = JSONRESPONSE.image_uri.large
I'm well aware I'm asking a lot here, but I'd love to try and get this working and learn from it.
Thanks for reading.
Actually, your split should work – you just need to give it the correct regex (and you can call that on #text directly). You also need to escape the pipe character in the regex, because pipes can have special meaning. You can use rubular.com to experiment with regexes.
parts = #text.split(/\|/)
# => => ["Arbor Elf ", " M13"]
Note that they also contain some extra whitespace, which you can remove with strip.
#card_name = parts.first.strip
#card_set = parts.last.strip
This might also be a good time to answer questions like: what happens if the user inserts multiple pipes? What if they insert none? Will your code give them a helpful error message for this?
You'll also need to escape these values in your URL. What if one of your users adds a card containing a & character? Your URL will break:
https://api.scryfall.com/cards/named?exact=Sword of Dungeons & Dragons&set=und
That looks like a URL with three parameters, exact, set and Dragons. You need to encode the user input to be included in a URL:
require 'cgi'
query = "https://api.scryfall.com/cards/named?exact=#{CGI.escape(#card_name)}&set=#{CGI.escape(#card_set)}"
# => "https://api.scryfall.com/cards/named?exact=Sword+of+Dungeons+%26+Dragons&set=und"
What comes after that is a little less clear, because you haven't written the code yet. Try making the call with the Net::HTTP module and then parsing the response with the JSON module. If you have trouble, come back here and ask a new question.
I have tried these things but it is not working for me:
def fileNames = [/ReadyAPI-\d.\d.\d.vmoptions/, 'loadtestrunner.bat', 'ready-api.bat', 'securitytestrunner.bat']
def fileNames = ['ReadyAPI-\\d.\\d.\\d.vmoptions', 'loadtestrunner.bat', 'ready-api.bat', 'securitytestrunner.bat']
What I am trying to do is that there will be one of the two files that will be present in the system which are:
'ReadyAPI-1.2.2.vmoptions' OR 'ReadyAPI-1.3.1.vmoptions'.
I am relatively new to Groovy so may be I am not seeing common problem. So, please bear with me. Thanks
You will need to get the filename first, then put it into the list. You can use Groovy's FileNameByRegexFinder from groovy.utils like this to find that file with a regex:
def optionsFile = new FileNameByRegexFinder()
.getFileNames('.', /ReadyAPI-\d.\d.\d.vmoptions/).first()
def fileNames = [optionsFile, 'loadtestrunner.bat', ...]
Note that the first parameter to getFileNames() is the base directory to search in, you will likely need to change that for your scenario.
I am trying to use Python 2.7.3.2 to send an email through Lotus Notes 8.5.
There are plenty of examples on how to do this in other languages, and I've done it myself in VBA, but having difficulties with Python.
self.db = self.session.getDatabase(server, dbfile)
# ...
mailDoc = self.db.CreateDocument
mailDoc.Form = "Memo"
mailDoc.sendto = recipientList
mailDoc.subject = subject
mailDoc.Body = bodytext
Error returned: AttributeError: Property 'CreateDocument.Form' can not be set.
I have attempted to skip setting the form, but it also fails on setting any of these attributes.
Would anyone have code on this, or suggestions on what to try to resolve it.
I know nothing about Python, but my guess is that the shorthand notation document.item = "foo" for setting an item value is not supported. Most likely, you need to do this:
mailDoc.AppendItemValue("Form","Memo")
(You can also use ReplaceItemValue, which is equivalent for a newly created document, and also works for updating existing documents, so many people prefer to just remember the one method name.)
My script is like this:
import ldap, sys
server = 'ldap://my_server'
l = ldap.initialize(server)
dn="myname#mydomain"
pw = "password"
l.simple_bind_s(dn,pw)
ldap.set_option(ldap.OPT_REFERRALS,0)
print "valid"
I am using Python 2.7 on windows.
Is there any method to read or get the contents of active directory?
You can do quite a lot also using win32com.client (which I had trouble finding documentation for). For example I've needed to resolve user email knowing his ADS_NAME_TYPE_NT4 formatted name (doman\jonjoe).
First of all you need to convert it to ADS_NAME_TYPE_1779 format (CN=Jeff Smith,CN=users,DC=Fabrikam,DC=com):
name_resolver = win32com.client.Dispatch(dispatch='NameTranslate')
name_resolver.Set(3, 'domain\\jonjoe')
ldap_query = 'LDAP://{}'.format(name_resolver.Get(1))
Once you have that you can simply call GetObject():
ldap = win32com.client.GetObject(ldap_query)
print(ldap.Get('mail'))
Tested with Python 3.2.5
You should realy need to read the documentation of python-ldap http://www.python-ldap.org/docs.shtml
You have a connection in your variable l, then you can do this.
l.con_search_s('dc=your,dc=base,dc=dit', ldap.SCOPE_SUBTREE, 'uid=*', ['uid', 'uidnumber'])
The above code, goint to search in to all the uid's entrys, for if entry, is going to get the uid and the uidnumbre attributes.
found a new way with a php dump of a mysql database and 15 lines of lua, no pattern finding. Mod can delete this.
I'm trying to separate this into separate parts of a table, but I can't figure out how to make a pattern to ignore a specific thing.
local output = "<tr><td>ABAH</td><td>A Basic Anti Hack</td><td>Clark</td><td>Download"
for plugin in output:gmatch("<tr>(.-%S)Download</a>") do
--print( plugin )
for title in plugin:gmatch("<td>(.-%S)</td><td>") do
print(title)
end
for description in plugin:gmatch("</td><td>(.-%S)</t") do
print(description)
end
end
So far it outputs the title and the description, but also outputs the mail link, how can I make it ignore that?
Outputs:
1.ABAH
2.Clark
3.A Basic Anti Hack
I used http://codepad.org/XQ6rZ6ZM for testing.
Is there some reason why you can't simply apply another pattern to clean out the HTML for example:
local output = "<tr><td>ABAH</td><td>A Basic Anti Hack</td><td>Clark</td><td>Download"
for plugin in output:gmatch("<tr>(.-%S)Download</a>") do
for title in plugin:gmatch("<td>(.-%S)</td><td>") do
title= title:gsub('<.->','')
print(title)
end
for description in plugin:gmatch("</td><td>(.-%S)</t") do
description = description:gsub('<.->','')
print('description)
end
end