Skip to content

Instantly share code, notes, and snippets.

View foeken's full-sized avatar

Andre Foeken foeken

  • Nedap
  • Groenlo, The Netherlands
View GitHub Profile
@foeken
foeken / gist:f44e948bbc180fbdf3a5
Created March 13, 2016 16:15
font-color does not work
paragraph-divider {
font-color: $light-grey
margin-top: 12pt
margin-bottom: 12pt
text-alignment: center
content: "• • •"
}
@foeken
foeken / content.js
Last active May 23, 2016 16:41
Crude Google Chrome Ninchanese extension
function getImageUrl(searchTerm, callback, errorCallback) {
var api_key = 'XXX'; // NOTE, the API is limited so you need a personal API key and Custom Search Engine ID
var cx_key = 'XXX'; // SEE: https://github.com/hubot-scripts/hubot-google-images/issues/29#issuecomment-188960728
var searchUrl = 'https://www.googleapis.com/customsearch/v1?q=' + encodeURIComponent(searchTerm) + '&cx='+ cx_key +'&safe=high&searchType=image&key=' + api_key
var x = new XMLHttpRequest();
x.open('GET', searchUrl);
x.responseType = 'json';
x.onload = function() {

Multi tenant Elixir / Phoenix

I'm starting to use Elixir and Phoenix. I want to use a multi-tenant database setup like the Apartment gem provides for Rails apps.

The core setup is this:

  • Request comes in from specific subdomain
  • Translate subdomain to specific tenant database
  • Set the database to the tenant database
@foeken
foeken / encryptor.ex
Created September 13, 2018 08:45
ActiveSupport MessageEncryptor Elixir HMAC ExCrypto
defmodule ActiveSupportMessageEncryptor do
def encrypt(map, key) do
clear_text = Poison.encode!(map)
{:ok, aes_256_key} = Base.decode64(key)
{:ok, {iv, cipher_text}} = ExCrypto.encrypt(aes_256_key, clear_text)
payload = [cipher_text, iv] |> Enum.map(fn x -> Base.encode64(x) end) |> Enum.join("--") |> Base.encode64()
digest = :crypto.hmac(:sha, aes_256_key, payload) |> Base.encode16(case: :lower)
[payload, digest] |> Enum.join("--")
end
end
@foeken
foeken / chinese-fix.js
Created March 13, 2021 15:19
Fix Chinese page creation in Roam Research
// Fix broken page creation for Chinese
document.addEventListener('input', function(e){
var elem = e.target;
var pos = elem.selectionStart;
if (elem.nodeName != 'TEXTAREA' || e.data != '【') return;
elem.value = elem.value.replace('【','[]');
elem.setSelectionRange(pos, pos);
});
@foeken
foeken / roam.css
Created May 1, 2021 05:42
Zettelkasten CSS
//First the Better Roam Research with Custom font
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700;800&display=swap');
@import url("https://linuz90.github.io/better-roam-research/src/css/main.css");
body,
div,
textarea,
.level2 {
font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif !important; }
@foeken
foeken / enrich.rb
Created October 23, 2022 14:36
A Ruby based enricher the Tana Intermediate Format
# RUN: ruby filter.rb original.tif.json original.enriched.json
# GO TO START HERE ---------------------------------------------------------------------------
require "JSON"
require "securerandom"
filename = ARGV[0]
string = File.read(filename)
json = JSON.parse(string)
/* Define this only once, you can rename 'section' to any supertag you want to style */
.listContentItem:has(span[data-tag="section"]) .inlinerefnode span {
background-color: inherit !important;
color: white;
border: none;
}
/*
Per specific reference inside the supertag, you can define different colors.
# GO TO START HERE ---------------------------------------------------------------------------
require "JSON"
require "securerandom"
require "date"
filename = ARGV[0]
string = File.read(filename)
json = JSON.parse(string)
@foeken
foeken / tana.css
Last active November 9, 2023 08:45
/* ==UserStyle==
@name app.tana.inc - 10/21/2022, 9:02:58 PM
@namespace github.com/openstyles/stylus
@version 1.0.0
@description A new userstyle
@author Me
==/UserStyle== */
@-moz-document domain("app.tana.inc") {
:root {
--bulletDiameterInner: 6px;