Skip to content

Instantly share code, notes, and snippets.

View rodrigoespinozadev's full-sized avatar
🏠
Working from home

Rodrigo Espinoza rodrigoespinozadev

🏠
Working from home
View GitHub Profile
'use statics';
export default {
FETCH_ME: 'FETCH_ME',
FETCH_LIKES: 'FETCH_LIKES',
FETCH_TRACKS: 'FETCH_TRACKS',
FETCH_USER: 'FETCH USER'
};
@rodrigoespinozadev
rodrigoespinozadev / express-server-side-rendering.md
Created December 31, 2019 20:15 — forked from joepie91/express-server-side-rendering.md
Rendering pages server-side with Express (and Pug)

Terminology

  • View: Also called a "template", a file that contains markup (like HTML) and optionally additional instructions on how to generate snippets of HTML, such as text interpolation, loops, conditionals, includes, and so on.
  • View engine: Also called a "template library" or "templater", ie. a library that implements view functionality, and potentially also a custom language for specifying it (like Pug does).
  • HTML templater: A template library that's designed specifically for generating HTML. It understands document structure and thus can provide useful advanced tools like mixins, as well as more secure output escaping (since it can determine the right escaping approach from the context in which a value is used), but it also means that the templater is not useful for anything other than HTML.
  • String-based templater: A template library that implements templating logic, but that has no understanding of the content it is generating - it simply concatenates together strings, potenti
@rodrigoespinozadev
rodrigoespinozadev / my.cnf
Created December 6, 2019 05:06 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaSQL (on Ubuntu, CentOS etc. servers)
# Optimized my.cnf configuration for MySQL/MariaSQL
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# === Updated December 2018 ===
#
# The settings provided below are a starting point for a 2GB - 4GB RAM server with 2-4 CPU cores.
# If you have less or more resources available you should adjust accordingly to save CPU,
# RAM and disk I/O usage.
# The settings marked with a specific comment or the word "UPD" after the value
curl -i -H 'Content-type: application/json' -H 'Authorization: key=<your_server_key>' -XPOST https://fcm.googleapis.com/fcm/send -d '{
"registration_ids":["registration_ids", "of the", "target", "devices as array"],
"notification": {
"title":"Title of your notification",
"body":"content of your notification"
},
"data": {
"key1" : "value1",
"key2" : "value2",
"key3" : 23.56565,
@rodrigoespinozadev
rodrigoespinozadev / adminer_setup.sh
Created September 17, 2019 16:51 — forked from zloynemec/adminer_setup.sh
Secure adminer nginx setup
# Secure adminer setup
# Author Taras Kozlov
# download adminer to separate directory
mkdir -p /var/www/admin
cd /var/www/admin
wget http://www.adminer.org/latest.php -O adminer.php
echo '<?php phpinfo(); >' > info.php
sudo -i
@rodrigoespinozadev
rodrigoespinozadev / findUser.js
Created September 9, 2019 04:25 — forked from paigen11/findUser.js
Passport local and Passport JWT authentication with custom callbacks examples with a user registration MERN service.
import passport from 'passport';
module.exports = app => {
app.get('/findUser', (req, res, next) => {
passport.authenticate('jwt', { session: false }, (err, user, info) => {
if (err) {
console.log(err);
}
if (info != undefined) {
console.log(info.message);
# Install dependencies
% apt-get install cifs-utils
# Create mount point folder
% mkdir /mnt/capsule
# Create credentials file
% touch /root/.cifs/capsule
% cat /root/.cifs/capsule
username=username
@rodrigoespinozadev
rodrigoespinozadev / server.js
Created May 27, 2019 19:35 — forked from tagr/server.js
Node.js/Express: Add Expires header to /images and /stylesheets directories
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path');
@rodrigoespinozadev
rodrigoespinozadev / db-connect-test.php
Created May 11, 2019 16:55 — forked from FGDATA/db-connect-test.php
Script for a quick PHP MySQL DB connection test; using mysqli
<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbname = 'name';
$dbuser = 'user';
$dbpass = 'pass';
$dbhost = 'host';
$connect = mysqli_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
@rodrigoespinozadev
rodrigoespinozadev / safe_display_images.php
Created April 24, 2019 00:18 — forked from LeonanCarvalho/safe_display_images.php
My way to safely display external pictures
/* =========================================================
* My way to safely display external pictures
* =========================================================
* Copyright 2015 Leonan Carvalho @leonancarvalho
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0