How to set to redis value if the value contain multiline? - redis

I am not able to set multiline value to redis? is there any better way to do?

I found the answer.
Just do like
printf "*3\r\n\$3\r\nset\r\n\$3\r\nfoo\r\n\$15\r\nMyGroup\r\nGroupA\r\n" | nc localhost 6379
* Specify the rows
\$ count the character

Related

How to put multiple charsets at one position in hashcat?

I want to search for all letters and some special characters at the same time
?ludhHs?ludhHs?ludhHs?ludhHs?ludhHs?ludhHs?ludhHs?ludhHs?lludhHs
Something like this for a 9 Letter password with all characters. Does this work?
It sounds like you want to use the built-in charset ?a, which is a shortcut for ?l?u?d?s.
Try out this command:
hashcat -a 3 -m 0 your.hash ?a?a?a?a?a?a?a?a?a
Don't forget to swap out the mode and hash file for whatever you are cracking.
If you really were trying to use a custom charset with ?l and the characters udhHs, that's mostly redundant since ?l is already all the lowercase letters, but here's an example for that custom charset:
hashcat -a 3 -1 ?ludhHs -m 0 your.hash ?1?1?1?1?1?1?1?1?1

redis. how set key name with empty string (not empty value)

I'm making Redis client with swift.
How can i make key name with empty string. (not empty value)
in redis-cli.
I can make key name with empty string.
127.0.0.1:6379> set "" "stringValue"
OK
but, I am using socket to connect Redis server.
and send command, I got error.
telnet 127.0.0.1 6379
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
set "" "stringValue"
-ERR wrong number of arguments for 'set' command
please help me.
You used the inline command to send command to Redis, which does not work with binary data, or data which has 0 length or contains whitespace.
Instead, you should use the more complicated form: *3\r\n$3\r\nset\r\n$0\r\n\r\n$3\r\nval\r\n
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
*3
$3
set
$0
$3
val
+OK

What does :/= mean in %date:/=%?

While searching for a way to create a date-named directory in Windows, I came accross this question with that accepted answer.
There's a comment below the accepted answer:
To make it more easy: mkdir %date:/=%
So, %date% prints the current date, but what does :/= do?
It means substitute for the string between the : and the = with the string after the = and before the closing %
So it strips out any / from the variable %date% which is set by default to the current date.
The form of the command is
%variable:text=replace%
and it removes text and inserts replace in the same spot.
In your case the replace is empty so it just removes any / characters from the date string.

sed/awk + regex delete duplicate lines where first field matches (ip address)

I need a solution to delete duplicate lines where first field is an IPv4 address.For example I have the following lines in a file:
192.168.0.1/text1/text2
192.168.0.18/text03/text7
192.168.0.15/sometext/sometext
192.168.0.1/text100/ntext
192.168.0.23/othertext/sometext
So all it matches in the previous scenario is the IP address. All I know is that the regex for IP address is:
\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b
It would be nice if the solution is one line and as fast as possible.
If, the file contains lines only in the format you show, i.e. first field is always IP address, you can get away with 1 line of awk:
awk '!x[$1]++' FS="/" $PATH_TO_FILE
EDIT: This removes duplicates based only on IP address. I'm not sure this is what the OP wanted when I wrote this answer.
If you don't need to preserve the original ordering, one way to do this is using sort:
sort -u <file>
The awk that ArjunShankar posted worked wonders for me.
I had a huge list of items, which had multiple copies in field 1, and a special sequential number in field 2. I needed the "newest" or highest sequential number from each unique field 1.
I had to use sort -rn to push them up to the "first entry" position, as the first step is write, then compare the next entry, as opposed to getting the last/most recent in the list.
Thank ArjunShankar!

SSMS and SQLCMD displays only the first 8000 characters

In SSMS when I try to execute:
SELECT CONVERT(VARCHAR(MAX), REPLICATE('a',9000))
I see only the first 8000 characters displayed. The settings Tool >> Options >> Query Results >> Sql Server >> Results to Grid is set to 65534 and Results to Text is set to 8192.
Also when I try to run this from SQLCMD
sqlcmd -S Server -E -y 0 -Q "SELECT CONVERT(VARCHAR(MAX), REPLICATE('a',9000))" -o out.txt
I see only 8000 charecters.
The flag -y 0 is supposed to set it up to 1 MB. But I do not more than 8000 characters.
What could be the problem?
thanks,
_UB
REPLICATE output is based on the datatype input. So this explains sqlcmd.
If string expression is not of type varchar(max) or nvarchar(max),
REPLICATE truncates the return value
at 8,000 bytes. To return values
greater than 8,000 bytes,
string expression must be explicitly
cast to the appropriate large-value
data type.
So, use this SELECT REPLICATE(CONVERT(VARCHAR(MAX), 'a'), 9000)
And SSMS has never shown all text data (nor did Query Analyzer)
See here :
http://www.sqlservercentral.com/articles/varchar(max)/67057/
VARCHAR(MAX) is only capable of holding 8000 characters
see here
From MSDN:
varchar [ ( n | max ) ] -
Variable-length, non-Unicode character
data. n can be a value from 1 through
8,000. max indicates that the maximum
storage size is 2^31-1 bytes
As Joseph (below) says, to hold more, use a text or ntext data type, but if you want to be able to search that, then you'd need some form of full-text indexing enabled.
Better Link