instruction stringlengths 71 95.1k |
|---|
I have following code to create a mutable namedtuple. based my understand I can use dataclass to do it. is there a better way to do it or clean up the code?
@dataclass
class Price:
"""
This describes how to map default price value for product
"""
profit: float = 0.5
cost: float = 0.1
sale: float... |
I am writing a parser. To build up the tree, I need to find the correct type for my node based on text from my language input file. Right now, I have a map from a string (the node name) to a factory function which returns the correct type. Is there any way I can make this more simple/idiomatic when calling make shared?... |
I'm working on an implementation of the Karazuba Algorithm. I created a class BN which represents a number in an arbitrary base (and supports elementary operations). The algorithm works - but I'm not sure if I complicated it. Is there a better way to implement it or a way to optimize the code?
def decToBase(n: int, b:... |
In English, "Sh" is two letters. In other languages it's considered a single letter. I'm trying to calculate the length of a string in a Unicode aware way, with this in mind. I'm imagining a function like
def count_letters(my_string, lang="en")
But here's how I would do that for just one language, using a library that... |
I have this hosted service which grabs the data from API every second and process the data and save it into the database.
I have similar 3 more hosted services which run at the same time. Because of this, the CPU utilization is always high, I'm sure because of the foreach loops in functions and service but without that... |
You are given the following information, but you may prefer to do some
research for yourself.
1 Jan 1900 was a Monday.
Thirty days has September,
April, June and November.
All the rest have thirty-one,
Saving February alone,
Which has twenty-eight, rain or shine.
And on leap years, twenty-nine.
A leap year oc... |
This is a program exercise from The C Programming Language by Kernighan and Ritchie (Chap 5).
It is based on my earlier question here on Stack Overflow.
One user suggested to submit my code here, saying there's a whole
lot of bad coding practice in this snippet. Since most of the harmful
practice here originates from K... |
(The entire project lives here.)
I have a program that benchmarks three game tree search algorithms:
Minimax,
Alpha-beta pruning,
Alpha-beta pruning with move ordering.
So here is my code:
net.coderodde.zerosum.ai.impl.MinimaxGameEngine
package net.coderodde.zerosum.ai.impl;
import net.coderodde.zerosum.ai.Evaluator... |
I would appreciate som feedback on my Technical Document Page. I am doing the freeCodeCamp curriculum and a Technical Document Page is one of the Responsive Web Design Projects using only HTML/CSS.
I am especially interested in feedback regarding best practice, naming conventions and efficient code.
The code is also o... |
I would appreciate som feedback on my fictional portfolio. I am doing the freeCodeCamp curriculum and a personal portfolio is one of the Responsive Web Design Projects using only HTML/CSS.
I am especially interested in feedback regarding best practice, naming conventions and efficient code.
The code is also on GitHub.... |
I wrote a simple implementation of aysnc parallel.ForEach( ... )
All it really does is create a list of tasks and wait for them all to complete and aggregate the exceptions if any.
But to use CancellationToken I added Task.Run but I am worried that this is not the best way of stopping a task from running.
I could add s... |
I am learning Rust, coming from a Java background, and I was hoping to get some critique on my simple QuadTree implementation in Rust. This is as a learning exercise for me.
Are there tips on how to make it more idiomatic? Are there features of Rust I am overlooking?
// common.rs
#[derive(Copy, Clone, Debug)]
pub struc... |
I have been looking for answers for how to easily scrape data from Wikipedia into a CSV file with Beautiful Soup. This is the code so far. Is there an easier way to do it?
import urllib.request
from bs4 import BeautifulSoup
import csv
#the websites
urls = ['https://en.wikipedia.org/wiki/Transistor_count']
data =[]
#... |
I need to batch rename images with Mac Bash,while the directory index should be recorded.
To rename files ,turn
Root---A----0.png
| |
| ----1.png
|
-------B----0.png
|
----1.png
to
Root---A----0_0.png
| |
| ----0_1.png
|
-------B----1_0.png
|
----1_1.png
Here is my code... |
This is a simple calculator app that involves entering two numbers and allowing them to be editable and swappable. Calculations are done on the numbers, so the calculations should only be done when the inputs are blurred. The boxes' values need to be updated when the values are swapped. However, they also need to be ed... |
I've written code in C for reading a string of any length, and printing the string. It's one of my first C programs. I posted the program as part of a Stack Overflow question, and received a comment:
... there are many things wrong with your C version.
I'd really like to know what is wrong with the function I have wr... |
Here is the stack abstraction that I've written. I've designed it to be safe and without undefined behavior.
I use ugly_cast to discourage casting and to make casts more easily visible.
stack.h:
#ifndef STACK_H
#define STACK_H 1
#include <stddef.h>
#define stack_op(var, op) stack_##op(&(var), sizeof(var), stack_globa... |
I've recently set up a continuous integration pipeline to deploy a .NET Core application to my Linux machine living on the cloud.
My CI pipeline publishes my application, (specifically a .NET web application), zips it and then uploads by ftp.
Now, I've developed the following shell script which I will run as a service... |
I'm currently calling a fulfillment webhook with dialogflow in my node backend, performing crud operations on a firestore db. Is there a better, cleaner way to write these?
My code seems very poorly written but it works. I am striving to write cleaner more readable code so I'm looking for someone to give me some pointe... |
I want to write a custom ls command to learn rust.
This is what I've done as for the version 1.0. This display files and folders in a cyan or white if it's on a TTY. Otherwise I just print them.
I'm using atty and crossterm crates.
What I want reviewed
Is there a better way to deal with OsStr?
Is there a better way... |
I took a lot of pictures with my camera and I wanted to make a time-lapse out of them. The camera saved the pictures as picture1, picture2 ... picture956 etc. but the time-lapse software I'm using only accepts numbers of equal length like this: picture001, picture002, picture003 etc.
I thought Perl would be a good fit ... |
Ok, it's done...it took me a month but life is hard (and I'm pretty stupid myself) and I would like to know your opinions about it, do you think I can make it better?, more efficient?
#include <iostream>
using namespace std;
int main () {
unsigned long long int a = 600851475143;
unsigned long long int i = 1;
while (... |
I am very very new to programming, and this is my first day using Python.
I want to check to see if an input is of type 'int' and to proceed with my program if the user has entered an 'int', otherwise to print some error message, followed by a prompt to the user to try again.
What I have:
user_in = input('Input an in... |
Once again, I am reinventing the wheel here to understand the fundamentals of rust. In a previous question I requested feedback on my function that performed a hexadecimal to binary conversion. In this snippet, I am seeking some constructive feedback on converting from binary to hexadecimal.
fn main() {
let hexade... |
Problem description from an Iranian online course, translated with the help of Google Translate:
Tired of coding, Mehdi has gone on to his childhood games. But because he doesn't know who to play with, he has to change the rules of the game and play solitaire. To begin with, he wants to play solitaire "Walnut, Break O... |
I've never written a queue before and literally just took the concepts and tried to code something up. I decided to write a basic integer queue and as an example/driver I use a queue of size 5 which implements insert(), delete(), and display().
Please critique these implementations and comment if there should be any ad... |
I have two ways (middleware) of setting a specific header (if not set) to request but want to know if one is better/beneficial than the other and the reasons why.
Note: At some point I will need to log X-Request-Id value in every single application log I have. If this plan affects your answer, I don't know. Just saying... |
I am quite new to F# and just wrote my first program. It checks if the query exists in the brand list and returns the matching brand.
Query is the string you are searching for in the brand list. So someone could be looking for "Miso Power Washer X1000" the idea is that my function analyses the query to see if there is ... |
For my portfolio app using Django I made a thread that pulls out the usd exchange rates for various currencies every 6 hours and updates the database. The program kicks in as soon as the module module_stock.py is being imported.
Other than to make the thread to start in a function call, should I be aware of any disa... |
So I've written a class for storing user/device specific settings, but I've written the Kotlin pretty much like I would in Java:
import android.content.Context
import android.content.SharedPreferences
import java.util.*
class UserSettings {
private lateinit var _prefs :SharedPreferences
fun UserSettings(ctx ... |
I have to project the price for a publicly traded contract when the price should be approximately matching the targeted profit or loss. I have written the following code, runs under 0.02ms.. could be a faster and could be a bit more elegant as the code will get slower progressively depending on the iterations needed. I... |
Currently I'm going over the cracking the coding interview. I'm in the Linked List 2.1 question which is as follow:
Remove Duplicates, write code to remove duplicates from an unsorted
Linked List. How would you solve the problem if a temporary buffer is
not allowed?
I used a Hash, which breaks the temporary buffe... |
I have a script that converts a text file to html. The text file is an output of a program (needle). The function takes the text file as an input. I am aware the script is awful. I use this function in Django. I would like to improve it. Can you help me with it?. Here is the result file from the script.
def write_html(... |
I'm writing a JavaScript function for an array, based on a geographic sequence. \$[1, 2, 4, 8, 16]\$, etc.
This function needs to populate the next number in the sequence
$$item_n = item_{n-1} * 2$$
If there are more than \$10\$ items in the array, remove the first
(smallest) number.
If the array reaches \$2^{... |
I wrote a test that parses links from a web page, and in a loop, clicks on each of them, and then returns to the main page. But, each iteration is accompanied by parsing the entire web page again and again and overwriting the links array, although only one link is needed per iteration. I understand that this is ineffic... |
What does my code do?
I use Django and in the following snippet, I use a class together with a TemplateView to render an HTML page. I already tried to simplify it with methods, but my code still looks "messy" and unstructured. Do you have any more recommendations on how I could make it more clear?
class Index(LoginRequ... |
I am new to coding and to apply for an internship I need to solve several tasks. This is one of them. I wrote working code, but the program says it takes too long to complete. Help me speed up my code please.
Requirements:
Time limit - 1s
Memory Limit - 64mb
Input- standard input
Output- standard output
There is a ta... |
I wanted to give a shot to Modelling a Call Center from Cracking the Coding Interview. The problem statement is as follows:
You have a call center with three levels of employees: Respondent, Manager, Director. An incoming phone call must be allocated to a respondent who is free. If the respondent cannot handle the cal... |
The following app basically sums up the costs for an evening and calculates the costs per person. The user can input the description of the costs [String] (for example, round one = Spare Ribs Place, round two = Beer Place, etc.), the costs of the round [Double] (for example, 50$, 10.15$, etc.) and the amount of people ... |
I was trying to solve a problem on de-arrangements (Number of partial derangement such that exactly prime number discs are found away from their natural positions? (Any number of non-prime K disks may also be found in or out of their natural positions)).
Somehow solved it using recursion but my code fails (taking lon... |
When dealing with iOS app bundle, It is not convenient to get the file by its path, but loading it by its name.
Need to batch rename images recursively, with Mac Bash. And to make the name unique, the directory index should be numbered.
To rename files ,turn
Root----A----0.png
| |
| ----C----9.png
| ... |
I wrote a function in Java that edit file name, and replace each space char into dash char.
Currently I iterate all the files in a specific directory, iterate in each file name, creating a new file name, and replace the file in the directory.
I guess that the current complexity is \$O(N*M)\$ with
\$N\$ being the nu... |
I am using a set of data points (currently randomly generated), and drawing a line graph inside a box:
struct DrawLine: View {
var body: some View {
ZStack {
Rectangle()
.stroke(lineWidth: 1.0)
.fill(Color.purple)
.frame(width: InstrumentPrices.box... |
Assume directed graph with each edge being weighted by some positive float.
Problem: find all simple paths (in other words, [0, 1, 2, 0] is
simple while [0, 1, 0, 1, 2, 0] is not due to internal [0, 1, 0]
cycle) with length <= cutoff and "push" them using pusher
callback.
P.S. There exists some realtime engine ... |
I am solving a simple 1D steady heat question using spectral method. I am a long time MATLAB and Mathematica user and trying to learn Python. I compare only linear solving times and Python is way slower than MATLAB, which doesn't feel right. Can you please tell me why Python is an order of magnitude slower for only eve... |
During a project at my work I needed a convenient way to store values taking up the smallest amount of bits necessary, not in memory but later when they're serialized into an array of unsigned short ints. For instance, a value that could be between 0 and 7 was only supposed to be 3 bits long. I ended up developing my o... |
I am a hobbyist computer programmer trying to learn modern C++ (in this case C++17). I thought it might be an interesting challenge to write a tokenizer class for breaking down microsoft (and other) .CSV files into tokens. My tokens are simply a std::variant<int, double, std::string>, and I wrote an enum class to facil... |
It's only 38 lines of code and I haven't worked with web scraping that much before.
How heavy would my code be on their server?
It's for Deep Learning purposes and I haven't ran it yet but would it result in my IP getting banned a quarter way through once I start
downloading the 70k pdfs?
Also, I'm not sure how e... |
I implemented class Range as an equivalent to Python built-in range for practicing purposes. No features were added. Hope it mimics all aspects of range behavior, but maybe you can point out something I forgot. Also I tried to make the code efficient, that's why Range doesn't inherit from collections.abc.Sequence and d... |
I wrote a simple currency converter in Python. Right now, my currency
converter converts using the last available rate or converts using a
specific date.
Looking for:
I'd appreciate any tips about how I can improve my little script.
What new features would be nice to add to my project?
Many thanks!
PS. I'm ver... |
https://leetcode.com/explore/interview/card/top-interview-questions-medium/110/sorting-and-searching/799
Given a non-empty array of integers, return the k most frequent
elements.
Example 1:
Input: nums = [1,1,1,2,2,3], k = 2
Output: [1,2]
Example 2:
Input: nums = [1], k = 1 Output: [1] Note:
You may assume k is ... |
I am more than willing to use both a Promise library and an AJAX calls one if the situation calls for it. This base class sits at the very bare bones of my system and it needs to be done right.
My goal here was to create a bass class in JS that can be extended to help with AJAX calls using Promises. And so I did. But i... |
I made a simple dropdown menu which opens when clicked, and closes when the user clicks anywhere outside the menu. The following is the codebase:
function deactivateAllDropdownTriggers() {
document.querySelectorAll('.dropdown-trigger.active').forEach(function(elem) {
elem.classList.remove('active');
})... |
In my current BASH script project I am processing a string, which cannot have spaces.
At one point I get to where it is possible to have a series of digits. The series can be of any length, including zero, up to the abilities of the shell to handle command line arguments, and need not be a valid decimal integer. Leadin... |
I want to reduce boiler-plate code and write like this when developing in iOS:
let imgView: UIImageView = "share_fareware_text_bg"
Here is implementation code:
class ImageView: UIImageView, ExpressibleByStringLiteral{
public convenience required init(stringLiteral value: String) {
self.init(image: UIImage(... |
I'm trying to do some rudimentary DDD in validating my objects to ensure they are of a particular type. I.e. an Email object would always look like "my@example.com" and a NaturalNumber is always greater than 0.
However, I'm struggling to make it reusable. The closest I've got is a factory:
open class ConstrainedStringF... |
https://leetcode.com/problems/time-based-key-value-store/
Create a timebased key-value store class TimeMap, that supports two
operations.
1. set(string key, string value, int timestamp)
Stores the key and value, along with the given timestamp.
2. get(string key, int timestamp)
Returns a value such that set(key, va... |
I'm fetching some data by using bs4, and want to know why access speed gets slower as my program progresses.
I'm using thread, and I know threading isn't so fast because of GIL.
My problem is that my program gets slower gradually.
When the number of word is over 300,it become much slower than that of word is about 100 ... |
So I was tasked the following:
Given a list of strings, output a sorted string that consists of all
lowercase characters (a-z) from each string in the list.
Example
[aba, xz] -> aabxz
I tried this:
from collections import Counter
from string import ascii_lowercase
def merge(strings):
counter = Counter()
... |
I am writing a RSS reader Library which should be able to read the data from different sources. I am very new to writing libraries and not sure if I am going right with it.
These are my base interfaces with implementation
public enum ProcessType
{
Syndicate,
Atom,
API
}
public interface I... |
Recently I did an exercise to understand Akka. I implemented a trading system with Akka to process orders with Actors.
My code is like:
Order: Immutable class with acts as the messages in the system.
public final class Order {
public enum OrderType {
BUY,
SELL
};
private final int orderId... |
I've been learning Python for about 1 - 1 1/2 weeks now and just finished my first small project to help solidify what I've learnt. It's a very basic (bad) login / create account system that I run in PowerShell but just wanted someone feedback and thoughts as to how I'm getting on in regards to how long I've been lear... |
I wanted to understand memory and pointers better before I endeavour into file path manipulations for larger project. This is simple replace part of the string test function that I need to rewrite into struct to call upon. I used scopes to test for memory leaking and changes, I work on Windows 7, CygWin and notepad++. ... |
As per the Java documentation:
Interrupting a thread that is not alive need not have any effect.
Particularly, interrupting a thread between the call to start() and the invocation of run() has no effect.
So I wrote a Thread which can be interrupted even before it started, so that the interrupted state is communicated... |
I have written the script to run locally the needle program for a query against the subject files. It returns the highest percentage result file as a string. In addition it also converts to html file (write_html function).
Can you help me to improve the script?
subject_path = settings.MEDIA_ROOT+"subject_files/"
query_... |
In my job we use our internal CA, which runs on a Windows server. When I want to use its CRL on a Linux machine I have to do these steps:
download root CA and intermediate CAs
covert them to x509
merge into one file (CRL.pem)
For this I wrote the small script below, which I run automatically by timer unit (cron on sy... |
This function converts a string like:
/{?lang(2-5):lowercase}/{page(2+):lowercase}/{article}-{id:integer}*.html*
Into the following regular expression:
@^(?J)/(?:(?P<lang>[a-z\d\-_\W]{2,5})/)?(?P<page>[a-z\d\-_\W]{2,})/(?P<article>[\w\W]*?)\-(?P<id>[1-9]*?).*?\.html.*?$@
Ready to be used somewhere else, using preg_matc... |
I'm a beginner, and I have just written this basic code that simply plots a parabola in a graph.
Is it possible to make my code more efficient?
The process works by the creating lists of X and Y then adding range of numbers squared to the list Y and normal X to its list and then the function plot simply goes ahead and ... |
This is Leetcode problem 139: "Wordbreak"
Problem: Given a non-empty string s and a dictionary wordDict
containing a list of non-empty words, determine if s can be segmented
into a space-separated sequence of one or more dictionary words.
Note:
The same word in the dictionary may be reused multiple times in the... |
I've just recently completed this programming "challenge" called surgical strikes:
\$N\$ Indian Air Force fighter planes are located in different bases across the country. Each airbase is described by some integer coordinate \$(x,y)\$. The Air Force plans to do surgical strikes on a maximum of \$M\$ different targets ... |
I'm working on a practice algorithm problem, stated as follows:
There are eight houses represented as cells. Each day, the houses compete with adjacent ones. 1 represents an "active" house and 0 represents an "inactive" house. If the neighbors on both sides of a given house are either both active or both inactive, the... |
In Swift, I have a string like this
http://mnc-hdqp.oss-cn-shanghai.aliyuncs.com/user%2Fheat%2Fdefault.jpg?Signature=2BI%2BauSvy&Expires=1568682491&OSSAccessKeyId=LTAIQ8Lif1HHVkXd
Need to extract 2BI%2BauSvy, the value of key Signature
here is code: regex match, then use range to subtract the key ahead.
let key = "S... |
I use this script to block access to a one or more websites with vanilla JavaScript. I find that it helps me avoid some addictive news websites that make me depressed. (Credit to Marat Tanalin for helping me with the event handling.)
The script is aimed to be an all vanilla JavaScript imperative small script for person... |
When is it better to instantiate the sftp client globally vs inside a function as shown below? What considerations favor one method over the other?
For a long running service that polls indefinitely, would it better to instantiate globally so I don't need to instantiate a new client on each run?
Also, is there any diff... |
This is code, written by our dev team, and SonarQube tells me that the Cognitive Complexity is too high: 21, and the current (default, out of the box) metric limit is 15. I've had a go at reducing the complexity and would love some feedback.
For those interested, the full source code is also available on GitHub.
The co... |
I'm making a program to compare Borderlands 3 weapon damage over time in a graphic. There's still some work to be done, like implementing elemental damage, but I'd like to know if I'm doing a good job for now regarding the main firing logic.
My biggest concerns are:
General readability.
WeaponReload and WeaponFire ext... |
This is the repost of the following question as suggested by @HoboProber .
Again, if you don't know what is Schelling's model of segregation, you can read it here.
The Schelling model of segregation is an agent-based model that illustrates how individual tendencies regarding neighbors can lead to segregation. In the ... |
What do you guys think:
OPTION #1 (same font-face name and change font-weight)
@font-face {
font-family: ProximaNova;
src: url('/fonts/ProximaNova-Regular.ttf');
font-weight: normal; // THIS IS NORMAL
font-style: normal;
}
@font-face {
font-family: ProximaNova;
src: url('/fonts/ProximaNova-Semibold.ttf');
... |
I've got this custom hook that is suffering from a bad case of violation of SRP
This is a simple 5x5 board where a car can move around. Together with a server side check if the move is valid or not.
I'm thinking of moving directions to a useReducer hook. But problem is that I'm calling that using its index when I do th... |
Case 1: rank1_naming
This function takes two arguments
list_proteins_pattern_available
best_match_protein_name
Objective: Extract the three letter pattern from the both arguments.
Match the pattern and keep only the matched items. Extract the numbers
from list_proteins_pattern_available and also sort it. Find... |
I am making use of C++ and SFML to make a basic Pong game. I have made it so that there are two players who can control the paddle on each side and the ball will bounce off screen and paddles except the left and right sides of screen. Player can also pause and restart the game anytime.
My goal is to learn C++'s featur... |
I want to build Git class where i can store integers. FilesSet is where I store current state of integers. Commits' key is basically commit number so I can checkout pretty fast. Hashes is used for quick search of hashes that I need in commit part.
Update is for updating current state of integers.
In Commit I want to sa... |
Got this problem from Codewars.
There is a secret string which is unknown to you. Given a collection of random triplets from the string, recover the original string.
A triplet here is defined as a sequence of three letters such that each letter occurs somewhere before the next in the given string. "whi" is a triplet f... |
If I use node.addEventListener('click',Wyg.Editor.nodeClickedEvent); then when node is clicked, nodeClickedEvent has this===node. Since nodeClickedEvent is a static function in a class, I want this to === Wyg.Editor, so I wrote a helper function to simplify it.
Helper Function:
function fixThisFunc(object,functionName)... |
I just started to learn C++ and I decided to make a rock paper scissor game. It works very well but I would like to know how could I improve it further. Thank you very much in advance for your help.
#include <iostream>
#include <string>
#include <time.h>
int main()
{
using namespace std;
string playagain =... |
I understand this code is running properly and is grabbing from each excel file individually, but I want to create a for loop for using this data across multiple excel files
kinematic_viscosity = []
kinematic_viscosity_1= []
kinematic_viscosity_2= []
#*empty arrays for creating after loop in completed*
for dynamic... |
DESCRIPTION:
[Inspired by Chandler's GameOfCups with Joey in "Friends"].
Program gets 5-digit zipcode from user. (Assume user won't make a
mistake, and will enter exactly 5 digits).
Program awards points based on a series of rules, and reports the total
points earned at the end.
The... |
GitHub, NuGet
This component traces execution in a logical order instead of chronological as everybody else :)
For example, the following code:
static async Task MainAsync()
{
Op.Log.Subscribe(WriteLine);
using (new Op())
await Task.WhenAll(
from i in Range(0, 4)
... |
This is working code for input KML files into leaflet map
// Load kml file
fetch('lotA.kml')
.then( res => res.text() )
.then( kmltext => {
// Create new kml overlay
parser = new DOMParser();
kml = parser.parseFromString(kmltext,"text/xml");
console.log(kml)... |
I have some data…
let points = [(718, 620), (4596, 1280), (410, 333), (4597, 993),
(410, 337), (4597, 996), (428, 337), (4597, 1000), (431, 335), (4599, 1044)]
… that follows the pattern
[(pointStartOne.x, pointStartOne.y), (pointEndOne.x, pointEndOne.y),
(pointStartTwo.x, pointStartTwo.x) // ...
I need to structur... |
Can I use #define fori(i,n) for(int i=0;i<=n;i++) in Java?
And of course, Java doesn't have precompiler so we cannot do that in java. So I thought we can do that fori method either using stream() or manually defining a method. But I thought instead of just traversing why can't I put the third parameter as lambda expres... |
Next script returns NRPE friendly output. It checks percentage usage of all local filesystems.
Desired output if everything is ok:
OK | /=56;;;; /boot=20;;;; /opt=40;;;; /var=60;;;; (and exit_code0 = ok)
Desired output if something is wrong:
CHECK /var | /=56;;;; /boot=20;;;; /opt=40;;;; /var=93;;;; (and exit_code1 = ... |
The code consists of three functions:
Spans arbitrary vector (takes dimension as an argument)
Spans vector orthogonal to the one passed in the argument
Finds cross product between two vectors.
The code is following:
def span_vector(n):
'''n represents dimension of the vector.'''
return [random.randrange(-1000... |
I'm creating a filter with Linq in an ASP.NET MVC application. I was hoping I could get some tips on performance enhancements, aside from any possible performance enhancements.
I have a few questions:
Should I ToList before my extension methods that use .Select?
Would adding AsNoTracking help performance? If so, if my... |
I have been working through a tutorial on neural networks. I have then been translating the code to java, to help improve my understanding of what the code is doing.
The book mentions a way of speeding up the program:
Our implementation of stochastic gradient descent loops over training examples in a mini-batch. It's ... |
I wrote a simple timestamping filter that prepends each line with the UNIX timestamp in nanosecond precision as returned by clock_gettime, as well as the difference to the previous timestamp.
for i in {01..15}; do printf '%s\n' "input $i"; sleep 0."$i"; done | ./timestamper
BEGIN CLOCK_REALTIME. No monotonicity guar... |
I have been working on a vector library for a little bit now. And at this point the basics are down and I am looking for some tips and advic - this may include:
suggestions for things that might be missing and should be added
improvements for readability and of-course efficiency
if you have an important tip or adv... |
Let's suppose I have two lists:
list_b = ['cat.2','dog.6','bear.10','zebra.13']
list_a = ['cat','dog','bear','zebra']
I would like to create a dictionary with the desired output:
dict_ = {'cat.2':'cat','dog.6':'dog','bear':'bear.10','zebra.13':'zebra'}
I have two possible solutions. I am assuming the lists are not or... |
I'm currently halfway through a Python project, but would like a review before I spend too much more time on this to avoid going too far down a rabbit hole.
I had previously wanted to use HTML, CSS, and JavaScript, but I swapped to Python so I can get the current Window's user while opening my app.
At my work, we have ... |
I have created an Encryption and Decryption Algorithm that encrypts plain text using a given cipher and also decrypts it back to the original notation. It works great.
This was my code for a coding test and the reviewer told me that the class structure is inverse of what is the right way of doing it and that it is slop... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.