Skip to content

Instantly share code, notes, and snippets.

@eanmos
eanmos / problem.c
Created April 3, 2019 12:09
Нефедов Д. ПИНФ-11
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))
void print(int const [], size_t);
int *sum(int const [], int const [], size_t, size_t);
int *mul(int const [], int const [], size_t, size_t);
<?php
define("TYPE_PROMOCODE", "TYPE_PROMOCODE");
define("TYPE_PROMOTION", "TYPE_PROMOTION");
/*
===============================================================================
FUNCTION IMPLEMENTATIONS
@eanmos
eanmos / hexviewer.c
Created April 11, 2019 12:34
ПИНФ-11, Нефедов Д.
#include <stdio.h>
#include <stdlib.h>
#define PRINTABLE(c) (!((c <= 31) || c == 127))
int main(int argc, char *argv[]) {
FILE *f = fopen(argv[1], "rb");
fseek(f, 0, SEEK_END);
long size = ftell(f);
#include <stdio.h>
#include <math.h>
#define EPS 5
#define PI 3.141592653589793238462
#define DEG2RAD(a) ((a) * PI / 180.0)
static double mcos(double rad)
{
@eanmos
eanmos / problem_3.c
Last active June 7, 2019 08:01
ПИНФ-11, Нефедов Д. В. — Задача №3
/* ЗАДАЧА №3
*
* Найти в массиве целых чисел три минимальных числа. Числа могут повторяться.
* Для массива [2, 1, 0, 1] ответ будет [0, 1, 1].
*
* ПИНФ-11, Нефедов Д. В. — <eanmos@ya.ru>.
*/
#include <stdio.h>
#include <stdlib.h>
@eanmos
eanmos / dstrings.h
Last active June 7, 2019 21:14
Steganography
#ifndef DSTRINGS_H
#define DSTRINGS_H
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <assert.h>
@eanmos
eanmos / text.md
Created October 25, 2019 18:27
Signed vs. unsigned

@anrieff, actually it is a very interesting field for discussion. During this one, I made a lot of researches about signed vs. unsigned. I think some of my conclusions may be interesting for you.

Bugs

  1. Unsigned types hides bugs on overflow.

  2. Signed overflow is UB that makes the program's behavior non-deterministic. It actually could hide bugs too.

  3.  for i := 0 to List.Count - 1 do
    

> // do something here

@eanmos
eanmos / fix-infinality.md
Created February 9, 2020 21:32 — forked from cryzed/fix-infinality.md
A set of instructions on how to fix the harfbuzz + Infinality issue and restoring good-looking, Infinality-like font rendering.

Disclaimer: Please follow this guide being aware of the fact that I'm not an expert regarding the things outlined below, however I made my best attempt. A few people in IRC confirmed it worked for them and the results looked acceptable.

Attention: After following all the steps run gdk-pixbuf-query-loaders --update-cache as root, this prevents various gdk-related bugs that have been reported in the last few hours. Symptoms are varied, and for Cinnamon the DE fails to start entirely while for XFCE the icon theme seemingly can't be changed anymore etc.

Check the gist's comments for any further tips and instructions, especially if you are running into problems!

Screenshots

Results after following the guide as of 11.01.2017 13:08:

@eanmos
eanmos / Makefile
Last active March 8, 2020 13:36
Makefile for ARM cross-compilation
export QEMU_LD_PREFIX := /opt/cross/arm-linux-gnueabi
CC := arm-linux-gnueabi-gcc
CFLAGS := -std=c17 -g -Wall -Wextra -pedantic
AS := arm-linux-gnueabi-as
ASFLAGS := -g
QEMU := qemu-arm
GDB := arm-linux-gnueabi-gdb
@eanmos
eanmos / cos.c
Last active March 26, 2020 13:56
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <math.h>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif