I built a very basic image slider, but I'm still having trouble refactoring.
I caught myself reusing same code for clicking the previous/next buttons, selecting a slider dot, and the automated sliding. The difference between these actions is how the index of images changes. I'm not sure how t...
Including the signature, scope opening and closing braces, and all the superfluous vertical whitespace you've got here, the Read method has 223 lines of code, checks if the end was reached in 7 places and includes 4 goto instructions.
Other answers already stated it, but I don't think it can eve...
In digital computer programming, a bitwise operation operates on one or more bit patterns or binary numerals at the level of their individual bits. It is a fast, primitive action directly supported by the processor, and is used to manipulate values for comparisons and calculations.
On simple low-cost processors, typically, bitwise operations are substantially faster than division, several times faster than multiplication, and sometimes significantly faster than addition. While modern processors usually perform addition and multiplication just as fast as bitwise operations due to their lo...
I'm an upstart, been only professionally programming for a bit less than 2 years, mainly in Java as I am currently working as an Android developer.
I often find myself thinking about how to improve the readability and maintainability of my code, and establish some style guidelines, for the proje...
there are more than what is listed on that wiki, I don't use them much so I don't know them all offhand, there was someone looking at some encryption code a while back and it had a lot of bit manipulation in it @ckuhn203
@Mat'sMug I agree with the OP about the Constant name. What if the escape character (for some completely inexplicable reason) needed to be changed to a backslash 5 years from now? Then you'd have to rename it and change all instances of it, or let the name of it lie. Now, I don't think that would really happen for a csv reader, but still...
I wrote an algorithmn which should cut a companies name into 3 strings.
Input: 1 String
Output: 3 String.
Conditions:
String 1 2 and 3 shall not be longer then 35 signs. If the Input string is longer then it should be cut to a length of 105.
If you have fun and be interested ...
I'm sure there are bigger or smaller mistakes in all protocols. I believe this one is a very minor one, if they don't have a good reason for why it should be like that.
I am trying to refactor two methods.
Let me begin with context:
I cannot edit the QueryPermissions Class, it is an external dll that was given to me to use. Yes I realize its a bad practice to use an out variables. I am pushing for a rewrite of that service.
As you can see below the two metho...
I have set up a Dictionary that calls on a class to fill a DataGridView via SQL statements. The problem is in two (out of 5) instances the value passed HAS to be an integer. Any idea on how I can add error handling to this? Preferably a message box that just says "value needs to be an integer".
...
So we have a base interface:
public interface IMessage
{
//Some properties
}
then we have derived messages that implement this interface such as:
public class AlarmEventMessage: IMessage
{ //Some properties }
Now, these messages get r...
I wrote an algorithm which should cut a companies name into 3 strings.
Input: 1 String
Output: 3 String.
Conditions:
String 1 2 and 3 shall not be longer then 35 signs. If the Input string is longer then it should be cut to a length of 105.
If you have fun and be interested i...
Ok, his comment now makes the question make no sense. He wants to restrict it to numbers in 2 out of 5 cases that could be hundreds of thousands of parameter inputs?
@Malachi - I think yours is the best out of the three, I was trying to think of a way to recurse it to get the three values, but recursion always gives me a headache.
I am trying to find if a subwebsite exists in sharepoint, if it does then add +1, I think loop can be improved.
// subsiteName will be like "FruitCrateOfCompanyX"
public static string FormatMyHomieURL(string subsiteName, string mainSite)
{
if (!mainSite.EndsWith("/"))
...
Currently I have 3 functions which are really similar. They differentiate only in input parameter name, condition and return value.
I'm going to refactor them, and I thought you guys might tell me what is the best way in your opinion to refactor these. Feels like there has to be 1 function but wi...
Closing as 'unclear what you are asking'.... because your update leaves you with two chunks of code to review, and it is unclear what a reviewer should do in this case. If you want the revised code reviewed, start a new question. — rolfl ♦31 secs ago
Thank you very much for this detailed and well referenced answer, I really appreciate it! I will take the time to read through the answer and the resources you linked to carefully, then I'll come back and add a short conclusion to my question. — Matej11 mins ago
Is it ethical to release some code as open source which I have made during office hours, but which technically have nothing to do with the work? Apart from that they simply were unexisting libraries that didn't exist yet.
In the end I expect to be at most 1/3th of the time of it to be spent at work, and other time at home either way, documentation, etc., stuffz.
Examples are a proper interface to Tesseract in Java, and a modifyable proxy
@skiwi - typically, unless you have specific provisions that say otherwise, anything you do while employed by someone, belongs to them.... this includes after-hours work.
I've replaced the following horrendous Excel formula (values and names have been replaced):
=IF(AND(SourceTable[@Field1]="Value1",SourceTable[@Field2]="Value2"),"Result1",
IF(SourceTable[@Field2]="Value3","Result2",
IF(AND(SourceTable[@Field1]="Value4",SourceTable[@Field3]="Value5"),...
The one about Tesseract is slightly tricky, it's never been on company grounds and I maybe only programmed like 2 hours on it, and 10+ hours at home already and more to come... Therefore I consider that one mine
@Edward You are right, but, if you disagree with the ethics of the employment contractyou are in, then your choices are simple: 1. quit or 2. renegotiate. That's the only ethical choice. Doing something that is in breech of the contract, whether the contract is 'ethical' or not, is not ethical. Two wrongs don't make a right.
@skiwi - Again it depends on your contract. If you develop a library at home, it's yours. If you bring it to work and incorporate it into work related code, it gets murky. I've seen some contracts where the employee had to also become a third party contractor to be able to use the home created library.
Hmm about the free time employees get at some companies (Google is one of them I believe?), that work is all owned by the company i suppose? Like one day do something for fun
Surely a contract that would say that they own all code you have ever written in your life and is not already owned by someone other than you would not be legal, right?
Good day, 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
Howe...
The Copyright Law of the United States intends to encourage the creation of art and culture by rewarding authors and artists with a set of exclusive rights. Federal Copyright law grants authors and artists the exclusive right to make and sell copies of their works, the right to create derivative works, and the right to perform or display their works publicly. These exclusive rights are subject to a time limit, and generally expire 70 years after the author's death.
US Copyright law is governed by the federal Copyright Act of 1976. The constitution explicitly grants Congress the power to cr...
I do work one day a week there, so I'm actually doing more work if I continue to make those libraries in my own time, might shed some different light as working there every day in the week and then 'saying' you made things at home
@skiwi - Just ask. "Hey, I have some ideas for libraries that would make things more efficient. What is the policy if I create this on my own time to use for work?"
Even if it fails, nothing's massively wrong... If I get a significant part of the job done then I'll get a raise and I like to code, so I might still do it in my free time!
@JohnP That's the right approach. I once asked an employer this question and they said, "then it's ours." so I replied, "oh, too bad. I just forgot the idea." :)
The objective of this question is to create a program that pushes your computer's internal fan speed to its maximum RPM. Upon exiting the program, your fan should return to the normal operating RPM.
Rules:
You may not perform a CPU intensive task in order to modify the
fan's speed.
Exiting th...
There is a lot of going back and forth going on here.
I think that I would just pick PHP and write the whole thing in PHP, you would eliminate a lot of confusion and obscurity by being able to remove the <?php ?> tags from all over the place along with being able to properly indent the code.
Yo...
I have a function that takes a Dictionary<String, Object> as an argument. It uses this Dictionary to create parameters for a query string.
private static TableAdapters dataSource = new TableAdapters();
private void findScriptsQueryButton_Click(object sender, EventArgs e)
{
string fillBy = fin...
Meme: Smoking The Documentation / STM
Originator: Simon, in response to a question by rolfl
Cultural Height: The 2nd Monitor
Background: "The documentation." is now a common response to rhetorical question like "What was I smoking when I wrote this?". This is often followed by "STM again?" (Sm...
Waffles is getting upset.
The management, with its magnificent reality distortion field, seem to have a Stalinesque attitude towards the F-word, with one notable exception: user profiles.
Sometimes, after clicking on a user's profile I am promptly presented with a nasty word. This makes me cry...
Now that the first round of meta tag burninations is complete, what do you think should go next? My recommendations now are style and code-organization.
I've replaced the following horrendous Excel formula (values and names have been replaced):
=IF(AND(SourceTable[@Field1]="Value1",SourceTable[@Field2]="Value2"),"Result1",
IF(SourceTable[@Field2]="Value3","Result2",
IF(AND(SourceTable[@Field1]="Value4",SourceTable[@Field3]="Value5"),...
I ran into a problem recently where I had to decide whether a set of sum types was homogeneous (all the same). In itself, this is a pretty simple problem. However, there were a few complicating factors:
There exists a type within the types (call it Id) that is ignored in the comparisons.
There ...
This is the successor of my previous CSV reader. I implemented quite some useful suggestions.
Because I know some people will never be fully satisfied, I will give explanation on a few parts. Please do not bring old stuff up.
Prefixing constant identifiers with Sym_ (abbreviation for symbol) is...
I recently read that I should use enum for singletons to insure that only 1 instance exist throughout the code. So I created an EmailTemplate using the enum pattern.
public enum EmailTemplate
{
FORGOT_PASSWORD("forgotpassword.txt"),
CONFIRM_EMAIL("confirmation.txt");
private final S...
Below is a custom module which provides a framework for making ajax calls. How can I move this to Backbone?
It is very simple, if a user is found to exist ( determined by checking the local storage ) make an ajax call to get their data.
Otherwise just flip the page to the front or splash page....
I have been flagging answers where I have removed cursing so that mods are aware of a user in the case they violate the rules on a regular basis. Should I not flag it after I have removed the cursing?
@Malachi - so, you made me look ....... and you should really use that little box that lets you put a message in for your edits.... saying what you changed.
I'm assuming that names have been changed to protect the innocent, but just in case they've not been...
These are terrible names. All of them.
Function names should have verb-noun names and be PascalCased. So instead of CUSTOMFUNCTION should be GetCustomMatch (or something like that. I can't s...
The T-1000 is a fictional shapeshifting robot assassin and the primary antagonist in Terminator 2: Judgment Day. Created by the series' long-running antagonist, Skynet, the T-1000 is described in Terminator 2 as being composed of a mimetic poly-alloy, whose body is composed of liquid metal that allows it to assume the form of other objects (commonly knives and stabbing weapons) or people, typically terminated victims. Therefore, it is portrayed by multiple actors in the film. It is further explained in the prologue of the film's novelization, that the T-1000 was created through nanotechno...
The Terminator (also known as the T-800, T-850, or Model 101)—a cyborg, initially portrayed as a programmable assassin and military infiltration unit—is any one of a number of fictional characters portrayed by Arnold Schwarzenegger. "The Terminator" character first appeared as the titular antagonist in The Terminator, a 1984 film directed and co-written by James Cameron, and its sequels. The first film in the series features only one cyborg: the one portrayed by Schwarzenegger, although a second Terminator played by Franco Columbu is shown in a future flashback scene. In th...
I recently read that I should use enum for singletons to ensure that only one instance exists throughout the code. So I created an EmailTemplate using the enum pattern.
public enum EmailTemplate
{
FORGOT_PASSWORD("forgotpassword.txt"),
CONFIRM_EMAIL("confirmation.txt");
private fina...