How do we import data from a given file and use it in the program?
I want to merge sort some numbers from a file(say suppose there are 100 numbers in the file)
I would propose to use the http://code.google.com/p/openid-selector/ library.
It has the most used urls + graphics for each site.
It is what stackoverflow uses.
We should be using auto-layout. Not being as comfortable with auto-layout is not an excuse to not use it. Manually setting rects is not very good at all. Manually set rects don't play well with rotation. Manually set rects mean we probably need a special set of code for iPad versus iPhone. M...
@nhgrif so this gives a divide by zero error, like you said:
declare @numerator as int = 1
declare @denominator as int = 0
select case when @denominator = 0 then -1 else min(@numerator / @denominator) end
but this works
declare @numerator as int = 1
declare @denominator as int = 0
declare @quotient as decimal
if @denominator = 0 begin set @quotient = -1 end else set @quotient = min(@numerator / @denominator)
select @quotient
I'm doing a challenge on TalentBuddy that requires you to find the powers of multiple array pairs.
Since, I got the solution right, but not fast enough, I decided I'd ask for help here.
def fast_power(a, b)
pairs = a.zip(b)
pairs.each {|p| puts (p[0] ** p[1]) % 4211}
end
a1 = [long array w...
Write a console application that requests 10 numbers from the user as individual inputs.
Each number must be between 10 and 100, inclusive.
Compare each number to the last one entered to determine if it is its duplicate. If it is, ask the user for a different number.
Output each number to the scr...
This is what I came up with:
Version 1:
static double Integrate(Func<double, double> f, double low, double high, double delta)
{
return Enumerable.Sum(Enumerable.Select(Enumerable.Range((int)(low / delta), (int)((high / delta) - (low / delta))), c => f(c * delta) * delta));
}
If I'm allow...
hye im auni from malaysia. im a computer student and i need help with c programming. can you build a complete c code of car rental system? the system should include : rent a car, list the due date car, print bill of rental etc . The system also must use recursion, structure, nested structure, l...
I have a form that submits to a registration Servlet, which inserts a new user to the database when they sign up to the web application. Depending on the erroneous user input, the Servlet will sendRedirect() to a result page, telling the user what went wrong.
Servlet: doPost()
protected void d...
tl;dr: How should I rework my DSL so that it does not require mutating an instance to suddenly be another class?
I am writing a Ruby framework/DSL. In it there are a couple specific classes that inherit from a common base:
class MaterialBase; end
class Material < MaterialBase; end
c...
How could I improve this working Perl script? (it changes my desktop background to the next available one, without opening a terminal) Specifically, how could I iterate over my .fehbg and walls/ lazily, without reading them into arrays? I couldn't find a way to do that, I need the for loops.
...
I came across an odd issue @Mat'sMug you may find it funny. I created this large stored function that drops a schema, creates the same schema and a bunch of tables, and inserts stuff into them. It worked when I called it, but only once. Took me a couple hours to figure out the issue
Are you looking to have your code reviewed? There is not much code to review, and your question sound like you are looking for advice on which interface to use. This would not be on-topic for Code Review; would you please clarify? — Phrancis32 secs ago
I am making a program that is to add, subtract, multiply and divide fraction and whole numbers. An example of a few numbers would be:
Note: (The underscores are included!)
3_1/2 + 2_3/4
2 + 1/4
-5_5/6 + 1/2
45/3 + 1/8
ext.
I have my code, but for some reason I am not getting correct answers...
I have lot of repeatation in my code for instance lot of repeatation like variable z.
var updatealldata = function(data){
var z = data.totalvalue?data.x:data.y;
$(k).append(z);
}
var updatesingledate = function(data){
var z = data.totalvalue?data.x:data.y;
$(k[x-id=' + newId + '...
I've written a minimal unit test framework. The goal was to allow assertions of booleans, for equality and catched exceptions. Two things are bugging the most. That assertions have to rely on macros and using a function pointer type instead of one of the more modern C++ ways. Are there ways to fu...
Hi, You might want to keep either c++11 or c++14 and not both, asking to convert c++11 to c++14 would be off topic. Only keep the version you are using. — JaDogg8 secs ago
A handful of sites have conducted a variation of the "weekly topic challenge" idea. I, myself, have become quite fond of them since they do seem to be effective at increasing asking rate and can be a lot of fun. I've personally initiated challenges on several sites (most recently on History and P...
@janos Perl Vs Python problem is being discussed in the my current work place as well, (well the seniors are discussing it), I wrote some python code too.
Let's say I have a factory like this (it's from an interview):
public class ControllersFactoryImpl implements ControllersFactory {
private final SessionKeeper sessionKeeper;
private final ScoreKeeper scoreKeeper;
public ControllersFactoryImpl(final SessionKeeper sessionKeeper, fina...
my script works on IE7, 8 ,9 etc. chrome firefox, safari, etc. But when I run this on IE6, it doesn't work. Its a calculate function like a bet vs cash on bank = transfer.
What am I doing wrong? Please help. :(
Here's a working sample: http://jsfiddle.net/francais/c23vzkyn/
When sieving primes up to some 64-bit number n I need to determine an upper bound for the greatest potential factor of n, which is the greatest integer that is not greater than the (true) square root of n.
Computing this as std::sqrt(double(n)) is fraught with pitfalls. The standard IEEE double...
The universe was shaken, not stirred -- seriously: neither the Earth nor much of anything in the universe is perfectly homogenized. BTW, as a matter of form, you should (1) provide a reference for your data, (2) specify whether that's ppm by atom count or mass or volume, etc. — Carl Witthoftyesterday
In JavaScript we can write callback definition in many different ways:
Definition after usage:
var fs = require('fs')
fs.readFile('movie.mp4', finishedReading)
function finishedReading(error, movieData) {
if (error) return console.error(error)
// do something with the movieData
}
Defini...
I have a very simple ASP.NET MVC5 application. I am using this to create a very simple site that will allow users to download our applications once they have logged in to the website (they will need a code, provided by us in order to log in).
Now, I want to add a default Administrator account, w...
Code Review has had a number of challenges. The frequency was initially intended to be somewhat 'weekly', but the regularity has diminished to what has become more of a once-a-month-ish.
Rock Paper Scissors Lizard Spock
Poker Hand Evaluation
Sudoku Solver
Pokemon - Catch em all!
Simple Text Adv...
Here is a program for converting Impute2 files into MaCH format (related to genetics).
Source files include one xxx_haps file and one xxx_samples file, for example:
// chromosome21.gen_haps
--- rs62224609 16051249 T C 0 0 0 0 0 0
--- rs62224610 16051347 G C 0 1 0 1 1 0
--- rs143503259 16051453 ...
Auto layout is the right way to do it. There's no reason not to use auto layout besides being uncomfortable with it, and that is an absurdly poor excuse if you ask me. — nhgrif41 secs ago
I want to write one simple a program that will encrypt one test using and at the same time decrypt it. I wrote below program
Adding my whole code here:
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <openssl/aes.h>
#include <string.h>
...
right now I am developing a chess game in java and have been writing the whole game in one java file without doing subclasses and I was hoping I could get some help with that
I want to separate the moves of all the pieces into a new file
can someone show me how to do that
This is the whole ...
@Vog? I did some debugging, it seems that the event fetch works for all chat.SE sites, but not for chat.SO: http://hastebin.com/ijadoluwaf.avrasm Unless I can get it to work, I'll just use HTMLUnit again.
GUI-based pseudo-random password generator. Modification of this app, improved according to suggestions from Code Review users. Additional feature: calculation of time to crack password on average desktop PC, which is determined as time to go through all possible combinations of characters.
Ide...
This review is in continuation with Part I mentioned in query.
As part of the assignment given in Part II from this link, here is the solution:
Ocean
/* Ocean.java */
package Project1;
/**
* The Ocean class defines an object that models an ocean full of sharks and
* fish.
* @author mohet0...
Can the below code be improved? Are there any major issues with it?
Thanks
Writer w = client.sendMessageData();
for (File file : myAttachments) {
w.append("\r\n").append("--").append(bound).append("\r\n");
w.append("Content-Type: application/octet-stream\r\n");
w.append("Content-Tran...
Can the JVM perform runtime optimization in the following scenario?
We've got the following situation, we have this interface:
public interface ECSResource {
default int getFor(final Entity entity) {
return ResourceRetriever.forResource(this).getFor(entity);
}
}
And a concrete...
Question:
Write a C program that prompts the user to input an integer n and then forks 2 child processes P2 & P3. P2 should execute before P3 and it should replace its image by the ls command. Process P3 should execute after process P2 and should replace its image by the pwd command.
My Answer:...
My girlfriend and a friend started a Kiwanis club around here, so I figured it would be a good opportunity to try coding my first web site. Pretty new to coding still and its pretty basic, so just looking for general pointers or any bad practices I may be doing. Thanks!
https://gist.github.com/a...
I am currently developing a chess game but have made the mistake of putting all my Java code in one .java file.
I need help cutting up my code into more manageable chucks. Could someone show me how to take out all the piece movements and put them in a separate file which then links back in to th...
That is a shame I don't have my website I did when I was about 11 ! It was about Digimon so much fun! I don't know if it was bad or good! It was a simple html page! nothing much !
@rolfl I just realized that it's not exactly the question that is the problem, but the questioneer.
can u show me with an example of one of the classes linking to the main one as my problem is trying to right the classes the right way when i split them up — Jamiex3042 days ago
hello this is really confusing for me but thank you for the help, But I really need someone to show me how to cut up my code into easier chucks can you show me an example of say the piece movements separated into a new file that is linked to the main file, if you can that would be great — Jamiex3042 hours ago
He apparently does not really know what he's doing...
All reports from Google I get is that either som edifferent version magically fixed the issue (which it does not) or they use some real hack-ish way that doesn't seem proper
> com.cardshifter.core.cardloader.CardLoadingException: com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [simple type, class com.cardshifter.core.cardloader.XmlCardLoader$Cards] from String value (' '); no single-String constructor/factory method
that company what was looking to hire me, said that they can't offer me what I am making now, I would take a $6k a year paycut, but could advance quickly. and they could give me more experience in up and coming technologies where my current job can't..
if I wasn't tight on money I would have said yes right away....
I am just going to create a browser game and try to get some people donating to the game, and then create more, that way I get experience in ASP.NET then when I make another game I am going to do it in MVC so that I have that experience as well.
Qustion
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
string n ;
cin>>n;
int i ;
while(n[0]-'0' != 0){
long long int dp[n.length()+1] ;
dp[0] = dp[1] = 1;
// cout<<dp[0]<<" "<<...
Welcome to Code Review? Your title states "Wrong answer" are you looking to find a bug in your program? If so, this question is off topic for this site, unfortunately. — Phrancis33 secs ago
Wrong punctuation lol. Fixed it on the question but not updating here...
Do someone know some online resources for Java 8 ? I would like precisely something that would be in the format of: Take this old Java code and transform it in Java 8, here is what you should have.
Well asking for a Java 8 conversion would be off-topic since I'm asking for new code :P And I don't really have Java 7 code to review ! It's for a work presentation! I need to learn how to refactor to Java 8.
@Unihedron I know... But using features of a language to increase readability is important . Some dev do not use for-each... I would like to change things here a bit
For our Cardshifter Project we wanted to be able to load card definitions from file.
A card is defined as:
Having an unique id.
Having a set of resources, which are integers identified by a string.
Having a set of attributes, which are strings identified by a string.
In the implementation ev...
For our Cardshifter Project we wanted to be able to load card definitions from file.
A card is defined as:
Having an unique id.
Having a set of resources, which are integers identified by a string.
Having a set of attributes, which are strings identified by a string.
In the implementation ev...
@RubberDuck @Marc-Andre IMO, if it's a well written question and formulated in the form of "But I am not sure if it's possible to simplify these things now that Java 8 is around", then it's good and on-topic question.
@Marc-Andre I can recommend reading the Javadoc for some of the new default methods. In most of them, it explains what exactly it does with Java 7 code.
@SimonAndréForsberg The best way for me to learned it is to see it in action with this is A and here is B with the feature! I'm good a recognizing pattern in code.
@Marc-Andre You could take a look at my Sudoku Solver written with Java 8 on Github. I could easily translate my C# code where I heavily used LINQ to Java 8.
@RubberDuck Me neither. Technically I find all such questions on topic, but sometimes it's the asker who we should close, not the question. Some askers do need to learn more from tutorials in some cases IMO.
@Marc-Andre I never did a Java 7 Sudoku Solver unfortunately. But if you have a good understanding of C# then you could compare my C# code with the Java 8 code.