Git and GitHub cheatsheet

Git / github cheatsheet Installation of git Download git from here or use on debian based linux 1 2 sudo apt update sudo apt install git Check if git is installed 1 git --version Configure git 1 2 git config --global user.name "Your Name" git config --global user.email "Your email" (Optional) Change the default brach name from master to main 1 git config --global init.defaultBranch main Configuring SSH keys to github Run these commands on the terminal 1 2 3 4 ssh-keygen -t ed25519 -C "$Your email" eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519 cat ~/.ssh/id_ed25519.pub Go to Github>Settings>SSH and GPG keys. Click on New SSH key. Give a title and paste the key in the key field. Click on Add SSH key. The key should be available from the last command on the terminal. Git commands git init - initialize a git repository git add <file> - add a file to the staging area git add . - add all files to the staging area git add -A - add all files to the staging area git commit -m "message" - commit changes to the local repository git push - push changes to the remote repository git push -u origin <branch_name> - push changes to a branch git push origin <branch_name> - push changes to a branch git pull - pull changes from the remote repository git pull origin <branch_name> - pull changes from a branch git status - check the status of the repository git log - view the commit history git branch - view the branches git branch <branch_name> - create a new branch git checkout <branch_name> - switch to a branch git checkout -b <branch_name> - create and switch to a branch git merge <branch_name> - merge a branch into the current branch git clone <url> - clone a remote repository git remote add origin <url> - add a remote repository git remote -v - view the remote repositories git remote set-url origin <url> - change the url of the remote repository git remote remove origin - remove the remote repository git submodule: git submodule is used to add a git repository inside another git repository. This is useful when you want to use a git repository inside another git repository. For example, you can use git submodule to add a git repository that contains a library to your project. This way, you can use the library in your project without having to copy the library files into your project directory. git submodule add <url> - add a submodule git submodule init - initialize the submodule git submodule update - update the submodule git submodule update --remote - update the submodule to the latest commit

November 25, 2023 · 3 min · 447 words · Aum Pauskar

OOPS with Python and packages

Python Chapter summary - Unit 1 Unit 1 Python Fundamentals: An Introduction to Python programming: Introduction to Python, IDLE to develop programs; How to write your first programs: Basic coding skills, data types and variables, numeric data, string data, five of the Python functions; Control statements: Boolean expressions, selection structure, iteration structure; Define and use Functions and Modules: define and use functions, more skills for defining and using functions and modules, create and use modules, standard modules Contents What is python? Python is a high level interpreted language that is preffered in rapid development of programs due to it’s easy and simple syntax. IDLE IDLE is the short form of integrated development learning environment. Data types in python int(5), string(’this is a string’ or this is a string), tuple( (5,3,5) ), float(5.3), bool(true/false) … Python interation structure Unlike other languages python uses indententation instead of using brackets. Comments Comments are a piece of code that is essentially “dead code” these are essential to show the programmer what the code does and not to do anything. Comments in python - ...

November 23, 2023 · 25 min · 5176 words · Aum Pauskar

Linux

Linux/UNIX shell commands The UNIX shell is a command-line interface made for interacting with the OS. There are various commands to execute this. Note: The current documentaiton is based on Ububtu and similar debian bases operating systems. File systems The linux file system is a tree structure with the root directory at the top. The root directory is denoted by /. The directories are separated by / and the files are separated by .. The file system is case sensitive. The file system is made up of the following: ...

November 23, 2023 · 16 min · 3345 words · Aum Pauskar

Computer networks

Computer networks Packets In networking, a packet is a small segment of a larger message. Data sent over computer networks*, such as the Internet, is divided into packets. These packets are then recombined by the computer or device that receives them. The Internet is a “packet switching” network. Packet switching refers to the ability of networking equipment to process packets independently from each other. It also means that packets can take different network paths to the same destination, so long as they all arrive at the destination. Because of packet switching, packets from multiple computers can travel over the same wires in basically any order. This enables multiple connections to take place over the same networking equipment at the same time. ...

November 23, 2023 · 46 min · 9648 words · Aum Pauskar

Modulated motor control with arduino

