Here is my updated code per the suggestions given in Joe Wallis' answer.
I have changed the main loop in the readFile method, eliminating the if/else statements. I have also added additional methods to aid in easily retrieving data later form a separate module that is used.
import os
import tim...
If you can, have a look at this query; I didn't expect it to add new INSERTS in the rows after each previous insert (although now I kind of understand why it does that). Know an easy workaround?
I think I could use UPDATE statements like UPDATE #CategorizedTags SET Languages = AllTags WHERE AllTags IN ( /* list of Language tags here */ );
@Quill He posted as CW, I wouldn't worry about it, as long as he doesn't accept his own answer
Suppose I have the following:
public class NetworkServer
{
// Stuff
public NetworkServer()
{
// Stuff
// Wire up our events
Error += NetworkServer_Error;
DataReceived += NetworkServer_DataReceived;
StatusChanged += NetworkServer_StatusChanged...
I want to ask him if he's okay. His rep increase has completely flatlined recently, and he hasn't been in here for a while. I'm honestly a little worried.
This past weekend, CHAOS was working the New York Comic Con (NYCC) here in New York City. It was kind of amazing. But CHAOS wasn't the only one working hard this weekend....
Screenshot / Code Snippet
About
Someone found the current *beep* sound annoying and asked for a way to change the sound. Such a feature did not exist, so I created this UserScript which adds a button next to the notification settings button. This button opens a popup which allows you to ...
This question could be suitable for Code Review, as long as (a) your code works as intended, (b) your code is real code, rather than example code, and (c) your code is included in the body of the question. If you wish for a peer review to improve all aspects of your code, please post it on Code Review. — Phrancis7 secs ago
Install
Install from the Chrome Web Store
About
Porkchat is a Chrome extension that bundles together a lot of scripts I have written for Stack Exchange chat over the years. It is fully configurable - each individual script can be enabled/disabled from the options page.
Included Scripts
...
> Friday Link Highlighter - Avoid Rebecca Black's hit single - links are highlighted, and this script checks redirects so can detect links behind shorteners.
I solved the following problem on Hackerrank Here is my code:
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
private static StringBuilder htmlBuilder = new StringBuilder("");
private static Pattern rgxForTagAtEnd ...
Links can rot. Please include a brief challenge summary in your post. — Quill15 secs ago
Hey Java developers if you import parent.child.* will it import parent.child.grandchild as well, and for that matter will import parent.child.grandchild.* be effective?
I'm writing a Java program that has a button with an action listener:
JButton button = new JButton("Change");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
label.setText(textField.getText());
}
...
I was working on a little Java program and was using arrays so I had done:
import java.util.Arrays;
Later I started expanding on what I had previously done and decided I wanted to get input from the user, so at that point I added:
import java.util.Scanner;
Now a thought occurred. I know tha...
To quote from JonSkeet: "EDIT: Okay, after the clarification: a Java package is similar to a C# namespace - except that it has an impact on accessibility, whereas in C# namespaces and accessibility are entirely orthogonal."
"The Monkey Wrench" by Gordon Dickson. From Wikipedia:
In this story, Lowland society lawyer Cary Harmon drops in unannounced on the weather station of meteorologist Burke McIntyre, high in the Lonesome Mountains, a jagged chain of the deserted shorelands of Venus's Northern Sea. Curious abou...
Surely it just encourages bias in the voters to inflate high scores?
Yes, it does. That's the point:
There is obviously some intentional bias here, because we want the strongest, most electable candidates to proceed forward. That way the election is between ten strong candidates that you...
Is this good approach of using constant variables which holds the some data and used within this mixin only? Is there any better approach I could use instead the constants?
require 'active_support/concern'
module Expirable
extend ActiveSupport::Concern
BEFORE_EXPIRY_DURATION =
eval(APP...
All of this does just one thing. Move my player by finding the first finger that was used to touch the ship and drag it.
I have a few questions:
The first thing is I have an embedded class of MotionState. At first glance it makes a lot of sense to start with that. I latter ended up not using ...
Ok so, I was doing a puzzle on Coderbyte, and here is what the puzzle stated:
Have the function SimpleMode(arr) take the array of numbers stored in arr and return the number that appears most frequently (the mode). For example: if arr contains [10, 4, 5, 2, 4] the output should be 4. If there is...
I'm voting to close this question as off-topic because there is nothing wrong with the code. Questions asking about review or improvements to code belong on codereview.stackexchange.com — Peter Duniho1 min ago
Does this cause problems for utilities calling rm?
If so, this
if [ -t 1 ] ; then ..your code..; fi
will make sure you are not flooding stdin of other processes.
See this and other answers for more info on detecting whether you are in a shell or not.
I will probably come back tomorrow an...
The following code is not working
#include<stdio.h>
#define MAXLEN 100
typedef struct {
char element[MAXLEN];
int top;
}stack;
int isempty(stack S){
return (S.top == -1);
}
int isfull(stack S){
return (S.top == MAXLEN -1);
}
char top(stack S){
if(isempty(S))
printf("The stack is emp...
I have a requirement to check all records in a table which is big (Around 1.5-2 million records).
What it does is very simple, just get all the records and loop through one by one, and do things with the records.
I have a quartz job which will run every 2 minutes to check things.
ApplicationD...
Enough code to be reviewed, but it's borderline ...
Welcome to Code Review! It would really help us if you could fill in what goes on in allApplicationDetails.stream().forEachOrdered instead of //Do stuff. You would benefit more from a review of the complete class, as there might be things in there specifically that are slowing down your job. — Phrancis3 mins ago
@PeterDuniho, how do I properly migrate the question to CodeReview? When that happens, can you please add your readonly idea as an answer? I've never seen that construct before. — kdbanman1 min ago
@kdbanman I don't think this is the greatest post to migrate over to CR. Code Review works best for when you have real working code from an actual project that you want to have feedback on any and all aspects of the code. This question is really just asking "what's the best practice regarding X?", which is explicitly off-topic on CR (see the help center). — Mat's Mug39 secs ago
I am working on a home entertainment system, that allows me to access TV version of youtube. The problem I am having is that I have my own keys that I need to use but youtube is using the same keys. Is there a way I could filter the keys the iframe is using, so that I only allow the iframe to use...
@Mat'sMug ...oh. I just did, I was about to delete this one. Perhaps I'll leave this one and delete the new CR post. What do you think? — kdbanman50 secs ago
Interesting information, but irrelevant to this code, since the entire point of the program is to display information to the terminal. — 200_success ♦6 mins ago
Well, I for one, would never overwrite shell commands with new ones that altered the behaviour like that.
.. without taking precautions as I suggested in my answer.
But I agree that it is not a proper review, merely a review at all. And if that is what is demanded of this site, I expect that someone make up their minds about it.
Your point could be elaborated into a reasonable answer, if you explained how the original code is deficient without the -t check. (Personally, I'm currently not convinced.)
This method works for what I need it to do, but I just don't think it's extremely readable, and could be abstracted into different methods. I have a feeling I'm going against some best practices. Please let me know your suggestions:
def reserve
return render json: { error: "This entity is no...
Unit testing the rubberduck refactorings, inspections and quick-fixes has been pretty much impossible, at least until a MockFactory was implemented, to do things like this:
internal static Mock<CodeModule> CreateCodeModuleMock(string code)
{
var lines = code.Split(new[] {Environment.NewLine}...
Does anyone know how to read pajek file in shiny and then find the degree of each vertex and output it to CSV file in descending order?
Here's the Pajek file i want to import in and export the degree into CSV.
In R, i know how to code it normally like this:
#read the pajek file in igraph
repon...
Iam planning to use Xamarin platform for a big scale mobile app for ios and android.As I am a C# developer so I think the learning curve will be small.can somebody guide what are the limitations of this framework which can affect app performance or development.I want to consult someone who has al...
Yesterday and today I've made a very basic syntax highlight.
It creates a function in the window object that handles part of the job:
(function(window){
var f=window.highlight = function(lang, element){
var lang_defs = f[lang];
if(!lang_defs)
{
throw n...
I have implemented a JPA project to fetch tweets from twitter API and save them in MYSQL. It has two packages : controller and model.
I would like to know if it is a clean architecture or not?What about MVC principle? Is it correct?
Specially I am not sure about the classes TweetPersist and Twe...