« first day (73 days earlier)      last day (3948 days later) » 

12:50 AM
0
Q: Python Clean way to get whether a number is above/below two values and increment accordingly

TheoretiCALConsider (simplified) low_count = 0 high_count = 0 high = 10 low = 5 value = 2 What is a clean way to check a number value versus a min low and a max high, such that if value is below low low_count increments, and if value is above high high_count increments? Currently I have (code snippet) ...

0
Q: Simple code that finds number of factors crashes my computer. Is there a workaround for a large number?

alexakoThis is my attempt at problem 12 from Project Euler. However, my code freezes my old, linux computer when I run it. I've only got 512MB of RAM and an old Intel Core 2 Duo processor on my machine which, I assume, is why it can't run the code. Is there a way to optimize this code without using up ...

 
 
3 hours later…
3:33 AM
0
Q: What is the right way to “remove” Reference from it's ReferenceQueue?

leventovSometimes I need to ensure that some references won't be processed while examination from the associated ReferenceQueue. Generally at those moments I don't know reachability status of the referent. The only way I've came up with: class MyReference<V> extends SoftReference<V> { private boole...

 
4:12 AM
1
Q: Code and concept correctness with CSV writer in node

SmartLemonA friend of mine wanted an array to CSV string function for node, so I came up with this, basically it can take in a single object, a 2D array or an array of objects. If the children or parent is an object then the object properties become the headers, if the children are arrays then the first ...

 
4:54 AM
0
Q: Tag proposal: weak-references

leventovA weak-references tag would be suitable for: What is the right way to “remove” Reference from it's ReferenceQueue? Observer pattern in Java

 
 
3 hours later…
8:20 AM
0
Q: Structure pages mvc + oop

user2584229It's my first post here and I'm sorry for my bad english. I am developing a website and I want to use PDO AND MVC. Before, I was coding in procedural mysqli but I'm starting to understand the object-oriented programing. My problem is the following: If I understand the MVC pattern, there are 3...

 
 
2 hours later…
10:20 AM
0
Q: Is this a correct way to write a convenience constructor?

IreneI was reading more about the instancetype on Stack Overflow and now my question is: For every convenience constructor that I write, do I need to have the corresponding one using init? For example: RandomItem.h #import <Foundation/Foundation.h> @interface RandomItem : NSObject @property (non...

0
Q: Should you edit the code in a question?

LstorI have seen several (suggested) reviews lately, where someone edits the code in the original poster's question. Should such edits be allowed? The edits in question are mostly minor. Some add spaces to the code to increase readability, others fix syntax errors in the posted code.

 
 
1 hour later…
11:50 AM
0
Q: Two form. Second one not working

Provash Shoummai have a success.php page that once a order has been placed is sent to that page. i have set up two email scripts. one is sent if the buyer buys a product and the other is sent if the buyer books a course. (the reason i have made two is because they are using different variables)what seems to be ...

0
Q: Coding style and error

DaftDevFirst time here at code review. I would like to get this code reviewed since I want to improve my coding style by getting others opinions and also, I'm getting a 500 Internal Server Error in this code and I can't find where the error is, maybe you can help me find it. Link to Code

 
 
2 hours later…
1:51 PM
0
Q: PHP Memcached caching

cgdeveloperI wanted to create a class to cache dynamic PHP output (or a portion of it from one page) using Memcached key/value story. Basically it checks to see if the file has been cached already, if it has, it grabs it from Memcached and spits it out, otherwise, it outputs the file and stores it in Memcac...

 
2:30 PM
0
Q: Shift vowels towards the end of a Single Linked List

user2560730We have a linklist which is made of alphabets. We have to shift the vowels towards the end of the linklist, without changing the order in which they appear. So, A->C->E->F->G->O should become C->F->G->A->E->O This is the code I have written #include<iostream> using namespace std; struct ...

0
Q: List contents of a folder using a shell script and mail the folder

user2576191I want to list the contents of a folder and mail the list using a shell script. I Came up with the following script, please let me know if it is okay: for file in * do if [ -f "$file" ]; then echo "$file" | mail -s "List of files" Someone@somewhere.com fi done

 
 
1 hour later…
3:51 PM
0
Q: Which parts of my code are redundant? (html/c#/razor)

user2094139Hey guys I have the following code, which i kind of just put together sloppily since I'm not really familiar with Razor/html... but nonetheless it does what I want it to do, which is basically passing the value of true/false to model which I can use in my controller. If someone could clean up thi...

 
4:30 PM
0
Q: Placing and removing a dynamic tooltip

Jonny SooterI'm making a calendar and this is one part of the larger project. This adds a tooltip with more information when a calendar event is clicked. It then disappears after 10 seconds, or earlier if a click is detected. The exception being if the click in on the tooltip itself. This code works but feel...

1
Q: Is this a solid basic form validation script?

SomeoneIs this a good form validation script? I'm using jQuery. $(document).ready(function() { $("form").submit(function() { var shouldSubmit = true; $(this).children(":input:not(:button, [type=\"submit\"], [type=\"reset\"])").each(function() { if ($(this).val() == "") { ...

 
5:13 PM
0
Q: Lottery Code Not Working!

shezzI just started learning Javascript. I got this idea to try to make a code for the lottery! I just wanted to try it out, so I did, but this code didn't work. It keeps printing out "47" "undefined". I'm not sure why, so any feedback would be great! Thanks!! var random = Math.random(); choice1=45;...

 
5:52 PM
0
Q: Try/catch block inside a method that returns String

saint4lifeIs this try/catch block written correctly? public String execute() throws Exception{ try{ //Do blah return "success"; //Assuming everything goes well, return success. }catch (Exception e){ e.printStackTrace(); } return "error"; } Should the return "erro...

0
Q: Generic DB Value Getter

jsnI'm trying to see if there is a better way to do this when I just need one column with one row. Do not mind the lack of use of a prepared statement, I will put it in. public <T> T getValueFromDb(String col, String table, String cond, Class<T> returnValueClass) { T val = null; try { ...

 
6:31 PM
0
Q: How to make python knapsack program faster

lmasiklI have knapsack problem: I have data: List of product prices = MENU Most popluar product count = MOST_POPULAR_COCKTAIL Knapsack price = CASH Knapsack length = CHECK_LEN I need get all knapsack combinations from list of products prices which satisfy: List of product prices bigger or equal k...

 
7:13 PM
1
Q: versatile insertion method for PDO class

GAURAV MAHALEthis is my insertion method in PDO, it is working 100%. this 'insert' method accepts table, column and value but i want to make it versatile. (by default it should accepts without column name) public function insert($table, $pair = array()){ try{ $Sql = "INSERT INTO $table ( "; ...

0
Q: What would be the optimal way to address these arrays

Mattfor MN in xrange(RowModel,TotalModels): if(MN%5000==0):print 'Examining models', MN,'to', (MN+5000), '...' fobs=fobstemp fobserr=fobstemp*0.1 #10% error y=np.array([]) fmod=np.array([]) I was reading that it can be memory exhaustive to run for loops and range functions ove...

 

« first day (73 days earlier)      last day (3948 days later) »