@Jaagr I have a project with over a hundred files and I have posted questions with little snippets from it (where each snippet is a complete concept) to get it reviewed.
I'm new to C#, so I'm eager for any and all criticism/advice. Thanks!
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FileTransfer
{
class Program
{
private static string targetPath;
...
Hee!
I made a small function that is getting looped when an input is getting focus and stopping the loop when the input is losing focus
Now i would like to know if there is a better way to write this code:
var time;
function Change () {
if( !$('#eventurl').val() ) {
$("#js-sk...
Does this code outperform the common implementation with path-compression and union-by-rank?
https://gist.github.com/hopesenddreams/7bd5d93648cf4f8516183357b4c9e94d
import java.util.*;
public class DisjointSet<E> {
public static void main(String... args) {
Scanner s = new Scanner(S...
I have people on Code Review telling me to leave the question here. If people spent half as much time answering the question as they did arguing about where it should be posted, I could have marked an answer and awarded points already. — GoldenJoe44 secs ago
In a bigger VBA project, I wrote some code to compare to lists. First list (clist) is around 500 entries, second one (plist around 2000).
Each item in clist gets searched in the second list, if a match is found, some data gets added, if there already was a match, a line gets inserted in the secon...
I started writing this program to get a better understanding of different aspects of Ruby. I tried to follow the ruby style guide here. What it's supposed to do is take the exercises/tasks you give it, and record those tasks. It uses a record of those tasks to automatically create/update the head...
I am trying to create a function that can either beat numexpr or perform comparably for the vectorized mathematical operation k * exp(ee), where k and ee are 1D arrays of complex numbers. I had tried using openmp in Cython directly, but I have resorted to creating a DLL in C++ and then wrapping w...
I have an app that uses the file system a lot to store generated files (zip files and scss/css fil). When a user generates a file, the metadata and other information is stored in the db for later retrieval and action in another part of the app. Through testing or error, I realized the DB and...
I have recently written an unbeatable Python Tic Tac Toe game and I think this is one of the shorter versions out there that aren't super long. I was wondering if there was a way that I could shorten my code. I've looked into doing the for loop for the winning positions and defense as well, but t...
I recently decided to code some in Python after coding in Java using lombok for quite some time. However, I got bit real hard when I forgot to implement __eq__, since Lombok normally does it for you.
I decided to try to implement something similar to Lombok's @EqualsAndHashCode, which I called e...
i need help how to calculate square root of 3 in python using binary search. I have this code to calculate square root of 2 using binary search
def sqrt(x):
if x == 0 or x == 1:
return x
start = 1
end = x / 2
while start <= end:
mid = start + (end - start) / 2
...
I have the code below for a program that using arrays and superclass can calculate the grades of multiple students and take the average and give them the grade letter. I've been going back and forth trying to just get the average and makint it to work with my method DisplayvalueInArray to just ad...
I've written this to find the largest absolute difference between integers in a list.
I'm moving away from map, reduce and filter in favour of list comprehensions.
I like list comps but I feel like this is getting on the unreadable side.
Is this the most idiomatic way of achieving this? Is it ...
Currently I have the following code
def single_get(target):
return [some list of objects] # might be an empty list
def multiple_get(targets):
result = []
for target in targets:
result.extend(single_get(target))
return result
Is there a way to collapse multiple_get in...
I submitted the following Python 3 code for this HackerRank challenge. Given an n × n grid with an m and a p in random cells of the grid, it prints the next step in a path that moves the m to the p.
def nextMove(n,r,c,grid):
#First, find the princess
for i in range(len(grid)):
fo...
I am developing an application that should fetch data from mysql database to send sms. I'm decided to use cron job service to run a php script to fetch the data and send the sms after every 5 minutes.
My problem is I just can not figure out a way of setting up the select statement to NOT pick a ...
I 'm trying to create a universal CSS template for global styles. I can not find unambiguous recommendations. After inspecting various sites, I have compiled the following template . I ask your advice . Thank you!
*,
*:after,
*:before {
box-sizing: border-box;
}
html,
body {
overflow-x:...
Idea: A class that has two properties; name and surname, and a function that returns the first name and the surname together.
Is there anything that can be done better? Anything that is done poorly?
public class Person
{
private string Firstname { get; set; }
private string Surname { ge...
I need to find the smallest and largest volumes in an array of objects from a class, using their attributes, my code, while not perfect and very primitive works well when I try to find the largest numbers, as well as finding the owner of them in the array. But when I try to find the smallest, aga...
Idea: A class that has two properties; name and surname, and a function that returns the first name and the surname together.
Is there anything that can be done better? Anything that is done poorly?
public class Person
{
private string Firstname { get; set; }
private string Surname { ge...
This is the second version of my type converter framework.
The the previous one can be found here: Type creator service & framework
In this version I mostly implemented what @Dmitry Nogin suggested in his great reviews
I also extended it so that each converter has access to all the registered ...
I am new to android and developing an android app for getting regular updates on current location using google play services fused api but i want it to work on background too. Can you please tell me how to do so using Service class. Thank you
I'm using a simple logger on a server, which uses a method that looks like this:
@Override
public synchronized void write(String logtag, String reason, int severity) {
long logtime = System.currentTimeMillis();
String message = "";
switch (severity) {
case DEBUG:
...
I wish to make a mixin to produce the following result of modifier classes:
.text-left {
text-align: left
}
.text-right {
text-align: right
}
.text-center {
text-align: center
}
.text-justify {
text-align: justify
}
.float-left {
float: left
}
.float-right {
float: right
...
ObservableCollection is a leaky abstraction. WPF doesn't care if you only expose an ICollection, so long as the backing field implements the INotifyCollectionChanged interface.
Same as Winforms doesn't really need a BindingList.
Lol. Yeah. I know, I lurk in the depths of the 2nd monitor.
I have a table with (CompanyNumber, File_Date, [various financial results])
I wanted to get only the most recent set of accounts for each company.
After various googling I eventually got a query that does what I want it to do.
Is this a good way of doing it?
N.B. the File_Date field is actu...
I am getting back into python after a year of not doing it at all. I just wrote a bit of code to create a file that looks like this:
1,2
1,1,1,1
-1,0,1
42,17
Then I decided to take the average of each line and put it into a list. For this I wrote the following:
def line_averages():
out_file =...
I've had a quick search but nothing quite covers what I'm asking about. First time poster, so hi to all ! and thanks in advance for your time !!
Ok, so Say I have 5 columns and 5 rows of data.
The first four columns are numbers, and the fifth column needs to be marked with an 'X' if the first ...
Well on my previous post in C someone commented how it would be so simple in Python. I looked into it and came up with this, the problem is it doesn't past all the tests and I don't see what's wrong.
I am relatively new to Ruby, having worked with Rails for about 8 months.
For fun and my own education, I have written a Ruby gem (no Rails) that models dates with a precision (second, minute, hour, day ... billion years). A big part of my goal was create dates from the date format on Wikidata,...
That's the thing...I'm not sure. It also works on my tests, but on the challenge site it only passes 15% of their tests and unfortunately you don't get to see the test cases.
With the dynamic/reactive UI Elm seems like an ideal language for writing this kind of thing, but the code is coming out a lot messier than I thought it would - but then this is my first time seriously using Elm. Can anyone suggest improvements?
import Html exposing (..)
import Html.Attributes e...
Just want to say again, thank you. You guys are why CR is awesome.
here is the updated gist. If you're interested in what I originally tried vs what worked. Maybe someone later on can explain why the former doesn't work someday.
@Legato You use sanitized_line = re.sub("[^a-zA-z]+", " ", line). Where the regex is [^a-zA-z]+ Which probably should be [^a-zA-Z]+. That way it will match [].
Maybe you want to put this one on code review rather than stackoverflow now? :) — JCx32 secs ago
@JCx This question does not belong on Code Review Stack Exchange as it is asking specifically for how to change what the program does. (right-aligning) — Simon Forsberg16 secs ago
I am getting null pointer exception when try to use a method in Controller class. I am new in JavaFX, so don't know why its happening.
public class MainViewController implements Initializable{
@FXML TabPane mainTabPane;
public void initialize(URL location, ResourceBundle resources) {
...
Challenge
Write a program which reads a file and outputs a specified number of lines, sorted on length in descending order.
Specifications
The first argument is a path to a file.
The file contains multiple lines.
The first line indicates the number of lines to output.
The following lines a...
Challenge
Given a list of words mixed with extra symbols. Write a program that will clean up the words from extra numbers and symbols.
Specifications
The first argument is a path to a file.
Each line includes a test case.
Each test case is a list of words.
Letters are both lowercase and up...
I'm a software developer and just out of fun left an easter egg in the code. The only way for a final customer to see it is if they press the same button 25 times, which is unlikely to happen. The easter egg itself just contains a small photo of myself and a variant of "All your base are belong t...
I signed up for Raygun on Heroku and wrote a middleware in Express to handle the error, however, I am afraid this might block a request from coming through or executing all the way. The article below is what I am basing this off of.
Do I have the next(); in the correct place? I have it in tw...
I'm using the command pattern to enable actions in my game to be undoable. ICommand defines individual commands, ICommandHandler does the undo-redo logic and might be decorated with other handlers like logging etc.
public interface ICommand
{
void Execute();
void Undo();
}
public interf...