Skip to content

Instantly share code, notes, and snippets.

View hectorperez's full-sized avatar

Hector Perez hectorperez

View GitHub Profile
@hectorperez
hectorperez / mysql_create
Last active August 29, 2015 14:00
MySQL: Create database, user & give privileges
CREATE DATABASE new_database;
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'new_password';
GRANT ALL PRIVILEGES ON your_database_name.* TO 'your_user'@'localhost';
FLUSH PRIVILEGES;
@hectorperez
hectorperez / trigger
Created April 23, 2014 16:38
Trigger example
DROP TRIGGER IF EXISTS your_trigger_name;
DELIMITER $$
CREATE TRIGGER your_trigger_name
AFTER INSERT ON your_table_name FOR EACH ROW
BEGIN
...
END$$
DELIMITER;
@hectorperez
hectorperez / apache
Last active August 29, 2015 14:00
Apache commands
- apachectl configtest (check your Apache config files for any errors before restarting, because Apache will not start again if your config files have syntax errors)
- apachectl restart
- a2ensite [site]
- a2dissite [site]
- service apache2 reload
- service apache2 restart
- service apache2 stop
- service apache2 start
@hectorperez
hectorperez / passenger
Created April 24, 2014 12:47
Passenger commands
passenger-status
passenger-memory-stats
@hectorperez
hectorperez / utf8_MySQL_script
Created April 30, 2014 11:01
utf8 en MySQL script
SET NAMES utf8;
SET CHARACTER SET utf8;

Google Speech To Text API

Base URL: https://www.google.com/speech-api/v1/recognize
It accepts POST requests with voice file encoded in FLAC format, and query parameters for control.

Query Parameters

client
The client's name you're connecting from. For spoofing purposes, let's use chromium

lang
Speech language, for example, ar-QA for Qatari Arabic, or en-US for U.S. English

@hectorperez
hectorperez / logrotate.conf
Last active August 29, 2015 14:01
logrotate
/etc/logrotate.conf
/etc/logrotate.d/...
/home/deploy/APPNAME/current/log/*.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
@hectorperez
hectorperez / Self Signed SSL Certificate
Last active August 29, 2015 14:01
Self Signed SSL Certificate
sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
The most important line is "Common Name". Enter your official domain name here or, if you don't have one yet, your site's IP address.
https://www.digitalocean.com/community/articles/how-to-create-a-ssl-certificate-on-apache-for-ubuntu-12-04
@hectorperez
hectorperez / sed
Last active August 29, 2015 14:01
sed: Find this text and remove everything that follows
sed '/Find this text and remove everything that follows/q' filename > new_filename
require 'active_support/core_ext'
Time.now + 2.days