Skip to content

Instantly share code, notes, and snippets.

View tomlankhorst's full-sized avatar
🌊

Tom Lankhorst tomlankhorst

🌊
View GitHub Profile
@apollo13
apollo13 / traefik.nomad
Last active April 15, 2024 14:46
Traefik 2.5 with Consul Connect on Nomad
# Simple example to deploy traefik with consul connect enabled.
# For simplicity the job includes traefik as well as the backend service.
# Please note that traefik currently only supports connect for HTTP.
job "traefik-consul-connect-demo" {
datacenters = ["dc1"]
group "edge" {
network {
mode = "bridge"
@cls
cls / base64.hpp
Last active January 23, 2020 07:52
Straightforward constexpr Base64 block encoding in C++14
#include <array>
#include <tuple>
constexpr std::array<char, 4> base64(uint8_t octet0, uint8_t octet1, uint8_t octet2)
{
constexpr std::array<char, 64> table = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
@edwinheij
edwinheij / streamLargeFile.php
Last active August 20, 2022 22:17
Stream large file with Laravel
<?php
//disable execution time limit when downloading a big file.
set_time_limit(0);
/** @var \League\Flysystem\Filesystem $fs */
$fs = Storage::disk('local')->getDriver();
$fileName = 'bigfile';
$metaData = $fs->getMetadata($fileName);
@artivis
artivis / boost_serialization_eigen.h
Last active December 1, 2022 01:47
Boost serialization for Eigen Matrix
/**
------------------------------------------------------------------------------------
!!!!! This was moved to https://github.com/artivis/boost_serialization_helper !!!!!
------------------------------------------------------------------------------------
*/
#ifndef _BOOST_SERIALIZATION_EIGEN_
#define _BOOST_SERIALIZATION_EIGEN_
#include <Eigen/Sparse>
@paulkaplan
paulkaplan / colorTempToRGB.js
Last active March 4, 2024 10:29
Color Temperature to RGB
// From http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/
// Start with a temperature, in Kelvin, somewhere between 1000 and 40000. (Other values may work,
// but I can't make any promises about the quality of the algorithm's estimates above 40000 K.)
function colorTemperatureToRGB(kelvin){
var temp = kelvin / 100;
@ptrv
ptrv / .ctags.txt
Created January 20, 2013 01:41
ctags language support for latex and bibtex
--langdef=latex
--langmap=latex:.tex .latex
--regex-latex=/^\\part[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/PART \2/s,part/
--regex-latex=/^\\part[[:space:]]*\*[[:space:]]*\{([^}]+)\}/PART \1/s,part/
--regex-latex=/^\\chapter[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/CHAP \2/s,chapter/
--regex-latex=/^\\chapter[[:space:]]*\*[[:space:]]*\{([^}]+)\}/CHAP \1/s,chapter/
--regex-latex=/^\\section[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\2/s,section/
--regex-latex=/^\\section[[:space:]]*\*[[:space:]]*\{([^}]+)\}/\1/s,section/
--regex-latex=/^\\subsection[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/-\2/s,subsection/
--regex-latex=/^\\subsection[[:space:]]*\*[[:space:]]*\{([^}]+)\}/-\1/s,subsection/
@Lee-R
Lee-R / lithash.cpp
Created October 5, 2012 13:27
C++11 compile-time hash of literal strings.
#include <cstdint>
namespace detail
{
// FNV-1a 32bit hashing algorithm.
constexpr std::uint32_t fnv1a_32(char const* s, std::size_t count)
{
return ((count ? fnv1a_32(s, count - 1) : 2166136261u) ^ s[count]) * 16777619u;
}
} // namespace detail
@gsomoza
gsomoza / Acme_Dynamic.xml
Created April 1, 2011 13:44
Generating Dynamic Javascript for a Magento Module
<!-- app/etc/modules/Acme_Dynamic.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Acme_Dynamic>
<codePool>local</codePool>
<active>true</active>
</Acme_Dynamic>
</modules>
</config>