Skip to content

Instantly share code, notes, and snippets.

@Martinfx
Martinfx / mean, median, mode
Last active February 14, 2018 21:21
mean, median, mode
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
double mean(std::vector<double> mean)
{
@Martinfx
Martinfx / migrate_repo.sh
Created March 25, 2018 22:33 — forked from mariozig/migrate_repo.sh
Migrate repo from GitLab to GitHub Full blog post @ http://ruby.zigzo.com/2015/03/23/moving-from-gitlab-to-github/
# Assume we are in your home directory
cd ~/
# Clone the repo from GitLab using the `--mirror` option
$ git clone --mirror [email protected]:mario/my-repo.git
# Change into newly created repo directory
$ cd ~/my-repo.git
# Push to GitHub using the `--mirror` option. The `--no-verify` option skips any hooks.
@Martinfx
Martinfx / readme.md
Created July 14, 2018 19:38 — forked from jas-/readme.md
FreeBSD jail w/ services

myprint.scl.utah.edu

The myprint service handles wireless printing for the MLIB PC labs. FreeBSD is the operating system that was chosen for this service primarily for its security features.

Details on the current configuration of myprint.scl.utah.edu can be found below. 07/12/2013

Host OS configuration

This first section details the various configuration options applied to the kernel, NAT & traffic passing to jailed (non routable net) env, usage of IPFW service to filter incoming & outgoing traffic to specific subnets & or targets, OS, Jail & TCP stack hardening options

@Martinfx
Martinfx / freebsd10_cheatsheet.md
Created October 30, 2018 08:47
FreeBSD Cheatsheet
@Martinfx
Martinfx / Readme_VSCODE_FreeBSD
Created November 12, 2018 14:49 — forked from prash-wghats/Readme_VSCODE_FreeBSD
Notes for Building Electron and VSCode in FreeBSD11
Copy all the files to the build directory.
Copy icudtl.dat to the build directory. (you can find it in the vscode downloads ex for linux).
chromium version in port is 52.0.2743.116.
This was built with FreeBSD 11.0-RELEASE-p1. If building with other versions probably need to change
the freebsd versions in diff files (ex. freebsd11 => freebsd10)
Installed
node => v6.9.1
npm => 3.9.2
>chmod 755 vscode_build.sh
@Martinfx
Martinfx / server.cpp
Created July 17, 2019 17:54 — forked from ptitfred/server.cpp
C++ HTTP server
#include "server.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
using std::cout;
using std::cerr;
using std::cin;
using std::endl;
using std::fstream;
@Martinfx
Martinfx / README.md
Created August 7, 2019 22:34 — forked from bijanebrahimi/README.md
A guide to dtrace in FreeBSD

An introduction

what's dtrace?

DTrace dynamic tracing compiler and tracing utility DTrace is a comprehensive dynamic tracing framework for the Solaris Operating System. DTrace provides a powerful infrastructure that permits administrators, developers, and service personnel to concisely answer arbitrary questions about the behavior of the operating system and user programs.

How to enable dtrace?

@Martinfx
Martinfx / xhyve-freebsd-tutorial-1.md
Created August 17, 2019 16:16 — forked from tanb/xhyve-freebsd-tutorial-1.md
FreeBSD running on xhyve tutorial. (Appendix: Resize image with qemu. Create FreeBSD VM with qemu).

TL;DR

  • Create 5GB FreeBSD image.
  • Install FreeBSD on xhyve.
  • Mount host directory.

Requisites

@Martinfx
Martinfx / WhatIsStrictAliasingAndWhyDoWeCare.md
Created September 23, 2019 16:59 — 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