Skip to content

Instantly share code, notes, and snippets.

View jakobdamjensen's full-sized avatar

Jakob Dam Jensen jakobdamjensen

View GitHub Profile
config :sentry,
use_error_logger: true,
dsn: System.get_env("SENTRY_DSN"),
environment_name: Mix.env(),
root_source_code_path: File.cwd!(),
tags: %{
env: Mix.env()
},
included_environments: [:prod, :staging],
enable_source_code_context: true
defmodule MyApp.Facade do
defmacro facade(mod) do
quote bind_quoted: [mod: mod] do
Enum.each apply(mod, :__info__, [:functions]), fn {fun, arity} ->
values = Enum.map(1..arity, &(Macro.var(:"arg#{&1}", mod)))
defdelegate unquote(fun)(unquote_splicing(values)), to: mod
end
end
end
end
@jakobdamjensen
jakobdamjensen / mixin.js
Last active December 27, 2017 01:02
example of mixing pub-su
// utilizes the browser eventsystem
// usefull in cases where you need communication between independent components
// registered events are automatically removed onunload with preserving any other onunload handler
var eventsMixin = function(target) {
var _subscriptions = [];
target.broadcast = function(type, payload) {
var ev = new CustomEvent(type, {
detail: payload,
@jakobdamjensen
jakobdamjensen / global_template_helpers.js
Created December 26, 2014 19:08
Global Marionette Templatehelpers
var Mn = require('backbone.marionette'),
Radio = require('backbone.radio'),
i18nChannel = Radio.channel('i18n'),
_ = require('underscore');
_.extend(Mn.View.prototype, {
templateHelpers: {
t: function(key){
.tabbar__content-container {
> * {
position: absolute;
height: 100%;
width: 100%;
}
}
.tabbar__items {
padding: 0px;
var convertDateTimeFieldsToDate = function( date, time, template ) {
var startDate = document.querySelector( date ).value,
startDateSplitted = startDate.match( /([0-9]{2})\/([0-9]{2})-([0-9]{4})/ ),
startTime = document.querySelector( time ).value,
startTimeSplitted = startTime.match( /([0-9]{2}):([0-9]{2})/ ),
year = startDateSplitted[ 3 ],
month = startDateSplitted[ 2 ],
day = startDateSplitted[ 1 ],
new Region()
.publishedDocuments()
.query({whereIn: ['regions.id', regionIds], where: ['publishedDocuments.updated_at', '>=', new Date(timestamp)]})
.fetchAll({withRelated: [
'publishedDocuments.images',
'publishedDocuments.ecareSections',
'publishedDocuments.regions']
})
.then(function (collection) {
var map = {}, keys, i, maxLength, result = [];
var knex = require('knex')({
client: 'pg',
debug: true,
connection: {
host: 'localhost',
//user: 'your_database_user',
//password: 'your_database_password',
database: 'ecare_dump_db',
charset: 'utf8'
}
@jakobdamjensen
jakobdamjensen / Async throw
Created October 2, 2014 09:31
Async throw
Meteor.methods({
insertIt: function (name) {
var fut = new Future();
Books.insert({title: name}, function(err, result){
if(err){
fut.throw(err);
}
});
@jakobdamjensen
jakobdamjensen / Promises.js
Created August 21, 2014 08:54
Lidt tomme tanker
var findAndRemove = function(collection, query){
var promise = new Promise(),
remove = function(err, result){
var ids = [];
if( err ){
promise.resolve(err);
return;
}