Absolute vs relative vs "slash" URL? - url

If this full URL:
http://domain.com/dir/file.css
Is an "absolute URL", where the link will work from any website.
And this:
../dir/file.css
Is a "relative URL", where the link will only work from that directory path.
What is the combination of those two called…
/dir/file.css
Where the link will work from any location on that site?

Your first example is a URL. Your second and third examples are not URLs, they're paths. If the path begins with / then it's an absolute path, otherwise it's a relative path.
Web browsers generally understand how to interpret a path in relation to the "current" host and path.

You’re basically talking about a URI scheme. In your example:
/dir/file.css
This is considered the path:
/dir/
And this is the filename:
file.css
So saying “hostname plist path & filename” is a safe bet. Or perhaps /dir/file.css can be considered the root path since the / at the beginning anchors it to the hostname part of the URL.
This diagram from Wikipedia explains it well:
foo://username:password#example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose
\_/ \_______________/ \_________/ \__/ \___/ \_/ \______________________/ \__/
| | | | | | | |
| userinfo hostname port | | query fragment
| \________________________________/\_____________|____|/ \__/ \__/
| | | | | | |
| | | | | | |
scheme authority path | | interpretable as keys
name \_______________________________________________|____|/ \____/ \_____/
| | | | | |
| hierarchical part | | interpretable as values
| | |
| path interpretable as filename |
| ___________|____________ |
/ \ / \ |
urn:example:animal:ferret:nose interpretable as extension
path
_________|________
scheme / \
name userinfo hostname query
_|__ ___|__ ____|____ _____|_____
/ \ / \ / \ / \
mailto:username#example.com?subject=Topic

Related

Include path has been specified but still failed to include the header in the path in a Bazel C++ project

