pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
3,036,057 | 0 | <p>I wouldn't use XML-RPC. There's no need. Send either HTTP query parameters (GET or POST) to the server or possibly a JSON object and get JSON or HTML in response. PHP has methods for encoding and decoding JSON: <code>json_encode()</code> and <code>json_decode()</code>.</p> |
2,379,818 | 0 | Does XNA have a Polygon, like Rectangle? <p>I'm making a game where there is only a certain space the player can move around. I want to represent this space with a polygon of some sort. The main question I would ask of it is whether it contains a given point. (Like <code>rect.intersect()</code>)</p> <p>Does XNA have any way to do this?</p> |
19,941,569 | 0 | Populate datagridview combobox <p>I have the following code on my windows form load:</p> <pre><code> private void Panou_Load(object sender, EventArgs e) { List<string>[] list; //list in a array with all elements from a select query list = Conexiune.Select(); dataGridView1.Rows.Clear(); for (int i = 0; i < list[0].Count; i++) { int number = dataGridView1.Rows.Add(); dataGridView1.Rows[number].Cells[0].Value = list[0][i]; dataGridView1.Rows[number].Cells[1].Value = list[1][i]; dataGridView1.Rows[number].Cells[2].Value = list[2][i]; dataGridView1.Rows[number].Cells[4].Value = list[4][i]; dataGridView1.Rows[number].Cells[5].Value = list[5][i]; dataGridView1.Rows[number].Cells[6].Value = list[6][i]; } } </code></pre> <p>On my datagridview the 4th cell is a combobox. How can I populate the combobox with the value from my select (list[3][i] variable)?</p> <p><strong>UPDATE 1:</strong></p> <pre><code> private void Panou_Load(object sender, EventArgs e) { List<string>[] list; list = Conexiune.Select(); dataGridView1.Rows.Clear(); for (int i = 0; i < list[0].Count; i++) { int number = dataGridView1.Rows.Add(); dataGridView1.Rows[number].Cells[0].Value = list[0][i]; dataGridView1.Rows[number].Cells[1].Value = list[1][i]; dataGridView1.Rows[number].Cells[2].Value = list[2][i]; (dataGridView1.Columns[3] as DataGridViewComboBoxColumn).DataSource = new List<string> { list[3][i] }; dataGridView1.Rows[number].Cells[4].Value = list[4][i]; dataGridView1.Rows[number].Cells[5].Value = list[5][i]; dataGridView1.Rows[number].Cells[6].Value = list[6][i]; } } </code></pre> <p><a href="http://i.stack.imgur.com/0WLDr.jpg" rel="nofollow">http://i.stack.imgur.com/0WLDr.jpg</a></p> <p><strong>UPDATE 2:</strong></p> <pre><code> private void Panou_Load(object sender, EventArgs e) { List<string>[] list; list = Conexiune.Select(); dataGridView1.Rows.Clear(); (dataGridView1.Columns[3] as DataGridViewComboBoxColumn).DataSource = new List<string> { "", "activ", "inactiv", "neverificat" }; for (int i = 0; i < list[0].Count; i++) { int number = dataGridView1.Rows.Add(); dataGridView1.Rows[number].Cells[0].Value = list[0][i]; dataGridView1.Rows[number].Cells[1].Value = list[1][i]; dataGridView1.Rows[number].Cells[2].Value = list[2][i]; dataGridView1.Rows[number].Cells[3].Value = list[3][i]; dataGridView1.Rows[number].Cells[4].Value = list[4][i]; dataGridView1.Rows[number].Cells[5].Value = list[5][i]; dataGridView1.Rows[number].Cells[6].Value = list[6][i]; } } </code></pre> <p><a href="http://i.stack.imgur.com/MlnER.jpg" rel="nofollow">http://i.stack.imgur.com/MlnER.jpg</a></p> |
9,363,916 | 0 | asp.net calling button click event that i created <p>I am writing a web app in asp.net. I have an aspx page that call a class (Test) that Generates a button and return the button. The class constructor get the function that the button click event should activate (userClickOnButton) and insert to the button.click += EventHandler("the name of the function (userClickOnButton)");</p> <p>the problem is that in the aspx behind code i use IsPostBack (cant take it off , need this Condition) and when i click on the button the progrem does not go to the event i created for the button, but when i take off the IsPostBack Condition the program does go to the event i created (the function userClickOnButton).</p> <p>my code is: aspx code behind</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Test test = new Test(userClickOnButton); Button button = test.AddButton(); cell.Controls.Add(button); } } private void userClickOnButton(object sender, EventArgs e) { this.ModalPopupExtenderSelectFilds.Show(); } </code></pre> <p>my class</p> <pre><code>public class Test { Action<object, EventArgs> m_ButtonClickActivateFunction; public Test(Action<object, EventArgs> func) { m_ButtonClickActivateFunction = func; } public Button AddButton() { Button button = new Button(); button.Text = "select"; button.ID = "buttonID"; button.Click += new EventHandler(m_ButtonClickActivateFunction); return button; } </code></pre> <p>need help to activate the event without taking out the IsPostBack Condition</p> <p>thanks</p> |
26,345,251 | 0 | Ionic + Auth0 hangs when emulating on iOS <p>I followed @mgonto 's <a href="http://ionicframework.com/blog/authentication-in-ionic/" rel="nofollow noreferrer">Adding Auth to your Ionic App in 5 minutes</a>. It works great in my browser but when I "ionic emulate ios" it just hangs after I try to authenticate with Facebook (see screenshot). </p> <p>Any suggestions?</p> <p><img src="https://i.stack.imgur.com/MwdT9.png" alt="Screenshot of Auth0 hanging during iOS emulation"></p> |
13,443,876 | 0 | <h2>Some General Stuff</h2> <p>You need to know, that if you have a portable heap dump (phd, <a href="http://memoryanalyzer.blogspot.co.at/2010/01/heap-dump-analysis-with-memory-analyzer.html" rel="nofollow">see types here</a>), then it does not contain actual data (primitives), so then you can make your findings only based on reference map (which types hold a reference to which other types).</p> <p>You can give a try to <a href="http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.mat.ui.help/reference/oqlsyntax.html" rel="nofollow">OQL</a>. This is an SQL like language, with which you can query your objects.</p> <p>One example:</p> <pre><code>select * from java.lang.String s where s.@retainedHeapSize>10000 </code></pre> <p>This gives back all strings, that are bigger than ~10k. You can make also some functions (like this <a href="http://stackoverflow.com/a/9469829/337621">aggregating</a> here).</p> <p>You could give a try to it.</p> <h2>As for the current problem</h2> <p>If you check the FutureTask source (here is JDK6 below):</p> <pre><code>public class FutureTask<V> implements RunnableFuture<V> { /** Synchronization control for FutureTask */ private final Sync sync; ... public FutureTask(Callable<V> callable) { if (callable == null) throw new NullPointerException(); sync = new Sync(callable); } ... public FutureTask(Runnable runnable, V result) { sync = new Sync(Executors.callable(runnable, result)); } </code></pre> <p>The actual Runnable is referred by the Sync object:</p> <pre><code> private final class Sync extends AbstractQueuedSynchronizer { private static final long serialVersionUID = -7828117401763700385L; /** State value representing that task is running */ private static final int RUNNING = 1; /** State value representing that task ran */ private static final int RAN = 2; /** State value representing that task was cancelled */ private static final int CANCELLED = 4; /** The underlying callable */ private final Callable<V> callable; /** The result to return from get() */ private V result; /** The exception to throw from get() */ private Throwable exception; /** * The thread running task. When nulled after set/cancel, this * indicates that the results are accessible. Must be * volatile, to ensure visibility upon completion. */ private volatile Thread runner; Sync(Callable<V> callable) { this.callable = callable; } </code></pre> <p>So in the GUI open the Sync object (not open in your picture), and then you can check the Runnables.</p> <p>I dont know if you can change the code or not, but in general it is better always limit the size of the queue used by an executor, since this way you can avoid leaks. Or you can use some persisted queue. If you apply a limit you can define the rejection policy like for example reject, run in caller and so on. See <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html" rel="nofollow">http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html</a> for details.</p> |
14,710,438 | 0 | <pre><code>SELECT a.* FROM tableName a INNER JOIN ( SELECT `Cut-off`, COUNT(*) totalCOunt FROM tableName GROUP BY `Cut-off` HAVING COUNT(*) > 1 ) b ON a.`Cut-off` = b.`Cut-off` </code></pre> <p>for faster performance, add an <code>INDEX</code> on column <code>Cut-off</code></p> <ul> <li><a href="http://www.sqlfiddle.com/#!2/966aa/4" rel="nofollow">SQLFiddle Demo</a></li> </ul> |
17,465,913 | 0 | <p>It's very simple.</p> <pre><code> <div data-role="header" data-position="fixed" data-tap-toggle="false"> </div> </code></pre> <p>It works for me.</p> |
11,918,321 | 0 | <p>I would advice you to generate a XML Sitemap.</p> <p>A sitemap will allows you to specify the parameters you're looking to pass to the search engine, namingly the importance (or weight) that you give to pages and the rate at which the pages (usually) are updated. </p> <p>This doesn't mean the search engines will stick to only that. It could be that you say the page updates once a year and that it gets crawled 3 times that year, or that it is set to daily, and only gets crawled once a month.</p> <p><a href="http://support.google.com/webmasters/bin/answer.py?hl=en&answer=156184" rel="nofollow">Google on SiteMaps</a></p> |
39,953,048 | 0 | <p>If you prefer XPath over Groovy scripting, you can still use a simple XPath expression:</p> <pre><code>declare namespace b="base"; starts-with(//b:policies/b:policy/b:total-premium, '7.362') or starts-with(//b:policies/b:policy/b:total-premium, '6.994') or starts-with(//b:policies/b:policy/b:total-premium, '7.730') </code></pre> <p>The expected result is then <em>true</em>.</p> <p>With XPath you can use functions and operators as in other programming languages.</p> |
13,509,500 | 0 | <p>Create a ten-branch index tree, record the number of children of each node. Then browse the tree, stop at the node whose child number is ten.</p> |
25,258,930 | 0 | Cross-compiling ncurses 5.9 for ARM - form lib not found <p>I'm trying to cross-compile ncurses 5.9 for ARM for the purpose of porting GNU nano editor to this architecture. I've built my toolchain using crosstool-ng and the build finished without any problems. When trying to make GNU nano I've received some error messages concerning missing ncurses libs in my toolchain, what indeed is true. I've downloaded ncurses 5.9 and configured is as follows:</p> <p><code>./configure arm-linux --target=arm-linux --with-shared --prefix=/opt/x-tools/arm-unknown-linux-gnueabi</code></p> <p>Then I've tried to make ncurses 5.9 with following command:</p> <p><code>make HOSTCC=gcc CXX=arm-unknown-linux-gnueabi-c++</code></p> <p>And this part resulted in error:</p> <p><code>/opt/x-tools/arm-unknown-linux-gnueabi/bin/../lib/gcc/arm-unknown-linux-gnueabi/4.3.2/../../../../arm-unknown-linux-gnueabi/bin/ld: cannot find -lform collect2: ld returned 1 exit status</code></p> <p>From the error I assume I'm missing a library or a header "form.h" or "form.o". Could you point me to package containing this missing lib?</p> <p>Host OS is Debian 7.6 i386.</p> |
25,303,606 | 0 | Editing Class permission schema not working (REST) <p>By following the instructions given in <a href="http://quickblox.com/developers/Custom_Objects#Permissions" rel="nofollow">http://quickblox.com/developers/Custom_Objects#Permissions</a> every new record created (using REST interface) seems to get the ORIGNAL Class permission values instead of the edited ones.</p> <p>In addition to this, the "use class permission" check box makes no difference on those problematic records. If a single record is created or edited using the web admin panel, then the permissions are working on the client app also.</p> <p>Thanks Janne</p> |
4,343,680 | 0 | <p>You might want to look into the <code>strchr</code> function which searches a string for a given character:</p> <pre><code>include <string.h> char *strchr (const char *s, int c); </code></pre> <blockquote> <p>The strchr function locates the first occurrence of c (converted to a char) in the string pointed to by s. The terminating null character is considered to be part of the string.</p> <p>The strchr function returns a pointer to the located character, or a null pointer if the character does not occur in the string.</p> </blockquote> <p>Something like:</p> <pre><code>if (strchr (",.();:-\"&?%$![]{}_<>/#*_+=", curChar) != NULL) ... </code></pre> <p>You'll have to declare <code>curChar</code> as a <code>char</code> rather than a <code>string</code> and use:</p> <pre><code>curChar = paragraph[subscript]; </code></pre> <p>rather than:</p> <pre><code>curChar = paragraph.substr(subscript, 1); </code></pre> <p>but they're relatively minor changes and, since your stated goal was <code>I want to change the if statement into [something] more meaningful and simple</code>, I think you'll find that's a very good way to achieve it.</p> |
7,577,150 | 0 | <p>Try something like this:</p> <pre><code>$('ul li').click(function() { var elem=$(this).text(); $("select option[value='"+elem+"']").attr('selected', 'selected'); }); </code></pre> |
31,273,155 | 0 | Android Dash Lines Not Showing <p>Just note, I did reference the creating a dash line issues here on SO and with various searches via Google... Anyway, the issue is just that. I am not able to draw dash lines via xml (Can with DashPathEffect but don't want to keep doing this). Here is the dash drawable I use (dash_line.xml):</p> <pre><code><?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:color="@color/whiteColor" android:dashWidth="10dp" android:width="10dp" android:dashGap="4dp"/> </shape> </code></pre> <p>Now, then the implementation in xml for the imageview:</p> <pre><code><ImageView android:id="@+id/dash_test" android:layout_width="200dp" android:layout_height="10dp" android:background="@drawable/dash_line"/> </code></pre> <p>I am working with Android API 18. I even disable Hardware Acceleration in the manifest and even on the view itself by setting the layer type (both tried in xml and programmatically). I verified by taking the view, dashView.isHardwareAccelerated() and it is false. Any thoughts as to what I am missing?</p> <p>Edit: I can draw solid lines by the way so I know its not a layering issue. </p> <p>Edit: One work around is to use PathDashEffect. Although then you get into the issue of not being able to draw on top of images (which I would need to do). So... still would like an xml solution.</p> |
7,902,405 | 0 | ASP.NET AJAX Gauges with Asynchronous Update and animation <p>I´m currently working on a dashboard styled project, where i need to have gauges to display current values. </p> <p>can someone point me to some commercial or open source asp.net ajax controls that include gauges with these capabilities?</p> <p>Thanks in advance!</p> |
32,147,525 | 0 | How to create buttons like keyboard keys in android? <p>This question seems trivial. I want to create a button like keyboard keys for my app. When I click on it, a popup window appears above that button showing the letter pressed. Everything works great till now except one thing. When I add onFocusChangedListener to the button, nothing happens. I need to let my button act as a keyboard key, but I don't know how.</p> <p><a href="https://i.stack.imgur.com/Zq2Ny.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zq2Ny.png" alt="Keyboard Button Example"></a></p> <p>As you can see here, when a button is focused, a popup window appears. I want to do that, but <code>onFocusChangeListener</code> doesn't work. I know I can use a <code>KeyboardView</code> to achieve that, but I don't want to use that due to some other issues like centering buttons and setting keys' height with layout_weight. So I need to make it with normal buttons.</p> <h1>What I tried:</h1> <p><strong>My First Try:</strong></p> <pre><code>button.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { popupWindow.showAtLocation(keyboardPopup, Gravity.NO_GRAVITY, location.left - 10, location.top - button.getHeight()); } else { popupWindow.dismiss(); } } }); </code></pre> <p><strong><em>Result:</em></strong> Nothing happened. The popup window didn't appear at all.</p> <p><strong><em>Edit:</em></strong> After I have added <code>button.setFocusableInTouchMode(true);</code> as Ashley suggested, onFocusChanged is now getting called, but it acts so weird. The popup is <strong>sometimes</strong> shown, but at the same time when it is shown, it never disappears...</p> <p><strong>My Second Try:</strong></p> <pre><code>button.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: popupWindow.showAtLocation(keyboardPopup, Gravity.NO_GRAVITY, location.left - 10, location.top - button.getHeight()); break; case MotionEvent.ACTION_UP: popupWindow.dismiss(); break; } return true; } }); </code></pre> <p><strong><em>Result:</em></strong> This one acted so weird. Sometimes the popup shows and sometimes not, but when it is shown, the button didn't also change its state. It should have been focused, but nothing happened to the button, it acts as if it was in a normal state (Button's background doesn't change with state_focused declared in my drawable xml). It seems that onTouchListener overrides the button's functionality.</p> <p><strong>Here is a part of my layout:</strong></p> <pre><code><LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="3"> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1"> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="Q" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="W" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="E" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="R" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="T" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="Y" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="U" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="I" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="O" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="P" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> </LinearLayout> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1"> <View android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="0.5" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="A" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="S" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="D" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="F" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="G" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="H" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="J" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="K" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="L" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <View android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="0.5" /> </LinearLayout> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1"> <View android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1.5" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="Z" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="X" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="C" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="V" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="B" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="N" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <Button android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="M" android:background="@drawable/keyboard_button" android:textColor="#FFFFFF" android:onClick="onKeyboardClick" /> <View android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1.5" /> </LinearLayout> </LinearLayout> </code></pre> <p><strong>In code:</strong></p> <pre><code>public void onKeyboardClick(View view) { //The view pressed is a button. final Button button = (Button) view; //Create a PopupWindow. LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); final View keyboardPopup = inflater.inflate(R.layout.keyboard_popup, null); final PopupWindow popupWindow = new PopupWindow(keyboardPopup, view.getWidth() + 20, view.getHeight()); TextView keyboardKey = (TextView) keyboardPopup.findViewById(R.id.keyboard_key); keyboardKey.setText(button.getText().toString()); //Get button location to show the popup above it. int[] keyLocation = new int[2]; button.getLocationOnScreen(keyLocation); final Rect location = new Rect(); location.left = keyLocation[0]; location.top = keyLocation[1]; location.right = location.left + button.getWidth(); location.bottom = location.top + button.getHeight(); //This is a temporary solution. I don't want to use that. button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Show popup. popupWindow.showAtLocation(keyboardPopup, Gravity.NO_GRAVITY, location.left - 10, location.top - button.getHeight()); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { //Dismiss popup. popupWindow.dismiss(); } }, 200); } }); } </code></pre> <p>Any help will be greatly appreciated. Thanks.</p> |
31,657,146 | 0 | <p>Another example in JDK - <code>java.lang.Throwable</code></p> <pre><code>private Throwable cause = this; </code></pre> <p>The <code>cause</code> field can be in 3 states - unset; set to null; set to another Throwable. </p> <p>The implementer uses <code>this</code> to represent the <em>unset</em> state.</p> <p>A more readable strategy is probably to define a sentinel value for <em>unset</em></p> <pre><code>static Throwable UNSET = new Throwable(); private Throwable cause = UNSET; </code></pre> <p>of course, there's a recursive dependency - <code>UNSET.cause=?</code> - which is another fun topic.</p> |
32,261,766 | 0 | <p>You can access a string resource through <code>R.string.mystring</code> or <code>@string/mystring</code>. It is not required that string must be in the file <code>strings.xml</code>. It can be in another file, e.g. <code>mystrings.xml</code>. However, the only requirement is that the file <code>mystrings.xml</code> must be in the directory <code>res/values/</code>.</p> <p><strong>Besides</strong>, you cannot have two string resources with the same name, and it doesn't matter whether they are in different XML files. If you try that in Android Studio, you will get the following error: <code>Error:Execution failed for task ':app:mergeDebugResources'.</code></p> |
3,342,710 | 0 | <p>one of the easier ways is to harden your <code>php.ini</code> config, specifically the <a href="http://www.kavoir.com/2009/06/php-open_basedir-in-phpini-to-limit-php-file-accesses-to-a-certain-directory.html" rel="nofollow noreferrer">open_basedir directive</a>. Keep in mind, some CMS systems do actually use <code>..\</code> quite a bit in the code, and when there are includes outside the root folder this can create problems. (i.e. pear modules)</p> <p>Another method is to use <a href="http://www.ice2o.com/secure_php.php" rel="nofollow noreferrer">mod_rewrite</a>.</p> <p>Unless you are using an include file to check each and every URL for injection from <code>$_GET</code> and <code>$_SERVER['request_uri']</code> variables, you will open doors for this kind of attack. for example, you might protect <code>index.php</code> but not <code>submit.php</code>. This is why hardening <code>php.ini</code> and <code>.htaccess</code> is the preferred method. </p> |
12,372,294 | 0 | How do I find out what makes a browser keep loading? <p>I am using Opera and sometimes a page keeps on loading even though all content has already been presented. How do I find out which elements are to be loaded or what causes the ongoing loading process?</p> |
34,854,760 | 0 | Issue with EdgeNGramFilterFactory filter class and multiple diactric character in a word <p>I have indexed BLÅBÆRSOMMEREN into Solr and I have added EdgeNGramFilterFactory filter class like this: </p> <pre><code><fieldType name="nGramtext" class="solr.TextField" positionIncrementGap="100"> <analyzer type="index"> <charFilter class="solr.HTMLStripCharFilterFactory"/> <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/> <tokenizer class="solr.StandardTokenizerFactory"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" /> <filter class="solr.LowerCaseFilterFactory"/> <filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="15" /> <filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="15" /> <filter class="solr.PorterStemFilterFactory"/> </analyzer> </code></pre> <p>Now, if I search with whole word: <strong>BLÅBÆRSOMMEREN</strong> it gives me result, but if I search with <strong>BLÅB or BLÅBÆRSOMM</strong> it does not give me result. Note I have perform edismax query on this field</p> <p>As per the documentation <a href="http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.EdgeNGramFilterFactory" rel="nofollow">here</a> I guess, it should work with all these words but it does not.</p> <blockquote> <p>I have integrated Solr for an eCommerce Site. Initially I have configure that word in Name field and it won't work. Then I have configured that word in Short Description field only(Removed from Name).</p> </blockquote> <p>After this I have performed query and it works. Note: both fields have same field type.</p> <pre><code> <field name="Name" type="text" indexed="true" stored="true" required="false" /> <field name="ShortDescription" type="text" indexed="true" stored="true" required="false" /> </code></pre> <p>Moreover, there are copyfield like: </p> <pre><code><copyfield source="Name" dest="nGramContent"/> <copyField source="ShortDescription" dest="nGramContent"/> </code></pre> <p>What I did wrong here? Please help! How can I achieve this?</p> |
35,323,132 | 0 | <p>Here's how I do it: I create an orphan web page with a weird link (for example: <code>booboo123_99999.yoursite.com/setitweird444444444.php</code>), so nobody will know the link but you. You might also deactivate showing the source code from the app browser.</p> |
38,635,217 | 0 | <p>change SEO url to no from System>setting>server</p> |
15,423,460 | 0 | <p>You are not calling this method anywhere in your class</p> <pre><code> public void addToArray() </code></pre> <p>That is why the values which you enter are not stored</p> |
14,236,753 | 0 | <p>Depending on the number of conditional inputs, you might be able to use a look-up table, or even a <code>HashMap</code>, by encoding all inputs or even some relatively simple complex conditions in a single value:</p> <pre><code>int key = 0; key |= a?(1):0; key |= b?(1<<1):0; key |= (c.size() > 1)?(1<<2):0; ... String result = table[key]; // Or result = map.get(key); </code></pre> <p>This paradigm has the added advantage of constant time (<code>O(1)</code>) complexity, which may be important in some occasions. Depending on the complexity of the conditions, you might even have fewer branches in the code-path on average, as opposed to full-blown <code>if-then-else</code> spaghetti code, which might lead to performance improvements.</p> <p>We might be able to help you more if you added more context to your question. Where are the condition inputs coming from? What are they like?</p> <p>And the more important question: <a href="http://mywiki.wooledge.org/XyProblem" rel="nofollow">What is the actual problem that you are trying to solve?</a></p> |
40,565,252 | 0 | <p>If you were to use arccos you would need the length from one point to the other and the x distance from one point to the other.</p> <p>However with arctan you only need the x distance and the y distance.</p> <p>x and y distances are easy to work out because you just have to minus one coordinate from the other. However the distance between the 2 points is more complicated to work out. This is why it it easier to use arctan instead of arccos, however they can both be used (even arcsin and other inverse trigonometric functions).</p> |
12,851,172 | 0 | <pre><code>File f1 = new File("FILE_ONE"); File f2 = new File("FILE_TWO"); </code></pre> <p>Try removing the quotes here. You declared FILE_ONE and FILE_TWO as variables earlier in your program, but you aren't calling them. Instead, you've directly called a string "FILE_ONE," which will of course not be found. So replace it with the parameters you passed to CompareFile...</p> <pre><code>File f1 = new File(fILE_ONE2); File f2 = new File(fILE_TWO2); </code></pre> <p>And tell us if that takes care of it.</p> |
20,575,824 | 0 | <p>Add it before the button:</p> <pre><code>$('#submit').before('<input type="text" value="test" />'); </code></pre> <p><a href="http://jsfiddle.net/2GvuB/1/" rel="nofollow">http://jsfiddle.net/2GvuB/1/</a></p> |
25,322,288 | 0 | <pre><code>get_currencies() -> URL = "http://openexchangerates.org", Endpoint = "/api/latest.json?app_id=<myprivateid>", X = string:concat(URL, Endpoint), % io:format("~p~n",[X]). inets:start(), {ok, {_,_,R}} = httpc:request(X), E = jsx:decode(lists_to_binary(R)), Base = proplists:get_value(<<"base">>,E), Sec = proplists:get_value(<<"timestamp">>,E), {Days,Time} = calendar:seconds_to_daystime(Sec), Date = calendar:gregorian_days_to_date(Days+719528), Currencies = proplists:get_value(<<"rates">>,E), fun(C) -> V = proplists:get_value(C,Currencies), {change,Date,Time,Base,C,V} end. </code></pre> <p>and somewhere in your code:</p> <pre><code>GC = get_currencies(), %% you can store GC in an ets, a server state... %% but don't forget to refresh it :o) </code></pre> <p>and use it later</p> <pre><code>{change,D,T,B,C,V} = GC(<<"ZWL">>), %% should return {change,{2014,8,15},{2,0,12},<<"USD">>,<<"ZWL">>,322.355006} </code></pre> <p><strong>[edit]</strong></p> <p>When I use an external application such as jsx (using rebar itself), I use also rebar and its dependency mechanism to create my own application, in my opinion it is the most convenient way. (In other cases, I use also rebar :o)</p> <p>Then I build my application using the OTP behaviors (application, supervisor, gen_server...). It is a lot of modules to write, but some of them are very very short (application and supervisors) and they facilitate the application structure (see <a href="http://www.learnyousomeerlang.com/what-is-otp" rel="nofollow">What is OTP</a> if you are not familiar with this).</p> <p>In your case, my first idea is to have a gen server that build and store the GC anonymous function in its state, each time it get a cast message such as <code>update_currencies</code>, and provide the answer each time it get a call message such as <code>{get_change,Cur}</code> (and maybe refresh GC if it is undefined or out dated).</p> <p>You will also have to decide where the errors will be managed - <em>it may be nowhere: if the gen_server does nothing else but answer to this currency query: if something wrong appears it will crash and be restarted by its supervisor</em> - because this code has many interfaces with the out world and so subject to numerous failures (no Internet access, structure of answer change from site, bad currency request from user...)</p> |
11,710,059 | 0 | <p>In the code you posted, <code>this</code> is the global <code>window</code> object. When you create a function in the default global scope (like <code>get_denomination</code>) it gets attached as a property to the <code>window</code> object.</p> |
23,902,748 | 0 | <p>This solution should work just fine. Use <code>ave</code> to get the count of values for each <code>group</code></p> <pre><code>df[ ave(df$score,df$group, FUN=length) >=3 ,] # group score # 1 1 30 # 2 1 10 # 3 1 22 # 8 4 35 # 9 4 2 # 10 4 60 </code></pre> |
2,749,857 | 0 | <p><strong>EDIT:</strong> To make it clear, I don't recommend using this AT ALL, it will break, it's a mess, it won't help you in anyway, but it's doable for entertainment/education purposes.</p> <p>You can hack around with the <code>inspect</code> module, I don't recommend that, but you can do it... </p> <pre><code>import inspect def foo(a, f, b): frame = inspect.currentframe() frame = inspect.getouterframes(frame)[1] string = inspect.getframeinfo(frame[0]).code_context[0].strip() args = string[string.find('(') + 1:-1].split(',') names = [] for i in args: if i.find('=') != -1: names.append(i.split('=')[1].strip()) else: names.append(i) print names def main(): e = 1 c = 2 foo(e, 1000, b = c) main() </code></pre> <p>Output: </p> <pre><code>['e', '1000', 'c'] </code></pre> |
40,967,728 | 0 | React Native iOS App crashes <p>I followed the "Getting Started" to build my first React Native App.</p> <p>This is what I do:</p> <pre><code>npm install -g yarn react-native-cli react-native init AwesomeProject cd AwesomeProject react-native run-ios </code></pre> <p>However, the app crashed after building successfully.</p> <p>Then I open Xcode to run the app, but the app crashed again.</p> <p>Here is the information:</p> <pre><code>2016-12-05 13:26:26.633 [info][tid:main][RCTBatchedBridge.m:73] Initializing <RCTBatchedBridge: 0x60800019f210> (parent: <RCTBridge: 0x6080000b1460>, executor: RCTJSCExecutor) 2016-12-05 13:26:26.634 AwesomeProject[89471:10945233] *** Assertion failure in -[RCTBatchedBridge loadSource:onProgress:](), /Users/Leaf/Desktop/AwesomeProject/node_modules/react-native/React/Base/RCTBatchedBridge.m:197 2016-12-05 13:26:26.663 AwesomeProject[89471:10945233] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'bundleURL must be non-nil when not implementing loadSourceForBridge' *** First throw call stack: ( 0 CoreFoundation 0x000000010adcc34b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x0000000109cda21e objc_exception_throw + 48 2 CoreFoundation 0x000000010add0442 +[NSException raise:format:arguments:] + 98 3 Foundation 0x00000001098a6d79 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166 4 AwesomeProject 0x00000001093ef035 -[RCTBatchedBridge loadSource:onProgress:] + 997 5 AwesomeProject 0x00000001093ed1a3 -[RCTBatchedBridge start] + 883 6 AwesomeProject 0x000000010942d20c -[RCTBridge setUp] + 684 7 AwesomeProject 0x000000010942c263 -[RCTBridge initWithDelegate:bundleURL:moduleProvider:launchOptions:] + 387 8 AwesomeProject 0x000000010942c072 -[RCTBridge initWithBundleURL:moduleProvider:launchOptions:] + 146 9 AwesomeProject 0x000000010938d077 -[RCTRootView initWithBundleURL:moduleName:initialProperties:launchOptions:] + 183 10 AwesomeProject 0x0000000109376585 -[AppDelegate application:didFinishLaunchingWithOptions:] + 245 11 UIKit 0x000000010d33e0be -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 290 12 UIKit 0x000000010d33fa43 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4236 13 UIKit 0x000000010d345de9 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1731 14 UIKit 0x000000010d342f69 -[UIApplication workspaceDidEndTransaction:] + 188 15 FrontBoardServices 0x0000000110867723 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24 16 FrontBoardServices 0x000000011086759c -[FBSSerialQueue _performNext] + 189 17 FrontBoardServices 0x0000000110867925 -[FBSSerialQueue _performNextFromRunLoopSource] + 45 18 CoreFoundation 0x000000010ad71311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 19 CoreFoundation 0x000000010ad5659c __CFRunLoopDoSources0 + 556 20 CoreFoundation 0x000000010ad55a86 __CFRunLoopRun + 918 21 CoreFoundation 0x000000010ad55494 CFRunLoopRunSpecific + 420 22 UIKit 0x000000010d3417e6 -[UIApplication _run] + 434 23 UIKit 0x000000010d347964 UIApplicationMain + 159 24 AwesomeProject 0x000000010937695f main + 111 25 libdyld.dylib 0x000000010ed1e68d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb) </code></pre> <p>The content of <code>AppDelegate.m</code></p> <pre><code>/** * Copyright (c) 2015-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ #import "AppDelegate.h" #import "RCTBundleURLProvider.h" #import "RCTRootView.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSURL *jsCodeLocation; jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@"AwesomeProject" initialProperties:nil launchOptions:launchOptions]; rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; return YES; } @end </code></pre> |
21,920,300 | 0 | <p>Check this revised <a href="http://jsfiddle.net/Y3wzJ/12/" rel="nofollow">JSFiddle</a>.</p> <p>You're trying to bind the new plugin event handler before you defined the event handler. Move the event handler to the top of the script panel like so:</p> <p><strong>Script Panel:</strong></p> <pre><code>/* Define New Handler */ (function($) { $.fn.betterMouseover = function (accidentTime, funkcia) { if (accidentTime == undefined || accidentTime == null) { accidentTime = 250; } if (funkcia == undefined || funkcia == null || typeof funkcia != 'function') { funkcia = function() { console.log("no callback action specified for betterMouseover()"); }; } return this.each(function() { var jeOut; $(this).mouseenter(function() { var totok = this; jeOut = false; setTimeout(function(){ if (!jeOut) { $(totok).betterMouseoverHandler(funkcia); } }, accidentTime); }).mouseleave(function() { jeOut = true; }); }); } $.fn.betterMouseoverHandler = function (fx) { fx.call(this); } }(jQuery)); /* Bind New Handler */ $("#col1, #col2").mouseenter(function() { var color; if ($(this).attr('id') == "col1") { color = "#44a0ff"; } else { color = "red"; } $("#original").css({backgroundColor:""+color+""}); }); $("#col3, #col4").betterMouseover(500, function() { var color; if ($(this).attr('id') == "col3") { color = "#44a0ff"; } else { color = "red"; } $("#better").css({backgroundColor:""+color+""}); }); </code></pre> |
33,063,121 | 0 | <p>I didn't read your code, but I observe a strange artifact: along the horizontal edges, the detected pixels come in isolated 8-connected triples. I would suspect a flaw in the non-maximum suppression logics. (In any case, there is an anisotropy somewhere.)</p> <p>This said, edge detection on a binary image can be done by <a href="http://www.imageprocessingplace.com/downloads_V3/root_downloads/tutorials/contour_tracing_Abeer_George_Ghuneim/index.html" rel="nofollow">contour tracing</a>.</p> |
10,474,974 | 0 | <p>Try putting these in <code>.git/info/attributes</code>:</p> <pre><code># whatever gets them... yourfile binary -delta merge=binary *.yourext binary -delta merge=binary </code></pre> <p>that'll cause merge conflicts if those files change, and you'll have to figure out what to do with them. check the gitattributes and rebase doc for other merge strategies, I'm not even going to name the dangerous ones here.</p> <p>I'm not sure it's the actual merge trying to get the whole thing in core from running, but it seems worth a try.</p> |
2,083,197 | 0 | keep track of object changes in datagridview using the entity framework <p>I'm using a DataGridView to display EntityObjects from the .NET Entity Framework.</p> <p>how could I change the formatting of a row of the DataGridView if the corresponding EntityObject has been altered by the user, e.g. displaying the row in bold</p> <p>greetings</p> |
18,058,856 | 0 | <p>Neither.</p> <p>Protect your database from SQL injection <em>when making queries</em>. Where possible, do it <a href="http://stackoverflow.com/a/60496/19068">with parameterized queries</a> instead of manual escaping. </p> <p>Protect your HTML from XSS <em>when you generate your HTML</em>. i.e. apply <code>htmlspecialchars</code> to the data you get <em>out</em> of the database, not the data you put into it.</p> |
2,837,018 | 0 | <p>You can use <a href="http://php.net/manual/en/function.com-print-typeinfo.php" rel="nofollow noreferrer">com_print_typeinfo()</a> instead of var_dump(). This should work for COM, VARIANT and DOTNET objects. The output looks similar to this:</p> <pre> class IFile { /* GUID={C7C3F5A4-88A3-11D0-ABCB-00A0C90FFFC0} */ // some PHP-COM internal stuff ... /* DISPID=1610612736 */ function QueryInterface( /* VT_PTR [26] [in] --> ? [29] */ &$riid, /* VT_PTR [26] [out] --> VT_PTR [26] */ &$ppvObj ) { } /* DISPID=1610612737 */ /* VT_UI4 [19] */ function AddRef( ) { } // ... /* DISPID=1610678275 */ function Invoke( /* VT_I4 [3] [in] */ $dispidMember, /* VT_PTR [26] [in] --> ? [29] */ &$riid, /* VT_UI4 [19] [in] */ $lcid, /* VT_UI2 [18] [in] */ $wFlags, /* VT_PTR [26] [in] --> ? [29] */ &$pdispparams, /* VT_PTR [26] [out] --> VT_VARIANT [12] */ &$pvarResult, /* VT_PTR [26] [out] --> ? [29] */ &$pexcepinfo, /* VT_PTR [26] [out] --> VT_UINT [23] */ &$puArgErr ) { } // properties and methods of the COM object // ... /* DISPID=1001 */ /* VT_BSTR [8] */ /* Short name */ var $ShortName; /* DISPID=1004 */ /* VT_PTR [26] */ /* Get drive that contains file */ var $Drive; /* DISPID=1005 */ /* VT_PTR [26] */ /* Get folder that contains file */ var $ParentFolder; // ... /* DISPID=1204 */ function Move( /* VT_BSTR [8] [in] */ $Destination ) { /* Move this file */ } /* DISPID=1100 */ /* VT_PTR [26] */ function OpenAsTextStream( /* ? [29] [in] */ $IOMode, /* ? [29] [in] */ $Format ) { /* Open a file as a TextStream */ } } </pre> |
9,826,072 | 0 | <p>If you have an array named <code>array</code> and a variable <code>pn</code> holding the number of elements in <code>array</code>:</p> <pre><code>$ array=('+47177372141' '+41753459833' ) $ pn=2 $ for ((i=0;i<$pn;i++)); do echo ${array[$i]}; done +47177372141 +41753459833 </code></pre> <p>Another way to iterate over an array (be it numerically indexed or associative) is:</p> <pre><code>$ for key in "${!array[@]}"; do echo "$key: ${array[$key]}"; done 0: +47177372141 1: +41753459833 </code></pre> |
8,874,704 | 0 | <p>Here is a nice drag and drop demo using HTML5. PHP wouldn't really affect anything, as it is server side, and you're talking about client side interaction.</p> <p><a href="http://www.html5rocks.com/en/tutorials/file/dndfiles/" rel="nofollow">http://www.html5rocks.com/en/tutorials/file/dndfiles/</a></p> |
40,553,810 | 0 | <p>You're passing a zero to <code>pthread_join</code> as the thread you want to join:</p> <pre><code>pthread_join(0,NULL); </code></pre> <p>You wanted:</p> <pre><code>pthread_join(threads[0],NULL); pthread_join(threads[1],NULL); </code></pre> <p>You have several other bugs though. For one thing, your <code>checkOdd</code> code calls <code>pthread_cond_wait</code> even when it's that thread's turn.</p> <p>You don't seem to understand condition variables. Specifically, you seem to think that somehow the condition variable will know whether or not the thing you are waiting for has happened. It does not -- condition variables are stateless. It's your job to keep track of what you're waiting for and whether or not it has happened.</p> |
39,035,598 | 0 | <p>I don't remember much but I will try to put the idea (it's something which I had used a long time ago):</p> <ol> <li>Create a table value function which will take the id and phone number as input and then generate a table with id and phone numbers and return it.</li> <li>Use this function in query passing id and phone number. The query is such that for each id you get as many rows as the phone numbers. CROSS APPLY/OUTER APPLY needs to be used.</li> <li>Then you can check for the duplicates.</li> </ol> <p>The function would be something like this:</p> <pre><code>CREATE FUNCTION udf_PhoneNumbers ( @Id INT ,@Phone VARCHAR(300) ) RETURNS @PhonesTable TABLE(Id INT, Phone VARCHAR(50)) BEGIN DECLARE @CommaIndex INT DECLARE @CurrentPosition INT DECLARE @StringLength INT DECLARE @PhoneNumber VARCHAR(50) SELECT @StringLength = LEN(@Phone) SELECT @CommaIndex = -1 SELECT @CurrentPosition = 1 --index is 1 based WHILE @CommaIndex < @StringLength AND @CommaIndex <> 0 BEGIN SELECT @CommaIndex = CHARINDEX(',', @Phone, @CurrentPosition) IF @CommaIndex <> 0 SELECT @PhoneNumber = SUBSTRING(@Phone, @CurrentPosition, @CommaIndex - @CurrentPosition) ELSE SELECT @PhoneNumber = SUBSTRING(@Phone, @CurrentPosition, @StringLength - @CurrentPosition + 1) SELECT @CurrentPosition = @CommaIndex + 1 INSERT INTO @UsersTable VALUES(@Id, @PhoneNumber) END RETURN END </code></pre> <p>Then run CROSS APPLY query:</p> <pre><code>SELECT U.* ,UD.* FROM yourtable U CROSS APPLY udf_PhoneNumbers(Userid, Phone) UD </code></pre> <p>This will give you the table on which you can run query to find duplicate.</p> |
25,538,418 | 0 | <p>For one thing, you're using content1 as the outer index in the first chunck of code, so matric should be initialized with content1 on the outer as well:</p> <pre><code>matrix = [[0 for x in range(len(content2))] for x in range(len(content1))] </code></pre> <p>And yes, you can do it in one line like the other answer mentions:</p> <pre><code>matrix = [[1 if i == j else 0 for j in content2] for i in content1] </code></pre> |
8,603,188 | 0 | <p>SWI-Prolog <a href="http://www.swi-prolog.org/pldoc/doc_for?object=section%283,%273.16%27,swi%28%27/doc/packages/http.html%27%29%29" rel="nofollow">library(http/html_write)</a> library builds on DCG a DSL for page layout.</p> <p>It shows a well tought model for integrating Prolog and HTML, but doesn't attempt to cover the entire problem. The 'residual logic' on the client side remains underspecified, but this is reasonable, being oriented on practical issues 'reporting' from RDF.</p> <p>Thus the 'small detail' client interaction logic is handled in a 'black box' fashion, and such demanded to YUI components in the published application (the award winner <a href="http://e-culture.multimedian.nl/software/ClioPatria.shtml" rel="nofollow">Cliopatria</a>).</p> <p>The library it's extensible, but being very detailed, I guess for your task you should eventually reuse just the ideas behind.</p> |
26,810,978 | 0 | background-image with a left and right, the repeat-x of center image makes the right image not show up <pre><code>.news-header { background-image: url(maureske_green_left.gif), url(maureske_green_body.gif), url(maureske_green_right.gif); background-position: left, center, right; background-repeat: no-repeat, repeat-x, no-repeat; height: 31px; } </code></pre> <p>This works good but the repeat-x of <code>maureske_green_body.gif</code> makes maureske_green_right.gif to not show up.</p> <p>Setting a <code>width</code> doesnt make the right image to show neither.</p> <p>If I do <code>no-repeat</code> on the center image all images show up but of course theres a gap between all three. So how do I fix without making center image same width as webpage?</p> <p>Thanks in advance!</p> <p>Jarosław</p> |
22,168,426 | 0 | How to display the time on the right footer when inserting a card? <p>I'm using GDK <code>TimelineManager</code> to insert a static card to the timeline, and I noticed that there's no <code>just now</code> or something like that displayed on the right footer. </p> <p>What am I doing wrong? Is the time just for the Mirror API or am I missing something here?</p> |
4,392,102 | 0 | Entity Framework 4: What causes .Take(10) to return 20 records? <p>I believe I am doing the following:</p> <pre><code> var myQuery = Products.Where( p => p.deptid = 3); var myCount = Products.Count(); var myResult = myQuery.OrderBy( p => p.deptname).Skip(10).Take(10); //then return an object with a count property and a List<Product> property. </code></pre> <p>Sometimes, this returns double the take amount.</p> <p>There are a few layers to my solution, namely a Repository and a Service layer. I am pretty sure that I am not ordering, skipping, nor taking in my repository, and this is the service layer code. What could cause myResult to have more than 10 records when I take 10 records?</p> |
22,207,737 | 0 | using jquery validate plugin in asp.net controls not working <p>I am trying to use the jquery plugin <code>validate()</code> method to validate a div in my current sharepoint visual webpart. I am not sure why this is not working. it does nothing at all.</p> <p>Here is the code.</p> <pre><code> <div id="main" runat="server"> <h3>2. Select your study subject.<span class="red">*</span></h3> <asp:RadioButtonList CssClass="required" ID="rdb_study_popul" runat="server" OnSelectedIndexChanged="rdb_study_popul_SelectedIndexChanged"> <asp:ListItem>Individuals</asp:ListItem> <asp:ListItem>Population</asp:ListItem> </asp:RadioButtonList> </div> <asp:Button ID="btn_studysubject_section" runat="server" CssClass="WBSButtonhide" OnClick="btn_studysubject_section_Click" Text="Next"/> </code></pre> <p>here is the jquery </p> <pre><code> $("input[type='submit']").click(function () { if ($(this).val() != 'Back') { var names = []; var info = " "; $('#<%= main.ClientID %>').validate({ rules: { <%= rdb_study_popul.ClientID%> : { required: true } }, messages: { <%= rdb_study_popul.ClientID%> : "This field cannot be empty, please enter between" } }); } }); </code></pre> |
20,642,380 | 0 | <p>I would suggest, that you define a path in another more suitable way:</p> <pre><code> int pathDeltas[][] = { {1, 0}, {0, 1}, {-1, 0}, {0, -1}, // Up, down, left, right {1, 1}, {-1, 1}, {1, -1}, {-1, -1}, // diagonal paths }; </code></pre> <p>Then you can start from the kind position and adds deltas to x and y coordinates until you hit 1 or 8 value. Also you could calculate the knight paths like this:</p> <pre><code>int knightDeltas[][] {{1, 2}, {2, 1}, {-1, 2}, {-2, 1}, {1, -2}, {2, -1}, {-1, -2}, {-2, -1}}; </code></pre> |
11,923,556 | 0 | <p>You did not initialize <code>itr</code> before accessing <code>itr->second</code>. Indeed, you did not assign any legal value to <code>itr</code> at all.</p> |
25,720,825 | 0 | Load remote server image in UIScrollView with NSOperatoinQueue <p><br/> I want to load some "image" (In remote server) in a <code>UIScrollView</code> with <code>NSOperatoinQueue</code>. Because If I load it with normal <code>NSURL</code>, <code>NSData</code> or with <code>NSMutableURLRequest</code> it takes too much time to load for all the images. After that I show those images in <code>UIButton</code>. Here is my code:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; [self startAnimation:nil]; self.imageDownloadingQueue = [[NSOperationQueue alloc] init]; self.imageDownloadingQueue.maxConcurrentOperationCount = 4; // many servers limit how many concurrent requests they'll accept from a device, so make sure to set this accordingly self.imageCache = [[NSCache alloc] init]; [self performSelector:@selector(loadData) withObject:nil afterDelay:0.5]; } -(void) loadData { adParser = [[AdParser alloc] loadXMLByURL:getXMLURL]; adsListArray = [adParser ads]; displayArray = [[NSMutableArray alloc] init]; for (AdInfo *adInfo1 in adsListArray) { AdInfo *adInfo2 = [[AdInfo alloc] init]; [adInfo2 setBannerIconURL:adInfo1.bannerIconURL]; [adInfo2 setBannerIconLink:adInfo1.bannerIconLink]; [displayArray addObject:adInfo2]; } [self loadScrollView]; [activityIndicator stopAnimating]; } -(void) loadScrollView { [self.scrollView setScrollEnabled:YES]; [self.scrollView setContentSize:CGSizeMake([displayArray count] * ScrollerWidth, ScrollerHight)]; for (int i = 0; i < [displayArray count]; i++) { adButtonOutLet = [[UIButton alloc] initWithFrame:CGRectMake(i*320, 0, ButtonWidth, ButtonHight)]; currentAd = [displayArray objectAtIndex:i]; NSString *imageUrlString = [currentAd bannerIconURL]; UIImage *cachedImage = [self.imageCache objectForKey:imageUrlString]; if (cachedImage) { [adButtonOutLet setImage:cachedImage forState:UIControlStateNormal]; } else { [self.imageDownloadingQueue addOperationWithBlock:^ { NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrlString]]; UIImage *image = nil; image = [UIImage imageWithData:imageData]; // add the image to your cache [self.imageCache setObject:image forKey:imageUrlString]; // finally, update the user interface in the main queue [[NSOperationQueue mainQueue] addOperationWithBlock:^ { [adButtonOutLet setImage:image forState:UIControlStateNormal]; }]; }]; } adButtonOutLet.userInteractionEnabled= YES; [adButtonOutLet setTag:i]; [adButtonOutLet addTarget:self action:@selector(goToURL:) forControlEvents:UIControlEventTouchUpInside]; [self.scrollView addSubview:adButtonOutLet]; } } </code></pre> <p>Can anyone tell me what's wrong with the above code? There is no problem of parsing or retrieving data from Remote server. I check it by <code>NSLog</code>. I think the <code>NSOperationQueue</code> have some problem, which I can't manage properly. Thanks in advance. If you needed more information, I will attach here. Have a nice day.</p> |
6,590,952 | 0 | <p>As an alternative, I would suggest trying to switch to:</p> <pre><code>@Html.Action("actionMethod","controller") </code></pre> <p>This extension helper works similarly to RenderAction, but returns MvcHtmlString, instead of writing directly to the Output buffer (Response stream).</p> <p>The Html.RenderAction is a method returns void. So you must put a ";" at the end. As for the exception, you might want to try to debug into it and see what the variables are set to etc if you would like to stick with that helper method.</p> <p>Hopefully that helps.</p> |
7,856,420 | 0 | <p>You can't really ask a question about assembly code without mentioning what kind of processor assembly code you're talking about. For example, many processors have a dedicated instruction for counting number of bits set. For example, see <a href="http://en.wikipedia.org/wiki/SSE4#POPCNT_and_LZCNT" rel="nofollow">POPCNT</a> </p> |
20,502,239 | 0 | <p>I found the solution!!!! -------- NOT</p> <p>Add this line before all the code in my question above:</p> <pre><code> CrystalReportViewer1.ParameterFieldInfo.Clear(); </code></pre> <p>Then load the file name and so forth.......</p> |
30,332,584 | 0 | ListView inside fragment error <p>my fragment :</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>public class NewsFragment extends ListFragment { private ProgressDialog pDialog; // URL to get contacts JSON private static String url = "url"; // JSON Node names private static final String TAG_NEWS = "news"; private static final String TAG_ID = "id"; private static final String TAG_JUDUL = "judul"; private static final String TAG_TGL = "tanggal"; private static final String TAG_ISI = "isi"; private static final String TAG_SUMBER = "sumber"; private static final String TAG_GAMBAR = "gambar"; // contacts JSONArray JSONArray news = null; // Hashmap for ListView ArrayList<HashMap<String, String>> newsList; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View newsView = inflater.inflate(R.layout.fragment_news, container, false) ; newsList = new ArrayList<HashMap<String, String>>(); ListView lv = getListView(); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // getting values from selected ListItem String judul = ((TextView) view.findViewById(R.id.judul)) .getText().toString(); String tanggal = ((TextView) view.findViewById(R.id.tglPublish)) .getText().toString(); String sumber = ((TextView) view.findViewById(R.id.sumber)) .getText().toString(); // Starting single contact activity Intent in = new Intent(getActivity().getApplicationContext(), NewsDetailActivity.class); in.putExtra(TAG_JUDUL, judul); in.putExtra(TAG_TGL, tanggal); in.putExtra(TAG_SUMBER, sumber); startActivity(in); } }); // Calling async task to get json new GetNews().execute(); return newsView ; } /** * Async task class to get json by making HTTP call * */ private class GetNews extends AsyncTask<Void, Void, Void> { @Override protected void onPreExecute() { super.onPreExecute(); // Showing progress dialog pDialog = new ProgressDialog(getActivity()); pDialog.setMessage("Mohon tunggu..."); pDialog.setCancelable(false); pDialog.show(); } @Override protected Void doInBackground(Void... arg0) { // Creating service handler class instance ServiceHandler sh = new ServiceHandler(); // Making a request to url and getting response String jsonStr = sh.makeServiceCall(url, ServiceHandler.POST); Log.d("Response: ", "> " + jsonStr); if (jsonStr != null) { try { JSONObject jsonObj = new JSONObject(jsonStr); // Getting JSON Array node news = jsonObj.getJSONArray(""); // looping through All Contacts for (int i = 0; i < news.length(); i++) { JSONObject c = news.getJSONObject(i); String id = c.getString(TAG_ID); String judul = c.getString(TAG_JUDUL); String tgl = c.getString(TAG_TGL); String sumber = c.getString(TAG_SUMBER); // String gambar = c.getString(TAG_GENDER); // tmp hashmap for single contact HashMap<String, String> news = new HashMap<String, String>(); // adding each child node to HashMap key => value news.put(TAG_ID, id); news.put(TAG_JUDUL, judul); news.put(TAG_TGL, tgl); news.put(TAG_SUMBER, sumber); // adding contact to contact list newsList.add(news); } } catch (JSONException e) { e.printStackTrace(); } } else { Log.e("ServiceHandler", "Couldn't get any data from the url"); } return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); // Dismiss the progress dialog if (pDialog.isShowing()) pDialog.dismiss(); /** * Updating parsed JSON data into ListView * */ ListAdapter adapter = new SimpleAdapter( getActivity().getApplicationContext(), newsList, R.layout.list_item, new String[] { TAG_JUDUL, TAG_TGL, TAG_SUMBER }, new int[] { R.id.judul, R.id.tglPublish, R.id.sumber }); setListAdapter(adapter); } } }</code></pre> </div> </div> </p> <p>my xml : </p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code><?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:layout_marginLeft="12dp" android:layout_marginRight="12dp"> <!-- Main ListView Always give id value as list(@android:id/list) --> <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="wrap_content"/> </LinearLayout></code></pre> </div> </div> </p> <p>list_item.xml :</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code><?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="10dp" android:paddingLeft="10dp" android:paddingRight="10dp" > <!-- Judul --> <TextView android:id="@+id/judul" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingBottom="2dip" android:paddingTop="6dip" android:textColor="#43bd00" android:textSize="16sp" android:textStyle="bold" /> <!-- Tgl Publish --> <TextView android:id="@+id/tglPublish" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingBottom="2dip" android:textColor="#acacac" /> <!-- Sumber --> <TextView android:id="@+id/sumber" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="left" android:textColor="#5d5d5d" android:textStyle="bold" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout></code></pre> </div> </div> </p> <p>and error log :</p> <pre><code>05-20 00:24:41.091 20376-20376/com.emaszda.nutrisibunda E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.IllegalStateException: Content view not yet created at android.support.v4.app.ListFragment.ensureList(ListFragment.java:328) at android.support.v4.app.ListFragment.getListView(ListFragment.java:222) at com.emaszda.nutrisibunda.NewsFragment.onCreateView(NewsFragment.java:58) at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:953) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136) at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499) at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:488) at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141) at android.support.v4.view.ViewPager.populate(ViewPager.java:1073) at android.support.v4.view.ViewPager.populate(ViewPager.java:919) at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1441) at android.view.View.measure(View.java:15891) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5035) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:15891) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5035) at android.support.v7.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:453) at android.view.View.measure(View.java:15891) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5035) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:15891) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5035) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:15891) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5035) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2208) at android.view.View.measure(View.java:15891) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1957) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1156) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1336) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1056) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5542) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749) at android.view.Choreographer.doCallbacks(Choreographer.java:562) at android.view.Choreographer.doFrame(Choreographer.java:532) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735) at android.os.Handler.handleCallback(Handler.java:730) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5162) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:756) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:572) at miui.dexspy.DexspyInstaller.main(DexspyInstaller.java:171) at dalvik.system.NativeStart.main(Native Method) </code></pre> |
4,712 | 0 | <p>The users outside the network can make <a href="http://hgbook.red-bean.com/hgbookch12.html#x16-26800012.1" rel="nofollow noreferrer">patches</a>, and/or use <a href="http://hgbook.red-bean.com/hgbookch14.html#x18-32100014.4" rel="nofollow noreferrer">email</a> to send the updates to the main repo or someone, like yourself to merge them. The other internal people can have local copies, like yourself and do merges --but if you are having these out of network patches, it might be better that one person deal with them so nobody gets confused, but that's something you'd have to consider yourself.</p> <p>Syncing the other way, you'd create a patch, and them email or get a flash drive to the remote developers to patch their system. You're going to need some good communication in the team man, I am thankful I'm not in your shoes.</p> <p>Those are my only suggestions --well, the obvious, get them a VPN connection! I'd love to hear how it goes, what plans stabilize into a weekly groove, et cetera. </p> |
16,190,045 | 0 | <p>You are not using the proper syntax for <a href="http://dev.mysql.com/doc/refman/5.5/en/if.html" rel="nofollow">IF</a>:</p> <pre><code>IF EXISTS ( SELECT * FROM `apples` WHERE `apples`.`color` = ? AND `apples`.`size` = ?) THEN SELECT `apples`.`applesID`; ELSE INSERT INTO `apples` (`color`, `size`) VALUES(?,?); END IF; </code></pre> |
4,446,520 | 0 | <p>Javascript evaluates logic by truethness/falseness. Values such as (<code>false</code>, "", null, <code>undefined</code>, <code>0</code>, -0) are evaluated as logic false.</p> <p>Combine this with the lazy evaluation, 'OR' operations are now evaluated from <code>left to right</code> and <strong>stops</strong> once <code>true</code> is found. Since, in your example, the truthness is not literally a boolean, the value is returned.</p> <p>In this case:</p> <pre><code>x = 0; y = 5; alert(y || x)/*returns 5*/; alert(x || y)/*also returns 5*/; </code></pre> <p>this can also be other objects.</p> <pre><code>functionThatReturnsTrue() || functionThatDoesSomething(); </code></pre> |
16,786,284 | 0 | <p>There is no direct way to convert JavaScript to flash.</p> <p>There are two things you may with to try though. You can include an <strong>IFrame</strong> inside of flash from which you can render HTML content (though this may not be recommended depending on your purpose). You can also use the <strong>ExternalInterface</strong> class to call JavaScript methods from flash.</p> |
16,621,600 | 0 | Get the result for the last Task<> ( continuation)? <p>I have this sample code : </p> <pre><code>Task<int> t1= new Task<int>(()=>1); t1.ContinueWith(r=>1+r.Result).ContinueWith(r=>1+r.Result); t1.Start(); Console.Write(t1.Result); //1 </code></pre> <p>It obviously return the <code>Result</code> from the <code>t1</code> task. ( which is 1)</p> <p>But how can I get the <code>Result</code> from the <strong>last</strong> continued task ( it should be <code>3</code> {1+1+1})</p> |
24,569,617 | 0 | jquery validation is working but no validation message <p>I am working on a website using a purchased theme from wrapbootstrap and working specifically with its CONTACT FORM.</p> <p>You can check the demo of the contact form here: <a href="http://gridelicious.com/themes/treble/demo/#page-contact" rel="nofollow">CONTACT FORM DEMO</a></p> <p>The form is using validation that shows the floating message when the input is not as expected.</p> <p>the original html code for the form is just plain as below:</p> <pre><code><form> <input type="text" class="span12" placeholder="Title" required="required"> <input type="email" class="span12" placeholder="Email" required="required"> <textarea rows="10" class="span12" required="required"></textarea> <button type="submit" class="btn btn-primary">Submit</button> </form> </code></pre> <p>then I changed the codes for my need and the validation stopped showing the messages but I am sure the validation in the background is working. I can see from the red highlight and the form is not submitted.</p> <p>here is the customized code of mine:</p> <pre><code><form> <input id="message-title" type="text" class="span12" placeholder="Name" required="required"> <input id="message-email" type="email" class="span12" placeholder="Email" required="required"> <textarea id="message-content" rows="10" class="span12" required="required"></textarea> <button type="submit" class="btn btn-primary SendMessage">Submit</button> </form> </code></pre> <p>What could be the problem that caused this?</p> <p>FYI: I am working in asp MVC 5 web site. So I am editing the HTML in razor view. I use the submit button in the form above to submit ajax request to one of my controllers.</p> <p>My SHORTCOMING: I am not good at javascript. I have been trying to find a javascript piece that controls the validation of the form, but I could not find it. If you guys check the source code of the <a href="http://gridelicious.com/themes/treble/demo/#page-contact" rel="nofollow">CONTACT FORM DEMO</a>, there is no jquery validation embedded.</p> <p>From all of the javascript documents embeded in the website, I am only suspicious for this one document. Lemme show the whole code below:</p> <pre><code>$(document).ready(function(){ /** * Global variables. */ var pageHeight = $(window).height(); var pageWidth = $(window).width(); var navigationHeight = $("#navigation").outerHeight(); /** * ON RESIZE, check again */ $(window).resize(function () { pageWidth = $(window).width(); pageHeight = $(window).height(); }); /** * ON LOAD */ /* Initialize scroll so if user droped to other part of page then home page. */ $(window).trigger('scroll'); /* Fix navigation. */ $('#navigation').fixedonlater({ speedDown: 250, speedUp: 100 }); /* Centralize elements on page. */ $('.centralized').centralized({ delay: 1500, fadeSpeed: 500 }); /* Make embeded videos responsive. */ $.fn.responsivevideos(); /* Carousel "Quote slider" initialization. */ $('#quote-slider').each(function(){ if($('.item', this).length) { $(this).carousel({ interval: 20000 }); } }); /* Scroll spy and scroll filter */ $('#main-menu').onePageNav({ currentClass: "active", changeHash: false, scrollOffset: navigationHeight - 10, scrollThreshold: 0.5, scrollSpeed: 750, filter: "", easing: "swing" }); /* * Paralax initialization. * Exclude for mobile. */ if(pageWidth > 980){ /* Dont user paralax for tablet and mobile devices. */ $('#page-welcome').parallax("0%", 0.2); $('#page-features').parallax("0%", 0.07); $('#page-twitter').parallax("0%", 0.1); } /* Emulate touch on table/mobile touchstart. */ if(typeof(window.ontouchstart) != 'undefined') { var touchElements = [".social-icons a", ".portfolio-items li", ".about-items .item"]; $.each(touchElements, function (i, val) { $(val).each(function(i, obj) { $(obj).bind('click', function(e){ if($(this).hasClass('clickInNext')){ $(this).removeClass('clickInNext'); } else { e.preventDefault(); e.stopPropagation(); $(this).mouseover(); $(this).addClass('clickInNext'); } }); }); }); } /** * BLOCK | Navigation * * Smooth scroll * Main menu links * Logo click on Welcome page */ $('#page-welcome .logo a').click(function(){ $('html, body').animate({ scrollTop: $( $.attr(this, 'href') ).offset().top - navigationHeight + 4 }, 800); /* Fix jumping of navigation. */ setTimeout(function() { $(window).trigger('scroll'); }, 900); return false; }); /** * PAGE | Welcome * * Initialize slider for welcome page H1 message. */ $('#welcome-messages ul').bxSlider({ mode: 'vertical', auto: true, minSlides: 1, responsive: true, touchEnabled: true, pager: false, controls: false, useCSS: false, pause: 10000 }); /** * PAGE | WORK * * .plugin-filter - Defines action links. * .plugin-filter-elements - Defines items with li. */ $('.plugin-filter').click(function(){ return false; }); $('.plugin-filter-elements').mixitup({ targetSelector: '.mix', filterSelector: '.plugin-filter', sortSelector: '.sort', buttonEvent: 'click', effects: ['fade','rotateY'], listEffects: null, easing: 'smooth', layoutMode: 'grid', targetDisplayGrid: 'inline-block', targetDisplayList: 'block', gridClass: '', listClass: '', transitionSpeed: 600, showOnLoad: 'all', sortOnLoad: false, multiFilter: false, filterLogic: 'or', resizeContainer: true, minHeight: 0, failClass: 'fail', perspectiveDistance: '3000', perspectiveOrigin: '50% 50%', animateGridList: true, onMixLoad: null, onMixStart: null, onMixEnd: null }); /** * PAGE | Twitter * * Pull latest tweets from user. * Configuration: /plugins/twitter/index.php */ $('#twitterfeed-slider').tweet({ modpath: 'plugins/twitter/', username: 'TheGridelicious', count: 3 }); $('#twitterfeed-slider').tweetCarousel({ interval: 7000, pause: "hover" }); }); /** * Ajax request. * Start loading. * Append loading notification. */ $( document ).ajaxSend( function() { /* Show loader. */ if($(".loading").length == 0) { $("body").append('<div class="loading"><div class="progress progress-striped active"><div class="bar"></div></div></div>'); $(".loading").slideDown(); $(".loading .progress .bar").delay(300).css("width", "100%"); } }); /** * Reinitialize Scrollspy after ajax request is completed. * Refreshing will recalculate positions of each page in document. * Time delay is added to allow ajax loaded content to expand and change height of page. */ $( document ).ajaxComplete(function() { /* Remove loading section. */ $(".loading").delay(1000).slideUp(500, function(){ $(this).remove(); }); /* Portfolio details - close. */ $(".close-portfolio span").click(function(e) { $(".portfolio-item-details").delay(500).slideUp(500, function(){ $(this).remove(); }); window.location.hash= "!"; return false; }); }); </code></pre> <p>Please have a look and tell me if the setting is somewhere in this document, even though I dont think so, according to my knowledge which could be wrong.</p> <p>Please inform me other possibilities source for this problem. thanks</p> |
29,962,938 | 0 | Check if url image exist <p>I'm trying to check if a url image exist using a if statement. However when trying to test it by wrong image url it keep returning:</p> <blockquote> <p>fatal error: unexpectedly found nil while unwrapping an Optional value.</p> </blockquote> <p>code:</p> <pre><code>var httpUrl = subJson["image_url"].stringValue let url = NSURL(string: httpUrl) let data = NSData(contentsOfURL: url!) if UIImage(data: data!) != nil { } </code></pre> |
3,669,627 | 0 | <p>Turns out that if we do not need IList semantics and can make do with ICollection the update problem can be solved by adding a reference back from Lesson to Module, such as:</p> <pre><code>public class Lesson { ... protected virtual ICollection<Module> InModules { get; set; } ... } </code></pre> <p>And to the mapping files add:</p> <pre><code><class name="Lesson" table="Lessons"> ... <set name="InModules" table="ModuleToLesson"> <key column="lessonId"/> <many-to-many column="moduleId" class="NhLists.Module, NhLists"/> </set> </class> </code></pre> <p>Then a <code>Lesson</code> deleted is also removed from the collection in <code>Module</code> automatically. This also works for lists but the list index is not properly updated and causes "holes" in the list.</p> |
27,700,559 | 0 | <p>Try this code,</p> <pre><code>private class MYWEBCLIENT extends WebViewClient { private ProgressDialog prDialog; @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); prDialog = ProgressDialog.show(activity, "", "Please wait..."); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (prDialog != null && prDialog.isShowing()) prDialog.dismiss(); } } </code></pre> <p>Load webview code,</p> <pre><code>webViewInfo.getSettings().setJavaScriptEnabled(true); webViewInfo.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); webViewInfo.setWebViewClient(new MYWEBCLIENT()); webViewInfo.loadData("YOUR_URL_OR_HTML_FILE", "text/html", "UTF-8"); </code></pre> |
25,123,067 | 0 | XAMPP How to restart the server <p>I am new to web design, and I am using XAMPP for my website to test PHP and MySQL, I noticed that when I modify the index.html (HTML, CSS), I don't see the changes immediately when I open it from the browser localhost/webdesign/index.html. I often have to wait for more than 10 minutes to see the changes in localhost.</p> <p>However, if I open it locally D:/xampp/htdocs/webdesign/index.html I can see the modification I made immediately.</p> <p>I restarted the Apache server from the XAMPP control panel and still don't see the changes that I made. Anyone know how to fix this?</p> <p>When I changes the picture files, I can see the modification I made in the source code in localhost/index.html, but the pictures are still the same, the files are not being updated.</p> <p>What can I do to speed things up?</p> |
28,668,605 | 0 | <p>If you are using some UI Terminal like SQLDeveloper or TOAD, you can achieve it using below code:</p> <pre><code>CREATE OR REPLACE INPUTPROCEDURE (LV_CHOICE IN VARCHAR2) AS BEGIN DBMS_OUTPUT.PUT_LINE('Enter Y to display Unauthorized records OR N to skip the display'); --SELECT &1 INTO lv_choice FROM DUAL; IF lv_choice <> 'Y' THEN DBMS_OUTPUT.PUT_LINE ('RECORDS WILL NOT BE DISPLAYED'); ELSE DBMS_OUTPUT.PUT_LINE ('RECORDS TO BE DISPLAYED ARE:'); END INPUTPROCEDURE; </code></pre> <p>And Invoke the above Procedure like below:</p> <pre><code>DECLARE dyn_stmt VARCHAR2(200); b BOOLEAN := TRUE; BEGIN dyn_stmt := 'BEGIN INPUTPROCEDURE(:LV_CHOICE); END;'; EXECUTE IMMEDIATE dyn_stmt USING b; END; </code></pre> |
7,501,133 | 0 | How to add stylecop check as a pre-build action to VS2010? <p>In our project we have added StyleCop task to be executed after each commit by continuous integration server. The problem is that build often breaks because someone forgets to run Stylecop before commiting code to repository.</p> <p>The solution will be to execute StyleCop before each VS2010 build. How can I do it? Maybe it is possible to execute pre-build action per whole solution?</p> |
3,779,904 | 0 | SSAS Dynamic Dimension Security based on another dimension attribute <p>In my project I have to apply security based on a dimension attribute. I think the best way to explain my scenario is with an example, if you need more info please request me and I'll love to told you if it will help me find a solution.</p> <p>I have some main dimension, the dimcustomer, dimseller, fact, data and geographic. The fact table are related with dimseller ids, the dimcustomer is related to the dimseller based on one dimseller specific attribute(CNPJ)(another dimensions that i didnt described are related the same way).</p> <p>So my goal is to apply a role security based on the dimseller CNPJ, so then when the user related with that seller trys to browse data he will be allowed to view only the data that are related to his seller CNPJ.</p> <p>Table example:</p> <pre><code>DIM Seller: DIM Customer FactTable id name cnpj id name dimseller.cnpj dimseller.id dimcustomerid measure 1 ME 1234 1 guest1 1234 1 1 50,00 2 you 5678 2 guest2 5678 2 2 100,00 </code></pre> <p>So if i login as ME i will be able to se that i have the customer guest1 with one sold product that was sold by 50 bucks.</p> <p>Got my point?</p> <p>What is the best way of doing it?</p> <p>For now I'm considering the following guide: <a href="http://varadarajbhat.wordpress.com/2010/04/28/forms-based-authenticationfba-configuration-for-performancepoint-2010-and-sharepoint-2010-using-claims-authentication/#comment-41" rel="nofollow noreferrer">Claim Authentication with dynamic dimension security</a>, but at that way I should define it attribute by attribute. </p> <p>Is there a way that i can define this security need? I can easy filter the data using sql statements, but i have no ideia how i can apply this kind of security in the ssas.</p> <p>Thank you guys anyway!</p> |
16,028,349 | 0 | <p>Your mistake is in translating 0 based to 1 based indexing. The arrays are 0 based. You're having them enter in a 1 based row. Then you want to add the 8 numbers around it. If they entered 0 based numbers and entered N, you'd want to sum [n-1], n, and n+1 for each row/column. To deal with 0 based, you want to do n-2, n-1, and n. But you're doing n-2 and n+2. You're also not calculating the middle of the rows anywhere near right.</p> <p>Best practice is not even to do the math like that. It would be to read in the row/column number, then immediately subtract 1 to make it 0 based, and deal with it as 0 based from then on.</p> |
35,182,395 | 0 | <p>If you set an element's accessibility role to an empty string, Voice Over won't detect it. I had to hide some NSImageView elements in my app because their file names were being read out and it was confusing for the VO user.</p> <p>Either</p> <p><code>[element accessibilitySetOverrideValue:@"" forAttribute:NSAccessibilityRoleAttribute];</code></p> <p>or else</p> <p><code>[[element cell] accessibilitySetOverrideValue:@"" forAttribute:NSAccessibilityRoleAttribute];</code></p> <p>should do the trick.</p> <p>I know that Apple a new method based Accessibility API but it only works for OS X 10.10 onwards and the application I'm working needs to be compatible with 10.9.</p> <p>If you can use the new API <code>[element setAccessibilityRole:@""];</code> or <code>[[element cell] setAccessibilityRole:@""];</code> should do the same thing.</p> |
24,782,847 | 0 | ng-blur on a DIV <p>I am trying to hide a <code>DIV</code> on blur (the focus has been removed from the <code>DIV</code>). I am using angular and bootstrap. So far I have tried setting "focus" on the <code>DIV</code> when it is shown and then an <code>ng-blur</code> function when the user click anywhere else on the screen. This is not working.</p> <p>Basically the problem is I cannot set focus on my "<code>#lockerBox</code>" through JS, my "<code>hideLocker</code>" function works no problem when focus is given to my <code>DIV</code> with clicking it. </p> <pre><code><div class="lock-icon" ng-click="showLocker(result); $event.stopPropagation();"></div> <div ng-show="result.displayLocker" id="lockerBox" ng-click="$event.stopPropagation();" ng-blur="hideLocker(result)" tabindex="1"> $scope.displayLocker = false; $scope.showLocker = function ( result ) { $scope.displayLocker = !$scope.displayLocker; node.displayLocker = $scope.displayLocker; function setFocus() { angular.element( document.querySelector( '#lockerBox' ) ).addClass('focus'); } $timeout(setFocus, 100); }; $scope.hideLocker = function ( node ) { $scope.displayLocker = false; node.displayLocker = $scope.displayLocker; }; </code></pre> |
23,612,773 | 0 | IE8 buttons not working when floating next to an element <p>I'm working on Windows XP with IE8, and I noticed that when I make a button float next to an element, the clickable area of the button reduces to only the area that's not inmediately next to the element. It's little difficult to explain with words, so let's use images. This is the button floating left to the "something" div. Notice where the mouse pointer is:</p> <p><img src="https://i.stack.imgur.com/KN19p.jpg" alt="enter image description here"></p> <p>Notice the yellow border of the button too. If I do click in this position, the button responds. So far, so good. But, if I move the pointer little upper, the yellow border dissapears, and if I do click, the button doesn't respond:</p> <p><img src="https://i.stack.imgur.com/srdAA.jpg" alt="enter image description here"></p> <p>In fact, if I click in the colored area, the button doesn't work at all:</p> <p><img src="https://i.stack.imgur.com/xAE6f.jpg" alt="enter image description here"></p> <p>Here is the code (it works in Firefox and Chrome):</p> <pre><code><!DOCTYPE html> <html> <head> <title>Button Test</title> </head> <body> <input value="Rollover" style="float: left; height: 40px; width: 120px;" type="button"> <div>Something</div> </body> </html> </code></pre> <p>Does anyone know about this bug? Is there any fix for it?</p> <p>Thanks in advance.</p> |
22,189,441 | 0 | Why is CodeIgniter adding an extra "where" to my delete query? <p>For some reason, CodeIgniter is adding an extra "where" clause to my delete query. It's obvious as to why the MySQL error is happening... but why is CI adding this extra clause?</p> <p>This is the error:</p> <pre><code>Unknown column '8' in 'where clause' DELETE FROM `forum_messages` WHERE `thread_id` = '8' AND `8` IS NULL </code></pre> <p>This is my code:</p> <pre><code>function delete($thread_id){ $this->db->save_queries = FALSE; $this->db->where('thread_id', $thread_id); if(!$this->db->delete('forum_messages')){ $this->error = "The messages in this thread could not be deleted because of a database error: ".$this->db->_error_message(); } else { $this->db->where('thread_id', $thread_id); if(!$this->db->delete('forum_threads')){ $this->error = "The thread could not be deleted because of a database error: ".$this->db->_error_message(); } } } </code></pre> <p>UPDATE:</p> <p>None of the answers suggested below worked. For some reason I had to switch the delete queries and delete from forum_messages before I deleted before forum_threads.</p> |
40,945,712 | 0 | <p>It all depends on what out method you choose during transformation. In following I have defined output method as <code>xml</code>, it will give you output as XML which then you can render. Alternatively try with output method as <code>html</code></p> <p>Find follwoing working XSL.</p> <pre><code><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://locomotive/bypass/docx" > <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:strip-space elements="*"/> <!-- identity transform --> <xsl:template match="node()"> <xsl:copy> <xsl:apply-templates select="node()"/> </xsl:copy> </xsl:template> <xsl:template match="/"> <h2> Student information </h2> <xsl:for-each select="student"> USN: <span style="font-style: italic;color:red"> <xsl:value-of select="USN" /> <br /> </span> Name: <span style="font-style: italic"> <xsl:value-of select="name" /> <br /> </span> college Name: <span style="font-style: italic;color:green"> <xsl:value-of select="college" /> <br /> </span> Branch: <span style="font-style: italic;color:blue"> <xsl:value-of select="branch" /> <br /> </span> Year of Joining: <span style="font-style: italic;color:yellow"> <xsl:value-of select="YOJ" /> <br /> </span> Email-id: <span style="font-style: italic;color:blue"> <xsl:value-of select="email" /> <br /> </span> </xsl:for-each> </xsl:template> </xsl:stylesheet> </code></pre> <p>Workgin demo for you : <a href="http://xsltransform.net/ejivdHb/25" rel="nofollow noreferrer">http://xsltransform.net/ejivdHb/25</a></p> <p><a href="https://i.stack.imgur.com/dh4TY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dh4TY.png" alt="enter image description here"></a></p> |
13,149,416 | 0 | jquery.min.js - Google hosted - making automatic ajax requests <p>I have jQuery added via;</p> <pre><code><script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> </code></pre> <p>And when my page loads i get this;</p> <pre><code>XMLHttpRequest cannot load http://fiddle.jshell.net/favicon.png. Origin http://demo.chrisdlangton.com is not allowed by Access-Control-Allow-Origin. </code></pre> <p>The network shows the initiator is "jquery.min.js" !!!</p> <p>Now correct me if i am wrong but does it not appear that google has its hosted jQuery library making XMLHttpRequest on behalf of thier users without consent or warning!?</p> <p>EDIT: the below was posted as a comment BEFORE i was downvoted, making the down voter just as bad for not reading everything before passing judgement; i have only a small piece of code, nothing in my css, js, html, php makes any reference to "favicon" let alone jshell or fiddle. By removing the jQuery link i no longer encounter this. Also, by using a jQuery script i had stored on my pc from an earlier date, version 1.8.2 also, i do not get this at all therefore its not in the jQuery i previously downloaded. When i save the google hosted .js and add to to my html locally i get this error. This morning when i still had the google hosted .js in my html there was no error By process of elimination its clear jQuery hosted by google caused this.</p> <p>EDIT: this has stopped happening now - i have downloaded a copy of the .js that causes it and see it happening still when i use this downloaded copy but not when linking to the hosted .js. I'll be lodging a bug report with Google, maybe they were playing a trick.. wh knows.</p> |
22,113,698 | 0 | Detecting keypress in Java v2 <p>I am sorry but my previous question <a href="http://stackoverflow.com/questions/21969954/how-to-detect-a-key-press-in-java">How to detect a key press in Java</a> has not worked. </p> <p>I have watched multiple videos and seen articles about keylisteners of such but none have worked. I do know that I must call </p> <pre><code>repaint(); </code></pre> <p>to update the coordinates so don't mark me on that. I know I have to use a keyListener to make it move. I want it so when I hold down a key, my (png) graphic will move in my chosen direction. </p> <p>Also how could I make it so it keeps moving until my finger has stopped pressing that key. And say I pressed A and D it would move diagonally. </p> <p>I don't know what is wrong with my code but here is my code(I use eclipse standard kelper 7.4). I also tried to put 2 png images on the screen at once, but it was only displaying 1? How could I stop that? Also why is my background not black?</p> <p>Here is my code:</p> <pre><code>import javax.swing.*; import java.awt.*; public class window { public static void main(String[] args) { // TODO Auto-generated method stub JFrame f = new JFrame(); f.setSize(600,600); f.setBackground(Color.BLACK); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); f.setLocationRelativeTo(null); f.setResizable(true); f.setAlwaysOnTop(true); player player = new player(); f.add(player); } </code></pre> <p>}</p> <pre><code>//I do seem to have a few errors throughout my code. this is because of the KeyListener //The player class(this one has the keylistener problem) import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.geom.*; public class player extends JPanel implements KeyListener, ActionListener{ private ImageIcon image; int x = 0; int y = 0; public boolean right = false; public boolean left = false; public player(Display f){ f.addKeyListener(new KeyAdapter(){ public void keyReleased(KeyEvent e){ if(e.getKeyCode() == KeyEvent.VK_D){ right = false; } }}); } public void paintComponent(Graphics g){ super.paintComponent(g); this.setBackground(Color.BLACK); image = new ImageIcon("neonShip.png"); image.paintIcon(this, g, x, y); if(right){ x += 1; } repaint(); } @Override public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub } @Override public void keyPressed(KeyEvent arg0) { // TODO Auto-generated method stub } @Override public void keyReleased(KeyEvent arg0) { // TODO Auto-generated method stub } @Override public void keyTyped(KeyEvent arg0) { // TODO Auto-generated method stub } } //Next is the Display class import java.awt.*; import javax.swing.*; public class Display extends JFrame{ public JPanel gp = (JPanel) getGlassPane(); public Images i; public player k; public Display(){ i = new Images(); gp.setVisible(true); k = new player(this); gp.setLayout(new GridLayout(1,1,0,0)); this.setLayout(new GridLayout(1,1,0,0)); gp.add(k); this.add(i); } } </code></pre> <p>I am so sorry about the few errors I have but I did my best with the code. What is the problem with my keyListener or stuff. Please explain how to solve this problem.</p> |
40,433,086 | 0 | <p>I think this code is correct.</p> <pre><code>var hotels1 = tb_hotel.Join(tb_room_hotel, chid => chid.HotelID, crid => crid.HotelID, (chid, crid) => new { chid, crid }) .Where(x => x.crid.tb_Language.Title == lang && x.chid.ActionState != 0) .GroupBy(t => new { HID = t.chid.HotelID }) .Select(g => new { Average = g.Average(p => p.crid.Price), HID = g.Key.HID }).OrderBy(c => c.Average).ToList(); </code></pre> |
9,062,533 | 0 | <p>In general, the paint event happen after resize events. So if you resize using either the mouse or even programmatically, then the <code>drawMaze()</code> function will be called. I think you should not create the maze in <code>drawMaze()</code>, or at least make a lazy initialization. That's because a maze will be created each time the window is painted, which occurs every time you resize the window, you move the window, you hide some part of the window, you change focus, etc... That's a lot of mazes :D.</p> <p>EDIT: The paint event suggest you that the display has changed, and that the change is likely to affect the portion of the screen you are painting on. So few things:</p> <ul> <li>During a paint event you want to do only one thing: painting. So don't call garbage collection. In general calling the Gc is not a good idea, and moreover in a Listener it will just crush the performance.</li> <li>The event will not change the state of your Maze. So you should represent your maze using a state. One part is fixed, like the walls, the other side is variable, like the agent position inside the maze. Each time you modify the state, you ask a repaint.</li> <li>If you skip a paint event, the screen will be blank. </li> </ul> <p>For example if your maze is too big to fit on the screen, you use the paint event to paint only one part, etc..</p> |
21,791,697 | 0 | <p>What you are looking for is the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.oncommand%28v=vs.110%29.aspx" rel="nofollow">Button.OnCommand Method</a>:</p> <blockquote> <p>This allows you to create multiple Button controls on a Web page and programmatically determine which Button control is clicked.</p> </blockquote> <p>So inside <code>ListOfAssignments_ItemDataBound</code> you'd assign the CommandArgument to the button, where the <code>CommandArgument</code> is the ID of the article to be deleted:</p> <pre><code>protected void ListOfAssignments_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Button delButton = e.Item.FindControl("RemoveAssignment") as Button; delButton.CommandArgument = //set to the value of AssignmentID //rest of your code } } </code></pre> <p>And now your button should say to use your new OnCommand:</p> <pre><code><asp:Button ID="RemoveAssignment" OnCommand="RemoveAssignment" runat="server" Text="Remove" /> </code></pre> <p>And then you create the method:</p> <pre><code>protected void RemoveAssignment(object sender, CommandEventArgs e) { int articleIDToDelete = 0; if (Int32.TryParse((string)e.CommandArgument, out articleIDToDelete)) { //delete the article with an ID = articleIDToDelete } } </code></pre> |
20,673,290 | 0 | Entity Framework InvalidOperationException when updating an item <p>I get an <code>System.InvalidOperationException</code> error which states:</p> <blockquote> <p>Additional information: Member 'IsModified' cannot be called for property 'state' because the entity of type 'BatteryItem' does not exist in the context. To add an entity to the context call the Add or Attach method of DbSet.</p> </blockquote> <p>Haven't I done exactly this? That is my method below:</p> <pre><code>public void UpdateBatteryState(BatteryItem batItem, BatteryState state) { try { batItem.state = state.ToString(); context.BatteryItem.Attach(batItem); var entry = context.Entry(batItem); entry.Property(x => x.state).IsModified = true; Save(); } catch (Exception e) { Console.WriteLine(e.Message); } } </code></pre> |
33,039,602 | 0 | <p>Do not reinvent the wheel. There is already a tool that creates an executable package. See the documentation of Oracle: <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html" rel="nofollow">https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html</a> With this you can create native bundles (.exe on Windows) for different OS. From the page mentioned:</p> <pre><code>javapackager -deploy -native -outdir packages -outfile BrickBreaker -srcdir dist -srcfiles BrickBreaker.jar -appclass brickbreaker.Main -name "BrickBreaker" -title "BrickBreaker demo" </code></pre> <p>The same can also be accomplished with an Ant task which might be easier to integrate. There is also the Maven plugin <a href="https://github.com/javafx-maven-plugin/javafx-maven-plugin" rel="nofollow">javax-maven-plugin</a>.</p> |
11,432,518 | 0 | <p>I've discovered that the behaviour of a URL opening an iTunes preview web page before automatically opening the iTunes app on the host device (where available) is triggered by affiliate links (which need to track the click before taking the user to the intended destination).</p> |
13,249,757 | 0 | <p><strong>Note:</strong> I'm the <a href="http://www.eclipse.org/eclipselink/moxy.php" rel="nofollow"><strong>EclipseLink JAXB (MOXy)</strong></a> lead and a member of the <a href="http://jcp.org/en/jsr/detail?id=222" rel="nofollow"><strong>JAXB (JSR-222)</strong></a> expert group.</p> <hr> <p><strong>UPDATE</strong></p> <p>We have been able to reproduce the error you are seeing in EclipseLink 2.4.1. We have not been able to reproduce the issue in the EclipseLink 2.4.2 or 2.5.0 streams. I would recommend downloading the latest 2.4.2 nightly build and trying it out:</p> <ul> <li><a href="http://www.eclipse.org/eclipselink/downloads/nightly.php" rel="nofollow">http://www.eclipse.org/eclipselink/downloads/nightly.php</a></li> </ul> <p>We are still investigating this issue to ensure that it is truly fixed.</p> <hr> <p><strong>ORIGINAL ANSWER</strong></p> <p>So far I have been unable to reproduce the results from your question when MOXy is used as the JAXB provider. Could you provide some additional information to help me reproduce your use case. Below is what I have tried so far:</p> <p><strong>Java Model</strong></p> <p>I took the Java model from the following location on GitHub:</p> <ul> <li><a href="https://github.com/plutext/docx4j/tree/master/src/main/java" rel="nofollow">https://github.com/plutext/docx4j/tree/master/src/main/java</a></li> </ul> <p><strong>jaxb.properties</strong></p> <p>I added a file called <code>jaxb.properties</code> in the <code>org.docx4j.wml</code> package to enable MOXy as the JAXB provider.</p> <pre><code>javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory </code></pre> <p><strong>Demo</strong></p> <p>Below is the demo code I used to try and reproduce the issue:</p> <pre class="lang-java prettyprint-override"><code>package org.docx4j.wml; import javax.xml.bind.*; import org.eclipse.persistence.Version; public class Demo { public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance("org.docx4j.wml"); System.out.println(Version.getVersion()); System.out.println(jc.getClass()); Text text = new Text(); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(text, System.out); } } </code></pre> <p><strong>Output</strong></p> <p>Below is the output from running the demo code. I'm seeing the proper root element <code>t</code> marshalled out instead of <code>delInstrText</code> as described in the question.</p> <pre><code>2.4.1 class org.eclipse.persistence.jaxb.JAXBContext <?xml version="1.0" encoding="UTF-8"?> <ns0:t xmlns:ns2="http://schemas.openxmlformats.org/schemaLibrary/2006/main" xmlns:ns1="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:ns4="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:ns3="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:ns0="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:ns5="http://schemas.openxmlformats.org/officeDocument/2006/relationships"/> </code></pre> |
17,822,798 | 0 | Cubism.JS threshold scale doesn't work <p>I'm using cubism with data coming from graphite </p> <p>The data's domain is continuos [0,100] and the range is continuos [0,100] but anything below 100 is nonsense so I modified the scale and used a threshold scale so that:</p> <p>values < 100 will be 0 and 100 will be 100. I tested that with:</p> <pre><code>var scale = d3.scale.threshold().domain([100]).range([0,100]) console.log(scale(1)) //returns 0 console.log(scale(99.9)) //returns 0 console.log(scale(88.9)) //returns 0 console.log(scale(100)) //returns 100 </code></pre> <p>When I apply it, it the whole chart becomes empty</p> <pre><code>.call(context.horizon().height(100) .colors(colors) .scale(d3.scale.threshold().domain([100]).range([0,100])) // range([0,1]) doesn't work either ); </code></pre> <p><img src="https://i.stack.imgur.com/fVpCV.png" alt="enter image description here"></p> <p>without applying the scale (notice the small white area)</p> <pre><code> .call(context.horizon().height(100) .colors(colors) // .scale(d3.scale.threshold().domain([100]).range([0,100])) // range([0,1]) doesn't work either ); </code></pre> <p><img src="https://i.stack.imgur.com/94Wtr.png" alt="enter image description here"></p> |
11,258,573 | 0 | <p>I guess you could break it down</p> <pre><code>var row = cell.Row; var cell = wksheet.Cells(row, "J"); var value = cell.Value; </code></pre> |
35,494,056 | 0 | html-agility-pack how can i make import url's local using selectnodes? <p>I am using html-agility-pack to change all the website url's to local url's. I've already changed several url's with SelectNodes. However I have no idea how to use import url's with selectnodes. </p> <p>I want to change this:</p> <pre><code><style type="text/css" media="all"> @import url("http://link.nl/test.css"); @import url("http://link2.nl/test2.css"); @import url("http://link3.nl/test3.css"); @import url("http://link4.nl/test4.css"); </style> </code></pre> <p>to this:</p> <pre><code><style type="text/css" media="all"> @import url("c:/user/admin/documents/copy1.css"); @import url("c:/user/admin/documents/copy2.css"); @import url("c:/user/admin/documents/copy3.css"); @import url("c:/user/admin/documents/copy4.css"); </style> </code></pre> <p>Does anyone know how I can change this to a local path file with html-agility-pack?</p> |
4,405,802 | 0 | <p>If we were to follow the MVC architecture, and Cocoa Touch does, the model layer should be completely abstracted from view layer. In this case, giving your CData class access to an IBOutlet violates this principle - assuming that CData is a model-type class.<br /> Like you said, one way of going about it is to return something from <code>-calculateString</code>. This may seem like more code but does not limit the reusability of your model class.</p> |
4,450,577 | 0 | <p>It's important to realize that web pages will always render differently in different browsers. Acheiving pixel perfection is futile, and nowadays I try to explain to my clients what kind of cost is involved to make every browser render the site exactly alike. More often now, they understand that IE6 and FF4 won't ever render any page the same way. We must try to make our clients understand and embrace the dynamics of the web.</p> <p>Progressive enhancement and graceful degradation. Peace. </p> |
10,707,029 | 0 | <p>For the fading, you'll need to refrence <a href="http://jqueryui.com" rel="nofollow">jQuery UI</a> in your <code><head></code>:</p> <pre><code><script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.20/jquery-ui.min.js"> </script> </code></pre> <p>And then for the rest:</p> <pre><code>// Wait until the document is ready before proceeding $(function(){ // Cache a reference to the banner to jQuery doesn't have to find it again var $banner = $("#banner"); // Immediately add the 'light' class $banner.addClass("light"); // When #change is clicked, swap the classes on #banner $("#change").on("click", function(e){ // Prevent the link from changing the page e.preventDefault(); // Remove 'light', and add 'dark' $banner.addClass("dark", 1000).removeClass("light"); }); }); </code></pre> |
35,254,965 | 0 | ACTION_VIEW intent displays picture full screen with icons underneath system icons <p>I am launching a standard ACTION_VIEW intent:</p> <pre><code>Intent showThumbnail = new Intent(Intent.ACTION_VIEW); showThumbnail.setDataAndType(Uri.fromFile(pictureFile), "image/*"); v.getContext().startActivity(showThumbnail); </code></pre> <p>The picture shows up:</p> <p><a href="https://i.stack.imgur.com/UsglZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UsglZ.jpg" alt="Android image view intent overlapping icons"></a></p> <p>Note the overlapping 'back' icon at the top of the page and the 'share' and 'info' icons beneath the system icons.</p> <p>My question: Why is this happening and how do I make the image viewer top and bottom icons appear where they should (See image below).</p> <p>Note that the UIs (image and system icons) both vanish when clicking on the image. Upon clicking again the UI is correctly displayed:</p> <p><a href="https://i.stack.imgur.com/5fUZK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5fUZK.jpg" alt="Android image view with icons correctly displayed"></a></p> <p>Details: Nexus 7 (Lollypop)</p> |
9,906,007 | 0 | <p>Use the following code to convert content of file (text or csv) in String.</p> <pre><code> InputStream in; String str = ""; try { in = new URL(url).openStream(); int size = in.available(); for (int i = 0; i < size; i++) { char ch = (char) in.read(); str = str.concat(ch + ""); } in.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } </code></pre> |
8,789,496 | 0 | <p>Are you using the Timer in daemon mode? Please see this documentation which says what's a daemon thread.</p> <pre><code>/** * Creates a new timer whose associated thread may be specified to * {@linkplain Thread#setDaemon run as a daemon}. * A daemon thread is called for if the timer will be used to * schedule repeating "maintenance activities", which must be * performed as long as the application is running, but should not * prolong the lifetime of the application. * * @param isDaemon true if the associated thread should run as a daemon. */ public Timer(boolean isDaemon) { this("Timer-" + serialNumber(), isDaemon); } </code></pre> <p>If you are using a daemon thread, application will not wait for this thread to finish so any pending operation in this thread is not guaranteed to finish. However, if it's not a daemon thread, the application will shutdown only after this thread finishes its last operation.</p> <p>Coming to the closing of file handles, why don't you do that in the timer thread itself? If that cannot be done, Shudown hooks are the ideal way to do something at the application shutting down time.</p> <p>So, you can have a common lock, which can be acquired by the timer for every task execution and the same lock can be acquired by the shutdown task to close the open file handles.</p> <p>I hope that makes things clear.</p> |
18,276,755 | 0 | <p>It checks to see if the variable <code>name</code> matches the regular expression <code>/family/i</code></p> <p>The <code>i</code> makes the regex case-insensitive, so <code>FaMilY</code> would match.</p> |
40,360,429 | 0 | <p>According to <a href="https://laravel.com/docs/5.3#installing-laravel" rel="nofollow noreferrer">Laravel's Documentation</a></p> <p>Make sure to place the <code>$HOME/.composer/vendor/bin</code> directory (or the equivalent directory for your OS) in your $PATH so the laravel executable can be located by your system. In case of Windows you should ad that $PATH to your enviornment variables.</p> |
3,447,230 | 0 | Closing the NSPanel issue <p>very unusual problem i'm getting if i press the close button of panel, panel closes but when i press a custom button and calls this close function panel doesn't close. If i mark a breakpoint in close function and continue with execution then panel gets close...i'm confused. why panel doesn't close on normal execution but closes when i mark breakpoint and continue it? </p> <pre><code>NSRect panelRect = NSMakeRect(100, 100, 530, 400); RecordsListingViewController* listController = [[RecordsListingViewController alloc] initWithContentRect:panelRect styleMask:NSTitledWindowMask | NSClosableWindowMask | NSUtilityWindowMask backing:NSBackingStoreBuffered defer:YES]; NSUInteger modelInt = [[NSApplication sharedApplication] runModalForWindow:listController]; - (void)close { ///[self stop]; [[NSApplication sharedApplication] stopModal]; [super close]; } </code></pre> |
5,744,838 | 0 | <p>Even after your update, I agree with Markus. It doesn't seem you need a custom panel. What you need is an ItemsControl with UniformGrid as ItemsPanel and ViewBox as ItemsContainer. UniformGrid decides how your items container are arranged. ViewBox handles stretch and scale of each item.</p> |
16,610,815 | 0 | Weld CDI : Using @Alternative @Singleton <p>I have a Producers class annotated with <code>@Singleton</code>, containing a method annotated with <code>@Produces</code>.</p> <p>I want to write unit test using an alternative of this method, but can't manage to do it. here's a summary of my code :</p> <pre><code>package fr.easycompany.easywrite.tools.injection; @Singleton public class Producers { @Produces @Named(PREFERENCES_FILE_NAMED) public String producePreferenceFileName(){ return "preferences.xml"; } } </code></pre> <p>And my Alternative :</p> <pre><code>package fr.easycompany.easywrite.tools.injection; @Singleton @Alternative public class ProducersAlternative { @Produces @Named(PREFERENCES_FILE_NAMED) public String producePreferenceFileName(){ return "preferences_test.xml"; } } </code></pre> <p>I also created a beans.xml in src/test/resources/META-INF with the following content</p> <pre><code><?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:weld="http://jboss.org/schema/weld/beans" xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd"> <alternatives> <class>fr.easycompany.easywrite.tools.injection.ProducersAlternative</class> </alternatives> </beans> </code></pre> <p>At the execution, it's always <code>Producers#producePreferenceFileName()</code> which is called. Why is it not <code>ProducersAlternative</code>'s method ? Is it impossible to have an alternative of a singleton injected class ?</p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.