StackOverflow.com

VN:F [1.9.22_1171]
Rating: 9.4/10 (10 votes cast)

Random snippets of all sorts of code, mixed with a selection of help and advice.

Weird interaction with Python PIL image.save quality parameter

12 August 2022 @ 9:00 pm

This is just a part of the project I'm currently working on. I am trying to convert picture into text, then from text back to the picture without any loss or extra size. First, I open the picture, read the pixels, and write them down. Pictures are size NxN. from PIL import Image import sys import zlib def rgb_to_hex(rgb): return '%02x%02x%02x' % rgb N = im.width im = Image.open(r"path\\pic.png") px = im.load() read_pixels = "" for i in range(N): for j in range(N): read_pixels += rgb_to_hex(px[j, i,]) Then, transform the string into bytes. data = bytes.fromhex(read_pixels) img = Image.frombytes("RGB", (N,N), data) img.save("path\\new.png",quality = 92) According to the Pillow official documentation they are saying that quality goes from 0 -

Unit root test on lagged variables

12 August 2022 @ 9:00 pm

guys! I'm using this sintaxe but when I use the last part ("modelo = ...") it shows the following: "Error in merge.zoo(difetanol, detanol, mes2, mes3, mes4, mes5, mes6, mes7, : all(sapply(args, function(x) is.zoo(x) || !is.plain(x) || (is.plain(x) && .... is not TRUE" ethidra = (tsrelatorio[,"etanol"]) ethidra length(ethidra) acuavhp = (tsrelatorio[,"avhp"]) acuavhp length(acuavhp)``` matr <- matrix(0, nr = 12, nc = 12) matr[row(matr) == col(matr)] <- 1 matr Djt <- rbind(matr,matr,matr,matr); Djt dim(Djt) names(Djt) dimnames(Djt) = list(c(),c("M1", "M2", "M3", "M4","M5","M6","M7","M8","M9","M10","M11","M12")) Djt dim(Djt)``` teste=data.frame(Djt) attach(teste) mes2= teste[1:47,2] mes2 length(mes2) mes3= teste[1:47,3] mes3 length(mes3) mes4= teste[1:47,

Scheduling Multiple Cron Jobs for a REST API connector in Fivetran

12 August 2022 @ 9:00 pm

We use a Fivetran connector that pulls our data every five minutes. We do not need the data pulled that frequently during non working hours. The connector we have does not allow for customization, but a REST API was suggested if paired with a cron job. Is it possible to set up a schedule like this? Monday 4:00am to 11:55pm, run every five minutes. 12:00am to 4:00am, run on the hour Tuesday 4:00am to 11:55pm, run every five minutes. 12:00am to 4:00am, run on the hour Wednesday 4:00am to 11:55pm, run every five minutes. 12:00am to 4:00am, run on the hour Thursday 4:00am to 11:55pm, run every five minutes. 12:00am to 4:00am, run on the hour Friday 4:00am to 11:55pm, run every five minutes. 12:00am to 4:00am, run on the hour Saturday run every hour Sunday run every hour Thank you.

How do I maintain the state of my request data between GET and POST requests in one flask route?

12 August 2022 @ 8:59 pm

I have some user response data that is posted from the front end to my /post end route and then one piece of that data (user id) is posted to another flask route /stats. That is working properly, when I print to the console I am getting the correct user_id I want to get. The problem is that in this /stats end route I am performing a query of the database to gather some important stats and then I am grabbing those on the front end through a get request. The problem is that when I perform the get request, the state of my request_data is lost and throws the error: line 67, in stats user = request_data['user'] TypeError: 'NoneType' object is not subscriptable the app works perfectly until I perform the get request. here is my code for the flask route /stats: @app.route('/stats', methods=['GET', 'POST']) def stats(): request_data = request.get_json() user = request_data['user'] def get_total_percent_correct(user_id): correct =

Python globals() - how do variables get added/ updated to this global dictionary in the below example?

12 August 2022 @ 8:59 pm

In this line, how does name get populated to the globals dictionary? Method gets invoked here

Tailwind classes are not working after installed

12 August 2022 @ 8:59 pm

