instruction stringlengths 71 95.1k |
|---|
I'm currently getting data from an API every 15 seconds. This data contains a json with 100-2000 new items every time. Now i don't need all the items that are in there but still quite some of them and i want to store these items in a database. I will probably delete items that are added longer then 5-7 days.
Now i just... |
I wrote a little module for making quick CLIs in Python and I wanted to get your thoughts on areas of improvement (as well as to see what can break it).
One of the issues I had from the start was with looping and multi-threading, I wound up just adding a 1 second delay to make sure I've enough time to do some basic pro... |
So I have been wondering about the standard way of structuring your files/code when it comes to reading data from the driver file.
So what I now have is a buffer that's supposed to store the data that we, as user, requested from the driver file. Since we can't pass arrays to the function (decays to a pointer), what I d... |
This application is the front end to a very basic database application. The front end assumes that the back end database would have fields as per the html form.
some concerns on db2form.js I have are:
some very specific html doc references in the javascript - eg document.forms.searchform.elements.search.innerText = "... |
I'm drawing a background into kivy, and then wrap and place a transparent image on top of it. Each second I move the location of the transparent a little bit.
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty
from kivy.uix.image import Image
from kivy.clock import C... |
This is my first question on this website and I hope it goes well.
I have created a Kotlin factory pattern and I am using it very frequently. the code I use it consists of functions inside a class. This is not a static class however, it does not mutate any field inside this class.
When I look at this code, I can tell ... |
I'm implementing some basic data structures in Python. How does my LinkedList look like?
My experience in testing is quite low and I would really appreciate a review.
Implementation:
class LinkedList:
class Node:
def __init__(self, value, next_node=None):
self.value = value
self.nex... |
I have to find a method (using backtracking) to list all possible combinations, in lexicographical order,of k numbers out of the interval [1,n].. duplicates are not allowed. i.e: input: 5 3output:1 2 31 2 41 2 5 1 3 41 3 51 4 5 2 3 42 3 52 4 53 4 5
I know using namespace std; is bad practice, but that's the way we've b... |
So, I happen to know a bit about front-end development, and I'll make a seminar at the university about it where I share that knowledge with my fellow students. A few years ago, I've made a PacMan in JavaScript and SVG. Now I've refactored it in an attempt to make code easier to understand, because I think it may be in... |
I am trying to implement a motion detection algorithm using state of the art on an esp32camera.
This board has 512kB RAM and I don't want to use too much CPU.
So I wanted to get a review on what I implemented if there is piece of code which could be optimized.
I tried to comment as much as possible and put link on exi... |
I have m x n grid. m >= 1 ; n >= 1
I have item in the top-left corner and need to reach bottom-right corner of the grid.
Item can only move either down or right.
I need to find possible unique paths to do it.
I made two solutions for the problem: recursion (slower than the below one) and the one below.
The problem is t... |
The class WalkingData storages a "date" and a "walked distance". The class also read the stored data.
public class WalkingData
{
public DateTime Date { get; set; }
public int WalkedDistance { get; set; }
private string _filePath = @"c:\Data\Json.txt";
//Read Data from Json File
... |
I'm making an AI agent (blue entity) that pursues a target (green entity) while avoiding an obstacle (red entity).
The code works as it should most of the times, but will fail if all the entities are aligned in either the X or Y axis or any direction diagonally. I suspect this is due to dividing by zero.
I fixed the pr... |
I would like to know if this code of the database for my Pokemon clone game follows general practices in syntax and general readability. I feel like I could cut down on my comment usage, and place comments in other places. All variables here are static, and as far as I've read static variables must be Uppercase. As for... |
1) This code's task is to create graphs of various algebraic, logarithmic and trigonometric functions and relations using Python's matplotlib.plyplot module. Turning code into a graph is a process. First, I secure a list of xs using set_width(width). Then I iterate through the list by substituting each x into the funct... |
So in this problem I am given an NxN matrix, in which each value of the matrix represents an altitude. I need to find the best path from the top-left corner to the bottom-right one, my moves being limited to down and right.
Also, the path needs to be chosen in such way that the differences in altitude are the smallest... |
In the main() function of the following code, I wrote a very naive command parsing. Is there any more efficient way?
This program is aim to deal with ADD, SUB, MUL, DIV these four arithmetic operations for integers. The input would be in form like: ADD 1 1, MUL 12 90. And also there would be a special input character... |
I am a newbie to rust and wanted to know if this code is following idiomatic rust or can be improved.
use std::cmp::Ordering;
pub fn find(array: &[i32], key: i32) -> Option<usize> {
if array.is_empty(){
return None;
}
let mut start = 0;
let mut end = array.len() - 1;
let mut middle;
... |
The Problem
I am currently writing a script that converts images into numerical array representation and then calculates "in-between" images based on linear interpolation between the start and end array.
My code does exactly what I want but goes over many nested loops which strikes me as something that will lead to ver... |
Suppose we have variables, num and let, that may be (possibly nested) list, tuple, or None. The combination is to be such that:
Neither == None -> num + let
num == None -> let
let == None -> num
Both == None -> None
Return type is list or None
1-5 should hold for any number of variables, including one, and >2
Be a one... |
Introduction
For the purpose of learning how to work with pictures in Java, I created an ASCII-Art Generator. The program can do two things:
Convert pictures into ASCII-Art
Convert text into ASCII-Art
I splitted the task into several steps:
Convert text to image
Read image and its height and width
Saving data of ea... |
I have implemented a min heap and looking for a simpler solution.
Is there anyone for suggesting a simpler solution for this?
Thanks.
import com.sun.org.apache.xalan.internal.xsltc.dom.MultiValuedNodeHeapIterator;
import java.util.Arrays;
public class MinHeap {
private int capacity = 10;
private int size = 0... |
I'm fairly new to Javascript and am writing a piece of code to create a filtering system for a portfolio grid (a grid of work examples that filter by category when a button is selected).
While the code works just fine, I feel like the way I'm writing it is overly clunky. Can someone please let me know if there's a way ... |
How would I go about making this script much faster? Essentially it reads from a file and the slowest part is populating the words. In the words file there are over 100k words and I was looking for a way to speed it up since this script is going to be used to populate the database with over 200 languages.
import os, d... |
I recently created this Income Tax calculator based off your filing status (Single, or Married Filing Jointly) and which tax bracket you fall into for the 2020 tax year, taking into account the Standard deduction. I know the code is a little robust, but the math checks out as compared to several other tax calculators. ... |
I gave an attempt at reinventing the wheel and recreate list methods using my own Array Class to broaden my understanding about lists. I would like advice regarding efficiency, and in implementing negative indexes, since my code only works for positive ones.
class Array:
def __init__(self, List=[]):
self.a... |
So I'm writing a hobby programming language interpreter in C. It works but has serious performance problems.
According to gprof, the following function takes 30% of the running time (after excluding the time spent in the profiler itself). 75% of the 30% is spent only inside the function itself, not including its called... |
While using a JOptionPane, recently, it struck me as odd that the Java Library doesn't seem to have any standard icons for the dialogs. So I decided to create an enum for them. Instead of mapping the icons directly to the enum, I used a map.
import javax.swing.*;
import java.util.Map;
public enum MessageIcons {
... |
I've implemented a singly linked list in Java and would like a code review as I am still learning
and this is a different method I've found to do this. The logic is still fuzzy as well to me and
writing it out took ages and I'm sure I may have messed up a bit but still have time to mess
around with this.
Instruc... |
I have a headers dictionary value being passed to one of my constructors and based on that dictionary value I am extracting individual headers I need and setting all my variables.
public Tester(IDictionary<string, StringValues> headers)
{
int textId = 0;
if (headers == null)
{
ProcId = Generat... |
Is it good practice to give a value to a variable, then change its value immediately after, like that for example?
def get_user_id_from_username(username):
user_id = db.execute("SELECT id FROM user WHERE username = ?", (username, ))
for row in user_id:
user_id = row[0]
return user_id
Basically,... |
I'm learning Rust and looking for better/cleaner ways to list all file names that do not start with filter, given a pathname as a parameter.
fn list_files(&self, pathname: &PathBuf, filter: &str) -> Result<Vec<PathBuf>, Error> {
fs::read_dir(pathname).map(|read_dir| {
read_dir
.f... |
I have this code:
def apply_all (fs, x):
def reducer (acc, f):
(seq, x) = acc
next = f (x)
print((seq + [next], next))
return (seq + [next], next)
return [x] + reduce(reducer, fs, ([], x)) [0]
print(apply_all(f_list,4))
It works perfectly to accomplish... |
(See the next iteration.)
Introduction
Suppose Evil Lottery Inc is interested in not paying millions of dollars back to players. They gather the drawn lottery rows first, after which they mine rows that does not appear in the dataset.
The Evil Lottery Inc's approach is this: it first builds a radix tree of the drawn l... |
I hope you can help with improving my code. I am defining a function which draws out elements of a certain mass, one by one, from a distribution constrained by the function imf(), until I have used up all the mass given to the function. The code takes a very long time between 1 minute to 45 minutes depending on the inp... |
I have written a simple Tic Tac Toe game using some ASCII art. Is there anything I can do to improve upon the logic and structure of the program?
"""A basic command line tic tac toe game"""
import os
import sys
gameBoard = [['' for j in range(3)] for i in range(3)]
displayBoard = [[' ' for j in range(46)] for... |
I am remaking a very obscure old game called Rival Realms.
The full source is here if you're interested.
I come from a Java background so C++ is still fairly new to me.
I recently performed a refactor to move all the textures and sprites into one class. The intention is that I will create a Resources instance when th... |
Idea
Consider the following snippet:
import inspect
from pathlib import Path
def path_relative_to_caller_file(*pathparts: str) -> Path:
"""Provides a new path as a combination of the caller's directory and a subpath.
When creating a Path like Path("resources", "log.txt"), the containing Python script
has... |
I wrote a program which visualizes a doubly linked list in C++/SFML. The code is working as intended, and does exactly what I want. Could you give me some feedback / criticism on some do's and or don'ts?
This Node class represent a node within the doubly linked list. It inherits both from sf::RectangleShape and sf::Ver... |
As I have recently been selected to participate in my country's final preselection to the IOI -- this took me aback -- I have decided to get a bit more serious about competetitive programming.
The Rock-Paper-Scissors Tournament is an old question form the Waterloo Programming Contest 2005-09-17, available on kattis.
Wh... |
I feel like my code has way too much for what it is, this is my first project and would love to learn some tips in making code more efficient for the future, any other tips for my code here would be greatly appreciated.
#include <iostream>
#include <string>
#include <stdlib.h>
#include <time.h>
using namespace std;
in... |
I am rather new to python and am porting my R functions into python. I have written the functions below and the primary function is called thetaMax. That function minimizes a likelihood function or optionally minimizes a posterior distribution, depending on the option selected by method. The function works exactly as i... |
I am learning Vue after working for some time with Angular and I'd like to hear experienced programmers concerning the implementation of my Progressive Bar service (in Vue it's called Plugin).
The idea behind it is to have a solid service which is responsible for the progress bar indicator.
I've got there a component w... |
I am a recent graduate in computer programming and failed so far to get an internship or a job in the business so I am trying my best to learn from online source.
I am trying to implement a dir-like command on Windows, going through a folder and list all files and folder.
What I've learned is to avoid using namespace ... |
I'm a beginner python programmer..I recently started reading a python book called: "Python Crash Course, 2nd Edition: A Hands-On, Project-Based Introduction to Programming"...And I found an interesting challenge...The challenge is to copy the elements of the list to another list and change the elements to make them be... |
Is my approach to insertion Sort in Python efficient?
What can be improved efficiency wise?
def insertion_sort(array):
sorted_array = []
for elem in array:
insertion_index = len(sorted_array) #insert at end of list by default
for elem_sorted in sorted_array:
if elem_sorted > elem:... |
Here i have javascript code where is 'animals' object and 'people' array of objects. User selects the data from select box and accordingly table fills with selected data(which is array of objects) and when user wants to reset everything to the state before selected data, user just clicks 'backtozero' button.
the code i... |
I am working on this project where I like to PreserveIds once inserted into the database. The id are auto incrementing and I return them once the data in inserted. I like to know if there is a better way using inheritance vs using a for each loop and checking if the value is 0?
class Program
{
static void ... |
I know I never have to reinvent the wheel, but I did because I need speed performance. Also, I need these features:
introspection or metaprogramming
actuate like API backend
private variables interpolation
embedded Perl code inside template like text template
avoid in the minimal no core modules
work with eval in env... |
**
Write the beginnings of a class for a Table implemented with a Binary Search Tree. (done)
Then create a Table class with only one data member for the root. (done)
Provide the following methods:
a constructor that produces an empty table (done)
a method to insert a given item, (done)
Create a separate class for a N... |
So, I am trying to make people interested in my compiler project (in the early stages of development) by making some simple and clear programs in my programming language. Here is my implementation of the Pascal's Triangle in it. Do you think it's clear? If so, what do you think might be unclear to an average programmer... |
I am pretty new to DDD, so any help/ideas will be appreciated. I will explain my initial design and problem below.
The user can ask the system to generate products proposal, proposal is basically something, which has some ownership and set of products, which can be renewed if system evolves, new products should be auto... |
I decided to make my own light DI container.
I know about Zenject, etc. I wanted a very light analog.
I'm concerned about a few things:
1) is it correct to use struct instead of class for reference in this context?
2) every time you access _player.Reference, there is a check for null (in the UnityEngine.After the destr... |
Assume $ is not the browser. Now have to implement $, it will take a string, which is a query, it will use the querySelector to select the element. (Reference: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector)
$('text')
Now implement jquery like functions addClass and removeClass. (Reference: ht... |
I had an assignment to create a circumference calculator in Java which I've already submitted. I would like feedback on my code.
The program works as intended, but I am not sure whether it's spaghetti code or not after realizing that I only called one method in main which calls all of the other methods. Here is the cod... |
I am trying to create a robust, generic way to parse a bar delimited usr files, now I can read the file in and separate it by | then index with integers.
However, this always feels very rigid in its design and I want to try to avoid it.
What I would like is a way to map any bar delimited file to JSON or at least a Pyth... |
I want to create a list of the different response headers I get when querying an URL, I succeeded in doing this this way:
import requests
l= []
for _ in(5):
a = requests.get("https://google.com", allow_redirects=True).headers['Origin']
if a not in l:
l.append(a)
This is readable but I feel like this i... |
I have the following code, that defines:
A polynomial struct with some useful functions.
The newton Raphson algorithm for polynomials.
and calculates sqrt(2).
What can I improve?
There are some things I am unsure about myself:
Is size_t a good datatype for my purposes? I needed to be very careful when writing the lo... |
Below is a React useEffect hook I used in my application, basically what it does is:
data is an array for objects such as {round:number, date:dateString}.
When the application starts running, data will be an empty array, whenever round gets updated, the useEffect() will be called:
if the data array is empty, we update... |
So, a long time ago, I've made a program that prints all the permutations of digits of a number in AEC. Now I have refactored it a bit, and I would be interested in what you think about it.
;Advanced example: implementing the permutation algorithm.
AsmStart
debug=0
macro pushIntegerToTheSystemStack x
{
... |
My code has mutiple checks for if staments which I think could be optimized into few lines if I take id into varibable. To give some background I want to disable a button based on length of characters in input box. But the thing is out of two buttons only one will be rendered at a time.
Below is my working version of ... |
I'm looking for input on how to improve a powershell script I wrote.
Im especially looking for suggestions, that I might be able to apply to future projects as well. Like (anti-)patterns I'm not aware of and such.
General things like "too many small functions" vs "use more functions" or "better collect all info in a ce... |
I have an almost-JSON document in a file named versions.json. It looks like this:
{
"package_a": {
"sha_darwin": "6d94f041d06670977b2e5604b827f7e8bd46a1d200d14545ba75c17314ec12ad",
"sha_linux": "6daa0fae252dc32e0af6ad89119555b277456349c55dfc9f276ee83718c6a9e2",
"url": "https://github.com/someone/package_... |
Below is a method used in my application that reassigns a vehicle to a depot. Is there a better way of handling these conditionals than the boolean statements I have in place?
Some things to note are Vehicle and Depot are classes and Depot has an ArrayList of Vehicles Inside it. depoNo is set earlier in the program in... |
I wrote a NavigationBar component in React, using hooks, react-bootstrap, react-i18next and css. Now the component works as I expect it, but the code seems ugly. (I'm new with hooks)
Features:
It's transparent at the beginning but if we scroll down it will be "dark" (from react-bootstrap)
If there's no enough space to... |
I wanted to compare radix_sort to quick_sort for values limited to 0..127 so I implemented this :
void bin_radix_sort(int *a, const size_t size, int digits) {
assert(digits % 2 == 0);
int *b = malloc(size * sizeof(int));
for (int exp = 0; exp < digits; exp++) {
// Count elements
size_t co... |
Hi I've written a web scraper for tracking gold price. Can someone please review my code and suggest improvements. It gets the price of gold from a specific url then stores the price against date in a db file further makes a plot then uploads image to firebase. Further this image and gold price is sent to your whats-ap... |
The piston2d-graphics crate provides a trait, Graphics, which allows easy access to some graphics primitives. This would be a nice, easy-to-use API, if it weren't such a pain to end up with something that implements Graphics; for a time, there wasn't even a consistent set of crates that let you get one (that rendered a... |
I have made the solution for this question it is based on backtracking. Can anyone suggest me how to make it work faster, I haven't practiced backtracking that much, although my solution seems to work. Please check it out
class Test {
static int ans = Integer.MAX_VALUE;
static void f(char[] a, String s, in... |
I am replicating this blog post in Python.
The blog post shows that even if you know future stock market bottoms, only buying stocks when the stock market is below future stock market bottoms provides only a modest edge of 22%.
The code below replicates the blog post's result (approximately, I use different data).
Howe... |
I'm writing integration for a project, but our framework doesn't provide any ability to inject dependencies, so I've written tests with a unit testing framework (GTest) and used a mock (GMock) in an odd way simply to leverage its behaviour obverving functions. I have a python script to run it, it all works, but, is th... |
Let's say we train a model with more than 1 million words. In order to find the most similar words we need to calculate the distance between the embedding of the test word and embeddings of all the 1 million words words, and then find the nearest words. It seems that Gensim calculate the results very fast. Although whe... |
I'm happy to present my first Android project, which collects market index data (three Asian indices) and fires a notificaiton every Wednesday, Thursday and Friday at 7:30 AM displaying the data.
I've applied to Computer Science in Lund, Sweden. I am looking to improve my Java through Android development (which I've fo... |
Based on this code found on github and the advice given to me on stackoverflow I made this code for the xor in c.
#include <stdio.h>
#include <string.h>
void encryptDecrypt(char *input, char *output)
{
char key[3] = {'K', 'E', 'Y'};
for (int i = 0; i < strlen(input); ++i)
... |
Background
I worked at a community center where everyday one of my coworkers would spend 20ish minutes trying to organize the day's schedule. The facility had three rooms: The Great Hall, The Club House, and The Sub Cellar. Each of these rooms were open at different times in the day, and when he was organizing the sche... |
Robot Name
Manage robot factory settings.
When robots come off the factory floor, they have no name.
The first time you boot them up, a random name is generated in the format
of two uppercase letters followed by three digits, such as RX837 or BC811.
Every once in a while we need to reset a robot to its factory setti... |
I have a dictionary that I need to iterate efficiently. I already know about the keys beforehand which I need to extract from values dictionary object.
What's the best way to do that? I have around 20 entries in dictionary object as of now.
Below is how I am doing it but wanted to see if we can optimize it by just gett... |
I have a page with multiple menus. Once I hit a certain window width, I use CSS and jQuery to turn them into accordions. I also check the screen size when resizing so the accordions don't stay hidden if the user resizes the window. Since I have two window widths I need to adjust for, I am using two click events to open... |
A stab at Project Euler Problem 11: Largest product in a grid
"""
In the 20×20 grid below, four numbers along a diagonal line
have been marked in red.
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03... |
I'm very new to programming and I don't feel confident about the readability of this program.
This program gets the text you copied then extracts phone numbers and email addresses in the text. Once those are extracted, you can paste them anywhere(Eg: notepad).
Are there any ways that I can improve this code? Any sugge... |
I have an Outlook Module that contains the VBA Code below. The VBA code opens an Excel Add-In called TMAPAddIn.xlam, which then displays a User Form. I exported the Module and gave it to other colleagues so that they can import it to their Outlook, this allowed them to make a custom button on their Outlook Quick Access... |
Introduction
Basic Idea
The Sardinas-Patterson algorithm determines (in polynomial time), whether a code is uniquely decodeable or not.
Example
Code 1 is not uniquely decodeable, because "100" could be "baa" or "bc".
Now let's apply the algorithm to code 2:
It will be checked, whether a codeword is another codeword's... |
const propsSelector = (props:any) => {
let newProps: object = {}
Object.keys(props).forEach((prop) => {
if (typeof props[prop] !== 'undefined') {
Object.assign(newProps, {
[prop]: props[prop]
})
}
})
return newProps
}
const selectedProps:any = propsSelector(pr... |
Another code for exercism, It is to convert Vec of u32 from one base to another base. Please help to make it more idiomatic, Also if this type of question is welcomed here or not.
#[derive(Debug, PartialEq)]
pub enum Error {
InvalidInputBase,
InvalidOutputBase,
InvalidDigit(u32),
}
pub fn convert(number: ... |
Suppose I have a list with N sorted dates and M non-overlapping sorted periods with start date, end date (inclusive), and a tax rate for example. I have to make an efficient algorithm retrieve all tax rates for all dates. If there is not period including this date it should raise an error.
Given the brute-force approac... |
I wasn't able to find a standardized source for a working example of Merge Sort.
Each learning site had a slightly different take on the algorithm implementation, disregarding the bottom-top implementation.
I wrote my own code for this but unsure if it's the most efficient or if efficiency can be improved?
Any other sy... |
I am in the process of converting this code predictor.py located here to tensorflow v2 with Python 3.7. I want to do this conversion part by part. So from the refence repo, I've been going through this example.
For this block:
def resBlock(x, num_outputs, kernel_size = 4, stride=1, activation_fn=tf.nn.relu, normalizer... |
(See the previous (initial) iteration.)
This time, I have substantially reduced the usage of the final and this keywords. Also, I have dropped java.util.(SortedMap/TreeMap) and substituted it with a simple hash table/array, which dropped the running time of the mining phase by half:
Seed = 1588247737638
Data generated ... |
I designed the code and it works quite well for images of lower res. However my program takes a lot of time and ram to display higher res images (occupies 2GB RAM for 4k images and takes 20 minutes). This program currently only processes files in .png format.
#------------------------------------
import matplotlib.pypl... |
I'm trying to wrap my head around JavaScript Functional Programming.
I have created a very basic script that creates a new elements and appends them to the DOM.
If anyone could share any feedback, or great resources on the subject, that would be awesome.
Where does this style of programming lend itself best? Web Develo... |
I need to understand if the way I am modelling data in a Django application is correct. The idea is of a news site that has sources, authors and articles.
I want:
Source to have many Article
Author to have many Article
Article to have many Author
Does the below model do this correctly? I am worried there is a loop ... |
I am a beginner in programming. And I am learning python as my first language. I went on to do some challenges on HackerRank and stumbled upon this problem. The problem goes like this:
There is an array of \$\ n \$ integers. There are also \$\ 2 \$
disjoint sets , \$\ A \$ and \$\ B \$ each containing \$\ m \$
int... |
I am trying to work around the problem Pass-through for IAsyncEnumerable. The best I have so far is to return IAsyncEnumerable<IAsyncEnumerable<T>> instead of IAsyncEnumerable<T>, then to flatten it. I'm not thrilled about it, so I'm asking here for suggestions.
The underlying goal is to allow one to get portions of o... |
I have written a Java program that converts an integer to String digit by digit and concatenate them together using the + operator without touching the Stock Java API library.
I like to have feedback on my code. Where do I need to improve. If I need to deduct something. So please criticize me. Thank you.
import java.ut... |
The permutation matrix is represented as a list of positive integers, plus zero. The number indicates the position of the 1 in that row, e.g. a number zero would mean that the 1 is in the right-most position².
My first attempt is as follows, together with a printing function to help assess the result.
It seems too con... |
A tkinter widget for reading/editing .ini files
Dynamically generates a form based on the contents of the passed .ini file.
Why make this?
I made this as a backend for a larger project; I wanted my user to be able to manage persisted settings in an .ini file without having to find the file or use an external editor.
I... |
I have a questions as to the proper way to structure the code below.
This snippet of code is used within a socket class which is intended to be a high performance socket. Many data handlers subscribe to this sockets OnData event to handle different types of data. Ideally, I'm trying to kick the data handlers off in a t... |
Description
Simply take a JSON file as input and convert the data in it into a CSV file. I won't describe the functionality in too much detail since I have reasonable docstrings for that. As you can see, my solution is not memory efficient since I'm reading all the file into memory.
I'd like to improve the performance ... |
I am working on a custom bot UI with Microsoft Bot Framework. I found a template to create a floating widget with Materialize, however, it was for the "embed" version of webchat UI. My version uses some Divs to add additional elements (header, transcript button). These elements were in conflict with the Materialize CSS... |
I wrote 2 different implementations to find gcd of 2 big numbers. The simple one using Euclid's algorithm always beat the Binary algorithm in term of speed. Is my implementation of Binary algorithm bad?
a = 5**100 - 1
b = 5**120 - 1
def gcd_euclid_recursive(a, b):
if b == 0: return a
return gcd_euclid_recursiv... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.