Skip to content

Instantly share code, notes, and snippets.

View lemire's full-sized avatar
🚀
working hard and fast

Daniel Lemire lemire

🚀
working hard and fast
View GitHub Profile
size_t
compute_intersection (const uint32_t * rare,
const size_t nrare, const uint32_t * freq, const size_t nfreq, uint32_t * out) {
UINT4 goal;
const UINT4 *stop_rare;
@lemire
lemire / gist:66d0a7905443fdd220c1
Last active August 29, 2015 14:20
Exemple de document XML contenant des erreurs
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<!DOCTYPE université [ <!ELEMENT université (faculté*,description*)*>
<!ELEMENT faculté (département*)> <!ELEMENT département EMPTY>
<!ATTLIST département nom CDATA #REQUIRED xmlnote (vide|plein) "plein">
<!ATTLIST université téléphone ID #REQUIRED> ]>
<université téléphone="514-4321" xml:lang="fr"> <description>La plus grande.</description>
<faculté nom="sciences"> <département nom="mathématiques"></département>
<département nom="sociologie" xmlnote="vide"/> </faculté> </université>
@lemire
lemire / espacesdenoms.xml
Last active August 29, 2015 14:22
Document XML avec espaces de noms
<?xml version="1.0"?> <recherche xmlns="http://www.google.com/" xmlns:yahoo="http://www.yahoo.com/">
<mots-clefs xmlns="http://www.yahoo.com/">fraise, orange</mots-clefs>
<yahoo:mot xmlns:yahoo2="http://www.yahoo.com/"><nombre>3</nombre> </yahoo:mot> </recherche>
@lemire
lemire / iccbug.c
Last active December 23, 2015 13:29
Found a bug in the Intel compiler.
// Code sample illustrating a bug in the Intel compiler
// icpc (ICC) 13.0.1 20121010
// compile with:
// icc -restrict -std=c99 -O2 iccbug.c -o iccbug
// then run iccbug
// Tested in Linux Ubuntu 12.10 (Intel Core i7)
#include <stdint.h>
@lemire
lemire / telephone.html
Created April 18, 2016 15:30
Cherchons un numéro de téléphone avec XPath
<html>
<header>
<script id="telephone" type="application/xml">
<annuaire>
<individu><nom>Jean</nom><telephone>456-4321</telephone></individu>
<individu><nom>Pierre</nom><telephone>456-4221</telephone></individu>
<individu><nom>Jacques</nom><telephone>553-4221</telephone></individu>
<individu><nom>Marie</nom><telephone>456-4211</telephone></individu>
</annuaire>
</script>
w = 2
def hash(a,x):
return ((a * x) >> w) % ( 1<< w)
def isItUniversal():
for x in range(1<<w):
for y in range(x+1,1<<w):
@lemire
lemire / ajaxxpath.html
Created January 23, 2017 19:43
Fichier HTML pour ajax
<html>
<header>
<script id="telephone" type="application/xml">
<annuaire>
<individu><nom>Jean</nom><telephone>456-4321</telephone></individu>
<individu><nom>Pierre</nom><telephone>456-4221</telephone></individu>
<individu><nom>Jacques</nom><telephone>553-4221</telephone></individu>
<individu><nom>Marie</nom><telephone>456-4211</telephone></individu>
</annuaire>
</script>
@lemire
lemire / rdfexemple.xml
Created January 23, 2017 19:47
Fichier RDF
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF SYSTEM "http://purl.org/dc/schemas/dcmes-xml-20000714.dtd">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/">
<rdf:Description rdf:about="file://disk/news_12_02_02.mpg">
<dc:title>World News Tonight</dc:title>
<dc:creator>Special Broadcasting Service</dc:creator>
<dc:subject>International news events</dc:subject>
cat /dev/urandom | head -c 1024 | iconv -f latin1 -t ascii -c | tr -d -c 0-9a-z | head -c 8
@lemire
lemire / copybenchmark.c
Last active October 27, 2017 03:34
ARM NEON poor's man memcpy to sanity check the NEON performance
///////////////////
// A decent machine ought to be able to copy one 32-bit integer per CPU cycle
// using vectorized instructions. Furthermore, the vectorized loads and stores
// should be close to the performance of a memcpy, one would expect, for sizeable
// arrays.
//
// This tests the sanity of your ARM (aarch64) system:
//
// cc -O3 -o copybenchmark copybenchmark.c -std=c99
// ./copybenchmark