instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
So, I fixed my problem with a public ViewModel for my MainPage like this:
MainPage.xaml.cs:
private static MainPageVM Data = new MainPageVM();
public MainPage()
{
this.InitializeComponent();
SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;
this.DataContext = Data;
this.SizeCh... | stackexchange/codereview |
It works and does what is supposed what to do btw.
<?php
ob_start();
session_start();
include("php/connect.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Welc... | stackexchange/codereview |
I'm trying to integrate Arrow-kt's Either into an application that needs to parse and validate filter input. This input is a comma separated list of criteria. Either sound like a good candidate for that job because it does both jobs at the same time.
Big-Picture
I've got a parser that takes care of the first step:
inte... | stackexchange/codereview |
Given a set of items with a weight and a value, this problem gives the subset of items which maximize value so that their combined weights is less or equal than a given maximum weight. This solution runs in \$O(w\cdot n)\$ where \$n\$ is the number of items and \$w\$ is the max weight.
#[derive(Debug, Clone)]
struct It... | stackexchange/codereview |
This is a script I made for the ESP8266 that uses the Wi-Fi chip and creates a new Access Point every 5 seconds in order to display a message on WiFi lists on nearby devices that looks like this:
The code is:
#include <ESP8266WiFi.h>
const char* ssids[] = {"Never gonna give you up","Never gonna let you down","Never g... | stackexchange/codereview |
I have created a custom class (Generic) in C# for the Hanoi problem. and I am not sure I did the correct thing.
[DebuggerDisplay("Count = {Count}")]
[System.Runtime.InteropServices.ComVisible(false)]
public class HanoiStack<T> : IEnumerable<T>, ICollection, IEnumerable where T : IHanoiStack
{
privat... | stackexchange/codereview |
I built a container that can hold objects of various types, and look up an object convertible to a given type. I wrote something about my intended use-case here:
https://stackoverflow.com/questions/58562173/typesafe-way-to-provide-enriched-dependencies-to-derived-classes-in-c
Basically I want to be able to throw a bun... | stackexchange/codereview |
I have a simple function that takes a string and reverses it:
def reverse(string):
begin = 0
end = len(string) - 1
strlist = [i for i in string]
while(begin < end):
temp = strlist[begin]
strlist[begin] = strlist[end]
strlist[end] = temp
begin += 1
end -= ... | stackexchange/codereview |
I'm trying to optimize my solution to this LeetCode problem:
Write a program to find the nth super ugly number.
Super ugly numbers are positive numbers whose all prime factors are in
the given prime list primes of size k.
My working, accepted solution:
import heapq
class Solution:
def nthSuperUglyNumber(self, n... | stackexchange/codereview |
This is a follow-up question for A recursive_reduce_all Template Function Implementation in C++. As G. Sliepen's answer mentioned:
std::is_arithmetic_v<> checks whether the type is basically an integer or a float, nothing else will match.
I am trying to implement an arithmeticable concept which checks whether the ope... | stackexchange/codereview |
Suppose you have two lists:
One is a "dictionary", a list of words
The other is "documents", a list of documents (which in turn, are strings)
I would check whether a dictionary's word is within a document.
# DOCUMENTS
doc1 = "My sister likes to have sugar, but not my father."
doc2 = "Doctors suggest that driving may ... | stackexchange/codereview |
I've found my app, which uses the SortedList, has a poor performance.
So I decided to try to improve the performance of my app.
I created the FastSortedList class which I think is faster than the original one.
public class FastSortedList<TKey, TValue>
{
IComparer<TKey> _comparer;
List<KeyValuePair<TKey, TValue>... | stackexchange/codereview |
Left limit, right limit and the digit to be counted is entered. This code works only for whole numbers i. e. from 0 to n. This code returns the number of occurence of the digit n in the given range. Please review this code and suggest improvements.
#include <iostream>
int count_n(int l, int r, int n)
{
if (r <= l)... | stackexchange/codereview |
I am working on a website for a group of artists and want to know of a way to make my code cleaner and my website run faster. I am working on the gallery page, and there are over 100 pictures I want to show. I have been entering them in as shown below, but I know there must be a better way to try and do this, but I jus... | stackexchange/codereview |
I have developed some free standing functions to provide hex dumps for buffer (std::string) contents.
You can see it working in action here.
The purpose is for debugging diagnostics to print buffer contents to a (logging) stream, in a format similar as wireshark does.
Any proposals for improvements are welcome.
Here's ... | stackexchange/codereview |
I am applying to a university to study Computational Linguistics, and as I read, it would be recommended to have a background in Artificial Intelligence.
The Admission board asked me to prepare a portfolio of my works, and I am considering to add this solution to the portfolio.
I have been lazy to develop an AI to bypa... | stackexchange/codereview |
The following classes are used for web development. And I was wondering if I'm implementing them correctly specially the Base class.
This is a version 2.0 of the question the classes are as follows:
MyPDO
Session
Security
Base
Examples:
<?php
//using the autoloader
require "../classes/autoloader.php";
// checking if... | stackexchange/codereview |
I'm working on a "framework" for Telegram bots and right now everything "just works". I'm now in the process of rethinking about what I wrote and one of the things I dislike a lot is how I implemented the API client.
Right now I have an interface (TelegramBotApi) which maps every API endpoint to a method. This interfac... | stackexchange/codereview |
I have written a simple routine to check if the number of parentheses balances, so [{}] would return true since all parentheses which are opened are closed in the correct order. [)({}] would return false since you cant start with a closing parentheses.
Is anyone able to improve the routine - (efficiency, readability) s... | stackexchange/codereview |
I'm studying functional programming, and I have the following problem to solve. It's an simplified version of Caesars Cipher:
You need to write a function, which will take string encoded with Caesar cipher as a parameter and decode it.
The one used here is ROT13 where the value of the letter is shifted by 13 places. e... | stackexchange/codereview |
I have simple hierarchy which looks [a little bit] like the Optional<?> from Guava:
public abstract class Result<T> {
public static <ResultType> Result<ResultType> get(ResultType result) {
return new PresentResult(result);
}
public static Result<?> absent(Throwable exception) {
return new ... | stackexchange/codereview |
This is a problem that I had in mind for a loong time and today I decided to give it a go, the basic idea is you enter a number/sum and the program outputs all the possible ways this sum can be formed let's say we have 3 as input the output will be (1, 1, 1),(1, 2) I don't think that the code is really efficient so any... | stackexchange/codereview |
As the title suggests, I'm building a MySQL parser in python. The intention of this is to better support application development by managing migrations in a more declarative way. You can read about the underlying project at its github page if desired.
My immediate focus is on parsing CREATE TABLE, INSERT, and comment... | stackexchange/codereview |
So, I have made a BIG prank in VBScript.
First part is to prank with a Dummy HTA splash screen using an encoded PNG image inside it (Not included) and kill all windowed processes+explorer and keep it for a few seconds.
Then launch a internet explorer window in kiosk mode and launch fakeupdate.net according to windows v... | stackexchange/codereview |
I wrote my first application about custom exceptions and catching them. Here is the GitHub link.
I Have 3 types of custom exceptions:
TimeException (validate time: hours, minutes)
MovieException (validate movie name, director, genres) - from properies file
SeanceException (validate price, room, movie length) - from ... | stackexchange/codereview |
Hello dear colleagues.
As an exercise for Java streams, I've written simple program, which scrapes links to references from a news portal. Basically, I wanted to find out, which portals are the most referenced.
Right now, I ended up with the following piece of code:
final Map<String, List<URL>> hostToURLs = Analyzer.ma... | stackexchange/codereview |
With the help of some people here and there, I wrote the module below which works very well if the file targets.csv is not too big.
As soon as this file exceeds 100 MB, a MemoryError is returned.
The problem is that I used numpy to make the computations faster (and they became really fast compared to the previous versi... | stackexchange/codereview |
I am learning basic data structures in Python.
I'm not confident enough if my implementations are OK or I miss any corner cases.
So please check my code for Singly Linked List and Let me know where I can improve.
"""
Singly Linked List Implementation
"""
class Node:
"""
Constructor for Node class
takes ... | stackexchange/codereview |
I have a working SQL statement which shows the following:
Player
Champion
Role
Total Kill/Death Ratio
Total Kill+Assist/Death Ratio
Total Win %
Difference between Ratio from one month ago
Difference between KA Ratio from one month ago
Difference between win % from one month ago
However, I don't think it's quite as op... | stackexchange/codereview |
I am developing an application to validate the interaction between activities through intents.
I created 5 ImageButtons with an image for each. Each button is a movie and if you click any of them, it's directed to a new activity with a synopsis of the film. In the activity with the synopsis, there is an "up navigation"... | stackexchange/codereview |
A puzzle I was given:
Description:
Write a method that returns the "pivot" index of a list of integers.
We define the pivot index as the index where the sum of the numbers on
the left is equal to the sum of the numbers on the right. Given [1, 4,
6, 3, 2], the method should return 2, since the sum of the numbers ... | stackexchange/codereview |
I need to find a root of strictly monotonic function f (only raising or only lowering). There is only a one root of a function.
If given range from a to b doesn't contain root (fabs(f(a)*f(b) is not lower or equal than 0), we need to change range, since the assumption is that there is a one root, so we need to move on ... | stackexchange/codereview |
As part of a game engine I am creating, I am in the process of writing a bunch of math classes (vector2/3/4, matrix2/3/4, and quaternions to start with).
Vec2 class:
import math
import random
class Vec2(object):
def __init__(self, x, y):
self._x = float(x)
self._y = float(y)
@property
def ... | stackexchange/codereview |
I have written a simple state machine. Comments and feedback are welcome.
#include <stdio.h>
#include <stdlib.h>
typedef enum Event
{
eEVENT_X,
eEVENT_Y,
eEVENT_Z,
}Event;
typedef enum States
{
eSTATE_X,
eSTATE_Y,
eSTATE_Z
}States;
int e = eEVENT_X;
int s = eSTATE_X;
struct state_transition... | stackexchange/codereview |
I currently have 2 dataframes, A and B. These dataframes are generated in runtime, and increase in size according to parameters in the program execution.
I need to evaluate how many times a value in dataframe A is lesser than all the values in dataframe B.
For example:
Dataframe A
+-----+-------+
| id | value |
+-----... | stackexchange/codereview |
What I'm trying to accomplish here is to pull a table of open employment positions with AJAX, filter out the garbage code that comes with it, put each <tr> from the response into its correct category <div> according to the type of position.
The trick is that there are no ids or class names on the <tr> being pulled mak... | stackexchange/codereview |
This is a very simple for loop, but I find it very, complex-looking. I hope you can give me some insight on how it may be improved.
int Tindex = 0;
int16_t Test[960];
int TestSize = SampleSize / 2; //Test is 16Bit, Half size of 32bit
int TestChannels = 2; //Stereo
float copy = 0; //Used to store Audio data used to Mix... | stackexchange/codereview |
The following code is working exactly as it is expected to work, the thing is that I'm sure that it can be written in a more efficient and less verbose way, any reviews?
JavaScript:
$(document).ready(function() {
$('.hidden-content').hide();
$(".hidden-content-reveal").click(function() {
var $i = $(this... | stackexchange/codereview |
I am doing some pixel operations in Python, which obviously uses a lot of processing power and makes the program extremely slow. I have these nested loops:
for x in range(-1, 2): #for the left, center and right row of pixels next to this pixel
for y in range(-1, 2): #for the top and bottom row of pixels nwxt t... | stackexchange/codereview |
My employer gave me a sit-stand desk, but I was forgetting to use it: I just sat almost all day. So for fun and learning I wrote a simple JavaFX reminder app to remind me to alternate between sitting and standing. The app is pictured below:
In the screenshot the app is telling me to stand, and it shows the time the re... | stackexchange/codereview |
I have a LINQ 2 SQL query that needs to run a subquery in the where clause. The subquery just returns the largest date (from a date column) that is less than or equal to another date (an input to the function).
I originally had it like this (not this in the where clause of an outer query):
skew.CalibrationDate.Date == ... | stackexchange/codereview |
I have a batch job that contains a lot of items. I need to split these items into 4 categories - 1,2 category should be moved to a separate jobs as is; 3,4 categories job be additionally checked on validness and split into separate jobs - invalid items should be moved to a separate jobs.
Roughly diagram of the expected... | stackexchange/codereview |
Consider the following crossfilter / dc.js app (screenshot):
<!DOCTYPE html>
<html lang="en">
<head>
<title>Data Exploration Tool MVP</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHA... | stackexchange/codereview |
I'm wondering and actually playing in typescript playground with generics functions. The question is, is the code below readable? If not what kind of approach I could use to make it more typescript way and more readable?
Working example here
I implemented some basic functions like foldl, map and filter to experiment ge... | stackexchange/codereview |
I would like to get opinion if I am doing this right. I am creating a helper class that is globally accessible to my whole project. I want it to be easily called like Facebook.loginUser()
My code is like this:
class Facebook: NSObject {
class func LoginUser() {
println("Login user...")
}
}
And on usage just c... | stackexchange/codereview |
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#define STACK_SIZE 100
typedef struct _stack
{
char *mem;
size_t size;
int top;
} STACK;
STACK *stack_create(char *mem, size_t size);
void stack_push(STACK *stack, char c);
char stack_pop(STACK *stack);
char stack_peek(STACK *const stack);
void st... | stackexchange/codereview |
In the code below , i'm only able to get PHP arrays in javascript to work when I hard code the value . Is this the only way to get it to work, or is their a way to copy the entire PHP array into Javacript . Right now I'm tempted to just create a function chart() for each set of PHP array values. As in rather then writi... | stackexchange/codereview |
Now that we can move across the bridge, it's time to finally set up the problem so that it can be solved. A reminder of what the assignment is:
Welcome to the Bridge Crossing Problem. Person Pn can cross the bridge
in n minutes. Only one or two persons can cross at a time because it
is dark, and the flashlight mu... | stackexchange/codereview |
This is simple student information system project where you can do following things:
Add Records
List Records
Modify Records
Delete Records
To store data a .txt file is used.
I just want an honest critique of my code so I can improve.
#include<iostream>
#include<vector>
#include<string>
#include<fstream>
using... | stackexchange/codereview |
Please help in improving the code. I would like to hear comments on syntax and an approach to development. This is my first experience in writing a simple application for the site.
window.onload = function() {
/* инициализация таблицы-прайса
Вначале проверяем наличие таблицы-прайса на странице.
Класс табли... | stackexchange/codereview |
-I have a ListView, and its SelectedItem property is bound to EmployeeModel SelectedEmployee in my VM, and it implements the Set method from MVVM Light. (Basically, OnPropertyChanged, but the MVVM Light version.)
-I have three more ListViews (more, but for simplicity's sake, we'll say three.) They are bound to the fo... | stackexchange/codereview |
I've implemented a Tic Tac Toe game with a public method checkWin() to check if the game has a winner. This is my code.
public class TicTacToe {
int size;
int [][] board;
public TicTacToe(int size){
this.size = size;
board = new int[size][size];
for (int i = 0; i <size ; i++) {
... | stackexchange/codereview |
I'm currently learning about Dynamic Programming and solving a "coding question" related to the topic.
Given an array of non-negative integers, you are initially positioned
at the first index of the array.
Each element in the array represents your maximum jump length at that
position.
Determine if you are able to reac... | stackexchange/codereview |
I need to be able to access a number of different payment methods in a common list. They can be different methods - credit card, cheque, direct debit etc. The only common attributes are the payment method id and PaymentMethodEnum. I would then be casting the payment method to it's appropriate type to get the extended p... | stackexchange/codereview |
I am building a web app with a single (not pooled) full time (jdbc) connection between static classes and the database. This is expected to be a low traffic site and the static methods are synchronized. In an effort to speed up access to product information, I am trying PreparedStatements for the first time. As I test,... | stackexchange/codereview |
int get_digits (int num)
{
if(num < 10)
return 1;
if(num < 100)
return 2;
if(num < 1000)
return 3;
if(num < 10000)
return 4;
if(num < 100000)
return 5;
if(num < 1000000)
return 6;
if(num < 10000000)
return 7;
if(num < 100000000)
return... | stackexchange/codereview |
Is this algorithm good or can I improve it?
static void QuickSort(int[] a)
{
QuickSort(a, 0, a.Length - 1);
}
static void QuickSort(int[] a, int start, int end)
{
if (start >= end)
{
return;
}
int num = a[start];
int i = start, j = end;
... | stackexchange/codereview |
I basically want to convert all categorical column in an R dataframe to several binary columns:
For example, a categorical column like
Company
-------
IBM
Microsoft
Google
will be converted to 3 columns:
Company_is_IBM Company_is_Microsoft Company_is_Google
1 0 0
0 ... | stackexchange/codereview |
The sole purpose of this post is to see how a production quality developer would approach this very simple problem. I am a fresh graduate and do not have a professional development experience. What are the cases and approaches that I should start considering when developing in a production environment? Please feel free... | stackexchange/codereview |
I have this project in data analysis for creating a ranking of tennis players. Currently, it takes more than 6 days to run on my computer.
Can you review the code and see where's the problem?
Project steps:
I have a database of 600,000 tennis matches called matchdatabase.The database fileds are a) winner name, b) lose... | stackexchange/codereview |
I'm trying to calculate with SUMIFS and COUNTIFS some data.
The output sheet looks like this:
I've hidden some irrelevant or sensitive data to make it easy to go to the point.
My code runs an array on this worksheet and calculates per each day and user some KPIs I need from this worksheet:
The calculation is pretty s... | stackexchange/codereview |
I implemented the heaviest stone algorithm, but I am not sure about its time complexity. I'm doing sort which is O(nlogn), but it' inside a while loop.
Problem:
We have a collection of stones, each stone has a positive integer weight.
Each turn, we choose the two heaviest stones and smash them together. Suppose the st... | stackexchange/codereview |
I was assigned a task to fix the SQL injection flaw reported by a code analysis tool. I am not the original author of the code. I am fairly knowledgeable with SQL.
public int ExecuteNonQuery(string query, SqlParameter[] parameters)
{
using (SqlCommand command = CreateCommand(query, parameters))
{
i... | stackexchange/codereview |
I am trying to determine the correctness of a helper method within my MaxHeap class.
The goal of this helper method is, given the index of any node in the Max Heap, sink it to the correct level in the heap so that all of its children are greater than the node, and its parent is greater (essentially sink it to the corre... | stackexchange/codereview |
I'm working on my graduate project and I had stumbled upon a somewhat dilemma, I've managed to solve it with some workarounds but I have my doubts that this is the most efficient way to deal with this problem.
I'm writing a class to deal with the Plesk API and making it as flexible as possible for easy use.
Here is the... | stackexchange/codereview |
I am writing a program to count the number of uppercase and lowercase letters in a string. I came up with something that works, but as I am still a beginner I have a feeling writing the code this way is probably considered "clumsy."
Here is what I have:
stri = input("Give me a phrase:")
stri_up = 0
stri_lo = 0
for i i... | stackexchange/codereview |
I was wondering if I could get some feedback on the library I created to persist data online.
JitterPushDemo.java
public class JitterPushDemo {
public static void main(String[] args) {
Jitter jitter = new Jitter("scores");
// create hash map to map scores to players
HashMap<String, Stri... | stackexchange/codereview |
It's been a while since I've done any sort of programming, and my first time in Python. I'm just looking for any general feedback and tips since this is my first program.
# rock, paper, scissors game
import random
playerWin = 0
aiWin = 0
guess = 0
print('You are playing rock, paper, scissors. If you would like to quit... | stackexchange/codereview |
This Bash program parses day, month, year and month and year from arguments:
#!/usr/bin/env bash
for arg
do
day= month= year=
case $arg in
*/*/*|*-*-*)
read -r year month day <<< "$(date '+%Y %m %d' -d "$arg")"
;;
????/??|????/?)
IFS='/' read -r -a arr <<< "$arg"
month... | stackexchange/codereview |
I came across the question about creating memory-efficient Ruby pipe class with lazy evaluation. Some code is given to effectively create a pipeline of commands using lazy enumerators. I have been messing round with it and have implemented a tee command shown below. I feel like there is a better way to do it though.
cl... | stackexchange/codereview |
I need to write a program which will find a prime number, greater than the given n.
Can it be done simpler?
#include <stdio.h>
int isPrime(int n)
{
int i,j=0;
for(i=1; i<=n; i++)
{
if(n%i == 0)
j++;
}
if(j == 2)
return 1;
else if(j > 2)
return 0;
}
int fun(u... | stackexchange/codereview |
How can I improve readability of this code? indentChar needs to be reused elsewhere.
toCoordinate = dropWhile ((||) <$> (not . indentChar) <*> (=='(')) >>> takeWhile(/= ' ')
indentChar = (||) <$> isAlpha <*> (=='(')
Desired result:
*Parse> toCoordinate " \\--(my.coordinate - from outerspace)"
"my.coordinate"
| stackexchange/codereview |
So I am essentially a complete newbie to programming, and have been attempting to learn Python by completing the Project Euler problems. I haven't gotten very far, and this is my code for problem #3 :
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
Altho... | stackexchange/codereview |
I am trying to programm the Abelian sandpile model in VisualBasic. Also, here is a youtube video made by Numberphile about the very same topic.
Here is a picture (\$2^{20}\$ grains of sand) I made with my programm:
The current version workes fine - for now.
However, with large amounts of sand the calculation takes a ... | stackexchange/codereview |
I likes my use of functions so I'm mostly looking for little things but if you see something tell me :)
#include <iostream>
using namespace std;
void addQuarter(double &num); void addDime(double &num); void
addNikle(double &num); void addPennie(double &num);
bool quarterValid(double num, const double finalNum); bo... | stackexchange/codereview |
I am a beginner in Python and PyGame and wrote a memory game. I think there are lot of things I could have done better. I am looking for some advice on how I can improve the design and refactoring of the code.
# the imports
import pygame
import random
from itertools import product
from pygame.locals import *
from pygam... | stackexchange/codereview |
I am new to java and graphics, and I am creating a java program that draws a star. It took me a few hours, but I finally have it drawing a star, but I am wondering if there is a better way to write the "draw" method without having to repeat myself over and over. I am trying to use loops to minimize all this code, but I... | stackexchange/codereview |
I made a new version of this which was actually not behaving correctly, because it showed duplicated values, it just didn't add them again, this is the link to that program, someone point at correctly I think that the problem didn't state that student should use an ArrayList, but an Array, so I made this program again ... | stackexchange/codereview |
I have finally found some time to redo the last tic tac toe game I posted. I have gotten rid of "Magic Numbers" as well as any typos(if their are any please point them out but I think i rid myself of them...hopefully). I have updated the way the code is implemented as well as added a header titled "Constants". This cho... | stackexchange/codereview |
I am trying to implement a genetic algorithm to solve (Diophantine Equation).
For instance, a + 2b + 3c + 4d = 90 where a, b, c, d are positive integers.
After reading some books and following tutorials, I finally wrote this code, but as I am new to programming and GA, I don't know if this is a good implementation.
#in... | stackexchange/codereview |
This is my code that works:
foreach (var r in rlist)
{
if (r.IndexOf("_") != -1)
{
int id = int.Parse(r.Split('_')[1]);
var x_tmp = (from x in db.tblX where x.x_id == my_id && x.x_id == id select x).First();
x_tmp.order = someNumber;
}
}
db.SaveC... | stackexchange/codereview |
I've brute forced solve Project Euler 14. This is my first attempt at trying to solve it, by caching already solved answers, and skipping them as I run it, I am finding the program take's almost twice as long as the simple brute force method of checking each number.
It works, but I could also use some insight on how to... | stackexchange/codereview |
I have a snippet of code to get indices of a 2D numpy array if the maximum value of that raw is greater than a number.
index = []
for i in range(np.shape(soft_p)[0]):
if soft_p[i].max() > 0.4:
index.append(i)
I was wondering if there's a better way to do it using numpy conditions and functions
| stackexchange/codereview |
I have an mail object that returns its headers as an Enumerator of Header objects, which have two methods, getName and getValue. I need to convert that to a nice Clojure map so I wrote this short function:
(defn extract-headers [message]
(reduce (fn [hs h] (conj hs {(.getName h) (.getValue h)}))
{}
... | stackexchange/codereview |
I have a lot of Command objects. Each command has lots of Task objects. Tasks and commands are related. Each command wants to know which task belongs to it. Where each task wants to know which command it belongs to.
class Command:
def __init__(self, date):
self.deadline = date
self.tasks = []
... | stackexchange/codereview |
I have created the following view extending the JPanel class, the objective of this view is to allow the user to perform 3 CRUD operations create,delete and modify on the entity "Attribute", this entity belong to an entity User or Client, so when the user wants to perform CRUD operations it has to specify if the operat... | stackexchange/codereview |
I have just finished learning basic-intermediate Python subjects and wanted to test myself. This word-guessing game is one of the first programs I have written.
import random
def pick_random_word():
word_list = ["python", "c", "java", "swift", "html", "css", "go", "ruby"]
random_word = random.choice(word_lis... | stackexchange/codereview |
I'm working on a site that has to do with movies. I am consuming the Rotten Tomatoes API to get my movie information and using EF5 with a code first approach to get that into the database. I'm using MVC4. I am struggling to come up with a design that makes sense and accomplishes what I need to in an efficient manner wh... | stackexchange/codereview |
Please can any code experts review and improve my code?
HTML
<!DOCTYPE html>
<html>
<head>
<title>API</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=font1|font2|etc" type="text/css">
<link... | stackexchange/codereview |
This program tokenizes an arithmetic expression specified in infix notation. It is one of my personal projects and I would love to receive expert advice.
After compiling, you can run the program with one command-line argument:
$ tokenize <arith_expr>
This is an example of running the program:
$ tokenize "3^2 + 4.5 * (... | stackexchange/codereview |
I just have a somewhat simple question on coding practices. I have never written a large application before and I am currently working on building a game engine in JavaScript. The part that confuses me is what the best method of organization is in this particular case.
I have my base engine class, Engine, a graphics cl... | stackexchange/codereview |
My data set is a list of Edges which are passed as a pair of integers. Based on that, I have the following graph implementation for BFS. Could someone please review my code and comment on errors/omissions/efficiency and other points.
#include <queue>
#include <iostream>
#include <vector>
class Graph {
private:
i... | stackexchange/codereview |
I did an exercise (open-ended - without an answer) from a JavaScript book (chapter about functions).
Given array of passengers of a flight with their names and ticket types and one need to emulate stewardesses asking passengers for service during the flight depending on their ticket type (first class or coach) (stewa... | stackexchange/codereview |
I want to distinguish between people who have likes to posts and those who have dislikes. I want to find a way to improve my code without thinking it is efficient.
<% if current_user.voted_up_on? @post %>
<%= link_to "LIKE #{@post.get_upvotes.size}", like_post_path(@post), method: :post, class: "btn btn-outline-prima... | stackexchange/codereview |
I'd like to get some input on whether or not to DRY up this code. And if so how to implement it correctly. How do I know when it's worth refactoring?
public class Win32OperatingSystem
{
public Win32OperatingSystem() { }
/// <summary>
/// Number, in megabytes, of physical memory currently unused and availa... | stackexchange/codereview |
I'm learning the Elixir language and the Phoenix web framework. And I had an idea. What if, in a web wizard (multi-step form) scenario, I stored the intermediate data in a ETS table instead of the relational database?
So I wrote this controller:
defmodule PlayPhoenixWeb.ThingsController do
use PlayPhoenixWeb, :contro... | stackexchange/codereview |
I have a Web API application in .NET Core 3.1. In a controller I have a GET action that must return a JSON object with a name and a description. In order to retrieve the correct description I need to call an external API (not implemented by myself and outside of my control). This is the code in the controller:
public a... | stackexchange/codereview |
One of my assignments was to create a chessboard. In this assignment I could not use an array, or a form of list or what not. Below is my code for the creation of the chessboard:
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Color;
public class Checkerboard
{
private int xPositions;
pr... | stackexchange/codereview |
I recently have been working on a Trie in Java. I have looked at the related posts here on Code Review to try and enhance my code, but I do have some methods and constraints not present on other posts.
Objective
To efficiently implement a Trie data structure in Java that is fast, with low memory consumption.
Constrain... | stackexchange/codereview |
I've been messing around with protocol handlers in Java, going so far as to write my own using a custom URLStreamHandler and URLConnection. I was implementing the loose methods when I came across URLStreamHandler::openConnection(URL, Proxy). Since I'd already written my logic using Sockets without Proxy support, I de... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.