Skip to content

Instantly share code, notes, and snippets.

@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??)
@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 / 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
}
#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 / 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();
}

@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 / 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 / main.cpp
Created February 6, 2018 19:49
Pick up to M from N numbers from a list
#include <iostream>
#include <vector>
using namespace std;
typedef std::vector<uint8_t> choices_t;
void printVec( choices_t& picked ) {
for (uint8_t num : picked) cout << (int) num << " ";
cout << "\n";
@hempnall
hempnall / Flattening Iterators
Last active February 19, 2018 19:17
Flattening Iterators
Flattening Iterators
====================
Summary
-------
This is an interator template that fits a pattern whereby you need to
return a list of objects streamed out of a sorted list of files.
For instance, the Bitcoin blockchain comes in block files (blk00000.dat).
@hempnall
hempnall / Wildcards in Makefiles
Created February 19, 2018 19:53
Wildcards in Makefiles
txt_files := $(wildcard *.txt)
int_files := $(txt_files:.txt=.int)
hexdump_files := $(int_files:.int=.hexdump)
all:
echo $(txt_files)
echo $(int_files)
echo $(hexdump_files)
$(hexdump_files): $(INT_FILES)