This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const report_query = (year: number, month: number) => { | |
const query = `SELECT id, COALESCE(usage_in_percents, '0%') as usage, name, license_plate, '${year}-${month}' as month FROM | |
(SELECT car_id, TO_CHAR(SUM(diff) / (SELECT extract(days FROM date_trunc('month', date('${year}-${month}-01')) + interval '1 month - 1 day')) * 100, 'fm00D00%') as Usage_In_Percents FROM | |
(SELECT | |
car_id, startdate,lastdate, | |
DATE_PART('day', (date_trunc('month', startdate::date) + interval '1 month' - interval '1 day')::date::timestamp - startdate::timestamp) | |
AS diff | |
FROM rents | |
WHERE (EXTRACT(MONTH FROM startdate) = ${month} | |
AND EXTRACT(YEAR FROM startdate) = ${year}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import scapy.all as scapy | |
from argparse import ArgumentParser | |
def get_args(): | |
parser = ArgumentParser() | |
parser.add_argument("-i", "--interface", dest="interface", help="Target interface to monitor") | |
args = parser.parse_args() | |
return args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use tokio_postgres::{NoTls, Error}; | |
pub async fn pg_delete_old_records() -> Result<(), Error> { | |
let (client, connection) = tokio_postgres::connect("postgres://postgres:postgres@localhost:5432/test_db", NoTls).await?; | |
tokio::spawn(async move { | |
if let Err(e) = connection.await { | |
eprintln!("connection error: {}", e); | |
} | |
}); |