teleren/devto huggingface dataset:
Django - DB bulk_create()
Tags: python, django, database, queryset
Published: 2019-12-17 18:12:50

---
title: Django - DB bulk_create()
published: true
date: 2019-09-07 00:00:00 UTC
tags: python, django, database, queryset
canonical_url: https://tech.serhatteker.com/post/2019-09/django-db-bulk-create/
---

## bulk_create()

From [Django doc](bulk_create):

> This method inserts the provided list of objects into the database in an efficient manner (generally only 1 query, no matter how many objects there are):

So instead of inserting data into db one by one in an inefficient manner it is better to use this method.

Method api detail:

```py
bulk_create(objs, batch_size=None, ignore_conflicts=False)
```

Example:

```py
>>> MyModel.objects.bulk_create([
...     MyModel(title='This is a test'),
...     MyModel(title='This is only an another test'),
... ])
```

The `batch_size` parameter controls how many objects are created in a single query. The default is to create all objects in one batch, except for SQLite where the default is such that at most 999 variables per query are used.

On databases that support it (all except PostgreSQL < 9.5 and Oracle), setting the `ignore_conflicts` parameter(this parameter was added in `Django 2.2`) to `True` tells the database to ignore failure to insert any rows that fail constraints such as duplicate unique values. Enabling this parameter disables setting the primary key on each model instance (if the database normally supports it).

Another example for using `python list comprehension` to crate multi db model objects:

```py
objs = [
    Message(
        name=e.name,
        subject=e.subject,
        content=e.content,
        sender_name=e.sender_name
    )
    for e in query_list
]
msg = Message.objects.bulk_create(objs=objs)

# or use it like below but it is better to explicitly
# assign the keyword arguments as above
# msg = Message.objects.bulk_create(objs)
```

__Important__:

Please look at the number of caveats of this method in the [documentation](bulk_create). Such as the model’s `save()` method will not be called, and the `pre_save` and `post_save` signals will not be sent.

All done!

[bulk_create]: https://docs.djangoproject.com/en/2.2/ref/models/querysets/#bulk-create
After the fall of the Bitcoin movement, how will the Stablecoin movement with Libra and Gram play out?
Tags: libra, stablecoin, bitcoin
Published: 2019-09-06 23:50:38

---
title: After the fall of the Bitcoin movement, how will the Stablecoin movement with Libra and Gram play out?

published: true
description: 
tags: libra, stablecoin, bitcoin
---

<a href="https://medium.com/@lennartfr/after-the-fall-of-the-bitcoin-movement-how-will-the-stablecoin-movement-with-libra-and-gram-play-db5ee9fbae35">Will the Stablecoin movement succeed where Bitcoin failed</a>?

The cryptocurrency movement that was started by Satoshi Nakamoto at the end of the global financial crisis in 2008 focused on Bitcoin and its transport mechanism Blockchain. But Bitcoin had an Achilles heel which was that the currency wasn't tied to any established currency and so came to fluctuate almost as much as the Deutschmark in Weimar Germany at the end of the 1920s.

But it is also possible to create a digital currency and tie it to an established non-digit currency, a s.c. Stablecoin. Which give you a digital currency without all the fluctuations of a Bitcoin-type cryptocurrency.  

And maybe that is the way forward for the future of cryptocurrencies.
I built a tool to help people understand recursion!
Tags: computerscience
Published: 2019-09-06 23:37:55

Recursion is one of those topics where I think a lot of people have a hard time going from reading about it to grasping it in practical terms.  I know for myself that it was easy to learn the core jargon around recursion, such as base case, pre-order, in-order, post-order, etc, but I still found the concept difficult to wrangle with in practice.

We sometimes say that people are visual learners, and I believe that's definitely the case for myself.  I can learn all about the concepts, but if I can't see it, it will be harder for the idea to truly click.

Visualizing is my first step when trying to follow what a recursive function is doing, but that can be difficult when the function is complicated, or there are just too many calls to follow.

So, just to scratch my own itch, I built a little tool that can sketch out recursion as it happens.  You write a function, and the tool draws it out for you.  Let's take a look at some examples from it.  Hopefully it will help recursion click for you!

### Fibonacci Sequence

Here we have the example of all examples when it comes to recursion.  If you've read about recursion, you've probably seen an explanation of the Fibonacci sequence.   

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/pl9l5gnysnuohes66bfq.gif)

