Skip to content

Instantly share code, notes, and snippets.

View TheAshwanik's full-sized avatar
💭
Hi.. Don't hesitate to ping me.. I would love an interesting chat about tech.

Ashwani Kumar TheAshwanik

💭
Hi.. Don't hesitate to ping me.. I would love an interesting chat about tech.
View GitHub Profile
@TheAshwanik
TheAshwanik / Git Commands
Last active July 9, 2020 23:40
Git Commands
99% of the Git commands you'll need at work, demonstrated in a single script (bitbucket.org)
https://bitbucket.org/BitPusher16/dotfiles/raw/49a01d929dcaebcca68bbb1859b4ac1aea93b073/refs/git/git_examples.sh
https://news.ycombinator.com/item?id=21189256
#!/bin/bash
##########
# contents
@TheAshwanik
TheAshwanik / first_run.ini
Created June 26, 2020 16:05 — forked from HighMacGuy/first_run.ini
OpenVPN Access Server Letsencrypt
# OpenVPN Let's Encrypt first run config file
#https://loige.co/using-lets-encrypt-and-certbot-to-automate-the-creation-of-certificates-for-openvpn/
cert-name=
authenticator = standalone
standalone-supported-challenges = tls-sni-01
non-interactive = True
rsa-key-size = 4096
email = "user@server.com"
domains = "vpn.server.com"

Rails Generating & Scaffolding

Rails' use of strict naming conventions means a lot of core code SHOULD be in the same format whoever writes it? It could be written by a friend, colleague or a computer... it shouldn't matter because the same Rails rules apply to everyone.

This means that Rails can actually do some tasks for you! It can actually build things and write code on your behalf...

Coming from another language like PHP, this can seem like magic.

@TheAshwanik
TheAshwanik / MQTT_Mosquittto_ACL.md
Created March 14, 2015 00:37
How to make Access Control Lists (ACL) work for Mosquitto MQTT Broker with Auth Plugin?

Source:http://my-classes.com/2015/02/05/acl-mosquitto-mqtt-broker-auth-plugin/

How to make Access Control Lists (ACL) work for Mosquitto MQTT Broker with Auth Plugin?

If you planning to strengthening your MQTT service, then access control lists (ACL) are mandatory. Mosquitto broker supports this ACL feature through auth plugins.

One versatile auth-plugin for mosquitto that you should consider using is https://github.com/jpmens/mosquitto-auth-plug. It is very flexible, in that it can support multiple backends as auth provider databases, ranging from CDB, Redis to MySQL and Http. However, getting it compiled and making it start to work is not that straight forward or easy. Hence, this post. It gives some starting point to our students who are venturing into Mosquitto Authentication systems to get started.

Building the Mosquitto-Auth-Plugin

@TheAshwanik
TheAshwanik / domain-to-aws-ec2-instance.md
Created December 25, 2019 12:39 — forked from keithweaver/domain-to-aws-ec2-instance.md
Point Domain to Amazon Web Services (AWS) EC2 Instance

Point Domain to Amazon Web Services (AWS) EC2 Instance

  1. Open the Amazon Route 53 console at https://console.aws.amazon.com/route53/.
  2. If you are new to Amazon Route 53, you see a welcome page; choose Get Started Now for DNS Management. Otherwise, choose Hosted Zones in the navigation pane.
  3. Choose Create Hosted Zone.
  4. For Domain Name, type your domain name.
  5. Choose Create.
  6. Click the Hosted Zone, edit record set.
  7. In the value, add ec2-54-152-134-146.compute-1.amazonaws.com.
  8. Change your DNS file to point to the IPv4 address (This would be in something like GoDaddy).
@TheAshwanik
TheAshwanik / encrypt_openssl.md
Created March 31, 2019 13:31 — forked from dreikanter/encrypt_openssl.md
File encryption using OpenSSL

Symmetic encryption

For symmetic encryption, you can use the following:

To encrypt:

openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt

To decrypt:

@TheAshwanik
TheAshwanik / fail2ban_notifier.rb
Created December 27, 2018 00:32 — forked from etdsoft/fail2ban_notifier.rb
Simple Fail2banNotifier for exception_notification (will submit a pull request and update gist when accepted). See: http://securityroots.com/blog/2014/01/protecting-app-rails-fail2ban/
class Fail2banNotifier
def initialize(options)
@default_options = options
@default_options[:logfile] ||= Rails.root.join('log', 'fail2ban.log')
# Roll over every 30M, keep 10 files
@logger ||= Logger.new(@default_options[:logfile], 10, 30*1024*1024)
end
def call(exception, options={})
@TheAshwanik
TheAshwanik / letsencrypt_2018.md
Created June 27, 2018 06:40 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

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


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@TheAshwanik
TheAshwanik / Forward-Reverse-Proxy-Diff.md
Last active March 28, 2018 02:13
Difference between proxy server and reverse proxy server
@TheAshwanik
TheAshwanik / deploy-static-site-heroku.md
Created December 16, 2017 23:57 — forked from wh1tney/deploy-static-site-heroku.md
How to deploy a static website to Heroku

Gist

This is a quick tutorial explaining how to get a static website hosted on Heroku.

Why do this?

Heroku hosts apps on the internet, not static websites. To get it to run your static portfolio, personal blog, etc., you need to trick Heroku into thinking your website is a PHP app. This 6-step tutorial will teach you how.

Basic Assumptions