I have projects with a directory structure like that
---root
| |--src
| |--project1
| |--model
| | |--incude
| | | |--model
| | | |--modelA.hpp
| | | |--modelB.hpp
| | |--modelA.cpp
| | |--modelB.cpp
| | |--BUILD #1
| |...
| |--view
| |...
| |--common
| | |--include
| | |--common
| | |--data_type.hpp
| |--BUILD #2
|--WORKSPACE
As I have other package in this project and some of them use the same self-defined data type, I defined them in a package named common.
Now I include the data_type.hpp in file modelA.hpp
...
#include "common/data_type.hpp
...
Refering to the stage3 example in the tutorial, the BUID(#1) is like that
cc_library(
name = "modelA",
hdrs = "include/model/modelA.hpp",
deps = ["//src/project/common:data_type"],
copts = ["-Isrc/project/common/include"],
)
and the BUILD(#2) which defines the depedency module data_typeis like that
cc_library(
name = "data_type",
hdrs = ["include/common/data_type.hpp"],
visibility = ["//visibility:public"],
)
However, when I built the code, I got
src/project/model/include/model/modelA.hpp: fatal error: common/data_type.hpp: No such file or directory
Why I have defined copts = ["-Isrc/heimdallr/common/include"] but still got this error?
Please check the Header inclusion checking section of C/C++ Rules from the Bazel document. Relative to the workspace directory, all include paths should be created. Kindly refer to this issue for more information. Thank you!

ROS services are not building properly

I am trying to build my custom ROS services. They are inside a another parent package
the structure is as follows:
|--catkine_ws
| |--src
| | |--Parent
| | | |--CMakeLists.txt
| | | |--package.xml
| | | |--ChildA
| | | | |--CMakeLists.txt
| | | | |--package.xml
| | | | |--srv
| | | | | |--SomeService.srv
| | | |--ChildB
The packages are building correctly and I am able to use them in other nodes and packags.
however when I try to use rossrv list the custom services do not appear. I think that this is causing some issues when I try to build my Simulink controller and it cannot find the service message definition.
Does any one have any idea what is going on?
I was able to fix the problem, while not obvious, the solution was rather simple. I had to change the slightly change the structure of the package by making the parent package a meta package then do some handling to make sure that the sub packages still had access to the cmakes to locate my external packages.

Alternative of grep in lua script

I have the following text file output.txt that I created (it has 15 colums including symbol | ):
[66] | alert:n | 3.0 | 10/22/2020-14:45:50.066928 | local_ip | 123.123.123.123 | United States of America | SURICATA STREAM ESTABLISHED SYNACK resend with different ACK
[67] | alert:n | 3.0 | 10/22/2020-14:45:51.096955 | local_ip | 12.12.12.11 | United States of America | SURICATA STREAM ESTABLISHED SYNACK resend with different ACK
[68] | alert:n | 3.0 | 10/22/2020-14:45:53.144942 | 123.123.123.123 | local_ip | United States of America | SURICATA STREAM ESTABLISHED SYNACK resend with different ACK
[69] | alert:n | 3.0 | 10/22/2020-14:45:57.176956 | local_ip | 68.73.203.109 | United States of America | SURICATA STREAM ESTABLISHED SYNACK resend with different ACK
[70] | alert:n | 3.0 | 10/22/2020-14:46:05.240953 | 123.123.123.123 | local_ip | United States of America | SURICATA STREAM ESTABLISHED SYNACK resend with different ACK
[71] | alert:n | 3.0 | 10/22/2020-14:46:21.624979 | local_ip | 68.73.203.109 | United States of America | SURICATA STREAM ESTABLISHED SYNACK resend with different ACK
I'm familiar with the bash script, let say if I want to count total specific ip of 123.123.123.123 that can be found in the 9th column, I can implement like this:
#!/bin/bash
ip = "123.123.123.123"
report = output.txt
src_ip_count=$(grep "${ip}" "${report}" | awk '{ print $9 }' | grep -v "local_ip" | uniq -c | awk '{ print $1 }')
and the output is:
[root#me lua-output]# ./test.sh
2
How do I implement the same code above in lua ? I know there is popen function can be used.. but is there a native way to do this in lua ? Also if I use popen, I also need to pass variable $ip and $report inside that command which I'm not sure if it's possible.
There's a bunch of ways to go about this, really. Assuming you read your data from stdin (though the same works for any file you manually open), you can do something like this:
local c = 0
for line in io.lines() do -- or or file:lines() if you have a different file
if line:find("123.123.123.123") -- Only lines containing the IP we care about
if (true) -- Whatever other conditions you want to apply
c = c + 1
end
end
end
print(c)
Lua doesn't have a concept of what a "column" is, so you have to build that yourself as well. Either use a pattern to count spaces, or split the string into a table and index it.
You mentioned that if it is possible to use variable inside popen in lua. It is possible, and you can use grep command in lua.
So in lua you can do this:
-- lua script using grep example
ip = "123.123.123.123"
report = output.txt
local cmd = "grep -F " .. ip .. " " .. report .. " | awk '{ print $9 }' | grep -v 'local_ip' | uniq -c | awk '{ print $1 }'"
local handle = io.popen(cmd)
local src_ip_count = handle:read("*a")
print(src_ip_count)
handle:close()
output:
2

How to get MultiMarkDown to view tables in Sublime Text 2 OSX

I am trying to avoid using inline HTML to get tables working in my MD file. I have Markdown Preview and Table Editor installed via the package installer, and multimarkdown installed via homebrew, but I can't get the following text to display as a table:
| Left align adsf | Right align | Center align |
| :--------------- | ----------: | :----------: |
| This | This | This |
| column | column | column |
| will | will | will |
| be | be | be |
| left | right | center |
| aligned | aligned | aligned |
When I "Markdown Preview" it just displays like this:
| | | Left align adsf | Right align | Center align | | --- | --- | ---------------- | ----------- | ------------ | | | | ---------------s | ----------- | ------------ | | --- | --- | :--------------- | ----------: | :----------: | | | | This | This | This | | | | column | column | column | | | | will | will | will | | | | be | be | be | | | | left | right | center | | | | aligned | aligned | aligned |
I have switched the file type to MultiMarkdown (lower right portion of ST2 screen)
I have searched, and it appears some people have a build system, or other approaches I have been unable to get going. What am I missing? If a build system is needed, how do I set up one? I am mainly interested in viewing this in HTML, but wouldn't be opposed to other ways....
If you switch the parser to github, it'll work just fine.
Go to Prefrences > Package Settings > Markdown Preview > Settings - User and paste this code:
{
"parser": "github"
}
"If a build system is needed, how do I set up one?"
In OS X I would strong suggest getting the excellent Marked.app and then setting up a new build system in ST containing this trivial code
{
"osx": {"cmd": ["open", "-a", "Marked", "$file"]},
"selector": "text.html.markdown"
}
Then when you 'build' a markdown file (Cmd+B) you will get a preview generated in Marked.
Easy and elegant and well worth the cup-of-coffee price of Marked to avoid all the hassle of the plugin approach.

Porting code to Pharo 2.0

Pharo 2.0 changed some basic API bits, and I cannot found the new way of doing the following:
FileDirectory default directoryNamed: aFolderString.
FileDirectory on: aFilename.
FileDirectory default assureExistenceOfPath: aString.
ReferenceStream on: stream.
What would be the new equivalent code?
Is there an update guide available describing how to translate or port code?
The following statements correspond do the ones you put in your question.
FileSystem workingDirectory / aFolderString
aFilename asFileReference
aString asFileReference ensureDirectory
ReferenceStream does no longer exist in 2.0.
aPathString asFileReference resolves aPathString, so if there are slashes in your name you will end up in a subdirectory.
/ on the other hand takes a single directory or file name as an argument, and does not resolve further subdirectories. Depending on your platform you can easily refer to a file named foo/bar with a slash in the name with FileSystem workingDirectory / 'foo/bar'.
I have collected some translations you may find useful:
+------------------------------------------------------+---------------------------------------------------------------------------+
| FileDirectory | FileSystem |
+------------------------------------------------------+---------------------------------------------------------------------------+
| FileDirectory assureExistence. | aString asFileReference ensureDirectory. |
| FileDirectory baseNameFor: aString. | aString asFileReference base. |
| FileDirectory containingDirectory. | Path parent asFileReference pathString. |
| FileDirectory default deleteFileNamed: aString. | aString asFileReference ensureDeleted. |
| FileDirectory default directoryExists: aString. | aString asFileReference exists. |
| FileDirectory default directoryNamed: aFolderString. | FileSystem disk / aFolderString. |
| FileDirectory directoryEntryFor: aString. | aString asFilereference. |
| (FileDirectory entryFor: aString) / 'filename'. | aString asFileReference / 'filename'. |
| FileDirectory extensionFor: aString. | aString asFileReference extension. |
| FileDirectory default fileExists: aString. | aString asFileReference exists. " or " DiskStore current isFile: aString. |
| FileDirectory default fullNameFor: aString. | aString asFileReference fullName. |
| FileDirectory default pathName. | FileSystem disk workingDirectory fullName. |
| FileDirectory on: aFilename. | aFilename asFileReference. |
| (FileDirectory on: aString) entries collect: #name. | aString asFileReference children collect: #basename. |
| (FileDirectory on: aString) entryAt: 'filename'. | aString asFileReference / 'filename'. |
| FileDirectory oldFileNamed: aString. | aString asFileReference readStream. |
| FileDirectory slash. | FileSystem disk separator. " or " DiskStore delimiter asString. |
+------------------------------------------------------+---------------------------------------------------------------------------+
ReferenceStream is not supported anymore and has been deleted in Pharo 2.0. You should use Fuel which is well written, well documented, well tested and very fast. http://rmod.lille.inria.fr/web/pier/software/Fuel

Resources