Skip to content

Instantly share code, notes, and snippets.

@kolunar
kolunar / gist:535e601ad85bace399d36ce7623cd9a1
Created August 17, 2016 15:18
How To Set Up Subdomain or multi-domains and Apache Virtual Hosts on Ubuntu 14.04 LTS
Summary
=========
1) Create an A record for your sub-domain that points to your droplet
2) Create a .config file for your sub-domain site in /etc/apache2/sites-available
3) Create the directory for your site in /var/www (or wherever you said it was in the config file)
4) Enable the site in apache with: sudo a2ensite sub.yourdomain.com (or whatever you named your site in the config)
5) reload apache: sudo service apache2 reload
NOTE: the DNS record you create might take awhile to propagate
============================================================================================
@kolunar
kolunar / earthquake.html
Created April 24, 2017 15:18
Google Map JS API : markers to show earthquake locations
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style type="text/css">
html, body { height: 100%; margin: 0; padding: 0; }
#map { height: 100%; }
</style>
</head>
<body>
@kolunar
kolunar / snippet.php
Created April 24, 2017 15:22
Joomla function to create Thumbnails
// required libraries
jimport('joomla.image.image');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
/**
* Function to create thumbs from one image
* @author Roberto Segura - Digital Disseny, S.L.
* @version 16/07/2012
*
* @param string $imgPath - path to full image
@kolunar
kolunar / Ref
Created April 24, 2017 15:23
MySQLTuner
How To Limit MySQL Max Connections Per User
Ref: https://www.rackaid.com/blog/mysql-connection-limits/
Understanding max_user_connections
http://dev.mysql.com/doc/refman/5.7/en/user-resources.html
@kolunar
kolunar / README.md
Last active September 1, 2017 10:00
Caching

Caching in PHP using the filesystem, APC, Memcached and Redis.

Cache per script data in associative array.

If you have some data read from database which you need several time during page creation cache it locally do not depend on any other types of caches.

use APC Cache for single node applications

If you have just one web server or your data set is small so it fits in memory in each of the servers APC Cache may be the most efficient way for you to cache the data.

Use Memcached for large scale applications

If local node cache is not large enough to cache good amount of data caching on network by using memcached is very good way to go.

@kolunar
kolunar / snippet.js
Created April 24, 2017 15:56
jQuery check if form dirty
function getHasChanges() {
var hasChanges = false;
$(":input:not(:button):not([type=hidden])").each(function() {
if ((this.type == "text" || this.type == "textarea" || this.type == "hidden") && this.defaultValue != this.value) {
hasChanges = true;
return false; // returning false from this callback will break the each looping
} else {
if ((this.type == "radio" || this.type == "checkbox") && this.defaultChecked != this.checked) {
@kolunar
kolunar / README.txt
Last active April 24, 2017 16:03
bash scp data transfer (website migration from one host to another)
scp user@source user@destination -uUserName -pPassword
/* for digital ocean, one has to change ownership for a newly uploaded content as below */
chown -R www-data:www-data /var/www/html
/* www-data:www-data is the default user:group for web server */
Other scp example ref:http://www.hypexr.org/linux_scp_help.php
===============================================================
Example syntax for Secure Copy (scp)
@kolunar
kolunar / gist:8a7e71f47dc0a29618fece001d4e1e6b
Created April 24, 2017 22:42
E-mail authentication & SSL setup
Configuring SPF and DKIM for outgoing mail digital signing
https://www.exratione.com/2014/07/setting-up-spf-and-dkim-for-an-ubuntu-1404-mail-server/
Ref: http://www.openspf.org/SPF_Record_Syntax
Ref: http://www.dkim.org/
If Postfix not installed
https://www.digitalocean.com/community/tutorials/how-to-install-and-setup-postfix-on-ubuntu-14-04
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-14-04
MX tool:
@kolunar
kolunar / gist:280cf197e25aa45f3cbfb22d20cb8a62
Created April 24, 2017 22:51
How To Set Up Subdomain or multi-domains and Apache Virtual Hosts on Ubuntu 14.04 LTS
Summary
=========
1) Create an A record for your sub-domain that points to your droplet
2) Create a .config file for your sub-domain site in /etc/apache2/sites-available
3) Create the directory for your site in /var/www (or wherever you said it was in the config file)
4) Enable the site in apache with: sudo a2ensite sub.yourdomain.com (or whatever you named your site in the config)
5) reload apache: sudo service apache2 reload
NOTE: the DNS record you create might take awhile to propagate
============================================================================================
@kolunar
kolunar / gist:2fa29814ec80db391821f418082a6c16
Created April 24, 2017 22:52
How to set up digital ocean droplet
Create new droplet (1 click application or manual e.g. LAMP stack)
Step 1: Create a new user
Step 2: Root privileges
Step 3: Add Public Key Authentication
Step 4: Disable remote SSH access to root account
Step 5: Testing the changes
Step 6: Configure time zones
Step 7: Configure NTP Synchronization
Step 8: Setting up a firewall