If we want, we can also specify inline code which is useful for the small stuff.
Rust
fnmain(){let greetings =["Hello","Hola","Bonjour","Ciao","こんにちは","안녕하세요","Cześć","Olá","Здравствуйте","Chào bạn","您好","Hallo","Hej","Ahoj","سلام","Hej","Hallo","Hei","Helló","Hallo","Buna ziua","Merhaba"];for(num, greeting)in greetings.iter().enumerate(){print!("{} : ", greeting);match num {0=>println!("This code is editable and runnable!"),//en English
1=>println!("¡Este código es editable y ejecutable!"),//es Spanish
2=>println!("Ce code est modifiable et exécutable !"),//fr French
3=>println!("Questo codice è modificabile ed eseguibile!"),//it Italian
4=>println!("このコードは編集して実行出来ます!"),//jp Japanese
5=>println!("여기에서 코드를 수정하고 실행할 수 있습니다!"),//ko Korean
6=>println!("Ten kod można edytować oraz uruchomić!"),//pl Polish
7=>println!("Este código é editável e executável!"),//pt Portuguese
8=>println!("Этот код можно отредактировать и запустить!"),//ru Russian
9=>println!("Bạn có thể edit và run code trực tiếp!"),//vi Vietnamese
10=>println!("这段代码是可以编辑并且能够运行的!"),//zh Chinese
11=>println!("Dieser Code kann bearbeitet und ausgeführt werden!"),//de German
12=>println!("Den här koden kan redigeras och köras!"),//sv Swedish
13=>println!("Tento kód můžete upravit a spustit"),//cs Czech
14=>println!("این کد قابلیت ویرایش و اجرا دارد!"),//fa Persian
15=>println!("Denne kode kan redigeres og køres!"),//da Danish
16=>println!("Deze code is bewerkbaar en uitvoerbaar!"),//du Dutch
17=>println!("Tämä koodi on muokattavissa ja ajettavissa!"),//fi Finnish
18=>println!("Ez a kód szerkeszthető és futtatható!"),//hu Hungarian
19=>println!("Denne koden er redigerbar og kjørbar!"),//no Norwegian
20=>println!("Acest cod este editabil și rulabil!"),//ro Romanian
21=>println!("Bu kod düzenlenebilir ve çalıştırılabilir!"),//tr Turkish
_=>{},}}}
Bash
#!/bin/bashfor d in /sys/kernel/iommu_groups/*/devices/*;don=${d#*/iommu_groups/*};n=${n%%/*}printf'IOMMU Group %s '"$n"lspci -nns"${d##*/}"done
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."
$font:Robotosystem-ui-apple-systemBlinkMacSystemFont"Segoe UI"OxygenUbuntuCantarell"Fira Sans""Droid Sans""Helvetica Neue""Noto Sans"HelveticaArialsans-serif!default;$font-mono:ui-monospaceMenloMonacoConsolas"SF Mono""Cascadia Mono""Segoe UI Mono""DejaVu Sans Mono""Liberation Mono""Roboto Mono""Oxygen Mono""Ubuntu Monospace""Ubuntu Mono""Source Code Pro""Fira Mono""Droid Sans Mono""Courier New"Couriermonospace!default;@mixinfont{// convert space separated list to comma separated list
$font:list.join($font,"",$separator:comma);$font:functions.remove($font,"");$font-mono:list.join($font-mono,"",$separator:comma);$font-mono:functions.remove($font-mono,"");$font:functions.font-var($font,$fontExt-Main,$findFont-Main);$font-mono:functions.font-var($font-mono,$fontExt-Code,$findFont-Code); #{--ff}: $font; #{--fm}: $font-mono;//code
}
Javascript
functioncloseSearch(){//close the search displaying the regular page.conste=document.querySelector("main");e.innerHTML=window.main}functiongoSearch(){// on enter key or search icon click display results to the page.conste=document.querySelector("main");window.main||(window.main=e.innerHTML);vart=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> <i class="svgs search"></i> '.concat(document.getElementById("searchinput").value,"</h2>");returnn.innerHTML=o,ResultsClone.insertBefore(n,ResultsClone.firstChild),e.innerHTML=ResultsClone.outerHTML,t.innerHTML="",document.getElementById("searchinput").value="",!1}!function(){// search function code goes here}
PHP
<?php/**
* Postfix Admin
*/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)){# only set cookie if language selection was changed
setcookie('lang',$lang,time()+60*60*24*30);# language cookie, lifetime 30 days
}}$_SESSION['PFA_token']=md5(uniqid("pfa".rand(),true));/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
-- jelly-actix-web-starter - Creates an accounts table, along with some associated helpers.
create or replacefunctionupdate_timestamp() returns trigger as $$
beginnew.updated= now();
return new;
end;
$$ language 'plpgsql';
createtableif not exists accounts (
id serialprimary key,
name textnotnull,
email textnotnull unique,
password textnotnull,
profile jsonb notnulldefault'{}',
plan integernotnulldefault0,
is_active booleannotnulldefaulttrue,
is_admin booleannotnulldefaultfalse,
has_verified_email booleannotnulldefaultfalse,
last_login timestamp with time zone,
created timestamp with time zonenotnulldefault now(),
updated timestamp with time zonenotnulldefault now());
createunique indexaccounts_unique_lower_email_idx on accounts (lower(email));
createtriggeruser_updated before insert or update on accountsfor each row execute procedure update_timestamp();
Lua
functionsquare(x)returnx*xendprint(square(2))-- prints '4'
functiongetPlayerInformation()playerName=UnitName("player")playerLevel=UnitLevel("player")specId, specName=GetSpecializationInfo(GetSpecialization())return"Hey, I'm "..playerName.." (Level "..playerLevel.."). I'm currently in spec "..specName.."."endprint(getPlayerInformation())
C
#include<stdio.h>intmain(){int a;/* actual initialization */ a =10;printf("Hello, World!");return0;}
C++
// Your First C++ Program
#include<iostream>intmain(){int a;/* actual initialization */ a =10; std::cout <<"Hello World!";return0;}
#!/usr/bin/env python3
importsmtplib,socketfrominfluxdbimportInfluxDBClientwhileTrue:send=1later=time.time()+25200iso=time.ctime(later)tempF=round(bme280.temperature*1.8+29,3)#C to F formula is +32, difference is to correct bme280 temperature offset
humidity=round(bme280.humidity,3)pressure=round(bme280.pressure,3)# serialize data as JSON
data=[{"measurement":measurement,"tags":{"location":location,},"time":iso,"fields":{"temperature":tempF,"humidity":humidity,"pressure":pressure}}]# Send the JSON data to InfluxDB
try:client.write_points(data)exceptsocket.errorase:print("Could Not Connect to InfluxDB!")iftempF>90andhumidity>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>'elifhumidity>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>'eliftempF>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=0ifsend==1:try:iftime.time()>lastEmailTimeorabs(lastTemp-int(tempF))>1:lastEmailTime=time.time()+emailIntervallastTemp=int(tempF)sender.sendmail('[email protected]',emailSubject,emailContent)exceptsocket.errorase:print("Could Not Connect to SMTP server!")time.sleep(interval)
Ruby
=begin Ruby program to check whether the
year is leap year or not between range.
=endputs"Enter the lower limit:"lwr =gets.chomp.to_iputs"Enter the upper limit:"upr =gets.chomp.to_ifor yr in lwr..upr doif yr %400==0puts"#{yr} is a leap year"elsif yr %4==0&& yr %100!=0puts"#{yr} is a leap year"elseputs"#{yr} is not a leap year"endend