This file contains hidden or 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
| MIT License | |
| Copyright (c) 2015 Kaleb Fulgham | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: |
This file contains hidden or 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 (store) => { | |
| const requireLogin = (nextState, replace, cb) => { | |
| const { auth: { user } } = store.getState(); | |
| if (!user) { | |
| // oops, not logged in, so can't be here! | |
| replace('/login?returnUrl=' + | |
| encodeURIComponent(nextState.location.pathname + nextState.location.search)); | |
| } | |
| cb(); | |
| }; |
This file contains hidden or 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
| var request = require('request'); | |
| var zlib = require('zlib'); | |
| request(url, {encoding: null}, function(err, response, body){ | |
| if(response.headers['content-encoding'] == 'gzip'){ | |
| zlib.gunzip(body, function(err, dezipped) { | |
| callback(dezipped.toString()); | |
| }); | |
| } else { | |
| callback(body); |
This file contains hidden or 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
| // the main app file | |
| import express from "express"; | |
| import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db) | |
| import authenticate from "./authentication"; // middleware for doing authentication | |
| import permit from "./permission"; // middleware for checking if user's role is permitted to make request | |
| const app = express(), | |
| api = express.Router(); | |
| // first middleware will setup db connection |
This file contains hidden or 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
| /** | |
| * Sample React Native App | |
| * https://github.com/facebook/react-native | |
| * @flow | |
| */ | |
| import React, { Component } from 'react'; | |
| import { | |
| AppRegistry, | |
| StyleSheet, |
This file contains hidden or 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 * as My from './components/my-components.js'; | |
| export default class App extends React.Component { | |
| render() { | |
| return ( | |
| <div> | |
| <My.Foo /> | |
| <My.Bar /> |
This file contains hidden or 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
| --------------- FFMPEG command line | |
| ffmpeg = child_process.spawn("ffmpeg", [ | |
| "-i", rtsp , "-vcodec", "copy", "-f", "mp4", "-f", "segment", "-segment_time", recSeg, "-segment_wrap", 2, "-map", "0", "-segment_format", "mp4", "-reset_timestamps", "1", "-y", "plugins/security/videos/" + camName + "/rec-%01d.mp4" | |
| ], {detached: false}); | |
| ---------------- Node.JS streamer | |
| // Stream mp4 video file based on URL request from client player. Accept request for partial streams | |
| // Code attribution: https://github.com/meloncholy/vid-streamer/blob/master/index.js (MIT license) | |
| var recStream = function (req, resp) { | |
| var stream; |
This file contains hidden or 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, { Component } from 'react' | |
| import { BrowserRouter as Router, Route, Link, Match, Redirect, Switch } from 'react-router-dom' | |
| import OverviewPage from './page/OverviewPage' | |
| import AccountPage from './page/AccountPage' | |
| /* | |
| Layouts, inline define here for demo purpose | |
| you may want to define in another file instead | |
| */ |
This file contains hidden or 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 { browserHistory } from 'react-router'; | |
| /** | |
| * @param {Object} query | |
| */ | |
| export const addQuery = (query) => { | |
| const location = Object.assign({}, browserHistory.getCurrentLocation()); | |
| Object.assign(location.query, query); | |
| browserHistory.push(location); | |
| }; |