Skip to content

Instantly share code, notes, and snippets.

View pierreabreup's full-sized avatar

Pierre Abreu pierreabreup

View GitHub Profile
<html lang="pt-br">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<link href="https://fonts.googleapis.com/css?family=Nunito:200,300,400,600,700,800,900|Open+Sans+Condensed:300,300i,700|Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i" rel="stylesheet">
<title>My Cool App ;)</title>
<style type="text/css">
body {
background-color: #F2F4F5;
text-align: center;
defmodule MyAppWeb.ErrorView do
use MyAppWeb, :view
def template_not_found(template, _assigns) do
%{errors: %{detail: Phoenix.Controller.status_message_from_template(template)}}
end
end
@pierreabreup
pierreabreup / render_phoenix_error_view_inside_plug.ex
Last active May 11, 2020 22:00
This code shows you how to render a phoenix error view inside a Plug
defmodule MyAppWeb.Plug.Authorization do
@behaviour Plug
import Plug.Conn
def init(opts), do: opts
def call(conn, _) do
with {:ok, token} <- token(conn),
{:ok, current_user} <- authorize(token) do
import React from 'react'
import PropTypes from 'prop-types'
import axios from 'axios'
class H5PVideoState {
constructor(h5pVideoClass) {
this.h5pVideoClass = h5pVideoClass
this.lastState = null
this.lastCurrentTime = null
@pierreabreup
pierreabreup / h5p.xapi.tracking.send-to-lrs.js
Last active January 21, 2021 02:29
Tracking H5P xapi events and send it to LRS
import React from 'react'
import PropTypes from 'prop-types'
import axios from 'axios'
const H5pContent = ({ iframeSrc }) => {
const handleContentRef = dom => {
if (dom) {
dom.onload = () => {
dom.contentWindow.H5P.externalDispatcher.on('xAPI', function(event) {
console.log('INITIAL STATEMENT ON externalDispatcher')
@pierreabreup
pierreabreup / h5p.xapi.tracking.js
Created March 8, 2020 17:08
Tracking xAPI statemente event on H5P
import React from 'react'
import PropTypes from 'prop-types'
const H5pContent = ({ iframeSrc }) => {
const handleContentRef = dom => {
if (dom) {
dom.onload = () => {
dom.contentWindow.H5P.externalDispatcher.on('xAPI', function(event) {
console.log('INITIAL STATEMENT ON externalDispatcher')
console.log(event.data.statement)
import React from 'react'
import { mount } from 'enzyme'
import { MockedProvider } from "react-apollo/test-utils"
import { InMemoryCache } from 'apollo-cache-inmemory'
import { BrowserRouter } from 'react-router-dom'
import { TrailDetails } from 'views'
import { GRAPHQL_MOCKS_TRAILS } from '__mocks__/TrailDetails/GraphqlMocks.js'
import {IntrospectionFragmentMatcher} from 'apollo-cache-inmemory';
import introspectionQueryResultData from '../../../mobyGraphqlSchema.json';