Consider a list of strings you need to permanently assign a random color.
First you should turn the string into a hash.
var string = "string"
var hash = 0
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
EMSCRIPTEN_HOME = ~/Documents/inbox/emscripten | |
PROJECT = myproject | |
SOURCES = $(wildcard *.cc) $(wildcard *.c) | |
OBJECTS = $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(SOURCES))) | |
set-native: | |
$(eval CXX := clang -x c++) | |
$(eval CC := clang) | |
$(eval CPPFLAGS := -g -O2 -DHAS_TR1) |
#include <iostream> | |
#include <fstream> | |
#include <string> | |
#ifdef EMSCRIPTEN | |
#include <emscripten/emscripten.h> | |
#endif | |
namespace | |
{ |
# Installed barrier_breaker rc2 OpenWrt image | |
# Set computer to 192.168.1.2 | |
telnet 192.168.1.1 | |
passwd | |
# Set new root password; this enables ssh | |
# Set up the wired network interface as a DCHP client | |
cat > /etc/config/network <<\EOF |
#include <chrono> | |
#include <string> | |
#include <sstream> | |
#include <vector> | |
#include <iostream> | |
std::string to_string(const int i) | |
{ | |
std::stringstream ss; | |
ss << i; |
// Zero-Clause BSD (more permissive than MIT, doesn't require copyright notice) | |
// | |
// Permission to use, copy, modify, and/or distribute this software for any purpose | |
// with or without fee is hereby granted. | |
// | |
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | |
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | |
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | |
// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
#include <exception> | |
#include <functional> | |
#ifdef __EMSCRIPTEN__ | |
#include <emscripten.h> | |
#include <SDL.h> | |
#include <SDL_image.h> | |
#include <SDL_ttf.h> |
#!/bin/bash | |
if [ "$EUID" -ne 0 ] | |
then echo "Must be root" | |
exit | |
fi | |
apt-get update -y | |
apt-get upgrade -y | |
apt-get dist-upgrade -y |
#!/bin/bash | |
# Thanks to https://gist.github.com/Lewiscowles1986/ce14296e3f5222082dbaa088ca1954f7 | |
if [ "$(whoami)" != "root" ]; then | |
echo "Run script as ROOT please. (sudo !!)" | |
exit | |
fi | |
echo "deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi" > /etc/apt/sources.list.d/stretch.list | |
echo "APT::Default-Release \"jessie\";" > /etc/apt/apt.conf.d/99-default-release |