pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
8,494,204
0
<p>what about checking the referral ? are you using php ?, if yes the you can try using refferal instead, like</p> <pre><code>if($_SERVER[’HTTP_REFERER’]!=''){ echo "&lt;script&gt; $(function(){ $.ajax({ type: 'POST', url: this.href, success: updatePortslide, dataType: 'json', data: 'js=2' }); return false; }); &lt;/script&gt;"; } </code></pre>
10,012,221
0
<p>I hope the below code will give u an idea .. If your PEM doesnt have password ...... refer X509.h header file in openssl</p> <pre><code>X509* oCertificate=NULL; FILE *lFp=NULL; lFp=fopen(iFilePath,"rb"); if(lFp==NULL) { oCertificate=NULL; cout &lt;&lt;("Error File cannot be opened(file missing) ")&lt;&lt;iFilePath ; } else { oCertificate = PEM_read_X509(lFp, NULL, NULL, NULL); fclose(lFp); } return oCertificate; </code></pre>
34,847,873
0
<p>Hopefully It can help you to deal with your question as following code </p> <pre><code>Simple CASE expression: CASE input_expression WHEN when_expression THEN result_expression [ ...n ] [ ELSE else_result_expression ] END </code></pre> <p><strong>Arguments</strong> </p> <pre><code>input_expression Is the expression evaluated when the simple CASE format is used. input_expression is any valid expression. WHEN when_expression Is a simple expression to which input_expression is compared when the simple CASE format is used. when_expression is any valid expression. The data types of input_expression and each when_expression must be the same or must be an implicit conversion. THEN result_expression Is the expression returned when input_expression equals when_expression evaluates to TRUE, or Boolean_expression evaluates to TRUE. result expression is any valid expression. ELSE else_result_expression Is the expression returned if no comparison operation evaluates to TRUE. If this argument is omitted and no comparison operation evaluates to TRUE, CASE returns NULL. else_result_expression is any valid expression. The data types of else_result_expression and any result_expression must be the same or must be an implicit conversion. WHEN Boolean_expression Is the Boolean expression evaluated when using the searched CASE format. Boolean_expression is any valid Boolean expression. </code></pre> <p><strong>Examples</strong> </p> <pre><code>USE AdventureWorks2012; GO SELECT ProductNumber, Category = CASE ProductLine WHEN 'R' THEN 'Road' WHEN 'M' THEN 'Mountain' WHEN 'T' THEN 'Touring' WHEN 'S' THEN 'Other sale items' ELSE 'Not for sale' END, Name FROM Production.Product ORDER BY ProductNumber; GO </code></pre> <p><strong>If-else with 2 tables</strong></p> <pre><code>declare @a nvarchar(50) if 1=1 set @a='select * from table1' else set @a='select * from table2' begin execute sp_executesql @a end </code></pre>
12,409,173
0
<pre><code>$('div[id^="sameId_"]').click(...) </code></pre> <p>Demo: <a href="http://jsfiddle.net/kpcxu/">http://jsfiddle.net/kpcxu/</a></p> <p>For more info, see <a href="http://api.jquery.com/attribute-starts-with-selector/">Attribute Starts With selector</a>.</p>
5,414,451
0
<p>I can think of some easy things Microsoft could have done to the memory allocator that would have greatly reduced LOH fragmentation without major overhaul, such as rounding allocation sizes up to some multiple like 4K. Given that the smallest non-static LOH objects were 85K, that would represent at most a 5% loss of useful space, but would reduce the number of different-sized objects and gaps. BTW, I'm really unconvinced of the value forcing all big objects to the LOH (as opposed to, perhaps, having a means of designating when an object is created whether it should go to the LOH or not). I can understand some value in separating small objects from big ones once they reach Level 2, but there are enough cases where big objects get created and abandoned that forcing them to level 2 seems counterproductive.</p>
26,281,319
0
<p><code>DatePart</code> can accept dates which are actually text instead of Date/Time datatype. However, the text must be something which Access recognizes as a valid date representation. A text date in <em>"yyyymmdd"</em> format doesn't satisfy that requirement. For example, in the Immediate window ...</p> <pre class="lang-vb prettyprint-override"><code>? IsDate("20141009") False </code></pre> <p>However, if you insert dashes between the year, month, and day segments, Access can recognize the text string as a date.</p> <pre class="lang-vb prettyprint-override"><code>? Format("20141009", "0000-00-00") 2014-10-09 ? IsDate(Format("20141009", "0000-00-00")) True </code></pre> <p>Test that technique in a simple query to make sure it avoids the error.</p> <pre class="lang-sql prettyprint-override"><code>SELECT RTG.[Sent Date], RTG.[Accept Date], DateDiff( 'd', Format([Accept Date],'0000-00-00'), Format([Sent Date],'0000-00-00') ) AS Expr1 FROM RTG </code></pre> <p>If Access still throws an error, use <code>CDate</code> to cast the text date to Date/Time datatype.</p> <pre class="lang-sql prettyprint-override"><code> DateDiff( 'd', CDate(Format([Accept Date],'0000-00-00')), CDate(Format([Sent Date],'0000-00-00')) ) AS Expr1 </code></pre> <p>Your task would be less challenging with actual Date/Time fields. You could create new Date/Time fields and execute an <code>UPDATE</code> query to load the transformed values from the old text date fields.</p>
26,219,052
0
JHipster Persist Data/Access Database <p>Running with Spring Boot v1.1.7.RELEASE, Spring v4.0.7.RELEASE with hot reloading, etc.</p> <p>Hey JHipsters, I'm working on my first project with JHipster. I can successfully create an application that runs, authenticates, etc. My issues really began when I started to try to create and maintain entities. At this point I've created an entity successfully called "Employees" with all the supporting files that JHipster provides. I've also managed to add the fields that I wanted to that entity (which proved to be more difficult than I originally anticipated), but wasn't able to eliminate the sample fields without creating an error, so I've left them there. </p> <p>Now, maybe I'm missing something here, but when I go and save a group of values in my entity, as soon as I terminate my application, those values evaporate. Is JHipster designed to operate this way in developer mode? If so, how do I persist my values in the MYSQL database that JHipster created for me?</p> <p>Let me know if you need any more information from me to help.</p>
17,810,837
0
Dose z3 find all satifiable models <p>There are some constraints such as x + y > 5 , x > 3 , y &lt; 4, so the set of models x = 4 y= 3, which is given by z3. Dose z3 can give models incrementally, such as another set of models x=5,y = 2? Thanks. Regards </p>
33,028,037
0
<p>Use a set comprehension:</p> <pre><code>values = { url.split("/")[3] for url in url_list } </code></pre>
22,545,045
0
Ruby and Rails: setting current_user if statement <p>I'm in a controller method.</p> <pre><code>p current_user p request.referrer != Rails.application.routes.url_helpers.dashboard_patients_add_url if request.referrer != Rails.application.routes.url_helpers.dashboard_patients_add_url p 'in here' current_user = User.find_by_authentication_token(params[:token])[0] end p current_user </code></pre> <p>Returns </p> <pre><code>#&lt;User id: 33, first_name: "1", last_name: "1", working_at: "1", password_digest: nil, password_confirmation: nil, created_at: "2014-03-20 00:37:54", updated_at: "2014-03-20 00:38:00", email: "[email protected]", encrypted_password: "$2a$10$nw1UHb0PeFUFh17zKRhbsOA.MirNfXW69wj7aRfMSDEw...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2014-03-20 00:37:54", last_sign_in_at: "2014-03-20 00:37:54", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", authentication_token: "HHz6KyqrHF7pC41DyGKH", salutation: "1", speciality: "1", cell_phone_number: "1", office_phone_number: "1"&gt; false nil </code></pre> <p>So the if statement is false and the p within the if statement is not run...which would lead me to believe that current_user should not get set to the User.find_by_authentication_token result. However, clearly, it does. If I comment out the if statement, then I get </p> <pre><code>#&lt;User id: 33, first_name: "1", last_name: "1", working_at: "1", password_digest: nil, password_confirmation: nil, created_at: "2014-03-20 00:37:54", updated_at: "2014-03-20 00:38:00", email: "[email protected]", encrypted_password: "$2a$10$nw1UHb0PeFUFh17zKRhbsOA.MirNfXW69wj7aRfMSDEw...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2014-03-20 00:37:54", last_sign_in_at: "2014-03-20 00:37:54", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", authentication_token: "HHz6KyqrHF7pC41DyGKH", salutation: "1", speciality: "1", cell_phone_number: "1", office_phone_number: "1"&gt; false #&lt;User id: 33, first_name: "1", last_name: "1", working_at: "1", password_digest: nil, password_confirmation: nil, created_at: "2014-03-20 00:37:54", updated_at: "2014-03-20 00:38:00", email: "[email protected]", encrypted_password: "$2a$10$nw1UHb0PeFUFh17zKRhbsOA.MirNfXW69wj7aRfMSDEw...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2014-03-20 00:37:54", last_sign_in_at: "2014-03-20 00:37:54", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", authentication_token: "HHz6KyqrHF7pC41DyGKH", salutation: "1", speciality: "1", cell_phone_number: "1", office_phone_number: "1"&gt; </code></pre> <p>As expected. I have no idea why anything within that if statement would have any impact on anything since its condition is false.</p> <p>I've clearly misunderstood something extra basic, and I'd love for someone to clear my vision.</p>
8,592,487
0
<p>I received this error with regards to the largeHeap Attribute, my application did not run under eclipse but under ant it still built and ran normally.</p> <p>The android <a href="http://developer.android.com/guide/topics/manifest/manifest-element.html" rel="nofollow">documentation</a> states that:</p> <blockquote> <p>xmlns:android</p> <pre><code>Defines the Android namespace. This attribute should always be set to "http://schemas.android.com/apk/res/android". </code></pre> </blockquote> <p>I erased that line in my manifest, saved in eclipse, pasted the line back in and saved again, and it worked. In my case I guess the problem was eclipse, ant and adb not talking to each other correctly and the saving reset something. Interestingly restarting eclipse did not solve this problem (usually with these types of problems restarting eclipse is the first thing you should try, and usually it solves the problem).</p>
2,572,720
0
<p>Make sure you've got a valid email address for anyone who posts (as per S.O.) and implement a CAPCHA on registration and when you think someone might be behaving oddly. Keep a well-trained copy of spamassassin around and feed the posts through that.</p> <p>C.</p>
22,857,797
0
<p>Your Game Model does not belong to the <code>Games\Controller</code> namespace. </p> <p>I assume from your structure that your Model is not namespaced, so you have these 2 options:</p> <ol> <li><p><code>use Game;</code> as you did for View and BaseController or</p></li> <li><p><code>$data['games'] = \Game::all();</code></p></li> </ol>
16,182,824
0
Ada beginner Stack program <p>Basically, I have 2 files ( .adb and .ads). I am totally new to Ada and also how to compile 2 files. The program is of a basic stack implementation. I got this compile error when I compiled the .adb file.</p> <pre><code>$ gcc -c test_adt_stack.adb abstract_char_stack.ads:22:01: end of file expected, file can have only one compilation unit </code></pre> <p>The 2 files I have are: <strong>abstract_char_stack.ads</strong></p> <pre><code>----------------------------------------------------------- package Abstract_Char_Stack is type Stack_Type is private; procedure Push(Stack : in out Stack_Type; Item : in Character); procedure Pop (Stack : in out Stack_Type; Char : out Character); private type Space_Type is array(1..8) of Character; type Stack_Type is record Space : Space_Type; Index : Natural := 0; end record; end Abstract_Char_Stack; ----------------------------------------------------------- package body Abstract_Char_Stack is ---------------------------------------------- procedure Push(Stack : in out Stack_Type; Item : in Character) is begin Stack.Index := Stack.Index + 1; Stack.Space(Stack.Index) := Item; end Push; -------------------------------------------- procedure Pop (Stack : in out Stack_Type; Char : out Character) is begin Char := Stack.Space(Stack.Index); Stack.Index := Stack.Index - 1; end Pop; -------------------------------------------- end Abstract_Char_Stack; </code></pre> <p>and the other one is <strong>test_adt_stack.adb</strong></p> <pre><code>----------------------------------------------------------- with Ada.Text_IO; use Ada.Text_IO; with Abstract_Char_Stack; use Abstract_Char_Stack; procedure Test_ADT_Stack is S1 : Stack_Type; S2 : Stack_Type; Ch : Character; begin Push(S1,'H'); Push(S1,'E'); Push(S1,'L'); Push(S1,'L'); Push(S1,'O'); -- S1 holds O,L,L,E,H for I in 1..5 loop Pop(S1, Ch); Put(Ch); -- displays OLLEH Push(S2,Ch); end loop; -- S2 holds H,E,L,L,O New_Line; Put_Line("Order is reversed"); for I in 1..5 loop Pop(S2, Ch); Put(Ch); -- displays HELLO end loop; end Test_ADT_Stack; ----------------------------------------------------------- </code></pre> <p>What am I doing wrong? I just want to have it compile and display what it's supposed to do. This was a study the program kind of assignment. But I can't make it compile or don't know if I am doing it right.</p>
19,628,498
0
<p>If its Real device we can not See Data folder inside data </p> <p>but if its Emulator </p> <p>Go to</p> <p>data>data> Search for your package name>database>yourdatabse.db</p> <p><img src="https://i.stack.imgur.com/LSl4m.png" alt="enter image description here"></p> <p>enter image description here</p> <p>Search your package name. Then inside database folder yourdatabse.db will be created.</p>
7,388,567
0
<p>Some responders have suggested storing the data in ViewState. While this is custom in ASP.NET you need to make sure that you absolutely understand the implications if you want to go down that route, as it can really hurt performance. To this end I would recommend reading <a href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx" rel="nofollow">TRULY understanding ViewState</a>.</p> <p>Usually, storing datasets retrieved from the database in ViewState really hurts performance. Without knowing the details of your situation I would hazard a guess that you are better off just loading the data from the database on every request. Essentially, you have the option of a) serializing the data and sending the data to the client (who could be on a slow connection) or b) retrieving the data from the database, which is optimized for data retrieval and clever caching. </p>
34,241,578
0
<p>Same problem here</p> <pre><code>$ mysqldump -h localhost --lock-all-tables --set-gtid-purged=OFF -u root -p --socket=/var/run/mysqld/mysqld.sock --all-databases &gt; dump.sql mysqldump: Couldn't execute 'SHOW VARIABLES LIKE 'ndbinfo\_version'': Native table 'performance_schema'.'session_variables' has the wrong structure (1682) </code></pre> <p>Have you test a</p> <pre><code>$ mysql_upgrade -u root -p </code></pre> <p>or</p> <pre><code>$ mysql_upgrade --force -u root -p </code></pre>
5,869,269
0
How to get call end event in Android App <p>I have made small app for Android mobile.</p> <p>In one situation i am not getting any solution. Actually my app has small functionality for calling to customer.</p> <p>So after call ended i need that event of which last number will dialed or which app is runs.</p> <p>Please help me its urgent for me.</p> <p>Thanks</p>
24,246,562
0
How to migrate S3 bucket to another account <p>I need to move data from an S3 bucket to another bucket, on a different account. I was able to sync buckets by running:</p> <pre><code>aws s3 sync s3://my_old_bucket s3://my_new_bucket --profile myprofile </code></pre> <p><em>myprofile</em> contents:</p> <pre><code>[profile myprofile] aws_access_key_id = old_account_key_id aws_secret_access_key = old_account_secret_access_key </code></pre> <p>I have also set policies both on origin and destination. Origins allows listing and getting, and destination allows posting.</p> <p>The commands works perfectly and I can log in to the other account and see the files. But I can't take ownership or make the new bucket public. I need to be able to make changes as I was able to in the old account. New account is totally unrelated to new account. It looks like files are retaining permissions and they are still owned by the old account. </p> <p>How can I set permissions in order to gain full access to files with the new account?</p>
37,333,837
0
Java GUI ActionListener. Finding out which button was pressed <p>I´ve got a two dimensional Array (Matrix) with the Dimension 50x50. In these Matrix every position has the value 0 or 1. This Matrix is presented by a Grid Layout with 50x50 Buttons, which are white oder black, if the value is 0 or 1. If I press a Button the related position in the Matrix should change the value to 1. To implement this I create the Grid with one Button for each matrixposition, performed by a for-loop. I also implementet a ActionListener for each Button in this for-loop. I tried to change the value of the position using the ActionListeners, by giving the function creating the button and the ActionListener for each position two parameters for row and column of the position in the matrix. But theres a mistake, so I always get a NullPointerException, if I press a Button.</p> <pre><code>import javax.swing.*; import java.awt.*; import javax.swing.border.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class Bild extends JFrame { public Matrix matrix; public JButton createButton(int a, int x, int y) { JButton b = new JButton(); if(a==1){ b.setBackground(Color.WHITE); }else{ b.setBackground(Color.BLACK); } b.addActionListener( new ActionListener(){ public void actionPerformed( ActionEvent arg0 ) { matrix.matrix[x][y]=1; } }); this.add(b); return b; } public Bild(Matrix matrix) { matrix = matrix; GridLayout layout = new GridLayout(50,50,0,0); this.setLayout(layout); for (int i = 0; i&lt;50; i++) { for(int j=0; j&lt;50; j++){ if (matrix.matrix[i][j]==0){ this.add(createButton(1,i,j)); }else{ this.add(createButton(2,i,j)); } } } } } public class Matrix{ int[][] matrix; public Matrix(){ matrix = new int[50][50]; for(int i=0; i&lt;50; i++){ for(int j=0; j&lt;50; j++){ matrix[i][j]=0; } } } } import javax.swing.*; // JFrame, JPanel, ... import java.awt.*; // GridLayout public class Main{ public static void main (String[] args) { Matrix matrix = new Matrix(); JFrame frame = new Bild(matrix); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500,500); frame.setVisible(true); } } </code></pre>
9,591,075
0
<p>You can do all the work in the executing threads of the thread pools using an AtomicInteger to monitor the number of runnables executed</p> <pre><code> int numberOfParties = 5; AtomicInteger numberOfJobsToExecute = new AtomicInteger(1000); ExecutorService pool = Executors.newFixedThreadPool(numberOfParties ); for(int i =0; i &lt; numberOfParties; i++){ pool.submit(new Runnable(){ public void run(){ while(numberOfJobsToExecute.decrementAndGet() &gt;= 0){ makeJobs(1).get(0).run(); } } }); } </code></pre> <p>You can also store the returned Future's in a List and <code>get()</code> on them to await completion (among other mechanisms)</p>
5,709,975
0
Binary code Error help <p>I forgot to insert my code, sorry on my behalf..</p> <p>I have a Binary Search going in my program, but when I enter 10 student records into an Array and sort them, the last element of Student ID will not be picked up from my binary search.</p> <p>Say when I sort the Array and 232 was the last element in the Array, when I go to Search 232 the Binary Search Function gives me back not found and I look for any other ID with in the array and give it back with the records.</p> <pre><code> else if ( choice == 4) // Binary Search... This Also Force Array to be Sorted If Array is not Sorted. { merge_sort(0,N_STUDENT-1); cout&lt;&lt;" \n\t Enter the student number to search :"; // Ask user to Input Student ID. cin&gt;&gt;key; k=binarySearch(record, 0, N_STUDENT-1, key); // Serach Array if(k&gt;=0) cout&lt;&lt;"Student Details with student Number\n " &lt;&lt;key&lt;&lt; "exists at the position \n" &lt;&lt; k &lt;&lt; " Student Number\n" &lt;&lt; record-&gt;student_number &lt;&lt; " " &lt;&lt; " Student Name \n" &lt;&lt; record-&gt;studentname &lt;&lt; " " &lt;&lt; " Student Address \n" &lt;&lt; record-&gt;Address &lt;&lt; " " &lt;&lt; " Course Code \n" &lt;&lt; record-&gt;CourseCode &lt;&lt; " " &lt;&lt; " Course Name \n" &lt;&lt; record-&gt;CourseName; //Displays Position of Student And Student Details. else cout&lt;&lt; "Not found "; // if Record is not Found _____________________________________________________________________________________________________ //function binary search using the key value to serach int binarySearch(student sorted[], int first, int upto, int key) { // Sort Array if not Sorted... while (first &lt; upto) { int mid = (first + upto) / 2; // Compute mid point. if (key&lt;sorted[mid].student_number) { upto = mid; // repeat search in bottom half. } else if (key&gt;sorted[mid].student_number) { first = mid + 1; // Repeat search in top half. } else { return mid; // Found it. return position } } return -(first + 1); // Failed to find key } </code></pre>
23,991,717
0
Horizontal lines in errorbars disappearing <p>I'm having some troubles with errorbars in ggplot (R) similar to <a href="http://stackoverflow.com/questions/13491829/missing-errorbars-when-using-yscalelog-at-matplotlib">this problem in Python</a>. My horizontal errobars are disappearing when using the <code>scale_y</code> function. Can you help me find a solution? The <a href="http://aeblerov.com/yeast_sac.txt" rel="nofollow">data is here</a>.</p> <p>My code is:</p> <pre><code>data_sac_ggplot &lt;- ggplot(yeast_sac, aes(x=factor(day), y=mean_count, colour=yeastsample, group=c("low","high"))) + scale_y_log10(breaks = trans_breaks("log10", function(x) 10^x), labels = trans_format("log10", math_format(10^.x))) + geom_line(size=0.8) + geom_point(size=2, shape=21, fill="white") + theme_bw() data_sac_ggplot + geom_errorbar(aes(ymin=mean_count-low, ymax=mean_count+high), width=0.1, position=pd) data_sac_ggplot + scale_y_log10(breaks=c(1000,10000,100000,1000000,10000000,100000000,1000000000)) </code></pre> <p>Thanks!</p> <p><a href="http://aeblerov.com/example_sac.png" rel="nofollow">Picture of plot:</a></p>
23,051,546
0
Chromecast Chrome API - senderId <p>The receiver adds a senderId to each message it receives. Is the sender aware of that id? Where can it be found? That would help greatly during development.</p>
32,537,172
0
<p>At the end I went with System.JS and jspm, and I must say it absolutely solves all the problems that I was facing, and then some, flawlessly. It took me a while until I finally found out about it, but I believe this is gonna be the defacto standard for a long while so I'd encourage anyone writing a new project to just default to jspm.</p> <p>You get AMD and Common.JS and ES6 support, you don't mix your node modules and client modules (node_packages and jspm_packages), and flat dependecies... what more could you need?</p> <p>Thank you for your suggestions!</p>
20,456,422
0
AngularJSFilter not working <p>I am very new to Angular JS. Just started an hour back to dig into it.</p> <p>I cannot get the filter API to work on this page. I am drawing a blank .. </p> <p>I am very sorry to ask such a silly question...</p> <p>jsfiddle.net/khirthane/52hN5/</p>
14,551,224
0
Pass an MFC control to a thread or pass an handle? <p>I've been reading somewhere that it is safer to pass an MFC ui control to a thread as an handle rather than to pass a pointer to the control.</p> <p>Option 1 - pass a pointer to static text:</p> <pre><code>TestDialog dlg1; ::_beginthreadex(NULL, 0, &amp;tSetTextByPointer, &amp;dlg1.m_StaticText, 0, NULL); dlg1.DoModal(); UINT WINAPI tSetTextByPointer(LPVOID arg) { CStatic * pStaticText = static_cast&lt;CStatic*&gt;(arg); Sleep(3000); pStaticText-&gt;SendMessage(WM_SETTEXT, 0, (LPARAM)L"text"); return 0; } </code></pre> <p>Option 2 - pass an handle :</p> <pre><code>TestDialog dlg1; ::_beginthreadex(NULL, 0, &amp;tSetTextByHandle, &amp;(dlg1.m_StaticText.m_hWnd), 0, NULL); dlg1.DoModal(); UINT WINAPI tSetTextByHandle(LPVOID arg) { HWND * pTextHandle = static_cast&lt;HWND*&gt;(arg); Sleep(3000); ::SendMessage(*pTextHandle, WM_SETTEXT, 0, (LPARAM)L"text"); return 0; } </code></pre> <p>Should I really prefer using handles when accessing controls by multiple threads? Or is it enough to rely on SendMessage() to cover the thread-safety matter when accessing the control?</p>
13,087,688
0
<p>I find the Ajax Form plugin a good tool for the job.</p> <p><a href="http://www.malsup.com/jquery/form/#tab4" rel="nofollow">http://www.malsup.com/jquery/form/#tab4</a></p> <p>A basic code example could be:</p> <pre><code>$(document).ready(function() { // On Document Ready var options = { target: '#output1', // ID of the DOM elment where you want to show the results success: showResponse }; // bind form using 'ajaxForm' $('#myForm1').ajaxForm(options); }); // the callback function function showResponse(responseText, statusText, xhr, $form) { alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + '\n\nThe output div should have already been updated with the responseText.'); } </code></pre> <p>All your PHP file have to do is <code>echo</code> the <code>html</code> (or text) back that you want to show in your DIV after the form has been submitted.</p>
14,656,763
0
<p>You forgot the closing <code>&gt;</code> for the <code>CDATA</code> element:</p> <pre><code>"&lt;Description&gt;&lt;![CDATA["+page+"]]&gt;&lt;/Description&gt;"+\ </code></pre>
3,423,517
0
<p>There is quite a list:</p> <ol> <li><a href="http://code.google.com/p/nstub/" rel="nofollow noreferrer">NStub</a></li> <li><a href="http://sourceforge.net/projects/testgennet/" rel="nofollow noreferrer">TestGen.Net</a></li> <li><a href="http://code.google.com/p/nunitgenaddin/" rel="nofollow noreferrer">NunitGenAddIn</a></li> <li>($$)<a href="http://www.kellermansoftware.com/p-30-nunit-test-generator.aspx?mode=Specifications&amp;" rel="nofollow noreferrer">KellerMan NUnit Test Generator</a></li> <li><a href="http://research.microsoft.com/en-us/projects/pex/" rel="nofollow noreferrer">Pex</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/ms182524%28v=VS.80%29.aspx" rel="nofollow noreferrer">MSTest</a> - fair enough this is not NUnit, but it does generate tests and should be "considered"</li> </ol>
18,483,602
0
Tomcat ClientAbortException Listener? <p>Our Tomcat 6 Server is reporting quite a few ClientAbortException errors, which I believe is down to say a user navigating away from the page before its fully loaded. We are also getting No buffer space available (maximum connections reached? errors.</p> <p>Is there a way of creating a ClientAbortException Listener to terminate any Abandoned Connection Clean Up or unused http threads and delete any byte data used for incomplete downloaded images.</p> <p>This project is inherited and I've noticed that even when running locally if I start VisualJVM and view the monitor and then open a website locally I see an Abandoned Connection Clean Up thread created and a number of http threads created. If I open another website on the same local web server I can see yet again another Abandoned Connection Clean Up thread created and another set of http threads created. If I navigate through the pages, I don't see any other connections created, mainly because the project is using database pooling but if I close the browser the threads are still running, they are not being freed up.</p> <p>Needless to say, as soon as the server has been running for a number of days or is under load the aforementioned errors are generated.</p> <p>Any help would be much appreciated :-)</p>
7,604,272
1
How to select some urls with BeautifulSoup? <p>I want to scrape the following information except the last row and "class="Region" row:</p> <pre><code>... &lt;td&gt;7&lt;/td&gt; &lt;td bgcolor="" align="left" style=" width:496px"&gt;&lt;a class="xnternal" href="http://www.whitecase.com"&gt;White and Case&lt;/a&gt;&lt;/td&gt; &lt;td bgcolor="" align="left"&gt;New York&lt;/td&gt; &lt;td bgcolor="" align="left" class="Region"&gt;N/A&lt;/td&gt; &lt;td bgcolor="" align="left"&gt;1,863&lt;/td&gt; &lt;td bgcolor="" align="left"&gt;565&lt;/td&gt; &lt;td bgcolor="" align="left"&gt;1,133&lt;/td&gt; &lt;td bgcolor="" align="left"&gt;$160,000&lt;/td&gt; &lt;td bgcolor="" align="center"&gt;&lt;a class="xnternal" href="/nlj250/firmDetail/7"&gt; View Profile &lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class="small" bgcolor="#FFFFFF"&gt; ... </code></pre> <p>I tested with this handler:</p> <pre><code>class TestUrlOpen(webapp.RequestHandler): def get(self): soup = BeautifulSoup(urllib.urlopen("http://www.ilrg.com/nlj250/")) link_list = [] for a in soup.findAll('a',href=True): link_list.append(a["href"]) self.response.out.write("""&lt;p&gt;link_list: %s&lt;/p&gt;""" % link_list) </code></pre> <p>This works but it also get the "View Profile" link which I don't want:</p> <pre><code>link_list: [u'http://www.ilrg.com/', u'http://www.ilrg.com/', u'http://www.ilrg.com/nations/', u'http://www.ilrg.com/gov.html', ......] </code></pre> <p>I can easily remove the "u'http://www.ilrg.com/'" after scraping the site but it would be nice to have a list without it. What is the best way to do this? Thanks.</p>
26,668,805
0
<p>try below code :-</p> <pre><code>listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { Toast.makeText(getApplicationContext(), "Click ListItem Number " + position, Toast.LENGTH_LONG) .show(); } }); </code></pre> <p>Read below link for more information :-</p> <p><a href="http://www.vogella.com/tutorials/AndroidListView/article.html" rel="nofollow">http://www.vogella.com/tutorials/AndroidListView/article.html</a></p> <p><a href="http://androidexample.com/Create_A_Simple_Listview_-_Android_Example/index.php?view=article_discription&amp;aid=65&amp;aaid=90" rel="nofollow">http://androidexample.com/Create_A_Simple_Listview_-_Android_Example/index.php?view=article_discription&amp;aid=65&amp;aaid=90</a></p>
28,117,005
0
How can I tail -f but only in whole lines? <p>I have a constantly updating huge log file (MainLog).</p> <p>I want to create another file which is only the last n lines of the log file BUT also updating.</p> <p>If I use:</p> <blockquote> <p>tail -f MainLog > RecentLog</p> </blockquote> <p>I get ALMOST what I want except RecentLog is written as MainLog is available and might at any point only have part of the last MainLog line.</p> <p>How can I specify to tail that I only want it to write when a WHOLE line is available?</p>
3,477,306
0
<p>you left out a for(;true;) loop</p>
5,958,423
0
<p>I had the same problem and resolved it by updating to the latest jQuery (1.6) and jQuery.validate (1.8) libraries. The easiest way to get these is searching NuGet for jQuery.</p>
21,768,410
0
<p>Check the Optimisation Tips section in the Android Developer console for your app, it should give some suggestions for removing that tag.</p>
15,605,544
0
<p>Try this :</p> <pre><code> &lt;%= f.simple_fields_for :picture do |pic| %&gt; &lt;div class="fileupload fileupload-new" data-provides="fileupload"&gt; &lt;div class="input-append"&gt; &lt;div class="uneditable-input span3"&gt; &lt;i class="icon-file fileupload-exists"&gt;&lt;/i&gt; &lt;span class="fileupload-preview"&gt;&lt;/span&gt;&lt;/div&gt; &lt;span class="btn btn-file"&gt;&lt;span class="fileupload-new"&gt;Select file&lt;/span&gt; &lt;span class="fileupload-exists"&gt;Change&lt;/span&gt; &lt;%= pic.input :image, :as =&gt; :file, :label =&gt; "upload a photo" %&gt; &lt;/span&gt; &lt;a href="#" class="btn fileupload-exists" data-dismiss="fileupload"&gt;Remove&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre> <p>Just insert <code>erb</code> into bootstrap's html.</p>
826,228
0
<p>Use JConsole-- you likely already have it: <a href="http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html" rel="nofollow noreferrer">http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html</a> <a href="http://openjdk.java.net/tools/svc/jconsole/" rel="nofollow noreferrer">http://openjdk.java.net/tools/svc/jconsole/</a></p>
38,570,390
0
ui-router change url after $state.go <p>I have a route:</p> <pre><code>$stateProvider.state('keeper.telepay.category', { url: '/category-{id}/country-{cid}/region-{rid}' } </code></pre> <p>In all cases when I use $state.go with this route, I want to change <strong>rid</strong> to 'all' if it's value is '0', so my url'll be like </p> <p><strong>/category-1/country-195/region-all</strong></p> <p>I've tried to do it in $rootScope.$on('$stateChangeStart'), but with no luck. Any suggestions || directions would be very appreciated.</p> <p><strong>UPDATE</strong></p> <p>Here what I've tried on $stateChange:</p> <pre><code>$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams){ if(toState.name == 'keeper.telepay.category' &amp;&amp; toState.params.rid == 0) { toState.params.rid = 'all'; } } </code></pre>
12,094,773
0
<p>Solution was to add <strong>index index.php</strong></p> <pre><code> index index.php try_files $uri $uri/ $uri/index.php /index.php; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } </code></pre>
20,839,539
0
<p>This problem is quite simple to solve even without jQuery or similar in plain JavaScript. Here it is for your example:</p> <pre><code>var next = (function (sections) { function getTop(node) { return node ? node.offsetTop + getTop(node.offsetParent) : 0; } return function () { var i, nodeTop, top = window.pageYOffset; for (i = 0; i &lt; sections.length; i += 1) { nodeTop = getTop(document.getElementById(sections[i])); if (nodeTop &gt; top) { window.scrollTo(window.pageXOffset, nodeTop); return; } } }; }(['top', 'fe1', 'fe2', 'fe3', 'fe4', 'fe5'])); </code></pre> <p>The code is quite general, so you can pass any section ids you want (they just need to appear in the correct order).</p> <p>We use two standard DOM properties/functions here <code>window.pageYOffset</code> and <code>window.scrollTo()</code> to get and set vertical offset of the window (<code>window.pageXOffset</code> is used to keep horizontal offset the same). To get the vertical offset of the section start I defined <code>getTop</code> function using simple recursion (jQuery uses similar code IMHO).</p> <p>Resulting function <code>next()</code> is defined in a self-invoking closure to hide the implementation and helper function. To use it after this code is run, you simply call</p> <pre><code>next(); </code></pre> <p>I tested this code, so I am quite confident it works :).</p>
40,173,892
0
Center Loss in Keras <p>I want to implement center Loss explained in [<a href="http://ydwen.github.io/papers/WenECCV16.pdf]" rel="nofollow">http://ydwen.github.io/papers/WenECCV16.pdf]</a> in Keras</p> <p>I started to create a network with 2 outputs such as : </p> <pre><code>inputs = Input(shape=(100,100,3)) ... fc = Dense(100)(#previousLayer#) softmax = Softmax(fc) model = Model(input, output=[softmax, fc]) model.compile(optimizer='sgd', loss=['categorical_crossentropy', 'center_loss'], metrics=['accuracy'], loss_weights=[1., 0.2]) </code></pre> <p>First of all, doing like this, is it the good way to proceed? </p> <p>Secondly, I don't know how to implement the center_loss in keras. Center_loss looks like mean square error but instead of comparing values to fixed labels, it compares values to data updated at each iteration. </p> <p>Thank you for your help</p>
34,796,071
0
Removing multiple objects on Fabric.js canvas <p>Struggling to remove multiple objects from the fabric canvas. Everything seems to be in working order but when the code runs it does not remove the multiple selected objects from the canvas. </p> <pre><code> service.deleteSelectedObject = function () { var selectedObject = service.canvas.getActiveObject(); var selectedMultipleObjects = service.canvas.getActiveGroup(); var data = {}; // get object id // get selected objects from canvas if (selectedObject) { data = { type: 'whiteboard::delete', id: selectedObject.id }; delete service.objectMap[selectedObject.id]; service.canvas.remove(selectedObject); } else { data = { type: 'whiteboard::delete', object: selectedMultipleObjects }; console.log(selectedMultipleObjects); selectedMultipleObjects._objects.forEach(function (object, key) { console.log(object); service.canvas.remove(object); }); } signalService.sendMessage(service.recipient, data); }; </code></pre> <p>I should point out that all of these console logs do pass what they should. As well as the problem is occuring in the else statement the first part of this code works how it should </p> <p>please let me know if you need any further information. </p>
30,085,380
0
<p>Extensions have much lower memory limits than normal apps. You'll have to investigate why you extension is using so much memory. Perhaps there's a leak. </p>
40,490,111
0
<p>Add <code>global next_page</code> to the beginning of function <code>getPosts()</code> instead of pass the parameter into it, so that you update the value of global variable <code>next_page</code> . And declare the global variable next_page as a str <code>''</code> instead of list<code>[]</code>.</p>
39,789,717
0
<p>You can access logs from CLI using <code>yarn logs -applicationId &lt;application ID&gt;</code></p>
19,823,386
0
Cant push to stack, mips <p>I am just trying to print this 'a' to screen, but by first pushing to stack so that I can check whether I did accomplish on pushing to stack or not, seems that I couldn't because it prints a weird character everytime. What's wrong?</p> <pre><code>.data char: .word 'a' .text .globl main main: la $t0, char sub $sp, $sp, 4 #allocate byte for stack sb $t0, 0($sp) #push to stack la $t1, 0($sp) #I wasnt able to print the top of the stack directly so I tried this li $v0, 11 la $a0, 0($t1) #It isnt working anyway.. Prints É syscall add $sp, $sp, 4 jr $ra </code></pre>
35,683,626
0
Make banner ads responsive <p>Friends! I am working on adding banner ads to my website, the html that I have added to display banner is on <a href="https://jsfiddle.net/1r1kydjz/2/" rel="nofollow">https://jsfiddle.net/1r1kydjz/2/</a></p> <pre><code>&lt;div data-wrid="WRID-145664652759935473" data-widgettype="staticBanner" data-responsive="yes" data-class="affiliateAdsByFlipkart" height="90" width="728" style="text-align:center;"&gt;&lt;/div&gt; &lt;script async src="//affiliate.flipkart.com/affiliate/widgets/FKAffiliateWidgets.js"&gt;&lt;/script&gt; </code></pre> <p>The problem that I am facing is that my banner ads are not responsive, I want them to adjust according to the device i.e mobile, desktops and tablet.</p> <p>I have tried width: 100% and other things mentioned, but it doesn't help.</p> <p>Please note that the banner ad is inside a dynamically created iframe.</p> <p>Please let me know if any post that I can refer to.</p> <p>Thanks in advance.</p>
24,972,989
0
<p>As mentioned by @SirDarius, this is implementation dependent and therefore you would need to check on a per implementation basis.</p> <p><em>Usually</em>, <code>std::set</code> is implemented as a red-black tree with lean iterators. This means that for each element in the set, there is <em>one node</em>, and this node roughly contains:</p> <ul> <li>3 pointers: 1 for the parent node, 1 for the left-side child and one for the right-side child</li> <li>a tag: red or black</li> <li>the actual user type</li> </ul> <p>The minimal foot-print of such a node on a 64 bits platform is therefore <code>footprint(node)</code>:</p> <ul> <li>3*8 bytes</li> <li><code>sizeof(MyClass)</code>, rounded to 8 bytes (for alignment reasons: look up "struct padding")</li> </ul> <p><em>Note: it is easy to use an unused bit somewhere to stash the red/black flag at no additional cost, for example taking into account the fact that given node alignments the least-significant bits of the pointers are always <code>0</code>, or inserting in <code>MyClass</code> padding if any.</em></p> <p><em>However</em>, when you allocate an object <code>T</code> via <code>new</code> (which is what <code>std::allocator</code> does under the hood, and which itself uses <code>malloc</code> unless overloaded), you do not allocate <em>just</em> <code>sizeof(T)</code> bytes:</p> <ul> <li>a typical implementation of <code>malloc</code> uses <em>size buckets</em>, meaning that if you have 8 bytes buckets and 16 bytes buckets when you allocate a 9 bytes object it goes into a 16 bytes bucket (wasting 7 bytes)</li> <li>furthermore, the implementation also has some overhead to <em>track</em> those allocated blocks of memory (to know not to reuse that memory until it's freed); though minimal, the overhead can be non-negligible</li> <li>finally, the OS itself has some overhead for each page of memory that the program requests; although that is probably negligible</li> </ul> <p>Therefore, indeed, the use of a <code>set</code> will most likely consume <em>more</em> than just <code>set.size() * sizeof(MyClass)</code>, though the overhead depends on your Standard Library implementation. This overhead will likely be large for small objects (such as <code>int32_t</code>: on a 64-bits platform you are looking at least at a +500% overhead) because the cost of linking the nodes together is usually fixed, whereas for large objects it might not be noticeable.</p> <hr> <p>In order to reduce the overhead, you traditionally use <em>arrays</em>. This is what a B-Tree does for example, though it does so at the cost of <em>stability</em> (ie, each element staying at a fixed memory address regardless of what happens to the others).</p>
24,401,674
0
Running hadoop with compressed files as input. Data Input read by hadoop not in sequence. Number format exception <p>I giving a tar.bz2 file ,.gz and tar.gz files as input after changing the properties in mapred-site.xml. None of the above seem to have worked. What I assumed to happen here is the records read as input by hadoop go out of sequence ie. one column of input is string and the other is an integer but while reading it from the compressed file because of some out of sequence data, at some point hadoop reads the string part as an integer and generates an illegal format exception. I'm just a noob. I want to know whether there is a problem in the configuration or my code. </p> <p>The properties in core-site.xml are</p> <pre><code>&lt;property&gt; &lt;name&gt;io.compression.codecs&lt;/name&gt; &lt;value&gt;org.apache.hadoop.io.compress.BZip2Codec,org.apache.hadoop.io.compress.DefaultCodec,org.apache.hadoop.io.compress.GzipCodec,org.apac\ he.hadoop.io.compress.SnappyCodec&lt;/value&gt; &lt;description&gt;A list of the compression codec classes that can be used for compression/decompression.&lt;/description&gt; &lt;/property&gt; </code></pre> <p>properties in mapred-site.xml are</p> <pre><code>&lt;property&gt; &lt;name&gt;mapred.compress.map.output&lt;/name&gt; &lt;value&gt;true&lt;/value&gt; &lt;/property&gt; &lt;property&gt; &lt;name&gt;mapred.map.output.compression.codec&lt;/name&gt; &lt;value&gt;org.apache.hadoop.io.compress.BZip2Codec&lt;/value&gt; &lt;/property&gt; &lt;property&gt; &lt;name&gt;mapred.output.compression.type&lt;/name&gt; &lt;value&gt;BLOCK&lt;/value&gt; &lt;/property&gt; </code></pre> <p>This is my Code</p> <pre><code>package org.myorg; import java.io.IOException; import java.util.*; import org.apache.hadoop.util.NativeCodeLoader; import org.apache.hadoop.fs.Path; import org.apache.hadoop.conf.*; import org.apache.hadoop.io.compress.CompressionCodec; import org.apache.hadoop.io.compress.CompressionInputStream; import org.apache.hadoop.io.compress.CompressionOutputStream; import org.apache.hadoop.io.compress.Decompressor; import org.apache.hadoop.io.*; import org.apache.hadoop.mapreduce.*; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.input.TextInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat; import org.apache.hadoop.io.compress.GzipCodec; import org.apache.hadoop.io.compress.*; import org.apache.hadoop.io.compress.BZip2Codec; public class MySort{ public static class Map extends Mapper&lt;LongWritable, Text, Text, IntWritable&gt; { private final static IntWritable Marks = new IntWritable(); private Text name = new Text(); String one,two; int num; public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { String line = value.toString(); StringTokenizer tokenizer = new StringTokenizer(line); while (tokenizer.hasMoreTokens()) { one=tokenizer.nextToken(); name.set(one); if(tokenizer.hasMoreTokens()) two=tokenizer.nextToken(); num=Integer.parseInt(two); Marks.set(num); context.write(name, Marks); } } } public static class Reduce extends Reducer&lt;Text, IntWritable, Text, IntWritable&gt; { public void reduce(Text key, Iterable&lt;IntWritable&gt; values, Context context) throws IOException, InterruptedException { int sum = 0; for (IntWritable val : values) { sum += val.get(); } context.write(key, new IntWritable(sum)); } } public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); // conf.set("mapreduce.job.inputformat.class", "com.wizecommerce.utils.mapred.TextInputFormat"); // conf.set("mapreduce.job.outputformat.class", "com.wizecommerce.utils.mapred.TextOutputFormat"); // conf.setBoolean("mapreduce.map.output.compress",true); conf.setBoolean("mapred.output.compress",true); //conf.setBoolean("mapreduce.output.fileoutputformat.compress",false); //conf.setBoolean("mapreduce.map.output.compress",true); conf.set("mapred.output.compression.type", "BLOCK"); //conf.setClass("mapreduce.map.output.compress.codec", BZip2Codec.class, CompressionCodec.class); // conf.setClass("mapred.map.output.compression.codec", GzipCodec.class, CompressionCodec.class); conf.setClass("mapred.map.output.compression.codec", BZip2Codec.class, CompressionCodec.class); Job job = new Job(conf, "mysort"); job.setJarByClass(org.myorg.MySort.class); job.setJobName("mysort"); job.setOutputKeyClass(Text.class); job.setOutputValueClass(IntWritable.class); job.setMapperClass(Map.class); job.setReducerClass(Reduce.class); job.setInputFormatClass(TextInputFormat.class); job.setOutputFormatClass(TextOutputFormat.class); // FileInputFormat.setCompressInput(job,true); FileOutputFormat.setCompressOutput(job, true); //FileOutputFormat.setOutputCompressorClass(job, GzipCodec.class); // conf.set("mapred.output.compression.type", CompressionType.BLOCK.toString()); FileOutputFormat.setOutputCompressorClass(job, BZip2Codec.class); FileInputFormat.addInputPath(job, new Path(args[0])); FileOutputFormat.setOutputPath(job, new Path(args[1])); job.waitForCompletion(true); } } </code></pre> <p>These are all commandsput together in a makefile</p> <pre><code>run: all -sudo ./a.out sudo chmod 777 -R Data -sudo rm data.tar.bz2 sudo tar -cvjf data.tar.bz2 Data/data.txt sudo javac -classpath /home/hduser/12115_Select_Query/hadoop-core-1.1.2.jar -d mysort MySort.java sudo jar -cvf mysort.jar -C mysort/ . -hadoop fs -rmr MySort/output -hadoop fs -rmr MySort/input hadoop fs -mkdir MySort/input hadoop fs -put data.tar.bz2 MySort/input hadoop jar mysort.jar org.myorg.MySort MySort/input/ MySort/output -sudo rm /home/hduser/Out/sort.txt hadoop fs -copyToLocal MySort/output/part-r-00000 /home/hduser/Out/sort.txt sudo gedit /home/hduser/Out/sort.txt all: rdata.c -sudo rm a.out -gcc rdata.c -o a.out exec: run .PHONY: exec run </code></pre> <p>Command:</p> <pre><code>hadoop jar mysort.jar org.myorg.MySort MySort/input/ MySort/output </code></pre> <p>Here is the output:</p> <pre><code>Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /usr/local/hadoop/lib/native/libhadoop.so.1.0.0 which might have disabled stack guard. The VM will try to fix the stack guard now. It's highly recommended that you fix the library with 'execstack -c &lt;libfile&gt;', or link it with '-z noexecstack'. 14/06/25 11:20:28 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 14/06/25 11:20:28 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032 14/06/25 11:20:29 WARN mapreduce.JobSubmitter: Hadoop command-line option parsing not performed. Implement the Tool interface and execute your application with ToolRunner to remedy this. 14/06/25 11:20:29 INFO input.FileInputFormat: Total input paths to process : 1 14/06/25 11:20:29 INFO mapreduce.JobSubmitter: number of splits:1 14/06/25 11:20:29 INFO Configuration.deprecation: mapred.output.compress is deprecated. Instead, use mapreduce.output.fileoutputformat.compress 14/06/25 11:20:29 INFO Configuration.deprecation: mapred.map.output.compression.codec is deprecated. Instead, use mapreduce.map.output.compress.codec 14/06/25 11:20:29 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1403675322820_0001 14/06/25 11:20:30 INFO impl.YarnClientImpl: Submitted application application_1403675322820_0001 14/06/25 11:20:30 INFO mapreduce.Job: The url to track the job: http://localhost:8088/proxy/application_1403675322820_0001/ 14/06/25 11:20:30 INFO mapreduce.Job: Running job: job_1403675322820_0001 14/06/25 11:20:52 INFO mapreduce.Job: Job job_1403675322820_0001 running in uber mode : false 14/06/25 11:20:52 INFO mapreduce.Job: map 0% reduce 0% 14/06/25 11:21:10 INFO mapreduce.Job: Task Id : attempt_1403675322820_0001_m_000000_0, Status : FAILED Error: java.lang.NumberFormatException: For input string: "0ustar" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:580) at java.lang.Integer.parseInt(Integer.java:615) at org.myorg.MySort$Map.map(MySort.java:36) at org.myorg.MySort$Map.map(MySort.java:23) at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145) at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:340) at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1548) at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:163) 14/06/25 11:21:29 INFO mapreduce.Job: Task Id : attempt_1403675322820_0001_m_000000_1, Status : FAILED Error: java.lang.NumberFormatException: For input string: "0ustar" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:580) at java.lang.Integer.parseInt(Integer.java:615) at org.myorg.MySort$Map.map(MySort.java:36) at org.myorg.MySort$Map.map(MySort.java:23) at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145) at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:340) at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1548) at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:163) 14/06/25 11:21:49 INFO mapreduce.Job: Task Id : attempt_1403675322820_0001_m_000000_2, Status : FAILED Error: java.lang.NumberFormatException: For input string: "0ustar" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:580) at java.lang.Integer.parseInt(Integer.java:615) at org.myorg.MySort$Map.map(MySort.java:36) at org.myorg.MySort$Map.map(MySort.java:23) at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145) at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:340) at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1548) at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:163) 14/06/25 11:22:10 INFO mapreduce.Job: map 100% reduce 100% 14/06/25 11:22:10 INFO mapreduce.Job: Job job_1403675322820_0001 failed with state FAILED due to: Task failed task_1403675322820_0001_m_000000 Job failed as tasks failed. failedMaps:1 failedReduces:0 14/06/25 11:22:10 INFO mapreduce.Job: Counters: 9 Job Counters Failed map tasks=4 Launched map tasks=4 Other local map tasks=3 Data-local map tasks=1 Total time spent by all maps in occupied slots (ms)=69797 Total time spent by all reduces in occupied slots (ms)=0 Total time spent by all map tasks (ms)=69797 Total vcore-seconds taken by all map tasks=69797 Total megabyte-seconds taken by all map tasks=71472128 </code></pre> <p>I have also tried using this:</p> <pre><code>hadoop jar /usr/local/hadoop/share/hadoop/tools/lib/hadoop-streaming-2.3.0.jar -Dmapred.output.compress=true -Dmapred.compress.map.output=true -Dmapred.output.compression.codec=org.apache.hadoop.io.compress.BZip2Codec -Dmapred.reduce.tasks=0 -input MySort/input/data.txt -output MySort/zip1 </code></pre> <p>It is successfull in creating compressed files</p> <pre><code>hadoop fs -ls MySort/zip1 Found 3 items -rw-r--r-- 1 hduser supergroup 0 2014-06-25 10:43 MySort/zip1/_SUCCESS -rw-r--r-- 1 hduser supergroup 42488018 2014-06-25 10:43 MySort/zip1/part-00000.bz2 -rw-r--r-- 1 hduser supergroup 42504084 2014-06-25 10:43 MySort/zip1/part-00001.bz2 </code></pre> <p>and then running this:</p> <pre><code>hadoop jar mysort.jar org.myorg.MySort MySort/input/ MySort/zip1 </code></pre> <p>It still doesn't work . Is there something that I am missing here.</p> <p>It works fine when I run it without using compressed file bz2 and directly passing it the text file Data/data.txt i.e uploading it to MySort/input in hdfs (hadoop fs -put Data/data.txt MySort/input).</p> <p>Any help is Appreciated</p>
13,259,812
0
<p>Welcome to the wonderful world of loose typing. In php, array_search defaults to nonstrict comparisons ("=="), but you can add a third parameter to force strict ("==="). You almost always want strict, though there are times when nonstrict is the correct operation.</p> <p>check out the following:</p> <pre><code>$allcraftatts = array(0, 0, 0, 0, 0, 0, "Sharp Stone", "Sharp Stones", "stone", new stdClass(), "sharp", "hard", 0, 0, 0, 0, 0,0 ,0); $testcopy=$allcraftatts; $testsharp=array_search("sharp", $testcopy); $testsharpStrict=array_search("sharp", $testcopy, true); print_r(get_defined_vars()); if(0 == "sharp"){ echo "true for == \n"; }else{ echo "false == \n"; } if(0 === "sharp"){ echo "true for === \n"; }else{ echo "false === \n"; } </code></pre> <p>and the output:</p> <pre><code>[testcopy] =&gt; Array ( [0] =&gt; 0 [1] =&gt; 0 [2] =&gt; 0 [3] =&gt; 0 [4] =&gt; 0 [5] =&gt; 0 [6] =&gt; Sharp Stone [7] =&gt; Sharp Stones [8] =&gt; stone [9] =&gt; stdClass Object ( ) [10] =&gt; sharp [11] =&gt; hard [12] =&gt; 0 [13] =&gt; 0 [14] =&gt; 0 [15] =&gt; 0 [16] =&gt; 0 [17] =&gt; 0 [18] =&gt; 0 ) [testsharp] =&gt; 0 [testsharpStrict] =&gt; 10 ) true for == false === </code></pre>
41,068,081
0
<p><code>UserDefaults</code> is just a bunch of pairs of keys and values. So, you could assign a boolean value ("hidden") for each product:</p> <pre><code>// get the current product - this depends on how your table is set up let product = products[indexPath.row] // set the boolean to true for this product UserDefaults.set(true, forKey: product) </code></pre> <p>Then, wherever you're initializing your products, add:</p> <pre><code>// only include elements that should not be hidden products = products.filter({ UserDefaults.boolForKey($0) == false }) </code></pre> <p>You could also store all of the </p>
30,018,686
1
python threads - please explain <p>I'm trying to understand how threads work in python and I'm slightly confused around a few things. </p> <p>I was under the impression that you could run different tasks at the same time in parallel when using threads? </p> <p>The code below will demonstrate some of the issues I'm experiencing with threads. (I know there are better ways writing a port scanner but this will clarify the issues I'm having )</p> <p>============ Start Example ============</p> <pre><code> import socket import threading def test2(start,end): for i in range(int(start),int(end)): server = 'localhost' s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) try: s.connect((server,i)) print("port", i , "is open", threading.current_thread().name) s.close() except socket.error as e: s.close() def threader(): print(threading.current_thread().name) if threading.current_thread().name == "Thread-0": test2(1,1000) elif threading.current_thread().name == "Thread-1": test2(1000,2000) elif threading.current_thread().name == "Thread-2": test2(2000,3000) elif threading.current_thread().name == "Thread-3": test2(3000,4000) for i in range(4): t = threading.Thread(target=threader, name= "Thread-"+str(i)) t.start() </code></pre> <p>============ End Example ============</p> <p>if I would scan 1000 ports with 1 thread it usually takes around 7-8 sec.</p> <p>The problem with the code above is that this takes around 30 sec to execute.</p> <p>Should it not take around 7-8 sec to execute if all threads are running in parallel and are scanning the same amount of ports? </p> <p>I'd really appreciate if someone could explain what I'm doing wrong here.</p> <p>TIA!</p>
264,933
0
<p>I don't know how if this is an acceptable solution for you, but you can upload your own HTML (or any other type for that matter) files on Google Pages. So the proposes solution would be: write manually the HTML pages with the necessary JS tags and upload them to Google Pages.</p>
89,750
0
<p>And when you need to inject it back into some other DOM (like your HTML page) you can export it again using the $dom->saveXML() method. The problem however is that it also exports an xml header (it's even worse for the saveHTML version). To get rid of that use this:</p> <pre><code>$xml = $dom-&gt;saveXML(); $xml = substr( $xml, strlen( "&lt;?xml version=\"1.0\"?&gt;" ) ); </code></pre>
32,426,365
0
<p>Your first script seems to work just fine with the latest Unicode version of AutoHotkey. Get latest version @ ahkscript.org</p> <p>Added a check for "ы" in the code below:</p> <pre><code>~LWin Up:: Input, key, L1 if (key = "n" or key = "ы") { Run, Notepad.exe } else if (key = "s") { Run, cmd.exe } return </code></pre> <p>Make sure to Encode your with script UTF-8 (not UTF-8 without BOM) </p> <p>Edit: </p> <p>Okay I think I found an Answer that doesn't require you to Add "ы" but instead relies on SC codes produced by the Keyboard, meaning it's Layout independent.</p> <p><a href="http://ahkscript.org/docs/commands/Input.htm" rel="nofollow">Relevant info from Input command from the Docs:</a></p> <blockquote> <p>E [v1.1.20+]: Handle single-character end keys by character code instead of by keycode. This provides more consistent results if the active window's keyboard layout is different to the script's keyboard layout. It also prevents key combinations which don't actually produce the given end characters from ending input; for example, if @ is an end key, on the US layout Shift+2 will trigger it but Ctrl+Shift+2 will not (if the E option is used). If the C option is also used, the end character is case-sensitive.</p> <p>EndKeys A list of zero or more keys, any one of which terminates the Input when pressed (the EndKey itself is not written to OutputVar). When an Input is terminated this way, ErrorLevel is set to the word EndKey followed by a colon and the name of the EndKey. Examples: EndKey:., EndKey:Escape.</p> <p>The EndKey list uses a format similar to the Send command. For example, specifying {Enter}.{Esc} would cause either ENTER, period (.), or ESCAPE to terminate the Input. To use the braces themselves as end keys, specify {{} and/or {}}.</p> <p>To use Control, Alt, or Shift as end-keys, specify the left and/or right version of the key, not the neutral version. For example, specify {LControl}{RControl} rather than {Control}.</p> <p>Although modified keys such as Control-C (^c) are not supported, certain characters that require the shift key to be held down -- namely punctuation marks such as ?!:@&amp;{} -- are supported in v1.0.14+. Other characters are supported with the E option described above, in v1.1.20+.</p> <p>An explicit virtual key code such as {vkFF} may also be specified. This is useful in the rare case where a key has no name and produces no visible character when pressed. Its virtual key code can be determined by following the steps at the bottom fo the key list page.</p> </blockquote> <pre><code>~LWin Up:: Input, key, L1 E, {SC031}.{SC01F} ; {n}.{s} if (Errorlevel = "EndKey:SC031") { Run, Notepad.exe } If (Errorlevel = "EndKey:SC01f") { Run, cmd.exe } return </code></pre> <p>Also, I wasn't able to reproduce an issue where Windows key was held down?</p>
12,027,921
0
<p>Try this,</p> <pre><code>int x = 1; if (*(char *)&amp;x == 1) printf("Little Endian [LSB first]"); // or LED1 ON else printf("Big Endian [MSB first]"); // or LED2 ON </code></pre>
40,193,067
0
Sessions in shopping cart <p>I'm trying to show in a table the values that are stored in a session, the problem is: How to show all the information until now the application shows one of my three sessions, what about the rest? Any Idea?</p> <pre><code>&lt;?php $_SESSION['id'][] = $_GET['id']; $_SESSION['name'][] = $_GET['name']; $_SESSION['price'][] = $_GET['price']; ?&gt; &lt;h1&gt;Shopping Cart&lt;/h1&gt;&lt;br&gt; &lt;table border=1&gt; &lt;th&gt;ID&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Price&lt;/th&gt; &lt;tbody id="tb"&gt; &lt;?php foreach($_SESSION['name'] as $key=&gt; $n){ ?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $n; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre>
37,396,786
0
How to count consecutive row where one column have a specific value in SQL Server? <p>I have a data set that looks like this</p> <pre><code>gId mId 226 88825 226 88825 226 88825 226 88825 226 88825 226 88825 226 88832 226 88832 226 88832 226 88832 226 88863 226 88863 226 88863 226 88863 226 88863 227 89080 227 89080 227 89080 227 89148 227 89148 227 89148 227 89197 227 89197 227 89197 227 89148 227 89197 227 89197 227 89197 227 89197 227 89148 227 89197 227 89197 227 89197 227 89197 227 89148 227 89197 227 89197 227 89197 229 89267 229 89318 229 89322 231 90257 231 90340 231 90350 247 94318 247 94318 249 94642 249 94642 249 94642 249 94400 249 94642 249 94642 249 94642 249 94642 249 94642 249 94642 249 94400 249 94400 249 94400 249 94400 </code></pre> <p>I need to be able to get a list of the unique <code>gId</code> column where the <code>mId</code> column contains the same value in 5 or more consecutive rows. So the above data set will return something like this</p> <pre><code>gId mId 226 88825 226 88863 249 94642 </code></pre> <p>One important thing to mention that I can't change the order of this list so I have to count it top to bottom to be able to check for consecutive rows.</p> <p>My table looks like this</p> <pre><code>CREATE TABLE t ( gId int NOT NULL, mId int NOT NULL ); </code></pre>
3,195,918
0
<p>You can't prevent the user from switching back because you've spawned a separate process. As far as the operating system is concerned it's as if you'd started the second one via it's desktop icon (for example).</p> <p>I think the best you can hope for is to disable the relevant menus/options when the second process is active. You'll need to keep polling to see if it's still alive, otherwise your main application will become unusable.</p> <p>Another approach might be to minimize the main application which will keep it out of the way.</p>
31,622,009
0
Nginx server (not showing changes) - Delete cache? <p>I'm running a Laravel Site (Ubuntu) on Nginx (Not a virtual box). When I make changes to a css file, or any file for that matter i'm unable to see the changes right away. I've tried changing sendfile from on to off as noted in this link: </p> <p><a href="http://stackoverflow.com/questions/6236078/how-to-clear-the-cache-of-nginx">How to clear the cache of nginx?</a></p> <p>And I couldn't find a Nginx cache file to delete the cache. Many sites recommend going to the "path/to/cache" folder but I can't find it:</p> <p><a href="https://www.nginx.com/blog/nginx-caching-guide/" rel="nofollow">https://www.nginx.com/blog/nginx-caching-guide/</a></p> <p>Anyway I don't believe I set up any kind of proxy caching or anything. Any ideas where I can find my cache so I can delete it folks? For that matter am I looking to do the correct thing here? Thanks for you answer in advance.</p> <p>This is what my test server block looks like:</p> <pre><code>server { # secure website with username and password in htpasswd file auth_basic "closed website"; auth_basic_user_file /tmp/.htpasswd.txt; listen (myip) default_server; listen [::]:83 default_server ipv6only=on; root /var/www/test/(sitefolder); index index.php index.html index.htm; # Make site accessible server_name (myiphere); location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ /index.php?$query_string; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } </code></pre> <p>This is what my real site server block looks like:</p> <pre><code>server { # secure website with username and password in htpasswd file auth_basic "closed website"; auth_basic_user_file /tmp/.htpasswd.txt; listen (myip) default_server; listen [::]:81 default_server ipv6only=on; root /var/www/(mysite)/public; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name (myip); location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ /index.php?$query_string; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } </code></pre>
25,130,414
0
not being able to set the n° of specified threads desired <p>I have this very simple openmp program that is not creating the four desired threads, #include #include </p> <pre><code>main () { omp_set_num_threads(4); #pragma omp paralel { int id = omp_get_thread_num(); int nt = omp_get_num_threads(); printf ("I am thread %d of %d threads\n",id,nt); } </code></pre> <p>When I run it the command line says the total it is 1. What am I forgetting? </p>
191,006
0
<p>I also vote for the second version based on<br> this <a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/undo.htm" rel="nofollow noreferrer">link</a> (which is Oracle 10.2, but I think it still applies to 9.2 as well). </p> <p>It says: "After a transaction is committed, undo data is no longer needed for rollback or transaction recovery purposes. However, for consistent read purposes, long-running queries may require this old undo information for producing older images of data blocks."</p> <p>and</p> <p>"When automatic undo management is enabled, there is always a current undo retention period, which is the minimum amount of time that Oracle Database attempts to retain old undo information before overwriting it."</p>
19,807,883
0
<p>Are you getting no errors at all from the Javascript console you're using? I'd say adding parentheses should do the trick:</p> <pre><code>$$('.student-link').invoke('observe','click',draw_report()); $$('.student-link').invoke('observe','click',set_active()); </code></pre> <p><strong>EDIT</strong>: I see you use a jQuery tag in your original question. Are you sure you're using jQuery? Because the javascript code above looks suspiciously like Prototype.</p>
3,761,428
0
<p>Since you're asking for the best way, and if Log4J is not a strong requirement, my suggestion would be to use <a href="http://logback.qos.ch/" rel="nofollow noreferrer">Logback</a> and its <a href="http://logback.qos.ch/manual/appenders.html#DBAppender" rel="nofollow noreferrer"><code>DbAppender</code></a>. That's the best way :)</p> <p>Last time I checked, the <a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/jdbc/JDBCAppender.html" rel="nofollow noreferrer"><code>JDBCAppender</code></a> from Log4J was still not satisfying and if you can't use logback, you might prefer some third party implementation. See the links below for details:</p> <ul> <li><a href="http://www.boky.cc/2010/02/03/jdbcappender-for-log4j/" rel="nofollow noreferrer">http://www.boky.cc/2010/02/03/jdbcappender-for-log4j/</a></li> <li><a href="http://www.dankomannhaupt.de/projects/" rel="nofollow noreferrer">http://www.dankomannhaupt.de/projects/</a> (older)</li> </ul>
21,531,351
0
how to do URL-Rewriting when browser cookies are disabled? <p>I am trying to achieve URL-Rewriting for my Application. I am using java,servlet, JSP, tomcat 7 as part of the technologies. </p> <p><strong>BackGround:</strong> The reason for URL-Rewriting is that when my browser cookies are disabled the connection between the client and the server is not established and session on being lost and for each request that comes from the browser the server thinks as a new request. </p> <p>By reading through the <a href="https://stackoverflow.com/questions/2065735/how-can-i-do-sessions-in-java-if-some-one-disables-cookies-in-my-browser?lq=1">interne</a>t found that URL-Rewriting is one solution. </p> <p>My application has just one JSP page called <code>root.jsp</code> This is how i am loading the jsp page from my servlet. I have only one servlet that handles all the request.</p> <pre><code>getServletContext().getRequestDispatcher("/view/root.jsp").forward( request, response); </code></pre> <p>In <code>root.jsp</code> includes another jsp pages as a part of <code>root.jsp</code> it shown below. Based on the programming logic the respective JSP page that needs to be included get added.</p> <pre><code>&lt;div class="grey_container"&gt; &lt;jsp:include page="${requestScope.jspPage.pageFileUrl}" flush="false" /&gt; &lt;/div&gt; </code></pre> <p>I read that the URL-rewriting is possible using <code>HttpServletResponse encodeURL() and encodeRedirectURL()</code>. For the JSP pages this encodeURL is achievied using <a href="http://www.tutorialspoint.com/jsp/jstl_core_url_tag.htm" rel="nofollow"><code>&lt;c:url&gt;</code></a></p> <p>WHat i have tried </p> <p>In my servlet show below, I did not see any Jsession ID being appended to the URL.</p> <pre><code>getServletContext().getRequestDispatcher(response.encodeURL("/view/root.jsp")).forward( request, response); getServletContext().getRequestDispatcher(response.encodeRedirectURL("/view/root.jsp")).forward( request, response); </code></pre> <p>Next thought that i might need to configure something similar in JSP using <code>&lt;c:url&gt;</code> tag. So tried to configure in the <code>&lt;jsp: include&gt;</code> but it is throwing some compilation exception. so at this point of time i tried different approaches to make that JSP compilation error go away but was not successful. So thought that is it possible configure to <code>&lt;jsp: include&gt;</code> to have <code>&lt;c:url&gt;</code> was not sure. configuring in JSP with <code>&lt;c:url&gt;</code> is needed?</p> <p>Below is the exception when i try to configure the </p> <pre><code>&lt;jsp:include page="&lt;c:url value="${requestScope.jspPage.pageFileUrl}"/&gt;" flush="false" /&gt; org.apache.jasper.JasperException: /view/root.jsp (line: 97, column: 38) Unterminated &amp;lt;jsp:include tag at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42) at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443) at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:133) at org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:992) at org.apache.jasper.compiler.Parser.parseInclude(Parser.java:854) at org.apache.jasper.compiler.Parser.parseStandardAction(Parser.java:1116) at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1451) at org.apache.jasper.compiler.Parser.parse(Parser.java:138) at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242) at org.apache.jasper.compiler.ParserController.parse(ParserController.java:102) at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:373) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) </code></pre> <p>How should i configure my servlet/JSP page for the URL rewriting?</p>
34,493,379
0
<pre><code>for (CNContact *contact in contacts) { if (!contacts) { contacts = [[NSMutableArray alloc] init]; if ( contact.imageData != nil ) { // iOS &gt;= 4.1 UIImage *CIMage = [UIImage imageWithData:(NSData *)contact.imageData]; } } NSString *string = [formatter stringFromContact:contact]; NSLog(@"contact = %@", string); [contacts addObject:string]; } // Please this code is run in my app please try it. </code></pre>
277,436
0
<p>See that the margins and paddings are correct. The scrollbar can be behind something.</p> <p>Put the exterior container height with a fixed value, It can be <em>stretching</em> the listview so it will never show the scrollbar.</p> <p>HTH</p>
35,997,353
0
<p>The cells are reused in iOS, so you need to make sure you properly unhook handlers and reset state when a cell is reused. You can do something like this:</p> <pre><code>public partial class CustomCell : UITableViewCell { EventHandler _likeButtonHandler; public static readonly NSString Key = new NSString (typeof(CustomCell).Name); public static readonly UINib Nib = UINib.FromName (typeof(CustomCell).Name, NSBundle.MainBundle); public CustomCell () { } public CustomCell (IntPtr handle) : base (handle) { } public override void PrepareForReuse () { LikeButton.TouchUpInside -= _likeButtonHandler; _likeButtonHandler = null; base.PrepareForReuse (); } public void SetupCell (int row, string Name, EventHandler likeBtnHandler) { _likeButtonHandler = likeBtnHandler; LikeButton.TouchUpInside += _likeButtonHandler; LikeButton.Tag = row; NameLabel.Text = Name; RowLabel.Text = row.ToString (); } } </code></pre> <p>Notice that I unhook the event handler in the <code>PrepareForReuse</code> override. This is the correct place to do clean up and reset a cell for reuse. You should NOT be using <code>MovedToWindow()</code>.</p> <p>Then your <code>GetCell</code> method will look like this:</p> <pre><code> public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) { var cell = tableView.DequeueReusableCell (CustomCell.Key) as CustomCell ?? new CustomCell (); cell.SetupCell (indexPath.Row, _fruits [indexPath.Row], _likeButtonHandler); return cell; } </code></pre> <p>The <code>_likeButtonHandler</code> is a simple <code>EventHandler</code>.</p>
37,774,208
0
MYSQL Nested Query with two select <p>I have:</p> <pre><code>Table1 (UserID -City - Adress - Mobile) Table2 (DeviceID - UserID - Vendor - Model). </code></pre> <p>I want to perform nested query to select the following in one row:</p> <pre><code> select DeviceID, UserID, Model From Table2 Where Vendor=Sony (and for this row go and select City - Address - Mobile from table 1 where table1.UserID = Table2.UserID) </code></pre> <p>How can I perfom the second select in the same query to be printed in the same row after Model.</p>
30,385,579
0
<p>Suggest the use of <code>Defined Name Ranges</code> to hold the user maintained list <em>(as show in the picture below)</em></p> <p><img src="https://i.stack.imgur.com/lDiiH.png" alt="enter image description here"></p> <p>Let’s add a worksheet for user input of the requirements called “_Tables”. Then create <code>Defined Name Ranges</code>, for users to enter the requirements, called <code>"_Path"</code>, <code>"_Files"</code> and <code>"_SubFldrs"</code></p> <p>Then replace all the user’s input in current code </p> <pre><code>REPLACE THIS ''' With Application.FileDialog(msoFileDialogFolderPicker) ''' If .Show Then ''' myDir = .SelectedItems(1) ''' End If ''' End With ''' msg = "Enter File name and Extension" &amp; vbLf &amp; "following wild" &amp; _ ''' " cards can be used" &amp; vbLf &amp; "* # ?" ''' myExtension = Application.InputBox(msg) ''' If (myExtension = "False") + (myExtension = "") Then Exit Sub ''' Rtn = MsgBox("Include Sub Folders ?", vbYesNo) ''' SearchSubFolders = Rtn = 6 </code></pre> <p>with this in order to read the requirements from the worksheet "_Tables"</p> <pre><code> Set WshLst = ThisWorkbook.Sheets("_Tables") sPath = WshLst.Range("_Path").Value2 aFleKey = WshLst.Range("_Files").Value2 bSbFldr = UCase(WshLst.Range("_SubFldrs").Value2) = UCase("YES") aFleKey = WorksheetFunction.Transpose(aFleKey) </code></pre> <p>then Process the lists See below the entire code below. It's necessary to have the statement <code>Option Base 1</code> at the top of the module</p> <pre><code>Option Explicit Option Base 1 Sub Fle_FileSearch_List() Dim WshLst As Worksheet Dim sPath As String Dim aFleKey As Variant, vFleKey As Variant Dim bSbFldr As Boolean Dim vFleLst() As Variant Dim lN As Long Set WshLst = ThisWorkbook.Sheets("_Tables") sPath = WshLst.Range("_Path").Value2 aFleKey = WshLst.Range("_Files").Value2 bSbFldr = UCase(WshLst.Range("_SubFldrs").Value2) = UCase("YES") aFleKey = WorksheetFunction.Transpose(aFleKey) Rem To clear output location ThisWorkbook.Sheets(1).Columns(1).Resize(, 2).Clear Rem Process input list For Each vFleKey In aFleKey If (vFleKey &lt;&gt; "False") * (vFleKey &lt;&gt; "") Then Call Fle_FileSearch_Fldrs(sPath, CStr(vFleKey), lN, vFleLst, bSbFldr) End If: Next Rem Validate Results &amp; List Files found If lN &gt; 1 Then ThisWorkbook.Sheets(1).Cells(1).Resize(UBound(vFleLst, 2), 2) _ .Value = Application.Transpose(vFleLst) Else MsgBox "No file found" End If End Sub </code></pre> <p>Also some adjustments to the function <em>(now a procedure)</em> to allow the process of the list.</p> <pre><code>Sub Fle_FileSearch_Fldrs(sPath As String, _ sFleKey As String, lN As Long, vFleLst() As Variant, _ Optional bSbFldr As Boolean = False) Dim oFso As Object, oFolder As Object, oFile As Object Set oFso = CreateObject("Scripting.FileSystemObject") If lN = 0 Then lN = 1 + lN ReDim Preserve vFleLst(1 To 2, 1 To lN) vFleLst(1, lN) = "Files Found - Path" vFleLst(2, lN) = "Files Found - Name" End If For Each oFile In oFso.GetFolder(sPath).Files Select Case oFile.Attributes Case 2, 4, 6, 34 Case Else If (Not oFile.Name Like "~$*") * _ (oFile.Path &amp; "\" &amp; oFile.Name &lt;&gt; ThisWorkbook.FullName) * _ (UCase(oFile.Name) Like UCase(sFleKey)) Then lN = lN + 1 ReDim Preserve vFleLst(1 To 2, 1 To lN) vFleLst(1, lN) = sPath vFleLst(2, lN) = oFile.Name End If: End Select: Next If bSbFldr Then For Each oFolder In oFso.GetFolder(sPath).subfolders Call Fle_FileSearch_Fldrs(oFolder.Path, sFleKey, lN, vFleLst, bSbFldr) Next: End If End Sub </code></pre>
6,659,690
1
Is there a way to chunk 2 or more repititions of a tag in a tagged sentence using nltk? <p>I'm trying to use the nltk module in python to chunk together any instances where two to five nouns occur in sequence.</p> <p>This is the code I am using:</p> <pre><code>parse_pattern = "Keyword: {&lt; N&gt;{2,5}}" keyword_parser = nltk.RegexpParser(parse_pattern) result = keyword_parser.parse(sentence) </code></pre> <p>I makes sense that this bit should do the trick: <code>Keyword: {&lt; N&gt;{2,5}}</code></p> <p>I even found an example in the book Natural Language Processing with Python that uses the above bit completely analogously: <code>NOUNS: {&lt; N.*&gt;{4,}}</code> where the authors explain that that bit of code should chunk 4 or more nouns.</p> <p>However, I get an error when I run the above code:</p> <pre><code>ValueError: Illegal chunk pattern: {&lt; N&gt;{2,5}} </code></pre> <p>Note: I also tried the above using <code>{&lt; N.*&gt;{2,5}}</code> (with the dot star solely because the author of the aforementioned book did) with no luck.</p> <p>Any help in how to chunk two or more repetitions of a tag would be highly appreciated.</p>
37,046,362
0
<p>You could achieve this by looping over the properties of the object itself and sorting the arrays they contain, something like this:</p> <pre><code>for (var key in mainarray) { if (mainarray[key] === Array) mainarray[key].sort(); } </code></pre> <p><a href="https://jsfiddle.net/26gk4h9b/" rel="nofollow"><strong>Working example</strong></a></p> <p>Note that by default <code>sort()</code> only uses basic alphanumeric sorting logic. If you need anything more complex you would need to implement that yourself.</p>
23,489,696
0
How to disabled selected date (asp.net mvc4) <p>I am trying to make an appointment page in MVC4. It is working well but I would like to disable the date which is chosen. Here is my controller to make an appointment:</p> <pre><code>public ActionResult Make() { return View(); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult Make(Models.AppModel User) { if (Session["UserEmail"] != null) { using (var db = new MaindbModelDataContext()) { var patient = db.Patients.FirstOrDefault(u =&gt; u.Email == (String)Session["UserEmail"]); var app = new Appointment(); app.Date = (DateTime)User.Date; app.Description = User.Description; app.Status = "isPending"; app.PatientNo = patient.PatientNo; app.AppNo = Guid.NewGuid().GetHashCode(); db.Appointments.InsertOnSubmit(app); db.SubmitChanges(); } } else { return RedirectToAction("Index", "User"); } return RedirectToAction("Index", "Patient"); } // } } </code></pre> <p>and here is my view with the datepicker</p> <pre><code>@model DentAppSys.Models.AppModel @{ ViewBag.Title = "Appointment"; } &lt;link type="text/css" rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&gt; &lt;script src="//code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt; &lt;script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&gt;&lt;/script&gt; @using (Html.BeginForm()) { @Html.AntiForgeryToken(); @Html.ValidationSummary(true, ""); &lt;div&gt; &lt;fieldset&gt; &lt;legend&gt;Get an Appointment&lt;/legend&gt; &lt;div&gt;@Html.LabelFor(u =&gt; u.Date)&lt;/div&gt; &lt;div&gt; @Html.TextBoxFor(u =&gt; u.Date, htmlAttributes: new { id = "DatePicker" }) @Html.ValidationMessageFor(u =&gt; u.Date) &lt;/div&gt; &lt;div&gt;@Html.LabelFor(u =&gt; u.Description)&lt;/div&gt; &lt;div&gt; @Html.TextBoxFor(u =&gt; u.Description) &lt;/div&gt; &lt;input type="submit" value="Submit" class="footer_btn" /&gt; &lt;/fieldset&gt; &lt;/div&gt; } &lt;script type="text/javascript"&gt; $(function () { $("#DatePicker").datepicker(); }); &lt;/script&gt; </code></pre>
4,049,949
0
<p>This website is pretty good but not specific to Java: <a href="http://bigocheatsheet.com/" rel="nofollow noreferrer">http://bigocheatsheet.com/</a></p> <p><strike>A copy of the original link in this answer can be found at <a href="https://github.com/benblack86/java-snippets/blob/master/resources/java_collections.pdf" rel="nofollow noreferrer">https://github.com/benblack86/java-snippets/blob/master/resources/java_collections.pdf</a></strike></p> <p><strike><em>The website hosting the original links for Java's big-O summary has gone offline. You can still find them at the web archive:</em></p> <p><a href="http://web.archive.org/web/20110227091351/http://www.coderfriendly.com/2009/05/12/java-collections-cheatsheet/" rel="nofollow noreferrer">http://web.archive.org/web/20110227091351/http://www.coderfriendly.com/2009/05/12/java-collections-cheatsheet/</a></strike></p> <p><strike><a href="http://web.archive.org/web/20110626160836/http://www.coderfriendly.com/wp-content/uploads/2009/05/java_collections_v2.pdf" rel="nofollow noreferrer">http://web.archive.org/web/20110626160836/http://www.coderfriendly.com/wp-content/uploads/2009/05/java_collections_v2.pdf</a></strike></p>
20,014,292
0
Chain an additional order on a Rails activerecord query? <p>Activerecord seems to ignore my second <code>order</code> in a chained AR query.</p> <p>What I'm trying to do is retrieve the top 5 most-read articles <em>within</em> the top 25 highest-scored (eg. rated by users) articles.</p> <p><code>Article</code> has both <code>read_count</code> (integer) and <code>score</code> (float) columns that I order by.</p> <p>My (naive?) attempt was this query:</p> <pre><code>Article.order("score DESC").limit(25).order("read_count DESC").limit(5) </code></pre> <p>What this returns is simply the first 5 highest-scored articles, rather than the 5 most-read articles within the first 25 highest-scored.</p> <p>Can I do this in a single query? Thanks for any help!</p> <p><em>(I'm on Rails 3.2 and Postgres 9.2)</em></p> <p><strong>Addendum</strong></p> <p>Thank you to brad and Philip Hallstrom for two solutions to this. Either would have been acceptable, although I went with brad's database-only solution as explained in my comment on his answer.</p> <p>Profiling each query on my local development machine (MBA) showed the subquery solution to be 33% faster than the Ruby-loop solution. Profiling the queries on my production machine (Heroku + Crane production database) showed the subquery solution to be <strong>95% faster</strong>! (this is across a database of 40,000 articles).</p> <p>While the actual time taken is pretty insignificant, 95% faster and 50% fewer lines of code is a pretty good decider.</p> <pre><code>Ruby-loop solution: (Philip) dev: 24 msec prod: 16 msec Sub-query solution: (brad) dev: 22 msec prod: 0.9 msec </code></pre> <p>Thanks to both Philip and brad for their answers!</p>
34,858,841
0
<p>I had the exact same problem with a VS 2012 and oracle.dataAccess.dll In a software my team developed. When looking dipper to the code and spending lots of hours configuring all kinds of stuff eventually turns out it was a compiling error due to a 64x/86x bit mismatch. Your exception is quite general but I hope this works for you too.</p>
25,821,688
0
Swift generic Function (n choose k) <p>I'm trying to make this JavaScript code in Swift: <a href="https://gist.github.com/axelpale/3118596" rel="nofollow">k_combinations</a></p> <p>And so far i have this in Swift:</p> <pre><code>import Foundation import Cocoa extension Array { func slice(args: Int...) -&gt; Array { var s = args[0] var e = self.count - 1 if args.count &gt; 1 { e = args[1] } if e &lt; 0 { e += self.count } if s &lt; 0 { s += self.count } let count = (s &lt; e ? e-s : s-e)+1 let inc = s &lt; e ? 1 : -1 var ret = Array() var idx = s for var i=0;i&lt;count;i++ { ret.append(self[idx]) idx += inc } return ret } } func kombinaatiot&lt;T&gt;(setti: Array&lt;T&gt;, k: Int) -&gt; Array&lt;Array&lt;T&gt;&gt; { var i: Int, j: Int if (k &gt; setti.count || k &lt;= 0) { return [] } if (k == setti.count) { return [setti] } if (k == 1) { var combs: Array&lt;T&gt; = [] for var i = 0; i &lt; setti.count; i++ { combs += [setti[i]] } return [combs] } var combs: Array&lt;Array&lt;T&gt;&gt; = [[]] for var i = 0; i &lt; setti.count - k + 1; i++ { var head = setti.slice(i,i + 1) var tailcombs = kombinaatiot(setti.slice(i + 1), k - 1) for var j = 0; j &lt; tailcombs.count; j++ { combs += ([head + tailcombs[j]]) } } println(combs) return combs } </code></pre> <p>But problem is that my function prints</p> <pre><code>[[], [1, 2, 2, 3, 4], [2, 3, 3, 4], [3, 4, 4]] </code></pre> <p>when it should print </p> <pre><code>[[1,2], [1,3], [2, 3] </code></pre> <p>What i'm doing wrong here? Im noobie at coding, and my javascript skills aren't very well, but that javascript worked for me, but in swift i can't make that work.</p>
16,105,116
0
<p>Display as columns - this is a simple way. You may employ Rpad(), Lpad() for this, which would be more advanced I guess:</p> <pre><code>DECLARE v_name varchar2(30) := 'Joe Bloggs'; v_job varchar2(20) := 'Contractor'; v_pay number := 52657.3; BEGIN DBMS_OUTPUT.PUT_LINE('Employee Name'||chr(9)||chr(9)||chr(9)||'Job'||chr(9)||chr(9)||chr(9)||chr(9)||chr(9)||'Total Pay'); DBMS_OUTPUT.PUT_LINE('--------------------------------------------------------'); DBMS_OUTPUT.PUT_LINE(v_name||chr(9)||chr(9)||chr(9)||chr(9)||chr(9)||v_job||chr(9)||chr(9)||TRIM(TO_CHAR(v_pay, '$999G999G999D99'))); END; / Employee Name Job Total Pay -------------------------------------------------------- Joe Bloggs Contractor $52,657.30 </code></pre>
30,951,269
0
<p>You are casting the short to AppCacheStatus object below, hence the error.</p> <pre><code> AppCacheStatus status = ((ApplicationCache) (driver)).getStatus(); </code></pre> <p><a href="http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/html5/ApplicationCache.html#getStatus%28%29" rel="nofollow">ApplicationCache</a> is an interface so you have to write your own version of getStatus method.</p> <p>You may want to get the cache status using the JavaScriptExecutor. Hope that helps.</p> <pre><code>JavascriptExecutor jsExecutor = (JavascriptExecutor) driver; long cacheStatus = (long) jsExecutor.executeScript("return window.applicationCache.status;"); System.out.println(cacheStatus); </code></pre>
26,393,976
0
Python File Writing Format Issue <p><strong>The Code</strong></p> <pre><code>def rainfallInInches(): file_object = open('rainfalls.txt') list_of_cities = [] list_of_rainfall_inches = [] for line in file_object: cut_up_line = line.split() city = cut_up_line[0] rainfall_mm = int(line[len(line) - 3:]) rainfall_inches = rainfall_mm / 25.4 list_of_cities.append(city) list_of_rainfall_inches.append(rainfall_inches) inch_index = 0 desired_file = open("rainfallInInches.txt", "w") for city in list_of_cities: desired_file.writelines(str((city, "{0:0.2f}".format(list_of_rainfall_inches[inch_index])))) inch_index += 1 desired_file.close() </code></pre> <p><strong>rainfalls.txt</strong></p> <blockquote> <pre><code>Manchester 37 Portsmouth 9 London 5 Southampton 12 Leeds 20 Cardiff 42 Birmingham 34 Edinburgh 26 Newcastle 11 </code></pre> </blockquote> <p><strong>rainfallInInches.txt</strong> This is the unwanted output</p> <blockquote> <p>('Manchester', '1.46')('Portsmouth', '0.35')('London', '0.20')('Southampton', '0.47')('Leeds', '0.79')('Cardiff', '1.65')('Birmingham', '1.34')('Edinburgh', '1.02')('Newcastle', '0.43')</p> </blockquote> <p>My program takes the data from 'rainfalls.txt' which has rainfall information in mm and converts the mm to inches then writes this new information into a new file 'rainfallInInches.txt'.</p> <p>I've gotten this far except I can't figure out how to format 'rainfallInInches.txt' to make it look like 'rainfalls.txt'.</p> <p>Bear in mind that I am a student, which you probably gathered by my hacky code.</p>
38,889,709
0
Redirect to another route when `mapHooks` fails <p>I have defined following <code>mapHooks</code>:</p> <pre><code>const mapHooks = { fetch: ({ dispatch, params }) =&gt; dispatch(fetchPost(params.postId)).catch(() =&gt; { console.log('catch'); }), }; </code></pre> <p>Sometimes, post cannot be found and I'd like to redirect user to the another page. When I <code>catch</code> the error I tried to call <code>push('/foo')</code> to redirect to <code>/foo</code> page, but it does nothing (<code>push</code> comes from <code>react-router-redux</code>.</p> <p>How can I redirect user properly ?</p>
9,367,650
0
Extract KML from Fusion Tables into Google Earth <p>I am trying to extract my KML file from Google's Fusion Tables into Google Earth. I follow what I think are the necessary steps via KML Network Link instructions. I must be missing something because no matter what I do the data will not show in Google Earth. I have the Fusion file shared as Unlisted, but am I supposed create a public URL as well in order for the points to show in google earth?</p> <p>Sorry for the basic/beginner question. It's SO basic I can't find a question already addressing the issue.</p> <p>Thanks in advance.</p>
30,184,152
0
<p>You can achieve this by specifying things you want to show on card in <code>cardConfig</code></p> <pre><code>cardConfig: { fields: [ 'Name', 'TestCases', 'c_StoryType', 'Children', 'c_TargetRelease', 'PlanEstimate' { name: 'Children', renderer: this._renderChildStories }, ], } </code></pre> <p>and then define <code>_renderChildStories</code> function, I thing <code>value</code> will be a collection of child stories, so you can loop that depending upon the <code>val</code> value</p> <pre><code>_renderChildStories: function(val) { var store = Ext.create('Rally.data.custom.Store',{ data: [ { 'FormattedID': val.get('FormattedID'), 'Name': val.get('Name') } ] }); return store } </code></pre>
26,008,034
0
How to customise the php script so that the feedback is exactly the same as the user have typed out in a form? <p>Does anyone have any idea how to customize the php page so that the user can see a feedback of what he has already filled in? I noticed many php scripts have a 'thank you' feedback but I want more than that. The codes for the php as shown below :</p> <pre><code> &lt;?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "[email protected]"; $email_subject = "Photography Courses that I want to sign up"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.&lt;br /&gt;&lt;br /&gt;"; echo $error."&lt;br /&gt;&lt;br /&gt;"; echo "Please go back and fix these errors.&lt;br /&gt;&lt;br /&gt;"; die(); } // validation expected data exists if(!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['tel']) || /*!isset($_POST['basic']) || !isset($_POST['advanced']) || !isset($_POST['raw']) || !isset($_POST['lightroom']) ||*/ !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $name = $_POST['name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['tel']; // required $basic = $_POST['basic']; // not required $advanced = $_POST['advanced']; // not required $raw = $_POST['raw']; // not required $lightroom = $_POST['lightroom']; // not required $comments = $_POST['comments']; // not required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$name)) { $error_message .= 'The Name you entered does not appear to be valid.&lt;br /&gt;'; } if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.&lt;br /&gt;'; } /*if(!preg_match($string_exp,$telephone)) { $error_message .= 'You need to insert the telephone number.&lt;br /&gt;'; }*/ /* if(strlen($comments) &lt; 2) { $error_message .= 'Insufficient Words for comments! &lt;br /&gt;'; }*/ if(strlen($error_message) &gt; 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "\n Name: ".clean_string($name)."\n\n"; $email_message .= "Email: ".clean_string($email_from)."\n\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n\n"; $email_message .= "Courses Taking: \n\n".clean_string($basic)."\n\n" .clean_string($advanced)."\n\n" .clean_string($raw)."\n\n" .clean_string($lightroom)."\n\n"; $email_message .= "Comments: ".clean_string($comments)."\n\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?&gt; &lt;!-- include your own success html here --&gt; &lt;?php echo '&lt;h2&gt;Thanks for filling up this form, We will get back to you by next Monday (29 Sep). Have a terrific weekend!&lt;/h2&gt;'; echo '&lt;p&gt;**How do I feedback of what the user has already filled in the form here?** &lt;/p&gt;'; ?&gt; &lt;?php $redirect = 'http://www.acetraining.com.sg'; ?&gt; &lt;?php } ?&gt; &lt;SCRIPT LANGUAGE="JavaScript"&gt; redirTime = "4000"; redirURL = "&lt;?php echo $redirect ?&gt;"; function redirTimer() { self.setTimeout("self.location.href=redirURL;",redirTime);} &lt;/script&gt; &lt;BODY onLoad="redirTimer()"&gt; </code></pre> <p>Thanks!</p>
20,676,383
0
<p>You need many to many relationship:</p> <p><strong>In your user model:</strong></p> <pre><code>class User extends Eloquent { public function leads() { return $this-&gt;belongsToMany('Lead'); } } </code></pre> <p><strong>In your Lead model:</strong></p> <pre><code>class Lead extends Eloquent { public function users() { return $this-&gt;belongsToMany('User'); } } </code></pre> <p><strong>Then from your controller:</strong> Utilize the many to many relationship.</p> <pre><code>$leads = User::find(1)-&gt;leads; </code></pre> <p><strong>Important:</strong></p> <p>Three database tables are needed for this relationship: <code>users</code>, <code>leads</code>, and <code>lead_user</code>. The <code>lead_user</code> table is derived from the alphabetical order of the related model names, and should have <code>user_id</code> and <code>lead_id</code> columns.</p> <p>Reference:</p> <p><a href="http://laravel.com/docs/eloquent#many-to-many" rel="nofollow">http://laravel.com/docs/eloquent#many-to-many</a></p> <p><strong>Iterate items</strong></p> <pre><code>foreach ($leads as $lead) { dd($lead); } </code></pre> <p>More info:</p> <p><a href="http://laravel.com/docs/eloquent#working-with-pivot-tables" rel="nofollow">http://laravel.com/docs/eloquent#working-with-pivot-tables</a></p>
33,968,920
0
postgres database : Insufficient privilege, permission denied for relation table <p>I have been using the postgres database on heroku for a while. and suddenly I had some problems on saving to database I got this error all the time</p> <pre><code> Insufficient privilege, permission denied for relation table </code></pre> <p>its a problem of user permission , but I'm confused why it happened , because it was working correctly before</p>
15,274,823
0
<p>You can store a whole matrix in one column of a <code>data.frame</code>:</p> <pre><code>x &lt;- a [, -1] y &lt;- a [, 1] data &lt;- data.frame (y = y, x = I (x)) str (data) ## 'data.frame': 10 obs. of 2 variables: ## $ y: num 0.818 0.767 -0.666 0.788 -0.489 ... ## $ x: AsIs [1:10, 1:9] 0.916274.... 0.386565.... 0.703230.... -2.64091.... 0.274617.... ... model &lt;- lm (y ~ x) newdata &lt;- data.frame (x = I (b [, -1])) predict (model, newdata) ## 1 2 ## -3.795722 -4.778784 </code></pre> <p>The paper about the pls package, (<a href="http://www.jstatsoft.org/v18/i02/" rel="nofollow">Mevik, B.-H. and Wehrens, R. The pls Package: Principal Component and Partial Least Squares Regression in R Journal of Statistical Software, 2007, 18, 1 - 24.</a>) explains this technique. </p> <p>Another example with a spectroscopic data set (quinine fluorescence), is in <a href="http://hyperspec.r-forge.r-project.org/blob/flu.pdf" rel="nofollow"><code>vignette ("flu")</code></a> of my package hyperSpec. </p>
1,469,564
0
<p>The character array contains executable code and the cast is a function cast.</p> <p><code>(*(void(*) ())</code> means "cast to a function pointer that produces void, i.e. nothing. The <code>()</code> after the name is the function call operator.</p>
29,419,642
0
PHP Form With Conditional Fields <p>I am trying to create a PHP form to insert records into a database where the record has conditional start and end dates. I have two radio buttons setup where you can either choose: </p> <ol> <li>No End Date </li> <li>Choose a series of date and time options which are concated into start and end dates and times. </li> </ol> <p>I have Javascript set so that by default you only see the first option. The additional fields appear if you choose the second radio button. When you hit the submit button, you get the following error: </p> <blockquote> <p>Column count doesn't match value count at row 1</p> </blockquote> <p>Can anyone tell me what the see wrong in the markup? </p> <p>Here is the code for the page:</p> <pre><code>&lt;?php require_once('../Connections/mysqlconnect.php'); ?&gt; &lt;?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION &lt; 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) &amp;&amp; ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO keywords (id, station, keyword, url, target, start_date, end_date) VALUES (%s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['id'], "int"), GetSQLValueString($_POST['station'], "text"), GetSQLValueString($_POST['keyword'], "text"), GetSQLValueString($_POST['url'], "text"), GetSQLValueString($_POST['target'], "text"), GetSQLValueString($_POST['unlimited'], "text"), GetSQLValueString(date("Y-m-d H:i:s", strtotime($_POST['startDay'] . $_POST['start-hour'] . ':' . $_POST['start-minute'] . $_POST['start-meridian'])), "date"), GetSQLValueString(date("Y-m-d H:i:s", strtotime($_POST['endDay'] . $_POST['end-hour'] . ':' . $_POST['end-minute'] . $_POST['end-meridian'])), "date")); mysql_select_db($database_mysqlconnect, $mysqlconnect); $Result1 = mysql_query($insertSQL, $mysqlconnect) or die(mysql_error()); $insertGoTo = "manage.php?mess=3"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&amp;" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } mysql_select_db($database_mysqlconnect, $mysqlconnect); $query_Recordset1 = "SELECT * FROM keywords"; $Recordset1 = mysql_query($query_Recordset1, $mysqlconnect) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Ad Inventory:: Add New Campaign&lt;/title&gt; &lt;script type="text/javascript" src="http://yourligas.yourli.com/datepicker/jquery-ui-1.10.4.custom/js/jquery-1.10.2.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://yourligas.yourli.com/datepicker/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://yourligas.yourli.com/datepicker/jquery-ui-1.10.4.custom/js/jquery-ui-.custom.min.js"&gt;&lt;/script&gt; &lt;script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"&gt;&lt;/script&gt; &lt;link rel="stylesheet" type="text/css" media="screen" href="http://yourligas.yourli.com/datepicker/jquery-ui-1.10.4.custom/css/ui-lightness/jquery-ui-1.10.4.custom.css"&gt; &lt;link rel="stylesheet" type="text/css" media="screen" href="http://yourligas.yourli.com/datepicker/jquery-ui-1.10.4.custom/css/ui-lightness/jquery-ui-1.10.4.custom.min.css"&gt; &lt;script&gt; $(function() { $( "#startdatepicker" ).datepicker({ showOn: "button", buttonImage: "http://yourligas.yourli.com/datepicker/jquery-ui-1.10.4.custom/development-bundle/demos/images/calendar.gif", buttonImageOnly: true, changeMonth: true, changeYear: true }); }); $(function() { $( "#enddatepicker" ).datepicker({ showOn: "button", buttonImage: "http://yourligas.yourli.com/datepicker/jquery-ui-1.10.4.custom/development-bundle/demos/images/calendar.gif", buttonImageOnly: true, changeMonth: true, changeYear: true }); }); &lt;/script&gt; &lt;style&gt; html,body{font-family:Arial, Helvetica, sans-serif;font-size:14px;margin:0 auto;background:#EFEFEF;} h1{margin-left:0;font-size:36px;} a{text-decoration:none;color:#036;font-weight:bold;font-size:16px;} a:visited{color:#036} td{ font-family: Arial, Helvetica, sans-serif; color: #585858; } tr.heading, .heading a{color:#fff; font-size:14px;font-weight:bold} tr.heading td{background:#036!important;color:#ffffff;} tr.alt td { background-color: #B9DCFF; } tr td { background-color: #D7EBFF;padding:10px; } .nav{list-style:none;margin:0;padding:0;text-align:right;} .nav li{display:inline-block;padding:0 10px;} .confirm-message{ width:800px; margin:0 auto; border:1px solid #004A0D; padding:15px; text-align:center; background-color: #B9FFC6; } .error{ color:#ff0000; font-style:italic; } &lt;/style&gt; &lt;link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;&lt;h1 align="center" style="font-size:30px;"&gt;CONNOISSEUR LI:: Keyword Management&lt;/h1&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;?php // define variables and set to empty values $campaignErr = $startdateErr = $enddateErr = ""; $campaign = $startdate = $enddate = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["campaign"])) {$campaignErr = "Please Specify a Campaign Name!";} else {$campaign = test_input($_POST["campaign"]);} if (empty($_POST["startDay"])) {$startdateErr = "Please Specify a Start Date!";} else {$startdate = test_input($_POST["startDay"]);} if (empty($_POST["endDay"])) {$enddateErr = "Please Specify an End Date!";} else {$enddate = test_input($_POST["endDay"]);} } ?&gt; &lt;form action="&lt;?php echo $editFormAction; ?&gt;" method="post" name="form1" id="form1" style="font-size:12px;"&gt; &lt;table align="center" border="0" cellpadding="10" cellspacing="0" style="margin:0 auto;"&gt; &lt;tr valign="middle"&gt; &lt;td nowrap="nowrap" align="right"&gt;Station:&lt;/td&gt; &lt;td&gt; &lt;select name="station" style="font-size:12px;"&gt; &lt;option value="WBZO" selected="selected"&gt;WBZO&lt;/option&gt; &lt;option value="WHLI"&gt;WHLI&lt;/option&gt; &lt;option value="WKJY"&gt;WKJY&lt;/option&gt; &lt;option value="WALK"&gt;WALK&lt;/option&gt; &lt;option value="WWSK"&gt;WWSK&lt;/option&gt; &lt;/select&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr valign="middle"&gt; &lt;td nowrap="nowrap" align="right"&gt;Keyword:&lt;/td&gt; &lt;td&gt;&lt;span id="sprytextfield1"&gt; &lt;input type="text" name="keyword" value="" size="62" required="required" style="font-size:12px;" /&gt; &lt;span class="textfieldRequiredMsg"&gt;Please specify a keyword!&lt;/span&gt;&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign="middle"&gt; &lt;td nowrap="nowrap" align="right"&gt;URL:&lt;/td&gt; &lt;td&gt;&lt;span id="sprytextfield1"&gt; &lt;input type="text" name="url" value="" size="62" required="required" style="font-size:12px;" maxlength="2083" /&gt; &lt;span class="textfieldRequiredMsg"&gt;Please specify a URL!&lt;/span&gt;&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign="middle"&gt; &lt;td nowrap="nowrap" align="right"&gt;&lt;/td&gt; &lt;td&gt; &lt;input name="target" type="checkbox" value="blank" /&gt; Open Link in New Window? &lt;/td&gt; &lt;/tr&gt; &lt;tr valign="middle"&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt; &lt;div&gt; &lt;input type="radio" name="schedule" value="true" class="schedule" checked="checked" /&gt; No End Date Yet&lt;br /&gt;&lt;br /&gt; &lt;input type="radio" name="schedule" value="false" class="schedule" /&gt; Schedule a Start and End Date &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign="middle" id="start-schedule"&gt; &lt;td&gt;Start Date:&lt;/td&gt; &lt;td&gt; &lt;span id="sprytextfield2"&gt; &lt;input name="startDay" id="startdatepicker" style="font-size:12px;" /&gt;&lt;style&gt;.ui-datepicker-trigger{position:relative;left:3px;top:2px;}&lt;/style&gt; &amp;nbsp;&amp;nbsp;@&amp;nbsp; &lt;?php echo "&lt;select name=\"start-hour\" style='width:50px'&gt;"; $i = 1; while ( $i &lt;= 12 ) { $i = sprintf("%02d",$i); echo "&lt;option value=".$i." selected='12'&gt;".$i."&lt;/option&gt;"; $i++; } echo "&lt;/select&gt;"; echo ":&amp;nbsp;"; echo "&lt;select name=\"start-minute\" style='width:50px'&gt;"; $i = 0; while ( $i &lt;= 59 ) { $i = sprintf("%02d",$i); echo "&lt;option value=".$i."&gt;".$i."&lt;/option&gt;"; $i++; } echo "&lt;/select&gt;"; ?&gt; &amp;nbsp; &lt;select name="start-meridian" style="width:50px;font-size:12px;"&gt;&lt;option value="am" selected="selected"&gt;AM&lt;/option&gt;&lt;option value="pm"&gt;PM&lt;/option&gt;&lt;/select&gt; &lt;span class="textfieldRequiredMsg"&gt;Please specify a start date!&lt;/span&gt; &lt;span class="textfieldInvalidFormatMsg"&gt;Invalid date format. Please specify your date as mm/dd/yyyy!&lt;/span&gt; &lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign="middle" id="end-schedule"&gt; &lt;td&gt;End Date:&lt;/td&gt; &lt;td&gt; &lt;span id="sprytextfield3"&gt; &lt;input name="endDay" id="enddatepicker" style="font-size:12px;" /&gt;&lt;style&gt;.ui-datepicker-trigger{position:relative;left:3px;top:2px;}&lt;/style&gt; &amp;nbsp;&amp;nbsp;@&amp;nbsp; &lt;select name="end-hour" style="width:50px"&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;option value="3"&gt;3&lt;/option&gt; &lt;option value="4"&gt;4&lt;/option&gt; &lt;option value="5"&gt;5&lt;/option&gt; &lt;option value="6"&gt;6&lt;/option&gt; &lt;option value="7"&gt;7&lt;/option&gt; &lt;option value="8"&gt;8&lt;/option&gt; &lt;option value="9"&gt;9&lt;/option&gt; &lt;option value="10"&gt;10&lt;/option&gt; &lt;option value="11" selected="selected"&gt;11&lt;/option&gt; &lt;option value="12"&gt;12&lt;/option&gt; &lt;/select&gt; &lt;?php echo ":&amp;nbsp;"; echo "&lt;select name=\"end-minute\" style='width:50px'&gt;"; $i = 0; while ( $i &lt;= 59 ) { $i = sprintf("%02d",$i); echo "&lt;option value=".$i." selected=\"59\"&gt;".$i."&lt;/option&gt;"; $i++; } echo "&lt;/select&gt;"; ?&gt; &amp;nbsp; &lt;select name="end-meridian" style="width:50px;font-size:12px;"&gt;&lt;option value="am"&gt;AM&lt;/option&gt;&lt;option value="pm" selected="selected"&gt;PM&lt;/option&gt;&lt;/select&gt; &lt;span class="textfieldRequiredMsg"&gt;Please specify an end date!&lt;/span&gt; &lt;span class="textfieldInvalidFormatMsg"&gt;Invalid date format. Please specify your date as mm/dd/yyyy!&lt;/span&gt; &lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign="baseline"&gt; &lt;td nowrap="nowrap" align="right"&gt;&amp;nbsp;&lt;/td&gt; &lt;td align="right"&gt;&lt;input type="submit" value="Insert" style="font-size:14px;padding:3px 5px;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;input type="hidden" name="id" value="" /&gt; &lt;input type="hidden" name="MM_insert" value="form1" /&gt; &lt;/form&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p align="center"&gt;&lt;b&gt;&lt;a href="javascript: history.go(-1)"&gt;&amp;crarr; Cancel&lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;script&gt; $(document).ready(function(){ $("#start-schedule").css("display","none"); $(".schedule").click(function(){ if ($('input[name=schedule]:checked').val() == "false" ) { $("#start-schedule").slideDown("fast"); //Slide Down Effect } else { $("#start-schedule").slideUp("fast"); //Slide Up Effect } }); $("#end-schedule").css("display","none"); $(".schedule").click(function(){ if ($('input[name=schedule]:checked').val() == "false" ) { $("#end-schedule").slideDown("fast"); //Slide Down Effect } else { $("#end-schedule").slideUp("fast"); //Slide Up Effect } }); }); &lt;/script&gt; &lt;script type="text/javascript"&gt; &lt;!-- var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "date", {format:"mm/dd/yyyy", validateOn:["blur"]}); var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "date", {format:"mm/dd/yyyy", validateOn:["blur"]}); //--&gt; &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; &lt;?php mysql_free_result($Recordset1); ?&gt; </code></pre>
5,088,870
0
xml parsing error <p>I am writing a ocs IM client for android and now I am trying to delete a contact from contact list with the </p> <pre><code>&lt;deleteContact rid="100"&gt;&lt;/deleteContact&gt; &lt;uri&gt;sip:[email protected]&lt;/uri&gt; &lt;/deleteContact&gt; </code></pre> <p>command request to the cwa server... the command is from <a href="http://msdn.microsoft.com/en-us/library/bb969527%28v=office.12%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/bb969527%28v=office.12%29.aspx</a>.</p> <p>When I send the request to the ocs server I get the following error:</p> <pre><code>Error in XML document (5, 3): deleteContact was not expected </code></pre> <p>Does somebody know what could be the problem? Or at least tell me please how can I read that error: document (5, 3) ... </p> <p>My original code:</p> <pre><code>&lt;cwaRequests sid="5" xmlns="http://schemas.microsoft.com/2006/09/rtc/cwa"&gt; &lt;deleteContact rid="2"&gt; &lt;uri&gt; sip:[email protected] &lt;/uri&gt; &lt;/deleteContact&gt; &lt;/cwaRequests&gt; </code></pre> <p>Thank you very much!</p>
26,206,286
0
Regular expression to match wordpress like shortcodes, for both self closing and enclosed <p>I am trying to get a regular expression pattern to implement a shortcode feature in Joomla CMS, using plugins, similar to WordPress.</p> <p>The shortcode may be a self closing one like <code>{myshortcode shortcode="codeone"}</code> at some occassions and may be an enclosed ones like:</p> <pre><code>{myshortcode shortcode="anothercode"|param="test"} {column}column 1{/column} {/myshortcode} </code></pre> <p>I managed to figure out the regular expression used in WordPress:</p> <pre><code>{(}?)(myshortcode)(?![\w-])([^}\/]*(?:\/(?!})[^}\/]*)*?)(?:(\/)}|}(?:([^{]*+(?:{(?!\/\2})[^{]*+)*+){\/\2})?)(}?) </code></pre> <p>This is working fine if the content contains one or more self closing shortcodes, or one or more of the enclosed shortcodes. But if the content contains a mixture of both, it won't work. </p> <p>Instead of using the square brackets <code>[]</code>, I am using the curly braces <code>{}</code>, as this is how content plugins are used in Joomla.</p> <p>Now please check the below HTML snippet:</p> <pre><code>&lt;div id="lipsum"&gt; &lt;p&gt; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pellentesque lectus tellus, ut tincidunt orci posuere non. Aliquam erat volutpat. Phasellus in lobortis dolor, porta varius nunc. Ut et felis rutrum, pharetra mi a, ullamcorper purus. In vitae fringilla velit. In nec scelerisque mauris, sed eleifend urna. Duis feugiat risus et arcu eleifend venenatis. &lt;/p&gt; &lt;h3&gt;Shortcode 1&lt;/h3&gt; &lt;p&gt;{myshortcode shortcode="codeone"}&lt;/p&gt; &lt;h3&gt;Shortcode 2 - &lt;/h3&gt; &lt;p&gt;{myshortcode shortcode="anotherone"|param="test"} {column}column 1{/column} {/myshortcode} &lt;/p&gt; &lt;p&gt; Duis quis nisl fringilla, porttitor tellus a, congue mauris. Sed posuere erat vel metus egestas, eget lobortis dolor pretium. Proin iaculis pharetra consectetur. Sed in enim ultricies, sagittis nisl vitae, porttitor libero. Praesent ut erat nisi. Maecenas luctus magna lacus. Mauris ullamcorper maximus arcu et tincidunt. Aenean cursus enim blandit, scelerisque ex sed, vestibulum felis. In magna massa, sagittis in eleifend vel, tristique vitae nisi. &lt;/p&gt; &lt;/div&gt; </code></pre> <p>Here the HTML contains both self enclosing and enclosing shortcodes. In this case the above regular expression pattern is not working, as it matches the two shortcodes as one, starting from <code>{myshortcode shortcode="codeone"}</code> to <code>{/myshortcode}</code> as a single shortcode.</p> <p><strong>So my question is is there a pattern I can use to match both the shortcodes?</strong></p> <p>Please check the current state of it here <a href="http://regex101.com/r/tF0mA9/1" rel="nofollow">http://regex101.com/r/tF0mA9/1</a>. Here I am expecting two matches.</p> <p>Thank you for your help.</p>
27,802,997
0
<pre><code>#graph_bg{ position:relative; width:350px; height:300px; background-color:yellow; overflow:hidden; } #graph_bar{ position: absolute; top: 350px; left: 50px; height:300px; width:50px; background-color:blue; } #pop{ position: absolute; top:50px; left: 50px; width:50px; height:50px; background-color:red; display: none; } &lt;div id="graph_bg"&gt; &lt;div id="graph_bar"&gt;&lt;/div&gt; &lt;div id="pop"&gt;&lt;/div&gt; &lt;/div&gt; $("#graph_bar").animate({"top":"50px"} ,2000 ,function(){ $("#pop").show(); } ); </code></pre> <p><a href="http://jsfiddle.net/zacwolf/cgsdcwp3/1/" rel="nofollow">http://jsfiddle.net/zacwolf/cgsdcwp3/1/</a></p> <p>Since I didn't have your images I used background-colors instead, but you could just change those to background-image to use your images. The thing you were missing is that the background container needs to be the parent to the other two elements, then you can use "overflow-hidden" in the background container, and set the initial absolute position of the bar so that it is outside the visible limits of the background container. Then you just animate it to the "top" position where you want it to be. Also, you forget the # in your show()</p>
20,354,188
0
<pre><code>f1 = 1 ; N = 1024 ; fs = 200 ; ts = 1/fs ; t = -(N/(2*fs)):ts:(N/(2*fs) ; y = sin(2*pi*f1*t) ; plot(t,y) </code></pre> <p>You do not need to use i for getting 1024 samples out. this can be done by choosing correct start and stop values for t.</p>
14,991,286
0
Set the background in canvas using layer (zIndex) <p>I need to get a background on canvas using layers. Variable for it's background. I know I should use CSS and set the z-index, but do not know how to do it in this case.</p> <p>JS:</p> <pre><code>function doFirst(){ var x = document.getElementById('canvas'); canvas = x.getContext('2d'); var item1 = new Image(); item1.src = "images/sheep.png"; item1.addEventListener("load", function() { canvas.drawImage(item1,20,300)}, false); var item2 = new Image(); item2.src = "images/tshirt.png"; item2.addEventListener("load", function() { canvas.drawImage(item2,300,300)}, false); var background = new Image(); background.src = "images/background.png"; background.addEventListener("load", function() { canvas.drawImage(background,0,0,1024,768)}, false); } </code></pre> <p>HTML:</p> <pre><code>&lt;canvas id="canvas" width="1024" height="768"&gt; </code></pre>
12,834,155
0
<p>you may also add Method to Button for onClick in xml and use the same method in activity.As,</p> <pre><code>private void blabla(view v){ if(v= ui_titlebar_back_btn){ //do something } else if(v==blabla){ //do something } } </code></pre>
29,196,683
0
<p>Try it with <code>filename</code>:</p> <pre><code>send_data @clients.pluck(:email).join('; '), filename: file_name </code></pre>
36,973,977
0
<p>Try commenting out the following line of code in your AppDelegate.swift file - </p> <pre><code>PFUser.enableAutomaticUser() </code></pre> <p>enableAutomaticUser() will log in an anonymous user once you call PFUser.logOut(), and the username for an anonymous user is nil.</p>
11,930,477
0
<pre><code>with open("f1") as f1,open("f2") as f2: if f1.read().strip() in f2.read(): print 'found' </code></pre> <p>Edit: As python 2.6 doesn't support multiple context managers on single line:</p> <pre><code>with open("f1") as f1: with open("f2") as f2: if f1.read().strip() in f2.read(): print 'found' </code></pre>