Skip to content

Instantly share code, notes, and snippets.

View akamilkhan's full-sized avatar
💥
Moving forward!

Kamil akamilkhan

💥
Moving forward!
View GitHub Profile
@akamilkhan
akamilkhan / QuaternionToEulerAngles.c
Created March 11, 2021 07:20
Quaternion to Euler Angles conversion snippet
#include <math.h>
struct Quaternion
{
double w, x, y, z;
};
struct EulerAngles
{
double roll, pitch, yaw;
uint64_t time_now()
{
return (std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch())).count();
}
@akamilkhan
akamilkhan / recordpcap.sh
Last active March 18, 2020 15:04
udpsub.py: subscribe udp mulitcast channel
#!/bin/bash
# manually join security feeds
TIMEOUT=24h
IFACE=$1
while read p; do
python udp_sub.py $p $IFACE > /dev/null &
done <<EOF
224.0.31.2 14311
224.0.31.44 14311
224.0.31.23 14311
@akamilkhan
akamilkhan / tcp.py
Created October 30, 2019 06:27
TCP msg sender with PPS control
import socket
import time
#import fcntl
#import os
HOST = '192.168.9.10'
PORT = 29999
PPS = 20000
delay = 1.0/PPS
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@akamilkhan
akamilkhan / UnitUniformityTemplate.jsx
Created October 20, 2019 17:33
Template to achieve units uniformity in Photoshop Script
function main() {
// declare local variables
var orig_ruler_units = app.preferences.rulerUnits;
var orig_type_units = app.preferences.typeUnits;
var orig_display_dialogs = app.displayDialogs;
git fetch origin '+refs/heads/*:refs/remotes/origin/*' '+refs/remotes/*:refs/remotes/upstream/*'
#Source: https://stackoverflow.com/questions/28645819/how-to-fetch-all-branches-including-the-remotes-remote-branches
#include <chrono>
#include <iostream>
auto start = std::chrono::steady_clock::now();
// ***************
// CODE UNDER TEST
// ***************
auto end = std::chrono::steady_clock::now();
auto diff = end - start;
std::cout << std::chrono::duration <double, std::nano> (diff).count() << " ns" << std::endl;
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(###CPU ID###, &cpuset);
int rc = pthread_setaffinity_np(###THREAD HANDLE####, sizeof(cpu_set_t), &cpuset);
//gcc ./udpmulticast2udp.cpp -o udpmulticast2udp-app to compile
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <time.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@akamilkhan
akamilkhan / client.c
Created April 1, 2019 06:03 — forked from suyash/client.c
UDP echo client-server implementation
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
int main() {
const char* server_name = "localhost";
const int server_port = 8877;