### Number of ways to jump up a flight of steps

So this one is a little less done to death.  How many different ways could you jump up 4 steps, if you can take steps 1, 2, or 3 at a time?  Let's find out.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/oyub1gjmvzzuyk8m2hvy.gif)

### Try your own function

Want to see how your own function looks?  The app accepts functions in a little made up language that mostly looks like any C style code.    

[You can try it out here.](https://practicum.tech/recurser)

I hope you enjoy!
Continuous Integration and Code Reviews
Tags: discuss, devops, codequality, testing
Published: 2019-09-06 22:19:15

I'm working on moving my team to a continuous integration process. Right now, we do work in a feature branch and once the feature is complete, we submit it a pull request for code review/merging. However, I'm not a fan of introducing large features all at once, which requires someone to spend part of their day reviewing dozens (and sometimes 100+) changes in a single code review session. Small commits are ideal and make it much easier to identify problematic code, and it obviously lends itself to more frequent releases. I suspect I'm preaching to the choir here, so I'll avoid extolling the virtues of CI/CD.

Most of my team is on board, but one of our team members is a bit resistant to this change. I am completely empathetic to his position, however. His concern is that when we introduce many small commits over time, it becomes difficult to review the feature in its entirety to make sure the code is consistent and works with all of the previous pieces of code that were introduced. My position is that automated testing directly addresses his concern. It will become apparent pretty quickly if new code is incompatible with previous code, based on the automated test results. Bite-sized commits are much easier for a reviewer to digest, and allow the reviewer to focus on style, readability, etc..., instead of whether the code works properly.

Has anyone else transitioned to continuous integration and faced resistance along the way? How have you addressed it with your team? Thanks in advance for any input!

Please forgive any grammatical errors or lack of clarity. It is Friday afternoon and I'm struggling to put my thoughts together after a long week (and it's hard to want to think about work after you've gotten home) :)
Three things from today - 9/6
Tags: devjournal, kubernetes, spark, datascience
Published: 2019-09-06 21:56:01

#9/6/2019
### Friddddddddday

Friday - nuff said.

##1.  Undo git commit

...because I always end up looking it up -

```
git reset HEAD~
```

##2. [Tilix](https://github.com/gnunn1/tilix)

I finally found a terminal manager that I like better than Terminiator!

##3. [OODA loop](https://en.wikipedia.org/wiki/OODA_loop)

Useful cycle for troubleshooting:
 - Observe 
 - Orient 
 - Decide
 - Act



See you party people Monday!
How does rack preprocess your middlewares?
Tags: webdev, ruby, rails
Published: 2019-09-06 21:50:29

# Tiny introduction

Have you ever thought about what happens when you start your rails server?
If no, I recommend you very much to learn more about [Rack](http://rack.github.io/). If you prefer video resources, guys from [thoughtbot](https://thoughtbot.com/) have an amazing [video](https://thoughtbot.com/upcase/videos/rack) especially for you.

# So, but how do rack middlewares work underhood?

Just a simple example of **config.ru** with two middlewares:

```ruby
# frozen_string_literal: true

class HelloWorld
  def call(env)
    [200, { 'Content-Type' => 'text/plain' }, ["Hello World\n"]]
  end
end

module Middleware
  class Base
    attr_reader :app

    def initialize(app)
      @app = app
    end

    def call(_env)
      raise NotImplementedError
    end
  end
end

class FirstMiddleware < Middleware::Base
  def call(env)
    status, headers, body = app.call(env)
    [status, headers, body << "First middleware body\n"]
  end
end

class SecondMiddleware < Middleware::Base
  def call(env)
    status, headers, body = app.call(env)
    [status, headers, body << "Second middleware body\n"]
  end
end

use FirstMiddleware
use SecondMiddleware
run HelloWorld.new

```

Let's start diving!

When **rack** processes **config.ru** it binds your code running with an instance of **Rack::Builder**.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/psey1idnq592a7kadwnh.png)
Then each time when rack meets **use AnyMiddlewareClass**, builder prepares middleware class and puts into instance variable **@use**
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/y3gumink1yw6603ke805.png)
Finally, the builder runs our application object but wraps it beforehand on all middlewares
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/erqpaabxacfbz9i43h98.png)

