This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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*/); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function createSocketListener(socket, store) { | |
return event => { | |
const action = JSON.parse(event.data); | |
store.dispatch(action); | |
} | |
} | |
// when creating your websocket connection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function timestampAction(action) { | |
return { | |
action, | |
time: Date.now() | |
} | |
} | |
function storageMiddleware() { | |
return () => next => action { | |
const stampedAction = timestampAction(action); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* style.css */ | |
.title { | |
font-weight: 700; | |
} | |
/* js-file */ | |
import styles from './style.css'; | |
//... | |
titleElement.className = styles.title; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"parser": "babel-eslint", | |
"env": { | |
"browser": true, | |
"node": true, | |
"es6": true | |
}, | |
"plugins": [ | |
"react" | |
], |
OlderNewer