Skip to content

Instantly share code, notes, and snippets.

@dotriz
dotriz / README
Created March 29, 2021 12:55 — forked from claudiorrrr/README
bash script to create nginx virtual hosts
# README
This is a very basic repo. It consist in 2 files:
1. `addvhost.sh`
2. `wp.sh`
They will help you to streamline a basic virtual host configuration in a Ubuntu machine using Nginx. Also, in case you would like to chose Wordpress, the `wp.sh` script will guide you to install it without messing around with databases, etc. It will do everything automatically.
In a fresh machine, they should be used in order.
@dotriz
dotriz / slack.php
Last active November 30, 2017 13:38
Slack notification from php script using curl
function slack_notification($message, $room = "dev", $username = "my-bot", $icon = ":robot_face:") {
$room = ($room) ? $room : "dev";
$data = "payload=" . json_encode(array(
"channel" => "#{$room}",
"text" => $message,
"icon_emoji" => $icon,
"username" => $username
));
// You can get your webhook endpoint from your Slack settings
@dotriz
dotriz / change-favicon.js
Created August 28, 2017 14:28
Allows you to change favicon of your webpage at run time using jquery
function change_favicon(new_favicon_path)
{
$('link[rel="shortcut icon"]').remove();
$('head').append('<link id="favicon" href="'+ new_favicon_path +'" rel="shortcut icon" type="image/png" />');
}
change_favicon('/paht/to/favicon.png');
@dotriz
dotriz / mailgun-curl-mail.php
Last active August 28, 2017 14:31
This small function allows you to send email using Mailgun API with curl in PHP
function send_mail_mg($subject, $body, $to) {
$plain = strip_tags(nl2br($body));
$data = array( 'from' => SENDER_NAME . ' <support@' . MAILGUN_SITE . '>',
'to' => $to,
'subject' => $subject,
'html' => $body,
'text' => $plain);
$ch = curl_init();