I am working on a project that needs to take a .bdf font file and turn it into a Numpy array. I am using the code below to turn the bitmap for the font into a numpy array. It currently works, I just feel that it's nearly impossible to read but I'm not sure if there's a better way to do it.
How ...
Problem statement: If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
NOTE: Do not count s...
I have the following implementation of quick sort (assuming an immutable array).
Comments?
const reorder = (arr, pivot) => {
larger = []
smaller = []
for (i = 0; i < arr.length; i++) {
if (arr[i] < arr[pivot]) {
smaller.push(arr[i])
} else if(arr[i]>arr[pivot]) {
larger...
The below query takes roughly 2 minutes for almost 2000+ records.
The tables are indexed.
what might be causing the issue?
SELECT
S_MATRIC_NMBR PRIMARY_ID,
NVL(INITCAP(S_NAME), ' ') LAST_NAME,
(
CASE
S_SEX
WHEN 'M' THEN 'Mr'
WHEN 'F' THEN 'Miss'
ELSE ''
E...
I want to get table names and column names from queries in a dataframe. The dataframe is like this:
Date Query
29-03-2019 SELECT * FROM table WHERE ..
30-03-2019 SELECT * FROM ... JOIN ... ON ...WHERE ..
.... ....
20-05-2019 SELECT ...
and I run function to that dataframe...
Well, if you have a working code and is looking for a code review, you can check the site guidelines of codereview.stackexchange.com. However, it seems that this kind of question does not fit this site since you don't have any attempts and the specific roadblocks you're running into — Andreas56 secs ago
TLDR: (Sent here from StackOverflow) The code I've presented is working. I'm looking for a code review from more experienced devs to know if what I have done is OK, and to learn if there are better practices I should focus on to expand my skills and understanding.
Hello. I have completed versi...
input = ['A','A','B','C','C','A','A','D','D','D','D','D','E','A','A']
requiredElements = 3
output = ['A','D','C'].
it is possible to change the required elements when it is changed to 4 it must return array of four commonly occuring elements
This the flow:
login
get two tokens (access token and refresh token) and two expiration time (one for each token) from server
from now on the Angular application can determine if we're logged in by monitoring the refresh token expire time. if the refresh token is still valid then it doesn't mat...
I was messing around with ssh and decided to write a python program that scans for any connections that aren't from the system, then terminates them. It works well for many connections from my iMac to my MacBook. A more in-depth explanation of the program is written at the top of the code. I'd ap...
I'm thinking of importing separate language modules (or config data) to be used when chosen by the user. Everything else besides the displayed texts should stay the same, and (I think) this should help save memory since only the language used is being imported and read.
Below is some sample code...
Does anybody know how to avoid error: Got AttributeError when attempting to get a value for field data_from_file on serializer DataSerializer in below code?
# models.py
class Data(models.Model):
data_from_file = models.CharField(max_length=20)
# serializers.py
class DataSerializer(serialize...
No, you cannot selectively turn off language features for yourself in Java. This would need to be enforced in code review. Maybe you could write a static analyzer for this and hook it into your build. — Thilo55 secs ago
You should ask yourself why you need to do this in the first place. Usually it's because your application model isn't designed to fit your application needs, but rather to fit whatever shape the data you get from the server has. If your model had fit your application, you would probably have nested update functions for each type that construct the new model level by level, rather than global functions that each does everything in isolation. This is an architecture question that is probably too broad to properly answer here. You might try a forum or Code Review instead. — glennsl41 secs ago
I'm voting to close this question as off-topic because it belongs to Code Review forum. — sophros43 secs ago
Hello W.D and welcome to Stack Overflow. As sophros said, you should ask this question here. Anyway, you should explain the problem in your post, most people don't want to watch youtube to understand it, and explain your approach. — Corentin Limier14 secs ago
(You might get eye-cancer today. So if you do not feel ready for this. Leave!)
This Server is trying to handle Clients communicating with each other. Because I was not willing to actually give every client a name, they are named by their socket's file descriptor. This is my first application whi...
my code detects if a cycle is present in a graph using Union find algorithm with Weighted tree analysis and path compression.
It works and I have included test cases.
# check cycles in graph using union find
# weighted tree balancing added
from collections import defaultdict
class graph:
d...
I have the below code that performs well until input size reaches 1000. After that, it takes more than 2 milliseconds to finish. Any help?
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
public static void Main(string[] args)
{
var numbersCount = int.Parse(Con...
I write a lot of TODO's but I never keep track of where they are.
This program will search through files (and folders if needed) and find any TODO comments and their line number.
The details will be printed to the screen and a file will be generated in the folder which is a csv of the files and...
We're having a small debate in work about the following piece of code:
private string GetNextFileName(string fileName)
{
int index = 1;
string nextName = $"{fileName}_{index}.png";
while (File.Exists(nextName))
{
nextName = $"{fileName}_{++index}.png";
}
return...
I need to reduced following java method complexity according to sonar acceptable level. now ,it given this like sonar issue.
need some expert help to do this.
public List<X> Y(final DateTime treatmentDiscontinueTime,
final List< P> vali...
In ionic, I want to get the firestore document id to display the stored information of the user who logged in. I set the documents name to the user's email like Collection[name] = Users Document[name] = [email protected]
Here is how i set the document name in auth.ts
import * as firebase from 'fireb...
This program opens a file and prints the text out to the terminal 1 character at a time and at a predetermined speed using time.sleep()
Simple and maybe, if you think like me, pretty cool..
GitHub
from time import sleep
import sys
BLINK = 0.2
chars_in_line = 50
def open_file(fn):
with op...
This code computes the Minimum Spanning Tree of a given graph using Kruskals Algorithm.
It works successfully and I have provided test cases within the code.
I would like feedback on code efficiency (Choice of ds and functions/function size) and anything else to improve the code (Aside from pep...
As a practice exercise, I implemented a cellular automaton (Conway's Game of Life) in python (with help from this tutorial).
I am very curious, if this code follows common best practices and I am wondering how to improve the code in terms of performance and readability.
import numpy as np
impo...
That said I'd be curious to see the runs-all-day VBA code. Might be a good idea to put it up for peer review on Code Review. — Mathieu Guindon28 secs ago
I'm converting a response I get from SQL that looks something like this.
{
"COLUMNS":["SUCCESS","RETMESSAGE"],
"DATA":[[true,"Order Approved"]]
}
Into a JSON object like this.
[{
"SUCCESS":true,
"RETMESSAGE":"Order Approved"
}]
I have a solution but I don't like it. I'm looking for ...
Why the downvotes? Roko is right - this is better suited for codereview, but as far as I'm aware, that doesn't mean it isn't suited for StackOverflow. Perhaps I'm mistaken. — Tyler Roper15 secs ago
I'm trying to create an abstraction for peripherals. It'd be straight forward if all of them shared the same interface, unfortunately, they do not.
For example, let's say I have a peripheral A which I can communicate with and power it on or off. I also have a peripheral B, which I can communicat...
As I expliain in my rant, I have been searching for a replacement to hand-crafted POSIX-make-compatible makefiles to manage my dotfiles (which use symlinks). I decided the simplest thing to do would be to roll my own.
Requirements:
written in language likely to be immediately available on majo...
Stackoverflow is for coding problems and debugging questions, not for help refactoring your code. Your question is probably better suited on codereview, but read their guides first to make sure your question is on-topic there: codereview.stackexchange.com/help/how-to-ask — Max Vollmer15 secs ago
I am using NearestNeighbors for a text-based recommendation system. The purpose of the model is to return some set of codes
For example:
copper tube ->1010101
Aluminium pipe ->2020202
The training set contains two columns(aka features) : keywords(like copper tube) &
code(like 1010101).
from sk...
This style of question, where you have a functional routine but you want opinions on style or help with refactoring is better asked on codereview.stackexchange.com (code review is not an option for migration that I can access in the review queues) — Chris Schaller49 secs ago
By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total
from top to bottom is 23.
3
7 4
2 4 6
8 5 9 3
That is, 3 + 7 + 4 + 9 = 23.
NOTE: As there are only 16384 routes, it is possible to solve this problem by trying every route.
However, ...
I am reading a lot about chess impl and I have thoughts...
In a lot of places I saw that Piece is the parent and all the types that can be as elephant are the children.There is abstract method : isValidMove(Box start, Box end, board)
Box(is a Coordinate)
Every subclass implements the isValidMove....