(This is a backup of https://samulinatri.com/blog/memory-management)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A C port of the example at https://iq.opengenus.org/octree | |
#include <stdlib.h> | |
#include "octree.h" | |
Octree * octree_point(int x, int y, int z) { | |
Octree * p = malloc(sizeof(Octree)); | |
p->point = malloc(sizeof(Point3D)); | |
p->point->x = x; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some possible implementations of the Bresenham Algorithms in C. | |
The Bresenham line algorithm is an algorithm which determines which points in an | |
n-dimensional raster should be plotted in order to form a close approximation | |
to a straight line between two given points. | |
It is commonly used to draw lines on a computer screen, as it uses only integer | |
addition, subtraction and bit shifting, all of which are very cheap operations | |
in standard computer architectures. | |
It is one of the earliest algorithms developed in the field of computer graphics. | |
A minor extension to the original algorithm also deals with drawing circles. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From: https://cplusplus.com/forum/beginner/94946/ | |
// By: https://cplusplus.com/user/Disch/ | |
#define FPS 60 | |
int frame_length = 1000 / FPS; // Number of ms between frames. 17 gives you approx 60 FPS (1000 / 60) | |
Uint32 next_frame; // Timestamp that next frame is to occur | |
int skipped_frames; // Number of frames we have skipped |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Source material: | |
http://security.stackexchange.com/questions/24444/what-is-the-most-hardened-set-of-options-for-gcc-compiling-c-c | |
https://wiki.gentoo.org/wiki/Hardened_Gentoo | |
https://wiki.debian.org/Hardening | |
================================================================================================================> | |
GCC Security related flags and options: | |
CFLAGS="-fPIE -fstack-protector-all -D_FORTIFY_SOURCE=2" | |
LDFLAGS="-Wl,-z,now -Wl,-z,relro" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# A simple plugin for hiding/showing all layers. | |
from gimpfu import * | |
def hide_show_all_layers(origin, hide): | |
layers = origin.layers | |
pdb.gimp_undo_push_group_start(origin) |
I often find myself using Byobu on a Linux machine when connected to it over SSH. In doing so, I've noticed that many of the documented keyboard shortcuts don't work. This can be due to the native PC's OS intercepting certain keys, or possibly other reasons.
Below is a cheatsheet with Byobu features I have found usually work when run over a SSH connection.
Action | Windows + Putty to Ubuntu | MacOS + Terminal to Ubuntu |
---|---|---|
Help menu | BASH: byobu-config | FN-F1 |
Create new window | CTRL-a c | CTRL-a c or FN-F2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:lua vim.api.nvim_open_win(0, true, {relative='win', width=200, height=200, row=16, col=16}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Taking a few things from my fish cfg back to bash: vi keys, branch name in prompt, custom prompt, completion (with fzf) | |
# Custom prompt | |
# Vi keys | |
# History | |
# Completion (Using fzf & fzf-tab-completion) | |
# Tip: Install bashmarks and fasd for faster directory browsing | |
# Custom prompt: Add to .bashrc | |
# Helps reset prompt when tty crashes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/* | |
Usage: ./to-netscape-bookmarks.sh urls | tee bookmarks.html | |
urls is a simple textfile with urls separated by breakline | |
Titles are pulled with pup tool | |
*/ | |
const { exec } = require('child_process'), fs = require('fs'), readline = require('readline') | |
const file = process.argv[2] |
NewerOlder