Posts

Showing posts from November, 2022

Knex select always returns pending promise [duplicate]

I am writing a simple function to query my database with Knex in Node. Everything I've tried returns Promise { <pending> } Function to query the DB: const queryTable = async () => { const data = await knex .select("*") .from(TABLE_NAME) return data; }; I've tried calling the function in it's own async/await wrapper, and I've tried the .then() callback after... No luck. Any leads appreciated!

body entered function not working in godot

i am trying to make a node named "gear" change textures when it moves through a certain area but nothing happens, i tried making it print something when it collides with something, but nothing happens, this problem has been bugging me for days and i cant find any reason why, its hitbox is working but the function refuses to acknowledge it the captialisation is alright i literally copied and pasted it to no avail, i looked at somone elses code other than the name of that node the function is exactly the same, what is going on, link to project

pd.read_html(url) - awkward table design

Image
Table headings through the table are being converted into single column headings. url = "https://www.environment.nsw.gov.au/topics/animals-and-plants/threatened-species/programs-legislation-and-framework/nsw-koala-strategy/local-government-resources-for-koala-conservation/north-coast-koala-management-area#:~:text=The%20North%20Coast%20Koala%20Management,Valley%2C%20Clarence%20Valley%20and%20Taree." dfs = pd.read_html(url) df = dfs[0] df.head() Be great if I could have the High preferred use as a column that assigns to the correct species. Tried reset_index() this did not work. I'm lost for searching can't find anything similar. Response to @Master Oogway and thanks @DYZ for the edits. The amendment suggested removes the error, but does not interact with the second table. Take White Box, Eucalyptus albens. Occurs in second table and not first. If I export dftable: If I write htmltable to .txt when using find_all: I have never done this before and appreciate th...

Which data type is suitable for a date like 31-12-2014 in Snowflake?

Image
I have lots of data we want to store in Snowflake cloud but we could save the data into the snowflake due to date like 31-12-2014 which is given in an excel CSV file: ] I am trying: "Shipment date" varchar(16777216), "Shipment year" number(4), which data type will be suitable for that purpose?

(UNITY, SHADER)Can you draw the same texture multiple times in a single pass?

