how to join channels with a variable username (mirc) - code-snippets

simple question, i guess, but I'm fairly new to this, so maybe you can help me.
I made a bot for a chat, which i want to share with people.
So, my first thought was: i'll add a command (!join), which then will let the bot
join the specific channel. For some reason (i guess its due the operators), my join won't work.
Here is the snippet:
on *:TEXT:!join:#: {
var %name = $nick
;/msg $chan joining channel %name
/join #%nick
}
But it just won't connect. Any ideas?
If i just use /kick $nick (or %name), it works, so i guess this # is messing things up.
Thanks in advance

Try the following:
/join $chr(35) $+ %nick
Explanation: A variable name must be a word on its own in your line of code for it to be recognised as a variable name. Therefore, #%nick will be interpreted as the string #%nick, whereas %nick will be interpreted as the name of the user issuing the command.
To append the value of a variable or identifier, you can use the identifier $+ which appends strings together. For instance, a $+ b will return ab.
Another issue arises when you use # $+ %nick, because # is an alias for the identifier $chan. This means that if I were to type !join in #test, it would try to join #testPatrickdev. Instead of using #, I use $chr(35) (which will in turn return the character #). It appends that to the value of the variable %nick.

Use mIRC's $eval function, eg: $($+(#, %nick))

Related

Why use "?" instead of ":" in URL?

We can use
'PATCH /companies/:id' : 'CompanyController.find'
to update data.
One suggested me that I can use the alternative way:
'PATCH /companies/find?key=Value'
But I do not know what it works. Please explain me why we prefer ? mark than : mark in search path.
You can use either or. The biggest reason most people chose one or the other is just how they want to present the URL to the user.
Using a path variable (:) can symbolize you're accessing a defined resource, like a user ID, where as an argument (?) can symbolize you're are dynamically changing/searching something within a defined resource, like a token or search term.
From what I can tell that's the general practice I see:
example.com/user/:username
versus
example.com/user/?search="foo"
http://en.wikipedia.org/wiki/URL
If we are firing GET request, ? symbol is used to let the server know the url parameter variables starts from there. And this is commonly used. I didn't used : symbol instead of ?
You are probably messing the things up:
According to your example, :id indicates a variable that must me replaced by an actual value in some frameworks such as Express. See the documentation for details.
And ? indicates the beginning of the query string component according to the RFC 3986.
It's a rule to design rest api
you can find 'how to design a rest api'
Assuming below code is Sails.js
'PATCH /companies/:id' : 'CompanyController.find'
It will makes REST API that be mapped onto 'CompanyController.find' by using PathParam. Like this
www.example.com/companies/100
Second one will makes REST API by using QueryParam.
It also be mapped onto 'CompanyController.find'
/companies/find?key=Value
But the API format is different. Like this
www.example.com/companies/find?key=100
PathParam or QueryParam is fine to make REST API.
If the Key is primary for company entity,
I think PathParam is more proper than QueryParam.

Sql Server Full-Text Search with wild card suffix using Entity Framework 6 Interceptor

