Skip to content

Instantly share code, notes, and snippets.

@emadflash
emadflash / fykin_pallindromes.c
Last active June 26, 2021 04:11
fykin pallindromes
#include<stdio.h>
#include<string.h>
#include<stdbool.h>
int is_pallindrome(char* string, size_t len) {
char* begin = string;
char* end = string + len - 1;
int checking = len / 2;
while(end != begin && checking-- != 0) {
#include <stdio.h>
void print_arr(int* a, int size) {
for(int i=0; i < size; ++i) {
printf("%d ", a[i]);
}
}
void bubble_sort(int* a, int size) {
for(int i=0; i < size; ++i) {
// cpp
string s { "aaaa" };
auto x = std::move(s);
s = "some other shit";
cout << s;
// rust
let x = String::from("aaaa");
let y = x;
@emadflash
emadflash / print_arr.c
Last active June 14, 2021 07:23
print arrays LUL
#include<stdio.h>
typedef enum {
INT,
CHAR,
} type;
void print_arr(void *arr, int size, type t) {
printf("[ ");
switch(t) {
@emadflash
emadflash / how-to-add-image-to-gist.md
Created May 31, 2021 15:09 — forked from mroderick/how-to-add-image-to-gist.md
How to add an image to a gist

How to add an image to a gist

  1. Create a gist if you haven't already.
  2. Clone your gist:
    # make sure to replace `<hash>` with your gist's hash
    git clone https://gist.github.com/<hash>.git # with https
    git clone git@gist.github.com:<hash>.git     # or with ssh
@emadflash
emadflash / ideas-v4.png
Last active May 31, 2021 15:11
project ideas
ideas-v4.png
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
declare -a exclude_dirs
exclude_dirs=(
"build"
"dist"
@emadflash
emadflash / WhatIsStrictAliasingAndWhyDoWeCare.md
Created May 22, 2021 10:02 — forked from shafik/WhatIsStrictAliasingAndWhyDoWeCare.md
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

@emadflash
emadflash / template.sh
Created May 22, 2021 09:58
deliberately exit bash script options; helps in tests (idk)
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
package main
import (
"fmt"
"os/exec"
"sync"
)
var Urls = []string{
"https://github.com/juliangarnier/anime.git",