Thanks a lot for your attention, useful links:
- [Rack in images](https://github.com/JoelQ/intro-rack-notes)
- [My repo with the code examples](https://github.com/woarewe/rack-jorney)
[Video] How to Code Snake with HTML and JavaScript Tutorial
Tags: html, javascript, webdev
Published: 2019-09-06 21:20:34

In this video I will show you how to create the all famous snake game.

Watch on YouTube:
https://youtu.be/oY-WEIXNIvI

A basic understanding of HTML5 canvas and animation techniques is required. If you don’t have any experience in this area yet I recommend to watch this first:

Particle Animation with HTML5 Canvas
https://youtu.be/VfmTi4k51aQ
To align assignments or not?
Tags: java, codequality, healthydebate
Published: 2019-09-06 20:39:39

If you've looked at the code of some well-known maintained C/C++ open source projects, you may have noticed that whenever there are multiple variable assignments they tend to be aligned like this:

```cpp
first_num      = 1;
second_num     = 2;
third_num      = 3;
fourth_num     = 4;
fifth_num      = 5;
some_other_num = 6;
```

instead of

```cpp
first_num = 1;
second_num = 2;
third_num = 3;
fourth_num = 4;
fifth_num = 5;
some_other_num = 6;
```

This can sometimes also be seen in Makefiles (especially automatically generated ones). But speaking of Java, most IDEs will likely attempt to trim redundant whitespace by default.

**So what do you think? Is this style relevant to Java as well?
Also, which one looks more readable to you?**
Why Data Science?
Tags: beginners, career
Published: 2019-09-06 18:37:06

### Intro & Background
Hello, my name is Patrick Ly. I have been working in the oil and gas industry for 5 years. First, I held a position as an Operations Engineer which is an intermediary technical position between the office and oilfield operations. I helped improve the effectiveness and efficiency of our drilling and completions programs. Later in my career I got promoted to Site Supervisor. In this position I was responsible for managing the oilfield service equipment, asset wells, and personnel onsite in the field by delegating and facilitating the work flow. 

Recently this year, my company was acquired by another upstream oil company and I was laid off. In truth, it was a blessing in disguise because I contemplated quitting my position for a career shift earlier in the year. I enjoyed the people I worked with, found satisfaction in having a major impact on the business, and the monetary rewards. However, the operational side of the oil and gas industry did not stimulate my technical interests nor did I see it aligning with my long term career goals. 

### The Search 
I started my job search to find a role that could utilize my business knowledge of the oil and gas industry but had a more technical focus. I found that a traditional drilling and completions engineer role would be the best fit from my prior experience but again the technical part of the role did not appeal to me. As an operations engineer you are primarily a project manager and then a business analyst. Thus, there is some limitation on how much higher level analysis/analytics you can do. The priority is executing and managing the operation to be within budget. 

As I progressed in my job search, I noticed the growing positions of jobs related to analytics and data science. This was when I did more research into this sector. One main source of information came from one of my friend that just finished a master program for data science. He talked about how relatively new it is and how the demand was growing (especially in oil & gas). Also he talked about the advanced applications of data science that I intrigued me. 

### The Reason
With this interest I began to examine the reasons I want to pursue data science. Below summarizes the main points: 

1) **Great fit** - Besides having the technical capability as an engineer, data science fits my personality as I am a very logical and analytical person that likes to look at the objectivity of the subject at hand. 
2) **Improving technical skills** - Data science will improve many technical skills such as programming, statisical analysis, problem solving etc. It will provide a platform where I can become a forever learner. 
3) **Practicality & scope** - I can envision numerous application of data science I could use not my career but personal life as well. 

Overall, I feel that data science could be a great way to expand my technical abilities and segue my career into another sector that I could be passionate about.
A Choice
Tags: ruby, rubydoc, documentation
Published: 2019-09-06 19:14:45

---
title: A Choice
published: true
description: Where to contribute?
tags: ruby, rubydoc, documentation
---

I have a choice to make:

- Write about Ruby here on DEV, as I've sometimes done.
- Contribute to RubyDoc.

For example, I've recently worked on (and just posted) a piece about Ruby's class <code>Exception</code>:

