[Solved] When to use WP_query(), query_posts() and pre_get_posts

You are right to say: Never use query_posts anymore pre_get_posts pre_get_posts is a filter, for altering any query. It is most often used to alter only the ‘main query’: add_action(‘pre_get_posts’,’wpse50761_alter_query’); function wpse50761_alter_query($query){ if( $query->is_main_query() ){ //Do something to main query } } (I would also check that is_admin() returns false – though this may be … Read more

[Solved] How to convert hex to decimal in c#.net? [duplicate]

Console.Write(“Enter HEX: “); string hexValues = Console.ReadLine(); string[] hexValuesSplit = hexValues.Split(new char[] { ‘ ‘ }, StringSplitOptions.RemoveEmptyEntries); Console.WriteLine(“HEX = DECIMAL”); foreach (String hex in hexValuesSplit) { // Convert the number expressed in base-16 to an integer. int value = Convert.ToInt32(hex, 16); Console.WriteLine(string.Format(“{0} = {1}”, hex, Convert.ToDecimal(value))); } Console.ReadKey(); P.S. : The original code does not … Read more

[Solved] How to find dates between two dates in SQL Server 2005

This will work in sqlserver 2005: DECLARE @startdate datetime DECLARE @enddate datetime SELECT @startdate=”2015-12-04″, @enddate=”2015-12-07″ ;WITH N(N)AS (SELECT 1 FROM(SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1)M(N)), tally(N)AS(SELECT ROW_NUMBER()OVER(ORDER BY N.N)FROM N,N a,N b,N c,N d,N e,N f) SELECT top (datediff(d, @startdate, @enddate) + 1) dateadd(d, N – 1, … Read more

[Solved] When should you use WP_Query vs query_posts() vs get_posts()?

query_posts() is overly simplistic and a problematic way to modify the main query of a page by replacing it with new instance of the query. It is inefficient (re-runs SQL queries) and will outright fail in some circumstances (especially often when dealing with posts pagination). Any modern WP code should use more reliable methods, like … Read more

[Solved] Python wondering about user input

Use a list and a while loop. data=[] for x in xrange(100): data.append(raw_input(“Your data: “)) If you don’t need to store the data that was entered, get rid of the list and process this data right in the loop. 1 solved Python wondering about user input

[Solved] How To Do Task Repeatedly In Java 1.6 [duplicate]

If you want to do task every 250ms even doStuff() may take more than 250ms, you should use a new thread to “doStuff”(In this case, more than one doStuff may work at a time) updated(I tried this in win7x64, JDK 1.6 and it works) java.util.TimerTask task = new java.util.TimerTask() { @Override public void run() { … Read more

[Solved] How do I write a secure but simple loginscript using these technologies? [closed]

1) You should use this Maven archetype: maven-archetype-webapp 2) You link your database to your Java code with Hibernate. Read more here: http://www.tutorialspoint.com/hibernate/orm_overview.htm Then, you “generate” the XHTML page from your Java code. 3) The Spring framework is a very big thing to learn if you don’t know anything about Java web. Try servlets + … Read more

[Solved] How to select the first number in a string

This substring() expression does what you ask: substring(string, ‘\m\d+\D?*\M’) The regular expression only returns the first match, or NULL if none. \m … beginning of a word\d+ … one or more digits\D? … zero or one non-digits\M … end of word Demo: SELECT string, substring(string, ‘\d+\D?\d*\M’) FROM ( VALUES (‘FLAT 3, thanos house, nw1 6fs’) … Read more

[Solved] how toggleClass work?

You could do something like: $(“.form-elements input[type=”image”]”).on(“click”, function() { var currSrc = $(this).attr(“src”); // check if the source ends with “_pasif.png” if (/_pasif.png$/.test(currSrc)) { // if it does, just replace it with “.png” $(this).attr(“src”, currSrc.replace(/_pasif.png$/, “.png”)); } else { // if it does not, replace “.png” with “_pasif.png” $(this).attr(“src”, currSrc.replace(/.png$/, “_pasif.png”)); } }); <script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js”></script> … Read more

[Solved] How can I get integer value from activity-launcher to activity-default

To pass values from your “LauncherActivity:” Intent i = new Intent(getApplicationContext(), DefaultActivity.class); i.putExtra(“cycles”,5); startActivity(i); Then retrieve those values in the “DefaultActivity”: Bundle extras = getIntent().getExtras(); int cycles = 0; if (extras != null) { cycles = extras.getInt(“cycles”); } for (int i = 0; i < cycles: i++) { //do stuff } 1 solved How can … Read more

[Solved] Data retrieving from a database to a table by clicking a button [duplicate]

it also should display in the jTable without clearing existing data (as a new row) Well then you can’t use the setModel(…) method since that will replace all the existing data with the new data. And you can’t use the DbUtils.resultSetToTableModel(…) method since that will return new TableModel. Instead you will need to read the … Read more