Skip to content

Instantly share code, notes, and snippets.

@h4k1m0u
h4k1m0u / c.md
Last active April 20, 2024 16:48
C notions

Linkage

Identifiers for variables and constants declared at file scope have external linkage (i.e. visible in other translation units).

Global and static variables

Both are initialized to zero for variables and NULL for pointers by default, and exist for all the lifetime of the program.

Static keyword

  • A variable declared inside a function that keeps its value between invocations (as if it were global), and so is initialized only once.
  • Function or variable is only visible (callable) within the same *.c file it was defined into (limited scope => optimal performance).
@h4k1m0u
h4k1m0u / design-patterns.md
Last active December 5, 2020 16:34
Notions about design patterns found in the Head First Design Patterns book

Composition vs inheritance

From this [youtube tutorial][1]:

  • Inheritance (is-a relationship): design objects around what they are.
  • Composition (has-a relationship): design objects around what they do (i.e. behavior).

Favor composition over inheritance.

Inheritance

  • Drawback: a derived class inherits all functionalities, even those it doesn't need.
@h4k1m0u
h4k1m0u / git-cheatsheet.md
Last active July 5, 2020 15:05
Cheatsheet for Git commands

Resolve conflicts using local modifications

git fetch origin master
git rebase -X theirs

theirs means ours in the case of a rebase (inverse of git merge).

Double-dash

Means the end of command options, after which only positional parameters are accepted.

@h4k1m0u
h4k1m0u / keras_augmentation.ipynb
Last active November 23, 2019 16:35
Getting started with Keras: MLP, CNN, Data augmentation, functional API, CheckPoint
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@h4k1m0u
h4k1m0u / plot_normal_samples.R
Last active October 24, 2019 11:58
Different color for samples (50%) below or above median
# 1000 samples from standard normal dist
x = seq(1, 1000)
y = rnorm(1000)
y_normalized = (y - min(y)) / (max(y) - min(y))
# split in half and with different color
median = median(y_normalized)
print(median)
plot(x, y_normalized, pch=21, bg=ifelse(y_normalized > median, 'red', 'green'))
  • <Tab>: Edit mode.
  • <g>, <x/y/z>: Move in direction.
  • <n>: Change dimensions.
  • numpad numbers: Change view.
  • <x>: Delete.
  • <Shift-z>: Render.

Blender modelling

  • <a>: Select/unselect all.
  • ``: Wireframe/solid mode.

Methods keywords

  • virtual: Support polymorphism.
  • =0 (pure virtual): Must be overriden.
  • final: Cannot be overriden.

Arrays:

#include <iostream>

using namespace std;
@h4k1m0u
h4k1m0u / Assembly-notes.md
Last active May 20, 2024 17:57
Notes about Assembly language with NASM

Run with NASM on Linux

32 bits

$ nasm -f elf -o script.o script.asm
$ ld -m elf_i386 -o script script.o

-elf is used in nasm to produce a 32 bits object file (otherwise it outputs a binary file by default which is difficult to link).

64 bits

@h4k1m0u
h4k1m0u / analyse_sentiments.ipynb
Created September 1, 2018 23:19
Sentiment analysis with Scikit-learn on tweets
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@h4k1m0u
h4k1m0u / 3d_cube
Last active September 1, 2018 22:21
Scripts made with ThreeJS
Only to change the gist name.