Skip to content

Instantly share code, notes, and snippets.

Avatar

Jose Davis Nidhin josnidhin

View GitHub Profile
@josnidhin
josnidhin / http_request.js
Last active Jan 14, 2021
Simple Nodejs http request without external dependencies
View http_request.js
'use strict';
const HTTP = require('http'),
HTTPS = require('https'),
PROTOCOL = {
HTTP: 'http:',
HTTPS: 'https:'
};
function request (opts, data) {
@josnidhin
josnidhin / my_ublock_filters
Last active Mar 6, 2020
My uBlock Filters
View my_ublock_filters
facebook.com
facebook.net
fb.com
fb.net
fb.me
fbcdn.com
fbcdn.net
fbsbx.com
fbsbx.net
fburl.com
@josnidhin
josnidhin / bcrypt_password_example.pl
Created Apr 22, 2019
An example on how to use bcrypt to securely hash passwords in Perl
View bcrypt_password_example.pl
use Crypt::Eksblowfish::Bcrypt qw(bcrypt en_base64);
use Data::Entropy::Algorithms qw(rand_bits);
my $bcrypt_cost = 12;
sub encrypt_password {
my $password = shift;
my $salt = en_base64(rand_bits(16*8));
my $settings = '$2a'.'$'.$bcrypt_cost.'$'.$salt;
return bcrypt($password, $settings);
@josnidhin
josnidhin / docker-container-makefile
Last active May 16, 2018
A simple makefile that I use to build and push docker containers to various AWS accounts
View docker-container-makefile
NAME = test-app
VERSION = latest
TEST_AWS = 111111111111
STAGE_AWS = 222222222222
PROD_AWS = 333333333333
AWS_ECR_DOMAIN = dkr.ecr.eu-west-1.amazonaws.com
# Start DO NOT EDIT SECTION
@josnidhin
josnidhin / random_hour.js
Created Apr 16, 2018
A simple javascript function to generate a pseudo random hour between a start and end hour
View random_hour.js
function getRandomHour(startHour, endHour) {
if (startHour > 23 || endHour > 23) {
throw new Error('Illegal range');
}
if (startHour < 0 || endHour < 0) {
throw new Error('Illegal range');
}
if (startHour === endHour) {
@josnidhin
josnidhin / dms_task_rule.js
Created Aug 24, 2017
A Simple NodeJS script to generate MySQL to Redshift AWS DMS table mappings
View dms_task_rule.js
/**
* @author Jose Nidhin
*/
'use strict';
/**
* Using Table Mapping with an Task to Select and Filter Data
* https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Tasks.CustomizingTasks.TableMapping.html#CHAP_Tasks.CustomizingTasks.TableMapping.SelectionTransformation
*/
@josnidhin
josnidhin / modsec-ratelimit.conf
Created Apr 25, 2017
A simple mod security config for IP Rate limiting Apache server behind a load balancer.
View modsec-ratelimit.conf
# assumes libapache2-modsecurity is installed
# Reference Mannual - https://github.com/SpiderLabs/ModSecurity/wiki
SecRuleEngine On
<LocationMatch "^/.*">
# initialise the state based on X-Forwarded-For ip address
SecRule REQUEST_HEADERS:X-Forwarded-For "@unconditionalMatch" "phase:2,initcol:ip=%{MATCHED_VAR},pass,nolog,id:100"
@josnidhin
josnidhin / nginx.conf
Last active Nov 18, 2016
Nginx as SMTP Proxy.
View nginx.conf
http {
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /var/www;
location /auth_server {
@josnidhin
josnidhin / terminate_ec2_with_tags.yml
Created Aug 22, 2016
The ansible script to find ec2 instances with certain tags and terminate them. Does not uses ec2 dynamic inventory script.
View terminate_ec2_with_tags.yml
---
- name: Terminate EC2 instances
hosts: localhost
connection: local
gather_facts: no
vars:
aws_region: "eu-west-1"
ec2_tags:
Name: "Test Server"
@josnidhin
josnidhin / CSV2DynamoDBDataPipeline.json
Created Jul 22, 2015
A sample AWS DataPipeline configuration which loads CSV data from S3 to DynamoDB
View CSV2DynamoDBDataPipeline.json
{
"objects": [
{
"schedule": {
"ref": "DefaultSchedule"
},
"writeThroughputPercent": "0.95",
"dataFormat": {
"ref": "DynamoDBDataFormatId_suGD7"
},