Skip to content

Instantly share code, notes, and snippets.

@martinium
martinium / logcheck.nim
Last active October 3, 2022 03:54
Checks a bunch of logs for certain criteria
import strutils
import std/[asyncfile, asyncdispatch, asyncfutures, os]
import times
var post = openAsync("post_" & $now().toTime().toUnix() & ".txt", fmWrite)
var error = openAsync("error_" & $now().toTime().toUnix() & ".txt", fmWrite)
var fail = openAsync("fail_" & $now().toTime().toUnix() & ".txt", fmWrite)
var auth = openAsync("auth_" & $now().toTime().toUnix() & ".txt", fmWrite)
var succ = openAsync("succ_" & $now().toTime().toUnix() & ".txt", fmWrite)
var users = openAsync("users_" & $now().toTime().toUnix() & ".txt", fmWrite)
@martinium
martinium / temptable.cr
Created December 26, 2016 19:48
Temperature Table in F, C and K
fahr = 0
while fahr <= 500
celsius = 5.0 * (fahr - 32.0) / 9.0
kelvin = 273.15 + celsius
puts "#{fahr}\t #{celsius}\t #{kelvin}\t"
fahr += 1
end
@martinium
martinium / tempconverter.cr
Created December 26, 2016 18:28
Temp converter
def fahrToCels(fahr : Number)
celsius = 5 * (fahr - 32) / 9
puts "The temperature #{fahr} Fahrenheit is #{celsius} in Celsius degrees."
end
input = STDIN.gets.to_i
fahrToCels(input)
fn main() {
let lower = 0.0;
let upper = 300.0;
let step = 1.0;
let mut fahr = lower;
println!("Fahrenheit\tCelsius");
while fahr <= upper {
let celsius = 5.0 * (fahr - 32.0) / 9.0;