Skip to content

Instantly share code, notes, and snippets.

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

Allan Freitas allanfreitas

🏠
Working from home
View GitHub Profile
@allanfreitas
allanfreitas / send_an_mail_from_terminal.md
Created September 19, 2017 02:08 — forked from joseluisq/send_an_mail_from_terminal.md
Send an email from terminal

Send an email from terminal

echo "This is the body" | mail -r notifications -s "This is the subject" [email protected] ; tail -f /var/log/maillog
@allanfreitas
allanfreitas / slugify.js
Created September 19, 2017 02:08 — forked from joseluisq/slugify.js
Javascript Slugify
function slugify (text, ampersand = 'and') {
const a = 'àáäâèéëêìíïîòóöôùúüûñçßÿỳýœæŕśńṕẃǵǹḿǘẍźḧ'
const b = 'aaaaeeeeiiiioooouuuuncsyyyoarsnpwgnmuxzh'
const p = new RegExp(a.split('').join('|'), 'g')
return text.toString().toLowerCase()
.replace(/[\s_]+/g, '-') // Replace whitespace and underscore with single hyphen
.replace(p, c =>
b.charAt(a.indexOf(c))) // Replace special chars
.replace(/&/g, `-${ampersand}-`) // Replace ampersand with custom word
@allanfreitas
allanfreitas / letsencrypt_auto_renew.sh
Created September 19, 2017 02:07 — forked from joseluisq/letsencrypt_auto_renew.sh
Auto renew Let's Encrypt certs script for Nginx server configs.
#!/bin/sh
######################################################################
# Auto renew Let's Encrypt certs script for Nginx server configs
######################################################################
#
# README:
# This script renew previous certs ONLY.
# Make sure you have "certbot" installed and have created your first
# certs before to run it.
@allanfreitas
allanfreitas / mysql_query_log.md
Created September 19, 2017 02:05 — forked from joseluisq/mysql_query_log.md
How to enable the MySQL/MariaDB general query log

How to enable the MySQL/MariaDB general query log

  1. Enter to MySQL/MariaDB server command-line tool (change root with your username and password):
mysql -u root -proot
  1. Set the general log file path:
SET GLOBAL general_log_file='/var/log/mysql/mycustom.log';
// app/Http/Middleware/AssetUrls.js
// Middle where to load mix-manifest.json
// file Laravel Mix generates
class AssetUrls {
* handle (request, response, next) {
const View = use('View')
View.global('assetUrls', function () {
return require('../../../public/mix-manifest.json')
@allanfreitas
allanfreitas / FooController.php
Created August 3, 2016 01:13 — forked from igorw/FooController.php
Silex convention-based controllers
<?php
// src/Foobar/Controller/FooController.php
namespace Foobar\Controller;
class FooController
{
public function helloAction($request)
{
@allanfreitas
allanfreitas / browserify.js
Created July 8, 2016 10:48 — forked from revolunet/browserify.js
Sample split grunt-browserify config for vendors + applications files with react
var externalModules = [
'fs',
'events',
'react',
'react-addons',
'lodash'
];
module.exports = {
vendors: {
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var libs = ["underscore", "jquery"];
gulp.task("vendor", function () {
var b = browserify();
libs.forEach(function (lib) {
@allanfreitas
allanfreitas / AnnouncementList.js
Created June 30, 2016 18:37 — forked from akaHeimdall/AnnouncementList.js
Sample react component for listing announcements
// AnnouncementList
// <AnnouncementList/>
import React from 'react';
import marked from 'marked';
var AnnouncementsList = React.createClass({
renderAnnouncement : function(key) {
// var linkState = this.props.linkState;
@allanfreitas
allanfreitas / App.js
Created June 30, 2016 18:36 — forked from akaHeimdall/App.js
react component for main app that loads announcement list
// App
// <App/>
import React from 'react';
import Header from './Header';
import SenderNav from './SenderNav';
import Dashboard from './Dashboard';
import AnnouncementsList from './Announcements/AnnouncementsList';