Skip to content

Instantly share code, notes, and snippets.

View Sysetup's full-sized avatar
🚀

Carlos H. Ramírez. Sysetup

🚀
View GitHub Profile
@Sysetup
Sysetup / script.sh
Last active July 24, 2018 23:25
Cut the last 10 seconds of several video files "Bash Script"
for file in `find . -name '*.mp4'`
do
echo "This is the file: " $file
DURATION=`ffprobe -i $file -show_format -v quiet | sed -n 's/duration=//p'`
echo "Duration: " $DURATION
FINAL=`echo "$DURATION - 10" | bc`
echo "Final Duration: " $FINAL
ffmpeg -i $file -t $FINAL -c copy $file.mp4
done
@Sysetup
Sysetup / app.js
Created March 17, 2018 03:17
Get var from an URL. JavaScript
function getQueryVariable(variable){
var query = window.location.search.substring(1);
try {
query = decodeURI(query);
} catch(e) {
console.error(e);
}
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
@Sysetup
Sysetup / materialsDBQueries.js
Created January 18, 2018 20:39
Async parallel
'use restrict';
/**
* Module dependences.
*/
var mongoose = require('mongoose');
/**
* load up the material model.
*/
@Sysetup
Sysetup / index.html
Last active January 3, 2018 01:31
Pagination
<div class="row">
<div class="col-md-12">
<h2>Compras a proveedores</h2>
<div class="compra-proveedor-container"></div>
<div class="page 1">
Page1
</div>
<div class="page 2">
Page2
</div>
@Sysetup
Sysetup / index.js
Last active November 3, 2017 17:52
Middleware example. ExpressJS.
app.use(getHost, sessionset);
sessionset({
secret: 'sysetup-x',
resave: false,
saveUninitialized: false,
name: 'session-x',
cookie: {
domain: host //var host; //Store hostname get with getHost function.
}
@Sysetup
Sysetup / index.js
Last active November 3, 2017 05:00
Circular structure to JSON
https://stackoverflow.com/a/31557814/3363138
function simpleStringify(object) {
var simpleObject = {};
for (var prop in object) {
if (!object.hasOwnProperty(prop)) {
continue;
}
if (typeof (object[prop]) == 'object') {
continue;
@Sysetup
Sysetup / controller.js
Created October 29, 2017 05:04
Insert a new register to a JSON file with NodeJS.
'use restrict';
/**
* Local module dependences.
*/
var db = require('./db');
/**
* Function that get all data entered in the signup form, check if user exist calling db.engine.findByUsername() function. Return the properly messages to the view according if user exist and password match.
*
@Sysetup
Sysetup / index.ejs
Last active October 24, 2017 14:40
EJS Template
<div class="list-group">
<!-- loop over blog posts and render them -->
<% posts.forEach((post) => { %>
<a href="/post/<%= post.id %>" class="list-group-item">
<h4 class="list-group-item-heading"><%= post.title %></h4>
<p class="list-group-item-text"><%= post.author %></p>
</a>
<% }) %>
</div>
@Sysetup
Sysetup / app.js
Created October 9, 2017 23:37
Middleware for Express.js
var express = require('express');
var app = express();
var server = app.listen(3000);
function logger(req,res,next){
console.log(new Date(), req.method, req.url);
next();
}
@Sysetup
Sysetup / index.html
Created September 9, 2017 04:07
DOM images preloader
<div class="load-container">
<img src="img/logo.gif" alt="logo" class="loading"/>
</div>
<div>
<img src="img/sequence/Frame0001.jpg" alt="" class="sequence" id="myimg">
</div>