- [About Ruby Class Exception](https://dev.to/burdettelamar/about-ruby-class-exception-21f3)

I wrote it to provide documentation for the class that includes lots of illustrative code -- more that what's offered in the RubyDoc:

- [Class: Exception (Ruby 2.6.3)](https://ruby-doc.org/core-2.6.3/Exception.html)

Now I've discovered that I could instead have offered improved example code for the RubyDoc page itself.  It turns out that over at documenting-ruby.org, [anyone can submit documentation patches](http://documenting-ruby.org/).

Contributing there would have a far greater reach than anywhere else, because RubyDoc is where people go to find out about Ruby, and because RubyDoc is always high in Google's search results.

I can't be proud of my hesitation:

- Here, I'm me.
- In the RubyDoc, I'd be anonymous.

I have to ask myself:

- Do I want to be seen?
- Or do I want to make a bigger difference?

(I think I know what's the right thing.)
Responsive Navbar w/ Flexbox
Tags: css, webdev, flexbox, tutorial
Published: 2019-09-06 18:57:53

Out with another video tutorial based off of https://twitter.com/azaleamollis written tutorial.  Learn to code up a responsive navigation bar with Flexbox.  A bit of CSS animation and jQuery to boot!

[Subscribe To The Channel!](http://www.youtube.com/c/FollowAndrew?sub_confirmation=1)

{% youtube 6pidsgeLLzE %}
Any tips for someone just starting out learning Elixir?
Tags: discuss, elixir
Published: 2019-09-06 18:55:46

I recently decided to start learning Elixir.  I've already got a project in mind (I'm going to be converting some existing tools I use regularly on my systems from Python (a language I already have solid experience with) to Elixir since the concurrency model should help them be significantly more efficient), and I've worked through the whole 'Getting Started' guide on the website without any significant issues.

However, it's drastically different from most of what I'm used to (I'm coming from a mostly Python background, with some JS and SH experience), and I'm wondering if anybody might have some advice for people new to the language?  Any particular gotcha's to watch out for that aren't well documented?  Possibly things that need to be handled significantly differently in Elixir compared to other languages for efficiency reasons?
How I Chose Data Science
Published: 2019-09-06 18:50:33

I recently began a 15 week program with the Flatiron School with the goal of pursuing a career in data science. With an extremely limited background in programming or anything even tangential this stands to be a long and mind boggling road. So why choose something so seemingly remote from the rest of my experience? Let's take a walk and see... or keep sitting where you are, or don't bother, whatever it's a free country, no judgement.


![murica](https://media.giphy.com/media/5yzvlzQFqePni/giphy.gif)


By financial investment and official certification I am a geologist. Once naively entrenched in the dream of becoming a paleontologist I was all in on being a scientific rock-star. However, toward the end of my undergraduate years I realized academia wasn't for me and on the steps of reality my childhood dream perished like. 

![dead dreams](https://media.giphy.com/media/igp7Q6iW1bXBC/giphy.gif)

I became momentarily lost, unsure of where to go after so many years of a singular goal. But weep not for me my friends, life went on and I soon found new dreams and fresh pursuits. I spent the two years after graduating as a missionary abroad, seeking to bring the opportunity of meaning to others while seeking it myself. A year of this brief whisper in the dark we call life was spent in oil fields of Texas, followed by four years in the wild world of secondary education.


So if you've made it this far you may be asking, "Brandon, what in the name of green bean soup does any of that have to do with data science?" Well my friend, I.... wait a minute, what *does* any of this have to do with data science?


![confusion](https://media.giphy.com/media/pPhyAv5t9V8djyRFJH/giphy.gif)


Oh, right! So as enthralling as this synopsis of my life has been, how did any of that point me in the direction of data? Once I decided to move away from teaching I began to look back on my varied career path to see if there was anything behind me that could help point the way forward. Upon reflection I began to see that through all the different roles I had been in there was one constant: a move toward data driven decision making. As a fairly analytical person with a penchant for puzzles and a proclivity for patterns, coupled with a few suggestions from acquaintances as well as my own explorations, data science seemed like a logical conclusion. The idea of extrapolating and extracting patterns and meaning from apparent nonsense is a fascinating prospect, and I look forward to seeing the full potential of the field. Anything from organizing cladistics in evolution, assessing producibility of a reservoir, to refining methodology and content focus in education, the possibilities are 


Anyway, that's all I have to say about that. I guess. Bye.
Load testing Azure EventHubs with JMeter
Tags: azure, jmeter, performancetesting, eventhub
Published: 2019-09-16 20:21:55

---
title: Load testing Azure EventHubs with JMeter
published: true
tags: azure,jmeter,performance-testing,event-hub
canonical_url: https://medium.com/@domenicosibilio/load-testing-azure-eventhubs-with-jmeter-a49d2e3675b7
---

[![](https://cdn-images-1.medium.com/max/600/1*5142Ik5tT2bF4YDUerMq1g.png)](https://medium.com/@domenicosibilio/load-testing-azure-eventhubs-with-jmeter-a49d2e3675b7?source=rss-299466747366------2)

Azure EventHubs performance testing made easy!

[Continue reading on Medium »](https://medium.com/@domenicosibilio/load-testing-azure-eventhubs-with-jmeter-a49d2e3675b7?source=rss-299466747366------2)
MFA on PayPal
Tags: tutorial, beginners, security, mfa
Published: 2019-09-06 18:29:17

---
title: MFA on PayPal
published: true
description: Tutorial on how to enable 2-step authentication on PayPal.
tags: tutorial, beginner, security, MFA
---

**#MFAally** is a hashtag for those trying to help others enable Multi-Factor Authentication on all of their important apps. To learn more about what MFA is and why it matters, [read this](https://dev.to/azure/multi-factor-authentication-mfa-nm2).

I had to send someone money on PayPal this morning for a meetup and realized, to my **HORROR**, that MFA was not enabled. I fixed that error immediately.

You can enable it so easily! Log in, go the the "settings gear", click security, and then find "2-step verification".

![You can enable 2-step authentication so easily! ](https://thepracticaldev.s3.amazonaws.com/i/nk2lig87hnzlhvj8ytwq.png)

Of course, I choose [Microsoft Authenticator](https://www.microsoft.com/authenticator?WT.mc_id=devto-blog-tajanca). I opened up Authenticator, selected "New account", chose "other type of account" and then took a photo of the QR code on the screen.

Then I entered my code from Authenticator into the PayPal website and I was all set!
![Then I entered my code from Authenticator into the PayPal website and I was all set!](https://thepracticaldev.s3.amazonaws.com/i/zki1cgl416nodt8nccqd.png)

Look at me! With my fancy 2FA! You can too! #MFAally
![Look at me! With my fancy 2FA! You can too! #MFAally](https://thepracticaldev.s3.amazonaws.com/i/ctutoe7fsndpabsgawcq.png)

---
**For this and more, check out my book, [Alice and Bob Learn Application Security](https://aliceandboblearn.com/) and my online training academy, [We Hack Purple](https://academy.wehackpurple.com)!**
---
Developers using Macbooks, have you made the Touch Bar useful?
Tags: discuss
Published: 2019-09-06 18:22:19

---
title: Developers using Macbooks, have you made the Touch Bar useful?
published: true
description: 
tags: #discuss
---

I recently upgraded to a newer Macbook, one with a Touch Bar. So far, I haven't found its defaults useful for me in most apps I use for work. I've re-mapped `esc` to my Caps Lock key, but otherwise haven't done anything.

Any way to make this weird thing useful for programming?
What is the "<>" operator called in Elixir?
Tags: discuss, elixir
Published: 2019-09-06 18:02:41

I'm reading over the Elixir guides and recently came across the various operators. One of which is the `<>` operator used to concatenate two stings. It doesn't mention a name for the operator though. And it's my first time seeing that in any language.

```elixir
"Hello" <> " World"
"Hello World"
```
Integrate the Reminders API with Your Alexa Skill to Deepen Customer Engagement
Tags: alexa, beginners, tutorial, javascript
Published: 2019-09-06 18:01:40

---
title: Integrate the Reminders API with Your Alexa Skill to Deepen Customer Engagement

published: true
description: Integrating the Reminders API in your skill is a great way to actively extend its utility without requiring customers to launch your skill. With the Reminders API, you can engage more frequently with your customers and become a part of their routines.

tags: alexa, beginners, tutorial, javascript, 
---

Integrating the Reminders API in your skill is a great way to actively extend its utility without requiring customers to launch your skill. With the Reminders API, you can engage more frequently with your customers and become a part of their routines.

<center><h2>Learn more by clicking below<br/>👇</h2></center>

[![Click to see more](https://thepracticaldev.s3.amazonaws.com/i/etabaqfuvt8945pbevja.png)](https://developer.amazon.com/blogs/alexa/post/2b4de691-9cad-4c82-86e0-98e674786742/integrate-the-reminders-api-with-your-skill-to-deepen-customer-engagement1)

_If you'd like updates on more content like this, follow me on Twitter **[@ItsPanW](https://twitter.com/itspanw)**_