Skip to content

Instantly share code, notes, and snippets.

View felipeek's full-sized avatar

Felipe Kersting felipeek

  • Porto Alegre, Brazil
View GitHub Profile
@felipeek
felipeek / Analyze memory usage with valgrind and massif.md
Last active July 21, 2022 01:11
Analyze memory usage with valgrind and massif

Approach 1: run a process with massif, let it take automatic memory snapshots and then analyze the results

Approach 2: run a process with massif, manually decide when the snapshots are taken, and then analyze the results

Approach 1

    1. Run your process with massif: valgrind --tool=massif <your executable> <your process arguments>
    1. Do whatever you need to do, and then stop your process. A file named ms_print massif.out.pid will be generated.
  • 3a. Option 1: Run ms_print massif.out.*pid* > user_friendly.txt to generate a user-friendly file and analyze it.
  • 3b. Option 2: Run massif-visualizer massif.out.*pid* to visualize the results in a pretty UI. You need to install massif-visualizer: sudo apt install massif-visualizer
@felipeek
felipeek / point_lies_on_line_2d.c
Last active December 7, 2021 21:05
Check if point lies on a line (2D)
// checks whether a point lies on a line (2D)
// l1_x, l1_y -> line's first point
// l2_x, l2_y -> line's second point
// p_x, p_y -> point of interest
// w -> output indicating the weight of the point
// returns 1 if point lies on the line, 0 if not
// https://gist.github.com/felipeek/93c873395506868e50ea6f2323eb3399
int point_lies_on_line_2d(float l1_x, float l1_y, float l2_x, float l2_y, float p_x, float p_y, float* w) {
const float EPSILON = 0.000001f;
int vertical_line = (l1_x - l2_x) > -EPSILON && (l1_x - l2_x) < EPSILON; // vertical line
@felipeek
felipeek / linux-debug.md
Created August 9, 2020 00:03
How to debug the Linux Kernel using VirtualBox

Assumptions: Host machine is linux.

  1. Download virtualbox
  2. Install a linux flavour. Preference for Debian since distro-dependent commands in the following steps will be debian-dependent
  3. Run your VM.
  4. Inside VM, download last kernel code from kernel.org
  5. Extract linux src code
  6. Copy your configuration file from /boot/config-$(uname -r) to .config in the extract linux src code folder.
  7. Make sure .config has the following options: CONFIG_FRAME_POINTER=y , CONFIG_KGDB=y , CONFIG_KGDB_SERIAL_CONSOLE=y , CONFIG_KGDB_KDB=y , CONFIG_KDB_KEYBOARD=y. Change if necessary. Alternatively use make xconfig to configure in UI.
  8. Install compilation dependencies (debian: sudo apt-get install build-essential libncurses-dev bison flex libssl-dev libelf-dev)
This file has been truncated, but you can view the full file.
<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<asset>
<contributor>
<author>Blender User</author>
<authoring_tool>Blender 2.80.75 commit date:2019-07-29, commit time:14:47, hash:f6cb5f54494e</authoring_tool>
</contributor>
<created>2019-12-23T00:22:22</created>
<modified>2019-12-23T00:22:22</modified>
<unit name="meter" meter="1"/>
#!/bin/bash
git remote set-url origin https://github.com/felipeek/squiggly.git
git remote add bitbucket https://Felipeek@bitbucket.org/Felipeek/squiggly.git
# From now on...
# git push origin ~> Updates GITHUB
# git push bitbucket ~> Updates BITBUCKET (if needed for some reason)