Skip to content

Instantly share code, notes, and snippets.

View rvteja92's full-sized avatar

Ravi Teja P rvteja92

View GitHub Profile

CompletableFuture

Definition

A CompletableFuture object is a placeholder for a result that might not be available at present but will be available in future.

The CompletableFuture library provides mechanisms to perform asynchronous

@rvteja92
rvteja92 / rounding_decimals.md
Created September 18, 2018 11:56 — forked from jackiekazil/rounding_decimals.md
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value

Host bitbucket.org-name1
    HostName bitbucket.org
    User git
    IdentityFile ~/.ssh/halc_bitbucket_rsa
    IdentitiesOnly yes

Host bitbucket.org-name1
    HostName bitbucket.org
 User git
@rvteja92
rvteja92 / 001.md
Last active May 4, 2018 08:10
Python and Timezones - with Django and Pytz - working with daylight saving time

Working around varying timezone offset (daylight saving time)

Create a pytz.timezone object

>> import pytz
>> tz = pytz.timezone('Asia/Kolkata')
>> tz
<DstTzInfo 'Asia/Kolkata' HMT+5:53:00 STD>
@rvteja92
rvteja92 / letsencrypt_2017.md
Created April 23, 2018 05:52 — 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.

@rvteja92
rvteja92 / Git cheat sheet.md
Last active May 18, 2017 15:54
Git Cheat Sheet

Clean the local files (and directories) and update with remote files (and directories)

git fetch origin master
git reset --hard FETCH_HEAD
git clean -df

Replace all local changes and pull remote repo

@rvteja92
rvteja92 / Drop all tables.md
Created July 3, 2016 09:48
Drop all the tables from database 'DATABASE_NAME'

Drop all tables from a database in MySQL

SET FOREIGN_KEY_CHECKS = 0; 
SET @tables = NULL;
SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables
  FROM information_schema.tables 
  WHERE table_schema = 'DATABASE_NAME'; -- specify DB name here.

SET @tables = CONCAT('DROP TABLE ', @tables);
@rvteja92
rvteja92 / git-tips.md
Last active June 9, 2016 17:48
Handy git commands not regularly used but very helpful

Keep file in repository but do not track changes

To ignore changes to a file

git update-index --assume-unchanged <file>

To tracking again

git update-index --no-assume-unchanged 
@rvteja92
rvteja92 / gist_tag.rb
Last active June 8, 2016 17:01 — forked from BinaryMuse/gist_tag.rb
A Liquid tag for Jekyll sites that allows embedding Gists and showing code for non-JavaScript enabled browsers and readers (updated)
# Updated for new gist urls
require 'cgi'
require 'digest/md5'
require 'net/https'
require 'uri'
module Jekyll
class GistTag < Liquid::Tag
def initialize(tag_name, text, token)
@rvteja92
rvteja92 / pipfreezeerror.py
Last active June 8, 2016 15:04
Pip3 freeze ASSERTION ERROR
'''
The defualt pip3 installation in Ubuntu 14.04 (pip 1.5.4) seems to have a bug.
It gave an Assertion Error like this
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/freeze.py", line 74, in run
req = pip.FrozenRequirement.from_dist(dist, dependency_links, find_tags=find_tags)