App-Cheats
view release on metacpan or search on metacpan
- crictl
- Interacts with CRI compatible tools.
- Not ideal for making containers.
- kubectl is unaware of its usage and may delete pods made using this tool.
- crictl pull ...
- crictl images
- crictl ps -a
- crictl exec -it ... ls
- crictl logs ...
- crictl pods
- crictl --runtime-endpoint (?)
- For DEBUGGING.
# Pods recap (CKAD)
Pod
- Smallest possible creatable object.
kubectl (k)
k run nginx --image nginx
k get pods
# Pods with yaml (CKAD)
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onload = function() { // <== Difference
document.getElementById("demo").innerHTML = this.responseText;
};
xhttp.open("GET", "ajax_info.txt", true);
xhttp.send();
}
# Submit a form using ajax. (prevents auto reload)
function save_details(endpoint) {
console.log("POST ", endpoint);
const form = document.querySelector("form[id=details]");
const xhttp = new XMLHttpRequest();
xhttp.open("POST", endpoint);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.send( $("#details").serialize() );
}
#############################################################
## Javascript - Attributes
#############################################################
# Set/Get meta data for an HTML element
# Output a table from data in Chrome console
console.table([{a:1,b:2},{a:3,b:4},{b:5,a:2}])
#############################################################
## JQuery - Ajax
#############################################################
# Submit a form using ajax. (structured format,compact)
function submit_form(file_root_name) {
const endpoint = "/my_endpoint";
console.log("POST ", endpoint);
$.ajax({
url: endpoint,
headers: {
'Content-type': 'application/x-www-form-urlencoded',
},
method: 'POST',
data: $("#id").serialize(),
});
}
# GET request using ajax
$.ajax({
# Create a simple mojo server and connect to it.
perl -Mojo -E 'say a("/status" => {text => "Active!"})->start("daemon", "-l", "http://*:8088")'
perl -Mojo -E 'a("/hello" => { text => "Welcome!" } )->start' get /hello
#
perl -Mojo -E 'a("/hello" => { text => "Welcome!" } )->start' daemon
perl -Mojo -E 'say a("/hello" => {text => "Hello Mojo!"})->start("daemon")'
perl -Mojo -E 'say a("/hello" => {text => "Hello Mojo!"})->start("daemon", "-l", "http://*:8080")'
mojo get http://127.0.0.1:3000/
#
# View local files on an endpoint:
perl -Mojo -E 'say a("/" => {text => "Hello Mojo!"}); a("ls" => sub{ my @files = glob "*/*"; $_->render( json => \@files) } )->start("daemon")'
mojo get http://127.0.0.1:3000/ls
#
# Show a message on connection.
perl -Mojo -E 'a("/" => sub{ say $_->req->to_string; $_->render( text => "123") })->start' daemon
# View available routes in a mojo server
perl -Mojo -E 'a("/hello" => { text => "Welcome!" } )->start' routes
# Easily create several routes.
#############################################################
## Python Modules - json
#############################################################
# Using json in a python webserver
#
import json
class Server:
def info(self):
try:
return json.dumps(possible_endpoints)
except KeyError:
return bottle.HTTPError(404, "Error occurred")
#############################################################
## Python Modules - logging
#############################################################
# Log format to use for the logger
log_format = '%(asctime)s %(levelname)s %(module)s.%(funcName)s:%(lineno)d %(message)s'
( run in 0.308 second using v1.01-cache-2.11-cpan-b61123c0432 )