instruction stringlengths 71 95.1k |
|---|
This Bash program parses day, month, year and month and year from arguments:
#!/usr/bin/env bash
for arg
do
day= month= year=
case $arg in
*/*/*|*-*-*)
read -r year month day <<< "$(date '+%Y %m %d' -d "$arg")"
;;
????/??|????/?)
IFS='/' read -r -a arr <<< "$arg"
month... |
I'm fairly new to Python and am exploring how to fix functions and make code 'more effective and readable'. As a first step, I would want to try to make shorter snippets of code here - for example by dividing it into more functions.
I would also appreciate further improvements regarding possible errors I might stumble ... |
Well I was solving Problem 3 from Project Euler, but I just found out that my code is really bad, it would take so much time to finish processing the code and I honestly do not know how to optimize it.
Problem Statement
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600... |
I want to print the below pattern
*
* *
* * *
* * * *
* * * * *
My logic written
for row in range(1,6):
for col in range(1,6):
if row is col:
print(row * '* ')
Can someone review the code and suggest any improvements needed
The code which i have written is it a right approach ?
|
I have different format of address in an array, those format looks like this
lastname/firstname/_/country/postalCode/_/regionId/city/addressFirst/addressSecond/_/phone
lastname => a part of the address (noted AddressPart)
/ => a separation
_ => a line break
the above entire would do
lastname firstname
country postalCod... |
Heart rate or blink generator. Clocked from the system frequency, but calculated from a constant of 120MHz. Has a prescaler with values 2, 3, 5, 6, for even heart beat / blinking. The IS_DEBUG parameter is required for debugging for easy control over the rhythm, this parameter reduces 120MHz to 120Hz. IS_BLINK selects ... |
Develop a program to maintain a list of homework assignments. When an assignment is assigned, add it to the list, and when it is completed, remove it. You should keep track of the due date. Your program should provide the following services:
Add a new assignment.
Remove an assignment.
Provide a list of the assignments... |
Everything currently works exactly as requested by the instructor, I've included as much possible commented documentation as I can think of to make it easier for people to see what the required criteria is for the project!
Let me know what you guys think, I would really appreciated it!
The program is disjointed as it i... |
This is a working solution to today's Advent of Code puzzle, written in Haskell. However, I feel like this solution is not optimal.
module BinaryDiagnostic (parseInput, part1, part2) where
import Control.Monad (liftM2)
import Data.List (group, maximumBy, sort, transpose)
import Data.Ord (comparing)
bin2dec :: Str... |
Given a list of integers a 2D graph has to be plotted taking 1st, 3rd, 5th, ... numbers as upward slope and 2nd, 4th, ... numbers as downward slope.
I have used a Python list to do it. Is there any further optimization possible with Python?
Sample input:
3, 1, 2, 3, 6, 2, 3, 6, 2, 3, 6, 3, 2, 3, 6, 2, 3, 4, 3, 2, 5, 4... |
My favourite 3rd party library isn't getting maintained so now I need to make my own library for interfacing with Riot Games' API. Epic.
Problem is that there are rules, such as:
100 requests in 2 minutes
20 requests in 1 second
So I made an API request scheduler.
import asyncio
import time
from collections import de... |
I'm learning regex for c++, and tried to make a simple function. It is very small but I'm satisfied, because this is the first time I managed to pass function as argument. This is a replace function. Please give me tips on how to improve:
std::string Replace(std::string text, std::regex reg, std::function<std::string(s... |
I am trying to solve the following exercise:
"Consider a function removePrimes() be a C function that takes as input an array of integers, removes all numbers that are prime, and returns the compacted version of the array. Create an array of 200 integers, with random values between 7 and 13, and call removePrimes()... |
I implemented this carousel component in react:
import React from "react";
import { AiOutlineArrowLeft, AiOutlineArrowRight } from "react-icons/ai";
import { useResizeDetector } from "react-resize-detector";
let arrowStyle = {
background: "white",
border: "1px solid lightgray",
borderRadius: "20%",
cursor: "po... |
I think I programmed a bottom-up merge sort, but I'm a little sceptical that it will work under any data set. By now, I've tested it with many random arrays of massive lengths, and it seems to work; the only thing making me doubt my function is that whenever I look online for a non-recursive one, all of the algorithms ... |
I have implemented the bulls and cows game in C++.
The code:
#include <cstdio>
#include <cstdlib>
#include <ctime>
struct DigitMatches {
int matches_in_right_positions;
int matches_in_wrong_positions;
};
void CountNumberDigits(int (&counts)[10], int n) {
while (n > 0) {
counts[n % 10]++;
... |
I'm learning rust and doing an exercise where to parse a particular SGML document.
Each line in a document can be either an opening tag "" , a closing tag "" or a scalar: " Val".
I'm using a regex with named capture groups to detect and extract, and would like to return an enum afterwards.
I came up with the following ... |
In one of my homework projects, I have to parse a matrix definition into a matrix data structure in C. The elements of the matrix will be given in a list of double. I need a simple tokenizer and parser for the task naturally, but I have not much experience in parsing. I implemented the tokenizer and parser. The tokeniz... |
My code is working but it is extremely long. So, I guess there is a way to make it shorter/more efficient.
The problem solved here is from Advent of Code 2021, Day 3, Part 1: https://adventofcode.com/2021/day/3
binary_list = open("data.txt").read().split("\n")
counter_1st_bit_0 = 0
counter_1st_bit_1 = 0
counter_2nd_b... |
I have seen a lot of Repository pattern implementations with Unit of Work. The simplest way of implementing this I came across is using hard-coded repos (such as this one), while the way recommended by Microsoft improves on this with a generic repo interface, but the repos themselves are still stored in the instance.
I... |
In my app users can create and soft-delete payment gateways something like Paypal. Users of a website can connect to the gateway and make payments.
I've written the logic in a transaction also locking a matching record (on website field) which was soft-deleted by the user because of race-condition. Read code for a bett... |
Context: My question comes from needing to iterate different np.arange arrays. The main motivation is to calculate all the possible combinations between the arrays, let's say a, b, c, x, y, z where the last 3 (x, y, z) can be arrays OR floats.
The reason behind is that every combination can be evaluated then in equatio... |
Preface
Following my first POC version:
2d Grid - Iterating by Rows / Cells
I have gained much more understanding, and present
A new version
A new version is ready, with templates and an attempt at using reusable classes, Iterable and Iterator.
It works as shown from the unit tests, but it does not support iterating ov... |
Some notes that I thought would be worth mentioning up front:
Advent of Code randomizes the input for each user, with the input format being 1,000 12-digit binary numbers delimited by newlines.
I've verified that my solution works by submitting the generated answer on the website.
Here is the important part of the pr... |
I am not familiar with iterators. I am confused with the traits approach and the traditional one. I don't know which one I should use in 2021.
I wrote a minimal example that can iterate through prime numbers. My approach is naive, but the goal is to use an iterator that may skip values.
#include <vector>
#include <iost... |
I am new to groovy/jenkins. I am using active choices parameter (projects) and active choices reactive parameter (testcases).
The code below will loop thru $testcases and execute shell scripts based on what is selected
//jenkins file
pipeline {
agent any
stages {
stage('Running test cases') {
... |
I have the following response coming from a rest call and performing some logic based on what is returned.
This is what I want.
If the overall status code is NOT 200 OR
If within the list of SimpleResponse, none of the SimpleResponse objects has a 200 httpCode, throw an error.
Too much going on there, having an option... |
Hi I am new to python and I have written a simple calculator, I would like to ask if the code is written well or if anyone has any tips on how to write it better.
def addidtion():
if choose == 1:
print("Your result:", firstNum + secondNum)
def subtraction():
if choose == 2:
print("Your result:"... |
Here is my C code for finding the most occurring word in a sentence:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ht.h"
#define MAX_WORD_LEN 1024
/*
* Caller must call free on returned string
* */
char* find_most_occurring_word(const char* sentence) {
if (!sentence)
return NU... |
On recent comments based fixed modules for FPGAs for generating a pseudo-random bit sequence are presented. The first module generates a bit sequence. The third module speeds up the generation by transferring the bus to, for example, a multiplexer which is controlled by a faster device. Hence this bus is serialized int... |
Animate circle using Javascript and HTML5 Canvas. The circle will be drawn at the center of the canvas. The initial radius will be 0 and will keep on increasing till 100 and then decrease till 0 and this cycle will keep repeating.
var cnvs = document.createElement("CANVAS");
cnvs.width = (3 * window.innerWidth)/4;
c... |
I am currently switching for R to Python so please be patient with me. Is the following a good way to count the number of rows given column names and values?
import pandas as pd
df = pd.DataFrame([["1", "2"], ["2", "4"], ["1", "4"]], columns=['A', 'B'])
cn1 = "A"
cn2 = "B"
cv1 = "1"
cv2 = "2"
no_rows = len(df[(df[cn1... |
This is a new version of the todo(1) utility I published some time ago.
Now I use julian days rather than time_t to hold time; and the topological sorting is necessary to compute task urgency.
Most of the information is in code comments and the manual.
Manual:
TODO(1) General Commands Manual ... |
I retrieve data from an Excel file located on sharepoint.com using Microsoft.Graph like this:
var workbookRange = await graphServiceClient
.Sites[SiteId]
.Drive
.Items[ExcelFileId]
.Workbook
.Worksheets[WorksheetIdId]
.Range("B2:C500")
... |
I am working on a script that recursively searches a directory to find files which matches a regex 5 or more times.
Using the script I can search for files which look like
https://github.com/nicolargo/glances/issues/1087
https://askubuntu.com/questions/758696/cannot-login-into-locked-ubuntu-14-04-session-unity
https://... |
I have a dataclass of a single class object 'AStock' as such:
@dataclass
class AStock:
code_: Union[str, int]
force_update_: bool = False
ticker_: str = field(init=False)
symbol_: str = field(init=False)
name_: str = field(init=False)
sector_: str = field(init=False)
subsector_: str = f... |
I am creating a social network and part of the features allows people to upload a profile pic. I want to know how secure my code is. From start to finish.
<form action="upload_profile_pic.php" method="POST" enctype="multipart/form-data">
</form>
include 'includes/header.php';
if ($_SERVER['REQUEST_METHOD'] != 'POST... |
public class Referenceable<T> {
private T obj;
private Referenceable(T t) { obj = t; }
public static <U> Referenceable<U> ref(U u){
return new Referenceable<U>(u);
}
public T dereference() {
return obj;
}
public T dereference(T newT) { // Should be used for reassi... |
Just realized I have never implemented Radix Sort (spurred about watching a YouTube video about it). So I thought I would give it a go.
This is Radix Sort, using a counting implementation. For numbers that are N bytes in length, we use an N pass counting approach. Starting with the least significant byte we do a counti... |
I have been using reduce() method to group by Open and Closes statuses (Status_111, Status_222, etc) which then creates an array of which Ids (item.Id) it is associated with.
Code is working and with an expected result, however, I feel like code could have been written better because as you can see I have been using to... |
I made a user-defined function union in VBA, such that:
it could take variable parameters
each parameter is a one-column range like A1, A2:A10; we don't need to consider passing constant values to parameters
we could consider, within one input range, there are no duplicates; but it is very possible to have duplicates ... |
Im currently writing my own cached shortened urls where I at the start of application read the database that has all the stored url:uuid from the database into a global dict value.
When a person enters a url. It checks if its already in the dict. If the url exists in the dict, then we re-use the uuid (instead of creati... |
This function str_join() is an updated version of my earlier function strcat_new() — found here: strcat_new() function, not present in the Standard C library.
The older version strcat_new() had a bug that is fixed in this version of str_join().
Syntax: char *str_join(const char *delim, long num_args, ...);
str_join.c
... |
I'm currently in the process of defining some framework, one of the first things that I thought I could start with was defining some repository pattern/layer.
I generally wanted some input on it, because I still feel that there's room to make the code more concise than what it currently is, to be perfectly honest.
Any... |
This is my Rust implementation of the rabbit searching algorithm I found yesterday in this video. The problem statement is as follows.
There are 100 holes in a line. A rabbit is in one of the holes. You need to catch the rabbit. However, you can only look at one hole at a time. If the rabbit is in the hole that you lo... |
A Sobol sequence, a series of low-discrepancy quasi-random numbers in range [0,1], can be generated by first initializing a vector of direction numbers:
Dim V(31) As ULong
For i = 1 To 31
V(i-1) = 2 ^ (32 - i)
Next
and then by fetching each number by continually looping through the enumeration below:
For Each lnumbe... |
I'm attempting to look at a portion of a cookie's value, and if it contains 'en_us', do one thing, and if it contains 'es_us', do another thing instead.
I've written up code that pulls the cookie, returns the cookie value, and then looks to see if the cookie value includes 'en_us'. But I feel like this code can be shor... |
I have this problem where I've to print a number pyramid by taking input from the user.
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5
I've written the following code and then output is correct. However, I was wondering if there are any other optimized way to print this pyramid, since mine incl... |
Follow up to original question:
This is Radix Sort, using a counting implementation. For numbers that are N bytes in length, we use an N pass counting approach. Starting with the least significant byte we do a counting sort of all the values. We then repeat the counting sort using each consecutively higher byte in the ... |
I wrote this code, it actually works, and I'm going to use this strategy in an active project that's due in January.
I don't know web components yet -- the best I can personally utilize is <template> and DocumentFragment. But, I don't think I need the latter.
My goal was to use modules with HTML templates that I can p... |
I'm working on a web socket client wrapper around ClientWebSocket and this is kinda my first public library project, which is why I'm asking this question here. I was inspired by this web socket client wrapper, because it uses Rx .NET instead of regular .NET events and I also wanted to give System.IO.Pipelines a try.
T... |
I am currently working on a JavaFXML Jeopardy game. I realized that I am rewriting a lot of code and am curious of ways to better the code so that it is easier to read and more concise.
I tried making question objects to store in an array, but it seemed as though I was still rewriting a lot of the same code.
Below is a... |
Trying to create a simple image processing library in pure C++. Here is the first part, duplicating 8-bit BMP images (taken from Udemy in hybrid c/c++ but I modified it a bit). Any comments are welcome.
Image.hpp
#pragma once
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
class Image
{
public:
Image... |
I've started learning Rust a few days ago. This is the Pig Latin exercise from the Rust Book. The code works as expected. I have commented the logic of the program in the code.
My handling of Strings is very hacky, as far as I know. To be honest, I mostly fiddled with it looking at error messages until the compiler was... |
I have been trying to understand the difference between two approaches and have always got confused so thought of asking this question here.
Consider following code,
public string? MyMethod(object parameter)
{
return parameter.Something(); // access something on object assuming return type is same
}
Now there're t... |
This is my first time trying to add clean error handling and loading notification for async requests in my project. It looks kind of bulky to me, but maybe that's because I'm inexperienced? This is what I have at the top of all my index-like components. I also thought maybe it was a good target for a custom hook, but I... |
I have created a helper service to send files from the client application to the API over HTTP using the POST method. Source project on Blazor Server Side, .NET 6, C # 10.
Service features:
Sending files to the API.
A limited number of parallel sending processes.
Ability to freely add files to the queue without waitin... |
Annoyed at the tension between good software design principles that require well-defined delimitations between interface and implementations, and the requirements for critical code to run fast, which demands avoid placing runtime overheads in the critical path, I've come up with a solution that I haven't seen elsewhere... |
Hiii... Can you please check the code and see whether I might have done a mistake ? Beginner's eyes can be misleading quite easily. I feel like there's something wrong in this solution. I can't figure out what. so please check the solution and let me know.
keep in mind i'm native sinhala speaker.
Assume hot dogs come ... |
I'm trying to calculate perfect powers to solve this code wars challenge: https://www.codewars.com/kata/55f4e56315a375c1ed000159/haskell
The number 81 has a special property, a certain power of the sum of its digits is equal to 81 (nine squared). Eighty one (81), is the first number in having this property (not consid... |
I'm a newbie programmer and was given a task to find if the input word is a palindrome or not. Now, I've written the program to the best of my ability but would like to know how it could be improved.
Also, enlighten me if there are any errors in my program or any other way to make my program more efficient and easy to ... |
SQLite C/ADO VBA library with reflection
The SQLiteCAdo library is a VBA middleware facilitating access to SQLite databases. Its two subpackages provide alternative connectivity options: via ADODB/SQLiteODBC and directly via the C-language API. My earlier project, SQLiteDB, is the predecessor of the SQLiteADO subpackag... |
To train my skills in C++, I decided to implement the well-known "Dynamic array" data structure on my own. I realized early on that using pointers or smart pointers is wrong, as it leads to calling default constructor on reallocation. A naive approach for the push_back function would include: T* new_buf = new T[n]this ... |
Firstly consider this code:
#include <iostream>
#include <set>
using namespace std;
int main()
{
const char delim = '\n';
char inp;
int cnt = 0;
multiset<char> m1;
while (cin.get(inp) && cnt != 2)
if (inp == delim)
cnt++;
else
m1.insert(inp);
multiset<cha... |
I created a small library Python library to randomly create primitive types and collections. The primitive types are int, float, and string. The collections are tuples of 2, tuples of 3, a list, a 2d list, a set, and a dictionary. The odds are all equal in the random library. Notably, the collections take a function to... |
I'm attempting to scrape data.cdc.gov for their COVID-19 information on cases and deaths.
The problem that I'm having is that the code seems to be very inefficient. It takes an extremely long time for the code to work. For some reason the CDC's XML file doesn't work at all, and the API is incomplete. I need all of the ... |
My question is very simple.
I wrote this program for pure entertainment. It takes a numerical input and finds the length of every Collatz Sequence up to and including that number.
I want to make it faster algorithmically or mathematically (i.e. I know I could make it faster by running multiple versions parallel or by w... |
I want to use dynamically allocated data, corresponding to a 3D array in a C program. After using the data, I would like to properly deallocate the data again.
My approach is as follows:
#include <stdlib.h>
#include <stdio.h>
double ***arr3D_d( size_t dim1, size_t dim2, size_t dim3 ) {
size_t ii, jj;
double ... |
I'm playing around with a chess engine that I wanted it to know all the rules such as pawn promotion, en-passant, and castling. Currently, I'm using a basic Negamax for the AI but I plan to improve at a later stage.
I have not spent too much effort on the interface as I plan to make it compatible with XBoard / Winboard... |
Processing a set of conditions with 'Continue'
I found the following more readable, opposed to trying to parse out if/elseif. What are your thoughts about this? Is there a better way?
What The Code Does
This code is a section of a for loop that does some testing on a file on a remote system (no need to check creds). I'... |
This is a follow-up question for Two dimensional gaussian image generator in C++ and Image pixelwise operation function with multiple inputs in C++. For learning C++20 and researching purposes, I am attempting to implement a function manhattan_distance for calculating Manhattan distance between two images input. The fo... |
list1 = input("Enter words =").split()
list2 = input("Enter words =").split()
def twincheck(l):
if sorted(l[0])==sorted(l[-1]):
st=True
print(True)
else:
st=False
print("\nFalse")
if st==True:
for i in range(len(l[0])):
for j in range(len(l[-... |
I am creating a website for users to track their Magic the Gathering inventory. I have created some functionality to import a csv to easily add cards to their inventory. The functionality works as expected however when you start to get to the larger amounts of records, in the tens of thousands, it starts to struggle an... |
Hi I have spent few days reading about various architectures and decided to use MVC (Model-View-Controller).
But I had hard time applying all the theory to my node.js code. I've wrote some minimal backend code as close to MVC architecture as I could. (note: it hasn't "View" part at all, but I plan to use "ejs" framewor... |
This is a software to take backups of file(s) and folders. This can save backups in a network folder also. This software can take successful backups of huge number of file(s)/folder(s). In one test, this software successfully copied 19,466 files. This software can be used by individuals as well by companies/enterprises... |
I've written a mini max algorithm, which I would like to simplify.
I call the function like this:
board.push(move)
score = minmax(board, depth, tree)
board.pop()
And the actual function:
def minimax(board: chess.Board, depth: int, tree: MinMaxTree = None) -> int:
if finished(board) or depth == 0:
return ev... |
I am converting a double to a string with a fixed length (6 characters in this case). A minus, point or E also count. This seemed like a very simple task in the beginning, but I ran in to many issues.
The double can be a large value, a small value, positive or negative or in scientific notation. This made the function ... |
Overview
I have been writing my own graph API for Rust and one thorny problem I wished to tackle was a
parallel breadth first traversal of the graph. The API itself will have different graph
flavours, but the one I have built for these tests is an undirected variant without double
edges.
I have created a breadth first ... |
At work we are using Xamarin.iOS for our apps. We frequently have to fight it's disadvantages, namely it's memory leak issues where strong cyclic references keep objects alive and prevent them from being GC'ed just because someone somewhere forgot to set a property to null before discarding a view controller.
We previo... |
I am just looking for code improvements as I believe that it is done, and would like to see it expanded.
I mainly want code improvements to make it more efficient, but any and all constructive criticisms are enjoyed
If the snippet is broken the link to the fiddle is here:
https://jsfiddle.net/BOSS2342/q18z037w/
What my... |
stack.hpp
class Stack
{
public:
Stack(float incFactor = 1.5f);
~Stack();
template<typename T>
inline void push(T value)
{
validate(sizeof(T));
*(reinterpret_cast<T*>(top)) = value;
top += sizeof(T);
size += sizeof(T);
}
void push(char* value);
void p... |
The code is an attempted divide and conquer method of finding the maximum total reward of a game where each turn two adjacent numbers in an arbitrary list are multiplied by each other to create a reward and then those two numbers are replaced by a 0, creating a new list and another turn of the game. When the list event... |
I'm trying to calculate a time weighted average of a feature (feat) based on previous rows by date for a given class. Below is a sample output:
+------------+-------+------+---------------------+
| date | class | feat | time_weight_av_feat |
+------------+-------+------+---------------------+
| 11/11/2000 | 2... |
have the following struct with one method:
struct CaveData
{
int tunnel_radius;
int min_cave_edge_points;
int max_cave_edge_points;
int min_surface_points;
int max_surface_points;
int min_random_points;
int max_random_points;
int chunk_seem_connector_cave_range_quotient;
int chun... |
I wrote a prioritized left shuffle algorithm (the code is copied from my open source C# project Fluent Random Picker).
That means: You've got some values and each of them has a priority (a number).
The higher the priority is, the higher are the chances of the value being far on the left after the shuffle.
The algorithm... |
I am learning python and I have made a function to get text from a .nfo file, improving on this block of code:
# Book Author
_author = ["Author:", "Author.."]
logger_nfo.info('Searching Author book...')
with open(nfofile, "r+", encoding='utf-8') as file1:
fileline1 = file1.r... |
I am pretty new to Python and programming in general, since I go to a programming school I am learning a lot of things by the book, which personally it doesn't suit me and I am falling behind everyone. Currently I am trying to change that and show that I am capable of doing something with my "knowledge" of Python, curr... |
I have invented and implemented a new search engine architecture.
This search engine has been developed mainly for English Alphabet. This search engine is based on the fact that no letter in English Alphabet has more than 30,000 words starting with it. This search engine works on text/html files only.
Please review the... |
Below you can see my implementation of a simple event dispatcher. I would like to get some feedback or improvement tips regarding the design and maybe an idea how to get rid of the static_cast. Thank you very much.
Classes
Event.h
#pragma once
#include <cstdint>
enum class EventType : uint8_t {
ButtonPress,
F... |
This question is with respect to Day 1, Part 2 of the 2021 Advent Of Code challenge, which requires comparing values from a rolling window taken from integers streamed as input. This answer is correct, insofar as it emits the intended output, but I'm unclear as to the quality of the code.
(This challenge is no longer s... |
For anyone reading this old question, this module has evolved and improved a lot since then. It has been fully rewritten in C# and uploaded to the PowerShell Gallery! If you would like to try it out:
Install-Module PSTree -Scope CurrentUser
And, if you want to check out the source code: PSTree GitHub. This project is ... |
Edit: the project was submitted, and I got a good grade! :D
I am finishing up a project for my computer science class. The project is a space invaders clone that uses the JavaFX library to provide graphics. The program itself is complete and functional, but I wanted to make sure that the code itself is readable and pro... |
LeetCode problem 239. Sliding Window Maximum
You are given an array of integers nums,
there is a sliding window of size k which is
moving from the very left of the array to the very right.
You can only see the k numbers in the window.
Each time the sliding window moves right by one position.
Return the max sliding win... |
This is a text based adventure game, where you need to fight against 2 enemy in every round. The damage dealt and potion heal is a random number.
How can I improve?
Game class:
package textbasedadventuregame;
import java.util.Scanner;
public class Game {
public static void main(String[] args) {
String[] ... |
I have been trying to figure out what is the best performance wise and also best practice to get data from a dict using Python. I currently have a data that looks like this:
data = {
"cart": {
"id": 123456,
"currency": "GBP",
"name": None,
"rows": [
{
"id"... |
I have the following code:
def start_threads(self):
thread_pool = []
for obj in self._objs_list:
thread = threading.Thread(target=self._do_task, args=(obj,))
thread_pool.append(thread)
thread.start()
for thread in thread_pool:
thread.join()
self._do_final_task()
_do_tas... |
Description
I am trying to implement a robust, multi-threaded producer-consumer model with a single producer in the main thread and several consumers in other threads.
The generator thread loops over data, recognizes through some condition which sort of data it is dealing with, and proceeds to delegate the sample to th... |
I am reading data out of some large (~2GB each) binary files; these have a well defined structure:
- Header (info about the next chunk of data)
- Chunk of data (any type)
- Repeat
I am using the following function to extract data from the files:
template<class T> std::vector<T> getFromBin(std::ifstream& ifs, int num);... |
I'm using React Native to implement Conway's Game of Life as a mobile phone app. So far I've implemented the game logic and a main screen with an embedded GLView component where the game board is rendered, as well as buttons for moving the camera. The touch screen system to allow users to set the initial board state ... |
I've seen something similar and have been trying to refactor the JS. I have two columns of content, which when scrolled move in opposite directions. This should also loop continuously. The fundamentals of this are working but I'm not sure if it's massively over engineered? Or if the JS could be better so ensure a smoot... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.