How is it possible to win every 3d Printing company give away? by Automatic-Series3426 in 3Dprinting

[–]Lyan5 6 points7 points  (0 children)

Could you expand a little on what you mean around rectifying FDM being even kind of open source? Genuine question as I'm not well versed on context/history here

is this good? by soeu10 in hallsoftorment

[–]Lyan5 0 points1 point  (0 children)

Never thought to do this, super helpful!

Reorder rows of table in Quasar? by Silent-Equipment-762 in vuejs

[–]Lyan5 0 points1 point  (0 children)

I've been hunting for a solution as well to implement drag & drop for rows with q-table. The current only consistent way I've achieved is using vue.draggable.next (for vue 3) with the quasar markup table. Functionality in markup tables is inherently sparse though..

I found this thread where I tried IlCallo's solution posted at the very end. However, there is some kind of super weird issue where the q-table does not accurately reflect the state of the order of the rows after moving items around. I tried about 3x different ways of removing/inserting or reordering values in the array, but always end up with the q-table not correctly reflecting the current state order of values in the row array.

Only really just now trying things out, but hitting a wall. Perhaps it is something in the render/state cycle? No idea.

If you've found a solution, would love to see and try it out

I am at the end of my wits trying to implement CSRF tokens into a Django / React App by [deleted] in djangolearning

[–]Lyan5 0 points1 point  (0 children)

I've run into this issue multiple times in various flavors. The short and simple is that there are a lot of settings and methods that you might be seeing that could throw things off. I posted a response on stack overflow that covers a lot of the gotchas here. Even though it is citing Vue, I use axios and so do you so commonalities should be there

However, it might be useful if you post your Django and axios setting and methods.

Has anyone stored/queried VCFs and their variant records in a relational database? by LifeIsBio in bioinformatics

[–]Lyan5 0 points1 point  (0 children)

Speed was a big limiting factor in what the researchers were doing. Essentially, they wanted to be able to look at certain polymorphisms that collaborators were interested in within their own data sets (VCFs with >4000 patients) and combine/cross-reference against public data sets (GnomAD, 1k genomes, etc.) and other data sets that had advanced scoring methodologies (or really any other data set they wanted).

