Skip to content

Instantly share code, notes, and snippets.

View mdaftab88's full-sized avatar

MD AFTAB mdaftab88

  • Bangalore
View GitHub Profile

SHORTCUTS

Key/Command Description
Tab Auto-complete files and folder names
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + U Clear the line before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + W Delete the word before the cursor
Ctrl + T Swap the last two characters before the cursor

Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups command.

  1. List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe

Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.

  1. Reset the consumer offset for a topic (preview)
@mdaftab88
mdaftab88 / gist:a55124d3bf85e812f165723d93180e99
Created December 27, 2019 05:20 — forked from HashNuke/gist:608259
to undo push and commits
# to undo a git push
git push -f origin HEAD^:master
# to get to previous commit (preserves working tree)
git reset --soft HEAD
# to get back to previous commit (you'll lose working tree)
git reset --hard HEAD^
<command>
<ident value="only_if">
<pos line="38" column="2"/>
</ident>
<args_add_block value="false">
<args_add>
<args_new/>
<string_literal>
<string_add>
<string_add>
@mdaftab88
mdaftab88 / GoogleAuthenticationCurl.sh
Created January 14, 2021 05:47 — forked from LindaLawton/GoogleAuthenticationCurl.sh
Curl bash script for getting a Google Oauth2 Access token
# Client id from Google Developer console
# Client Secret from Google Developer console
# Scope this is a space seprated list of the scopes of access you are requesting.
# Authorization link. Place this in a browser and copy the code that is returned after you accept the scopes.
https://accounts.google.com/o/oauth2/auth?client_id=[Application Client Id]&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=[Scopes]&response_type=code
# Exchange Authorization code for an access token and a refresh token.
curl \
@mdaftab88
mdaftab88 / RubyObjectModel.md
Created April 4, 2021 18:56 — forked from dmlaziuk/RubyObjectModel.md
Ruby Object Model

Ruby Object Model

Ruby version 2.4.1

BasicObject

 > BasicObject.public_instance_methods(false)
 => [:!, :==, :!=, :__send__, :equal?, :instance_eval, :instance_exec, :__id__]
@mdaftab88
mdaftab88 / til.md
Created April 24, 2021 22:01 — forked from jplong91/til.md
Today I Learned...

TIL - Today I Learned

Wednesday, 11/20/19

Explaining require and permit: params.require(:person).permit(:name, :age)

The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit.

The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require.

@mdaftab88
mdaftab88 / til.md
Last active May 7, 2021 13:41
Today I Learned....

TIL - Today I Learned

Sunday, 25 April 2021

Rails Polymorphic Associations

Sunday, 02 May 2021

  1. How to give a line break in a markdown file
    Just add two spaces at the end of the line. It worked for me. :)
  2. BEGIN in Ruby.
@mdaftab88
mdaftab88 / gist:387498332d2c3d267c644f14a362c6c6
Created May 5, 2021 15:03 — forked from ryansobol/gist:5252653
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@mdaftab88
mdaftab88 / sc
Last active May 23, 2021 17:55 — forked from jtprince/sc
screenshot application
#!/usr/bin/env ruby
# sc - screenshot utility using imagemagick 'import'
# Aftab: See this link: https://qr.ae/pGyZ0V
require 'optparse'
require 'ostruct'
require 'shellwords'
require 'fileutils'
viewers = {