Jason Yau May 16, 2022 [Features] #Markdown
This article shows various Code Blocks allowing to easily compare sublime themes.
Code Blocks
Code blocks.. ❤️ with automatic syntax highlighting ✨
See the docs for options.
Inline Code block
If we want, we can also specify inline code
which is useful for the small stuff
.
rust
1 | |
2 |
|
3 | use jelly::actix_web;
|
4 | use mainlib;
|
5 | use std::io;
|
6 |
|
7 | #[actix_web::main]
|
8 | async fn main() -> io::Result<()> {
|
9 | mainlib::main().await
|
10 | }
|
11 |
|
12 | let context = Context::new();
|
TOML
1 | base_url = "https://abridge.netlify.app/"
|
2 | title = "Abridge"
|
3 | description = "Abridge is a fast and lightweight Zola theme using semantic html, abridge.css class-light CSS, and No Mandatory JS."
|
4 | default_language = "en"
|
5 |
|
6 |
|
7 | build_search_index = true
|
8 | minify_html = false
|
9 | feed_filename = "atom.xml"
|
10 | taxonomies = [
|
11 | {name = "categories", feed = true},
|
12 | {name = "tags", feed = true},
|
13 | ]
|
html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example HTML5 Document</title>
</head>
<body>
<p>Test</p>
</body>
</html>
javascript
function closeSearch() {
const e = document.querySelector("main");
e.innerHTML = window.main
}
function goSearch() {
const e = document.querySelector("main");
window.main || (window.main = e.innerHTML);
var t = document.getElementById("suggestions"),
n = ((ResultsClone = t.cloneNode(!0)).id = "results", document.createElement("div")),
o = '<h2><button type="button" title="Close Search" onclick="closeSearch()"><i class="svgs x"></i></button> Results For: '.concat(document.getElementById("searchinput").value, "</h2>");
return n.innerHTML = o, ResultsClone.insertBefore(n, ResultsClone.firstChild), e.innerHTML = ResultsClone.outerHTML, t.innerHTML = "", document.getElementById("searchinput").value = "", !1
}! function() {
}
php
<?php
require_once('common.php');
$CONF = Config::getInstance()->getAll();
if ($_SERVER['REQUEST_METHOD'] == "POST") {
if (!isset($_SESSION['PFA_token'])) {
die("Invalid token (session timeout; refresh the page and try again?)");
}
$fUsername = trim(safepost('fUsername'));
if ($lang != check_language(false)) { setcookie('lang', $lang, time() + 60*60*24*30); }
}
$_SESSION['PFA_token'] = md5(uniqid("pfa" . rand(), true));
json
{
"name": "Abridge Zola Theme",
"short_name": "Abridge",
"description": "Fast & Lightweight Zola Theme",
"start_url": "/index.html",
"scope": "/",
"background_color": "#111111",
"theme_color": "#222222",
"display": "standalone",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
},
{
"src": "/android-chrome-192x192m.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
}
]
}
SQL
create or replace function update_timestamp() returns trigger as $$
begin
new.updated = now();
return new;
end;
$$ language 'plpgsql';
create table if not exists accounts (
id serial primary key,
name text not null,
email text not null unique,
password text not null,
profile jsonb not null default '{}',
plan integer not null default 0,
is_active boolean not null default true,
is_admin boolean not null default false,
has_verified_email boolean not null default false,
last_login timestamp with time zone,
created timestamp with time zone not null default now(),
updated timestamp with time zone not null default now()
);
create unique index accounts_unique_lower_email_idx on accounts (lower(email));
create trigger user_updated before insert or update on accounts
for each row execute procedure update_timestamp();
Lua
function square(x)
return x * x
end
print(square(2))
function getPlayerInformation()
playerName = UnitName("player")
playerLevel = UnitLevel("player")
specId, specName = GetSpecializationInfo(GetSpecialization())
return "Hey, I'm " .. playerName .. " (Level " .. playerLevel .. "). I'm currently in spec " .. specName .. "."
end
print(getPlayerInformation())
C
#include <stdio.h>
int main() {
int a;
a = 10;
printf("Hello, World!");
return 0;
}
C++
#include <iostream>
int main() {
int a;
a = 10;
std::cout << "Hello World!";
return 0;
}
Go
package main
import "fmt"
func main() {
var myvariable1 = 20
var myvariable2 = "hello world"
fmt.Println("hello world")
}
Python
import smtplib, socket
from influxdb import InfluxDBClient
while True:
send = 1
later = time.time() + 25200
iso = time.ctime(later)
tempF = round(bme280.temperature * 1.8 + 29, 3) humidity = round(bme280.humidity, 3)
pressure = round(bme280.pressure, 3)
data = [
{
"measurement": measurement,
"tags": {
"location": location,
},
"time": iso,
"fields": {
"temperature" : tempF,
"humidity": humidity,
"pressure": pressure
}
}
]
try:
client.write_points(data)
except socket.error as e:
print("Could Not Connect to InfluxDB!")
if tempF > 90 and humidity > 55:
emailSubject = "Humidity>55: " + str(int(humidity)) + "%H , Temperature>90: " + str(int(tempF)) + "F"
emailContent = 'Humidity: ' + str(int(humidity)) + '%H , Temperature: ' + str(int(tempF)) + 'F <a href="https://metrics.example.com">Dashboard</a>'
elif humidity > 55:
emailSubject = "Humidity>55: " + str(int(humidity)) + "%H"
emailContent = 'Humidity: ' + str(int(humidity)) + '%H , Temperature: ' + str(int(tempF)) + 'F <a href="https://metrics.example.com">Dashboard</a>'
elif tempF > 90:
emailSubject = "Temperature>90: " + str(int(tempF)) + "F"
emailContent = 'Humidity: ' + str(int(humidity)) + '%H , Temperature: ' + str(int(tempF)) + 'F <a href="https://metrics.example.com">Dashboard</a>'
else:
send = 0
if send == 1:
try:
if time.time() > lastEmailTime or abs(lastTemp-int(tempF)) > 1:
lastEmailTime = time.time()+emailInterval
lastTemp = int(tempF)
sender.sendmail('jake@example.com', emailSubject, emailContent)
except socket.error as e:
print("Could Not Connect to SMTP server!")
time.sleep(interval)
Back to top