teleren/devto huggingface dataset:
Django: Fixing race condition when queuing with on_commit hook
Tags: django, queue, celery, djangoq
Published: 2018-04-12 09:42:49

---
title: Django: Fixing race condition when queuing with on_commit hook
published: true
description: When processing task in db asynchronously, it possible one process creating the record haven't commit yet while the background process already started and try to process the updated record.
tags: django, queue, celery, django-q
---

This has been explained in [Celery docs]( http://docs.celeryproject.org/en/latest/userguide/tasks.html#database-transactions).

And we bumped into this issue after rolling out django-q into production recently. Let say we have a function like this:-

``` python
@transaction.atomic
def send_msg(recipient, text, msgid=None, queue=False):
    msg = Message.objects.get_or_create(msgid=msgid)
    if queue:
        async('send_msg', recipient, text, msg.msgid, queue=False)
        msg.status = 'QUEUED'
        msg.save()
        return msg

    # pass msg to backend gateway
    send_to_gateway(recipient, msg, ....)
```

Once we had the qcluster running, we start seeing "Duplicate entry error" in the log. Look like when we call async(), the cluster picked it up before the transaction get committed, so get_or_create() there will create new object with the same msgid instead of getting an existing one. So we fix that using `transaction.on_commit()` in django 1.9.

``` python
@transaction.atomic
def send_msg(recipient, text, msgid=None, queue=False):
    msg = Message.objects.get_or_create(msgid=msgid)
    if queue:
        def _add_to_queue():
            async('send_msg', recipient, text, msg.msgid, queue=False)

        msg.status = 'QUEUED'
        msg.save()
        transaction.on_commit(_add_to_queue)
        return msg

    # pass msg to backend gateway
    send_to_gateway(recipient, msg, ....)
```

We use SQS but it doesn't matter what broker you use. It's depend whether your task depend on something in db. In our case above, the flow basically:-

Web request
1. User send message
2. We create a record in the db to represent the sent message with unique id
3. async() the function to send the message, with the message id as one of the arguments.
4. commit the transaction.

Queue worker
1. The send message function invoked from qcluster
2. Try to get the message by message id or create new one if doesn't exists.
3. Send the message and update status as SENT.
4. Commit transaction.

This issue happened between no. 3 in web request and no. 2 in the queue worker. Basically the rule of thumb if you're using transaction, **async should be called from the outside of the transaction, not inside**.

*****
Originally posted at [issue on Github](https://github.com/Koed00/django-q/issues/154).
Turn Your Customers Into Subscribers
Tags: prestashop, prestashopmodules, paypal, subscriptions
Published: 2018-04-12 08:31:10

---
title: Turn Your Customers Into Subscribers
published: true
description: SOO Paypal Subscription & Recurring Payment is the best Plug-and-Play Subscription Management module on Prestashop to empowers businesses to launch subscription models and manage the entire lifecycle of their subscribers.
tags: prestashop, prestashop modules, paypal, subscriptions
canonical_url: https://www.prestasoo.com/blog/starting-your-own-subscription-business-with-prestashop.html
---

![](https://www.prestasoo.com/images/stories/subscriptions/real-recurring-payment-by-paypal.gif)
[SOO Paypal Subscription & Recurring Payment](https://www.prestasoo.com/prestashop-modules/subscriptions-prestashop-module.html) is the best Plug-and-Play Subscription Management module on Prestashop to empowers businesses to launch subscription models and manage the entire lifecycle of their subscribers.

Capture More Residual Revenue

Can you guarantee how much money your Prestashop store is going to make this month?

If you offered subscription-based products, you could do just that : Create product of the month clubs, weekly service subscriptions or even yearly software billing packages with Paypal.

https://www.prestasoo.com/prestashop-modules/subscriptions-prestashop-module.html
When was the last time you wrote CSS code without preprocessors?
Tags: discuss, css, career, webdev
Published: 2018-04-12 06:27:45

---
title: "When was the last time you wrote CSS code without preprocessors?"
published: true
description: Every once in a while I work on a project that doesn't use preprocessors.  No variables, mixins, functions, nesting. Just pure CSS.
tags: 
- discuss
- css
- career
- webdev
---

Every once in a while I work on a project that doesn't use preprocessors.  No variables, mixins, functions, nesting. Just pure CSS.

It is a challenge, at least for me. The most common mistake I make the very first second I open CSS file is I try to nest selectors. This feature is so simple and powerful that I don't notice it. It is part of my daily routine and getting back to writing old-school selectors is hard suddenly. It is hard to debug and search "flat" selectors, too. Maybe it is just me, but I cannot live without preprocessors anymore.

New developers are emerging every day. Do you learn preprocessors from the start or do you learn pure CSS first?
What about experienced developers, how do you behave when you write pure CSS nowadays? Do you enjoy writing pure CSS? 
Did we take preprocessors for granted?
Where Software Lives
Tags: software, beer, quote
Published: 2018-04-21 17:50:44

---
title: Where Software Lives
published: true
tags: [software, beer, quote]
canonical_url: https://dmerej.info/blog/post/where-software-lives/
---

Last night I had a beer with some old friends and colleagues.

We were discussing a particular library and one of us explained he recently found patches from almost all of us in the git history.

And then he said (I’m paraphrasing a little):

> Software lives in the minds of the people who wrote it. Code and documentation are nothing but distant echoes of their thoughts at a given time.

I could not agree more.

Code is all but a means to an end, try and remember that.

Cheers!
Fixing WordPress Jetpack Connection Errors
Tags: apache, bugs, php, wordpress
Published: 2023-04-29 21:13:22

---
title: Fixing WordPress Jetpack Connection Errors
published: true
date: 2018-04-12 06:04:24 UTC
tags: apache,bugs,php,wordpress
canonical_url: https://mikestaszel.com/2018/04/12/fixing-wordpress-jetpack-connection-errors/
---

I recently migrated my WordPress installation from an old Debian 8 Google Cloud instance to Debian 9. I decided to do the installation myself this time instead of using a Bitnami image for greater control. I couldn’t get _[certbot](https://certbot.eff.org)_ (a [Let’s Encrypt](https://letsencrypt.org/) client for free SSL certificates) to work on the Bitnami image so I figured I’d set everything up myself.

I ran into one problem that took me a while to debug and figure out. I relinked my site to [Jetpack](https://jetpack.com/) to get basic analytics and automatic sharing to LinkedIn, but Jetpack couldn’t communicate with my site.

<!--more-->

The error messages were very cryptic:

```
Your Jetpack has a glitch. Something went wrong that’s never supposed to happen. Guess you’re just lucky.
```

And:

```
parse error. not well formed
```

Through reading some documentation and StackOverflow posts I decided to check if the XML-RPC endpoint was working on my site – it was – mostly.

After almost giving up, I happened to notice that I didn’t have the PHP XML package installed, maybe that was causing the parsing error? I bet you need an XML parser for an XML-RPC API.

Sure enough, all I needed to do was install the “php-xml” package with:

```
sudo apt install php-xml
```

That solved all the issues! I can see my site stats, share posts to LinkedIn, and use the WordPress mobile app. I guess this is more of a “note-to-self” for next time I move this blog somewhere, but maybe it’ll end up helping someone!

<!--kg-card-end: html-->
スモールスタートでサービスを作る時は、やはりHerokuが便利だね
Tags: heroku, paas
Published: 2018-04-12 05:12:23

---
title: スモールスタートでサービスを作る時は、やはりHerokuが便利だね
published: true
description: 
tags: heroku, PaaS
---

# スモールスタートでサービスを作る時に今ならどのPaas使って構築するか考える
- 知人に聞かれたので整理も兼ねてここに残しておく

## 超かんたんなサービスの初期要件
- 機能要件)
    - 会員登録ありのSNS
    - メディア媒体あり
    - ニッチセグメント版Rettyみたいなやつ
    - 最近流行りのBlockchainとかそういうのは使わない

- 非機能要件) 
    - 拡張性があること(グロース時に、Paas変えなくてもスケールできること)
    - ドキュメントが充実してること (jp/en問わず)
    - あるていど技術的に枯れていること
    - Paas業者が潰れなそうなところ (スタートアップ系のPaasは避ける)

# 結論
- heroku ([https://jp.heroku.com/home](https://jp.heroku.com/home)) 一択だなと
- エンジニアがインフラ面をそこまで意識せずに使えるのは大きい。特にスモールスタート時は開発リソースも少ないので
- 運用コストが安い。初期の頃は無料プランで対応できる。(無駄にスペック高くしなければ)
- 運良くサービスがヒットし、グロースしたらエンジニア採用してAWSとかGCPに引っ越せばいいと思う

# 比較対象
- ConohaなどのVPS
    - 月額数千円〜は必ずかかる。インフラ知識が必要。サービス以外に思考リソースが取られる
- Amazon Web Service (AWS) や Google Cloud Platform (GCP)
    - 初期の頃は無料プランである程度つかえる。しかし、AWS/GCPの操作に関して、前提知識が結構必要
    - セキュリティの設定をきちんとしないと、クラウド破産もありえる。下記は救われているが、救われないケースも有る
    - [初心者がAWSでミスって不正利用されて$6,000請求、泣きそうになったお話。](https://qiita.com/mochizukikotaro/items/a0e98ff0063a77e7b694)


# 余談
まぁ、dev.to (このサービス)もherokuで動いてるしねー。
- [The dev.to tech stack](https://dev.to/ben/the-devto-tech-stack)
Datalists with Vue.js
Tags: vue, javascript, webdev
Published: 2018-04-13 13:20:34

---
title: Datalists with Vue.js
published: true
tags: vue,javascript,webdev
canonical_url: https://www.raymondcamden.com/2018/04/12/datalists-with-vuejs/
---

This isn't necessarily a very exciting post, but a few days back someone asked me about integrating Vue.js with [datalist](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist) tags. The datalist tag is one of my favorite HTML tags and something I've [blogged about a few times](https://www.raymondcamden.com/search/?q=datalist) in the past. If you aren't familiar with it, it basically provides a "autosuggest" style experience to an input tag.

The HTML is pretty simple. Here is the example used in the MDN article I linked to above:

```
<label for="myBrowser">Choose a browser from this list:</label>
<input list="browsers" id="myBrowser" name="myBrowser" />
<datalist id="browsers">
  <option value="Chrome">
  <option value="Firefox">
  <option value="Internet Explorer">
  <option value="Opera">
  <option value="Safari">
  <option value="Microsoft Edge">
</datalist>
```

Basically - you create a `<datalist>` element and supply options. You then take your input and add the `list="id of the list"` attribute. Now when the user types, they will get suggestions based on the list and what they've typed in. It's pretty well supported (basically everyone but Safari and Mobile Safari, because of course) and fails gracefully (the user can still type anything they want). How would you combine this feature with Vue.js? Let's look at a static example. First, the HTML:

```
<div id="app">
  <input type="text" v-model="film" list="films">
  <datalist id="films">
    <option v-for="film in films">{{film}}</option>
  </datalist>
</div>
```

You can see the input field and the list. The `option` tag is tied to a variable called `films`. Now let's look at the JavaScript:

```
const app = new Vue({
  el:'#app',
  data() {
    return {
      film:'',
      films:[
        "A Throne Too Far",
        "The Cat Wasn't Invited",
        "You Only Meow Once",
        "Catless in Seattle"
	    ]
	}
  }
})
```

Not too exciting, but it works rather well. You can test it below:

{% codepen https://codepen.io/twhite96/pen/PRvZyG %}

How would you make it dynamic? Simple - just change how the data is generated. Here's an example of that:

```
const app = new Vue({
  el:'#app',
  data() {
    return {
      film:'',
      films:[]
    }
  },
  created() {
    fetch('https://swapi.co/api/films/')
    .then(res => res.json())
    .then(res => {
      this.films = res.results.map(f => {
        return f.title;
      })
    })
  }
})
```

All I did was add in a `created` event handler and hit the [Star Wars API](https://swapi.co) for my data. You can test the result below:

{% codepen https://codepen.io/twhite96/pen/KoYrrg %}

I may be biased - but everything is better in Vue.
Any plans to create a publish api for dev.to?
Tags: discuss, meta
Published: 2018-04-11 22:00:16

---
title: Any plans to create a publish api for dev.to?
published: true
description: 
tags: discuss, meta
---

Anyone else think it would be very useful to be able to push content to dev.to via an API?  Does one already exist, I couldn't find one.
A Look at The Draft for JWT Best Current Practices
Tags: jwt, authentication, ietf, bestpractices
Published: 2018-04-11 20:19:03

---
title: A Look at The Draft for JWT Best Current Practices
published: true
description: Learn the best practices for keeping your JWTs secure.
tags: #jwt #authentication #ietf #bestpractices
canonical_url: https://auth0.com/blog/a-look-at-the-latest-draft-for-jwt-bcp/
---

The IETF OAuth Working Group is always hard at work creating and improving standards in the identity space. In this post, we will take a look at the latest draft for the JWT Best Current Practices document. This document describes common pitfalls and attacks related to the use of JWTs, and how to implement mitigations against them. 

[Read on to learn more 🙌](https://auth0.com/blog/a-look-at-the-latest-draft-for-jwt-bcp/?utm_source=dev&utm_medium=sc&utm_campaign=jwt_ietf)

![A Look at The Draft for JWT Best Current Practices](https://thepracticaldev.s3.amazonaws.com/i/ptsmmva58fi4egmdmf28.png)
How fast does your sector/industry move?
Tags: discuss, career, workplace
Published: 2018-04-11 19:40:45

---
title: How fast does your sector/industry move?
published: true
tags: discuss, career, workplace
---

Not everyone in software development works in the same sector, software development is everywhere, from web development to the financial sector!

As I was leaving work today, I was thinking about the sector I work in, about how slow it can be at adopting new technology, methods and frameworks... It got me thinking about other sectors and how it must affect them?

Some sectors must be packed with BDD (Buzzword Driven Development) and others must be moving to new tech at as slowly as they can 


So, I want to hear what you all think, what sector do you work in, how fast does it move, and do you think it's a good thing?
some history about functional programming - lambda calculus 
Tags: javascript
Published: 2018-04-11 19:32:37

---
title: some history about functional programming - lambda calculus 
published: true
description: 
tags: javascript
---

# Some history about Functional programming - I
Functional Programming (FP) is not a new concept and it has some history that it based on to be at this form we use nowadays. this history starts with λ lambda calculus.

## λ lambda calculus
Lambda calculus was introduced by Alonzo church in the 1930s as apart of an investigation into the foundation mathematics.

Lambda calculus is a typeless theory of functions, it describe a notion of a function in computational perspective.

Function in lambda calculus is a black box , what it dose that it take some input, so may it takes a number like x and it’s going to process it in someway and it’s going to produce an output.

There’s two facts about functions in λ calculus:

functions are black box so you are not allowed to look inside, you can’t see the mechanism of what’s going on.
functions are pure so they have no internal state, no hidden information that we can use.
What’s the point of λ calculus?

You can encode any computation into lambda calculus function.
It build the basis of functional programming.
What you can do with λ calculus?

lambda calculus basically got nothing in it, no data types no recursion or even control structure, all we got is variables, a way of building functions and a way of applying those functions.

so we have to encode almost everything you need to build your program logical operators, loops, recursions, …etc

How to define functions in λ calculus?

To define a function that take single input x and increment that input by one you may define your function in that way

λx. x+1
x is the input, x+1 is the output

To define another function that take two inputs and return the summation as the output you may type your function in that way.

λx.λy x+y
here the function take two inputs x, y and return the summation of them as output.

also you can decode some logic operators as function in lambda calculus here an example, let’s encode true and false into functions

If true were a function it would be a function that take two arguments and return the first one,

so TRUE function would be like

λx.λy x
and the same for FALSE function it would be a function that takes two arguments and return the second one as output,

λx.λy y

That’s was a very simple introduction about lambda calculus.

here’s some resources where i read about lambda calculus.

https://www.cs.kent.ac.uk/people/staff/dat/tfp12/tfp12.pdf
https://en.wikipedia.org/wiki/Lambda_calculus
Friday Blast #22
Tags: fridayblast, links, post
Published: 2019-01-20 15:22:13

---
title: Friday Blast #22
published: true
tags: friday_blast,links,post
canonical_url: https://horia141.com/friday-blast-22.html
series: "Friday Blast"
---

Back from holidays with a shorter set of links. Still, there’s some pretty interesting stuff.

[Geospatial indexing: the 10 million QPS Redis architecture powering Lyft (2017) #video](https://www.youtube.com/watch?v=cSFWlF96Sds) - a look at the tools and approaches Lyft uses in order to scale Redis to over 15 million QPS across their whole system. The growth was such that the title of the talk fell behind the actual numbers. It’s an interesting approach of high-level algorithm design (S2 based geohashing, complex business rules around position updates and reads) and basic infrastructure tailored to Lyft’s specific issues (proxies with consistent hashing, service discovery, health checks).

[Reasoning about performance in the context of search (2017) #video](https://www.youtube.com/watch?v=80LKF2qph6I) - again a deep dive into the design of search (or at least some aspects of it) at Bing. The usage of Bloom filters is quite interesting, as opposed to the usual inverted index / post lists. I’d say the best thing to get out of this talk is the way the author goes about estimating performance for several cases, and how even from high level numbers (I want to serve 10M documents) one gets to pretty low-level details (that means I’ll do 5 memory accesses on average). The kind of stuff which should be considered when designing anything performance sensitive. And also the kind of stuff which frequently pops up in system design interviews.

[Why your encrypted database is not secure (2017)](https://blog.acolyer.org/2017/06/16/why-your-encrypted-database-is-not-secure/) - turns out databases leak a lot of information in various memory and disk caches, access logs etc, which can be used by local attackers to beat the data encryption in so called _encrypted databases_. This even occurs in the form of _snapshot attacks_, which are attacks where one can see just one query. Another thing to add to your “securing data at rest is a hard problem” box.

[Service ownership checklist (2017)](http://codecapsule.com/2017/11/12/service-ownership-checklist/) - a an example of a service ownership checklist - all the bases you need to cover when you’re running a service for other teams / external user. Spans subjects from project management to security, logging, capacity planning etc. The list is kind of daunting, but then again, it’s applicable to more mature organizations, which can take the time to properly do these things.

[The art of promise-based architectures (2015)](http://blog.rangle.io/the-art-of-promise-based-architecture/) - in JavaScript land there is (or was) a big transition from callbacks to promises and later to `async/await` on top of those promises. This is an article from the start of that transition highlighting the benefits and how to think in the new world.
De vuelta, cambios y anuncios
Published: 2018-04-11 20:05:12

---
title: De vuelta, cambios y anuncios
published: true
tags: 
canonical_url: https://yorodm.github.io/blog/cambios-plantilla-blog/
---

# De vuelta, cambios y anuncios.

Despúes de casi 3 meses sin actualizar el blog (muuuuuuucho trabajo) estoy de vuelta con nuevos cambios para la plantilla (ahora el RSS muestra el contenido completo) y sindicaciones para [dev](https://dev.to/yorodm) y pronto en[Medium](http://medium.com).

Les dejo un _roadmap_ de los próximos temas que pienso tratar en el blog:

1. _Emacs_ para desarrolladores de _frontend_ (Vue, Angular, Typescript).
2. _Emacs_ para desarrolladores de _backend_ (SQL, Python, Ruby, PHP).
3. Integrando _Odoo_ a las redes sociales.

Saludos y mantenganse enlazados.
Lint only over changed files
Tags: javascript, beginners, git
Published: 2018-04-11 16:47:42

---
title: Lint only over changed files
published: true
description: How to run lint only over changed files
tags: javascript,beginners,git
---

The bigger your project gets, the longer time `lint` takes.

So the following task is quite useful since we basically want to run lint only over changed files.

```json
# package.json
{
  "scripts": {
    "tslint": "git diff --name-only develop... | grep -E '\\.tsx?$' | xargs yarn tslint"
  }
}
```

I'm referring `tslint` here, but the same is true of `eslint`, `stylelint`, and etc.
What to learn to become a front end developer?
Tags: help, beginners
Published: 2018-04-11 16:07:46

---
title: What to learn to become a front end developer?
published: true
description: 
tags: #help, #beginners
---

Hello everyone. I have recently started to study the basics of the html and css language, and soon I will start javascript. I was wondering, beyond the "holy trinity", what does a good front end developer know?
Process Proposal 
Tags: process, proposal, web
Published: 2018-01-05 16:45:50

---
title: Process Proposal 
published: true
description: In my University's Practices
tags: #process #proposal #web
---
![step by step](https://pyrus.com/en/blog/wp-content/uploads/2016/07/step.jpg)
When I was at the university I present a proposal to make a little different the process to develop a website (also works with other software develops), My boss back then was new and just had a computer and customer, but the time we had more and more customers and the company was growing.
Arrived designers, engineers and commercial people, all were part of the developing, and I thought in form to make more cheap and fast all, this is my proposal:

Planning > Concept > Executing


* Planning
We had a meeting to talk all about the project, the commercial people involved us in the area, business type, graphics line, type the customer, basically all.

It's important to make the act(a paperwork about all talked in the meeting) and the requirements doc.

know what does the customer want?
probably neither he, but our mission is to make something great and possible, the list of requirements is a way to know more and avoid mistakes.

*Concept
We defined the schedule meetings but demonstrated the responsibility and compromise of the project, all person like the project manager, designer, developer, and the customer must be synchronized.

Present the concept graphics, proposals and the interactive mockups.(videos or software like marvel...)

*Executing
The developers defined delivery times to present the website or software, that are presents many problems but is the more fun area.
coding and during many nights without sleep is heavy, but and the end you can see your little son jejeje

//Note: I know that process is the same to scrum or other, but I would like to say my opinion and share my manner to make the things.

thanks for reading, Is very important to me this blog because is an outside to my mind and share with you.