Print hosting default URL (or channel URL) with Firebase CLI - firebase-cli

The Firebase CLI tool can show me the default URLs of the hosting site(s) of a project in a human-readable format:
$ firebase hosting:sites:list
Sites for project <my-app>
┌──────────────────┬──────────────────────────────────┬─────────────────┐
│ Site ID │ Default URL │ App ID (if set) │
├──────────────────┼──────────────────────────────────┼─────────────────┤
│ my-app │ https://<my-app>.web.app │ -- │
└──────────────────┴──────────────────────────────────┴─────────────────┘
If I have multiple channels, it can also show me the URLs for each channel on a given site:
$ firebase hosting:channel:list
Channels for site <my-app>
┌────────────┬─────────────────────┬──────────────────────────────────┬─────────────┐
│ Channel ID │ Last Release Time │ URL │ Expire Time │
├────────────┼─────────────────────┼──────────────────────────────────┼─────────────┤
│ live │ 2022-10-27 15:06:54 │ https://<my-app>.web.app │ never │
└────────────┴─────────────────────┴──────────────────────────────────┴─────────────┘
But how do I print only the URL of a channel, for use in a shell script? (Without resorting to regexes.)

You can use a --json argument.
Combined with jq, you can retrieve a specific URL.
Example with live channel:
$ firebase hosting:channel:list --json |\
jq '.result.channels[]|select(.name|contains("live")) | .url'

There isn't any command that prints just the default URLs. The CLI uses a package cli-table and prints all the data together.
You can however use the Firebase Hosting REST API to list all the sites of a project and their channels and create a script or even better fork the Firebase CLI and add a new function alongside listSites() function of the CLI to print the URLs without the table.
The REST APIs response is just an array of sites so it should be pretty straightforward:
{
"sites": [
{
"name": "projects/<project_id>/sites/<site_id>",
"defaultUrl": "https://<project_id>.web.app",
"type": "DEFAULT_SITE"
}
]
}

Related

list all bazel targets in the directory

How can I put all targets from a package into one variable in a higher-level package?
I'm trying to create a simulation framework with the following architecture:
.
├── run_simulation.py
├──data
| ├── folder1
| │ ├── file_1.cvs
| │ ...
| │ └── file_k.csv
| ├── folder2
| │ ├── file_1.cvs
| │ ...
| │ └── file_k.csv
| └── BUILD
└── BUILD
the data/BUILD file consists of:
data_dirs = [
"folder1",
"folder2"
]
[
filegroup(
name = "my_cool_data_" + data_dir,
srcs = glob(["{}/*.csv".format(data_dir)]),
...
) for data_dir in data_dirs
]
and produce a target with experimental data per a folder.
I'd like to run the script run_simulation.py with inputs from folders in the data directory with a command like:
$ bazel run run_simulation_<data target name>
so I have to add to the ./BUILD file
data_targets=[*do smth to get all targets from data/BUILD file*]
[
py_binary(
name = "run_simulation_" + data_target,
...
data = ["//data:{}".format(data_target)],
...
) for data_target in data_targets
]
The problem is how can I put all targets from the data package into a variable in the ./BUILD file? I couldn't find a way to do this in the official documentation.

URL parts canonical terminology

