Skip to content

Instantly share code, notes, and snippets.

View Narven's full-sized avatar
👾
Walking to the fridge...

Pedro Luz Narven

👾
Walking to the fridge...
View GitHub Profile
ljf akdsfjsdkfjasldkj
@Narven
Narven / stream.js
Created April 8, 2019 14:14 — forked from DingGGu/stream.js
NodeJS Mp3 Streaming ExpressJS
var express = require('express');
var app = express();
var fs = require('fs');
app.listen(3000, function() {
console.log("[NodeJS] Application Listening on Port 3000");
});
app.get('/api/play/:key', function(req, res) {
var key = req.params.key;
@Narven
Narven / livestream.js
Last active April 7, 2019 13:11 — forked from deandob/livestream
Node.JS function to remux mp4/h.264 video from an IP camera to a HTML5 video tag using FFMPEG
// Live video stream management for HTML5 video. Uses FFMPEG to connect to H.264 camera stream,
// Camera stream is remuxed to a MP4 stream for HTML5 video compatibility and segments are recorded for later playback
var liveStream = function (req, resp) { // handle each client request by instantiating a new FFMPEG instance
// For live streaming, create a fragmented MP4 file with empty moov (no seeking possible).
var reqUrl = url.parse(req.url, true)
var cameraName = typeof reqUrl.pathname === "string" ? reqUrl.pathname.substring(1) : undefined;
if (cameraName) {
try {
cameraName = decodeURIComponent(cameraName);
var spawn = require("child_process").spawn;
var converter = spawn("gst-launch-0.10", ["filesrc location=/dev/stdin ! decodebin ! audioconvert ! audioresample ! lame ! filesink location=/dev/stdout"]);
converter.stdout.on("data", function(chunk) {
console.log(chunk.toString());
});
converter.stderr.on("data", function(chunk) {
console.log("err: ", chunk.toString());
});
import QtQuick 2.4
Column {
width: parent.width
height: parent.height
property alias model: columnRepeater.model
Repeater {
id: columnRepeater
@Narven
Narven / regex-yyyy-mm-dd.js
Created November 29, 2018 12:51 — forked from m-coding/regex-yyyy-mm-dd.js
javascript regex to match date pattern YYYY-MM-DD
// allows YYYY/M/D and periods instead of slashes
// http://stackoverflow.com/questions/24989065/trying-to-validate-yyyy-mm-dd
/^\d{4}[\/.]\d{1,2}[\/.]\d{1,2}$/
// YYYY-MM-DD and YYYY-M-D
// http://stackoverflow.com/questions/6177975/how-to-validate-date-with-format-mm-dd-yyyy-in-javascript
/^\d{4}\-\d{1,2}\-\d{1,2}$/
// YYYY-MM-DD
// https://gist.github.com/arth2o/8471150
@Narven
Narven / tsconfig.json
Created July 9, 2018 09:20
Default tsconfig.json
{
"compilerOptions": {
/* Basic Options */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
type ValidSymbol = '#' | '$'
interface GenerateConfig {
symbol: ValidSymbol;
length: number;
}
function generateRandomId (symbol: ValidSymbol, length: number): string
function generateRandomId (options: GenerateConfig): string
function generateRandomId (optionsOrSymbol: any): string {
@Narven
Narven / bad.ts
Last active July 4, 2018 08:50
looking bad ts file
type ValidSymbol = '#' | '$'
interface GenerateConfig {
symbol: ValidSymbol;
bar: number;
}
function generateRandomId (symbol: ValidSymbol, bar: number): string
function generateRandomId (options: GenerateConfig): string
function generateRandomId (optionsOrSymbol: any): string {
@Narven
Narven / .gitconfig
Created May 15, 2018 06:05
alias defined on my ~./gitconfig
# basic commands
a = add
b = branch
cp = cherry-pick
s = status -s
cl = clone
ci = commit
ck = checkout
br = branch
diff = diff --word-diff