I have a rails service on aws, and I use elasticcache(redis).When i get redis slowlog,there are so many command like 'COMMAND'.
93) 1) (integer) 1176043
2) (integer) 1525704863
3) (integer) 1135
4) 1) "COMMAND"
94) 1) (integer) 1176042
2) (integer) 1525704862
3) (integer) 1005
4) 1) "COMMAND"
95) 1) (integer) 1176041
2) (integer) 1525704807
3) (integer) 1040
4) 1) "COMMAND"
I never call command like 'COMMAND' in my code.I can't find any slowlog with 'COMMAND' in my local development enviroment.And i'm not sure what 'Command' means.
Any body can help me?
Related
All,
I must suck at eLisp. Banged this first function out in no time.
(defun sort-lines-reverse (beg end)
"sort lines in reverse order"
(interactive
(if (use-region-p)
(list (region-beginning) (region-end))
(list (point-min) (point-max))))
(if (and beg end)
(sort-lines 1 beg end))
)
works perfectly. Hosed this next one
(defun sort-numeric-fields-reverse (field beg end)
"sort numeric fields in reverse order"
(interactive
(if (use-region-p)
(list (read-number "Field number: " 1) (region-beginning) (region-end))
(list (read-number "Field number: " 1) (point-min) (point-max)))
(message "calling if")
(if (and beg end)
((message "inside if")
(sort-numeric-fields field beg end)
(reverse-region beg end))
)
))
No runs no hits no errors. Don't see a single message displayed in messages. I do get my field number prompt.
A snippet of randomly generated test data if one so wishes.
8 412086510
8 744308263
8 1482781895
8 995992436
1 1021762533
1 897682569
1 963686690
1 166565707
1 2096612583
1 829723388
1 587753131
1 264251710
32 139885828
32 781244288
Adding insult to injury in my KDE Neon environment the C-M-x to bring up the lisp debugger doesn't do squat.
The only real difference between these two functions is in this one I have to prompt for a field number. Inside the if I run 2 functions instead of one. After getting the first one to work the second should have been a cakewalk.
Help would be appreciated.
Two issues:
missing ) at the end of interactive, after (if (use-region-p) ...
missing progn in (if (and beg end)...
(progn is superfluous because if has been replaced by when.)
Corrected version:
(defun sort-numeric-fields-reverse (field beg end)
"sort numeric fields in reverse order"
(interactive
(if (use-region-p)
(list (read-number "Field number: " 1) (region-beginning) (region-end))
(list (read-number "Field number: " 1) (point-min) (point-max))))
(message "calling if")
(when (and beg end)
(message "inside if")
(sort-numeric-fields field beg end)
(reverse-region beg end)))
EDIT: Code changed: if-progn replaced with when according to hint from #phils.
Hint: using an adequate editor makes the typing easy and gives you control over parentheses.
For the following line:
(random 9 current-pseudo-random-generator)
I'm getting the following error:
. . random: contract violation
expected: (or/c (integer-in 1 4294967087) pseudo-random-generator?)
given: #<procedure:current-pseudo-random-generator>
>
What's wrong?
current-pseudo-random-generator is a parameter, so you must use it like
(random 9 (current-pseudo-random-generator))
By default, random will use that automatically so you could simplify your example to (random 9).
I can't find anything in the official documentation of the dnsruby gem, so I'll ask here: Is there any chance to get a parsed version of the dnsruby outputs, especially for A-Record?
When I'm performing:
def find_domain
self.domain_name = Reversed.lookup(self.ip_address)
res = Resolver.new
a_recs = res.query(self.domain_name) # Defaults to A record
end
the output of a_recs is a long string, e.g.:
;; Answer received from 192.168.178.1 (75 bytes) ;; ;; Security Level : UNCHECKED ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59802 ;; flags: qr rd ra cd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 OPT pseudo-record : payloadsize 512, xrcode 0, version 0, flags 32768 ;; QUESTION SECTION (1 record) ;; google-public-dns-b.google.com. IN A ;; ANSWER SECTION (1 record) google-public-dns-b.google.com. 86399 IN A 8.8.4.4
I just need the IP-Address (in this case: 8.8.4.4) itself and not the whole answer to my query. Is there a solution? I want to avoid doing that the "dirty" way.. Thanks in advance!
I'm seperating the whole string into single words with .split and save the values into an array. Then I'm going to loop through them and pick the last value. Something like this (note tested):
a_recs = res.query(self.domain_name).split
a_recs.each do |ip|
a_recs = ip
end
When iterating through the array the last values are getting overwritten so the last one (in my case the IP-address 8.8.4.4) should be saved to a_recs.
For some reason, my menu renders like this:
1) RUNTHROUGH 6) option 4
2) QUIT 7) option leg
3) NEW SEARCH PATERN 8) option arm
4) CLEAR SEARCHES 9) option whatever
5) option 1 10) option blabla
,but I would like it to be aligned properly, like this:
1) RUNTHROUGH 6) option 4
2) QUIT 7) option leg
3) NEW SEARCH PATERN 8) option arm
4) CLEAR SEARCHES 9) option whatever
5) option 1 10) option blabla
How can I do that?
I am populating menu from two arrays:
One is constructed from label variables like this:
MENU_OPTIONS=( "$SCRIPT_RUNTHROUGH" "$PROGRAM_QUIT" "$PATTERN_NEW" "$PATTERN_CLEAR" )
where variable has value like this, with color escapes
SCRIPT_RUNTHROUGH=$'\e[1;31mRUNTHROUGH\e[0;33m'
PROGRAM_QUIT=$'\e[1;31mQUIT\e[0;33m'
PATTERN_NEW=$'\e[1;31mNEW SEARCH PATERN\e[0;33m'
PATTERN_CLEAR=$'\e[1;31mCLEAR SEARCHES\e[0;33m'
and another array entries is coming from file:
readarray -t entries < ./file
content of file is raw text data:
option 1
option 4
option leg
option arm
option whatever
option blabla
so select block goes like:
select opt in "${MENU_OPTIONS[#]}" "${entries[#]}";
do
case "$opt" in
...)
;;
Bash mostly count the char in each option, regardless they are "displayable" or not. So, the escape code used to highlight some of your items false the display.
Here is an example:
sh$ for i in {1..12}; do OPTIONS[$i]=$(printf "option-%02d" $i); done
sh$ select i in "${OPTIONS[#]}"; do echo $i ; done
1) option-01 4) option-04 7) option-07 10) option-10
2) option-02 5) option-05 8) option-08 11) option-11
3) option-03 6) option-06 9) option-09 12) option-12
This is as expected. But if I highlight the 4th item:
sh$ OPTIONS[4]=$'\e[1;31moption-04\e[0;33m'
sh$ select i in "${OPTIONS[#]}"; do echo $i ; done
1) option-01 4) option-04 7) option-07 10) option-10
2) option-02 5) option-05 8) option-08 11) option-11
3) option-03 6) option-06 9) option-09 12) option-12
WORKAROUND
Well ... it's more a hack than a workaround. Really.
I add some extra spaces at the end of every option in order to widen the columns. Instead, I add a few \b at the end of the highlighted option (6 gave good results on my tests). I can't be more precise, since I wasn't able to clearly determine the rule to follow. You probably have to be prepared for trial and error...(thing are even more complicated by the fact Bash uses a mix of tab and space to indent the various options)
Anyway, this display properly on my system:
sh$ for i in {1..12}; do OPTIONS[$i]=$(printf "option-%02d " $i); done
# ^^^^^^^^
sh$ OPTIONS[4]=$'\e[1;31moption-04\e[0;33m\b\b\b\b\b\b'
# ^^^^^^^^^^^^
sh$ select i in "${OPTIONS[#]}"; do echo $i ; done
1) option-01 5) option-05 9) option-09
2) option-02 6) option-06 10) option-10
3) option-03 7) option-07 11) option-11
4) option-04 8) option-08 12) option-12
EDIT: I was puzzled by the fact in my example, the menu was off by 8 char. Doesn't match with the number of bytes in the various escape codes.
But, given the code from GNU bash 4.2 :
(execute_cmd.c)
static int
displen (s)
const char *s;
{
#if defined (HANDLE_MULTIBYTE)
wchar_t *wcstr;
size_t wclen, slen;
wcstr = 0;
slen = mbstowcs (wcstr, s, 0);
if (slen == -1)
slen = 0;
wcstr = (wchar_t *)xmalloc (sizeof (wchar_t) * (slen + 1));
mbstowcs (wcstr, s, slen + 1);
wclen = wcswidth (wcstr, slen);
free (wcstr);
return ((int)wclen);
#else
return (STRLEN (s));
#endif
}
It appears that if Bash is compiled with multibyte support, it converts the raw string using mbstowcs in order to calculate its length using wcswidth. Given my system has UTF-8 LC_CTYPE, probably mbstowcs misconverted the escape code as some Unicode character...
Following oracle query complies and works fine:
SELECT
Employee.EmployeeId,
Employee.EmployeeName,
Employee.Description,
Employee.IsFrozen
FROM
employee, employeerole, roledef
WHERE
employee.employeeid = employeerole.employeeid
AND employeerole.roleid = roledef.roleid
AND rolename IN (
CASE
WHEN (1 < 2) THEN ('Owner Role')
WHEN (2 < 1) THEN ('Eval Owner Role')
END);
Now in my case I would like to add in second when ie (2 < 1) two rolename('Owner Role' and 'Eval Owner Role').
Kindly suggest how will the above query change.
Thanks in advance.
-Justin Samuel
Why use a CASE? Why not simply
AND ( ( (1 < 2) and rolename IN ('Owner Role', 'Eval Owner Role') )
OR ( (2 < 1) and rolename IN ('Eval Owner Role') ) )
I am assuming that you don't actually have predicates that are hard-coded to evaluate to TRUE (1 < 2) or FALSE (2 < 1) and that those are actually bind variables in your actual code.
If you really want to use a CASE statement, you could code
AND( CASE WHEN (1 < 2) and rolename IN ('Owner Role', 'Eval Owner Role')
THEN 1
WHEN (2 < 1) and rolename IN ('Eval Owner Role')
THEN 1
ELSE 0
END) = 1
but that is going to be much more difficult for the optimizer to deal with and much less clear for the developer that has to maintain it.