Skip to content

Instantly share code, notes, and snippets.

View Sysetup's full-sized avatar
🚀

Carlos HRG. Sysetup

🚀
View GitHub Profile
@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 / 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.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 / 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 / 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 / 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