Skip to content

Instantly share code, notes, and snippets.

Avatar

Andre Foeken foeken

View GitHub Profile
@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
@foeken
foeken / gist:3739301
Created Sep 17, 2012
Javascript tests :)
View gist:3739301
Feature: Adaptive layout functionality
As a registered user
In order to productive on a range of devices
I want Caren Pro to fluidly scale the amount of information displayed
Background:
Given a care provider "Care4All"
And a "Care4All" employee "Andre"
And "Andre" has an activated account
And "Andre" is logged in
View gist:2875479
Beste,
Jammergenoeg is de wet van Dam in 2011 in werking getreden die consumenten beschermt hiertegen. Bij een opzegging van een dienst is een maandelijkse opzegtermijn verplicht. Bij opzeggen dient het openstaande gefactureerde bedrag terug te worden betaald. Aangezien het hier gaat over een stilzwijgende verlenging na 2011 is de wet van toepassing. Er is zelfs jurisprudentie over hosting bedrijven en domeinaanvragen.
Dus nogmaals vraag ik u te voldoen aan de wet en de openstaande factuur te crediteren.
http://www.opzeggen.nl/wet-van-dam
BRON: http://ictrecht.nl/contracten-en-algemene-voorwaarden/veelgestelde-vragen-over-de-wet-van-dam/
##Geldt de Wet Van Dam ook voor hosting en domeinnamen?
You can’t perform that action at this time.