A list of useful conventions to follow when running a project
This file contains 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
/* Body and header styles inspired by http://bettermotherfuckingwebsite.com/ */ | |
/* | |
Bookmarklet: | |
javascript:(function() { | |
var style = document.getElementsByTagName("style"); | |
var css = "a,a:link,a:visited{color:#265C83}body{margin:40px auto;max-width:60em;line-height:1.6;font-size:18px;color:#222;background:#EEE;padding:0 10px}h1,h2,h3{line-height:1.2}canvas,iframe,img,select,svg,textarea,video{max-width:100%}.overflow-container{overflow-x:scroll}.aspect-ratio{height:0;padding-top:56.25%;position:relative}.aspect-ratio--object{height:100%;position:absolute;top:0;right:0;bottom:0;left:0;width:100%;z-index:100}a{transition:color .4s;text-decoration:none}a:hover{color:#7FDBFF}a:active{transition:color .3s;color:#007BE6}"; | |
if (style[0]) { | |
style[0].innerHTML = css; |
- Does the code work? Does it perform its intended function, the logic is correct etc.
- Is all the code easily understood?
- Does it conform to your agreed coding conventions? These will usually cover location of braces, variable and function names, line length, indentations, formatting, and comments.
- Is there any redundant or duplicate code?
- Is the code as modular as possible?
- Can any global variables be replaced?
This file contains 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
# TODO: | |
# - build modes: release, debug | |
CXX := g++ | |
EXECUTABLE := project.exe | |
EXECUTABLE_TESTS := project_tests.exe | |
INCLUDE := -I./deps | |
This file documents the mmap() facility available with the PACKET socket interface on 2.4/2.6/3.x kernels. This type of sockets is used for i) capture network traffic with utilities like tcpdump, ii) transmit network traffic, or any other that needs raw access to network interface.
You can find the latest version of this document at: http://wiki.ipxwarzone.com/index.php5?title=Linux_packet_mmap
This file contains 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
""" | |
Interpreter for a language targeted at solving fizzbuzz | |
Source: [The fastest fizzbuzz in the west](https://www.promptworks.com/blog/the-fastest-fizzbuzz-in-the-west) | |
## Imports | |
""" | |
from rply import LexerGenerator, ParserGenerator | |
from rply.token import BaseBox | |
import sys |
This file contains 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
#include <cstdio> | |
template <typename ... Args> | |
bool safe_sscanf(char const* s, char const* fmt, Args*... args) | |
{ | |
constexpr auto len = sizeof...(args); | |
auto n = sscanf(s, fmt, args...); | |
if (n != len) | |
{ | |
printf("sscanf error: captured %d instead of %zu - string was [%s], format was [%s]\n", n, len, s, fmt); |
#include <iostream>
#include <string>
#include <ftw.h>
#include <fts.h>
template <typename T>
void walk_dir(std::string const& fpath, T&& function)
{
char const* filepath[] = { fpath.c_str(), nullptr };
This file contains 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
// https://banu.com/blog/2/how-to-use-epoll-a-complete-example-in-c/ | |
// http://www.kegel.com/poller/ | |
/** Todo | |
* - [ ] Split i/o and logic | |
* - [ ] Unit test logic | |
* - [ ] Logging | |
* - [ ] Continuous integration | |
* - [ ] Linux | |
* - [ ] Windows |
This file contains 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
#include <cstdio> | |
#include <array> | |
#include <x86intrin.h> | |
int main() { | |
__m128 vector_a = { 1, 2, 3, 4 }; | |
__m128 vector_b = { 5, 6, 7, 8 }; | |
vector_a = _mm_add_ps(vector_a, vector_b); | |
std::array<float, 4> a; | |
_mm_store_ps(a.data(), vector_a); |