http://www.entityframework.info/Home/FullTextSearch
This example works fine for full word searches but does not talk about how to implement wild card suffix.
For example, I can do the following in SQL and get results for "bill" or "billy" using '*' in the end. How do I add that to my Interceptor?
select * from dbo.messagethread a
where contains(Text, '"bil*"')
If you look at that example code in that link above, I was thinking if something like this (below) is possible, but obviously that does not work as it is getting added to the parameter name not the value.
string.Format(#"contains([$1].[$2], #{0} *)", parameter.ParameterName));
There are questions like this one which talk about wildcards in full-text in SQL.
Look for this line in the example link provided in the question.
parameter.Value = value;
Then, to do prefix match, just add this line below that.
value = $"\"{value}*\""; // prefix match
We're basically changing the value of the parameter to have the * in it inside double quotes.
Now if you search for "bil", you get results for "bill"/"billy" and so on.

Identifier terminal except certain keywords

I'm using Irony framework and I have:
IdentifierTerminal variable = new IdentifierTerminal("variable");
a terminal for identifying an entry terminal.
This variable terminal can hold any string, except for a predefined list of reserved strings.
This identifier does not start or any with quotes or double quotes.
I want something like:
IdentifierTerminal variable = any contiguos string EXCEPT "event", "delegate";
How can I enforce this rule for this terminal?
Have you declared your keywords explicitly? If not, this page: https://en.wikibooks.org/wiki/Irony_-_Language_Implementation_Kit/Grammar/Terminals#Keywords will show you how. It seems that you don't need to explicitly say that an identifier cannot be a keyword, as the parser is able to figure this out. I found the following quote
Finally, in most cases, the Irony scanner does not need to distinguish between keywords and identifiers. It simply tokenizes all alpha-numeric words as identifiers, leaving it to the parser to differentiate them from each other. Some LEX-based solutions try to put too much responsibility on the scanner and make it recognize not only the token itself, but also its role in the surrounding context. This, in turn, requires extensive look-aheads, making the scanner code quite complex. In the author's opinion, identifying the token role is the responsibility of the parser, not the scanner. The scanner should recognize tokens without using any contextual information.
source: http://www.codeproject.com/Articles/22650/Irony-NET-Compiler-Construction-Kit

Problems getting data from XML using Nokogiri and Rails

I'm trying to get information from a XML file with Nokogiri. I can retrieve file using
f = File.open("/my/path/file.xml")
cac=Nokogiri::XML(f)
And what a get is a fancy noko:file. My row tags are defined like
<z:row ...info..../>
like
<Nokogiri::XML::Element:0x217e7b8 name="z:row" attributes=[#<Nokogiri::XML::Attr:0x217e754 name="ID_Poblacio" value="3">
and I cannot retrieve the rows using either:
s=cac.at_xpath("/*/z:row") or
s=cac.at_xpath("//z:row") or
s=cac.at_xpath("//row") or
s=cac.at_xpath("z:row")...
Probably I'm really fool but I cannot figure out which can be the issue.
Does anyone face this problem?
Thanks in advance.
P:S I tried to paste my cac file directly from bash but something wierd happens with format so I remove it from question. If anyone can explain how to do it I will appreciate it.
Your XML element name contains a colon, but it is not in a namespace (otherwise the prefix and uri would show up in the dump of the node). Using element names with colons without using namespaces is valid, but can cause problems (like this case) so generally should be avoided. Your best solution, if possible, would be to either rename the elements in your xml to avoid the : character, or to properly use namespaces in your documents.
If you can’t do that, then you’ll need to be able to select such element names using XPath. A colon in the element name part of an XPath node test is always taken to indicate a namespace. This means you can’t directly specify a name with a colon that isn’t in a namespace. A way around this is to select all nodes and use an XPath function in a predicate to refine the selection to only those nodes you’re after. You can use a colon in an argument to name() and it won’t be interpreted as a namespace separator:
s=cac.at_xpath("//*[name()='z:row']")

How to get regex to ignore URL strings?

I have the following Regexp to create a hash of values by separating a string at a semicolon:
Hash["photo:chase jarvis".scan(/(.*)\:(.*)/)]
// {'photo' => 'chase jarvis'}
But I also want to be able to have URL's in the string and recognize it so it maintains the URL part in the value side of the hash i.e:
Hash["photo:http://www.chasejarvis.com".scan(/(.*)\:(.*)/)]
// Results in {'photo:http' => '//www.chasejarvis.com'}
I want, of course:
Hash["photo:chase jarvis".scan(/ ... /)]
// {'photo' => 'http://www.chasejarvis.com'}
If you only want to match up to first colon you could change (.*)\:(.*) to ([^:]*)\:(.*).
Alternatively, you could make it a non-greedy match, but I prefer saying "not colon".
How do figure out a person's family name and first name?
Changing chasejarvis to chase and jarvis might not be possible unless you have a solution for that.
Do you already know everyone's name in your project? Nobody is having the initial of a middle name like charvisdjarvis (assuming the name is "Charvis D. Jarvis".)?

Resources