I've been reading around and it seems there is no very well coherent and fully accepted terminology for the URL parts. Is that true? I'd like to know which standards exists for URL parts terminology. What is the most common? Is there any well established standard?
I found the following:
RFC3986 section 3
foo://example.com:8042/over/there?name=ferret#nose
\_/ \______________/\_________/ \_________/ \__/
| | | | |
scheme authority path query fragment
| _____________________|__
/ \ / \
urn:example:animal:ferret:nose
window.location from Javascript on browsers
protocol://username:password#hostname:port/pathname?search#hash
-----------------------------href------------------------------
-----host----
----------- origin -------------
protocol - protocol scheme of the URL, including the final ':'
hostname - domain name
port - port number
pathname - /pathname
search - ?parameters
hash - #fragment_identifier
username - username specified before the domain name
password - password specified before the domain name
href - the entire URL
origin - protocol://hostname:port
host - hostname:port
NodeJS, module url
Above the line with the URL you see node's url module old API, whilst under the line you see the new API. It seems node shifted from a RFC standard terminology to a more browser friendly standard terminology, that is, similar to browser's windows.location.
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ href │
├──────────┬──┬─────────────────────┬────────────────────────┬───────────────────────────┬───────┤
│ protocol │ │ auth │ host │ path │ hash │
│ │ │ ├─────────────────┬──────┼──────────┬────────────────┤ │
│ │ │ │ hostname │ port │ pathname │ search │ │
│ │ │ │ │ │ ├─┬──────────────┤ │
│ │ │ │ │ │ │ │ query │ │
" https: // user : pass # sub.example.com : 8080 /p/a/t/h ? query=string #hash "
│ │ │ │ │ hostname │ port │ │ │ │
│ │ │ │ ├─────────────────┴──────┤ │ │ │
│ protocol │ │ username │ password │ host │ │ │ │
├──────────┴──┼──────────┴──────────┼────────────────────────┤ │ │ │
│ origin │ │ origin │ pathname │ search │ hash │
├─────────────┴─────────────────────┴────────────────────────┴──────────┴────────────────┴───────┤
│ href │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
Highly ranked article from Matt Cutts
URL: http://video.google.co.uk:80/videoplay?docid=-7246927612831078230&hl=en#00h02m30s
The protocol is http. Other protocols include https, ftp, etc.
The host or hostname is video.google.co.uk.
The subdomain is video.
The domain name is google.co.uk.
The top-level domain or TLD is uk. The uk domain is also referred to as a country-code top-level domain or ccTLD. For google.com, the TLD would be com.
The second-level domain (SLD) is co.uk.
The port is 80, which is the default port for web servers. Other ports are possible; a web server can listen on port 8000, for example. When the port is 80, most people leave out the port.
The path is /videoplay. Path typically refers to a file or location on the web server, e.g. /directory/file.html
This URL has parameters. The name of one parameter is docid and the value of that parameter is 7246927612831078230. URLs can have lots parameters. Parameters start with a question mark (?) and are separated with an ampersand (&).
Some of my concerns:
Is window.location a standard or based on a standard?
Shall I call http:// the protocol or the scheme?
Shall I say host or authority?
Why nor window.location nor node have properties for TLD or other domain parts, when available?
The terminological difference between hostname (example.com) and
host (example.com:8080) is well established?
for node origin does not include username:password# whilst for windows.location it does
I'd like to follow on my code a well established standard or best practises.
The URI standard is STD 66. This is currently mapped to RFC 3986.
So for the generic URI syntax, these terms are authoritative, currently:
scheme
authority
userinfo
host
port
path
query
fragment
Terminology depends on which architectural style/technology you are using.
I prefer REST style for identifying different parts of my url REST URI Standard
But I repeat again there are no single universal standard to represent URL
Java java.net.URL follows RFC 2396 which is an older version of RFC 3986.
Python's urlparse also follows RFC 3986, except for using netloc instead of authority possibly for legacy reasons.
In other words, I'd follow RFC 3986.

Alloy programming for example network configuration

Suppose there are 8 pcs and 1 switch, I want to divide three subnets.how to use alloy language program?Can you give an example?
The following models a small network.
sig IP {}
some sig Subnet {
range : some IP
}
abstract sig Node {
ips : some IP
}
sig Router extends Node {
subnets : IP -> lone Subnet
} {
ips = subnets.Subnet
all subnet : Subnet {
lone subnets.subnet
subnets.subnet in subnet.range
}
}
sig PC extends Node {} {
one ips
}
let routes = { disj s1, s2 : Subnet | some r : Router | s1+s2 in r.subnets[IP] }
let subnet[ip] = range.ip
let route[a,b] = subnet[a]->subnet[b] in ^ routes
fact NoOverlappingRanges { all ip : IP | one range.ip }
fact DHCP { all disj a, b : Node | no (a.ips & b.ips) }
fact Reachable { all disj a, b : IP | route[a,b] }
run {
# PC = 8
# Subnet = 3
# Router = 1
} for 12
If you run it:
┌───────────┬────────────┐
│this/Router│subnets │
├───────────┼────┬───────┤
│Router⁰ │IP² │Subnet¹│
│ ├────┼───────┤
│ │IP³ │Subnet⁰│
│ ├────┼───────┤
│ │IP¹¹│Subnet²│
└───────────┴────┴───────┘
┌───────────┬─────┐
│this/Subnet│range│
├───────────┼─────┤
│Subnet⁰ │IP³ │
│ ├─────┤
│ │IP⁴ │
├───────────┼─────┤
│Subnet¹ │IP¹ │
│ ├─────┤
│ │IP² │
│ ├─────┤
│ │IP⁵ │
│ ├─────┤
│ │IP⁶ │
│ ├─────┤
│ │IP⁷ │
│ ├─────┤
│ │IP⁸ │
│ ├─────┤
│ │IP⁹ │
│ ├─────┤
│ │IP¹⁰ │
├───────────┼─────┤
│Subnet² │IP⁰ │
│ ├─────┤
│ │IP¹¹ │
└───────────┴─────┘
┌─────────┬────┐
│this/Node│ips │
├─────────┼────┤
│PC⁰ │IP¹⁰│
├─────────┼────┤
│PC¹ │IP⁹ │
├─────────┼────┤
│PC² │IP⁸ │
├─────────┼────┤
│PC³ │IP⁷ │
├─────────┼────┤
│PC⁴ │IP⁶ │
├─────────┼────┤
│PC⁵ │IP⁵ │
├─────────┼────┤
│PC⁶ │IP⁴ │
├─────────┼────┤
│PC⁷ │IP¹ │
├─────────┼────┤
│Router⁰ │IP² │
│ ├────┤
│ │IP³ │
│ ├────┤
│ │IP¹¹│
└─────────┴────┘
You'd probably like to see what PCs are assigned to what subnet. Then go to the evaluator and type:
ips.~range
┌───────┬───────┐
│PC⁰ │Subnet¹│
├───────┼───────┤
│PC¹ │Subnet¹│
├───────┼───────┤
│PC² │Subnet¹│
├───────┼───────┤
│PC³ │Subnet¹│
├───────┼───────┤
│PC⁴ │Subnet¹│
├───────┼───────┤
│PC⁵ │Subnet¹│
├───────┼───────┤
│PC⁶ │Subnet⁰│
├───────┼───────┤
│PC⁷ │Subnet¹│
├───────┼───────┤
│Router⁰│Subnet⁰│
│ ├───────┤
│ │Subnet¹│
│ ├───────┤
│ │Subnet²│
└───────┴───────┘
Disclaimer: This was quickly hacked together so there might be modeling errors.
Alloy is a modelling language used mainly to reason about designs. So Forget about "programming".
What you can do in Alloy is to define the general rules of how pc, switch and subnets relate to each other. You can then verify if those rules allow to divide those pc into three subnets, and if the division match your expecations. In the case it does not, congrats, you have found a "bug" in your specification, solving it will improve your understanding of the constraints inherent to the system you are currently modelling.

