Git Product home page Git Product logo

42_cheatsheet's Introduction

42_cheatsheet's People

Contributors

agavrel avatar deadlyelder avatar gbudau avatar hugothms avatar keuhdall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

42_cheatsheet's Issues

Swindle the norminette

My personal favorites abusing static variables

Writing colorful usage

int	usage(void)
{
	static char usage_str[] =

	GREEN"philo_one\n"RESET
	"Simulation of the philosopher.\n\n"
	YELLOW"USAGE:\n    "RESET
	GREEN"philo_one "RESET
	"number_of_philosopher time_to_die time_to_eat "
	"time_to_sleep [number_of_time_each_philosophers_must_eat]\n\n"
	YELLOW"ARGS:\n    "RESET
	"All args must be positive integer\n";
	ft_putstr_fd(usage_str, 1);
	return (1);
}

Function pointers

void			listen_keystroke(t_dlist **lst)
{
	char		buffer[8];
	int			el;
	static void	(*f[])(t_dlist **lst) = { lst_validate, lst_del_one,
		lst_del_one, lst_move_left, lst_move_right, lst_move_up,
		lst_move_down, lst_select, lst_esc, lst_void_ret};

	ft_memset(buffer, 0, 8);
	while (read(0, buffer, 8) != -1)
	{
		el = ft_chrmatch(buffer);
		f[el](lst);
		render(find_first(lst), 0);
		ft_memset(buffer, 0, 8);
	}
}

Just a typing error

ctrl/cmd + f in .md on :two_: to change with 💕 (about a book in security part, misc, and another part).

Swindle the norminette part is misleading

In two of your examples here you actually do declaration and assignation on the same line, which does not comply with 42 norm if I'm not mistaken (I might be wrong as it's been a while since I've done C, even more longer using 42's norm).

Also, I could suggest you one more (really) ugly kludge of mine:

if (true)
{
   func1();
   func2();
}

5 lines here

if (true)
   func1();
if (true)
   func2();

Only 4 lines here :)

Setting values of a struct to 0 without using memset or bzero - not working on mingw_w64 or clang

In the following section, "Setting values of a struct to 0 without using memset or bzero", you show how to zero a struct in a norm-complying way (separate declaration and initialization).

t_mystruct mystruct;
(void)mystruct;

I tested the code on mingw_w64 and clang, this doesn't seem to zero the struct. In fact, after some searching, I found the following Stack Overflow question. Apparently this is a no-op.

This might be because I am using a different compiler but unfortunately, the link in "First by installing a C compiler on your computer" to mingw is dead.

I found the following way to zero a struct after declaration, I tested it on mingw_w64 and clang:

t_mystruct mystruct;
mystruct = (t_mystruct){};

Suggested edit of biased bulletpoint

Hi! Would it be possible to make the following section gender-neutral and a tick more serious?

"0x07 [Boys Only] Don't waste time flirting : For some who have been living in the basement of their parents' house for years it is a good opportunity to see what a girl looks like in real life. Nevertheless, you have to under that 1/this is not the right time and place to do so."

I know it is meant as a light-hearted joke nodding at the jaded trope of programmers being mostly male and socially inapt. Sometimes that kind of banter might have unintended consequences, such as reinforcing pre-existing discriminatory tropes, or even naturalising behaviour that might be harmful or disrespectful. I believe this is to be the case because it's targeting males as 'potential harassers', considering that flirting in inappropriate moments or when unsolicited is one form of harassment and distress, while it also poorly assumes that boys are exclusively interested in girls, which reinforces the idea of girls as prey to boys.

My suggested revision of that paragraph is as follows:

"0x07 Don't flirt during the piscine. It is not the appropriate time and place to do so. Having someone's attention in a context of mutual helping is not an invitation to flirt, and might come off as distressing or downright disrespectful. Leave it out."

Thanks for your attention. All the best!

ft_putchar typo

// ft_putchar(42 + '0'); // will only print 4
^
|
42 + 48 == 90 == 'Z' (not '4')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.