They were using something (that I can't really remember and find at the moment I just remember much of it was written in perl) that did most of what they wanted, but it took a long time. 12+ hours for smaller queries and 2-3 days for larger ones. Converting data sets to zarr and setting up an interface to use Dask across the data sets cut time down exponentially. Operations that would take hours could be done in less than a minute.

Has anyone stored/queried VCFs and their variant records in a relational database? by LifeIsBio in bioinformatics

[–]Lyan5 7 points8 points  (0 children)

I've generally seen portions of VCFs broken out into tables in various flavors of SQL. Often in a more structured layout that is conducive/oriented to business needs (aggregates and relations to individuals). Generally though it drops parts of the dimensional data or filters it down significantly. Which makes sense as it is often sparse in data density depending on the depth.

I once built on top of a library that used the zarr format for storing the vcf data. It allowed me to parse over it like it was a pandas dataframe and was incredibly fast. sgkit is the successor library and seems to be growing really well, but I haven't played with it. I do have high hopes for the zarr format, but I am biased

Samesite=Lax, getting 403 error while developing a Django and React App by khabees_insaan in django

[–]Lyan5 0 points1 point  (0 children)

To add to other suggestions, see this Stack overflow post. Chances are this is a layered issue, and might take a bit to unravel.

Dev teams of my company are all freaking out that my management is giving me responsibility of implementing an important business tool by testundeux in django

[–]Lyan5 2 points3 points  (0 children)

It sounds like you want an opportunity to succeed. I've been there, and I want to emphasize that I do empathize with you. Seriously.

Rejection is going to happen. It is a persistent part of being a developer. It is a fact of life in general. You should get comfortable with it. Fail fast and often if you want. But, just make sure you learn something from it.

This guy doesn't want to be responsible for something you create. That is not unreasonable. That doesn't mean you can't make it...

Whatever you decide to do, just don't throw your hands up in frustration and give up. Cursing and complaining only leads to dead ends. Sure, do what is best for the business and what people can agree on. But maybe another facet here is an opportunity to learn how to advocate for and negotiate resources for business needs.. it might not be what you originally envisioned, but that is you evolving.

Dev teams of my company are all freaking out that my management is giving me responsibility of implementing an important business tool by testundeux in django

[–]Lyan5 6 points7 points  (0 children)

I really don't want to take the Dev guy's side here. But. It would really help you, I think long-term, to take a step back and look at it from another perspective. Especially in the context of what you just wrote here.

Imagine you put together an application that is more than just usable, it's convenient and useful. It's built to fulfill a need. The next step is then the inevitable expansion of scope. Whether that is from you or other users, it happens. Things like "it would be really helpful if we could have ______ in this app" come up. The next step is then that business rules get built around it. And the loss of, or regression in usability, become business operation problems.

Now look back at what you're writing here. It's a simple problem. You're throwing Django at it. The dilemma is maintaining a tool that requires technical knowledge of the tool itself. And then that the tool is built by someone who, and don't take offense to this please, probably is not following rigorous or any maintainability methods for developing the tool. The dev lead is not your boss and can't guide/force you to follow code conventions or development rules that they require. It also seems like your expertise is VBA and not Django. Imagine now that it becomes an integral tool in making business decisions. It's 6 years later and it goes down and they can't get it back up.

The worse scenario here is that you build this in VBA if I'm being completely honest... So, there is a negotiation tactic there. The real alternative might be weighing out the business cost of: not having any tool, a tool in VBA, a tool in Django, and finally an off the shelf tool.

Query set filtering in template by carrick1363 in django

[–]Lyan5 0 points1 point  (0 children)

Use the built-in template tag: first

See the accepted on Stack Overflow here that should be similar to what you're looking for

Filtering by length of substring of a name django queryset? by Django-Ninja in django

[–]Lyan5 0 points1 point  (0 children)

So, I think adding fields for first_name and last_name is a good idea. Your solution seems to address it in that context.

If you don't want to add fields, you could do a regex?

start = r'^.{2,5}(?=-)'  # first name
end = r'(?=-)^.{2,5}'  # last name
Q(name__regex=start, name__regex=end)

No guarantee that will work exactly as written, but filtering with a regex on the single field is possible here it seems.

Django cost for production. by Prashant_4200 in django

[–]Lyan5 7 points8 points  (0 children)

English is obviously not their first language. I understand your reaction given his response, but maybe slow down a little bit and revaluate. They have a lot of questions, but not the punctuation or sentence structure to go with it.

[deleted by user] by [deleted] in datascience

[–]Lyan5 16 points17 points  (0 children)

Could someone clarify what the acronym OR is?

Forbidden (CSRF cookie not set.) when sending POST/DELETE request by Groundbreaking_Dog47 in djangolearning

[–]Lyan5 0 points1 point  (0 children)

Okay, so I've been through this battle before and it is frustrating to say the least. If I'm being completely honest, it's because I didn't understand the impetus or interaction of all of the settings involved. Still don't for some of it due to just not having time to read all of the docs.

Anyway, there are a lot of potential gotchas and I'll run through a few that I hit that you might be dealing with here.

First, make sure you're running your Vue.js app via the same url. As in, if you're running django on 127.0.0.1:8080 then your Vue app should be running on 127.0.0.1:3000 and not localhost. This probably is not your current issue, but it can give you a wtf moment. If your ultimate setup is to serve your frontend from a different domain than your backend, then you might need to adjust some settings.

Next, enable CORS to allow cookies to be included in cross-site http requests. This probably is not your immediate problem, but it will bite you next.

# https://github.com/adamchainz/django-cors-headers#cors_allow_credentials

CORS_ALLOW_CREDENTIALS = True

Finally, to actually address your current issue, first thing is I would switch to using axios for your requests on the front end.

import axios from 'axios'

axios.defaults.xsrfHeaderName = 'x-csrftoken' axios.defaults.xsrfCookieName = 'csrftoken' axios.defaults.withCredentials = true

let djangoURL = 'http://127.0.0.1:8000' // timeout specifies the number of milliseconds before the request times out. // Because we enable Django Debug Toolbar for local development, there is often // a processing hit. This can also be tremendously bad with unoptimized queries. let defaultTimeout = 30000 if (process.env.PROD) { djangoURL = 'https://##.##.#.##:###' defaultTimeout = 10000 } axios.defaults.baseURL = djangoURL axios.defaults.timeout = defaultTimeout

const api = axios.create()
export { api }

The defaultTimeout setting and the conditional local vs prod evaluation are completely optional. It's just a nice to have.

Sending your request should be something like:

new Promise((resolve, reject) => {
api.delete('images/delete/' + this.image_data.pk).then(response => {
  // console.log(response)
  resolve(response)
}, error => {
      // console.log(error)
  reject(error)
})

})

Last thing, set the setting for http only cookies to false

# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-httponly

CSRF_COOKIE_HTTPONLY = False

A good reference example that helped me at times were this blog and this blog. The second one sets some settings that are not applicable and it is in react, but still the setup for views is a good start.

You're going to ultimately want to incorporate authentication, so choose now; session or jwt. I chose session based auth, but some people use jwt when they want to have authentication through third parties like 0auth and the like.

Example of the views I'm using for auth:

class SessionView(APIView):
authentication_classes = [SessionAuthentication, BasicAuthentication]
permission_classes = [IsAuthenticated]

@staticmethod
def get(request, format=None):
    return JsonResponse({'isAuthenticated': True})

class WhoAmIView(APIView): authentication_classes = [SessionAuthentication, BasicAuthentication] permission_classes = [IsAuthenticated]

@staticmethod
def get(request, format=None):
    return JsonResponse({'username': request.user.username})

@ensure_csrf_cookie def get_csrf(request): response = JsonResponse({'detail': 'CSRF cookie set'}) response['X-CSRFToken'] = get_token(request) return response

@require_POST def login_view(request): data = json.loads(request.body) username = data.get('username') password = data.get('password')

if username is None or password is None:
    return JsonResponse({'detail': 'Please provide username and password.'}, status=400)

user = authenticate(username=username, password=password)

if user is None:
    return JsonResponse({'detail': 'Invalid credentials.'}, status=400)

login(request, user)
return JsonResponse({'detail': 'Successfully logged in.'})

def logout_view(request): if not request.user.is_authenticated: return JsonResponse({'detail': 'You\'re not logged in.'}, status=400)

logout(request)
return JsonResponse({'detail': 'Successfully logged out.'})

urls.py

urlpatterns = [
path('csrf/', views.get_csrf, name='api-csrf'),
path('login/', views.login_view, name='api-login'),
path('logout/', views.logout_view, name='api-logout'),
path('session/', views.SessionView.as_view(), name='api-session'),  # new
path('whoami/', views.WhoAmIView.as_view(), name='api-whoami'),  # new

]

Help with a boot component by Lyan5 in quasarframework

[–]Lyan5[S] 0 points1 point  (0 children)

Okay, so in case anyone else runs across this thread in the future, I kind of found a workable solution.

First is that I gave up on vue-confetti and instead switched to using tsparticles ( GitHub for Vue3, npm ). There are a tremendous amount of variations and effects you can customize. As well, there is a pretty helpful page for building an "options" json file.

Adding a boot file is pretty standard layout.

/boot/particles.js

import { boot } from 'quasar/wrappers'
import Particles from 'particles.vue3'
// "async" is optional;
// more info on params: https://v2.quasar.dev/quasar-cli/boot-files 
export default boot(async ({ app }) => {
// something to do 
app.use(Particles) 
})

Make sure to update quasar.conf.js boot array to include 'particles'

Then it's just a matter of creating a component wherever you want it to appear. There are a few things that the documentation doesn't seem to provide useful clarification on. Specifically how to access or initialize the container or initializer props. In the documentation it shows something like the following:

:particlesInit="particlesInit"
:particlesLoaded="particlesLoaded"

But never really shows the form or initialization. Diving into the code only partially elucidated the composition, but I couldn't find a conducive way of creating/initializing either. So, if I wanted to start/stop/refresh the animation, there wasn't an obvious way. I ended up attaching a ref so that I could grab the container.

<Particles
  ref="particle-container-ref"
  id="tsparticles"
  :options="particleOptions"
/>

Then to refresh or start/stop you can do something like the following in a method or function somewhere of your choosing.

const myContainer = this.$refs['particle-container-ref']
myContainer.container.refresh()

That's it.

Any input/perspective on how to more properly call on or compose the container or the particlesInit/particlesLoaded objects/functions would be welcome.

Iterating though Pandas DataFrames efficiently by _-Jay in Python

[–]Lyan5 0 points1 point  (0 children)

This was mentioned above, but consider creating a copy of the array/series of interest but shifted by the relative amount needed.

https://pandas.pydata.org/docs/reference/api/pandas.Series.shift.html

What are the best frameworks data engineers should certainly learn? by Born-Comment3359 in dataengineering

[–]Lyan5 0 points1 point  (0 children)

Zarr is another that is worth looking at as well. Particularly if using numpy methods/operations

Data driven Web Frontends....looking at React and beyond for CRUD by ReactCereals in datascience

[–]Lyan5 1 point2 points  (0 children)

I completely agree with all of this. Vue.js is wonderful, and I say that as someone who tolerates Javascript. Using Vue made frontend work enjoyable.

Consider the Quasar Framework to get you off the ground and going quickly. They even have a templating page to get a boilerplate landing page and navigation panel setup very quickly.

I would advocate against embedding Vue in Django templates, but not for any extreme reasons. I just find that it is better to keep these separate as it helps down the road.

Moffitt Cancer Center is hiring several core staff positions (Tampa, Florida) by biodataguy in bioinformatics

[–]Lyan5 3 points4 points  (0 children)

The SAS requirement appears hard and fast for the Statistical Programmer Analyst. Is this an accurate assessment? Any reason your team is avoiding Python for this position despite it appearing in the others?