Motor Encoder Components Arduino Uno 4x4 Keypad I2C LCD DC Motor with encoder L293D Motor Driver Connections Display connections From (I2C display) To (arduino) 1 VCC 5V 2 GND GND 3 SDA SDA 4 SCL SCL Keypad connections From (Keypad) To (arduino) 1 Row 1 D13 2 Row 2 D12 3 Row 3 D11 4 Row 4 D10 5 Col 1 D9 6 Col 2 D8 7 Col 3 D7 8 Col 4 D4 Motor connections From (Motor) To 1 Motor negative Output 4 (L293D) 2 Motor positive Output 3 (L293D) 3 Encoder ground GND (L293D) 4 Channel B D3 (arduino) 5 Channel A D2 (arduino) 6 Encoder power 5V (arduino) L293D connections From (L293D) To (arduino) 1 Power 1 5V 2 Input 4 D5 3 Output 4 refer above 4 Ground GND (both arduino/motor) 5 Ground GND (both arduino/motor) 6 Output 3 refer above 7 Input 3 D6 8 Enable 3,4 5V 9 Enable 1,2 5V 10 Input 1 N/A 11 Output 1 N/A 12 Ground GND 13 Ground GND 14 Output 2 N/A 15 Input 2 N/A 16 Power 2 5V Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 // ---------- // keypad setup #include <Keypad.h> const byte numRows= 4; //number of rows on the keypad const byte numCols= 4; //number of columns on the keypad // global keypad variables String enteredValue = ""; int encoderSpeed = 0; float debugEncoderSpeed = 0.00; // (encoderSpeed * 100) / 255 //keymap defines the key pressed according to the row and columns just as appears on the keypad char keymap[numRows][numCols]= { {'1', '2', '3', 'A'}, {'4', '5', '6', 'B'}, {'7', '8', '9', 'C'}, {'*', '0', '#', 'D'} }; //Code that shows the the keypad connections to the arduino terminals byte rowPins[numRows] = {13,12,11,10}; //Rows 0 to 3 byte colPins[numCols]= {9,8,7,4}; //Columns 0 to 3 Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols); // ---------- // lcd setup #include <Adafruit_LiquidCrystal.h> Adafruit_LiquidCrystal lcd_1(0); int LCDRow = 0; #define motorA 5 #define motorB 6 int encoderPin1 = 2; int encoderPin2 = 3; volatile int lastEncoded = 0; volatile long encoderValue = 0; volatile long correctEncoderValue =0; long lastencoderValue = 0; int lastMSB = 0; int lastLSB = 0; void setup() { Serial.begin (9600); pinMode(encoderPin1, INPUT); pinMode(encoderPin2, INPUT); digitalWrite(encoderPin1, HIGH); //turn pullup resistor on digitalWrite(encoderPin2, HIGH); //turn pullup resistor on attachInterrupt(0, updateEncoder, CHANGE); attachInterrupt(1, updateEncoder, CHANGE); pinMode(motorA,OUTPUT); pinMode(motorB,OUTPUT); lcd_1.begin(16, 2); lcd_1.print("Enter value:"); lcd_1.setCursor(LCDRow, 10); } void loop() { // encoder control statements correctEncoderValue = encoderValue/4; Serial.println(correctEncoderValue); if ( 0<=correctEncoderValue && correctEncoderValue < 3000) { analogWrite(motorA,encoderSpeed); digitalWrite(motorB,LOW); } else { analogWrite(motorA,0); digitalWrite(motorB,LOW); } delay(100); // keypad control statements char keypressed = myKeypad.getKey(); if (keypressed != NO_KEY) { Serial.println(keypressed); } // getting the key pressed from the user if (keypressed){ // gets triggered for numeric key presses if (keypressed != 'D' && keypressed != 'A' && keypressed != 'B' && keypressed != 'C') { Serial.println(keypressed); lcd_1.print(keypressed); lcd_1.setCursor(++LCDRow, 10); enteredValue += keypressed; // a - clear the entered value } else if (keypressed == 'A') { lcd_1.clear(); lcd_1.print("Enter value:"); lcd_1.setCursor(++LCDRow, 10); enteredValue = ""; encoderSpeed = 0; // d - update the entered value } else { LCDRow = 0; lcd_1.clear(); lcd_1.print("Value updated"); delay(500); // taking the encoder speed from the user // encoder value lies between 0 and 255 // we take the value only if its between 0 and 255 if (enteredValue == "") { encoderSpeed = 0; Serial.println("Case 1: Blank entered value"); } else if (enteredValue.toInt() > 0 && enteredValue.toInt() < 255) { encoderSpeed = enteredValue.toInt(); Serial.println("Case 2: Accepted entered value"); } else { encoderSpeed = 0; Serial.println("Case 3: Out of of bounds entered value"); } } // special keypresses end } // keypressed trigger end debugEncoderSpeed = (encoderSpeed * 100) / 255; Serial.println(debugEncoderSpeed); } void updateEncoder(){ int MSB = digitalRead(encoderPin1); //MSB = most significant bit int LSB = digitalRead(encoderPin2); //LSB = least significant bit int encoded = (MSB << 1) |LSB; //converting the 2 pin value to single number int sum = (lastEncoded << 2) | encoded; //adding it to the previous encoded value if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoderValue ++; if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoderValue --; lastEncoded = encoded; //store this value for next time } How to use this Click the link below and press simulate. You can see the debug output in the serial monitor. To enter a value press a key on the keypad. To update the value press D and to clear the value press A. ...

November 21, 2023 · 5 min · 902 words · Aum Pauskar