Chess

Tips and tricks

Aims Develop towards the centre Castle early and castle often State When both sides have similarly active pieces it’s known as an even or balanced position Relative/absolute pins Notation Symbol Meaning + Check ++ Double check # Checkmate 0-0 Castles kingside 0-0-0 Castles queenside ! Good move ? [Read More]

Big data

A consolidated list of sources

Sources of big data Big data communities and platforms http://archive.ics.uci.edu/ml/index.php Kaggle Statista Data World Data Hub AWS open data Google public data Crime https://www.fbi.gov/services/cjis/ucr https://www.pcr.uu.se/research/UCDP/ https://www.drugabuse.gov/drug-topics/trends-statistics Internet https://wiki.dbpedia.org/ https://trends.google.com/trends/explore Reddit datasets Government https://www.ukdataservice.ac.uk/ https://data.gov.uk/ https://data.london.gov.uk/ https://www.data.gov/ https://opengovernmentdata.org/data/ https://www.cia.gov/library/publications/the-world-factbook/ https://data.gov.au/ https://opendata.cityofnewyork.us/ https://open.canada.ca/en/open-data Mathematics I got 717 problems… Project Euler problems Health https://healthdata.gov/ https://digital.nhs.uk/data-and-information/data-collections-and-data-sets https://www.who.int/data/collections https://www.who.int/gho/maternal_health/reproductive_health/en/ http://portals.broadinstitute.org/cgi-bin/cancer/datasets.cgi https://www.cdc.gov/datastatistics/ https://www.fda.gov/drugs/drug-approvals-and-databases/drugsfda-data-files https://github.com/publichealthengland/coronavirus-dashboard 1000 Genomes project USDA food composition Business https://www. [Read More]

Profiling resources

Tools

  • valgrind
  • perf
  • /usr/bin/time --verbose
  • Tracy
  • htop

Compiler options

Enabling in gcc

Use -p for prof and -pg for gprof. But it will take longer to run.

References

Hashing

Hash tables

A hash table (hash map) is a data structure that implements an associative array abstract data type, a structure that can map keys to values. A hash table uses a hash function to compute an index into an array of buckets or slots, from which the desired value can be found.

Hashing derives a fixed size result from an input. See Hash table.

Properties of a hashing algorithm

  • Stable: the same input generates the same output every time
  • Uniform: the hash values should be uniformly distributed through the available space
  • Efficient: the cost of generating a hash must be balanced with application need
  • Secure: the cost of finding data that produces a given hash is prohibitive

String hashing

  • Sum ASCII values – not uniform, not secure
  • Fold bytes of every four characters into an integer – not secure
  • CRC32 – not secure
  • MD5 – not efficient, not secure
  • SHA2 – stable, uniform, not efficient, secure

Handling collisions

  • Chaining
  • Open addressing
  • Load/fill factor – the ratio of filled hash table array slots
  • DFS/BFS – depth-first search versus breadth-first
  • Brute force
  • Greedy algo – stall at local maxima
  • Dynamic programming
  • Longest common subsequence
  • Simulated annealing
  • Random solutions
  • Polynomial
  • PTAS – approximation scheme
  • More Hash Function Tests
  • Linear probing
  • Robinhood hashing
  • Cuckoo hashing
  • Preimage (attack)
  • URL shortener

No comment

Leaving commented code

What are the alternatives to leaving commented old code in a codebase as a reference? Many times I’ve been saved by something that had been commented, but does the overhead of littering the code outweigh the occasional convenience? Commented code is also destined to bit rot. Add an extended comment to remind your future self what was removed Gist? Move to legacy code examples – would be cool if it turns up in IDE searches Document in a third party tool Get used to using git log -p GitLab blame Some other change visusalisation tool? [Read More]

static

Non-const global variables have external linkage by default Const global variables have internal linkage by default Functions have external linkage by default What’s the “static initialization order ‘fiasco’ (problem)”? C++ scoped static initialization is not thread-safe, on purpose! (pre-C++11) constinit static vs std::call_once vs double checked locking DCLP Double-Checked Locking Pattern const and static variables don’t have external linkage. [Read More]

Geospacial

  • GeoJSON is an open standard format designed for representing simple geographical features, along with their non-spatial attributes. It is based on the JSON format.”
  • Sequalize
  • GIS – geographical information standard
  • GML – geography markup language is the XML grammar defined by the Open Geospatial Consortium (OGC) to express geographical features.”
  • PostGIS is an open source software program that adds support for geographic objects to the PostgreSQL object-relational database.”

Run Apache

In Docker

docker run --detach --rm --publish 80:80 deanturpin/aws-apache FROMubuntu# Install dependenciesRUN apt updateRUN apt -y install apache2 vim# Install apache and write hello world messageRUN echo 'Kem chho!' > /var/www/html/index.html# Configure apacheRUN echo '. /etc/apache2/envvars' > /root/run_apache.shRUN echo 'mkdir -p /var/run/apache2' >> /root/run_apache.shRUN echo 'mkdir -p /var/lock/apache2' >> /root/run_apache.shRUN echo '/usr/sbin/apache2 -D FOREGROUND' >> /root/run_apache.shRUN chmod 755 /root/run_apache.shEXPOSE80CMD /root/run_apache. [Read More]