Search Results

Search found 163 results on 7 pages for 'trivia'.

Page 1/7 | 1 2 3 4 5 6 7  | Next Page >

  • Code Trivia #7

    - by João Angelo
    Lets go for another code trivia, it’s business as usual, you just need to find what’s wrong with the following code: static void Main(string[] args) { using (var file = new FileStream("test", FileMode.Create) { WriteTimeout = 1 }) { file.WriteByte(0); } } TIP: There’s something very wrong with this specific code and there’s also another subtle problem that arises due to how the code is structured.

    Read the article

  • Code Trivia #6

    - by João Angelo
    It’s time for yet another code trivia and it’s business as usual. What will the following program output to the console? using System; using System.Drawing; using System.Threading; class Program { [ThreadStatic] static Point Mark = new Point(1, 1); static void Main() { Thread.CurrentThread.Name = "A"; MoveMarkUp(); var helperThread = new Thread(MoveMarkUp) { Name = "B" }; helperThread.Start(); helperThread.Join(); } static void MoveMarkUp() { Mark.Y++; Console.WriteLine("{0}:{1}", Thread.CurrentThread.Name, Mark); } }

    Read the article

  • Code Trivia #5

    - by João Angelo
    A quick one inspired by real life broken code. What’s wrong in this piece of code? class Planet { public Planet() { this.Initialize(); } public Planet(string name) : this() { this.Name = name; } private string name = "Unspecified"; public string Name { get { return name; } set { name = value; } } private void Initialize() { Console.Write("Planet {0} initialized.", this.Name); } }

    Read the article

  • Code Trivia #4

    - by João Angelo
    Got the inspiration for this one in a recent stackoverflow question. What should the following code output and why? class Program { class Author { public string FirstName { get; set; } public string LastName { get; set; } public override string ToString() { return LastName + ", " + FirstName; } } static void Main() { Author[] authors = new[] { new Author { FirstName = "John", LastName = "Doe" }, new Author { FirstName = "Jane", LastName="Doe" } }; var line1 = String.Format("Authors: {0} and {1}", authors); Console.WriteLine(line1); string[] serial = new string[] { "AG27H", "6GHW9" }; var line2 = String.Format("Serial: {0}-{1}", serial); Console.WriteLine(line2); int[] version = new int[] { 1, 0 }; var line3 = String.Format("Version: {0}.{1}", version); Console.WriteLine(line3); } } Update: The code will print the first two lines // Authors: Doe, John and Doe, Jane // Serial: AG27H-6GHW9 and then throw an exception on the third call to String.Format because array covariance is not supported in value types. Given this the third call of String.Format will not resolve to String.Format(string, params object[]), like the previous two, but to String.Format(string, object) which fails to provide the second argument for the specified format and will then cause the exception.

    Read the article

  • Our Geek Trivia App for Windows 8 is Now Available Everywhere

    - by The Geek
    When we first released our Geek Trivia app, it was sadly only available in the US store for Windows 8, but now you can get it no matter where you live. It’s completely free, so get your copy right now! For those that aren’t familiar with this app—it’s really quite simple: if you want your daily dose of Geek Trivia to show up on a Live Tile on your Windows 8 Start Screen, get this app. We’ve also got quizzes, loads of previous trivia, and we’ll be adding even more features in the near future. Our Geek Trivia App for Windows 8 is Now Available Everywhere How To Boot Your Android Phone or Tablet Into Safe Mode HTG Explains: Does Your Android Phone Need an Antivirus?

    Read the article

  • Download the Official How-To Geek Trivia App for Windows 8

    - by The Geek
    The new How-To Geek Trivia application has just been approved in the Windows 8 store, so if you’re already running the release preview you can go and download it right now for free. It’ll give you a daily dose of geeky trivia right on your Windows 8 desktop. Click Here to Download Geek Trivia for Windows 8 Each trivia question will present you with the question, and then once you answer, will show you whether you picked the right one as well as the full description. How to Banish Duplicate Photos with VisiPic How to Make Your Laptop Choose a Wired Connection Instead of Wireless HTG Explains: What Is Two-Factor Authentication and Should I Be Using It?

    Read the article

  • This Week in Geek History: NORAD Tracks Santa, First HTTP Test, Babbage’s Birthday

    - by Jason Fitzpatrick
    History trivia shouldn’t be limited to just treaty dates and wars ending, we’re marking off major milestones in geek history—one week at at time. This week in history we’ve got Santa on the Cold War radar, baby HTTP going for a spin, and Babbage’s birth to help usher in the age of computers. Latest Features How-To Geek ETC How to Use the Avira Rescue CD to Clean Your Infected PC The Complete List of iPad Tips, Tricks, and Tutorials Is Your Desktop Printer More Expensive Than Printing Services? 20 OS X Keyboard Shortcuts You Might Not Know HTG Explains: Which Linux File System Should You Choose? HTG Explains: Why Does Photo Paper Improve Print Quality? An Alternate Star Wars Christmas Special [Video] Sunset in a Tropical Paradise Wallpaper Natural Wood Grain Icons for Your Desktop and App Launcher Docks My Blackberry Is Not Working! The Apple Too?! [Funny Video] Hidden Tracks Your Stolen Mac; Free Until End of January Why the Other Checkout Line Always Moves Faster

    Read the article

  • Code Trivia: optimize the code for multiple nested loops

    - by CodeToGlory
    I came across this code today and wondering what are some of the ways we can optimize it. Obviously the model is hard to change as it is legacy, but interested in getting opinions. Changed some names around and blurred out some core logic to protect. private static Payment FindPayment(Order order, Customer customer, int paymentId) { Payment payment = Order.Payments.FindById(paymentId); if (payment != null) { if (payment.RefundPayment == null) { return payment; } if (String.Compare(payment.RefundPayment, "refund", true) != 0 ) { return payment; } } Payment finalPayment = null; foreach (Payment testpayment in Order.payments) { if (testPayment.Customer.Name != customer.Name){continue;} if (testPayment.Cancelled) { continue; } if (testPayment.RefundPayment != null) { if (String.Compare(testPayment.RefundPayment, "refund", true) == 0 ) { continue; } } if (finalPayment == null) { finalPayment = testPayment; } else { if (testPayment.Value > finalPayment.Value) { finalPayment = testPayment; } } } if (finalPayment == null) { return payment; } return finalPayment; } Making this a wiki so code enthusiasts can answer without worrying about points.

    Read the article

  • Most unintuitive behaviour in the .Net framework?

    - by BlueRaja
    Intended behavior is often another phrase for bug-which-we-knew-about-when-we-wrote-it, but-we-wrote-it-anyways. Because it was "intended" (or perhaps it is now too late or too difficult), many of these extremely-unintuitive bugs never get fixed. For instance, consider the following code (C#): TextInfo textInfo = Thread.CurrentThread.CurrentCulture.TextInfo; textInfo.ToTitleCase("hello world!"); //Returns "Hello World!" textInfo.ToTitleCase("hElLo WoRld!"); //Returns "Hello World!" textInfo.ToTitleCase("Hello World!"); //Returns "Hello World!" What would you expect textInfo.ToTitleCase("HELLO WORLD!"); to return? In fact, it returns "HELLO WORLD!". This was well-documented "intended behavior," but, in my eyes, is extremely unintuitive, and therefore a bug. What is some other unintuitive behavior like this in this in the .Net framework? Bonus points if you can provide a fix that does not break backwards-compatibility. Remember! Always keep these two simple rules in mind when designing an API (or anything else): Make the common case the default, and Keep It Simple, Stupid!

    Read the article

  • What are some programming questions (or mistakes) you get wrong only as you get better?

    - by BlueRaja
    In programming, as many professions, there are mistakes you'll make now that you may not have made as a beginner. For instance, consider pointers: In C++, is there any difference between arrays and pointers? The beginner will say yes, they are two completely different concepts, and treat them as such. The intermediate programmer (having learned that arrays are pointers internally) will tell you no, they are the same thing, and may miss some crucial bugs by interchanging them all willy-nilly. The expert, however, will again say they are different things (ex. see here or here). What other questions/mistakes are like this?

    Read the article

  • How to make code run a certain amount of times before returning something?

    - by user3564967
    I made a trivia game and I have to make a method (SuccessOrFail) that will return whether the user beat the trivia or not. namespace D4 { /// <summary> /// Displays the trivia and returns whether the user succeeded or not, number of questions asked, and a free piece of trivia. /// </summary> public partial class TriviaForm : Form { private Trivia trivia; private Question question; private Random rand = new Random(); private HashSet<int> pickedQuestion = new HashSet<int>(); private string usersAnswer; private int numCorrectAnswers; private int numIncorrectAnswers; public TriviaForm() { InitializeComponent(); this.trivia = new Trivia(); QuestionRandomizer(); QuestionOutputter(); } /// <summary> /// This method will return true if succeeded or false if not. /// </summary> /// <returns>Whether the user got the trivia right or not</returns> public bool SuccessOrFail(bool wumpus) { bool successOrFail = false; int maxQuestions = 3; if (wumpus == true) maxQuestions = 5; int numNeededCorrect = maxQuestions / 2 + 1; if (this.usersAnswer == question.CorrectAnswer.ToString()) numCorrectAnswers++; else numIncorrectAnswers++; if (numCorrectAnswers + numIncorrectAnswers == maxQuestions) { if (numCorrectAnswers == numNeededCorrect) successOrFail = true; else successOrFail = false; numCorrectAnswers = 0; numIncorrectAnswers = 0; return successOrFail; } else return false; } /// <summary> /// This method will output a free answer to the player. /// </summary> public string FreeTrivia() { return question.Freetrivia; } // This method tells the player whether they were correct or not. private void CorrectOrNot() { if (this.usersAnswer == question.CorrectAnswer.ToString()) MessageBox.Show("Correct"); else MessageBox.Show("Incorrect"); } // Displays the questions and answers on the form. private void QuestionOutputter() { this.txtQuestion.Text = question.QuestionText; this.txtBox0.Text = question.Answers[0]; this.txtBox1.Text = question.Answers[1]; this.txtBox2.Text = question.Answers[2]; this.txtBox3.Text = question.Answers[3]; } // Clears the TextBoxes and displays a new random question. private void btnNext_Click(object sender, EventArgs e) { this.usersAnswer = txtAnswer.Text; CorrectOrNot(); this.txtQuestion.Clear(); this.txtBox0.Clear(); this.txtBox1.Clear(); this.txtBox2.Clear(); this.txtBox3.Clear(); this.txtAnswer.Clear(); this.txtAnswer.Focus(); QuestionRandomizer(); QuestionOutputter(); this.txtsuc.Text = SuccessOrFail(false).ToString(); } // Choose a random number and assign the corresponding data to question, refreshes the list if all questions used. private void QuestionRandomizer() { if (pickedQuestion.Count < trivia.AllQuestions.Count) { int random; do { random = rand.Next(trivia.AllQuestions.Count); } while (pickedQuestion.Contains(random)); pickedQuestion.Add(random); this.question = trivia.AllQuestions.ToArray()[random]; if (pickedQuestion.Count == trivia.AllQuestions.ToArray().Length) pickedQuestion.Clear(); } } } } My question is how to make it so that the code asks the user 3 or 5 questions and then returns whether the user won or not? I was wondering if somehow I could make a public void that would just make the form pop up and ask the user 3 to 5 questions and then once it asks the maximum number of questions, to close and then have a method that returns true if the user won, or false if they didn't. But I literally have no idea how to do that. Edit: So I know a for loop can make code run more than once. But the problem I'm having is, is that I don't know how to make it so that the trivia game asks 3 to 5 questions BEFORE returning something.

    Read the article

  • What stackoverflow questions bring out the best in you? [closed]

    - by Mark Robinson
    This question is to help me (us) ask better questions of this community to encourage better working together. What questions here bring out the best in you? I don't mean which are the best / most appropriate questions but which bring the best out of you? That is, it brings out your best thinking and most constructive behaviour. Consider, for example, questions that make you think or that are asked in a certain way. Or consider specific a question should be. Or more abstractly, questions asked on a certain day / time, ... So I'm not necessarily asking about specific subjects but rather how a question is asked. What inspires you to drop everything and start answering? This comes from my observing questions that get highest points - I’m graduating with a Computer Science degree but I don’t feel like I know how to program. is very positive but my first ever question caused a minor storm. Ironically, I'm nervous posting this question so please don't attack if this is inappropriate.

    Read the article

  • More trivia than really important: Why no new() constraint on Activator.CreateInstance<T>() ?

    - by flq
    I think there are people who may be able to answer this, this is a question out of curiosity: The generic CreateInstance method from System.Activator, introduced in .NET v2 has no type constraints on the generic argument but does require a default constructor on the activated type, otherwise a MissingMethodException is thrown. To me it seems obvious that this method should have a type constraint like Activator.CreateInstance<T>() where T : new() { ... } Just an omission or some anecdote lurking here?

    Read the article

  • A Good Developer is So Hard to Find

    - by James Michael Hare
    Let me start out by saying I want to damn the writers of the Toughest Developer Puzzle Ever – 2. It is eating every last shred of my free time! But as I've been churning through each puzzle and marvelling at the brain teasers and trivia within, I began to think about interviewing developers and why it seems to be so hard to find good ones.  The problem is, it seems like no matter how hard we try to find the perfect way to separate the chaff from the wheat, inevitably someone will get hired who falls far short of expectations or someone will get passed over for missing a piece of trivia or a tricky brain teaser that could have been an excellent team member.   In shops that are primarily software-producing businesses or other heavily IT-oriented businesses (Microsoft, Amazon, etc) there often exists a much tighter bond between HR and the hiring development staff because development is their life-blood. Unfortunately, many of us work in places where IT is viewed as a cost or just a means to an end. In these shops, too often, HR and development staff may work against each other due to differences in opinion as to what a good developer is or what one is worth.  It seems that if you ask two different people what makes a good developer, often you will get three different opinions.   With the exception of those shops that are purely development-centric (you guys have it much easier!), most other shops have management who have very little knowledge about the development process.  Their view can often be that development is simply a skill that one learns and then once aquired, that developer can produce widgets as good as the next like workers on an assembly-line floor.  On the other side, you have many developers that feel that software development is an art unto itself and that the ability to create the most pure design or know the most obscure of keywords or write the shortest-possible obfuscated piece of code is a good coder.  So is it a skill?  An Art?  Or something entirely in between?   Saying that software is merely a skill and one just needs to learn the syntax and tools would be akin to saying anyone who knows English and can use Word can write a 300 page book that is accurate, meaningful, and stays true to the point.  This just isn't so.  It takes more than mere skill to take words and form a sentence, join those sentences into paragraphs, and those paragraphs into a document.  I've interviewed candidates who could answer obscure syntax and keyword questions and once they were hired could not code effectively at all.  So development must be more than a skill.   But on the other end, we have art.  Is development an art?  Is our end result to produce art?  I can marvel at a piece of code -- see it as concise and beautiful -- and yet that code most perform some stated function with accuracy and efficiency and maintainability.  None of these three things have anything to do with art, per se.  Art is beauty for its own sake and is a wonderful thing.  But if you apply that same though to development it just doesn't hold.  I've had developers tell me that all that matters is the end result and how you code it is entirely part of the art and I couldn't disagree more.  Yes, the end result, the accuracy, is the prime criteria to be met.  But if code is not maintainable and efficient, it would be just as useless as a beautiful car that breaks down once a week or that gets 2 miles to the gallon.  Yes, it may work in that it moves you from point A to point B and is pretty as hell, but if it can't be maintained or is not efficient, it's not a good solution.  So development must be something less than art.   In the end, I think I feel like development is a matter of craftsmanship.  We use our tools and we use our skills and set about to construct something that satisfies a purpose and yet is also elegant and efficient.  There is skill involved, and there is an art, but really it boils down to being able to craft code.  Crafting code is far more than writing code.  Anyone can write code if they know the syntax, but so few people can actually craft code that solves a purpose and craft it well.  So this is what I want to find, I want to find code craftsman!  But how?   I used to ask coding-trivia questions a long time ago and many people still fall back on this.  The thought is that if you ask the candidate some piece of coding trivia and they know the answer it must follow that they can craft good code.  For example:   What C++ keyword can be applied to a class/struct field to allow it to be changed even from a const-instance of that class/struct?  (answer: mutable)   So what do we prove if a candidate can answer this?  Only that they know what mutable means.  One would hope that this would infer that they'd know how to use it, and more importantly when and if it should ever be used!  But it rarely does!  The problem with triva questions is that you will either: Approve a really good developer who knows what some obscure keyword is (good) Reject a really good developer who never needed to use that keyword or is too inexperienced to know how to use it (bad) Approve a really bad developer who googled "C++ Interview Questions" and studied like hell but can't craft (very bad) Many HR departments love these kind of tests because they are short and easy to defend if a legal issue arrises on hiring decisions.  After all it's easy to say a person wasn't hired because they scored 30 out of 100 on some trivia test.  But unfortunately, you've eliminated a large part of your potential developer pool and possibly hired a few duds.  There are times I've hired candidates who knew every trivia question I could throw out them and couldn't craft.  And then there are times I've interviewed candidates who failed all my trivia but who I took a chance on who were my best finds ever.    So if not trivia, then what?  Brain teasers?  The thought is, these type of questions measure the thinking power of a candidate.  The problem is, once again, you will either: Approve a good candidate who has never heard the problem and can solve it (good) Reject a good candidate who just happens not to see the "catch" because they're nervous or it may be really obscure (bad) Approve a candidate who has studied enough interview brain teasers (once again, you can google em) to recognize the "catch" or knows the answer already (bad). Once again, you're eliminating good candidates and possibly accepting bad candidates.  In these cases, I think testing someone with brain teasers only tests their ability to answer brain teasers, not the ability to craft code. So how do we measure someone's ability to craft code?  Here's a novel idea: have them code!  Give them a computer and a compiler, or a whiteboard and a pen, or paper and pencil and have them construct a piece of code.  It just makes sense that if we're going to hire someone to code we should actually watch them code.  When they're done, we can judge them on several criteria: Correctness - does the candidate's solution accurately solve the problem proposed? Accuracy - is the candidate's solution reasonably syntactically correct? Efficiency - did the candidate write or use the more efficient data structures or algorithms for the job? Maintainability - was the candidate's code free of obfuscation and clever tricks that diminish readability? Persona - are they eager and willing or aloof and egotistical?  Will they work well within your team? It may sound simple, or it may sound crazy, but when I'm looking to hire a developer, I want to see them actually develop well-crafted code.

    Read the article

  • Variables are "lost" somewhere, then reappear... all with no error thrown.

    - by rob - not a robber
    Hi All, I'm probably going to make myself look like a fool with my horrible scripting but here we go. I have a form that I am collecting a bunch of checkbox info from using a binary method. ON/SET=1 !ISSET=0 Anyway, all seems to be going as planned except for the query bit. When I run the script, it runs through and throws no errors, but it's not doing what I think I am telling it to. I've hard coded the values in the query and left them in the script and it DOES update the DB. I've also tried echoing all the needed variables after the script runs and exiting right after so I can audit them... and they're all there. Here's an example. ####FEATURES RECORD UPDATE ### HERE I DECIDE TO RUN THE SCRIPT BASED ON WHETHER AN IMAGE BUTTON WAS USED if (isset($_POST["button_x"])) { ### HERE I AM ASSIGNING 1 OR 0 TO A VAR BASED ON WHTER THE CHECKBOX WAS SET if (isset($_POST["pool"])) $pool=1; if (!isset($_POST["pool"])) $pool=0; if (isset($_POST["darts"])) $darts=1; if (!isset($_POST["darts"])) $darts=0; if (isset($_POST["karaoke"])) $karaoke=1; if (!isset($_POST["karaoke"])) $karaoke=0; if (isset($_POST["trivia"])) $trivia=1; if (!isset($_POST["trivia"])) $trivia=0; if (isset($_POST["wii"])) $wii=1; if (!isset($_POST["wii"])) $wii=0; if (isset($_POST["guitarhero"])) $guitarhero=1; if (!isset($_POST["guitarhero"])) $guitarhero=0; if (isset($_POST["megatouch"])) $megatouch=1; if (!isset($_POST["megatouch"])) $megatouch=0; if (isset($_POST["arcade"])) $arcade=1; if (!isset($_POST["arcade"])) $arcade=0; if (isset($_POST["jukebox"])) $jukebox=1; if (!isset($_POST["jukebox"])) $jukebox=0; if (isset($_POST["dancefloor"])) $dancefloor=1; if (!isset($_POST["dancefloor"])) $dancefloor=0; ### I'VE DONE LOADS OF PERMUTATIONS HERE... HARD SET THE 1/0 VARS AND LEFT THE $estab_id TO BE PICKED UP. SET THE $estab_id AND LEFT THE COLUMN DATA TO BE PICKED UP. ALL NO GOOD. IT _DOES_ WORK IF I HARD SET ALL VARS THOUGH mysql_query("UPDATE thedatabase SET pool_table='$pool', darts='$darts', karoke='$karaoke', trivia='$trivia', wii='$wii', megatouch='$megatouch', guitar_hero='$guitarhero', arcade_games='$arcade', dancefloor='$dancefloor' WHERE establishment_id='22'"); ###WEIRD THING HERE IS IF I ECHO THE VARS AT THIS POINT AND THEN EXIT(); they all show up as intended. header("location:theadminfilething.php"); exit(); THANKS ALL!!!

    Read the article

  • Best way to go for simple online multi-player games?

    - by Mr_CryptoPrime
    I want to create a trivia game for my website. The graphic design does not have to be too fancy, probably no more advanced than a typical flash game. It needs to be secure because I want users to be able to play for real money. It also needs to run fast so users don't spend their time frustrated with game freezing. Compatibility, as with almost all online products, is key because of the large target market. I am most acquainted with Java programming, but I don't want to do it in Java if there is something much better. I am assuming I will have to utilize a variety of different languages in order for everything to come together. If someone could point out the main structure of everything so I could get a good start that would be great! 1) Language choice for simple secure online multiplayer games? 2) Perhaps use a database like MySQL, stored on a secure server for the trivia questions? 3) Free educational resources and even simpler projects to practice? Any ideas or suggestions would be helpful...Thanks!

    Read the article

  • The Battle of Helm’s Deep in LEGO [Video]

    - by Jason Fitzpatrick
    Not only is this an impressive rendering of the Lord of the Ring’s series Battle of Helm’s Deep, but the animator threw in some great cameos and jokes along the way. LEGO The Battle of Helm’s Deep [via Geeks Are Sexy] Our Geek Trivia App for Windows 8 is Now Available Everywhere How To Boot Your Android Phone or Tablet Into Safe Mode HTG Explains: Does Your Android Phone Need an Antivirus?

    Read the article

  • Get to Know the ‘Real’ Pyro [Humorous Team Fortress 2 Video]

    - by Asian Angel
    People sometimes wonder just what is going through Pyro’s head when he is spreading mayhem and destruction. If you are one of them, then here is your chance to see things from Pyro’s ‘unique’ point-of-view! Meet the Pyro [via Dorkly] How to Use an Xbox 360 Controller On Your Windows PC Download the Official How-To Geek Trivia App for Windows 8 How to Banish Duplicate Photos with VisiPic

    Read the article

  • The World of ‘Game of Thrones’ in Minecraft [Image Gallery]

    - by Asian Angel
    Are you a serious ‘Game of Thrones’ fan? Then prepare for a visual feast with this gallery of images showing a recreation of the world of Westeros in Minecraft. Here is another visual teaser from this awesome gallery… WesterosCraft Gallery (Imgur) [via Neatorama] How to Play Classic Arcade Games On Your PC How to Use an Xbox 360 Controller On Your Windows PC Download the Official How-To Geek Trivia App for Windows 8

    Read the article

  • A Perfect Example of Why You Never, Ever Buy a Used Keyboard [Humorous Image]

    - by Asian Angel
    Just go buy a new keyboard…unless you are into masochistic self-torture or other similar pursuits… Note: If you have the stomach for it, you can view the full-size version of the image here. I’m never going to buy a used keyboard ever again. [via Reddit Tech Support Gore] How to Fix a Stuck Pixel on an LCD Monitor How to Factory Reset Your Android Phone or Tablet When It Won’t Boot Our Geek Trivia App for Windows 8 is Now Available Everywhere

    Read the article

  • Declaration of Email Signatures [Video]

    - by Jason Fitzpatrick
    In honor of the Fourth of July and as a public service to highlight bad email signature practices, College Humor shares a peek at what the Declaration of Independence would look like if Founding Fathers shared our modern sensibilities about email signatures. Declaration of Email Signatures [College Humor] Download the Official How-To Geek Trivia App for Windows 8 How to Banish Duplicate Photos with VisiPic How to Make Your Laptop Choose a Wired Connection Instead of Wireless

    Read the article

1 2 3 4 5 6 7  | Next Page >