instruction stringlengths 71 95.1k |
|---|
I'm a beginner using Python, and I'm trying to implement a functionality of a monitor program already developed by an other programmer.
This program is working on a Windows machine (made by Inno Setup), which has to listen to the RabbitMQ server and consume messages. Those messages are supposed to start a background Af... |
I need to check if a filename contains a value that I get from 2 excel Columns (ContractNumber & PONumber). My Script is too slow right now. It has been running for 1 hour, and it completed only 2%.
The files are in 600+ folders within the main directory(shared drive). There are 19K files(pdf/docx). And 40K numbers to ... |
I have implemented my business logic using the repository pattern. I have an Approve method in my controller. I am calling the service method ApproveUserChangeRequest, which in turn invokes GetUserChangeRequest and ApproveUserChangeRequest in the UnitofWork class. I would like to know if this is standard practice or if... |
I'm learning how to write WPF custom controls. My example, NameLister, exposes a single DependencyProperty, Names, of type ObservableCollection<string>, and displays all the names concatenated together into a single string in a TextBlock.
To test my control, I have a TestApp which binds a collection of three strings: "... |
I made this code to calculate pi using MonteCarlo method.
I'm also learning how do Java threadpools and multithreading work.
Can you tell me if this method is thread-safe and how can I improve it if there is a deadlock chance.
private volatile boolean waiting = false;
private int reqsamples = 10000;
private int sample... |
I solved the Advent of Code problems last year in Python, and I wanted to learn a new language this year, so I decided to write up Part 1 of on of the hardest problems from last year - problem 15 - in Rust.
While the problem in all its particulars is quite difficult to understand fully, the basic idea is quite simple: ... |
Background
A request (req in the code) is made to my server, and a response (res) returned. By the time the response has filtered through to the code below, most of the heavy lifting - looking up entries in a database, etc - has already been done. This code just puts some final tweaks on all responses before it's pushe... |
I'm a hobbist trying to become a professional software developer. I do have a lot interest in Data Science in general and my goal is to master Python before diging deeper into specific data science topics.
I created this game when I started studying object oriented programming. Thank you all in advance.
import os
impor... |
Consider the following code.
$car = (object)[
'general' => [
'interior' => [
'seats' => 'destroyed'
]
]
];
$exteriorProperties = [
'hood' => 'shiny',
'windows' => 'dirty'
];
foreach($exteriorProperties as $key => $prop){
$car->{'other'}->{'exterior'}->{$key} = $prop;
}
... |
I created snake as my first program with GUI, I didn't learn OOP yet,
so my program has no classes. I know that I should use comments, I am sorry.
Short instruction:
l - increase snake speed
k - decrease snake speed
space - pause/start/restart game it depends
a - turn snake left
d - turn snake right
What can I im... |
I am practicing w/ Python and wanted to code a simple Rock, Paper, Scissors game w/o any user input. I used a list to hold the values and randomly pulled them with a function. I used the the return value from the first function to print the response in the second function, along with the printed results. What are some ... |
This code is scraping the data from IMDB and displays it in JSON or CSV format.
I plan to extend it beyond the top rated movies. How can I improve the quality of my code? I am using Python 3.7.3.
from bs4 import BeautifulSoup
import requests
import csv
import json
import codecs
films = []
def getFilms250():
sou... |
Is it bad practice to mix async and sync call in same ASP.NET core API call?
For example, in following code method CropBlackBroderOfAnImageAsync is an async method.
On the other hand SaveImageForProcessing(file, sourceFolderPath); is a sync method.
The reason I am calling SaveImageForProcessing synchronously is
that I ... |
int main()
{
int x,numDigits,i,y,a,diff;
scanf("%d",&x);
a=x;
int result = 1;
int base=10;
numDigits=0;
do
{
++numDigits;
x = x / 10;
} while ( x>0 );
for(result=1;numDigits>0;--numDigits){
result *= base;
i=result;
y=a%i;
whil... |
So, here's a task. A background thread may or may not call all of it's listeners some time after sendRequest() was called (in other words sendRequest() schedules a possible event). The required function must:
Subscribe to those events
Call sendRequest() periodically until the function returns anything
Return the first... |
I am modeling a linear process at a number of equally spaced time steps. I have a large list (~70k elements) which corresponds to a location at each time step, timerange = np.linspace(0, time, iterations, False) * speed. For each element in this list, I want to compare its value (location) to two other lists and see if... |
This is a pong game I created some time ago, but it doesn't have methods to store scores yet and also might have some bugs. It is also very slow.
The code:
from tkinter import Tk
from random import choice
import os
def clear():
os.system('cls' if os.name == 'nt' else 'clear')
class Pong:
def __init__(self):
... |
I am new to python. I have been given a task to verify the data from 2 apis which give similar data but in different format i.e. Json and XML. I have written the code but it is taking too much time to execute. I am unfamiliar with formatting and etc so please help me here. (I am excluding urls and header etc. for secur... |
To compensate for shaky hands when holding a mobile device I'm averaging the rotation of the phone over the last n (in this case 16) frames, and setting the camera's rotation to this average. This works smoothly and allows the user to look around in 360° by moving their phone around without getting sick of vibrations.
... |
Please keep in mind that I am very new to data science and completely new to NLP! I am trying to create a model to classify customer reviews as either negative or positive. However, my main problem is that most of them are in Norwegian, which seems not to be very well supported. I have found this repo https://github.co... |
I have a piece of code (below) that checks a data table (45,000 rows) to see if the row matches any entries in a range elsewhere on the workbook (using custom functions). The routine then creates an array of Flags and writes that array back to a field in the table - so a series of Sumifs formulae reference only those ... |
To celebrate questions getting more reputation points per upvote, I revisited my previous question, Plot timings for a range of inputs.
Since the time of that original question (more than two years!), this code has undergone quite a few changes. I incorporated some of the advice given in the answer by @MaartenFabré. I ... |
I have a for of loop, for each item in the childElements HTMLCollection I want to subtract the height of the elements from the parent height.
let height = element[0].clientHeight;
const childElements = <[HTMLElement]>element[0].children;
let i = 0;
for (const childElement of childElements) {
if (i !== childElements... |
Hello I would like to use python to change the author of an html file, in order to do so I have written a few lines.
First I have used the HTMLParser class from the standard library to make a class that indicates which line of the html page needs to be changed.
from html.parser import HTMLParser
class AuthorFinder(HTM... |
I've previously came up with the question "Rolling dice in a method chain" and was interested if this could be improved. It could, so now I have this class:
public class DiceQueue : IEnumerable<int>
{
public int Sides { get; }
internal Random Rnd = new Random();
public DiceQueue(int sides) { Sides = sides; ... |
I've just refactored my Rust and C++ code which simulates the shoeshine shop model from this question. What else can be improved?
C++:
#include <iostream>
#include <iomanip>
#include <random>
#include <numeric>
#include <algorithm>
#include <array>
#include <queue>
#include <string>
#include <functional>
namespace sho... |
Task: Find the balance point of an array; return the index that if you break the array into left and right at that point will create the same sum on both sides.
e.g: given the array [2, 4, 5, 1, -2, 7, 2, 1, 4]
returned value should be: 3
left: 2, 4, 5, 1 = 12
right: -2, 7, 2, 1, 4 = 12
public static arrayBalance(inp... |
Task:
Return the fibonacci value at a given index.
e.g: input: 6, return: 8.
Algorithm 1:
public static fibonacci(input: number): any {
if (input <= 1) return input;
return this.fibonacci(input - 1) + this.fibonacci(input - 2);
}
Time complexity: \$O(n^2)\$,
Space complexity: \$O(1)\$
Algorithm 2:
public... |
I have written a class to generate a unique username from the full name. The full name is the name of a company usually containing 4 to 5 words. The username generated will be of format {preffix}{username}{suffix}. The user name should not be derived from stop words. stops words are generated analysing the most common ... |
I have a component, it's actually an entire screen in my application. This screen/component renders multiple other components. However, what it renders is conditional. Currently, I have an if statement, which decides which markup is returned. The only differences between the two markups is one additional <PDFPreview> c... |
I've been taking a crack at Domain Driven Design, SOLID principles, and unit tests to write more maintainable code in the future.
Though I tend to run into the same issue: While I have many classes/objects that are easy to test, and do one thing well, I'm completely stumped on how to get classes to interact with each o... |
After a test run with LoadRunner I wanted to know the average time for each transaction for each VU volume step, the LR let you create a graph for this but don't give you the point values... so it's not possible to further analyse the data. As I'm learning python I decided to write a script to do the job for me, this i... |
I would like to store all error messages in one file and call them for example with
if (!std::filesystem::exists(ArgFilename)) {
throw std::runtime_error{error_001_nofile};
} else {
//do something
}
The file errorcodes.h is included to the main program and looks like
#ifndef SRC_ERRORCODES_H_
#define SRC_E... |
This is part of a Particle Swarm Optimization algorithm, a snippet of a Particle class implementation.
/**
* Particle class constructor
* @param p - the position of the particle
* @param v - the velocity of the particle
*/
Particle::Particle(std::array<double, 30> p, std::array<double, 30> v) {
bestFitness = fi... |
So, I was working on a dashboard for a potential customer and I needed a fake dataset with employee information to demonstrate. Mainly, I needed to know when the employee arrived the company (first swipe), when he left (last swipe) and the hours he spent in many other areas of the company (ORC is a room, DSP is another... |
I've read several places that say it's really bad to use append, and I understand why. I read somewhere that it was never even correct to use append. However, I was working on a textbook exercise in Essentials of Programming Languages (Ex 1.21 pg27) that asked me to write a Cartesian product function. I couldn't think ... |
public class URLBuilder {
StringBuffer api_url;
final String AND = "&";
private String API_KEY;
String parameter;
public void setAPI_KEY(String API_KEY) {
this.API_KEY = API_KEY;
}
public void setCity_name(String cityname) {
parameter = "q="+ cityname;
}
pu... |
I tried starting off with something like below. Note that traversal etc. is not included, this is the portion for storage and modifications. It feels like this could be much more elegant at places but not exactly sure how. I'm mainly trying to improve how the code almost repeats for getters and setters for left and rig... |
I made this as a personal challenge. It seems to work fine as I can't find any bugs and am happy with how it runs, but I am interested in what I should do to make the code more professional.
Note: This code was tested in Python 3.7.4.
class TicTacToe:
def __init__(self):
self.p1 = '\U00002B55'
self.... |
I have the below
private function yearMenu() {
$m = date('m');
$y = date('Y');
if (($m>3 && $y==2019) || ($m<4 && $y==2020)){
$menu = 1;
}
if (($m>3 && $y==2020) || ($m<4 && $y==2021)){
$menu = 2;
}
if (($m>3 && $y==2021) || ($m<4 && $y==2022)){
$menu = 3;
}
... |
I created my first JavaScript program and I feel it's all over the place.
I just started it without thinking too much about it. Now, I am quite sure I should have used OO style.
Also, it seems there is a lot of repetitive code.
Anyway, as this is my first JS project I would be thankful for all feedback or any pointer t... |
This is an interview question. Take a list of strings that represent port ranges like these:
const systemPorts = '11000-11001, 11100-11101, 12000-12010, 13000';
const customerports = '11000-11003, 11100-11106, 12000-12015, 13000-13003';
And return a merged list of ports in the form of a string:
'11100-11106,12000-12... |
I'm working on a design for a video buffer in C++ that will be used by many consumers both in the native library space(C++) as well as Java side using JNI. My Idea is the following:
Have a buffer manager that will receive frames directly from the hardware and allocate each frame only once on the heap using shared point... |
My issue that I was trying to solve was constructing a vector where the values were mirrored around the central element. The problem is here: https://stackoverflow.com/questions/58876916/construct-mirror-vector-around-the-centre-element-in-c
I solved the issue using the method in the accepted answer and am sharing my w... |
In my endeavor to learn Angular, I've created a flashcard site with an F#/Mongo backend. As I'm new to Angular, I'm going to post everything; any and all feedback is welcome.
First, some pictures of it in action:
This is the home page. The dropdown on the left (or top) allows you to filter the displayed decks by all ca... |
I've been refactoring code today, try to implement a clean code setup using repositories. Is this on track? Can any improvements be made?
public class IndexModel : PageModel
{
private readonly MembershipFormRepository _membershipFormRepository;
private readonly IMembershipFormViewModelService _membershipFormVie... |
I initially posted this on Stackoverflow but was recommended to try here instead.
I'm looking for feedback on why the implementation of my
ClientFactory is probably bad, from a Dependency Injection-point of
view. Or if it is actually okay to use in production?
My code below works. I know how to implement a named/typed... |
I have this below code where i am sending some content over a POST and then consuming the response. I would like to know if there can be any optimizations that can be done and is there any possibility of connection leak.
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.S... |
What do you think about this code I wrote.
It reads several json files ( I attached them as pastebins)
and the code outputs summary information calculated from the input.
# 1) calculate the
# engagement rate from the first JSON file (the user's Instagram media)
# - Calculate the average number of comments - Calculate t... |
When I heard about the new Linux I/O interface io_uring I searched about the ring buffer.
I then thought I may replace my safe queue which is base on C++ 11 std::queue with a ring buffer to avoid repeated memory allocation during producing and consuming the packets between threads.
So I wanted to implement it as an exe... |
I have been trying to get the blob data from oracle into a zip file using Python. I couldn't find the answer on any of the other links. Below is the code:-
import cx_Oracle
import numpy as np
import pandas as pd
con = cx_Oracle.connect("OPT", "OPT", "INDLIN1234:1521/OPTEPC1")
cursor = con.cursor()
sql_string = """SELEC... |
let formData = new FormData();
formData.append('File', document.file);
formData.append('DocumentType', document.documentType);
product = {
...values,
productType: productT,
};
for (var key in product) {
if (key != 'createdDate' && key != 'expirationDate') {
formData.append(key, product[key... |
I wrote a timer app in python using both twilio and the timer module; sends an sms to my phone after a certain amount of time has passed. While it works without a doubt, I wanted to gather some ideas/opinions on how to improve my program for efficiency, readability, etc...
I'm open to all suggestions.
import time
from ... |
If I have a method where the input is a list of integers, and within that method I convert the list to a list of strings, what is the best way to name the new list?
For example (using C#):
public void DoSomething(IEnumerable<int> cheeseburgerToppingIds)
{
var cheeseburgerToppingIdsAsStrings = cheeseburgerToppingIds... |
I would like to be specific in parameter types or write something like this:
Test test = (Json<Test>)"{\"age\": 46}";
Where:
public class Test
{
public int Age { get; set; }
}
My helper is:
public struct Json<T>
{
public static implicit operator string(Json<T> json) => json.JObject.ToString();
public st... |
I was told to create a 2D array from a txt file that had the "carModel, carColor" followed by a new line. The 2D array is 8x8 and for each time a certain carmore and carcolor appear, their respective [x][y] coordinate that represents their count goes up by 1.
So far, I have read the file, created a 2D array from the fi... |
I was learning some DOM manipulation and interaction with third-party APIs by building a simple interface to get the people who commented on a PR on GitHub.
I got great feedback for my initial prototype: Interface for getting Github PRs commenters using Github API.
Now I am trying to get into OOP using ES6 Classes, so ... |
A small script that simply prints a given string. It's an improved snippet that combines some recommendations given in my post on string helper functions.
org 100h
mov si, hello
call puts
ret
puts:
jmp .run
.putc:
mov ah, 0Eh
mov bx, 7
int 10h
.run:
lodsb
cmp al, 0
... |
I am working on writing a discrete random variable generator function in excel vba. I've pulled this off a number of ways but here is the one I like the most.
Imagine in excel we have the following in cells A1:B3
red 5
blue 7
yellow 3
The following code is modeled as follows. Imagine drawing a line going from ... |
I have implemented a simple calculator using the Shunting Yard algorithm. It takes infix expression as an input "3 + 5 * 2", which evaluates and returns the value 13.
public class ShuntingYardAlgorithm{
private static Map<String, Operator> operatorMap = initializeOperatorMap();
private static Map<String, Oper... |
I have implemented Prim's Algorithm from Introduction to Algorithms. I have observed that the code is similar to Dijkstra's Algorithm, so I have used my Dijkstra's Algorithm implementation.
Please review this code and suggest improvements.
To compile on Linux: g++ -std=c++14 prims.cpp
#include <iostream>
#include <map>... |
I was doing container with most water question in Leetcode for which I wrote this algorithm
Question link: https://leetcode.com/problems/container-with-most-water
Question:
Given n non-negative integers a1, a2, ..., an , where each represents
a point at coordinate (i, ai). n vertical lines are drawn such that
th... |
The fact is that a material object must have a field that does not make sense to an immaterial object
Here is a class whose objects I want to divide into material and immaterial:
public class GameObject {
protected boolean isHidden;
protected Coordinate position;
protected int pictureWidth, pictureHeight;
... |
I have implemented a stack in Python 3, and it works well. If anything needs to be improved, I would appreciate the criticism.
class Stack:
def __init__(self):
self.stack = []
def isEmpty(self):
return self.stack == []
def push(self, data):
self.stack.appen... |
I have written c++ code which performs an elevator's function like carrying people from one floor to another. It is a fun project and I have written to test my C++ skills. Please review this code and suggest improvements. Also suggest some other features I should add.
#include <iostream>
#include <algorithm>
#include <... |
Continuing my trend of (ab)using the Windows command-line interface to do fancy graphics-related things with my command-line-graphics library, CLIGL, I've created an infinite procedural terrain generator, capable of generating coherent fractal noise to an appreciable distance.
The basic structure of the project is as f... |
I'm looking for any feedback in order to improve code styling, performance etc.
Also I want to make sure that the way I've implemented AES here is actually secure
import os
import hashlib
import sys
import base64
from cryptography.fernet import Fernet
class Cryptor:
def __init__(self, password):
self.__pa... |
I've written my custom implementation of an f"" / .format(...). I started the project thinking it was going to be longer than three lines.
from typing import List, Union, AnyStr
def format_string(string: str, variables: List[Union[str, int, float, bool, complex]]) -> str:
"""
Formats the passed string with the... |
I'm new in this community and with Python 3!
I'm trying to optimize this exercise:
We have n strings stored in a txt file.
Inside the strings a secret word is hidden as a substring of
consecutive characters.
We know with certainty that the word repeats itself exactly once in each
string but we don't know where. ... |
I have implemented a Bubble Sort. It works well. But if you think something needs to be improved, say it. This code was tested in Python 3.7.4.
def bubble_sort(nums):
for i in range(len(nums)-1):
for j in range(0,len(nums)-1-i,1):
if nums[j] > nums[j+1]:
swap(nums, j, j+1)
... |
I am writing an HTTP message coder/decoder. In my decoder I parse http messages into a http_request or http_response. In my encoder I encode one of these classes.
Representing the messages is the easy part, but I am sure I have made some mistakes. Please review and let me know what could be improved.
Some questions:... |
I have just started messing around with PHP/SQL and came up with a simple sign-in application that checks if your sign-in information is valid based on database information. Here is my code:
<!DOCTYPE HTML>
<html>
<head>
<title>Sample Database Page</title>
<style>
body {
font-family: sans-serif;
}
.... |
I wanted a routine that would allow me to use the NumPad keys for directional commands. 1-9 for each compass point, - for up and + for down. If one of these keys are not pressed, it would act as a regular readline(). I threw in a few simple lines to act as timers, obviously this was just to complete it.
This is my solu... |
This is a program that I created using Python. Please help me optimize the code.
import time
import sys
import socket
from time import localtime, strftime
# start up system
def start():
print("Welcome, please choose what to do")
choice = input('register/login ')
if choice == 'register':
register(... |
I'm making a Mandelbrot set viewer in JavaFX. It takes a while, like maybe 5 seconds to finish. Here's my code:
package sample;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scen... |
I wrote this code to read a square matrix saved as binary file, that it can be int, uint, float etc... to pick a value from the matrix at given row y and given column x.
Could this code be faster to pick this value, better than 20 seconds.
The maximum row and column number in matrix is 3601 for each one.
import struct
... |
Context: I am making a website that allows people to upload their Facebook Messenger data, and see data visualizations for conversations. It is a React front-end, and a nodejs back-end. It doesn't store anything in a database at the moment, but there is a caching layer to deal with different sessions. So once the user ... |
I have written BST in Java for practice. How can I write better unit test cases. I am sure the way I have written them is not proper.
Code for BST
package com.r.basics.tree;
import org.junit.Before;
import org.junit.Test;
public class BinarySearchTreeTest{
private BinarySearchTree<Integer> binarySearchTreeSUT;
@B... |
def draw_board(board):
display_board = ''
for number in list(range(len(board))):
if (number + 1) % 3 == 0:
if number < 6:
display_board += ' ' + str(board[number]) + ' \n—————————————————\n'
else:
display_board += ' ' + str(board[number]) + ' ... |
I've designed a database schema to store multiple translations with the objective of it being easy to retrieve data and add more translations if ever needed in the future without needing to make any change at all.
Here's a dbdiagram.io of the part of the database that's relevant to this post.
One of my bot commands ta... |
It's an exercise from a Swift-course I'm currently taking.
You are given an array of integers. Make an additional array named
computedNumbers. computedNumbers should multiply each element in the
numbers array by the next following element. The last element shall be
multiplied by the first element.
Example: If n... |
I think the part to get shortest path from the cost table got pretty messy. Also can use some tips on how to avoid the extra O(V+E) work checking all edges from source to dest after getting the cost table, or have a better optimized implementation in general.
DirectedGraph.scala
case class Vertex(id: String)
case class... |
In the following hunchentoot easy-handler definition:
(define-easy-handler (new-game :uri "/new-game") ()
(standard-page (:title "Add a new game"
:script (ps
(defvar add-form nil)
(defun validate-game-name (evt)
... |
I am trying to remove all occurrences of the words I collect in the list exclude from every text note. This is my approach.
import operator,re
exclude=[]
for i in range(len(freq_select)):
if freq_select[i][1]<=25:
exclude.append(freq_select[i][0])
def remove_nonfrequent(note):
print(remove_nonfrequent.i)
... |
The fact is that I wanted to apply the builder pattern. But this could not be achieved, since I could not create an instance of the class with an empty constructor - this is dangerous. The goal is to make the parameter list a little shorter and more meaningful. As a result, I created a new class, the builder, which set... |
I'm new to the C programming language and I just made a basic version of Python's split() function using C.
Note: A major functionality I chose not to implement is the usage of optional delimiters.
Official documentation of split() can be found here.
#include <stdlib.h>
#define TRUE 1
#define FALSE 0
#define DEFAULT_BU... |
My React application manages some entities. I'm using Redux (with redux-thunk) to manage the application state. I've created a RESTClient based on Axios:
export class RESTClient<E extends { id: number }> extends Client {
protected path: string;
public constructor(path: string, token?: string) {
super(token);
... |
I was recently going through some OpenCV code that finds the center of mass in a contour and realized there is potential room for optimisation.
What I noticed looking back through my code is when I calculate the mass I'm using contours.size() which makes me believe that I'm calculating the moments and center of mass fo... |
I am attempting to train many classifiers to test their performance with classifying tweets as being from a political bot, or not (a binary 0 or 1 classifier).
My data is being read in via a csv file, with 200,000 rows, that looks like this:
username,tweet,following,followers,is_retweet,is_bot
AUSTINLOVESBEER,NHS fails... |
I have a function that checks if a user can perform an operation based on access to a specific URL.
The function parameters are the requested URL: url, and user level: lv. The conf object has stored access levels for comparison with the users access level.
function isAuthenticated(url, lv){
let conf = config.getCo... |
I am using the below code to retrieve nodes and values. It is taking 20 mins to retrieve the nodes and values of HKLM.
I'm expecting to reduce the retrieving time
Getting nodes
Private Function f_GetSubkeys(ByVal WindowsRegistryKey As RegistryKey) As Integer
For Each subkeyName As String In WindowsReg... |
I've made a controller for Python's Turtle. The controller essentially defines an 'instruction set' so that commands can be recorded in a text file and then executed sequentially by the turtle. It acts similarly to (underlying) assembly code in that it executes these instructions in order and can also do simple iterati... |
My goal is to implement a function that accepts a Follower object that will be used to report progress through a complex function (a depth-first traversal of a graph). Here's my attempt:
pub trait Follower<'a, N> {
fn root(&mut self, node: &'a N);
}
pub fn depth_first<'a, N>(
node: &'a N, follower: &mut dyn Fo... |
I have requirement to check list of environment variable in Linux. Based on environment variable, exit code will be different. how to optimize the below code?
def check_mandatory_envs():
if "ENVCONTEST_1" not in os.environ:
exit(125)
if "ENVCONTEST_2" not in os.environ:
exit(126)
if "ENVVIRT... |
This is the first time for me to ask a question in this site. Recently, I was learning python 3.x and I got a question...
Which is faster ?
if n==0 or n==1:
or
if n*(n-1)==0:
Similarly, for a,b,c,d are numbers, which is faster?
if n==a or n==b or n==c or n==d:
or
if (n-a)*(n-b)*(n-c)*(n-d)==0:
I have been confused ... |
I'm trying to build an iterator (enumerator) that can select specific elements in an Expression tree by traversing the tree and deferring further iteration until needed.
My following implementation intends to keep it simple by leveraging the ExpressionVisitor. But since a visitor-pattern uses recursive stack calls to ... |
Here I created a typed version of lodash flow that offers more specific typing.
I'm curious if this exists in any other library, which optimized in tying any way — offering mainly it up to the world as a better version of flow.
The return value is set to the return in the last passed function
The input value is set t... |
Question: A binary string is given with only 0's and 1's. A number n is also given as the length of a sub string to be considered. It is to find the number of unique substrings. Here, n=3.
My algorithm: The ways I followed:
(i) First, I extracted out the sub string of length 3 and converted it into a number.
(ii) Then... |
I've made a small script to compile Go code with Python.
The result is not something I'm happy with, because:
It seems overly complicated
I'm worried the nested if-else with f string are unreadable
Am I using the subprocess module the correct way?
Any review is welcome.
#!/usr/bin/env python3
import argparse
import ... |
I'm trying to write a JavaScript BitTorrent client in Node.js to get more familiar with the language and ecosystem. I don't know how often people use classes in JavaScript since I feel like the overall approach is to try to hide the least state possible and embrace some of the functional programming styles with callbac... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.