« first day (471 days earlier)      last day (3562 days later) » 

12:03 AM
 
0
Q: Is my spin-lock implementation correct?

OneOfOneI'm working on a project where a spinlock is more appropriate than a mutex, and after few tries I came up with: type SpinLock uint32 func (sl *SpinLock) Lock() { for !atomic.CompareAndSwapUint32((*uint32)(sl), 0, 1) { runtime.Gosched() //without this it locks up on GOMAXPROCS > 1 ...

 
Now I have to ask a question on Stack Overflow...
 
12:19 AM
We're back at 96% answered!
I consider a "specialization" of the tag. It's warranted and useful.
 
The unanswered count is still at 697, though. Weird.
 
I'm not suggesting should be removed.
0
Q: Static function variables in Swift

nhgrifI'm trying to figure out how to declare a static variable scoped only locally to a function in Swift. In C, this might look something like this: int foo() { static int timesCalled = 0; ++timesCalled; return timesCalled; } In Objective-C, it's basically the same: - (NSInteger)foo ...

 
> Simulated annealing (SA) is a generic probabilistic metaheuristic for the global optimization problem of locating a good approximation to the global optimum of a given function in a large search space.
I had to re-read that a few times
 
2
Q: Is this safe against major XSS attacks ? (text only)

Fábio LinharesI am building a classifieds website here in Portugal. And I'm now in the security phase. So until now i already made what i thing that it is a good measure against SQL injection, and the way i did it was like the following: $firstname = chunk_split(mysql_real_escape_string($_POST[firstname]),1,'...

 
Wow, what a crudy solution:
 
