Skip to content

Instantly share code, notes, and snippets.

View Scarysize's full-sized avatar

Franz Scarysize

View GitHub Profile
std::vector<uint8_t> RTPPacket::pack(
uint8_t payloadType,
uint16_t sequenceNumber,
uint32_t timestamp,
std::vector<uint8_t> &data
) {
std::vector<uint8_t> header(12, 0);
const uint8_t version = 2;
header[0] = (version << 6) | header[0];
header[1] = (0x7F & payloadType);
import React from 'react';
import moment from 'moment';
moment.locale('de');
const EventItem = ({ event, blacklist, recommend }) => {
const time = moment(event.start).format('lll');
return (
<li className="collection-item">
<div className="row">
<a href={fbUrl} target="_blank">
/**
* Creates a redux middleware which will send every action over a websocket connection.
* @param {WebSocket} socket The websocket connection object
* @return {Function} A redux middleware function
*/
function createSyncMiddleware(socket) {
return () => next => action => {
// your actions should not contain any functions, which can´t be stringified
socket.send(JSON.stringify(action));
// don´t forget this otherwise the middleware will swallow all actions
import {applyMiddleware, createStore, combineReducers} from 'redux';
import {createSyncMiddleware} from '...somewhere';
export default function initStore(socket) {
let middelware = applyMiddleware(/* redux-logger, thunk etc.*/);
if (/* check if this is the 'leader' */) {
middleware = applyMiddleware(createSyncMiddleware(socket), /* other middlware*/);
}
export default function createSocketListener(socket, store) {
return event => {
const action = JSON.parse(event.data);
store.dispatch(action);
}
}
// when creating your websocket connection
function timestampAction(action) {
return {
action,
time: Date.now()
}
}
function storageMiddleware() {
return () => next => action {
const stampedAction = timestampAction(action);
export function createStorageListener(store) {
return event => {
// the storage event tells you which value changed
const {action} = JSON.parse(event.newValue);
store.dispatch(action);
}
}
// when you setup the app
function MeteoGroupInteractiveMap(domElement, options) {
constructor(domElement, options) {
// Do we want to hide this?
// We might need to hide this in closures for map functionalities (zoom, pan etc.)
// IMO we should definitly hide it.
this.map = new google.maps.Map(domElement, options);
// better:
const map = new google.maps.Map(domElement, options);
this.setupMapControls(map);
/* style.css */
.title {
font-weight: 700;
}
/* js-file */
import styles from './style.css';
//...
titleElement.className = styles.title;
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": [
"react"
],