Input the following code inside your terminal:
npx create-react-app my-app
When I started coding in React I would always wonder why everything didn’t just use a class component when coding, it would make life a lot easier to follow I use to think. But, I learned that they have advantages of using each type when needed.
React’s project architect is very important when handling state. State is an object that represents the parts of the app that can change. Each component can maintain its own state, which lives in an object called “this”. State can be passed down from one component to another depending on the architecture of the project…
Given a string of words, reverse all the words. For example:
“Hi my name is Avi”, becomes “Avi is name my Hi”.
words = 
length = len(s)
spaces = [' ']
i = 0 while i < length:
if s[i] not in spaces:
word_start = i
while i < length and s[i] not in spaces:
i += 1
i += 1
return " ".join(reversed(words))
The code above makes an empty array of words, finds the length of the input, an array with a space and an index start point. The code checks for the index being shorter than the length of the input in the first loop. The second loop checks for the final letter index of the word, then it returns the words reversed.
Given an array of integers (positive and negative) find the largest continuous sum. An example of an array would be the following:
[7,2,-6,3,4,10,10,-10,-10] . The array’s maximum sum would be 30, summing everything until the last two
-10’s are not included in the sum.
max_sum = current_sum = arr
for num in arr[1:]:
current_sum = max(current_sum + num, num)
max_sum = max(current_sum, max_sum)
Consider an array of non-negative integers. A second array is formed by shuffling the elements of the first array and deleting a random element. Given the two arrays, find which element is missing in the second array.
for num1, num2 in zip(arr1,arr2):
if num1 != num2:
zip() function returns a zip object, which is an iterator of tuples where the first item in each passed iterator is paired together, and then the second item in each passed iterator are paired together etc.
If the passed iterators have different lengths, the iterator with the least items decides the length of the new iterator.
a = ("John", "Charles", "Mike")
b = ("Jenny", "Christy", "Monica")x = zip(a, b)
(('John', 'Jenny'), ('Charles', 'Christy'), ('Mike', 'Monica'))
The bigO notation for the solution of our problem is nLog(n).
They’re many ways to approach this problem, but you have to consider the time it takes to run the code once the data becomes much bigger than your sample test data.
The Array Pair Sum problem: Given an integer array, output all the unique pairs that sum up to a specific value C.
def pair_sum(arr, C):
seen = set()
output = set() for num in arr:
target = C - num
if target not in seen:
This code has a big O notation of n which is exponential due to having to do two loops. Remember that spaces matter when coding with python!
Application programming interface or API, is a software intermediary that allows for two applications to talk to each other. In other words, an API is the messenger that delivers your request and responses from the front end to the back end of your program (client side rendering).
API’s are designed to do different tasks, these tasks are decided based off of the business needs. API functionalities are independent of the respective implementations, developers can make something as simple as rendering some JSON data, to having to deal with authentication and authorization of data with login capabilities.
Rails API provides a…
Hey, I encountered a problem when I was deploying my first project on Heroku that I was having a hard time debugging. I created a full CRUD, MVC project using Ruby on Rails, running everything locally.
localhost:3000 was running beautifully without any bugs, and I was excited to finally see my first project deployed live so that my friends and family could finally see what I was working on.
But when I deployed the project, I kept getting a rendering error. My first app’s screen would look like the following:
Now I have to check my Heroku logs to try…
Devise gem is a beautiful gem. Inside your gemfile, require:
gem 'devise', '~> 4.7', '>= 4.7.1'
Or which ever version is the most updated. Run
bundle install to grab the library and any dependencies for your rails project.Next, you need to run the generator:
rails generate devise:install
devise.rb file under the
initializers folder. You can configure the options there for email requirement in regex, password length, and other options for user inputs. Change the
config.mailer_sender to the email you wish others to receive emails from as a response. You’ll need to set up the default URL options for…
Problem solver with experience in Software, and Mechanical engineering. Interested in web-dev, machine learning, artificial intelligence, and new technologies.