Advanced Hello World in Zig - Loris Cro (34:50) Oct 13, 2020
stdout, stderr, logging
View zig_learn_video.md
View paskha.html
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Orthodox Easter Calculator</title> | |
</head> | |
<body> | |
<h1>Orthodox Easter Calculator</h1> | |
<p>Enter a year and see the year day for Orthodox Easter using Gauss formula.</p> | |
<label for="year">Year:</label> | |
<input type="number" id="year" min="0" max="9999"> |
View paskha.zig
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
const std = @import("std"); | |
const expect = std.testing.expect; | |
const expectEqualDeep = std.testing.expectEqualDeep; | |
const stdout = std.io.getStdOut().writer(); | |
const stderr = std.io.getStdErr().writer(); | |
const cumdaytab = [_][14]i32{ | |
[_]i32{ 0, -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364 }, | |
[_]i32{ 0, -1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, |
View reverse_codepoint.zig
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
const std = @import("std"); | |
var gpa = std.heap.GeneralPurposeAllocator(.{}){}; | |
const allocator = gpa.allocator(); | |
fn reverse_string(str: []const u8) ![]u8 { | |
var len = str.len; | |
var out = try allocator.alloc(u8, len); | |
var str_iter = (try std.unicode.Utf8View.init(str)).iterator(); |
View zig_cheetsheet.md
A half-hour to learn Zig
This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/
Basics
the command zig run my_code.zig
will compile and immediately run your Zig
program. Each of these cells contains a zig program that you can try to run
(some of them contain compile-time errors that you can comment out to play
with)
View GirardNewton.hs
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
-- Haskell version of formulae from | |
-- https://youtu.be/4FNCIYD8HdA | |
import Control.Monad (join) | |
import Data.Ratio | |
oneS :: [Rational] | |
oneS = join $ repeat [1, (-1)] | |
pSum :: Int -> Rational |
View exchange_to_from.pl
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/perl | |
## Usage: $0 'https://booking.uz.gov.ua/ru/?time=00%3A00&url=train-wagons&date=2019-08-01&from=2218020&wagon_type_id=%D0%9F&train=058%D0%9B&to=2208001' | |
use v5.14; | |
use strict; | |
use warnings; | |
say $ARGV[0]; | |
$_=$ARGV[0]; | |
chomp; |
View git-tips.md
If you want to list all the files currently being tracked under the branch master, you could use this command:
git ls-tree -r master --name-only
If you want a list of files that ever existed (i.e. including deleted files):
git log --pretty=format: --name-only --diff-filter=A | sort - | sed '/^$/d'
View full_moon.sh
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
#!/bin/bash | |
moon_ar=(19 17 17 15 14 14 12 12); | |
c=0; | |
for i in {05..12}; | |
do LC_TIME=ru_UA.UTF-8 date -d "2019-${i}-${moon_ar[$c]}" +'%B %d %a'; c=$(($c+1)); | |
done \ | |
| sed -E 's/(.+)/\L\1/; s/^(\w)/\U\1/; s/^(\w+)ая /\1ай /; s/^(\w+)я /\1ь /; s/^(\w+)а /\1 /' |
View gasolina.html
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
<html> | |
<pre> | |
Phasolina\PhasolinaException: Unknown error in /home/gasonline/www/vendor/gasolina/phasolina/src/Phasolina.php:242 | |
Stack trace: | |
#0 /home/gasonline/www/frontend/components/User.php(132): Phasolina\Phasolina->request(Object(Phasolina\Endpoint\CityAccountGetRequest)) | |
#1 /home/gasonline/www/frontend/components/User.php(150): frontend\components\User->loginByCookie() | |
#2 /home/gasonline/www/frontend/components/User.php(28): frontend\components\User->renewAuthStatus() | |
#3 /home/gasonline/www/vendor/yiisoft/yii2/web/User.php(351): frontend\components\User->getIdentity() | |
#4 /home/gasonline/www/vendor/yiisoft/yii2/base/Component.php(130): yii\web\User->getIsGuest() | |
#5 /home/gasonline/www/frontend/components/View.php(49): yii\base\Component->__get('isGuest') |
NewerOlder