I'm new to shaders, and I'm trying to make an outline of a tk2d spine object(a 2d character). I know there are other ways to obtain the outline effect, but this approach got me curious. (Please don't suggest another way to draw outlines, respectfully, because that is not my question.) So basically how I'm trying to get the outline effect is by getting the vertexes of my object, input a color, and draw it 8 directions(top, down, left, right, 4 diagonal directions) by setting offsets to each direction. I got this working, and it looks fine, but my shader code doesn't, because I have a total of 9 passes, 8 of which do the exact same thing(draw the same texture), with the only difference being the offset direction, and the last pass drawing the tk2d spine character. I don't like that I have 8 almost-exactly repeated codes, it seems to be a waste because there is an area where the same calculation is done 8 times, and I suppose performance would be affected as well...

ErrorReply: NOAUTH Authentication required when using createCluster with redis in nodejs

I am trying to use elasticache redis cluster and using a password with it. When I try to write or read I am seeing. I am running out of ideas of things to try. I have tried to use password in the root node on the object and putting directly. I've tried other libraries and am seeing the same issues. [ErrorReply: NOAUTH Authentication required.] So here is the example of my code sorry for the mess. const redis = require('redis'); const { createCluster, } = redis; const password = 'abc123'; function getRedisClient() { const rootNodes = [{ url: `rediss://:${password}@${host}:6379`, rejectUnauthorized: true, }]; return createCluster({ rootNodes, defaults: { socket: { connectTimeout: 5000, }, }, }); } const cluster = getRedisClient(); cluster.on('error', (err) => console.log('Redis Cluster Error', err)); const run = async () => { try { ...

How to move specific cells in an excel file to a new column with openpyxl in python

I am trying to moving some specific cells to a designated location. As shown in the image, would like to move data in cells D3 to E2, D5 to E4,..... so on so for. Is it doable with openpyxl? Any suggestions would be greatly appreciate it!! Click to see the image Here is what I got so far. It worked per say. wb=xl.load_workbook(datafile) ws=wb['Sheet1'] #insert a new column #5 ws.insert_cols(idx=5,amount=1) wb.save(datafile) mr=ws.max_row #move cells for i in range (1,mr+1): v=ws.cell(row = i+1,column=4) ws.cell(row=i,column =5).value=v.value wb.save(datafile) wb.close How do I skip a row? I only wanted to copy values in every other row over.

How to print all columns and prevent an insertion of one when using lapply()?

I have a file with 28 columns and numerous rows >10000. I am splitting this file by the second column called gene_id, so that there are numerous outputs each file with a distinct gene_id. variant_id gene_id tss_distance ma_samples ma_count maf pval_nominal slope slope_se hg38_chr hg38_pos ref_allele alt_allele hg19_chr hg19_pos ID new_MAF CHROM POS REF ALT A1 OBS_CT BETA SE P SD Variance chr1_17726150_G_A_b38 ENSG00000272426.1 821374 68 78 0.0644628 0.764314 -0.0320846 0.106958 chr1 17726150 G A chr1 18052645 rs260514:18052645:G:A 0.058155 1 18052645 G A G 1597 0.0147047 0.0656528 0.822804 2.62364886486368 6.88353336610048 chr1_17729225_G_A_b38 ENSG00000117118.9 675055 205 226 0.186777 0.770706 0.00898192 0.0308023 chr1 17729225 G A chr1 18055720 rs11580304:18055720:G:A 0.194694 1 18055720 G A A 1597 0.00515331 0.022282 0.817129 0.890444032956592 0.792890575828 chr1_17729225_G_A_b38 ENSG00000117122.13 748390 205 226 0.186777 0.0373499 0.0553745 0.0265315 chr1 17729225 G A chr1 1805...

Different Headers but Same Footer for Each Section

How would I create a document that has two sections where the headers are different but the footers are the same? For example, I would have the first section be labeled "Header 1" and the second section be labeled "Header 2" but the footer for both of those sections would be the same, in this case, "Author: John Apples." I am working in MS Excel since I want to import some data from a sheet. NOTE: I am very new to VBA I tried using the "DifferentHeaderFirstPageHeaderFooter = True" but that applies to both the header and footer, not just the header. Also, I don't believe I am creating separate sections so it would be nice to have that feature implemented since I plan to add more sections that would have different headers. Any help would be greatly appreciated. My Code 'Create a new Doc Set myDocument = WordApp.Documents.Add WordApp.Visible = True WordApp.Activate 'Set Landscape Orientation myDocument.PageSetup.Orientation = 1 ...

All imports in WebStorm shown as unused at TypeScript backend project

https://i.stack.imgur.com/J0yZw.png This is how it looks for all files with .ts . And in .tsx files it also doesn't work. Other projects in WebStorm work correct but they're written in .js and .jsx only. Also I've tried reinstall WebStorm twice and set all to defaults, that doesn't help at all.

PHP Constructors and extending parent classes

I'm coming from Java, and wanting to use the constructor of a child class the way that it works in Java, but it appears that it doesn't work like that in PHP. The constructor of the child object can't seem to overwrite the instance variable values constructed in the parent object. Here, the parent object is being used just for the common methods between multiple child classes that will extend it. The parent class will never be called on its own. When I instantiate a new TestPackage, I just get the initialized error values from the parent class. What gives? <?php interface Package{ public function getCode(); public function decode($packageCode); public function getSetName(); public function getSetNameLang(); public function getSubsetType(); public function getSubsetTypeLang(); public function setSubsetType($typeCode); public function getPackageOptionsArray(); public function getChoicesArray(); public function getOptionStatus($inde...

React State not Updating in DataGrid MUI

for some reason a column in my Material-UI DataGruid wont update upon state change? Code for state var: const [brandMap, setBrandMap] = useState(new Map()); fetchBrands function (which changes state) async function fetchBrands() { const accessToken = await getToken(); await fetch("http://localhost:8000/auth/brands", { method: "GET", headers: { Authorization: `Bearer ${accessToken}` } }) .then((data) => data.json()) .then(data => { setBrandMap(prevState => ({ ...prevState, ...data.data.reduce((map, obj) => (map[obj.id] = obj.name, map), {}) })) }) }; Columns list that I pass into MUI DataGrid, note the "FetchData(1)" function gets the data that the columns use. useEffect(() => { setColumns(({ columns: [ { field: 'image', headerName: '', filterable: false, renderCell: (params) => ( <img src={params.value} style=/> )}, { f...

Return value must be of type Collections array returned Doctrine / Symfony 6

I have 2 order and line entities, with onetoMany / manytoOne relationship I want to save a command with its lines, except I need to customize things, so I go through a datapersister function persist If I don't try to save my lines it goes well, but as soon as I want to save the lines I get this message: "App\Entity\DoRetourEntete::getRetALignes(): the return value must be of type Doctrine\Common\Collections\Collection, array returned Basically I'm sending it an array while it's waiting for a collection. But how to send it a collection in json? In get everything works fine, I have my line detail when I call a command. Here is my POST: { "nomCommande": "2398", "cmdALignes": [ { "ref": "maref1", "des1": "designation1", "qtt": 2 }, { "ref": "maref2", "des1": "designation2", "qtt": 2 ...

is not being positioned where I want it to go

Image
I'm trying to create a fake website for a school project. So far I've added a banner of images that cross fade. The next thing I want to add is a bar where you could go to different pages like "food," "sale," and so on. I want this bar to go beneath the image banner. When I add the tags though, they are positioned on top of my banner. Before, I had used a simple image banner, and when I added the tags they positioned themselves beneath the image like normal. But because I'm using multiple images and animations, it's behaving differently and I don't know how to fix it. Below is the effect that I want (but it's because I disabled the cross fade) The closest solution I got is changing .fadein{height:1000px} and that moves the buttons down but I'm not sure how viable that is. I've also changed the position of the buttons from relative, absolute, etc. but none give the effect that I want. Here is my code. Edit: I don't know why y...

How do you read through a file to get specific key value pairs with 1 key, and 2 values that are in a dictionary? [closed]

The first parameter is a dictionary representing data for a city and the second parameter is a data file that is open for reading. This function should modify the dictionary so that it contains the data in the file. If a city with data in the file is already in the dictionary then its data should be updated. Otherwise it should be added to the dictionary with its data. After this function is called, the dictionary should contain key/value pairs whose keys are the names of every city in the data file, and whose values are dictionaries which contain at least the population and economics_situation for those cities. I'm just trying to figure how to even start with this? Can anybody give me a clue, or a first step on an approach? We want our dict to look something like this: This is assuming if its an empty dictionary ''' {'Brampton': {'#': 1, 'population': [703, 38907, 6789, 8769, 9087, 9087]}, 'Pickering': {'#': 2, 'popula...

Pass an object from getServerSideProps to page function

In the code below when I return a class object in the function getServerSideProps through props, in the page function the variable is undefined, just like in the code below. export default function cars(obj){ return <h1>counter: {obj.counter}</h1> // obj is undefined, why?? } export async function getServerSideProps({req,res}){ class Counter{ constructor(){ this.counter = 22 } } var counter = new Counter() return { props: { obj:JSON.stringify(counter) } } } I was expecting that the page parameter obj would have the object counter and not be undefined.

Flutter_map showing a black screen

Image
I'm trying to use a map on my app, but i get a black screen instead of viewing the map. I tried adding some marker to the map which show and can be manipulated, but where there should be the map is a black background instead. My goal is to manage to show the map and navigate on it. I've already managed to show some elements on top on the map, but i cant get the map to display behind the elements. (i'm getting the same problem with or without the marker elements). import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:latlong2/latlong.dart'; import 'package:flutter_map/flutter_map.dart'; class MapScreen extends StatefulWidget { @override State<MapScreen> createState() => MapScreenState(); } class MapScreenState extends State<MapScreen> { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: Stack( children: [ ...

How to add data-id to button, Using YouTube API [duplicate]

The javascript I am using here is following YouTube's Api. https://developers.google.com/youtube/iframe_api_reference What I am trying to do in the code is add the data-id This: data-id="-Xgi_way56U" to the button. <button class="playa1 cover" type="button" data-container="play1"></button> Which would then become this: <button class="playa3 cover" type="button" data-container="play1" data-id="-Xgi_way56U"></button> Currently, I have 2 containers: Placing the data-id on the button will allow me to remove 1 container from the html. Am I right? https://jsfiddle.net/7apg90wz/ How the code works is, after clicking a button a video will appear on the screen, click the X the buttons return to the screen where you can click on the 2nd button and a video will appear on the screen. function onYouTubeIframeAPIReady() { players.add(".playa1", {}); players.add(...

Double Loops in R: Use .name_repair to specify repair?

I have this dataset in R: set.seed(123) myFun <- function(n = 5000) { a <- do.call(paste0, replicate(5, sample(LETTERS, n, TRUE), FALSE)) paste0(a, sprintf("%04d", sample(9999, n, TRUE)), sample(LETTERS, n, TRUE)) } col1 = myFun(100) col2 = myFun(100) col3 = myFun(100) col4 = myFun(100) group <- c("A","B","C","D") group = sample(group, 100, replace=TRUE) example = data.frame(col1, col2, col3, col4, group) col1 col2 col3 col4 group 1 SKZDZ9876D BTAMF8110T LIBFV6882H ZFIPL4295E A 2 NXJRX7189Y AIZGY5809C HSMIH4556D YJGJP8022H C 3 XPTZB2035P EEKXK0873A PCPNW1021S NMROS4134O A 4 LJMCM3436S KGADK2847O SRMUI5723N RDIXI7301N B 5 ADITC6567L HUOCT5660P AQCNE3753K FUMGY1428B D 6 BAEDP8491P IAGQG4816B TXXQH6337M SDACH5752D C I wrote this loop that compares different string distance metrics between all combinations of (col1,col2) and (col3,col4): method = c("osa", "l...

How to pass a string from a secondary window to the main window in WPF

I am working on a to-do list application for a project. I would like to change the value of a string in an observableCollection. I am able to change the string in the same window but I would like to change the value from a textbox in a secondary window. So what I tried to do was is change a string in the first window by using a textbox in the second window. By doing the way I have listed below it just blanks out the item I am trying to edit. I would like to take the test from the textbox in the second window and use it to modify the taskName in the first window. Below I am going to include my code for the two c# files for the windows. This is the main window but it is called DemoMainWindow: using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; us...

cloudflare python bypassing

I'm trying too bypass cloudflare is there anything that im doing wrong? It just keeps returning the error code 403 import os import requests def clear(): os.system('cls' if os.name == 'nt' else 'clear') Heads = { 'accept': '*/*', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9', 'content-type': 'application/x-www-form-urlencoded', 'origin': 'https://rblxwild.com', 'referer': 'https://rblxwild.com/', 'sec-ch-ua': '"Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24"', 'sec-ch-ua-mobile': '?0', 'sec-ch-ua-platform': "Windows", 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-origin', ...

How to change row-'value' every time i try to position a label using grid?

I am trying to create a terminal GUI using python tkinter module and I already managed to access the tk.Label from TextFrame class. class TextFrame(tk.Frame): def __init__(self, container): super().__init__() self.container = container self['bg']='black' self.pack(fill='both', expand=True) self.label = tk.Label(self) Now the problem is that, I can't change the row everytime I call show() function inside Instances class. class Instances(Window): def __init__(self): super().__init__() self.string = tk.StringVar() self.index_row = 0 self.text_frame = TextFrame(self) self.text_frame.pack() self.entry_frame = EntryFrame(self) self.entry_frame.pack(side='bottom',fill='both') def show(self, e): textvar = self.string.get() self.entry_frame.entry.delete(0, 'end') self.text_frame.label.config(text=textva...

Restricting access of some roles to some specific pages

@bp.route("/products/wishlist", methods=["GET"]) @login_required @roles_required( "ADMIN", "CUSTOMER_STORE_MANAGER" ) def product_wishlist(): return product_wishlist_page() I have role restrictions like this where each page has some role requirements, what I need to do is restricting some roles so they could have access to only some specific pages, for example when CUSTOMER_STORE_MANAGER logins into the webpage, they should only be able to view the product_wishlist I thought about defining pages for each role and check if they are trying to access to pages which they have authorization. But I wonder if there is a more convenient way to do this in Flask?

How String.fromCharCode function work for mobile key board in html input field

I want to capture the keyboard key code and convert it to characters. I am using the String.fromCharCode javascript function but it only works on a computer keyboard it is not working with a mobile keypad. Any help will be appreciated. $(".inputsmeter").keyup(function (e) { let key = e.which; let c = String.fromCharCode(key); alert(c); });

CSS How To Blur/Bleed Sides Of Image

Image
I have a large image centered like this: I want to image to bleed with a blur on the sides like this: Is this possible? Also, is there a particular term used to describe what I want? I tried adding a background image and blurring that, but then I realized that just blurs everything. I don't know what else to do.

Problems with images in react application

When using images in react, there is either a problem with typescript, or the image breaks on the site. To solve the problem, I tried: Add url-loader and file-loader to the webpack.config.js const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const BUILD_PATH = path.resolve(__dirname, './build'); const SRC_PATH = path.resolve(__dirname, './src/'); const PUBLIC_PATH = path.resolve(__dirname, './public') module.exports = { entry: SRC_PATH + '/index.tsx', output: { path: BUILD_PATH, filename: 'bundle.js', }, mode: process.env.NODE_ENV || 'development', resolve: { modules: [path.resolve(__dirname, 'src'), 'node_modules'], extensions: [ '.tsx', '.ts', '.js' ], }, devServer: { static: PUBLIC_PATH, }, module: { rules: [ { test: /\.(js|jsx)$/, exclude: /node_modules/, use: ...

Karate UI: Locating web elements on a HTML web page having multiple div tags with same ID?

My web app has a page displaying a .yaml file with key-val pairs, the yaml page has multiple(100+) tags having the same ID's for all the key-vals making it hard to locate the web element to update through the karate ui script. Example of xpaths: key1: val1 //*[@id="ember5066"]/div[2]/div[6]/div[1]/div/div/div/div[5]/div[369]/pre/span/span[3] key2: val2 //*[@id="ember5066"]/div[2]/div[6]/div[1]/div/div/div/div[5]/div[373]/pre/span/span[3] enter image description here the below locator doesn't seem to work in this scenario * string webElement = "//span[text()='abc']/following::span[text()='key1']//following-sibling::span" Using the script syntax as below to update the value script(webElement, "_.innerHTML='" + parameterized + "'") Question: How to locate and update the value of the webElement or if there is a way to do indexing in karate? Thanks in advance! EDIT: @Peter Thomas I am able t...

File path in NextJS api route not resolving

I'm trying to resolve a file path in NextJS . I understand that API routes are working a little bit differently when deployed to Vercel. In order to create a correct path to the file I assumed I had to do this: const svg = fs.readFileSync( path.join(process.cwd(), "img", "file.svg"), "utf-8", ); // ENOENT: no such file or directory But I cannot make it work. The file cannot be found under that path. How can I find the correct path for a file in NextJS api routes? I've followed the documentation of this. Next version is: 11.1.3 When logging the path, it is giving /var/task/data/project-root/img/file.svg

Returning data from firebase functions returns null

I have this code exports.battle = functions.https.onCall((data, context) => { if(context.auth){ var difficulty = randInt(2,10) / 10 var user = context.auth["uid"] var userHP var userLevel var userDmg var resultUserDmg = [] var resultUserHp = [] var monsterHP var monsterLevel var monsterDmg var resultMonsterDmg = [] var resultMonsterHp = [] var ref = db.ref(`players/${user}`); ref.child("hp").once("value", (snapshot) => { userHP = snapshot.val() monsterHP = userHP * difficulty ref.child("level").once("value", (snapshot) => { userLevel = snapshot.val() monsterLevel = userLevel * difficulty console.log("type"+typeof(userHP)) console.log("value"+userHP) ...

.NET Maui Map Pin Example

I'm not sure this is actually possible, but I can't seem to find an example so maybe not. Just trying to display location pins on the map at certain long/lat coordinates i have available. Can anyone link an example?

Shared ViewModel Not Working With Bottom Sheet Dialog Fragment, DB and UI

Image
i have a really simple vocabulary note app contains 2 fragment and 1 root activity. In HomeFragment i have a button "addVocabularyButton". When it is clicked a BottomSheetDialogFragment appears and user gives 3 inputs and with a viewmodel it is saved in DB. My problem is when i save the input to the DB it works fine but i cannot see in HomeFragment that word instantaneously. I have to re-run the app to see in home fragment. I am using Navigation library and recycler view in home fragment. Github link : https://github.com/ugursnr/MyVocabularyNotebook Home Fragment class HomeFragment : Fragment() { private var _binding : FragmentHomeBinding? = null private val binding get() = _binding!! private var vocabularyAdapter = VocabulariesHomeAdapter() private lateinit var sharedViewModel: AddVocabularySharedViewModel override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { _bind...

Vuejs select options

trying to make select option: DVD, Books, Furniture. When selecting DVD it changes the element content to: DVD selection content . Code on select option and the form that should change: `<div class="typeswitcher"> <div> <h4 class="typeHeading">Type Switcher</h4> </div> <select name="typeSwitcher" id="typeSwitcher" v-model="itemType"> <option value="DVD" id="DVD" >DVD</option> <option value="dimensions" id="Furniture">Furniture</option> <option value="weight" id="Book">Books</option> </select> </div> <form method="POST"> <div class="switcher-form"> ...

How can I add 2d text to three.js (already tried sprites, fontLoader, etc)?

I'm to add 2d text as labels next to an object, as shown in the image. I've tried sprites (which, as far as I understand, don't work in newer versions of three.js), fontLoader, and a couple of rendering mechanisms--but I have not had any success, unfortunately. I see that I can use CSS3D, but I'm not sure what to grab from the sample codes. If someone could point me in the right direction, I would appreciate it. Image showing what I'm trying to achieve If anyone has any advice, I would greatly appreciate it. The following are some key parts of my code: <script src="https://unpkg.com/three@0.132.2/build/three.min.js"></script> <script src="https://unpkg.com/three@0.132.2/examples/js/loaders/GLTFLoader.js"></script> <script src="https://unpkg.com/three@0.132.2/examples/js/loaders/DRACOLoader.js"></script> <script src="https://unpkg.com/three@0.132.2/examples/js/controls/Or...

How to center the axes in Plotly on a 3d scatter plot in R?

Image
I have a 3d scatter plot that I created with Plotly in R - is there anyway to move the axes to the middle? My plot right now looks similar to this plot that I made real quick in R: But I would like to remove the grid background, the axis ticks, and move the axes to the middle of the plot to make it look similar to this: My main problem is moving the axes to the middle while maintaining the x, y, and z labels on them. I have used traces to simulate the central axes, but then I have the issue of no axis labels when I remove the background grid and axes. What is the best way to go about this? The code to recreate the first plot is below as well: coords = list("x"=c(), "y"=c(), "z"=c()) for(phi in seq(0, 2*pi, 0.2)) { for(theta in seq(0, pi, 0.2)) { x = (8 * sin(theta) * cos(phi)) y = (8 * sin(theta) * sin(phi)) z = (8 * cos(theta)) coords$x = append(coords$x, x) coords$y = append(coords$y, y) coords$z = append(coords$z, z) } ...

Where does BioPython store information related to various chemical molecules?

If we reconstruct a protein from a PDB file, is it enough to have a PDB file, or do we need more info external to the PDB? Take, for example, the BioPython framework. If any info is needed external to the PDB files, where does this framework store them? Can I open and check to see those files?

cross check if two df have different values and print any if there

i have two df and i wanna check for the id if the value differs in both df if so i need to print those. example: df1 = |id |check_column1| |1|abc| |1|bcd| |2|xyz| |2|mno| |2|mmm| df2 = |id |check_column2| |1|bcd| |1|abc| |2|xyz| |2|mno| |2|kkk| here the output should be just |2|mmm|kkk| but i am getting whole table as output since index are different This is what i did output = pd.merge(df1,df2, on= ['id'], how='inner') event4 = output[output.apply(lambda x: x['check_column1'] != x['check_column2'], axis=1)]

Determining the splitting ratio when augmenting image data

I have an image dataset that is quite imbalanced, with one class having 2873 images and another having only 115. The rest of the classes have ~250 images each. For reducing the imbalance, I decided to split the dataset into Train-Valid-Test components, with the major class having less proportion of images in the training set compared to the minor classes. Then I'll be augmenting the data in the training set. I intend to perform an 80-10-10 split on the dataset. Which outcome shall be considered as an 80-10-10 split? Splitting the dataset in the proportion 80-10-10, and THEN augmenting the training images (which would eventually result in >80% proportion for the training set after augmentation). Splitting the dataset in a proportion such that it eventually results in an 80-10-10 split AFTER augmentation. Also, is it acceptable to have an 85-7.5-7.5 split, provided it reduces imbalance in the dataset?

gettext/get_text while using beautifulsoup python

Image
import requests from bs4 import BeautifulSoup price_limit = 15 URL = "https://a.co/d/5iUKt2H" header = { "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "Accept-Encoding" : "gzip, deflate", "Accept-Language": "en-US,en;q=0.9,pl-PL;q=0.8,pl;q=0.7", "Connection": "keep-alive", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/107.0.0.0 Safari/537.36" } response = requests.get(url=URL, headers=header) soup = BeautifulSoup(response.text, 'html.parser') price = float(soup.find("span", class_=["a-offscreen"]).get_text().split("$")[1]) name = " ".join(soup.find(id="productTitle").getText().split()) ...

How much do most C compilers remove constant expressions? [closed]

At least with macros, C compilers are expected to remove at least most constant math operations. For example, func((4 + 40) * 2) is expected to become func(88) during compilation. I don't know what happens with something like this: if (1) first(); else second(); (which is the same as) const int mybool = 1; if (mybool) first(); else second(); Does this just become first(); on most compilers? What about: while(0){ dostuff(); } Does this get removed? If the answer isn't just "They all stay", where is a list of the things C compilers are expected to find and remove (aside from optimization)?

Importing RxJs in small Javascript project

Image
I'm trying to import RxJs in a small javascript project using "import" in my script file but I keep on getting the following error: Subscriber.js:10 Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'rxjs') This is what my script file looks like: <!DOCTYPE html> <html lang="en-US"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="./styles/style.css"> <title>Load RxJs using import</title> </head> <body> <h1>Importing RxJs Lib</h1> <div> <h1 id="info">'loading ...'</h1> </div> <!-- <script src="https://unpkg.com/rxjs@7.5.7/dist/bundles/rxjs.umd.js"></script> --> <script src="./js/script.js"...

EXC_BREAKPOINT on NSFetchedResultsController.performFetch() because of -[CFString isNSString__]: message sent to deallocated instance

I'm running into a repeatable crash when calling -performFetch on my NSFetchedResultsController in what SEEMS like a data-related crash: NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:sectionnamekeypath cacheName:cacheName]; aFetchedResultsController.delegate = self; NSError *error = nil; if (NO == [aFetchedResultsController performFetch:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); } It crashes at the performFetch() call. I turned on Zombie checking and it printed: *** -[CFString isNSString__]: message sent to deallocated instance 0x12c6071d0 I've checked all of the strings in my function and I can't find a string that has...

Phaser 3 Tetris clone, Game freezes when trying to stack blocks

In the Tetris clone I'm making, I'm only working with single blocks right now and I have been trying to stack blocks in a few rows. Here is the code for the blocks if (this.active == false){ this.cube = Math.floor((Math.random()* 7)); this.testblock = this.physics.add.sprite(608, 32, this.blocks[this.cube]); this.testblock.body.immovable = true; this.testblock.body.allowGravity = false; //this.testblock.body.setGravityY(-100); this.physics.add.collider(this.walls, this.testblock); this.physics.add.collider(this.p1, this.testblock); this.activeBlock = this.testblock; this.active = true; } this.activeBlock.y = this.activeBlock.y + 0.5; if(Phaser.Input.Keyboard.JustDown(this.keyE)){ console.log(this.activeBlock.y); } if(Phaser.Input.Keyboard.JustDown(this.keyA) && this.activeBlock.x != 352) { this.activeBlock.x = this.activeBlock.x - 64; } if(Phaser.Input.Keyboard.JustDown(this.keyD) && this.activeBlock.x != 928) { ...