instruction stringlengths 71 95.1k |
|---|
Consider the pattern below, where multiple async calls are made in parallel:
var thisTask = ThisAsync();
var thatTask = ThatAsync();
await Task.WhenAll(thisTask, thatTask);
var this = await thisTask;
var that = await thatTask;
While it works fine, I find it a bit too verbose for what it is doing.
While having some f... |
I am implementing an algorithm to find the pair of integers in the given array which have minimum XOR value.
Ex:
Input:
0 2 5 7
Output:
2 (value of 0 XOR 2).
Then bellow is my solution:
public int findMinXor(List<int> A)
{
var min = int.MaxValue;
for (int i = 0; i < A.Count - 1; i++)
... |
This is my first attempt at implementing a heap data structure and I've decided to cover the methods Peek, Pop, Push, and Replace. Think appear to work correctly but I admittedly had a lot of trouble figuring out the "ideal" way to implement each function as the reference implementations I found were all over the place... |
The program that contains the function I'm asking (handle_non_exact_answer) about has several instances of a class Test, with some options the user can set that determines the behavior of the class. If the class has certain options, we handle the class differently, so I deal with these cases in a separate function, whi... |
I've already posted a first attempt on Code review. Here is a new version that takes into account the answers I've received.
Is my program now reasonable or are there still things I need to improve?
As I am learning programming I do not want to develop bad habit.
Any tips on what is good to do and what is bad to do wo... |
I have some code that takes some JSON, parses it, and given an optional filter, will attempt to find any key (or nested key) that includes the filter (partial matching - it does not match values). The difficult part was handling deeply nested objects and arrays.
For example, given the following JSON:
{
"a": {
"b... |
I've only ever made small programs. So, I've tried to make something large but easily reusable/extendable. Posted below are the beginnings of a graph library I've written up.
One particular point I'd like to ask about is my use of the class HashMap. I wanted to be able to hash easily and by memory address. This approac... |
Successful attempt at the ICPC North America Qualifier 2018 Problem D "Froggie." Any advice and all topical comments on code optimization and performance enhancement is appreciated!
Problem Summary
You are recreating the classic ‘Frogger’ video game.
Each level consists of a road with multiple lanes, with cars traveli... |
I was asked for an example of a class to wrap dynamically added controls as I suggested in this Answer. Although it is out of the context of a Code Review, I thought that it would make an interesting post.
I'm looking for feedback on not only "How to improve my code" but also "How to better explain my code".
Basic C... |
On my Arch Linux system I have created a script that should do the following on system startup:
detect all network interfaces
check if physical interfaces are up
check if bridge interfaces are up
determine if physical interfaces have IPv4 addresses and delete them
check if physical interfaces have IPv6 addresses
delet... |
I am dealing with some older C style APIs, like Posix execve that take a char**. In the rest of my code, I prefer to use a fairly modern C++ style, so I have vector of std::string. Is this the best way to handle the glue between them?
char ** strlist(std::vector<std::string> &input) {
char** result = new char*[in... |
I have a need to parse strings that contain pairs of key : value, and remove a specific pair, when I'm only given the key.
Example:
Given the string char *in = "sha-auth privacy-protocol des authentication-password shapass123 privacy-password despass123 admin-status enabled";
and the key-word char *kw = "authenticatio... |
This is the code I made to scan IP addresses. I am new to python and just want to learn how I can optimize it. I know the subprocess is slower than others to IP scanning but if there is a way to make it faster I would like to know how. :)
#!/usr/bin/env python
# coding:utf-8
import subprocess
import datetime
hostname =... |
Given below is my task
Write a selenium test that makes a booking from Bangalore to New Delhi
for today's date with a return of tomorrow using makemytrip.com.
Select the cheapest flight and make sure that you come to the booking page.
I'm pretty new to Selenium and I would like to know if my attempt at achievin... |
NOTE: the Javascript is all I'm concerned about, the HTML/CSS is just DEMO code. One caveat is ARIA states or attributes, if you have input on that, by all means, dive in.
I had the need for and unobtrusive extensible toggle that could be applied to a handful of items: tooltips, accordions, panels, dropdowns, etc.
With... |
Problem definition
Find the longest word that doesn't contain any of the following characters:
gkmqvwxz
Input comes from a file named words.txt and contains one word per line. A word is anything that is not a whitespace.
The twist
My C++ implementation posted below is surprisingly slow, taking 1.7 seconds to run, wh... |
I'm pulling the values from the following XML based on the attribute name.
<DataRow>
<DataItem name="SYMBOL">MSFT-US</DataItem>
<DataItem name="NAME">Microsoft Corporation</DataItem>
<DataItem name="CUSIP">59491812311</DataItem>
<DataItem name="SEDOL">2588CFA</DataItem>
<DataItem name="CURRENCY">USD</DataIt... |
I am working since a couple of weeks on my first Python application and I would love to have a review of the code I wrote so far.
The app has the purpose of controlling the cooling and lighting of an AIO water cooling kit from NZXT on Linux. The official software only supports Windows but the interface is USB so the co... |
I'm trying to code a simple person database using structs and arrays in assembly.
Each person has a firstName, lastName, age and weight. The goal is to have an infinite loop that asks the user whether they want to read or write to the array then ask them for a position to read or write to. Currently, the array is lim... |
I have programmed a card game in Python. It is over 700 lines long. How can I improve the code?
There are two players. Every round, each player takes one card from the top of the deck. Those cards are compared, and the winner of the round is assigned based on the following rules:
Red beats black
Black beats yellow
Yel... |
In my intro CS class we're reviewing data structures. I'm currently working on implementing a queue using a linked list (FIFO) in C. I'd appreciate a review of the implementation as well as of my understanding of how a queue should work
// This program is implementation of queue data structure
// via linked list (FIFO)... |
I did a big mistake to create procedural C++ breakout game on start and now im having trouble converting it into OOP.
As far as I can see I need classes: Loptica (eng. Ball), Splav (eng. Paddle), Blok (eng. Block), Logika (eng. Logic), Kolizija (eng, Collision), Level (eng. Level)
Definition:
#include "SDL.h"
#include ... |
I'm looking for feedback on a way to avoid massive code duplication on unit tests of a generic interface. It is expected that the interface will have several dozen implementations with common constraints.
Consider the following simple builder interface:
public interface IBuilder<in TInput, out TOutput>
{
TOutput Bu... |
I was recently asked the following interview question over the phone:
Given an array of integers, produce an array whose values are the
product of every other integer excluding the current index.
Example:
[4, 3, 2, 8] -> [3*2*8, 4*2*8, 4*3*8, 4*3*2] -> [48, 64, 96, 24]
I came up with below code:
public static Big... |
I've wrapped an imported function (a promise) and attempted to write unit tests that bring my codebase to 100% coverage.
import { Auth } from 'aws-amplify';
import signIn from './shared';
describe('signIn', () => {
afterEach(() => {
jest.restoreAllMocks();
});
it('invokes the success callback on success', ... |
I wrote this C++ code for Tic-tac-toe for an interview (The basic skeleton was pre-provided) and got rejected because the code was too complex and inefficient. I'm not an expert programmer so I'd like some ideas about how to better my code to make it more efficient. The code is as follows:
#include <iostream>
const in... |
This question is the second follow-up of: Shell POSIX OpenSSL file decryption script
The first follow-up was: Shell POSIX OpenSSL file decryption script follow-up #1
Both of which have proven very useful and sped up my learning curve of shell scripting.
You should probably look at them, but as I made so many changes, I... |
This program is an implementation of the classic puzzle Tower of Hanoi! This is my first mostly recursive Assembly program. Any advice and all topical comments on code optimization and conventions is appreciated!
Compiled as follows using VS2017 x64 Native Tools Command Prompt:
> nasm -g -fwin64 hanoi.asm
> cl /Zi h... |
Made a project to generate TypeScript classes from database tables, and I'm looking for input if the code is reasonable. pg and mysql are not hard dependencies - that's why they're @ts-ignored.
This would be my first package to be published in npm.
Goals were to have as little as possible dependencies and maximum flexi... |
Part 2: JSON Test Harness: Part 2
Part 3: JSON Test Harness: Part 3
Part 4: JSON Test Harness: Part 4
Time to review some test harness code I have written.
https://github.com/Loki-Astari/JsonBenchmark
I wrote a C++ JSON parser/serializer and wanted to compare performance against other JSON parsers. This was originally... |
Part 1: JSON Test Harness: Part 1
Part 3: JSON Test Harness: Part 3
Part 4: JSON Test Harness: Part 4
Time to review some test harness code I have written.
https://github.com/Loki-Astari/JsonBenchmark
I wrote a C++ JSON parser/serializer and wanted to compare performance against other JSON parsers. This was originally... |
Part 1: JSON Test Harness: Part 1
Part 2: JSON Test Harness: Part 2
Part 4: JSON Test Harness: Part 4
Time to review some test harness code I have written.
https://github.com/Loki-Astari/JsonBenchmark
I wrote a C++ JSON parser/serializer and wanted to compare performance against other JSON parsers. This was originally ... |
Part 1: JSON Test Harness: Part 1
Part 2: JSON Test Harness: Part 2
Part 3: JSON Test Harness: Part 3
Time to review some test harness code I have written.
https://github.com/Loki-Astari/JsonBenchmark
I wrote a C++ JSON parser/serializer and wanted to compare performance against other JSON parsers. This was originally... |
The reason I created this is because the Material UI way of doing a simple 'menu that opens below the button' is convoluted as hell (see the 'toggle menu grow' example, and check the code out. I've basically copied the code for that, and put it in one nice wrapper.
Codepen
Here's the usage of the component:
<NavDropdo... |
Objective:
I want to loop through a bitarray and store subsets of that bitarray in a table.
Context:
I have a bitarray with 48 elements where each element represent one hour. I want to look back 24 hours from the start of the second day and retrieve the intervals where the last bit is 1.
I was able to achieve this but ... |
I am learning algorithms. And my current algorithm is create a single list, and try to remove all duplicated elements in a sorted list.
Ex:
given Input: 1 -> 1 -> 1 -> 2 -> 2 -> 3 -> 5 -> 5 -> 7
Expected Output: 3 -> 7
My bellow solution worked well:
//Definition for singly-linked list.
public class ListNode
{
... |
I wrote a Python program that can take as argument either a string or a filename, with these options being mutually exclusive:
#!/usr/bin/env python
import argparse
import sys
def parse_command_line():
parser = argparse.ArgumentParser()
parser.add_argument('-t', '--text', dest = 'input_text', help = 'Text')... |
I would like to know how to make this faster. It's okay for 100 rows but 1k, 10k, 100k is different.
let array = {
"PageOption": {
"rowperpage": "10",
"rowtotal": "235",
"currentPage": "1",
"divheight": "250"
},
"header": [
{
"visible": true,
"label": "rownum",
"fontweight"... |
I'm looking for a code review of this python I wrote - this code reads the zipcode column value from a CSV file and calls an API to retrieve lat, long, state and city info.
It works fine and gives me the correct results, but I'm looking for ways to improve the code/my approach and exception handling. I am pretty sure t... |
I have a task in which I want to handle error occurred in FTP downloading, For which I used the wget command to download a file via FTP and once the download is complete, compare downloaded filesize with FTP file size.
For that, I have the code as follows. My question: is this the correct method?
# fetch file details f... |
Here is a simplified version of my JSON.
{
"Relations": [
{
"Type": "A",
"Categories": [
{ "Name": "Identity" }
]
},
{
"Type": "B",
"Categories": [
{ "Name": "Identity" },
{
... |
I've implemented a simple calculator in C# that takes in the left operand, the operator, and the right operand. Once the calculate button is clicked, I use four methods to validate the inputs:
1. The input is present
2. The operands are decimals
3. The operands are within the range 1-1000000
4. The operator is valid.
R... |
So I've been following the discussions around VBA as an OOP language and the applicability of various design patterns, such as MVP or MVC. Excellent postings on these topics are extremely informative and have caused me to rethink my implementation approach for my projects (past and present). Change and growth is always... |
I have been studying C#, and I am trying to model the Tic Tac Toe game. Is my program reasonable or is there anything I need to improve?
enum Result
{
None,
Win,
Draw
}
public class TicTacToe
{
static char[] board = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
char player = 'O';
Resul... |
I wanted to challenge myself in a new language that I am learning (C#) by doing a simple exercise: check if a "modulus 10" Luhn number is valid or not. In this case the common application if verifying credit card numbers. So I discovered that an exist implementation of this algorithm.
I have tested the code works with ... |
I wrote a tool that takes a domain name and a password, concatenates them, hashes the result with sha512, and returns the result encoded in base64 truncated to 32 characters. The main idea behind this is to prevent an abusive server owner from getting my password by storing my password in plain text and using that pass... |
Am teaching myself about sorting techniques and trying my hand at a quicksort implementation. I found a lot of examples based on recursion but didn't want to go that route in a language that doesn't support tail-call optimization.
public static class ListExtensions
{
public static void InsertionSort<T>(this IList<T... |
I made this implementation of a stack in Swift that stores its elements as a linked list. It seems to work perfectly well, but I’m wondering how I can improve it to follow the best practices of the language.
struct StackList<T> : CustomStringConvertible {
private var first: StackNode? = nil // The topmost node in ... |
I have a fast producer thread and a slow consumer thread. The consumer processes as many objects as it can and simply ignores the rest in order to not slow down the producer. Therefore, I used a one-element wait-free single-producer single-consumer queue for passing objects to the consumer in a thread-safe manner. Afte... |
The way I've written this feels clunky. Particularly, it feels like I shouldn't need to have both a 'dateToCheck' and 'selectedDate' variables.
The objective is to find the Date in a list that is the closest to today (inclusive), with a preference for dates in the future.
The list is guaranteed to be passed in, in desc... |
I have a vector \$X_k\$ and a matrix \$Y_{k,j}\$, where \$k \in \{1,\dots,K\}\$ and \$j \in \{1, \dots, J\}\$. They are circular, meaning that $$\eqalign{X_{k+K} &= X_k \\ Y_{k+K,j} &= Y_{k,j} \\ Y_{k,j+J} &= Y_{k,j}}$$
I want to compute a \$ZX\$ vector and \$ZY\$ matrix according to the equations $$\eqalign{ZX_k &= -... |
I already posted this on Stack Overflow, but someone suggested to post it to Code Review instead.
I am creating an Android app that draws to the canvas. For this, I have defined rectangular screenareas that I want to draw to the canvas. As I am always drawing a fixed set of screenareas, I was thinking of using Enum (as... |
I am solving Word Break II from leetcode:
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences.
Note:
The same word in the dictionary may be reused multiple times... |
I am willing to see how to write readable and efficient continuations on the heap in c++. I am not quite satisfied.
The following is just an exercise: it is coded for fun. I post the code here because I am not really satisfied. I am looking for suggestions.
I picked up the simplest algorithm: measuring the length of ... |
This is a game for two users who roll 2 dice 5 times. If the total of dice is even, the player gains 10 points; if it is odd, they lose 5.
If there is a tie after the five rounds, then the users have to roll one die to determine the winner.
###### IMPORTING RANDOM AND TIME & DEFINING VARIABLES ######
import random
imp... |
I'm writing a Kotlin app that uses Exposed (https://github.com/JetBrains/Exposed) as a SQL wrapper to write and read objects from databases. The problem I'm facing is that I end up with 3 classes featuring the same variables. For example:
package database
import hashLength
import org.jetbrains.exposed.dao.EntityID
imp... |
Problem Statement: FOXLINGS
It’s Christmas time in the forest, and both the Fox and the Wolf
families are celebrating. The rather large Fox family consists of two
parents as well as \$N\$ (\$1 \leq N \leq 10^9\$) little Foxlings. The
parents have decided to give their children a special treat this year
– crack... |
I am relatively new in making (invocable)callouts. My main concern is if I should be using smaller parts for example for the body and using a query only once in this case. Any suggestions would be appreciated.
Class:
public class or_service {
@InvocableMethod
public static void InvocePostProperty(List<ID> p... |
Trivial utility program meant to go through the list of (small) files and report file offset of the first difference between them. The goal of the code is simplicity.
Any recommendations are useful. Be brutal. I'm collecting go experience :)
package main
import (
"fmt"
"io/ioutil"
"os"
)
func main() {
... |
I've written a script in python to grab different title and address from different pages of a website. Firstly the script will collect all the property links from the landing page and then go one layer deep to collect the title and address. When I run my script, I get the results accordingly.
Should it not be a better... |
What is the recommended (standard, cleaner, more elegant, etc.) method in Python to get a string with all the alphabet letters?
Here's three versions of code to generate a dictionary with keys as letters and 0 as all values. The aim is to parse a text and count how often a letter appears.
from string import ascii_lowe... |
I was asked below question in an interview where I need to print out even and odd numbers using two threads so I came up with below code one without synchronization and other with synchronization.
/**
* Without synchronization
*
*/
class Print {
private static final int MAX = 10;
private static int count = 1;
... |
First time writing a "game" in a sense. Used a functions approach, it's simple, looking for a review of the way it's written and of course looking for how should it be written. Also using random for first time (I know I'm a nube).
#Number Guess Game
import random
def gameNumber():
while True:
difficulty ... |
Overall, I feel that my code is a bit verbose.
game.py
#!/usr/bin/python3
import sys,os
from models import Board, GameState
"""
Game loop for the minesweeper game.
"""
class Game:
def __init__(self):
self.board = Board(rows=10, cols=10)
def play(self):
self.welcome()
while sel... |
I am learning C++ and socket programming and OpenSSL. As such, I decided to make a simple client that opens a TLS connection and writes some data as practice. It also serves as a base for more complex applications.
I'm very new to C++, so I don't know if I'm using good naming conventions or other basic practices. The ... |
This is a pong game with 4 paddles. The paddles are always on the same height as the mouse. I wrote it in C using SDL. The Makefile works for linux. Do you think the code is readable or should I structure it different? Do i need more comments or is evertything self explanatory?
https://github.com/noahhaasis/pong_ultima... |
I'm trying to implement Reiner Knizia’s Decathlon, a set of 10 solo dice games played with 8 dices named after Decathlon events in Olympics.
The first event is called "100 Metres".
The player divides 8 dices into two sets of 4, then pick a set and throw.
He may keep the dice (freeze) or rethrow. After he is satisfied w... |
I'm trying to improve performance for a generic function that turns a string into a multidimensional array.
Expected input:
A string that was generated by the function Arrays.deepToString().
The original array had no null values and did not contain arrays of length 0.
The array can have any number of dimensions from 1... |
The objective of the post is to improve design and improve command on C++. Given a map, start point and end point, the shortest path to end point from the start point has to be found out using Astar (A*) algorithm. The algorithm uses an evaluation function f for each point or node in the map. The f depends on g and h. ... |
Compute the prime factors of a given natural number.
A prime number is only evenly divisible by itself and 1.
Note that 1 is not a prime number.
My solution will catch every prime up to and including 896803. This is the fastest solution I could come up with. I know that hard code can only go so far.
def prime_factors(n... |
I'm new to the filesystem from Laravel, but I need an upload script that allows users to upload images to my server. However, i'm concerned about securety, so I thought why not ask for advice, because there aren't much reverences about that big topic of securety.
Basicly, this is how I check the user upload and how I u... |
I am trying a simple Hash Map implementation in c++. I have used this and this as reference. The implemented design uses a class HashEntry to manage individual key-value pair. The class HashMap handles the map itself. The map has functions to insert(put) a key-value pair, to retrieve(get) value based on a key and to er... |
In the code below, I am building a NODE_ENV-sensitive config object from environment variables.
let username
let password
let cluster
let hosts
let databaseName
let replicaSet
if (process.env.NODE_ENV === 'production') {
username = process.env.ATLAS_HUB_USERNAME
password = process.env.ATLAS_HUB_PASSWORD
cluster ... |
Made some adjustments to the previous code thanks to the helpful and thoughtful review by @SergeBallesta, @TobySpeight, @G.Sliepen, and @Edward.
Problem statement: This program should ask for the total number of shops that will be visited. At each shop, ask for the number of ingredients that need to be purchases. For e... |
PostgreSQL, Python 3.5, SQLAlchemy
I have a main database which has a journals table containing 30k+ journals. For each journal I have a RSS feed URL, using which I can parse and get new articles. There are some mandatory fields if those are missing for any of the articles then there is a third party API which I can us... |
I'm self-taught in Python and would have a lot of room for improvement. I made this basic Sudoku Solver mainly in order to practice the use of Class creation. I would greatly appreciate any feedback about how I could program any of this in a better way.
from math import ceil
class Cell(object):
def __init__(self, ... |
Context:
I'm coding up a simple genetic optimization algorithm from first principles, and have decided to use boolean/binary strings as genes so that I can flip bits on or off as a form of mutation. In order to evaluate the fitness of the solutions that it generates I need to be able to decode the binary strings produc... |
I'm very new to Rust and have tried to write a simple graphQL server with Rust and Postgres. It works, but I have not idea about what's good and what's bad here. I would love someone experimented to read this code.
main.rs
#![feature(plugin)]
#![feature(trace_macros)]
#![plugin(rocket_codegen)]
extern crate config as r... |
I am solving the "Spread the Word" problem on CodeChef:
Snackdown 2019 is coming! People have started to spread the word and tell other people about the contest. There are \$N\$ people numbered 1 through \$N\$. Initially, only person 1 knows about Snackdown. On each day, everyone who already knows about Snackdown tell... |
I'm working on a password brute-forcer that takes in a password from the user and brute-forces solutions until it finds a match. I was wondering if there is any way to improve performance or readability?
import itertools
import time
Alphabet = ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXiuYZ1234567890-_.")
Pa... |
I wrote a basic template for a vector of arbitrary dimension to be used in a 3D-engine. Most operators make use of C++ template meta programming and instances are implicitly convertible to glm types. It is also possible to build a matrix class on top of this. Suggestions in terms of optimizations, safety, readability e... |
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't one, return 0 instead.
Example:
Input: s = 7, nums = [2,3,1,2,4,3]
Output: 2.
Explanation: the subarray [4,3] has the minimal length under the problem constraint.
... |
I have a class that compares the performance of two methods (multi- and single- thread) that searches for maximum number in the string of numbers. I want to improve the performance of a multithreaded variant because I think it can work more efficiently.
public class Part4 {
private static String PATH = "part4.txt"... |
Just for fun I wrote some JavaScript that "converts" an image into pure HTML / CSS. The user is able to select a local image. This image is loaded into an invisible canvas in order to extract pixeldata from the image. Using the pixeldata, a structure of 1x1 <div/> elements is created with each element having its backgr... |
I wrote this algorithm to find the Kth element of a singly linked list and I would like your feedback because I want to know if there is a better version.
In my eyes, this is the most optimized way of doing it and I've covered every edge case (I also assumed that the only possible input is a number, if I removed that ... |
I have seen some solution here for the same problem, this and this I have found better ways to solve this problem. I just want to know how good or bad my code and way of approaching this problem is.
using System;
public class Program
{
public static void Main()
{
int sum = 0;
for (int i = 0; 3 ... |
I need to determine whether a cookie name is available or not in the cookie string. I have achieved this. We could use the cookie-parser package but I don't want to use that package so I have written the below code. Can I reduce the code in a better way that is more optimised?
function checkCookie(cookie, cookieT... |
I'm working with big 2d numpy arrays, and a function that I need to iterate over each row of these arrays.
To speed things up, I've implemented parallel processing using Python's multiprocessing module. Each worker of the pool gets an array index, which is used to read the data from the shared array, and after the func... |
I recently just finished making this blackjack game using C++ and SDL2. Although this took a lot longer than I expected it to, I feel like I'm getting a good hang of everything. However, this is only my third game and feel like there's bound to be a lot of room for improvement. There's a lot different files for all of ... |
I've just started using PyCuda with Python 3, but I have some experience in high performance computing on CPU. I've tried to port one of my old models for generating the Buddhabrot to run on my GPU instead. To briefly explain the algorithm to anyone not familiar, the idea is this:
Generate a random complex number \$z_... |
This is my first 'real' project in C# , i looked up some tutorials on the Internet for Tic Tac Toe. But they were not how i wanted it to be, so i came up with some own ideas and wanted some tips on improvement, because i know some things could be different. I simply don't really know how.
So here is my Code. You can t... |
I have just finished a small program for Tower of Hanoi using recursion. I did it to practice OOP which I recently learnt. It took me about 2 hours to research about the recursive algorithm and write out the code. It works, after much debugging... However, after comparing to other implementations, I realised my code is... |
(Somewhat) new to python and coding in general! Using python 3.7 and pandas, I'm running code to create a searchable list of people in my dataframe, and I feel like my way of telling duplicates apart is very roundabout. I would love some advice on making it simpler and more efficient.
I have a database in pandas, 'df2... |
I am formatting a data result from the array of objects that looks like this:
const data = {
periods: [{
month: 'January',
sickLeave: {
differance: '-12000',
revision: '6000',
paid: '18000',
},
holidayLeave: {
differance: '10000',
revision: '22000',
paid... |
Overview
I was challenged recently to write some code that could find the smallest integer that when multiplied and divided by 2 or 3, retained all of its digits and gained no extras. For example:
With 2
285714
When multiplied: 571428.
When divided: 142857.
With 3
31046895
When multiplied: 93140685.
When divided... |
This is a little program to show how a WAVe-File Generator could be written.
It use a Function-Object "SinFunction" to calculate the value of any point of the amplitude in time. This object and two floats are given to the constructor of the generator object. The two floats are the frequency and the duration of the crea... |
I'm working on a program that will (hopefully) eventually allow me to perform frame rate analysis like Digital Foundry does. The code below works (as far as I know), but before I iterate on it, I'd like some feedback as I'm new to both C++ and OpenCV. I say "as far as I know" because I'm not sure how "lossless" my lo... |
I have written my own little auto-generated table class, and I was wondering if you guys can give me some tips on how to make this code more elegant and secure and maybe compact it so I use only one master function to bind everything when I call it out!
The DB connection file:
<?php
$host = 'localhost';
$db = '***';
... |
I've written a simple web service which allows a user to shutdown or reboot a system from the LAN. Although written to be used on an RPI which lacks a power or reset button, it can be used on any Linux system.
Aside from the missing secure login (I'm assuming everyone on the network can be trusted at this moment), I'd ... |
I asked for help accomplishing this on StackExchange.
How to efficiently read a large file with a custom newline character using Python?
And ended up providing my own answer which is duplicated here.
class ChunkedFile(object):
"""
Yields file in 100 megabyte chunks (by default).
If lineterminator is provi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.