I'd like to begin with stating that this question's title is similar to this question but I tried the answers there but they won't work. I first tried Tailwind from their official CLI guide, but that wouldn't work so I followed this youtube tutorial for the set-up but Tailwind still won't work. In the previously mentioned question someone noted that you need to be very specific in the path from tailwind.cofig.js to your HTML, but I did this. My tailwind.config.js: module.exports = { content: ['./*.html'], theme: { extend: {}, }, plugins: [], } And here is a screenshot of my folder:

calling a function with a sublist inside another function

12 August 2022 @ 8:59 pm

I'm trying to run this code: list1 = [4,5,6,7,8] def func1(x,list1): return x*list1 def func2(x,list1): return func1(x,list[1:]) func2(3,list1) I got the following error message: TypeError Traceback (most recent call last) <ipython-input-25-5e4e46f738ca> in <module>() 7 return func1(x,list[1:]) 8 ----> 9 func2(3,list1) <ipython-input-25-5e4e46f738ca> in func2(x, list1) 5 6 def func2(x,list1): ----> 7 return func1(x,list[1:]) 8 9 func2(3,list1) TypeError: 'type' object is not subscriptable I want to know if it's possible to call a function inside another function but calling a sublist of the list called in the main function

system design vs system architecture

12 August 2022 @ 8:59 pm

I have seen many examples of system designs. For example, design a URL shortener or Twitter in Grokking the System Design Interview. But then, what is system architecture? Are those two the same things?

How can i backup mssql to microsoft azure sql?

12 August 2022 @ 8:58 pm

I have MSSQL sql backup and I want to use this backup of this file with .bak extension on microsoft azure server, how can I do it?

Stock Investment Experiment in OTree - no template

12 August 2022 @ 8:58 pm

I am working on an experiment in Otree/ Python and kindly ask for your help. I am a newbie in programming and Otree. In my experiment, participants either design their own portfolio (or get one assigned to them - whichever is easiest in the beginning) and observe changes to their portfolio in later rounds. After every round and change, they have the opportunity to buy/sell positions. On Otree's website, I found experiments titled "Stock game" or "Investment game" (links: https://www.otreehub.com/projects/otree-stock-trade/ and https://www.otreehub.com/projects/investment-game/), however, there was no template that I could adapt to my own experiment. I would be most grateful for guidance on a template with a stock investment game similar to mine. I am also very t

jsfiddle.net

VN:F [1.9.22_1171]
Rating: 9.0/10 (2 votes cast)

A playground for web developers, use it as an online editor for snippets built from HTML, CSS and JavaScript. The code can then be shared with others, embedded on a blog, etc.

bitbucket.org

VN:F [1.9.22_1171]
Rating: 8.8/10 (4 votes cast)

The alternative to Github, private and open git repositories.

More reliable merge checks

20 July 2022 @ 4:23 pm

We are introducing a change to the pull request merge checks that will make them more reliable. Specifically, we will no… The post More reliable merge checks appeared first on Bitbucket.

Default Pull Request Tasks

19 July 2022 @ 6:07 pm

There are multiple ways to create a task on a pull request. They can be added from the sidebar, top-level pull… The post Default Pull Request Tasks appeared first on Bitbucket.

Bitbucket Cloud migration Q&A

7 July 2022 @ 8:23 am

Learn more about Bitbucket Cloud and start planning your migration. The post Bitbucket Cloud migration Q&A appeared first on Bitbucket.

Announcing support for Docker BuildKit in Bitbucket Pipelines

5 July 2022 @ 12:36 am

We are happy to announce that one of the top voted features for Bitbucket Pipelines, Docker BuildKit is now available. You… The post Announcing support for Docker BuildKit in Bitbucket Pipelines appeared first on Bitbucket.

Improving performance on complex diffs

19 May 2022 @ 9:39 pm

Bitbucket Cloud is making changes to pull request diff functionality that will improve diff performance, particularly on complex diffs. We are… The post Improving performance on complex diffs appeared first on Bitbucket.

Announcing support for Windows runners in Bitbucket Pipelines

17 May 2022 @ 5:00 pm

We are happy to announce that Bitbucket Pipelines now supports self-hosted runners on Windows. You can create a self-hosted runner and… The post Announcing support for Windows runners in Bitbucket Pipelines appeared first on Bitbucket.

Changes to deleting snippet comments

10 May 2022 @ 4:55 pm

We're changing who can delete snippet comments. Our goal is to give users more control over content attached to their snippets.… The post Changes to deleting snippet comments appeared first on Bitbucket.

A modern approach to change management with Bitbucket Cloud and Jira Service Management

18 April 2022 @ 4:00 pm

One of my teammates calls change management the "eat your vegetables of ITSM." Just like eating veggies is important for getting… The post A modern approach to change management with Bitbucket Cloud and Jira Service Management appeared first on Bitbucket.

Announcing the beta for macOS Runners in Bitbucket Pipelines

4 April 2022 @ 11:02 pm

We are happy to announce that Bitbucket Pipelines now supports macOS self-hosted runners. This is currently in beta. You can now… The post Announcing the beta for macOS Runners in Bitbucket Pipelines appeared first on Bitbucket.

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

31 March 2022 @ 10:47 pm

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is… The post Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022 appeared first on Bitbucket.

SmashingMagazine.com

VN:F [1.9.22_1171]
Rating: 8.5/10 (6 votes cast)

Digital media magazine for designers and developers
Web design plus tips and tricks.