Skip to content

Instantly share code, notes, and snippets.

View shubhamwagh's full-sized avatar
🎯
Focusing

Shubham Wagh shubhamwagh

🎯
Focusing
View GitHub Profile
@shubhamwagh
shubhamwagh / StateDesignPatternTutorial.md
Last active December 1, 2023 22:16
State Design Pattern Tutorial
  • State Design Pattern allows an object to change its behavior when its internal state changes.
  • It is a behavioral type design pattern.
  • It has State Interface which represents all behaviors (methods) the context will exhibit.
  • The Concrete States in the state design pattern are the implementations of the State Interface that define behaviors specific to each state.
  • It has Context Class that holds a reference to the current state and expose methods to clients.
  • Useful to manage states in the applications and swtich between them.
  • Easy to maintian since each state is a different class and state-specific behavior is encapsulated in its respective class.
  • New states can be easily added by writing an extra class for the new state.
  • E.g. States in a document, states in a game, or different modes in a GUI.
@shubhamwagh
shubhamwagh / ssh_display_forward.md
Last active December 7, 2021 11:33
SSH Display forward
  • Make sure you have xauth installed. (See: xauth info or xauth list)
  • On the server your /etc/ssh/sshd_config file should have these lines:
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no
  • Make sure on client side you have X server installed.
  • On the client side your ~/.ssh/config file should have these lines if not create new config file and add:
@shubhamwagh
shubhamwagh / bitcoin_mining.md
Last active May 6, 2021 12:32
BitcoinMining-SimplifiedSketch

BitcoinMining explaination

Data

  • Assume this is the hash of the lastest block (shortened to 30 characters): 00000000000001adf44c7d69767585
  • Following are the hashes of a few valid transactions waiting for inclusion (shortened).
5572eca4dd4
db7d0c0b845
  • And this the hash of one special transaction that you just crafted, which gives 10BTC (the current reward) to yourself:
@shubhamwagh
shubhamwagh / rospc2_numpy.py
Created November 13, 2020 12:34
ROS PointClou2 to numpy conversion (this will avoid bit flip)
colours = np.array([
bytearray(msg.data[rgb_field.offset + 2::msg.point_step]),
bytearray(msg.data[rgb_field.offset + 1::msg.point_step]),
bytearray(msg.data[rgb_field.offset + 0::msg.point_step])
]).transpose().astype(np.float32)/255.0
@shubhamwagh
shubhamwagh / spiral.py
Created October 6, 2020 11:10 — forked from cablehead/spiral.py
Iterate a 2d matrix using a spiral pattern
import unittest
import copy
from itertools import cycle
def row(matrix, n):
# returns row n of a 2d matrix
return matrix.pop(n)
@shubhamwagh
shubhamwagh / aws-s3-size.sh
Created September 4, 2020 11:55
AWS gets size of the contents in your S3 bucket
#!/usr/bin/env bash
## If no bucket name is passed, prompt user to enter one from their account.
## Else, assign $1 to bucket_name.
get_bucket_name () {
if [[ $# -eq 0 ]]; then
echo
echo "$buckets"
echo
@shubhamwagh
shubhamwagh / delete_and_upload.py
Created September 17, 2019 17:46
AWS s3 bucket delete and upload
import boto3
session = boto3.Session(
aws_access_key_id='AWS_ACCESS_KEY_ID',
aws_secret_access_key='AWS_SECRET_KEY',
)
s3 = session.resource('s3')
bucket = s3.Bucket('bucket-name')
bucket.objects.all().delete()
s3.meta.client.upload_file(Filename='filename-with-path', Bucket='qbot.co.robot.software.deployment.mk7', Key='only-filename-in-the-bucket')
@shubhamwagh
shubhamwagh / Link.md
Created September 11, 2019 15:34
Smooth contours in Opencv
@shubhamwagh
shubhamwagh / Build.md
Last active December 1, 2023 22:23
Blender-Python-module-build