Skip to content

Instantly share code, notes, and snippets.

View robinvdvleuten's full-sized avatar
🚀

Robin van der Vleuten robinvdvleuten

🚀
View GitHub Profile
@robinvdvleuten
robinvdvleuten / slimmelezer.livemd
Created March 20, 2024 14:20
Connect to SlimmeLezer through GenServer

Connect to DSMR meter

Mix.install([
  {:dsmr, github: "mijnverbruik/dsmr"},
  {:kino, "~> 0.12.0"},
  {:kino_vega_lite, "~> 0.1.10"}
])

alias VegaLite, as: Vl
@robinvdvleuten
robinvdvleuten / up-transition.js
Created May 1, 2020 14:14
Add support for Tailwind transitions in Unpoly
import { getUpAttributes } from "./utils"
function transition(element, stages) {
stages.start()
stages.during()
requestAnimationFrame(() => {
// Note: Safari's transitionDuration property will list out comma separated transition durations
// for every single transition property. Let's grab the first one and call it a day.
let duration = Number(getComputedStyle(element).transitionDuration.replace(/,.*/, '').replace('s', '')) * 1000
@robinvdvleuten
robinvdvleuten / auth.js
Created April 4, 2020 08:00
React + Authorization Grant
import React, { useContext, useMemo, useState } from 'react'
class OAuthError extends Error {
constructor(error, description, uri) {
super(error)
this._description = description
this._uri = uri
}
@robinvdvleuten
robinvdvleuten / CorsListener.php
Created September 11, 2017 11:39 — forked from frodosghost/CorsListener.php
CORS Listener and Handling with Symfony2
<?php
namespace AppBundle\EventListener;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
@robinvdvleuten
robinvdvleuten / generate-pushid.js
Created January 24, 2017 11:28 — forked from mikelehen/generate-pushid.js
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
<?php
$filename = __DIR__.'/../dist/'.preg_replace('#(\?.*)$#', '', $_SERVER['REQUEST_URI']);
if (php_sapi_name() === 'cli-server' && is_file($filename)) {
return false;
}
require_once __DIR__.'/../vendor/autoload.php';
use Aws\Lambda\LambdaClient;
import React from 'react';
import { renderToString } from 'react-dom/server';
import Application from '../client/app';
export function handler(event, context) {
const markup = renderToString(<Application name={event.name} />);
context.succeed(markup);
};
<html>
<head>
<meta charset="utf-8">
<title>php-react-lamda-example</title>
</head>
<body>
<div id="root"></div>
<script>
window.__INITIAL_PAYLOAD__ = { name: "World" };
</script>
import React from 'react';
const Application = (props) => (
<div>Hello, {props.name}!</div>
);
export default Application;

Keybase proof

I hereby claim:

  • I am robinvdvleuten on github.
  • I am robinvdvleuten (https://keybase.io/robinvdvleuten) on keybase.
  • I have a public key ASArf4GdyA_UfDxuq4-m9lZLwoj8JBNhut8x_eFzL-vKwwo

To claim this, I am signing this object: