1.93K subscribers
3.7K photos
138 videos
15 files
3.9K links
Блог со звёздочкой.

Много репостов, немножко программирования.

Небольшое прикольное комьюнити: @decltype_chat_ptr_t
Автор: @insert_reference_here
Download Telegram
#prog #abnormalprogramming

spellscript

esotoric [sic!] programming language that's read like a spellbook


begin the grimoire.
summon the power with essence of 7.
conjure ritual named amplify with value to return value multiplied by value.
enchant power with essence 0 of through ritual amplify with power.
inscribe whispers of "the power is amplified: " bound with power.
close the grimoire.

output: the power is amplified: 49
11🤯3🤡3😁1
#abnormalprogramming

wiki.archlinux.org/title/Swap_on_video_RAM

In the unlikely case that you have very little RAM and a surplus of video RAM, you can use the latter as swap.
😁10🤯6👍1🤣1
#prog #c #article #abnormalprogramming

Серия из трёх (на текущий момент) статей о странностях C

Weekend projects: getting silly with C
Getting silly with C, part (void*)2
Getting silly with C, part ~(~1<<1)

Наверное, мои самый любимые примеры кода из статей — это многострочный комментарий:

#include <stdio.h>

int main() {
puts("Hello world");
asm("/*");
/* Nested comment */
for (int i = 0; i < 10; i++) puts("I LIKE PANCAKES!");
asm("*/");
puts("Goodbye world");
}


и абьюз type punning-а на сигнатуре main для доставания "Главного ответа о вселенной, смысле жизни и всего такого" из воздуха:

#include <stdio.h>

int main(int i) {

do do do do "baby shark!";

while (++i % 2);
while (i == 2);
while (i % 3);
while (i % 7);

printf("The answer is %d.\n", i);

}
😁12👍2🤯2🍌1
#prog #rust

Одна из клёвых вещей, которые есть в #zig — это синтаксис для многострочных строковых литералов:

const hello_world_in_c =
\\#include <stdio.h>
\\
\\int main(int argc, char **argv) {
\\ printf("hello world\n");
\\ return 0;
\\}
;


Большим преимуществом этого синтаксиса является тот факт, что он позволяет с лёгкостью сделать отступ для литерала целиком и при этом не добавлять этот отступ в сам литерал, а также требует минимального экранирования (всё до перевода строки — содержимое строки). Аналогичный код в, скажем, Rust, требует такой неприятной вещи:

    let hello_world_in_c = "\
#include <stdio.h>\
\n\
\nint main(int argc, char **argv) {\
\n printf(\"hello world\\n\");\
\n return 0;\
\n}";


и поддержки со стороны компилятора для того, чтобы экранирование перевода строки убирало не только сам перевод строки, но и предшествующие пробельные символы. Обратите внимание на то, что мне также пришлось экранировать кавычки и \n в коде. Сырые строковые литералы позволяют убрать экранирование, но не лишние отступы:

    let hello_world_in_c = r#"#include <stdio.h>

int main(int argc, char **argv) {
printf("hello world\n");
return 0;
}"#;


Именно по этой причине есть аж два RFC (раз, два), которые добавляют новые виды строковых литералов для подобных целей (включения многострочного кода на другом языке). Тем не менее, в обсуждении второго один человек заметил (и тут дела приобретают #abnormalprogramming оборот), что имитировать многострочные литералы из Zig в Rust в некоторой мере можно уже сейчас. Именно, doc-комментарии уже на этапе лексирования заменяются на #[doc]-атрибуты, а потому можно макросом извлечь эти литералы из атрибутов и сконкатенировать:

macro_rules! text {
(#[doc=$first_line:literal] $(#[doc=$lines:literal])*) => {
concat!($first_line, $("\n", $lines),*)
};
}
let hello_world_in_c = text! {
///#include <stdio.h>
///
///int main(int argc, char **argv) {
/// printf("hello world\n");
/// return 0;
///}
};
🥴202🤔2
Блог*
#prog #game #abnormalprogramming Verilog to Factorio blueprints compiler https://github.com/Redcrafter/verilog2factorio (thanks @GabrielFallen)
#prog #game #abnormalprogramming

Facto is a programming language that compiles to Factorio circuit network blueprints. You write readable code describing the logic you want, and the compiler generates optimized combinators that you paste directly into your game. No manual wiring, no layout headaches, no remembering signal types, no memory frustration, no debugging visual spaghetti.


Memory counter: "signal-A";
counter.write((counter.read() + 1) % 20);

Entity lamp = place("small-lamp", 0, 0);
lamp.enable = counter.read() < 30;


Можно запустить онлайн
17
#prog #abnormalprogramming

find + mkdir is Turing complete

(только GNU find, потому что доказательство опирается на поведение, не определённое в POSIX)

Также есть папир, где автор доказывает, что полноты по Тьюрингу можно добиться при помощи одного только GNU find и четырёх файлов, без mkdir.
🤯9👍5🤡2🥴2
Блог*
#prog #rust #php #abnormalprogramming Experimentally compiling PHP code to Rust
#prog #rust #php #abnormalprogramming

rustc-php: A Rust compiler written in PHP

A Rust compiler written in PHP that emits x86-64 Linux ELF binaries directly (no LLVM, no assembler, no linker). Implements ownership checking, borrow checking, type checking, move semantics, generics, traits, closures, and iterators. Useful if you need to compile Rust on a shared hosting server from 2008 where the only installed runtime is PHP.
🤯15😁11😱1
Блог*
Ландук думает, что это эвфемизм, лол
От героя поста (cts)

#prog #article #abnormalprogramming #typescript

That's a Lot of Fish: PlaidCTF 2020

Статья про реверс-инжиниринг вот этого:
🤷3🥰2🤯2👍1
Dolboeb-driven Development
https://www.youtube.com/watch?v=4XCkeN0XuqA
#prog #article #retroit #abnormalprogramming

Porting Mac OS X to the Nintendo Wii

Since its launch in 2007, the Wii has seen several operating systems ported to it: Linux, NetBSD, and most-recently, Windows NT. Today, Mac OS X joins that list.

In this post, I’ll share how I ported the first version of Mac OS X, 10.0 Cheetah, to the Nintendo Wii. If you’re not an operating systems expert or low-level engineer, you’re in good company; this project was all about learning and navigating countless “unknown unknowns”. Join me as we explore the Wii’s hardware, bootloader development, kernel patching, and writing drivers - and give the PowerPC versions of Mac OS X a new life on the Nintendo Wii.
🥰2❤‍🔥1🤯1