Skip to content

Instantly share code, notes, and snippets.

View baskaran-r's full-sized avatar

Baskaran Ramalingam baskaran-r

View GitHub Profile
@baskaran-r
baskaran-r / nginx-wordpress.conf
Created June 18, 2023 05:28 — forked from nfsarmento/nginx-wordpress.conf
Harden wordpress security nginx
############ WordPress ####################
# Disable logging for favicon and robots.txt
location = /favicon.ico {
try_files /favicon.ico @empty;
access_log off;
log_not_found off;
expires max;
}
@baskaran-r
baskaran-r / woocommerce-validate-registration.php
Created May 27, 2023 03:35
Woocommerce prevent spam registration
<?php
add_action('woocommerce_register_post', 'is_valid_registration_email_domain', 10, 3);
function is_valid_registration_email_domain($username, $email, $validation_errors)
{
list($email_user, $email_domain) = explode('@', $email);
// Eg. email 'test.ff.ff.f.f.f@gmail.com';
if (substr_count($email_user, '.') > 3) {
$validation_errors->add('email_error', 'Registration not allowed.');
}
@baskaran-r
baskaran-r / redis-docker-for-mac.md
Created October 9, 2021 01:42 — forked from simonw/redis-docker-for-mac.md
How to run a redis server using Docker-for-Mac

How to run a redis server using Docker-for-Mac

This will work with other flavours of Docker as well.

Run the following command:

docker run --name my-redis -p 6379:6379 --restart always --detach redis

This will download and run redis, set to auto-restart when your machine starts and bound to port 6379 on your machine.

## Remove broken symlinks (bash)
find . -type l -exec sh -c 'for x; do [ -e "$x" ] || rm "$x"; done' _ {} +
@baskaran-r
baskaran-r / application.controller.js
Created April 15, 2018 06:11
Contextual components yielding multiple blocks
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@baskaran-r
baskaran-r / mysql.js
Created February 24, 2018 03:02 — forked from isidroamv/mysql.js
CRUD - MySQL - NodeJS - Express
'use strict';
var mysql = require('mysql');
var config = require('../config');
var pool = mysql.createPool(config.mysql);
exports.exec = function(query, params, callback) {
if (!query) {
callback(true);
}
pool.getConnection(function(err, connection) {
if(err) { console.log(err); callback(true); return; }
@baskaran-r
baskaran-r / letsencrypt_2017.md
Created September 15, 2017 06:21 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@baskaran-r
baskaran-r / osx-install-mysql-with-homebrew
Last active April 2, 2017 10:30
Install MySQL on OSX sierra with homebrew
Install homebrew services
$ brew tap homebrew/services
Install and start service mysql at login
$ brew install mysql
$ brew services start mysql
Run service. Don't start at login (nor boot):

macOS 10.12 Sierra Setup

Custom recipe to get macOS 10.12 Sierra running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.11 El Capitan setup recipe and 10.10 Yosemite setup recipe. I am currently tweaking this for 10.12 Sierra and expect to refine this gist over the next few weeks.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. I generally reinstall each computer from scratch every 6 months, and I do not perform upgrades between releases.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your o

@baskaran-r
baskaran-r / Sublime Text 3 Build 3103
Created August 2, 2016 04:56
Sublime Text 3 Build 3103
I use the first
—– BEGIN LICENSE —–
Michael Barnes
Single User License
EA7E-821385
8A353C41 872A0D5C DF9B2950 AFF6F667
C458EA6D 8EA3C286 98D1D650 131A97AB
AA919AEC EF20E143 B361B1E7 4C8B7F04