Skip to content

Instantly share code, notes, and snippets.

@hempnall
hempnall / pca.cpp
Last active January 20, 2018 20:23
Principal Component Analysis in various Languages
#include <iostream>
#include <dlib/statistics/dpca.h>
#include <dlib/statistics/dpca_abstract.h>
#include <dlib/matrix.h>
#include <initializer_list>
using namespace dlib;
int main()
@hempnall
hempnall / README.md
Created January 1, 2018 20:46
Messing with DHASH

Use DHASH to compare images

Based on this repo:

https://github.com/Jetsetter/dhash.git

I categorised a bunch of images and had a play with this PIP repo to see whether it could tell the difference between images that are quite similat

@hempnall
hempnall / Calling_C_From_Rust.md
Created December 7, 2017 20:06
Calling C++ code from Rust

Start off with some Rust source code

hw.rs :

#[link(name = "extern")]
extern {
	fn hello();
}

#include <stdint.h>
#include <iostream>
#include <sstream>
typedef struct pcap_hdr_s {
uint32_t magic_number; /* magic number */
uint16_t version_major; /* major version number */
uint16_t version_minor; /* minor version number */
int32_t thiszone; /* GMT to local correction */
uint32_t sigfigs; /* accuracy of timestamps */
@hempnall
hempnall / gist:e265b70b9c5c62a42799497734f406df
Last active September 19, 2016 20:19
Filtering using AWK
#!/usr/bin/awk -f
# $ ./filter.awk filter_list data_file
# http://stackoverflow.com/questions/14062402/awk-using-a-file-to-filter-another-one-out-tr
BEGIN {
FS=",";
}
FNR==NR {
a[$0];
next
}
@hempnall
hempnall / gist:130fbfdf36d0982250ab73e2683ae5a3
Created July 22, 2016 07:11
setting up an apt-get server in a a dockerfile
FROM ubuntu:16.04
MAINTAINER jxy
RUN apt-get -y update && apt-get install -y dpkg-dev
COPY usr/share/xyz/debs /debs
WORKDIR /debs
RUN dpkg-scanpackages -m . | gzip -c > Packages.gz
RUN echo "deb [trusted=yes] file:///debs ./" > /etc/apt/sources.list.d/xyz.list
RUN apt-get update
@hempnall
hempnall / instructions.txt
Created August 14, 2015 18:51
Compiling Poppler on Mac for Qt5 (poppler 0.35.0)
I added these lines to near the top of CMakeLists.txt
set(Qt5Core_DIR /Users/<username>/Qt5.4//5.4/clang_64/lib/cmake/Qt5Core)
set(Qt5Gui_DIR /Users/<username>/Qt5.4//5.4/clang_64/lib/cmake/Qt5Gui)
set(Qt5Xml_DIR /Users/<username>/Qt5.4//5.4/clang_64/lib/cmake/Qt5Xml)
set(Qt5Widgets_DIR /Users/<username>/Qt5.4//5.4/clang_64/lib/cmake/Qt5Widgets)
set(Qt5Test_DIR /Users/<username>/Qt5.4//5.4/clang_64/lib/cmake/Qt5Test)
LINK_DIRECTORIES(/opt/local/lib)
I removed support for GObject introspection (whatever that is??)