Skip to content

Instantly share code, notes, and snippets.

View gerardorochin's full-sized avatar

Gerardo Rochín gerardorochin

View GitHub Profile
@gerardorochin
gerardorochin / rfc regex
Created June 6, 2013 00:00
Expresion regular para validar RFC
/^([A-Z,Ñ,&]{3,4}([0-9]{2})(0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[0-1])[A-Z|\d]{3})$/
@gerardorochin
gerardorochin / error-install-grub.sh
Last active March 5, 2024 04:49
Fix error generated on the install GRUB on Arch Linux: Syntax errors are detected in generated GRUB config file.
# try:
grub-mkconfig -o /boot/grub/grub.cfg
# output error:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux-ck
Found initrd image: /boot/initramfs-linux-ck.img
Found Windows 8 (loader) on /dev/sda1
error: out of memory.
error: syntax error.
@gerardorochin
gerardorochin / php_error_logstash.conf
Created June 2, 2014 15:39
php error logging into logstash + elasticsearch and trace errors on single line and root path hidden
input {
file {
type => "php-error"
path => "/var/www/error_log"
sincedb_path => "/opt/logstash/sincedb-access"
}
}
<?php
$data = array(
"content" => "Pickle Rick motherfuckers!",
);
$ch = curl_init("https://discordapp.com/api/webhooks/<WEBHOOK_ID>/<TOKEN>");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HEADER, 0);
@gerardorochin
gerardorochin / Make a USB bootable for pfSense on OSX
Created April 25, 2016 18:49
Example for create USB bootable for pfSense using device /dev/disk3
# diskutil list
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *121.3 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_CoreStorage Macintosh HD 121.0 GB disk0s2
3: Apple_Boot Boot OS X 134.2 MB disk0s3
/dev/disk1 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
@gerardorochin
gerardorochin / gitweb.nginx.conf
Last active February 8, 2018 05:01
FreeBSD gitweb.cgi config for nginx
#Git Web
location /git {
alias /usr/local/www/gitweb/;
index gitweb.cgi;
auth_basic "Git SCM";
auth_basic_user_file htpasswd;
}
location ~ ^/git/gitweb.cgi {
@gerardorochin
gerardorochin / html_to_markdown.php
Created October 23, 2013 15:43
Translate html minimal code WYSIWYG editor to markdown
<?php
$wysiwyg = "<p><b>test</b></p><p><i>test</i></p><p><strike>test</strike></p><p><br></p><p><ul><li>test</li></ul></p><p><ol><li>test</li></ol></p>";
$html = array('<b>', '</b>', '<i>', '</i>', '<p>', '</p>', '<br>', '<ul>', '</ul>', '<li>', '</li>', '<ol>', '</ol>', '<strike>', '</strike>');
$markdown = array('**', '**', '*', '*', '', PHP_EOL, PHP_EOL, '', '', "* ", '', '', '', '~~', '~~');
echo str_replace($html, $markdown, $wysiwyg);
/**
@gerardorochin
gerardorochin / export-bzr-to-git.sh
Last active December 25, 2015 13:29
bzr to git migration
#!/bin/bash
# Getting the bzr plugin
mkdir -p ~/.bazaar/plugins
cd ~/.bazaar/plugins
bzr branch lp:~lyda.google/bzr-fastimport/mysql-export-fix fastimport
# Migration
git init ~/project.git
cd ~/project.git
@gerardorochin
gerardorochin / fix-export-bzr-to-git.sh
Last active December 25, 2015 13:29
fix: file not in branch error msg: fatal: Path /full/path/file not in branch fast-import: dumping crash report to path/fast_import_crash_# bzr: broken pipe
#!/bin/bash
# Once you've confirmed the bug, switch to the fixed version do the following:
cd ~/.bazaar/plugins
# Instead of removing it, you can also just move it somewhere not visible to bzr.
rm -rf fastimport
bzr branch lp:~lyda.google/bzr-fastimport/mysql-export-fix fastimport
# try again
@gerardorochin
gerardorochin / bash-colors.sh
Created September 18, 2013 22:02
Color Output on Bash Scripts
#!/bin/bash
# tputcolors
echo
echo -e "$(tput bold) reg bld und tput-command-colors$(tput sgr0)"
for i in $(seq 1 7); do
echo " $(tput setaf $i)Text$(tput sgr0) $(tput bold)$(tput setaf $i)Text$(tput sgr0) $(tput sgr 0 1)$(tput setaf $i)Text$(tput sgr0) \$(tput setaf $i)"
done