Skip to content

Instantly share code, notes, and snippets.

Avatar

Andre Foeken foeken

View GitHub Profile
@foeken
foeken / roam.css
Created May 1, 2021
Zettelkasten CSS
View roam.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 / chinese-fix.js
Created Mar 13, 2021
Fix Chinese page creation in Roam Research
View chinese-fix.js
// 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 / encryptor.ex
Created Sep 13, 2018
ActiveSupport MessageEncryptor Elixir HMAC ExCrypto
View encryptor.ex
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
View appartment_phoenix.md

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 / content.js
Last active May 23, 2016
Crude Google Chrome Ninchanese extension
View content.js
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() {
@foeken
foeken / gist:f44e948bbc180fbdf3a5
Created Mar 13, 2016
font-color does not work
View gist:f44e948bbc180fbdf3a5
paragraph-divider {
font-color: $light-grey
margin-top: 12pt
margin-bottom: 12pt
text-alignment: center
content: "• • •"
}
@foeken
foeken / gist:018bbb5c1e482a9cf95b
Created Sep 30, 2014
A crude Github - Zendesk syncer
View gist:018bbb5c1e482a9cf95b
class Zendesk
ENDPOINT = "https://[DOMAIN].zendesk.com/api/v2"
USER = "[YOUR_USER_NAME]"
USER_ID = 0 #[YOUR_USER_ID]
TARGET_VIEW = 0 #[VIEW_ID]
BODY_FIELD_ID = 0 # [CUSTOM_BODY_FIELD_ID], We use an internal body
REPO_NAME_FIELD_ID = 0 #[REPO_NAME_FIELD_ID], We use a selectbox
GITHUB_FIELD_ID = 0 #[GITHUB_FIELD_ID], We use a checkbox
View gist:d4b4e207fda19abb9614
// Hack the 1password extention on OSX:
// Locate: /Users/[USERNAME]/Library/Application Support/Google/Chrome/Default/Extensions/aomjjhallfgjeglblehebfpbcfeobpgk
// Add this to global.min.js, look for var Ka = [{template},{template},{template}]
{
template_for: [/:\/\/mijn\.ing\.nl\//],
hints: [
["input[type=text]", "username"],
["input[type=password]", "password"]
@foeken
foeken / keybase.md
Created Mar 15, 2014
Keybase Proof
View keybase.md

Keybase proof

I hereby claim:

  • I am foeken on github.
  • I am dreetje (https://keybase.io/dreetje) on keybase.
  • I have a public key whose fingerprint is 7DC5 D6AA 64D6 6CF1 FF9E 0686 65BB 0DBC E7CE 60FE

To claim this, I am signing this object:

@foeken
foeken / gist:4160705
Created Nov 28, 2012
RubyMotion Bug in Module ordering
View gist:4160705
# Take the following setup, this works if everything is inside a single file.
# app/foo/monkey.rb
module Foo
module Monkey
puts "Monkey"
end
end
# app/foo/nut.rb