In C, you can use scanf to get character input from console. However, if you do it multiple times, you will realize that pressing enter after the first scanf affects the next scanf call. This happens when you have a space after your prompt, e.g. printf("Choice: "); char c; scanf("%c"). Either don't put a space at the end of printf or use a space in scanf like so: scanf(" %c")
Wednesday, December 28, 2022
Friday, September 16, 2022
When is inheritance useful?
A major disadvantage of inheritance is not being able to follow the program flow by ctrl + clicking function calls due to some functionality being implemented in ancestor classes. Therefore, I prefer composition over inheritance whenever possible. The one case where inheritance shines is reusing workflows. Let's say all your child classes have a run() method that calls f1(), f2() and f2() in order, where f1, f2, f3 functions are implemented in child classes. If we move the run() method to the ancestor class, child classes would just call that run method, saving you from duplicating the f1, f2, f3 calls in each child.
Monday, September 5, 2022
Studying Algorithms and Data Structures Effectively
Thursday, August 11, 2022
Leetcode notes
Friday, July 29, 2022
Behavioral interview preparation as a student
From Google to Toptal, behavioral questions are an integral part of the interview process. Questions like "what did you do when you realized that the deadline could not be met", "tell me about a case where your teammate was underperforming and your response" try to assess your communication and conflict resolution skills. As a student, you should treat such crisis as opportunites. A bad way to handle teammates that do not shoulder their share is to quarrel with them and take their share too without trying to negotiate a settlement. You should at least get their point of view in a coolheaded manner. Even if you cannot win them over for the cause, you will improve your communication skills and you will have stories to tell in interviews. Watch this video for tips.
Sunday, June 26, 2022
Podcast with a sofware engineer working in Munich
I recently did a podcast (in Turkish) with my cousin who works as the software engineering department head of a company in Munich. In it, we also answered the following questions which were previously asked by my mentee, Nansy:
Question: Did he have to learn on his own or was his university knowledge sufficient?
Answer: You have to learn on your own too.
Question: How important is GPA really?
Answer: Not much if you don't plan to do graduate studies. If your GPA is not great, you have to be able to give reasons for it. Good reasons: Worked on my projects/hobbies, worked part time, traveled around the world. Bad reasons: Watched movies, played games.
Question: How can someone decide which area/language/framework to learn and focus on when there are so many?
Answer: Picking an industry/sector will narrow down the selection. Make sure that your computer engineering fundamentals like algorithms and data structures are sound.
Saturday, June 25, 2022
Summer project ideas
- Create a fork and push your updates to this fork.
- Draw a polygon (e.g. hexagon) on map. Zoom - unzoom with mouse wheel. Drawing should be updated while zooming, it should not wait until mouse wheel stops.
- Pan with the right mouse click and drag. Drawing should be updated while panning, it should not wait until mouse button is released.
- Show country borders.
- On startup, map should center on Turkey and Turkey borders should fill the view.
- Document your progress/challenges, preferably create a public blog and write a developer diary there.
Wednesday, June 8, 2022
Finding a job
Finding a job can be divided into two stages:
- Stage 1, getting an interview:
- Past experience and your contributions
- Full time work
- Part time work
- Internships
- Side projects, Hackathons
- Education
- Tailoring resume/CV for the job you plan to apply
- Polishing LinkedIn profile, getting badges, contacting recruiters
- Preparing for and passing online assessment tests
- Stage 2, passing the interview:
- Preparing for coding questions
- Preparing for behavioral questions
- How do you resolve conflict with your superior / team mate?
- What do you do when it becomes clear that a deadline cannot be met?
Wednesday, June 1, 2022
Algorithms that you should know by heart
Algorithms that you should know by heart and be able to code without using the internet:
- Binary search
- Bubble sort
- Breadth/Depth first search a tree
- Printing permutations of a string
Tuesday, May 24, 2022
Programming job opportunities by country
Programming language selection
When selecting a programming language to specialize in, it makes sense to check industry demand. I used LinkedIn's job search and got the following job post numbers:
|
|
|
|
| |
| |||||
| |||||
| |||||
| |||||
| |||||
|
As you can see, the first four (Python, Java, JavaScript and C++) are close to each other and C# is a distant fifth.
Friday, May 20, 2022
Summer time
Doing extra-curricular projects will be a differentiating factor throughout your professional career because it will demonstrate your interest in the field, desire to learn and motivation. These are highly sought after qualities which separate the top engineers from the average. Below is a question from an online application which shows the importance of having a mobile and a web app project:
Summer is a good time to go the extra mile because there is no exam pressure. Of course there are internships to do, fun places to go, books to read and re-charging for the up coming semester.
If you think you can spare some time during the summer, I can help you with the following in a low-pressure setting:
- Coding projects to enrich your GitHub portfolio
- Ideas
- Bug tracking web app
- Machine Learning:
- Simple 2D self driving car
- Identify persons in a video using previously saved face image data
- Self driving: Run openpilot on CARLA
- Cryptocurrency: Simple blockchain app
- Simple PageRank app
- 2D web game with pathfinding
- Internet of things: Send sensor data to web server and display data in browser.
- Design guidance
- Management (sprint planning with Trello)
- Implementation (code review, debugging)
- Documentation
- Testing
- Meetings
- Tech discussions, e.g. self driving cars, cryptocurrency, internet of things, games, medicine/bioinformatics. Sectors: Automotive, aerospace, medicine, bioinformatics, games, finance (incl. crypto), cyber security etc.
- Team building: You are not just my mentees but potential founders / colleagues for me and for each other. Think of all these activities as parts of an extended interview.
- Start-up idea brainstorming.
Tuesday, May 17, 2022
Testimonials
Recent comments from my mentees:
"Working with you was an insanely beneficial learning experience. Your approach to tackling problems is much more efficient than what I used to do." Amer
"I usually get confused by the details, you showed me how not to loose sight of the overall picture." Nansy
Monday, May 16, 2022
Programming the PIC microcontroller
Recently I helped my students with a PIC18F8722 microcontroller project. Hardware setup:
- UNI-DS6 Development System + microboard with PIC18F8722 and seven segment display
- PICkit 3 In-Circuit Debugger
- Windows 10 PC + MPLAB X IDE + XC8 compiler
- Pay attention on how the cable is connected to PICKit 3.
- Difference between PORT and LAT: The latch is the output latch onto which values are written. The port is the voltage at the actual pin… So in most situations, you will write to the latch and read from the port. When you're reading from LATx, you're reading what is in the Data Register, when you read from PORTx, you're reading the actual I/O pin value. PIC uses read-modify-write to write operations and this can be a problem, so they use this shadow register to avoid it.
- Setting timer and interrupt bits:
//Clear interruptsINTCONbits.GIE = 0; //Global interrupt enableINTCONbits.TMR0IE = 0; //Timer0 interrupt enable.TMR0L = 0;TMR1 = 0;//TIMER 0 (PIC18F8722)INTCONbits.GIE = 1; //Global interrupt enableINTCONbits.TMR0IE = 1; //Timer0 interrupt enable.INTCONbits.TMR0IF = 0;T0CONbits.T08BIT = 1;T0CONbits.T0CS = 0; //internal clock selectedT0CONbits.PSA = 1; //prescaler is NOT assignedT0CONbits.T0PS0 = 0;T0CONbits.T0PS1 = 0;T0CONbits.T0PS2 = 0;T0CONbits.TMR0ON = 1;//TIMER 1T1CONbits.RD16 = 1;T1CONbits.T1CKPS0 = 0;T1CONbits.T1CKPS1 = 0;T1CONbits.T1OSCEN = 0;T1CONbits.TMR1CS = 0;T1CONbits.TMR1ON = 1;T1CONbits.T1RUN = 1;
- Using two timers with interrupt:
void __interrupt() isr(void) {if(TMR0IF) { //Timer 0 overflowTMR0IF = 0; //Clear Timer 0 interrupt flagTMR0 = 0; //Timer 0 counter}if(TMR1IF) { //Timer 1 overflowTMR1IF = 0; //Clear Timer 1 interrupt flagTMR1 = 30000; //Set counter so that overflow takes less time}}
- Calculating timer overflow period:
- For 40MHz oscillator, use #pragma config OSC = HSPLL
- Frequency of instruction cyles = 40Mhz/4 = 10MHz → 1 instruction cyle = 0.1us
- 8 bit timer overflows every 2^8 instruction cycles = 256 * 0.1 = 25.6us
- 16 bit timer overflows every 2^16 instruction cycles = 6553.6us = 6.5536ms
- XC8 problem: Cannot use const int nTimer0_500ms = 19531; int maxTimer0 = nTimer0_500ms; XC8 displays message “error: (712) can't generate code for this expression” at the int maxTimer0 = nTimer0_500ms line. I had to use #define nTimer0_500ms (19531).
- cTimer0 > 2 * 19531 → we expected 1s delay but the board LEDs behaved strangely. When we used a prescaler of 1:2 (000), it worked as expected.
- Make Timer 1 faster by setting TMR1 to e.g. 30000 so that it start counting from TMR1 and number of counts until overflow would be 2^16 - TMR1.
- Finding a binary number corresponding to row: nb += 1 << iRow
- PORTA = 0b0011: Turn on first two LEDs in column A of board
- Turn on 4th bit of a number: nb |= 1<<4
- Turn off 4th bit of a number: nb &= ~(1<<4)
- You have to check button presses multiple times to give user time and to do debouncing.
Sunday, April 24, 2022
How to fill a letter of intent/reference
Letters of intent or reference sometimes have a minimum word requirement. The best way to hit the word count is to give examples of which courses and projects you liked and why.
Saturday, April 23, 2022
AI explanation problem
After weeks of training of some sort of agent I can just tell you "yes" but I cannot tell you "why"... The pathologist writes a full scale report and he/she has to justify it.
Friday, April 22, 2022
Advanced Driver Assistance Systems (ADAS)
I recently bought and watched Udemy's Advanced Driver Assistance Systems (ADAS). It is a good beginner course to get an overview of concepts and challenges/steps to reach the goal of full self driving cars. It is especially useful if you plan on working in the smart/self-driving automotive industry.
Another good idea is to check out openpilot, which powers comma.ai. Here is a video of George Hotz showcasing openpilot.
Companies in Türkiye working on ADAS / autonomous driving:
- TOGG
- Ford Otosan