angular-rails-templates ng-include infinite digest

I'm using angular-rails-templates and trying to use ng-include each time I try to use it, I get an infinite digest.
My folder structure is as follows:
├── app
│ ├── assets
│ │ ├── javascripts
│ │ ├── templates
│ │ | ├── include.html
| ├── views
│ │ ├── layouts
│ │ | ├── application.html.erb
application.html.erb
<div ng-include="'assets/templates/include.html'"></div>
I've tried all sorts of variations, including no single quotes, just include.html, templates/include.html but they all throw me into an infinite digest. Am I missing something simple?

How to generate Identicon in Delphi

I've been given the task to implement Identicon using Delphi. I have searched the internet and still did not find anything.
so where do I begin, is there someone here who can give an explanation?
This is just an explanation to give you the idea of the Identicons.
Identicons are graphical representations of a bunch of bytes most likely a hash value.
Lets take a sample MD5 hash value (16 bytes)
abf5787309f3c4d5b255237c0b67dd5e
Ok let them arrange in a different way
ab f5 78 73
09 f3 c4 d5
b2 55 23 7c
0b 67 dd 5e
Now we have 16 fields each representing a byte. So we could build an image with 256 different small images. But maybe we can break it down to a less complicated method.
Lets take one byte (the first one ab) and its binary representation
10101011
Ok, let them arrange in a different way :o)
10 10
10 11
Now we have 4 fields and each field can have one of four states. And that is very easy to manage 4 different images.
00 = empty
01 = /
10 = \
11 = X
Back to our byte we will get this
┌─────┐
│ \ \ │
│ \ X │
└─────┘
And back to the whole we get
┌─────┬─────┬─────┬─────┐
│ \ \ │ X X │ / X │ / X │
│ \ X │ / / │ \ │ X │
├─────┼─────┼─────┼─────┤
│ │ X │ X │ X / │
│ \ / │ X │ / │ / / │
├─────┼─────┼─────┼─────┤
│ \ X │ / / │ \ │ / X │
│ \ │ / / │ X │ X │
├─────┼─────┼─────┼─────┤
│ │ / \ │ X / │ / / │
│ \ X │ / X │ X / │ X \ │
└─────┴─────┴─────┴─────┘
The whole point here is reduction into easy to handle small parts.
I once started to port the original library to Delphi / Graphics32. However, I never found the time to finish the small project until now. The source code together with a sample application can be found on my website (see Delphi -> Graphics32).
Originally it was meant to show some new vector graphic features from the upcoming version 2.0. Despite the fact, that this has still not been released, the source code can already be compiled with the code in the trunk repository.

Resources