My PowerShell scripting skills are pretty poor, but I've managed to hobble together got this script:
function Create-Process() {
param([string] $fileName, [string] $arguments)
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.RedirectStandardError = $true
$pinfo.Red...
when I posted this I thought that I caught everything that I could think of, but looking at it again I noticed that I could use at least 2 more Using statements here:
Dim objCommand As New SqlCommand(SQLstr, cnn)
Try
ReadLetterText(ErrorLog)
cnn.Open()
dr = objCo...
It's a good habit to end each statement with an explicit semicolon.
The innermost query q generates one row for each recent user. Since you have no interest in individual users, and only want counts and sums, you can collapse the two innermost queries q and r — both poorly named, by the way —...
@200_success SQL is a Different Beast than what @Mat'sMug and I like to Battle. we are thinking OO and then try to put it into SQL. that is why we both made that mistake.
@Calpratt spot the most important issue I think. I can only add nitpicks.
Instead of:
if guess.isalpha() == False:
should be:
if not guess.isalpha():
It seems you can delete _GetchUnix.__init__ because you're importing tty, sys in __call__ anyway.
The pep8 tool finds some Python sty...
I have been researching and experimenting with HTML5 and CSS3. I was aiming to create a very simple but efficient tiled gallery / grids. So some sort of grid system that I can layout anything inside.
Below is what I have created, what are your opinions? I also have a question, why the distributi...
I am trying to apply Interface principles into my code, learn by practice method.
I have a CRM system that has Notes, Payments, DairyEvents and anything else that needs to be bolt on over time.
I created an ITimeline interface that has a datetime and message method and implemented them on those...
@rolfl Do you believe that issues you encounter in already existing code on github, should first have a bug report created on github, and then make a commit that fixes it?
If it's a trivial fix, I wouldn't bother. If it takes longer to file a bug report than to fix, then the tool is getting in your way. Otherwise it's better to report first because you can't be sure when you'll really fix
this is a really good example to explain how I think about XML Documents.
<Author>
<AuthorId>1</AuthorId>
<Firstname>William</Firstname>
<Lastname>Shakespeare</Lastname>
<Profession>englischer Dramatiker, Lyriker und Schauspieler</Profession>
<DayOfBirth>Sonntag, 26. April 1564</DayOfB...
This one review will be a little bit tricky: I was trying to implement a template Vector struct in C11. Of course, templates don't really exist in C11, so I used a few macros to get the desired interface. Here is the implementation of the core features, trying to mimick those of the c++ std::vect...
This is my attempt at Project 18/67 of Project Euler. You can see the problem information, and obtain the needed txt file from here.
I had some help with the split function, and help on how to use an vector to do this. I would love any other feedback on this code.
#include <iostream>
#include <...
@Vogel612 I would probably drop the day of the week out of the date too.... that would be more display than data, and what if you didn't know the Day of the week, wouldn't that mess up your code or ......
As part of a Trading Card Game, I have created a Hand that will need to hold all cards that a player currently has in his hand. The code is built using Java 8.
The structure is the following:
Class for exception throwing.
The Hand class.
The HandTest test class.
public final class Exceptio...
doesn't need to be the full thing - if it's part of your challenge project then yeah, tag it with game and code-challenge - java and unit-testing would be the "other relevant tags" ;)
As part of a Trading Card Game, I have created a Hand that will need to hold all cards that a player currently has in his hand. The code is built using Java 8.
The structure is the following:
Class for exception throwing.
The Hand class.
The HandTest test class.
public final class Exceptio...
I wrote a little Perl script to Caesar shift strings. Usage:
$ # usage: caesar <string> [shifts,...]
$ caesar abcde # The default shift is 13.
nopqr
$ caesar abcde 1
bcdef
$ caesar abcde 1,13 # Multiple shifts are supported.
bcdef
nopqr
$ caesar abcde 1-3,5-6 # Shift ranges are supported.
bc...
I have been trying to get two text files to search trough each other line by line. Once has a bunch of words (around 20 words, one per line). for example :
"getting",
"wake up" ,
"do not use" .
And the other has many sentences(2.5 Mb). what I would like is for my program to find each of the wor...
I have the following code, written in Python:
if id:
fields = r.table(cls._tablename)
.get(id)
.run(cls.connection())
else:
try:
fields = list(r.table(cls._tablename)
.filter(**kwargs)
.limit(1)
...
@Hellovart The C++ gurus in this room are @JerryCoffin, @Jamal, @LokiAstari, @Corbin, along with a few others that know the language a bit (such as myself). You should always look for them when you come here with a question :)
there is a dime on my desk, and it just sits there, and I don't normally notice it untill im on my way out. I'm too lazy to move it, but it makes my desk look cluttered =\
Your method is lying. Not only it's displaying the digits, performing every Console.Write operation that needs to happen, it's also performing the "digit-splitting" logic.
It's more work than what its name says. For a simple coding exercise it's without consequences, but in larger projects if th...
Why skimp on braces? Putting braces around the if-block in generateString() costs you almost nothing — not even an extra line of code. Make it a habit to always include explicit braces so that you never write a disaster like this. (Don't think that it can't happen to you! Accidents often have...
My guess is that the reason is very likely to be a garbage collection.
Very possible explanation:
As it was said in the first case you have a big array eating up a lot of space and if the GC gets run during that time it will first do a minor collection. In minor collection there is a copy GC u...
@Vojta - in String class, the inner-char array is considered to be immutable... it never changes. The new String(char[]) constructor takes a 'defensive copy' .... so that it can be immutable after that.
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b27/java/lang/String.java#String.%3Cinit%3E%28java.lang.String%29 ^^^ Java 6 code, for example, is more complicated, but still would have copied the array.
Java6 and early Java7 would copy the array a lot more often than just the new String(String) class though, would copy it for substring, String.split, etc.
Note: the above invitation to stick around and wander the meta site and come say hi in the main chatroom, stands for everybody on this site! ;) — Mat's Mug55 mins ago
@rolfl And funny how I commented on your unit tests using assertEquals over assertTrue resp assertFalse... Guess what has been found in today's code of mine
I am trying to figure out how to add code to an application that isn't mine so that it will work correctly, and it took me a little bit to figure out why it was doing what it did. now I am tasked with fixing it.. may be an all day thing tomorrow idk
I didn't know SE actually had blogs!
I would be happy to write occasionally and review other people's work.
I really liked the idea of reviewing open-source software.
Also, I like the idea of writing simple How-Tos for more specific/obscure programming issues. Perhaps explaining how to use poor...
you have a lot of if statements in your SQL, this screams at me that you are doing something in your SQL that should be done in the application, and that this SQL should be separated into two distinct stored procedures.
the benefits
faster stored procedures
use an actual coding language to d...
I have a basic for loop in python that I'm wanting to run whereby I call a function and pass in a parameter that is varying from 480 to 6000 in increments of one...thus...
for iX in range(480,6000):
flgprbeamform(iX)
For some reason this keeps quitting after 40 loops every time, but the iX...
@rolfl I have an idea: was Parallel.foreach perhaps added in C# 4, and is therefore only available in version 4 or later? Could one of the C# guys here confirm or deny that?
Actualization:
If you use FrameWork 4 or newer you could to use the
Parallel.foreach
or
RemoveAll().Parallel();
functions. They are faster than another methods.
@Jamal - you editing all the 2012 stuff as well now?
I'm working on a directory that lists employee information. Each employee can belong to multiple departments and each employee can have multiple job titles. I have 5 mysql tables that I am pulling information out of, including:
employee
employee_has_department
department
employee_has_jobTit...
It's unfortunate that this had to come up when I was in class. Had that not been the case, then I would've been able to mention more than just one paragraph.
This is my first time writing a game in C++/SDL and I decided to post the code here so you can tell me what I am doing wrong.
main.cpp
#include <SDL.h>
#include "Game.h"
int screenWidth = 640;
int screenHeight = 480;
const char* title = "Pong Clone";
Game game;
int main(int argc, char* args[...
@rolfl PLinq (parallel) and Parallel.ForEach won't make a difference on a single-core computer, and there might even be a penalty with the added overhead. Hence I haven't upvoted that answer.
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
unsigned int i;
i = -12;
printf("%d\n" , i);
system("pause");
return 0;
}
Hi, I am learning C. I run the above code in vs 2012. Because I know unsigned refers to nonnegative number. I expected the program to report erro...
Welcome to Code Review! It seems like you have misunderstood what this site is about. We help with improving the cleanliness of existing, working code. We are not the site to ask for help in understanding, fixing or changing what your code does. Please see our help center for the whole rulebook, and feel free to come here anytime to get your working code peer reviewed, it's the best possible place you can ask for that. Cheers! — Mat's Mug44 secs ago
I am, primarily for learning purposes, working on creating an editor component in C++ with Qt. As a first step, to begin getting familiar with editing a document via QTextCursor, I wrote this function on my subclass of QPlainTextEdit to indent multiple selected lines:
void MyEditor::increaseSele...
I'm working on implementing a syntax highlighter for a simple text editor I've been working on. To do this, I need a simple lexer for various languages (I don't need a full one - I'm only interested in highlighting things like comments, strings, numbers and keywords). The way my editor component ...
I am going through Chris Pine's Learn to Program Ruby Book.
One of his chapter 6 exercises is to write a program for the 99 bottles of beer on the wall song. I was struggling so I googled for some answers.
I found the following two:
bottle = 99
while bottle > 0
if bottle > 1
puts bottle...
@Matt: This is actually not a good question for CR. The OP is just asking about which is best instead of a review of one or both. The close reason here is justified, though. It's probably not a good question on any SE site. — Jamal9 secs ago