Sign Up Now!

Sign up and get personalized intelligence briefing delivered daily.


Sign Up

Articles related to "code"


A function to sleep a 1000 years: explained

  • I encountered a code challenge that asked for a sleep function that sleeps a 1000 years.
  • The current functions use an integer to declare the amount of seconds, but 232 is only around a 100 years long.
  • After issuing the diagnostic, an implementation may choose to assume an implicit int and continue to translate the program in order to support existing source code that exploits this feature.
  • This function takes no parameters and gets the default return type.
  • So, now we have an int called i and a function with return type int called f().
  • According to the author, it stops at approximately a thousand years.
  • 0 would mean that f(sleep(7)) would not be run, and that’s the end of our f().
  • Let’s calculate the amount of years that this will run.
  • So this code will indeed run for a thousand years, with a margin of ten percent.

save | comments | report | share on


Machine learning model deployment with C++

  • Learn the actual Pricipal component analysis algorithm.Now that we have created the data table with the preprocessed face images, learning the PCA model is usually smooth.
  • Having saved the model, the inference layer will involve loading the saved model whose values are stored in the yml file also via OpenCV and developed to form an inference engine with necessary data preprocessing modules which is finally bundled as a .so file for deployment on a linux based environment.
  • Load a PCA modelFor inference, we let OpenCV load the existing model file from the saved .yml file after which we feed the eigenvalues, eigenvectors and mean to a new PCA object which we can then call a pca->project on to create a new image’s projection.
  • Create new image preprocessing and prediction stage.During inference of a machine learning model, it is important that the incoming image also passes through the same preprocessing as the training dataset.

save | comments | report | share on


Machine learning model deployment with C++

  • Learn the actual Pricipal component analysis algorithm.Now that we have created the data table with the preprocessed face images, learning the PCA model is usually smooth.
  • Having saved the model, the inference layer will involve loading the saved model whose values are stored in the yml file also via OpenCV and developed to form an inference engine with necessary data preprocessing modules which is finally bundled as a .so file for deployment on a linux based environment.
  • Load a PCA modelFor inference, we let OpenCV load the existing model file from the saved .yml file after which we feed the eigenvalues, eigenvectors and mean to a new PCA object which we can then call a pca->project on to create a new image’s projection.
  • Create new image preprocessing and prediction stage.During inference of a machine learning model, it is important that the incoming image also passes through the same preprocessing as the training dataset.

save | comments | report | share on


#techtalksMy Top React Techtalks of 2019

  • Tejas gives a compelling, real-world, case study of how TypeScript and GraphQL helped his company overcome issues with legacy code, iterate faster, and provide more value to their users.
  • Kitze talks about pragmatism into the fast-paced world of app development.
  • Elizabet shows how to prepare an SVG in Sketch, convert it to a JSX React component, and animate it with Framer Motion.
  • Learn how to build an accessible To-Do app with useReducer(), useState(), and React Context to manage state.
  • It is also a talk about architecture, abstractions and building tools that open up new possibilities.
  • The creator of MobX talks about his journey with the library and open source, reactive programming, client-side state management and learning new things.
  • Kent talks about how important it is to understand the abstractions that we use (Hooks, Suspense, JSX, etc), if we want to level up our abilities, speed and skills.

save | comments | report | share on


JavaScript's Async + Await in 5 Minutes

  • It’s likely that you’ve encountered Promises in your JavaScript (If you haven’t check out this guide quick 👍).
  • In our code, getting each ingredient requires an asynchronous operation.
  • For example, if the second operation needs the return value from the first operation and so on.
  • The await keyword allows us to wait for a Promise and define a variable with the return value of that Promise.
  • How about if the value you await on is not a Promise?
  • In our example, the asynchronous functions are returning a String after a setTimeout.
  • If you’ve got this far, we’ve created our function for getIngredients with the new async + await keywords.
  • If you’ve got this far, thanks for reading 😃 I’ve put together a gist with some possible example code that can be seen below along with some further resources on async + await.

save | comments | report | share on


Flask Apps - Open-Source Web Apps built with automation tools

  • In my career as a programmer, I learned a lot by playing with open-source stuff and add my work on top of an existing code-base.
  • Now I'm using automation tools to provide free products and provide a small piece of help for others.
  • What I learned, exactly?
  • I will put at the end of this article a short-list with open-source apps, coded/generated by starting from the design pattern perspective.
  • Currently, I'm using a semi-automated process that combines tools and boilerplate code to provide coded apps, with usable UI and basic features like authentication, database, ORM and basic deployment scripts.
  • Thank You!
  • Did you find this article helpful?

save | comments | report | share on


Lessons from Scrum

  • The longer the estimate, the greater the risk that you are underestimating the time required to complete this task.
  • If you find yourself attaching an estimate of more than two days, ask yourself: what is making this task more complex?
  • The biggest advantage we saw with acceptance tests was that requirements were discussed upfront with our stakeholders.
  • A by-product of having smaller tasks is that you tend to have smaller commits and conversely a shorter code review cycle.
  • Reducing the time pull requests stay in review keeps your cadence up, and reduces the risk of large changes being required for code review changes.
  • If you use a physical board for your tickets, think about how you can manage your digital assets in an orderly way.
  • It’s best to approach tasks that may look the most unpleasant or the most complex early on in the project.

save | comments | report | share on


3 More Common Beginner Python Mistakes

  • Without fail this crops up every year, a completely random error in perfectly fine looking code.
  • Just be careful when copying code from PDFs, online, or wherever because quite often you'll run in to random errors but more importantly you may even end up copying something malicious.
  • We had just introduced the concept of functions to the students, and how to use them to eliminate repeated parts of their code, and all of a sudden it was acting weird.
  • What the above snippet demonstrates is local function v.s. global scope.
  • A fair number of students had this in their code where they had accidentally redefined the input function in the program, then tried to use it later on.
  • As the pi example demonstrated what has happened is input now has the value of that string rather than being the built-in input function.

save | comments | report | share on


Six Sigma Gage R&R Analysis with R

  • For a measurement system to be accurate, the contribution of the gage R&R variability to the total variability should be lower than 10%.
  • For the following example, let’s consider a case where a battery manufacturer measures the voltage of three different batteries (parts), with two different voltmeters (appraisers), three different times (replicates).
  • This combination of results (i.e. small number of categories and a large percentage of variability), represents the worst case scenario for a measurement system.
  • The SixSigma R package represents a great tool that allows performing gage R&R analyses with just a few lines of code.
  • If you found this article useful, feel welcome to download my personal codes on GitHub. You can also email me directly at [email protected] and find me on LinkedIn. Interested in learning more about data analytics, data science and machine learning applications in the engineering field?

save | comments | report | share on


What Happens After Prisoners Learn to Code?

  • Even before starting at Slack, there was the not-insignificant challenge of relocating to Silicon Valley—which Aguirre, Ornelas, and Anderson all had to do in order to accept their positions.
  • In addition to working with Leal, Aguirre, Ornelas, and Anderson also each have a technical mentor, a work-culture mentor, and a career coach, and Slack’s nonprofit partners help the apprentices navigate housing, parole, and travel, and educate Slack’s employees on criminal-justice issues.
  • A spokeswoman for Slack said the company recognizes that this one project won’t solve broader reentry challenges, but she noted that the company hopes, internally and through its nonprofit partnerships, to help address issues faced by its formerly incarcerated hires.
  • Slack has held multiple company-wide meetings on criminal justice, including “reentry simulators” in which employees act out the challenges people face when leaving prison, such as applying for housing or registering with the Department of Motor Vehicles.

save | comments | report | share on