Skip to content

Instantly share code, notes, and snippets.

View eurocat2k's full-sized avatar

eurocat2k eurocat2k

View GitHub Profile
@larsch
larsch / testpcap.c
Last active January 11, 2022 08:14
libpcap latency/break test
#include <pcap.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <signal.h>
pcap_t* pcap;
void* thread(void* arg) {
@reciprocum
reciprocum / R3.java
Last active December 23, 2022 09:54 — forked from anonymous/R3.java
R3 - 3D vector algebra
/*
* R3.java
*
* Copyright (c) 2016 Karambola. All rights reserved.
*/
package pt.karambola.R3;
public class
R3
@starfys
starfys / fisr.js
Last active May 18, 2024 00:09
Fast inverse square root in Javascript
//Based on the fast inverse square root function
// https://en.wikipedia.org/wiki/Fast_inverse_square_root
// Some original comments preserved for humor value
// Designed to try to mimic the original as closely as possible
function Q_rsqrt(number)
{
var i;
var x2, y;
const threehalfs = 1.5;
@cuberoot
cuberoot / distanceBetweenSegments.js
Created December 7, 2014 18:55
Calculate the distance between two line segments using three.js vector class
// Port of code from: http://geomalgorithms.com/a07-_distance.html
//
// Ported by Michael Taylor, Dec 8 2014
//
// Copyright 2001 softSurfer, 2012 Dan Sunday
// This code may be freely used and modified for any purpose
// providing that this copyright notice is included with it.
// SoftSurfer makes no warranty for this code, and cannot be held
// liable for any real or imagined damage resulting from its use.
// Users of this code must verify correctness for their application.
@kylemcdonald
kylemcdonald / main.cpp
Created April 24, 2014 22:06
Example of using libpcap with openFrameworks in monitor mode in OS X (probably similar on Linux). By default we are only watching for probe request frames.
// make sure to link against /usr/lib/libpcap.dylib
#include "ofMain.h"
#include <pcap/pcap.h>
class ofApp : public ofBaseApp {
public:
pcap_t *pcap;
struct pcap_pkthdr header;
const unsigned char* packet = NULL;
list<string> packetHex;