When using compdef for ZSH completion, I would like to display a "nice" name to a user (e.g. a device name) and when it is selected, a different value is injected (e.g. device serial number / UUID).
How can this be done with _arguments / _alternative / _describe?
Specifically, I have function list-devices that will return ( devA devB devC ), and a separate shell script that will convert e.g. devA into UUID1234. I want the user to be able to select devA, and have UUID1234 appear on the command line.
Related
I'm trying to build a query that looks through a string column and compares it to a list of strings I have in a text file to see if any of the strings in the list are contained within the text of the string column. I then want to grab the first occurrence of a match and return it.
For further context, I have a list of app names in a text file that look like ('app 1', 'app 2', etc). These all belong to one device (let's call that 'device_1').
Separately, I have a database table called "reports" with a 3 columns:
report_id
device
report_title
1
device_1
title string 1
2
device_1
title string 2
3
device_1
title string 3
I'm filtering the reports table for only device = 'device_1'. The "report_title" column will hold a long string of text that may or may not contain an app name. Using a sql query, I want to check each report title string to see if it contains one of the app names in my text file, and if so, return that app name for the first match (there SHOULD only ever be one match per title string if there is one).
The final output that I'm trying to get would be something like the below:
report_id
device
app_name
1
device_1
app 1
2
device_1
app 2
3
device_1
app 1
4
device_1
app 3
I was originally trying to do this somehow by creating a temporary local table to hold the text file strings, but I'm getting error messages when trying to create a table due to not having the appropriate permissions (unless I'm doing it wrong).
Would this be better done by converting the text file into an array somehow?
I think something like this should do it
SELECT TOP (1) report_title
FROM reports
WHERE device = 'device_1';
I am writing an app in WordPress for managing dog adoptions. In one scenario, the user selects a primary breed from a select and a secondary breed from another select. When they choose the breed, an input (read-only) field is filled with the values of the 2 selects.
I wanted to test this and I have written an acceptance test that does just that. The dog breed from the select is chosen and the value is added to the input via jQuery:
Image of Field with Dog Value filled out
The trouble is that when I try to assert that the text exists, I continuously get an error and the test fails. The lines that follow are the ones I have tried:
$I->see('Kelpie X');
$I->seeElement( '#acf-field_mdr_dog_text_breed_name', ['value' => 'Kelpie X']);
$I->seeInField( 'input#acf-field_mdr_dog_text_breed_name', 'Kelpie X');
Why aren't these conditions passing? Does it have to do because jQuery set the value?
Thanks!
I am not sure why the first one did not work, but I noticed that the value in the input text field had a space after the X. Apparently seeInField & seeElement are very strict, so this did the trick:
// Note the space after the X
$I->seeElement( 'input#acf-field_mdr_dog_text_breed_name', ['value' => 'Kelpie X ']);
$I->seeInField( 'input#acf-field_mdr_dog_text_breed_name', 'Kelpie X ');
maybe someone once wrote a script for mass change of lotus type groups? Mass but not all, only grups with first two characters begins on ('GD') i need change mostly type from mail only (3) to Multipurpose (0).
Just select the groups, create an agent with this code, that runs on selected documents:
FIELD GroupType := "0";
If you really want to do the selection in your agent, then let it run on "all documents in view" and add a selection before the action:
SELECT #Begins( ListName ; "GD" );
FIELD GroupType := "0";
As this will run a lot slower I would manually select the groups and use the first agent as selecting is as easy as setting the cursor to the first group with "GD", then scroll down to the last one and click it while holding the Shift- Key.
I have a TEXT item field - order number, where user can enter his details.
When a user enters order number starting with 1, the character limit should be restricted to 14.
When a user enters order number starting with 2, the character limit should be restricted to 11.
How can we do it in Oracle Apex?
Click Create Dynamic Action, set following properties:
Event - Key press
Selection Type - Item
Item(s) - name of your item
Condition - Javascript expression with following expression (where P_ITEM is name of your item):
($v('P_ITEM').length >= 14 && $v('P_ITEM').substring(0,1) == '1') ||
($v('P_ITEM').length >= 11 && $v('P_ITEM').substring(0,1) == '2')
Action - Cancel Event
P. S. I have not tried to copy and paste long values. Probably, you need some additional javascript code for that. Also, this code can't restrict values starting from other symbols.
P. P. S. Also it is possible to do with Validations (it is quite simple, but validations are processed on the server side) and in triggers (both solution use PL/SQL code).
I am using twilio to provide audio conference functionality in my rails app. When I call my conference number, twilio passes on a couple of values - including 'From' which contains the caller's phone number in international format.
I have a profile for every user in my system and in my controller I am querying the profile to provide a personalised welcome message. Every profile contains between 0 and 3 numbers (primary, secondary and cellphone) and I need to check the caller's ID against those three fields in all profiles.
When I use the console on my dev machine, the following code finds the correct profile:
Profile.find_by('+44000000000')
When I upload to heroku, I use following code instead:
name = Profile.find_by(params['From']) || 'there'
Which causes an error in my app:
2014-04-03T19:20:22.801284+00:00 app[web.1]: PG::DatatypeMismatch: ERROR: argument of WHERE must be type boolean, not type bigint
2014-04-03T19:20:22.801284+00:00 app[web.1]: LINE 1: SELECT "profiles".* FROM "profiles" WHERE (+4400000000) ...
Any suggestion how that could be solved?
Thanks!
Additional information:
I think my problem is that I don't know how to query either the whole profile or three columns at once. Right now the code:
name = Profile.find_by(params['From'])
is not correct (params['From'] contains a phone number) because I am not telling rails to query the columns primary phone number, secondary phone number and cellphone. Neither am I querying the whole profile which would also be an option.
So the question basically is:
How can I change this code:
Profile.find_by(params['From'])
so that it queries either all fields in all profiles or just the three columns with phone numbers which each profile contains?
Is there something like Profile.where(:primary_number).or.where(:secondary_number)or.where(:cellphone) => params['From']
?
I am not familiar with twilio and not sure if this helps but find and find_by_attribute_name accepts array of values as options:
name = Profile.find_by([params['From'], 'there'] )
suppose params['From'] was here , This should generate:
SELECT `profiles`.* FROM `profiles` WHERE `profiles`.`attribute` IN ('here', 'there')
Or:
If you are trying to build dynamic matcher at run time , which is called Meta-programming , you can try this code:
name = eval("Profile.find_by_#{params['From']) || 'there'}(#rest of query params here) ")
Update
First of all, i think you are not using find_by correctly!! the correct syntax is:
Model.find_by(attribute_name: value)
#e.g
Profile.find_by(phone_number: '0123456')
Which will call where and retrive one record, but passing a value will generate a condition that always passes, for example:
Model.find_by('wrong_condition')
#will generate SQL like:
SELECT `models`.* FROM `models` WHERE ('wrong_condition') LIMIT 1
#which will return the first record in the model since there is no valid condition here
Why don't you try:
Profile.where('primary_number = ? OR secondary_number = ? OR cellphone = ?', params['From'], params['From'], params['From'])
You can write your query like:
Profile.where("primary_number = ? or secondary_number = ? or cellphone = ?", params['From'])
Just double check the syntax, but that should do it.