Jump to content

espurritado

Member
  • Posts

    178
  • Joined

  • Last visited

Reputation Activity

  1. Agree
    espurritado got a reaction from straight_stewie in Comparing times   
    python has datetime. wit it you can create an object representing a time, a date or a date and time.
    you can make it so it parses an input string in whichever format you want to give it to it
  2. Like
    espurritado got a reaction from straight_stewie in C# Number Generation Question   
    The easiest way to do it would be to generate the random number to an auxiliar variable, check if the generated number is in the set and if it's not, add it to the set.
     
    On the amount of numbers you are generating for that range is more than likely that at least one, if no more, are repeated if you don't check. If you want to understand this try reading about the birthday problem.
  3. Agree
    espurritado got a reaction from Voze in Java Print Error   
    You are printing the reference to the object. Do something like:
    int[] aux=rowSums(arr2D); for(int i=0;i<aux.length;i++){ System.out.println(aux[i]); }  
  4. Agree
    espurritado got a reaction from RadiatingLight in Help me win a bet!   
    When Linus and Luke did the Cherry MX factory tour they mention at some point that at that moment the assembly line was doing a special order for the German goverment
  5. Like
    espurritado got a reaction from AlTech in How would i make this test multi threaded in C#?   
    Last year I had to do a presentation about multithreading in c#, here's the first proof of concept I wrote for thread pools. Hope it helps.
    namespace EjemploThreadPool { class Program { static void Main(string[] args) { ThreadPool.SetMaxThreads(2,5); for (int i =0;i<10;i++) { ThreadPool.QueueUserWorkItem(ThreadProc); } Console.Read(); } static void ThreadProc(Object stateInfo) { Console.WriteLine("Empiezo a trabajar"); Thread.Sleep(1000); Console.WriteLine("Termino de trabajar"); } } } EDIT: After reading your code, you would have to make everything inside the while a process which is the task you would assign to the thread. You would have to make sure H, O and A are only accessed by one thread at any given moment. Consider using something like locks for the increment section.Since there is a limit to how many calculations you make, there's no special need to consider fairness (some process might get stuck in the lock but it's not an infinite task so eventually it will go through)
    Finally, the stopwatch must be stopped either by the last process, or when all the processes are done. The easiest way is to keep a done process counter (also with exclusive access) and make the check at the end of every process
  6. Informative
    espurritado got a reaction from vorticalbox in How would i make this test multi threaded in C#?   
    Last year I had to do a presentation about multithreading in c#, here's the first proof of concept I wrote for thread pools. Hope it helps.
    namespace EjemploThreadPool { class Program { static void Main(string[] args) { ThreadPool.SetMaxThreads(2,5); for (int i =0;i<10;i++) { ThreadPool.QueueUserWorkItem(ThreadProc); } Console.Read(); } static void ThreadProc(Object stateInfo) { Console.WriteLine("Empiezo a trabajar"); Thread.Sleep(1000); Console.WriteLine("Termino de trabajar"); } } } EDIT: After reading your code, you would have to make everything inside the while a process which is the task you would assign to the thread. You would have to make sure H, O and A are only accessed by one thread at any given moment. Consider using something like locks for the increment section.Since there is a limit to how many calculations you make, there's no special need to consider fairness (some process might get stuck in the lock but it's not an infinite task so eventually it will go through)
    Finally, the stopwatch must be stopped either by the last process, or when all the processes are done. The easiest way is to keep a done process counter (also with exclusive access) and make the check at the end of every process
  7. Like
    espurritado got a reaction from SCHISCHKA in how are program languages created?   
    As the people before me have said computers basically understand 1s and 0s.
    It depends on the programming language on how it works, but let's assume a compiled language.
    First you have to define the language, the syntax, the semantic, the basic words, the basic types, etc.
    Then you have to create somehow a compiler, something that from a text file with a piece of code that follows the rules described in the previous step creates a file with the a of instructions for an OS to do what you asked to do.
    And there you go, you have your programming language.
    There's obviously more to it, you have to determine the memory structure for variables, the organization of your reserved words, the hierarchy of your names in the different levels.
     
  8. Informative
    espurritado got a reaction from vorticalbox in PHP simple way to create REST API   
    you need to use Slim. I would recommend using composer to install it
  9. Like
    espurritado got a reaction from newgeneral10 in Help with Java Array   
    lets take it step by step:
    you roll 2,3,3,3,5; your counts list is [0,0,0,0,0,0] you start reading your rolls read the 2; you increase the second element in your array by one; your counts list is [0,1,0,0,0,0] read the 3; you increase the third element in your array by one; your counts list is [0,1,1,0,0,0] read the 3; you increase the third element in your array by one; your counts list is [0,1,2,0,0,0] read the 3; you increase the third element in your array by one; your counts list is [0,1,3,0,0,0] read the 5; you increase the fifth element in your array by one; your counts list is [0,1,3,0,1,0] therefor [0,1,3,0,1,0].
    then, you just have to ask: is the counts list [1,1,1,1,1,0] or [0,1,1,1,1,1]? if it is, you've got a straight
    for four of a kind is even simpler, you just ask: is there a four in counts?
     
    also
     
    = means assignment
    == means comparison
     
    you've got every single condition wrong
     
  10. Like
    espurritado got a reaction from Mira Yurizaki in Help with Java Array   
    actually is not that unrelated, you just don't check for the suit and just go up to 6 instead of 13
  11. Informative
    espurritado got a reaction from Mr_KoKa in How to remove last comma   
    you could consider printing the first number outside the loop, and then in the loop, coma and the next number.
     
    also PLEASE use code tags thanks
  12. Informative
    espurritado reacted to techmattr in Nextcloud Box opinions   
    I agree the product NextCloud Box doesn't seem optimal unless you're just using it for a few documents or something. I recently started using NextCloud as a DropBox replacement and I really like it so far. I'm running it in a VM with a separate NAS as the backend storage.
  13. Informative
    espurritado reacted to ProjectBox153 in Nextcloud Box opinions   
    And why did they go for a USB 3.0 drive? The RPi doesn't have USB 3. But I agree: the Raspberry Pi is NOT a good choice for a NAS unit, unless it had some SERIOUS hardware and software optimizations.
  14. Like
    espurritado got a reaction from Mira Yurizaki in Keyboard application help.   
    you could consider setting  up the Danish keyboard in the OS. As long as the keys layout is the same (for example the Danish layout and the Spanish) you could press the key where your character is supposed to be and you will get that output
  15. Agree
    espurritado got a reaction from anotherriddle in Software to design 3d objects for 3d printing?   
    well, to my mind comes FreeCad and Blender
  16. Agree
    espurritado got a reaction from paprikman in Software to design 3d objects for 3d printing?   
    well, to my mind comes FreeCad and Blender
  17. Informative
    espurritado got a reaction from Fyfey96 in How did you learn C#?   
    for me, I got smacked in the face with it when a professor decided that it would be a good idea that the practice part for his class was to create a learning algorithm and illustrate its progress through Unity.
     
    I think it was at that point when I realized that every programming language is basically the same and I could program in anything I wanted
  18. Like
    espurritado got a reaction from harry4742 in IP Protection?   
    just go online to some page that tells you what's your IP, make note of it, turn off your router for ten seconds and turn it back on. Refresh the page that shows your IP address, it will have changed if your IP is dynamic
  19. Agree
    espurritado got a reaction from Extwofour in C# Infinite Program   
    WHY??
     
    you have an enormous memory leak, just do
    static void ContiniuousChecker() { while (true){ //Do stuff here Thread.Sleep(500); } }
  20. Agree
    espurritado got a reaction from Fyfey96 in C# Infinite Program   
    WHY??
     
    you have an enormous memory leak, just do
    static void ContiniuousChecker() { while (true){ //Do stuff here Thread.Sleep(500); } }
  21. Agree
    espurritado got a reaction from AlTech in C# Infinite Program   
    WHY??
     
    you have an enormous memory leak, just do
    static void ContiniuousChecker() { while (true){ //Do stuff here Thread.Sleep(500); } }
  22. Like
    espurritado got a reaction from SSL in PHP and MySQL, having more "info" in one column   
    It might "work", but working with an unnormalized database implies possible problems in the future with insertions, updates and deletions of values.
    You must remember, as well, that SQL is way more optimized in it's operations than any code you, or any third party may write. Iterating between the 10 rows returned by a query with a single value will be more efficient than taking a single row, sending all the values received into an array and iterating between them
  23. Like
    espurritado got a reaction from SSL in PHP and MySQL, having more "info" in one column   
    as I just said, you are breaking the first normal form, the solution, again, would be a different entry for each individual state_id, city_id and spaid.
    this would mean that for spaid 421 you would have 6 different entries 
  24. Like
    espurritado got a reaction from SSL in PHP and MySQL, having more "info" in one column   
    you are breaking the first normal form of a relational data base. A field for an entry may only contain one value.
    A solution would be to create an additional table with entries team and value.
  25. Informative
    espurritado got a reaction from Joveice in PHP and MySQL, having more "info" in one column   
    It might "work", but working with an unnormalized database implies possible problems in the future with insertions, updates and deletions of values.
    You must remember, as well, that SQL is way more optimized in it's operations than any code you, or any third party may write. Iterating between the 10 rows returned by a query with a single value will be more efficient than taking a single row, sending all the values received into an array and iterating between them
×