12:33 AM
@Jamal 698. Makes it 95.8% answered (1-698/16652)
@ckuhn203 is it me or there's not really a need for a VBA macro to achieve what OP is doing?
..gotta go :(
 
12:54 AM
@Mat'sMug, I have a feeling it's being over complicated too, but I won't know for sure until (if) OP updates.
In the meantime, he's got lots to chew on.
 
How long should Sieve of Eratosthenes take to calculate 0 to 1,000,000 ?
 
Not long. It should only take around 1,250,000 iterations. (Guesstimated)
 
less than a few seconds
 
I've done something wrong.
 
like 0.5 to 2 seconds
 
1:04 AM
I'm approaching 300,000 iterations....
 
maybe less
 
I forgot to cut out all the evens at that start.
So no more than 600k iterations? Still, no more than a few seconds.
 
Looks like Xcode is crashing.
 
0
Q: Issue with Simple Python Volume Calculator

HyzicaI'm a beginner learning Python, one of my first projects was to try to construct something that would calculate volume for a few basic geometrical shapes. The issue I'm running into is that when I run the program through Linux Mint 17's python interpreter it always gives me an incorrect result f...

 
0.01 seconds in C++ :/
 
1:17 AM
to 1 million?
 
Yup. And I verified the results since that sounds too fast.
But I guess it makes sense. 1,000,000 is pretty damn small these days.
 
Swift/Xcode is not handling one million at all. It seems to be producing correct results for one thousand though
 
@Captain first post, off-topic /broken code
 
Hrmmm... Maybe post a gist or something?
(though I don't know swift at all, so not sure how much help I'll be haha)
 
It's probably my algorithm.
Or it could be how the playground works
 
1:22 AM
evens don't need a special case. the 2 case will catch it in the normal loop
 
Does anyone else have an additional answer for this? The two on there so far only cover a tiny portion of the code.
 
If you just generate the results and don't actually dump all of them how long does it take to run?
Output is shockingly slowed compared to computation.
 
I know output is slow
But if you'll notice, the output doesn't happen until it's all calculated.
It's only calculated once.
I was just outputting to check.
 
Hrmmmmm
 
    public static func isPrime(number: Int) -> Bool {

        if !self.isInitialized {
            self.initializeSieve()
        }
        return primes[number]
    }
I only generate if the array isn't already populated
 
1:24 AM
Yeah, I saw that. was just making sure you werent timing the entire execution
 
No, I haven't actually timed anything.
 
The algo seems to be basically what I had in C++ other than the extra evens loop
ah, it just doesnt terminate
perhaps there's a segfault or something?
i've seen segfaults in C++ sometimes look like hanging
but i doubt swift does that
 
It's not hanging.
The playground keeps a running track of how many times lines of code are called
 
ah
 
Which actually is probably what is slowing it down.
 
1:26 AM
Yeah, probably. Is it possible to disable that?
 
I can just put the code in a non-playground and compile and run it.
 
ah
 
Xcode actually frequently crashes when I try this to 1 mil
 
hrmmmm
that's rather weird
 
It's a beta.
 
1:28 AM
@nhgrif do arrays of bools default to true?
 
private static var primes: [Bool] = [Bool](count: maxNumber + 1, repeatedValue: true)
 
No idea.
 
because you're only ever setting them to false
 
I'm assuming repeatedValue: true sets them all to true
 
Yes
 
1:28 AM
ah ok
 
They're set to true in that line corbin pasted.
 
Surely the profiling overhead isn't this bad... I hope not anyway.
 
@nhgrif direct translation of your code to c#: 0.001 to 0.01s
 
Welp
This says 10 seconds.
 
Does C# not have an isEmpty() method for List? I was just about to post an answer about it for the Blackjack question, until I realized that this wasn't Java.
 
1:47 AM
@nhgrif compiled as a release binary? because if so, i sure to god hope apple steps up their optimization soon x.x
 
Debug build but with optimizations set for fastest, aggressive optimizations
 
@Jamal if (!list.Any())
 
Thanks!
 
Wow.
Almost same algorithm in Objective-C takes just under 0.3
And for right now, that algorithm is actually iterating to 1000000 twice
if (!primes) {
        primes = [NSMutableArray arrayWithCapacity:maxNumber + 1];
        primes[0] = @NO;
        primes[1] = @NO;
        for (NSInteger index = 2; index <= maxNumber; ++index) {
            primes[index] = @YES;
        }
        for (NSInteger index = 2; index <= maxNumber; ++index) {
            if ([primes[index] boolValue]) {
                for (NSInteger subIndex = (index * 2); subIndex <= maxNumber; subIndex += index) {
                    primes[subIndex] = @NO;
                }
0
Q: Why is Swift so... unSwift... at Sieve of Eratosthenes?

nhgrifThe following Swift snippet takes just over 10 full seconds to run: import Foundation struct Sieve { private static let maxNumber: Int = 1_000_000 private static var primes: [Bool] = [Bool](count: maxNumber + 1, repeatedValue: true) private static var isInitialized: Bool = false ...

 
2:05 AM
@Jamal that blackjack code :O
 
Actually, I've changed my mind on that. Some info suggests that Count() would be faster than Any() with List<T>.
 
@Jamal yes and .Count is faster still, but i don't think it matters in a blackjack game
(Count() returns Count if it's called on an object implementing ICollection)
 
I didn't even know there was more to that. I guess I'm just too used to the empty methods in C++ and Java.
 
yeah, i have the opposite. i'm trying to learn java and am constantly frustrated with the different apis :)
like LinkedList not exposing LinkedListNode
 
@nhgrif why are you getting downvote on SO? I upvoted to compensate, I think it's a valuable question
 
2:18 AM
I don't know, but...
I can get it to run at 0.02 now..
@Corbin It runs 0.02 seconds now. Swift apparently has its own compiler and doesn't use Apple LLVM compiler that ObjC uses.
And on none optimization level, there's a ton of overhead checking to make sure you're not going out of bounds on array indexes.
 
Wait, wait, wait... Swift has it's own compiler, but the LLVM toolchain can also compile it? That's kind of weird.
 
I don't know...
 
And damn, I still wouldn't expect it to be that slow.
I suppose it is just 100% array accesses though haha
Kind of a pathological case
Strange
 
By the way, I think this is one of my most complete answers ever on Stack Overflow:
4
A: Does Swift Automatically Clone Arguments?

nhgrifBy default, value type variables are passed to methods and functions not just by value, but as constants by value. That is, not only can the function not change the value of the variable outside the function, it can't even change the value of the variable INSIDE the function. In order for a fun...

 
 
1 hour later…
3:22 AM
That's one Morwenn zombie down...
 
:D
Since my parallel programming textbook recommends experience with C, I think it's safe to say that my class will be based on C. So I just have to learn one new language next semester.
 
that's a good thing. I think just about every programmer should have some experience with C
 
By the way, your answer has a typo (the template line).
And my correction had a typo. :-P
 
whoops, thanks
 
I suppose I don't need to worry about answering more questions soon. I'll have my fill of programming, I'm sure.
 
3:27 AM
if you're doing parallel programming in C, yep
 
Same room and same instructor from computer architecture, too. But hopefully the grade won't be the same.
 
What year are you in now? Junior year?
 
Senior year. Second-to-last semester, if things go well.
 
ah, excellent
 
Soon I'll have to update my resume and work on interviews. But for now I'm trying to finish up.
 
4:17 AM
Monking
 
hiya
 
4:31 AM
0
Q: A simple command line linear interpolator in C

JPCI'm trying to become more familiar with C (been working through the MIT Practical Programming in C course and K&R) so decided to write a simple command-line linear interpolator. You can feed it a vector (where missing values are represented by 0n) and it should print an interpolated vector. Any c...

 
Y.\.'.;. .U.P.D.A.T.E. .t.a.b.l.e. .S.E.T. .e.m.a.i.l. .= codereview.stackexchange.com/questions/60334/…
"I'm now in the security phase" :(
 
4:55 AM
@Jamal Thank you!!
I have been gone all weekend, went to states fair and stuff, gotta start my trek for fanatic all over again....lol
goodnight all
 
night
 
5:22 AM
@mjolka I. .N.E.E.D. .M.O.R.E. .D.O.T.S.
 
@Phrancis "i have never used pdo, and to be sure of what i am doing, and having to learn all that now would be to much.." :(
 
// look ma, no escaping!
 
5:47 AM
0
Q: Check if two nodes are cousins in a Binary Tree

JavaDeveloperGiven the binary Tree and the two nodes say ‘a’ and ‘b’, determine whether the two nodes are cousins of each other or not. Two nodes are cousins of each other if they are at same level and have different parents. Looking for code review, optimizations and best practices. public final class C...

 
6:01 AM
0
Q: A Simple Web Alarm Clock

Lemony-AndrewI decided to strengthen my "vanilla javascript" skills since I've lately been getting more into jquery and just discovered the potential of node.js. So as a result, I decided to make a basic alarm clock in javascript and html. (Plus I needed an alarm clock ). So here's my script: // Load an a...

 
6:43 AM
0
Q: Group and send all files to filetype folder

Devashish DasI have around ~2M of files in one folder, which I need to manage. So, I want to separate them in groups by their filetypes. Example: filenames 1.A, 2.A, 3.A, 2.B, 3.B, 4.B, 5.C, 6.C My code: import os all_files = os.listdir(".") filetypes = list(set([i.split(".")[-1] for i in all_files])) f...

 
well this is cool: Sorting a set of UTF-8 encoded strings as strings of unsigned bytes yields the same order as sorting the corresponding Unicode strings lexicographically by codepoint.
 
7:02 AM
Monking @all ;)
 
Monking @Vogel612
 
7:49 AM
Monking @all
 
Monking @Nobody
 
Monking @Nobody
 
 
1 hour later…
9:15 AM
0
Q: How to keep a radio button values during pagination

Zay YaJava code - How to keep a radio button values during pagination. I used the pagination for tag. I implement the Online Tests in pagination. But,After clicking another page, have not the selected radio values. Please advice me ,how to handle the radio button values during pagination.

 
@CaptainObvious off-topic. User has no SO account
 
9:39 AM
0
Q: how to perform Binary Addition in vb.net

LOsunGMy requirement is to add two binary numbers. say "1001" and "0101" as binary1 and binary2, By using the following code i have executed. Partial Class Default2 Inherits System.Web.UI.Page Dim carry As Boolean = False ' Boolean variable to hold the carry if occured Protected Sub Butto...

 
10:20 AM
What should we do with this answer:
0
A: Time Limit Exceeds [HS11DIVS] - How to make it faster?

Łukasz KusznerSolutions and answers are given after the contest deadline at the contest forum. You are also very welcome to discuss them here but please do not do this before the end of the particular problem set series.

 
fleggit
 
From 2011?? Oh dear...
 
@SimonAndréForsberg: @Pimgd brought up the question by adding the
 
woops
guess adding that tag is just annoyance then, it would bump all the old questions
 
@Pimgd bumping old questions is not necessarily a bad thing
this answer should have been flagged a looooong time ago
 
10:30 AM
0
Q: Thread pool worker implementation

Emily L.As an exercise in using C++11 features I decided to make a thread pool class. I would like to have a review on the code with focus on: Standards compliance / Portability issues / Best practices Thread Safety / Exception handling API Performance issues (Yes I know std::mutex is slow on windows,...

 
@CaptainObvious Emily's first question!
 
hi
@SimonAndréForsberg are you there ?
 
10:45 AM
Monking @Bhathiya-JaDogg-Perera
 
@Bhathiya-JaDogg-Perera maybe
 
Monking
It's 4PM here :p
 
Monking is universal
2
 
@SimonAndréForsberg I'll get back to the "review prepare FX" on Thursday, I need to get ready for an Software Engineer Trainee Interview.
 
@Bhathiya-JaDogg-Perera alright
 
10:49 AM
Before I comeback can you verify the cmd arguments with janos, Since we need to implement in the UI as well, and are we going to make it available for other languages too.
@SimonAndréForsberg ^^ I meant other programming languages.
 
@Bhathiya-JaDogg-Perera: You are talking about the automatic CR question preparer?
 
@Bhathiya-JaDogg-Perera For me, Java is enough. But if anyone wants to port it, it is open-source for a reason.
 
I can imagine it would work well in Python
 
10:54 AM
@Bhathiya-JaDogg-Perera: It is written in Java?
@SimonAndréForsberg How about writing it as a Greasemonkey script so one can use it directly on the webpage?
 
@Nobody It's @SimonAndréForsberg project
 
@SimonAndréForsberg: No comment?
 
@SimonAndréForsberg ^^
 
11:23 AM
@Nobody yes it's Java
@Nobody I'm not sure how that would work as it reads files from your computer
@Bhathiya-JaDogg-Perera Oh, that's how you meant...
@Bhathiya-JaDogg-Perera Sure, it'd be nice to support other languages. I think it should be able to auto-detect the files though, possibly from the file extension .py, .cpp, .c, .h, etc.
 
What can you detect about a .h file extension without reading the file itself?
I know of 3 languages that use .h files.
 
I know, I know. Both C, C++ and Obj-C uses it.
(or does C++ use .hpp?)
 
C++ uses .h
Also actually, Obj-C++ technically uses it too... not sure if you want to count that as a language or not.
 
Hopefully though, they at least have some common rules for how to read them. The only Java-specific rules I've made that I can remember from the top of my head is how to deal with // TODO comments and how to deal with import statements.
 
@nhgrif: I have seen both .hpp and .h used for C++
 
11:32 AM
@nhgrif Is there a Objective-C++ language? Didn't know that.
 
Yes.
It's basically C++ with Objective-C syntax.
 
Two wrongs doesn't make a right.
 
It's kind of weird to see a meta answer from a moderator with negative votes.
-2
A: "Code not yet written" clarification: Are unimplemented interfaces on- or off-topic?

200_successI've previously stated that I believe that requests to review just interfaces are off-topic. I'd like to add a second answer explaining why I think they should be off-topic. A key ingredient to the success of Code Review is our working-code requirement. It brings concrete benefits to the commun...

 
@SimonAndréForsberg: What are the two wrongs?
 
C++ and ObjC I presume.
 
11:35 AM
^^ that
 
Last night, I had some Swift code that took 10 seconds to run. The Objective-C equivalentish took about 0.3 seconds.
Then I finally found the Swift optimizer settings and Swift took under 0.2 seconds.
With no optimizations in place, Swift apparently does a ton of array index checking.
 
@SimonAndréForsberg: In which way is C++ a wrong?
 
I don't even bother asking people what they don't like about Objective-C anymore. I'm content with their being fewer ObjC programmers in the world. Just means I can ask for more money from employers.
 
@nhgrif: I believe I read the same reasoning about Erlang recently
@nhgrif: Btw. how much of a future has ObjC when it has been dropped as the "main" language at Apple? Are there many Apple legacy systems around?
 
@Nobody funny you didn't ask that about Objective-C
 
11:49 AM
I am no Objective-C programmer and don't plan to learn it
But I use C++ nearly everyday and have a hard time seeing it "from the outside"
 
12:03 PM
0
A: Questions about interfaces, protocols, and APIs

ckuhn203Let's look at our six magic questions. Is code included directly in my question? (See Make sure you include your code in your question below.) Am I an owner or maintainer of the code? Is it actual code from a project rather than pseudo-code or example code? Do I want the code to be ...

 
0
Q: Avoiding python multiline string indentation

noisyI want to make this code: def usage(): print( """ Usage examples: Test deployment: $ fab [noinput] test deploy Staging deployment: $ fab [noinput] staging deploy Production deployment: $ fab [noinput] production deploy """) to look more like this: def usag...

 
0
A: Questions about interfaces, protocols, and APIs

PimgdI'd say no. Applying ckuhn203's answer, but I disagree with the last point; it doesn't actually do anything, so it's not working code for me. It's more like a bunch of structs. And what can you ask about a bunch of structs and interfaces? Well, whether you've named them right, of course... bu...

 
12:31 PM
0
Q: Extending the MVC Routecollection

ComplexityI'm currently developping an MVC framework on which I will be writing my websites. This is done through the usage of a starter kit. In standard MVC, your routes are registered like the following: /// <summary> /// Registers the routes. /// </summary> /// <param name="routes">The <see cref="...

 
@Nobody Well, to be honest C++ isn't that bad. I really should start using it more myself. I'm just spoiled by the simplicity of using Java and Eclipse
 
@SimonAndréForsberg Well, not Eclipse (I'm an IDEA fan), but seriously I used C++ for 4 years or so and there are several things I just don't miss at all.
Greetings, Programs.
 
@SimonAndréForsberg: I use C++ with Eclipse and I have used Java with Eclipse
the java integration is much better, of course
 
12:46 PM
@Donald.McLean Let me guess, Scala has all the advantages of C++ and fewer of the disadvantages? :)
 
@Donald.McLean: When was that?
 
@Nobody I think I tried once to get C++ to work with Eclipse, but I did not succeed then.
 
and what are those?
@SimonAndréForsberg: Depending on what you want to do it can be fairly easy. The directly supported C++ projects in Eclipse are really easy.
 
@SimonAndréForsberg Actually no. C++ does have one thing that Scala does not - and that's direct control of memory usage. This can be both an advantage and a disadvantage.
@Nobody 1996-2001 or so.
 
use the right tool for the job, language wars are silly, rabble rabble
 
12:49 PM
C++ has changed a lot since then
@Yuushi: How would we know what is the right tool without language wars :P
2
 
@Nobody Lots of languages have changed since then. Heck, Scala wasn't created until 2005.
 
@Nobody ....critical thinking?
 
critical thinking alone might not be sufficient
there might be aspects that you don't think (critical) about which get mentioned in language war debates
 
I think that in some cases, the way a person thinks makes some languages easier for them to use. I know that I have a lot of trouble with shell scripts and assembly.
 
@Donald.McLean I can never remember bash syntax
C++ syntax? No problem. Bash syntax? No idea.
 
12:55 PM
@Donald.McLean: On the other hand being forced to think in another way might lead to new insight and better results
 
@Nobody Only if the new language is one that isn't a mismatch for them. If someone tried to force me to develop something in a shell script, the result would be a disaster.
 
Yeah, fighting against the language won't help much :)
But there are lessons to be learned from most languages
assembler will usually give you a better understanding of the machine's needs/architecture
 
@Nobody i understand assembly, I just can't write in it.
It looks like I will be learning some Objective C though. My daughter will be taking a programming class this semester.
 
So you have to write all her assignments? :P
I don't see the connection
 
@Nobody No, but I can be the Voice of Experience.
 
1:06 PM
I see
 
@SimonAndréForsberg you will have to catch me earlier this coming friday! LOL
 
1:29 PM
Monking CRitters.
 
morning @rolfl
 
Monking!
sorry I was away all weekend, it's hard to review code going 90 MPH on a motorcycle.
6
 
1:47 PM
Sunburn much?
 
got that done and over with the first 2 weeks I had the bike...lol
still peeling here and there
 
Hello, World!
 
@Malachi Don't review and drive
3
@Malachi Well, both Volvo and Vulva is Latin...
 
Monking all
 
Hi skiwi!
 
1:59 PM
Tab color didn't change so forgot here apperantly last few hours :)
 
Well, interview in an hour... I'm excited
3
 
All the best.
 
Thank you
 
@Phrancis The force will be with you.
5
 
> earned at least 200 reputation on 77 days
> 292 days, 292 consecutive
365 in this year..... so, that's 73 more days in my year.
So, 73 days to yearling, 73 maxrep to legendary.
hmmmm.
 
2:12 PM
Nice
 
does that mean you get Legendary first, or Yearling first?
 
that's CR there @rolfl?
 
It means, if I get 200 rep every day from now to halloween, I get legendary and yearling at the same time.
 
I think Yearling, if you maxed rep today already
No
Yearling would be awarded upon login
Legendary would be awarded upon hitting the cap
 
on SO visited 461 days, 279 consecutive, on CR visited 185 days, 142 consecutive
 
2:14 PM
you already have today's login...
 
@Pimgd - I'll get yearling even if I don't log in again.
 
oh.
 
Better finish up any Edits you were working on quickly... :)
 
Then it depends whether you have today's cap already
if so, then it's not gonna happen
if not, then you could get today's cap, be at 72 caps needed
and on the day you still need to hit the cap once, you'll get the badge once you hit the cap
 
Oh, you think I have an off-by-one?
 
2:15 PM
then a couple hours later it'll be the next day and yearling
kinda?
 
meh, the point is that, a month or two ago, I though, hmm, can I do it?
now I think it's not going to happen.... I can't max out every day.
opportunity lost.
 
dooom
 
@rolfl Too much even for a monkey?
2
@Phrancis Good luck
 
@SimonAndréForsberg - on June 6, 2010, Jon Skeet did not get 200 rep.
Not even he has a perfect record ... ;-)
3
 
I'm confused by how to interpret the recent voting on Meta.
5
Q: "Code not yet written" clarification: Are unimplemented interfaces on- or off-topic?

Nikita BrizhakI would like to know what exactly it means. The reason for asking is my question which was recently put on hold: Async task queue design Can anyone please specify why the code I provided is considered "not yet written" and what is "written code" then? Any opinions?

Is the community divided? opinion turning around?
 
2:27 PM
1
A: Match Simple Sentence or Partial Sentence

h.j.k.Consider parameterized testing? JUnit Here is how you can use JUnit 4's Parameterized runner with your test cases so that you can get a slightly nicer output in Eclipse. The gotcha is that you need to annotate your test class with @RunWith using the Parameterized runner, and it looks like you c...

 
Bad reasoning in my second post?
 
Thanks, Santa!
 
I dunno... I was just discussing it with Ckuhn
we went from ontopic to offtopic to ontopic
 
Nice discussion. Haven't read it all yet, though.
By @rolfl and my interpretation, interface questions are off-topic. But the help page is not explicit about it, so our interpretation may be off.
 
@Pimgd ima join in on that one.
 
2:34 PM
However, I'm reluctant to change the help page while there is controversy.
 
@Phrancis good luck
 
Argh..... I am confused about this issue myself, @200.... and, my instinct is that interfaces are off-topic because interfaces are a design component.
 
May I suggest that you rename the chat on that topic and link it to the Meta post?
 
yet, when I see interface code, I can review the design.... but, the issue, is that the design is generally off-topic, and too broad for Code Review.
too opinionated, but all of Code Review is opinionated.
 
how to rename chat
 
2:38 PM
Shall we move discussion there?
 
Sure.
@Pimgd - I will do it.
 
@rolfl If existing design exists (within the code) already, design questions is not off-topic!
 
Code that works vs Code that compiles if there is a well defined definition to distinguish between the two, Half the problems can be solved :D
 
@Bhathiya-JaDogg-Perera Code that works = Code that produces the expected results
 
@All - discussion about interfaces moved to here: chat.stackexchange.com/rooms/16508/…
3
 
2:55 PM
0
Q: Print all possible combinations of size r, from an array of size n?

user3371223This is my working solution for the following problem: given an array of integers of size n, print all possible combinations of size r. Before proceed to the solution I have the following question: Combination, means that the order does not matter, right? I.e. printing {1, 2} is the same as {2, 1...

 
I like this
> vapourware
 
0
Q: Clean code attempt at ATM problem on codechef.com

M KThe problem asks you to take an integer (debit amount) and a double (credit or initial balance amount) and process the requested debit verifying that 1 it's a multiple of the minimum denomimation amount of $5 and that it's also smaller than the credit/balance. If either is untrue, it is supposed...

1
Q: Is a filter a good way to accomplish a dynamic class in angular?

jcreamer898I want to apply a different badge color with bootstrap depending on a number. I wrote a filter to accomplish this... angular.module('Demo') .filter('reserveStatus', function() { return function(num) { var klass = ""; num = parseInt(num, 10); if ...

0
Q: A better way of always dumping Gedit out of Terminal?

Travis WestonI use terminal alot, so it was frustrating to me to deal with gedit's inconsistent behavior between having a window open and when one was not. I ended up searching around, and finding a way of getting around this. I've created this bash script, and aliased it to gedit, and I've slowly been expand...

 
3:18 PM
0
A: "Code not yet written" clarification: Are unimplemented interfaces on- or off-topic?

Malachi I wasn't happy with this design, because it forced me to collect all the actions in one place, and because it is not very loop-friendly. Does the interface really force you to collect all the actions in one place or do you not understand how to do it differently? This is where you should sh...

 
@Malachi did you land on the wrong site??
this sounds helluva lot like a real CR answer and not a meta-answer imo.
 
0
Q: throwing an exception within a try catch block in php

Lloyd Mooreis there a cleaner way to do this? try { $ffprobe = FFProbe::create(); $streams = $ffprobe->streams($infile); $videoStreams = $streams->videos(); $audioStreams = $streams->audios(); if (!$videoStreams) { throw new Exception("Coul...

 
@Vogel612 I know right? I am not sure if the user understands what an interface does though. the whole question is a better fit for .... OMGOSH ... PRogrammers merged with SO, I am voting to Delete
 
wait wait..
 
these are ideas and designs, not Logic and Code — Malachi 5 mins ago
 
3:25 PM
2 reopen, 1 delete..
wth?
 
one reopen is from the user I am guessing
 
@Malachi I'd wait for the dust to settle,
 
mods should cross post my answer onto the closed question....lol
 
@Malachi wth??
 
I would lose all that rep anyway though...lol
 
3:30 PM
depends.
 
@CaptainObvious I'm glad I pointed out that the OP was using a double for currency.
 
Well, interview is out of the way, and I'm feeling good about it. The jist of the job is, crunching data and making sure it looks accurate, and then making it look pretty. Sounds like it has my name all over it lol.
 
@Phrancis Nice, hopefully your good feeling will be reality!
 
Yes :)
I told her I crunch data in my free time just for the fun of it lol.
 
@Phrancis Again, good luck!
 
3:48 PM
I got the review button on top bar. Nice
3
 
@Bhathiya-JaDogg-Perera congrats
 
With great power comes great responsibility.....
 
yay Spider Man reference
 
Is it just me or does this smells funny?
public function insert($arg)
{
    $this->_sql .= "INSERT INTO {$arg}";
    return $this;
}
public function columns($arg)
{
    $this->_sql .= " ({$arg})";
    return $this;
}
public function values($arg)
{
    $this->_sql .= " VALUES ({$arg})";
    return $this;
}
 
3:52 PM
@Phrancis That's like homemade SQL injection prevention, without preventing it.
2
 
I'm doing that too, feeling very bad
 
@skiwi I think it's a query builder...
 
0
Q: Design a simple LRU cache with a expiration time

MrROYHow to improve the performance of the code below ? public class SessionCache { private static ConcurrentHashMap<String, Object> cache = new ConcurrentHashMap<>(); private static ConcurrentHashMap<String, Long> expirations = new ConcurrentHashMap<>(); public static void put(String key, Obj...

0
Q: checking substring in 8086 asm?

setuI have tried like this to check a substring in a mainstring in 8086..Is there any shorter process to do this..My implementation is somekind of lengthy..I want help to shorten my code. DATA SEGMENT STR1 DB 'MADAM' LEN1 DW ($-STR1); storing the length of STR1 STR2 DB 'MADAA' LEN2 DW ($-STR2)...

 
um.... where's the where?
 
3:54 PM
@Phrancis I hate code like that. There's been plenty of "PHP SQL wrapper" questions here in the past.
 
It's called a big mess.
2
 
@SimonAndréForsberg ignore then ;)
 
That one looks like he's trying to fake dynamic SQL via PHP
 
@rolfl With great power comes great responsibility. With even more power comes a diamond next to your name.
2
 
At least use parametrized queries if you are insisting to build your own wrapper :)
 
3:54 PM
    public static ArrayList<String> genericSelectStrings(Connection con,
            String table,
            String getColumn, String whereColumn1, String equalsTo1,
            String whereColumn2, String equalsTo2, Logger log) {

        ArrayList<String> selectedData = new ArrayList<>();

        if (log == null) {
            return null; // whoa
        } else if (con == null) {
            log.error(EXCEPTION_TAG + DB_FAIL);
            return null;
        } else if (isBad(table, getColumn, whereColumn1, whereColumn2)) {
 
@skiwi 't would be nice, right?
@Bhathiya-JaDogg-Perera that's nowhere near generic...
 
@Bhathiya-JaDogg-Perera
 
I had to write that to keep myself sane.
 
@Bhathiya-JaDogg-Perera tip. you're ™ ;)
 
3:57 PM
unfortunately the ™ is not allowed in tags..
 
I'm just doing the worse thing bad way
This is better than copy pasting code all over the place, err
 
@Bhathiya-JaDogg-Perera nevermind then ;)
 

« first day (471 days earlier)      last day (3562 days later) »