pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
12,182,265
0
<p>I don't think your problem is the OR operator, but the <a href="http://www.regular-expressions.info/repeat.html#greedy">greediness</a> of the <code>.*</code>. It will match your full string, and then <em>back</em>-track until the following expressions match. The first match in this backtracking process will be <code>'He said, "You're cool."' , 'Rawr</code>+<code>')</code>. Try <code>.*?</code> instead!</p>
40,964,811
0
<p>Firstly, I agree with the previous answer that you should be using the strict equality operator. Secondly, you are using incorrect syntax - where you have data-bind should be ko, i.e.:</p> <pre><code>&lt;!-- ko if: header.current_collection.url_type === 'stories' --&gt; &lt;p&gt;text&lt;/p&gt; &lt;!-- /ko --&gt; </code></pre> <p>You can find the <a href="http://knockoutjs.com/documentation/if-binding.html" rel="nofollow noreferrer">knockout if binding docs here</a></p>
24,800,034
0
<p>A very "dirty" solution would be to systematically check that the function's local environment is not changed after the "preamble". </p> <pre><code>fun &lt;- function(x) { a &lt;- x ls1 &lt;- ls() if (a&lt;0) { if (a &gt; -50) x &lt;- -1 else x &lt;- -2 } ls2 &lt;- ls() print(list(c(ls1,"ls1"),ls2)) if (!setequal(c(ls1,"ls1"), ls2)) stop("Something went terribly wrong!") return(x) } fun.typo &lt;- function(x) { a &lt;- x ls1 &lt;- ls() if (a&lt;0) { if (a &gt; -50) x &lt;- -1 else X &lt;- -2 } ls2 &lt;- ls() print(list(c(ls1,"ls1"),ls2)) if (!setequal(c(ls1,"ls1"), ls2)) stop("Something went terribly wrong!") return(x) } </code></pre> <p>With this "solution", <code>fun.typo(-60)</code> no longer silently gives a wrong answer...</p>
37,061,574
0
<p><a href="https://sourceforge.net/p/jmstoolbox/wiki/Home/" rel="nofollow">JMSToolBox</a> is perfect for dealing with JMS Messages and works very well with WebSphere MQ</p>
35,112,750
0
Appcelerator ImageView, changing image on android blinks / flickers <p>I have 20 images which I cycle through to show a fitness exercise. When updating the image (i.e going from frame 1 to frame 2) the entire imageView blinks. This only happens on Android, on iOS it works fine. </p> <p>Here is a video of it happening <a href="https://youtu.be/-CufuQErQ58" rel="nofollow">https://youtu.be/-CufuQErQ58</a> This is on emulator but its also happening on all android devices i've tested on. </p> <p>I tried changing the imageView to just a view with a backgroundImage, and this works without blinking however it runs very slowly and uses a lot more memory and often crashes.</p> <pre><code>exports.imagesWindow = function(exercise, noOfImages) { var win = new SS.ui.win('landscape'); var imgCount = 0; var header = new SS.ui.view(win, '10%', '100%'); header.top = 0; header.visible = true; header.backgroundColor = SS.ui.colors[0]; var cueText = new SS.ui.normalLabel(header, "some text", 7); cueText.color = 'white'; //var imgLeft = new SS.ui.responsiveImage({container:win, top:'10%', left:'2%', height: '75%', width: '30%', zoom: 0.3}); //var imgCenter = new SS.ui.responsiveImage({container:win, top: '10%', left: '35%', height: '75%', width: '30%', zoom: 0.3}); //var imgRight = new SS.ui.responsiveImage({container:win, top:'10%', left: '68%', height:'75%', width:'30%', zoom: 0.3}); if (noOfImages === 3) { imgLeft = new ImagePanel(win, '17%'); imgCenter = new ImagePanel(win, '50%'); imgRight = new ImagePanel(win, '83%'); } else { imgLeft = new ImagePanel(win, '30%'); imgRight = new ImagePanel(win, '70%'); } function updateImages() { cueText.text = (eval(exercise + "Cues"))[imgCount]; instructionNumber.text = (imgCount+1) + "/20"; if (noOfImages === 3) { imgLeft.image = '/images/instructionImages/' + exercise + "/" + exercise + '_front_' + imgCount + '.jpg'; imgCenter.image = '/images/instructionImages/' + exercise + "/" + exercise + '_side_' + imgCount + '.jpg'; imgRight.image = '/images/instructionImages/' + exercise + "/" + exercise + '_back_' + imgCount + '.jpg'; //SS.log("image updated: " + imgLeft.image + " " + imgCenter.image + " " + imgRight.image); } else { imgLeft.image = '/images/instructionImages/' + exercise + "/" + exercise + '_front_' + imgCount + '.jpg'; imgRight.image = '/images/instructionImages/' + exercise + "/" + exercise + '_side_' + imgCount + '.jpg'; } } //view.add(win); var homeView = new SS.ui.view(win, '12%', '30%'); homeView.center = {x: '5%', y: '92%'}; homeView.visible = true; var home = new SS.ui.dateButton(homeView, 'footer/home'); home.addEventListener('click', function(){ if (start){ clearInterval(start); }; win.close(); }); var footerView = new SS.ui.view(win, '12%', '30%'); footerView.center = {x: '50%', y: '92%'}; footerView.visible = true; var prevImg = new SS.ui.dateButton(footerView, 'footer/prevFrame'); prevImg.left = 0; //prevImg.height = Ti.UI.SIZE;prevImg.width = Ti.UI.SIZE; prevImg.addEventListener('click', goToPrev); var nextImg = new SS.ui.dateButton(footerView, 'footer/nextFrame'); //nextImg.height = Ti.UI.SIZE; nextImg.width = Ti.UI.SIZE; nextImg.addEventListener('click', goToNext); nextImg.right = 0; var stopPlayBtn = new SS.ui.dateButton(footerView, 'footer/playVideo'); //stopPlayBtn.height = Ti.UI.SIZE;stopPlayBtn.width = Ti.UI.SIZE; stopPlayBtn.addEventListener('click', stopPlay); var numberView = new SS.ui.view(win, '12%', '30%'); numberView.center = {x: '95%', y: '92%'}; numberView.visible = true; var instructionNumber = new SS.ui.normalLabel(numberView, (imgCount+1) + "/20", 5); updateImages(); var start; function stopPlay() { // start videos if (stopPlayBtn.image.indexOf('play')&gt;=0) { cueText.visible = false; start = setInterval(goToNext, 200); stopPlayBtn.image = '/images/footer/stopVideo.png';} // stop vidoes else { clearInterval(start); cueText.visible = true; stopPlayBtn.image = '/images/footer/playVideo.png'; } } function goToPrev() { if (imgCount &gt; 0) { imgCount--; } else { imgCount = 19; }; SS.log("imgCount: " + imgCount); updateImages(); } function goToNext() { if (imgCount &lt; 19) { imgCount++; } else { imgCount = 0; }; SS.log("imgCount: " + imgCount); updateImages(); } return win; }; var ImagePanel = function(viewToAdd, cX) { var imageView = Ti.UI.createImageView({ width: '30%', borderColor: 'white', center: {x: cX, y: '50%'} }); viewToAdd.add(imageView); //resize for tablets if(Ti.Platform.osname.indexOf('ipad') &gt;=0) { imageView.height = '45%'; imageView.borderWidth = 8; imageView.borderRadius = 12; } else { imageView.height = '65%'; imageView.borderWidth = 4; imageView.borderRadius = 6; } return imageView; }; </code></pre> <p>EDIT</p> <p>So after a bit more digging I found this article - <a href="http://docs.appcelerator.com/platform/latest/#!/guide/Image_Best_Practices" rel="nofollow">http://docs.appcelerator.com/platform/latest/#!/guide/Image_Best_Practices</a></p> <p>It seems on android that the image size is the limiting factor, and reducing the size of the images helped fix this, although it still blinks on the first cycle of images.</p>
30,064,502
0
<p>There error is the two dimensional array in the <code>columns</code> function is not being set correctly. The variable name is missing and in the incorrect place for each column.</p> <p>Either you can set the columns like this:</p> <pre><code>public function columns() { return array( 'Title' =&gt; array( 'title'=&gt;_t('PageListByTypeReport.PageName', 'Page name') ), 'ClassName' =&gt; array( 'title'=&gt;_t('PageListByTypeReport.ClassName', 'Page type') ) ); } </code></pre> <p>Or even simpler like this:</p> <pre><code>public function columns() { return array( 'Title' =&gt; _t('PageListByTypeReport.PageName', 'Page name'), 'ClassName' =&gt; _t('PageListByTypeReport.ClassName', 'Page type') ); } </code></pre> <p>The current <code>sourceRecords</code> function will work, although we can make this much simpler by just returning the results of <code>Page::get()</code> like this:</p> <pre><code>public function sourceRecords($params = array(), $sort = null, $limit = null) { $pages = Page::get()-&gt;sort($sort); return $pages; } </code></pre> <p>Here is a working and simplified version of the Report code: </p> <pre class="lang-php prettyprint-override"><code>class PageListByType extends SS_Report { function title() { return 'Page List by Type'; } function description() { return 'List all the pages in the site, along with their page type'; } public function sourceRecords($params = array(), $sort = null, $limit = null) { $pages = Page::get()-&gt;sort($sort); return $pages; } public function columns() { return array( 'Title' =&gt; _t('PageListByTypeReport.PageName', 'Page name'), 'ClassName' =&gt; _t('PageListByTypeReport.ClassName', 'Page type') ); } } </code></pre>
13,843,203
0
how to covert PST to IST Using javascript <p>i get PST date formate from Database and i need to convert IST formate. But my system also in IST Formate. please check this <a href="http://jsfiddle.net/sfcdD/9/" rel="nofollow">http://jsfiddle.net/sfcdD/9/</a>. </p> <pre><code> var date = "2012-12-12 05:18:28.541"; // PST date formate fetch from db var offset = (3600000*(+5.30)); // IST gmtOffset value var dateformate = 'dd/mm/yyyy "at" h:MM TT'; var dateArray = (date).split(' '); var year = dateArray[0].split('-'); var time = dateArray[1].split(':'); var d = new Date($.trim(year[0]), $.trim(year[1]-1), $.trim(year[2]), $.trim(time[0]), $.trim(time[1])); utc = d.getTime() +(d.getTimezoneOffset()*60000); //d.getTimezoneOffset() is taking local timezone nd = new Date(utc + parseInt(offset)); alert(dateFormat(nd,dateformate)); // dispaly 12/12/2012 at 5:06 AM but need to display 12/12/2012 at 7:48 PM </code></pre> <p>so my conversion is not work. it display wrong date.</p>
27,616,277
0
Powershell: can't generate current time in csv <pre><code>$timestamp = get-date -format "d-M-yyyy-H-mm" </code></pre> <p>I fill a csv file with lines, every line has <code>$timestamp</code> in first column and 3 other values.</p> <pre><code>#script actions1 $line = "$timestamp;value1;value2;value3" $line | out-file $file -encoding utf8 -append -force #script actions2 $line = "$timestamp;value1;value2;value3" $line | out-file $file -encoding utf8 -append -force </code></pre> <p>When I open the csv file, I see that every string has the same date and time which cannot be true. The csv sample looks like this:</p> <pre><code>"22-12-2014-12-00;value1;value2;value3" "22-12-2014-12-00;value1;value2;value3" "22-12-2014-12-00;value1;value2;value3" </code></pre> <p>How can i write the current time of each event in my log?</p>
19,706,596
0
<p>If you want to remove complete inline style attribute then you can simple use this.</p> <pre><code>$('#test').removeAttr('style'); </code></pre>
20,970,512
0
Junit for spring security <p>I've used the spring security http element to enforce security, in the securityContext.xml. I am able to successful secure my web app. I want to write a junit for the same. Will I be able to write it.</p>
38,737,641
0
<p>Following lines of javascript worked for me.</p> <pre><code>Date utcDate; /*utcDate = your own initialisation statement here;*/ Date localDate = new Date(utcDate.getTime() + TimeZone.getDefault().getRawOffset()); </code></pre> <p>Alternatively you can try <a href="http://momentjs.com/" rel="nofollow noreferrer">moment.js</a> which won't add time offset automatically.</p> <p>Cheers!</p>
6,596,940
0
<p>This is because <code>image.Pointer()</code> is a smart pointer object, a wrapper around the read pointer to your data. You must pass <code>image.Pointer().GetPointer()</code> to fftw.</p>
15,394,450
0
onDraw() not being called <p>I am working on fixing someone's Android app. It was originally made for 2.1 and I am trying to get it work to 4.0+. Unfortunately the person who made the app is not around so I am stuck with his code.</p> <p>The app implements custom sliders, a horizontal and vertical. I got the vertical slider fixed, but I cannot get the horizontal slider to work. It is not calling <code>onDraw()</code>: When the view loads, <code>onDraw()</code> gets called and I see both of my sliders initialized, then when I move my horizontal slider it moves and calls <code>onDraw()</code> once, but never again will it call it, unlike the vertical slider which does call it.</p> <p>Here is the code:</p> <pre><code>public class PanSeekBar extends RelativeLayout { private RelativeLayout layout1; public ImageView track; public ImageView thumb; public boolean initialized = false; public int thumbDownPosX = 0; public int thumbDownPosY = 0; public int thumbLeft = 0; public int thumbTop = 0; public int thumbRight = 0; public int thumbBottom = 0; private int max = 100; public boolean touched = false; public PanSeekBar(Context context) { super(context); initialize(context); // TODO Auto-generated constructor stub }// End of PanSeekBar Constructor private void initialize(Context context) { Log.d("initialize (PanSeekBar)", "initialize"); setWillNotDraw(false); LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view1 = inflater.inflate(R.layout.pan_seekbar, this); layout1 = (RelativeLayout) view1.findViewById(R.id.ps_layout1); track = (ImageView) layout1.findViewById(R.id.ps_track); thumb = (ImageView) layout1.findViewById(R.id.ps_thumb); thumb.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { initialized = true; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: Log.d("onTouch (PanSeekBar)", "Action Down"); thumbDownPosX = (int) event.getX(); thumbDownPosY = (int) event.getY(); thumbLeft = thumb.getLeft(); thumbTop = thumb.getTop(); thumbRight = thumb.getRight(); thumbBottom = thumb.getBottom(); touched = true; break; case MotionEvent.ACTION_MOVE: // Log.d("onTouch (PanSeekBar)", "Action Move"); int left = (int) (thumb.getLeft() + event.getX() - thumbDownPosX); if (left &lt; 0) { left = 0; Log.d("onTouch (PanSeekBar)", "left &lt; 0: " + left); } else if (left &gt;= track.getWidth() - thumb.getWidth()) { left = track.getWidth() - thumb.getWidth(); Log.d("onTouch (PanSeekBar)", "left &gt;= track.getWidth(): " + left); } int top = thumb.getTop(); int right = left + thumb.getWidth(); int bottom = top + thumb.getHeight(); thumbLeft = left; thumbTop = top; thumbRight = right; thumbBottom = bottom; Log.d("onTouch (PanSeekBar)", "Action Move -- thumb layout: " + thumbLeft + ", " + thumbTop + ", " + thumbRight + ", " + thumbBottom); layout1.invalidate(); // thumb.invalidate(); break; case MotionEvent.ACTION_UP: Log.d("onTouch (PanSeekBar)", "Action Up"); touched = false; break; }// End of switch return true; }// End of onTouch }); }// End of initialize @Override protected void onDraw(Canvas canvas) { Log.d("onDraw (PanSeekBar)", "onDraw"); super.onDraw(canvas); if (initialized) { thumb.layout(thumbLeft, thumbTop, thumbRight, thumbBottom); Log.d("onDraw (PanSeekBar)", "thumb layout: " + thumbLeft + ", " + thumbTop + ", " + thumbRight + ", " + thumbBottom); } }// End of onDraw }// End of PanSeekBar </code></pre> <p>Here is the code for the vertical slider that does work:</p> <pre><code>public class MySeekBar extends RelativeLayout { private RelativeLayout layout1; public ImageView track; public ImageView thumb; private MyToast toast; private MyToast toast2; private MyToast toast3; private int globalMaxValue; private int globalProgress; private boolean initialized = false; public int thumbDownPosX = 0; public int thumbDownPosY = 0; public int thumbLeft = 0; public int thumbTop = 0; public int thumbRight = 0; public int thumbBottom = 0; private int globalSetProgress = 0; private int globalConfigType = 1; // Margin top in custom_seekbar.xml private int marginTop = 20; public boolean touched = false; public MySeekBar(Context context) { super(context); // TODO Auto-generated constructor stub initialize(context); }// End of MySeekBar public void initialize(Context context) { Log.d("initialize (MySeekBar)", "initialize"); setWillNotDraw(false); LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view1 = inflater.inflate(R.layout.custom_seekbar, this); layout1 = (RelativeLayout) view1.findViewById(R.id.al_cs_layout1); track = (ImageView) layout1.findViewById(R.id.cs_track); thumb = (ImageView) layout1.findViewById(R.id.cs_thumb); // Gets marginTop MarginLayoutParams params = (MarginLayoutParams) track .getLayoutParams(); Log.d("initialize (MySeekBar)", "current margintop = " + marginTop); marginTop = params.topMargin; Log.d("initialize (MySeekBar)", "new margintop = " + marginTop); // int marginTopPixelSize = params.topMargin; // Log.d("initialize (MySeekBar)","debug = "+marginTopPixelSize); // Jared // When creating MyToast, setting width causes issues. toast = new MyToast(context); toast.setText(""); toast.setBackgroundColor(Color.LTGRAY); toast.setTextColor(Color.BLACK); toast.setPadding(1, 1, 1, 1); toast.setVisibility(View.INVISIBLE); toast.setTextSize(10f); // toast.setWidth(40); toast2 = new MyToast(context); toast2.setTextSize(12f); toast2.setTextColor(Color.rgb(192, 255, 3)); // toast2.setWidth(40); toast2.setPadding(10, 1, 1, 1); // toast2.setBackgroundColor(Color.BLACK); toast2.setVisibility(View.INVISIBLE); toast3 = new MyToast(context); toast3.setText("CH"); toast3.setTextSize(15f); toast3.setTextColor(Color.rgb(192, 255, 3)); // toast3.setWidth(40); toast3.setPadding(1, 1, 1, 1); layout1.addView(toast); layout1.addView(toast2); layout1.addView(toast3); thumb.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { initialized = true; // 0=down 1=up 2=move // Log.d("onTouch (MySeekBar)", // Integer.toString(event.getAction())); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: Log.d("onTouch (MySeekBar)", "Action Down"); thumbDownPosX = (int) event.getX(); thumbDownPosY = (int) event.getY(); // Position of thumb touched. Irrelevant to scale // Log.d("onTouch (NewSeekBar)","thumbDownPosX "+thumbDownPosX+" thumbDownPosY "+thumbDownPosY); thumbLeft = thumb.getLeft(); thumbTop = thumb.getTop(); thumbRight = thumb.getRight(); thumbBottom = thumb.getBottom(); touched = true; toast2.setVisibility(View.INVISIBLE); toast3.setVisibility(View.INVISIBLE); toast.setVisibility(View.VISIBLE); // Location/size of the thumb button // Log.d("onTouch (NewSeekBar)","thumbLeft "+thumbLeft+" thumbRight "+thumbRight+" thumbTop "+thumbTop+" thumbBottom "+thumbBottom); break; case MotionEvent.ACTION_MOVE: // Log.d("onTouch (MySeekBar)", "Action Move"); int thumbHeight = thumb.getHeight(); int thumbWidth = thumb.getWidth(); int trackWidth = track.getWidth(); int trackHeight = track.getHeight(); // Location/size of the thumb button and track // Log.d("onTouch (NewSeekBar)","thumbHeight "+thumbHeight+" thumbWidth "+thumbWidth+" trackWidth "+trackWidth+" trackHeight "+trackHeight); int top = (int) (thumb.getTop() + event.getY() - thumbDownPosY); Log.d("onTouch (NewSeekBar)", "top " + top); // Top border if (top &lt; marginTop) { top = marginTop; Log.d("onTouch (NewSeekBar)", "top &lt; marginTop " + top); } else if (top &gt;= trackHeight - thumbHeight + marginTop) { top = trackHeight - thumbHeight + marginTop; Log.d("onTouch (NewSeekBar)", "top &gt;= trackHeight " + top); } thumbLeft = thumb.getLeft(); ; thumbTop = top; thumbRight = thumbLeft + thumbWidth; thumbBottom = top + thumbHeight; // Log.d("onTouch (MySeekBar)", // "thumbTop: "+thumbTop+" thumbBottom: "+thumbBottom); int value = getProgress(); Log.d("onTouch (NewSeekBar)", "getProgress(): " + value); // setdBText(value); // Log.d("onTouch (MySeekBar)", "value: "+value); setProgress(value); // toast.setText(String.valueOf(temp)); // toast2.setText(String.valueOf(temp)); layout1.invalidate(); break; case MotionEvent.ACTION_UP: Log.d("onTouch (MySeekBar)", "Action Up"); toast.setVisibility(View.INVISIBLE); toast2.setVisibility(View.VISIBLE); toast3.setVisibility(View.VISIBLE); touched = false; break; }// End of switch return true; }// End of onTouch }); }// End of initialize @Override protected void onDraw(Canvas canvas) { Log.d("onDraw (MySeekBar)", "onDraw"); super.onDraw(canvas); if (initialized) { thumb.layout(thumbLeft, thumbTop, thumbRight, thumbBottom); Log.d("onDraw (MySeekBar)", "thumb layout: " + thumbLeft + ", " + thumbTop + ", " + thumbRight + ", " + thumbBottom); int top = thumbTop - marginTop; int left = thumbLeft + 4; // toast.layout(left, top, left + toast.getWidth(), top + // toast.getHeight()); top = thumbTop + thumb.getHeight() / 2 - toast2.getHeight() / 2 + 1; left = thumbLeft; toast2.layout(left, top, left + toast2.getWidth(), top + toast2.getHeight()); } }// End of onDraw </code></pre> <p>The XML:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/test_layout"&gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" &gt; &lt;com.networksound.Mixer3.NewSeekBar android:id="@+id/newSeekBar1" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/com.networksound.Mixer3.NewSeekBar&gt; &lt;com.networksound.Mixer3.NewSeekBar android:id="@+id/newSeekBar2" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/com.networksound.Mixer3.NewSeekBar&gt; &lt;com.networksound.Mixer3.MySeekBar android:id="@+id/mySeekBar1" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/com.networksound.Mixer3.MySeekBar&gt; &lt;com.networksound.Mixer3.MySeekBar android:id="@+id/mySeekBar2" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/com.networksound.Mixer3.MySeekBar&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;com.networksound.Mixer3.PanSeekBar android:id="@+id/panSeekBar1" android:layout_width="match_parent" android:layout_height="wrap_content" &gt; &lt;/com.networksound.Mixer3.PanSeekBar&gt; &lt;com.networksound.Mixer3.PanSeekBar android:id="@+id/panSeekBar2" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/com.networksound.Mixer3.PanSeekBar&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre>
18,190,745
0
$scope.$apply in AngularJS - Function executed each time is the last defined function <p>If I call the code below inside a loop of asynchronous HTTP requests I get latter response. Any suggestions on where I could be going wrong?</p> <p>NOTE: This is essentially pseudo code.</p> <pre><code>function successful_request(site) { console.log('In: ' + site.id); $scope.$apply(function() { console.log('Out: ' + site.id); } } </code></pre> <p>OUTPUT:</p> <pre><code>In: 1 In: 2 In: 3 Out: 3 Out: 3 Out: 3 </code></pre> <p>I hope I've made sense here. I suspect it's a case of how I'm calling $scope.$apply but I'm not sure what I should do differently.</p>
9,594,069
0
<p>First, update your Joomla, current version is 2.5.2. There are definitely security issues using 1.6 as it has not been supported for over a year now.</p> <p>Next, there are tons of slider extensions. Widgetkit by Yootheme is really nice and should be able to do images and videos. There are dozens of other options in the JED - <a href="http://extensions.joomla.org/extensions/photos-a-images/images-slideshow" rel="nofollow">http://extensions.joomla.org/extensions/photos-a-images/images-slideshow</a></p>
1,860,273
0
<pre><code>var app = $('#ApplicationID')[0] </code></pre> <p>or </p> <pre><code>var app = $('#ApplicationID').get(0) </code></pre> <p>should do the same thing as </p> <pre><code>var app = document.getElementById('ApplicationID') </code></pre>
8,982,416
0
How to publish Actions to Facebook Graph API with parameters in call URL <p>To begin, Ive spent several hours looking for an answer and have come CLOSE but havent found a full answer.</p> <p>So Im trying to publish actions using Facebook's Graph API and want to send parameters in the URL when initially calling it with the Facebook Javascript SDK.</p> <p>Here is a call that WORKS:</p> <pre><code> function postNewAction() { passString = '&amp;object=http://mysite.com/appnamespace/object.php'; FB.api('/me/APP_NAMESPACE:ACTION' + passString,'post', function(response) { if (!response || response.error) { alert(response.error.message); } else { alert('Post was successful! Action ID: ' + response.id); } } ); } </code></pre> <p>With object.php looking like so:</p> <pre><code> &lt;head xmlns:enemysearch="http://apps.facebook.com/APP_NAMESPACE/ns#"&gt; &lt;meta property="fb:app_id" content="APP_ID" /&gt; &lt;meta property="og:type" content="APP_NAMESPACE:object" /&gt; &lt;meta property="og:title" content="some title" /&gt; &lt;meta property="og:description" content="some description"/&gt; &lt;meta property="og:locale" content="en_US" /&gt; &lt;meta property="og:url" content="http://www.mysite.com/appnamespace/object.php"/&gt; &lt;/head&gt; </code></pre> <p>So obviously the above will post some sort of action to Facebook that will be the same every time object.php is called.</p> <p>This is not ideal for my purposes.</p> <p>So I took a look at <a href="http://stackoverflow.com/questions/8431694/dynamic-generation-of-facebook-open-graph-meta-tags">this thread</a> and it helped but as you will see, doesnt answer everything.</p> <p>So if I change object.php to include dynamically generated meta tags by using content from either GET or POST and use the <a href="http://developers.facebook.com/tools/debug" rel="nofollow">Object Debugger</a> with a matching URL format to the one provided in og:url, the debugger shows everything as working as I would expect with now warnings. Here is what the dynamically generated object.php looks like:</p> <pre><code> &lt;?php if(count($_GET) &gt; 0) { $userName = (int)$_GET['userName']; } else { $userName = (int)$_POST['userName']; } ?&gt; &lt;head xmlns:enemysearch="http://apps.facebook.com/APP_NAMESPACE/ns#"&gt; &lt;meta property="fb:app_id" content="APP_ID" /&gt; &lt;meta property="og:type" content="APP_NAMESPACE:object" /&gt; &lt;meta property="og:title" content=" &lt;?php echo $userName; ?&gt;" /&gt; &lt;meta property="og:description" content="Click to view more from &lt;?php echo $userName; ?&gt;"/&gt; &lt;meta property="og:locale" content="en_US" /&gt; &lt;meta property="og:url" content="http://mysite.com/appnamespace/object.php?userName=&lt;?php echo $userName; ?&gt;"/&gt; &lt;/head&gt; </code></pre> <p>SO, what I need to know is how to send url parameters in the initial call. If I use the debugger and enter something to the effect of <a href="http://mysite.com/appnamespace/object.php?userName=Brad" rel="nofollow">http://mysite.com/appnamespace/object.php?userName=Brad</a> everything works fine and the meta tags return content with that name inside of them. However if I try to pass the same url in the Javascript Call, it returns an error saying that my meta property og:type needs to be 'APP_NAMESPACE:object' (which as you see above, is what I have) instead of 'website' (which as you can see above, is something I am not using). Here is what that broken call would look like:</p> <pre><code> function postNewAction(userName) { passString = '&amp;object=http://mysite.com/appnamespace/object.php?userName=' + userName; FB.api('/me/APP_NAMESPACE:ACTION' + passString,'post', function(response) { if (!response || response.error) { alert(response.error.message); } else { alert('Post was successful! Action ID: ' + response.id); } } ); } </code></pre> <p>To be clear, the userName variable is only for example.</p> <p>Any thoughts?</p>
16,680,099
0
<p>Looks like you are missing a few jar's.</p> <p><a href="http://poi.apache.org/overview.html" rel="nofollow">http://poi.apache.org/overview.html</a></p> <p>You need:</p> <pre><code>poi-version-yyyymmdd.jar commons-logging.jar commons-codec.jar log4j.jar poi-ooxml-schemas-version-yyyymmdd.jar xmlbeans.jar stax-api-1.0.1.jar dom4j.jar </code></pre>
38,712,058
0
<blockquote> <p>However upon setting the static property, the original closure gets executed. It's not the case for lazy instance properties. Why is that?</p> </blockquote> <p>What answer would satisfy you? Are you asking for someone to read Apple's mind? You're as capable of reading the Swift source code as anyone else, so go read it and see what it does. Personally, I agree with your expectation. In my opinion this behavior is a bug, and I've filed a bug report with Apple. If you agree, file one too. But I wouldn't expect anything to change if I were you. And regardless, your question can appeal only to opinion, which is not a good fit for Stack Overflow.</p> <p>In case you're curious, my bug report is number 19085421, and reads, in part:</p> <blockquote> <p><strong>Summary:</strong> A lazy var's initializer should not be evaluated at all if the var is written to without being read first. But that is what a global var does.</p> <p><strong>Steps to Reproduce:</strong> Run the enclosed project.</p> <p><strong>Expected Results:</strong> I am assigning to the global var before anyone ever reads its value. Therefore I expect that its initializer will <em>never</em> be evaluated.</p> <p><strong>Actual Results:</strong> Its initializer <em>is</em> evaluated, as the logging in the console proves. This defeats, to some extent, the purpose of laziness.</p> </blockquote>
23,022,274
0
<p>I use <a href="https://github.com/mirek/CoreWebSocket" rel="nofollow">CoreWebSocket!</a>. It's pretty good so far. Best of all, i found it very easy to understand. It might be a good place to start.</p> <p>I also know of <a href="https://github.com/square/SocketRocket" rel="nofollow">SocketRocket</a>. Which I'm told is actually better. But I've been working with CoreWebSocket for a while now, and its working just fine to me. </p> <p>Both are pretty well documented. So I think these would be a good place to start. Let me know if you need anything else.</p> <p>Thats just the sockets though. I also have an 'always online' based application. Where the users are always online. The good thing is, sockets are persistent in the sense that you make the connection only once. For this you need some kind of turn server to figure out who's online and their credentials to connect. Once connected you can seamlessly send receive data between them with out involving an in-between server. </p> <p>If you need to be aware of what the users are sending and receiving, then its a good idea to have a server in-between, Where data is sent to the server first, and then forwarded to the appropriate users.</p> <p>The libraries above have some documentation on how they work, so you can use it to figure out some kind of architecture before you pick one of them to use.</p> <p>Good luck!</p> <p>EDIT: To be honest, sockets are meant for (in my opinion) live connections. So if you want to send and receive controls for a game or something of that sorts. The idea is that you don't need establish a new connection every time you want to send data. You make a connection once, and you can send and receive until it is closed. Is this the kind of application you're trying to make? </p>
18,100,918
0
<p>You can use javascript to submit the form. To make it easier, give the form an id, here's an example that uses jQuery:</p> <pre><code>&lt;form id="paypal-form" action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" target="PPDGFrame" name = "paypal_form"&gt; &lt;input id="type" type="hidden" name="expType" value="light"&gt; &lt;input id="paykey" type="hidden" name="paykey" value="RETURNED_PAYKEY_GOES_HERE"&gt; &lt;input type="submit" id="submitBtn" value="Pay with PayPal"&gt; &lt;/form&gt; &lt;script&gt; $('paypal-form').submit(); &lt;/script&gt; </code></pre>
36,375,191
0
How do you add extra data in currentUser object? <p>I am trying to add an extra information that is not in profile for the <code>currentUser</code> object in Meteor. I am thinking it is possible and the technique should be somewhere in <code>meteor/alanning:roles</code>.</p> <p>e.g. if I have a <code>organizations</code> object in <code>users</code> e.g.</p> <pre><code>{ _id: ... profile: { ... } roles: [ ... ] organizations: [ ... ] } </code></pre> <p>I would like to see it when I do</p> <pre><code>{{ currentUser }} </code></pre>
39,456,914
0
<p>You can fix this by uninstalling M2Crypto via pip, then installing the package python-m2crypto, and then to make sure install M2Crypto again </p> <pre><code>pip uninstall M2Crypto apt-get install python-m2crypto pip install M2Crypto </code></pre> <p>This solved for me</p>
6,330,658
0
how can I replace blank value with zero in MS-Acess <p>I have below query in Ms-Access but I want to replace Blank value with zero but I can't get proper answer. Is there any way to replace blank value in zero.</p> <pre><code>(SELECT SUM(IIF(Review.TotalPrincipalPayments,0,Review.TotalPrincipalPayments))+ SUM(IIF(Review.TotalInterestPayments,0,Review.TotalInterestPayments )) FROM tblReviewScalars as Review INNER JOIN tblReportVectors AS Report ON(Review.LoanID=Report.LoanID) WHERE Report.AP_Indicator="A" AND Report.CashFlowDate=#6/5/2011# AND Review.AsofDate=#6/5/2011# AND ( Review.CreditRating =ReviewMain.CreditRating)) AS [Cash Collected During the Period], </code></pre>
8,465,846
0
Using datatype different Property Editor <p>I have a class with an Integer Property which I want to change over a PropertyGrid. BUT: I don't want to use the Integer InputBox but a Dropdown List with an Enum as content. How could I do this?</p>
23,122,518
0
<p>You can use <code>$[:]</code> to match a literal. </p>
12,868,898
0
<p>Both of these would work:</p> <pre><code>$("#animation1, #animation2, #animation3").click(function() { // existing code }); </code></pre> <p>or </p> <pre><code>function animate() { //existing code } $("#animation1").click(animate); </code></pre>
28,194,237
0
<p><a href="https://github.com/raptorjs/marko" rel="nofollow">Marko</a> does exactly what you are looking for: </p> <p>It offers 3 key features that enable progressive rendering:</p> <ol> <li>Streamed Template Rendering - So your html is sent early and the buffers are cleared often</li> <li>Async Rendering of html fragments - Marko will manage the waiting, buffering and eventual rendering</li> <li>Out of order rendering - Marko will optionally send template data as soon as it is available from api calls or db queries, then it will re-order the html on the client side</li> </ol> <p>I just did a screencast on Marko that you might find helpful:</p> <p><a href="http://knowthen.com/episode-8-serving-content-in-koajs-with-marko/" rel="nofollow">http://knowthen.com/episode-8-serving-content-in-koajs-with-marko/</a></p>
20,310,889
0
How to find the kth smallest element within an interval of an array <p>Suppose I have an unsorted integer array a[] with length N. Now I want to find the kth smallest integer within a given interval a[i]-aj. Ex: I have an array a[10]={10,15,3,8,17,11,9,25,38,29}. Now I want to find the 3rd smallest element within [2,7] interval. The answer is 9. I know this can be done by sorting that interval. But this costs O(MlogM)(M=j-i+1) time. I also know that, this can be done by segment tree. But I can't understand how to modify it to handle such query.</p>
19,443,431
1
python cache dictionary - counting number of hits <p>I'm implementing a caching service in python. I'm using a simple dictionary so far. What I'd like to do is to count number of hits (number of times when a stored value was retrieved by the key). Python builtin dict has no such possibility (as far as I know). I searched through 'python dictionary count' and found <code>Counter</code> (also on stackoverflow), but this doesn't satisfy my requirements I guess. I don't need to count what already exists. I need to increment something that come from the outside. And I think that storing another dictionary with hits counting only is not the best data structure I can get :)</p> <p>Do you have any ideas how to do it efficiently?</p>
32,535,190
0
<p>Absurd over-generalization:</p> <p>Every <code>Traversable</code> instance supports a horrible hack implementing <code>reverse</code>. There may be a cleaner or more efficient way to do this; I'm not sure.</p> <pre><code>module Rev where import Data.Traversable import Data.Foldable import Control.Monad.Trans.State.Strict import Prelude hiding (foldl) fill :: Traversable t =&gt; t b -&gt; [a] -&gt; t a fill = evalState . traverse go where go _ = do xs &lt;- get put (drop 1 xs) return (head xs) reverseT :: Traversable t =&gt; t a -&gt; t a reverseT xs = fill xs $ foldl (flip (:)) [] xs reverseAll :: (Functor f, Traversable t) =&gt; f (t a) -&gt; f (t a) reverseAll = fmap reverseT </code></pre>
18,048,541
0
Golang: what's the point of interfaces when you have multiple inheritence <p>I'm a Java programmer, learning to program in Go. So far I really like the language. A LOT more than Java. </p> <p>But there's one thing I'm a bit confused about. Java has interfaces because classes can inherit only from one class. Since Go allows multiple inheritance, what's the point of interfaces?</p>
7,848,809
0
<p>Some alternative using Linq to Xml</p> <pre><code>using System.Xml.XPath; var document = XDocument.Parse(@"&lt;Z&gt; &lt;X&gt; &lt;Code&gt;ABC&lt;/Code&gt; &lt;/X&gt; &lt;X&gt; &lt;Code&gt;DEF&lt;/Code&gt; &lt;/X&gt; &lt;/Z&gt;"); var codeValues = document.XPathSelectElements("//Z/X/Code") .Select(e =&gt; e.Value) .OrderByDescending(e =&gt; e); </code></pre> <p>You can simplify it even further if you want. You need to take into account performance though. If your xml files are large this won't perform as well I guess. If you only have small files the simplicity of this outweighs the small performance penalty. </p>
14,708,374
0
<p>Note that <a href="http://php.net/manual/en/function.php-uname.php">PHP_OS reports the OS that PHP was <em>built</em> on</a>, which is not necessarily the same OS that it is currently running on.</p> <p>If you are on PHP >= 5.3 and just need to know whether you're running on Windows or not-Windows then testing whether one of the <a href="http://php.net/manual/en/info.constants.php">Windows-specific constants</a> is defined may be a good bet, e.g.:</p> <pre><code>$windows = defined('PHP_WINDOWS_VERSION_MAJOR'); </code></pre>
10,263,001
0
jquery form validation using groups <p>I have an order form, one part of the form is the address. It contains Company, Street-Address, ZIP, Town, Country with a simple jquery form validation with every field required, and ZIP validated for number. Now what I want is to group them and only have one field showing "valid address" on success, or "address wrong" on error.</p> <p>This is a part of my js code:</p> <pre><code>$("#pageform").validate( { messages: { company_from: addressError, //addressError is a JS var for the error message street_from: addressError, zip_from: addressError, town_from: addressError, country_from: addressError }, groups: { from: "company_from street_from zip_from town_from country_from" }, errorPlacement: function(error, element) { if (element.attr("name") == "company_from" || element.attr("name") == "street_from" || element.attr("name") == "zip_from" || element.attr("name") == "town_from" || element.attr("name") == "country_from" ) { $("#error_from").append(error); } }, success: function(label) { var attribute = $(label[0]).attr("for"); $(".err-ok-" + attribute + " .ok").css("display", "block").css("visibility", "visible"); } } ); </code></pre> <p>This is a part of the corresponding HTML code:</p> <pre><code>&lt;input type="text" name="company_from" id="company_from" class="required default input-s8" maxlength="255" /&gt; &lt;input type="text" name="street_from" id="street_from" class="required default input-s8" maxlength="255" /&gt; &lt;input type="text" name="zip_from" id="zip_from" class="required digits default input-s8" maxlength="5" onblur="checkCalculation()" /&gt; &lt;input type="text" name="town_from" id="town_from" class="required default input-s8" maxlength="255" /&gt; &lt;!-- and a select list for the country --&gt; </code></pre> <p>You do not need to take a closer look on how I show the error and so on, my problem is, that <strong>I do not know when to show the error label and when the success label</strong>. When I enter a letter for the ZIP code, my errorPlacement function and the success function is called (and the errorPlacement first), so I guess it's always calling the success if there is at least one field correct. </p> <p>Please ask if there are any questions, and I am pretty sure there are... :-)</p>
3,117,647
0
xml element not indented properly <p>i have created a xml file using c# but the main problem is that it is not indented</p> <p>i have used xmldocument.preserverwhitespace=true;</p>
38,630,132
0
<p>you cant echo string in php file and introduce as JSONObject in android.</p> <p>all error and message must be in json array and just json array showed in php file .</p> <p>i suggest this :</p> <pre><code> &lt;?php $host='localhost'; $uname='amodbina0106'; $pwd='Amodbina200'; $db="kezin_king"; $result = array(); $con=mysqli_connect("localhost","amodbina0106","Amodbina200","kezin_king"); if ($con-&gt;connect_error) { $result['status'] = false; $result['message'] = 'server lost'; die(json_encode($result)); } $username = $_GET['username']; $password = $_GET['password']; $flag['code']=0; if($name == '' || $username == '' || $password == '' || $email == ''){ $result['status'] = false; $result['message'] = 'All field required'; } else{ $sql=mysql_query("insert into sample values('$id','$name') ",$con); if(mysqli_query($con,$sql)) { $flag['code']=1; $result['status'] = true; $result['message'] = 'hi'; } print(json_encode($result)); mysql_close($con); } ?&gt; </code></pre>
33,814,145
0
<p>Does this do it:</p> <pre><code>UPDATE tbl SET defaultHours = 5 WHERE ts &gt;= CURRENT_DATE() - INTERVAL 1 MONTH AND ts &lt; CURRENT_DATE() - INTERVAL 1 MONTH + INTERVAL 1 DAY </code></pre> <p>?</p>
24,468,586
0
MySQL --> MongoDB: Keep IDs or create mapping? <p>We are going to migrate our database from MySQL to MongoDB. Some URLs pointing at our web application use database IDs (e.g. <a href="http://example.com/post/5" rel="nofollow">http://example.com/post/5</a>) At the moment I see two possibilities:</p> <p>1) Keep existing MySQL IDs and use them as MongoDB IDs. IDs of new documents will get new MongoDB ObjectIDs.</p> <p>2) Generate new MongoDB ObjectIDs for all documents and create a mapping with MySQLId --> MongoDBId for all external links with old IDs in it.</p> <p>2 will mess up my PHP app a little, but I could imagine that #1 will cause problems with indexes or sharding? What is the best practice here to avoid problems?</p>
30,062,585
0
<p>I found the quickest solution was to create a sql database with different tables for each type( Vehicles, Lookups etc.). When I just loaded all the data in and queried with a bunch of joins it took over a minute. But by creating foreign key references, indexes and adding primary keys to the table I got it down to less than a second. So I create the query from my c# Code and get back an object that contains all the information I need from each table.</p>
36,195,493
0
Android drawable oval shape with center out of bound <p>I'm willing to declare a xml drawable with semi-circle. So the center of the oval is out of the bound: <a href="https://i.stack.imgur.com/Ot43c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ot43c.png" alt="what i want"></a> </p> <p>I tried doing it with scale tag but i can't get it to work, here is what i have done.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item&gt; &lt;scale android:scaleGravity="center"&gt; &lt;shape android:shape="ring"&gt; &lt;stroke android:width="2dp" android:color="#C8C8D7"/&gt; &lt;size android:width="300dp" android:height="300dp"/&gt; &lt;/shape&gt; &lt;/scale&gt; &lt;/item&gt; &lt;/layer-list&gt; </code></pre> <p>But it doesn't work.</p>
1,496,878
0
<p>You can add a condition that applies to a relative (or absolute node) to any step of an XPath expression.</p> <p>In this case:</p> <pre><code>//*[@id=substring-after(/Reference/@URI, '#')] </code></pre> <p>The <code>//*</code> matches all elements in the document. The part in <code>[]</code> is a condition. Inside the condition the part of the URI element of the root References node is taken, but ignoring the '#' (and anything before it).</p> <p>Sample code, assuming you have loaded your XML into <code>XPathDocument</code> <code>doc</code>:</p> <pre><code>var nav = doc.CreateNavigator(); var found = nav.SelectSingleNode("//*[@id=substring-after(/Reference/@URI, '#')]"); </code></pre>
37,702,259
0
<p>Can it be simply because call to rate_limit_status.json also counts? What if you do </p> <pre><code>client.search("baeza") client.search("baeza") client.search("baeza") puts Twitter::REST::Request.new(client, :get, 'https://api.twitter.com/1.1/application/rate_limit_status.json', resources: "search").perform </code></pre> <p>Will it return 176? </p> <p><em>Update</em> - call to rate_limit_status should <em>not</em> affect limits, but would be interesting to see the outcome of the suggested calls anyway.</p> <p><em>Update 2</em></p> <p>Gem fetches only first page by default, no matter of results count. Getting next page(s) is under your control. See <a href="https://github.com/sferik/twitter/blob/77238b540edfbc76aa2f25bc4398c3dad8f55edb/lib/twitter/search_results.rb#L50" rel="nofollow">here</a> - fetch_next_page is private method, called by "each" method of enumerator <a href="https://github.com/sferik/twitter/blob/77238b540edfbc76aa2f25bc4398c3dad8f55edb/lib/twitter/enumerable.rb#L13" rel="nofollow">here</a> - so if you start iterating over search results and pass through all first page results. When you just made a request (called search) - it only fetches first page (one query).</p> <p>Also, gem sets count parameter for API search request to 100 (max allowed) if not specified by default - <a href="https://github.com/sferik/twitter/blob/77238b540edfbc76aa2f25bc4398c3dad8f55edb/lib/twitter/rest/search.rb#L7" rel="nofollow">here</a> for constant and <a href="https://github.com/sferik/twitter/blob/77238b540edfbc76aa2f25bc4398c3dad8f55edb/lib/twitter/rest/search.rb#L31" rel="nofollow">here</a> for setting it </p>
21,579,269
0
<p>The dts data Conversion task is time taking if there are 50 plus columns!Found a fix for this at the below link</p> <pre><code>http://rdc.codeplex.com/releases/view/48420 </code></pre> <p>However, it does not seem to work for versions above 2008. So this is how i had to work around the problem</p> <pre><code>*Open the .DTSX file on Notepad++. Choose language as XML *Goto the &lt;DTS:FlatFileColumns&gt; tag. Select all items within this tag *Find the string **DTS:DataType="129"** replace with **DTS:DataType="130"** *Save the .DTSX file. *Open the project again on Visual Studio BIDS *Double Click on the Source Task . You would get the message the metadata of the following output columns does not match the metadata of the external columns with which the output columns are associated: ... Do you want to replace the metadata of the output columns with the metadata of the external columns? *Now Click Yes. We are done ! </code></pre>
19,292,250
0
<p>The $id item is contained in an ID item. Try:</p> <pre><code>$id = $item['ID']['$id']; </code></pre> <p>Edit: I am not sure why you have the nested loops. This should be enough:</p> <pre><code>foreach ($json as $key1 =&gt; $item) { $id = $item['ID']['$id']; echo gmdate("d-m-Y H:i", strtotime('+2 hours', $item['datum'])) . '&amp;nbsp;' . $item['titel'] . ' met ID: '.$id.'&lt;br/&gt;'; } </code></pre>
4,320,985
0
<p>To fetch records based on TIME only:</p> <pre><code>WHERE TIME(FROM_UNIXTIME(your_column)) BETWEEN '01:15:00' AND '01:15:59' </code></pre> <p>Regards</p>
25,774,392
0
<p>The simplest approach would be to not set the proxy when Fiddler isn't running.</p> <p>You haven't told us anything about your environment that would enable anyone to help you further.</p>
23,191,488
0
<p>You didn't put it in Form use input hidden to post it </p> <pre><code>&lt;form method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt; &lt;input type="number" name="vuelto"&gt;&lt;br&gt; &lt;input type="hidden" name="cobro" value="&lt;?php echo $cobro; ?&gt;"&gt; &lt;input type="submit" name="submit" value="Submit Form"&gt;&lt;br&gt; &lt;/form&gt; </code></pre> <p>That's how you can pass cobro variable value which will be available in $_POST['cobro']</p>
37,661,285
0
<p>i have found out that the div container which contains the background image has only size : 100%, so maybe if i change the size of the container, but i want that the container is responsive too ... hmm anyone a idea ?</p> <p>here pictures where the container is with width: 100% and without<a href="http://i.stack.imgur.com/BH8Sc.png" rel="nofollow">enter image description here</a></p> <p><a href="http://i.stack.imgur.com/TEYN5.png" rel="nofollow">without and with width: 100%</a></p>
33,596,622
0
java.lang.AbstractMethodError: com.mysql.jdbc.PreparedStatement.setBlob(ILjava/io/InputStream;)V <p>I'm trying to set a BLOB in MySQL DB as below:</p> <pre><code>PreparedStatement ps=con.prepareStatement("insert into image values(?,?,?,?,?)"); ps.setString(1,firstname); ps.setString(2,lastname); ps.setString(3,address); ps.setString(4,phone); if(is!=null) { ps.setBlob(5,is); } int i=ps.executeUpdate(); </code></pre> <p>The line <code>ps.setBlob(5,is)</code> throws the below exception:</p> <blockquote> <p>java.lang.AbstractMethodError: com.mysql.jdbc.PreparedStatement.setBlob(ILjava/io/InputStream;)V</p> </blockquote> <p>How it this caused and how can I solve it?</p>
40,263,746
1
How to make a list of prices for a receipt? <p>I've been trying for a while to make my receipt to show all the prices I listed,using sum() to show subtotal, and make a dollar sign next to my prices. So far I have a lot of my receipt done, but can't figure this out. This is my code so far:</p> <pre><code>price = [] headphones = int(input("Enter price of Headphones: ") ) while(True): price = int(input("Enter price of Headphones: ")) if (price == -1): break apple= int(input("Enter price of Apple: ") ) while(True): price = int(input("Enter price of Apple: ")) if (price == -1): break pen = int(input("Enter price of Pen: ") ) while(True): price = int(input("Enter price of Pen: ")) if (price == -1): break mouse = int(input("Enter price of Mouse: ") ) while(True): price = int(input("Enter price of Mouse: ")) if (price == -1): break paper = int(input("Enter price of amount for Paper: ") ) while(True): price = int(input("Enter price of amount for Paper: ")) if (price == -1): break cookies = int(input("Enter price of Cookies: ") ) while(True): price = int(input("Enter price of Cookies: ")) if (price == -1): break bananas = int(input("Enter price of Bananas: ") ) while(True): price = int(input("Enter price of Bananas:")) if (price == -1): break bread = int(input("Enter price of Bread: ") ) while(True): price = int(input("Enter price of Bread: ")) if (price == -1): break subtotal = headphones + apple + pen + mouse + paper + cookies + bananas + bread tax = int(subtotal * 0.065) total = subtotal + tax a = headphones b = apple c = pen d = mouse e = paper f = cookies g = bananas h = bread w = subtotal y = w * .065 v = y+w print("Target Recipt".center(80, "-")) print("-".center(80, "-")) print("Headphones $: ".center(0, ), headphones) print("Apple $: ".center(0, ), apple) print("Pen $: ".center(0, ), pen) print("Mouse $: ".center(0, ), mouse) print("Paper $: ".center(0, ), paper) print("Cookies $: ".center(0, ), cookies) print("Bananas $: ".center(0, ), bananas) print("Bread $: ".center(0, ), bread) print("-".center(80, "-")) print() print() print("Subtotal".center(37, ), w) print("Tax".center(37, ), y) print() print("Total".center(37, ), v) print() print() print('Have a wonderful day!'.center(80, "-")) </code></pre> <p>I can't seem to figure out what what I'm doing wrong. I know that I'm supposed to use this:</p> <pre><code>prices = [] while(True): p = float(input("Enter a price" )) prices.append(p) for i in range(len(prices)): print(prices[i]) </code></pre>
36,406,229
0
<p>I only found 2 issues, and that was that you were setting it globally and you had the shadow AFTER you created the sun. You can move it wherever you'd like, but if you wanted it applied to your "Sun", then it would be best done like this.</p> <p>The way I've found best to stop that problem is by wrapping my change code in save() and restore() functions. Like this:</p> <pre><code> }, Sun: { render: function(){ ctx.fillStyle = "rgb(255,255,51)"; ctx.save(); //store ctx so it can be later reused. ctx.shadowColor = 'yellow'; ctx.shadowBlur = 50; ctx.shadowOffsetX = 0; ctx.shadowOffsetY = 0; ctx.beginPath(); ctx.arc(rectX, rectY, rectW, rectH, Math.PI*2, true); //alligns the sun in center ctx.closePath(); ctx.fill(); ctx.restore(); //ctx at time of save. </code></pre> <p>Working Fiddle: <a href="https://jsfiddle.net/gregborbonus/g1d6jkh7/" rel="nofollow">https://jsfiddle.net/gregborbonus/g1d6jkh7/</a></p>
31,148,451
0
Reading numeric keys from JSON file <p>Let's say I store a dictionary's values in JSON file. Here is the simplified code:</p> <pre><code>test = {} for i in range(10): for j in range(15): test['{},{}'.format(i, j)] = i * j with open('file1.json', 'w') as f: json.dump(test, f) </code></pre> <p>I have hard time reading back from this file. How can I read back from this file into a dictionary with elements like key as [i,j] and value as i*j? I use simple </p> <pre><code>with open('file1.json', 'r') as f: data2 = json.load(f) </code></pre>
12,058,250
0
Index was outside the bounds of the array on Infragistics UltraGrid when OnPaint is called <p>I've binded my grid's DataSource to a BindingSource object which i update from another thread. I've wrote the following code:</p> <pre><code> protected override void OnPaint(PaintEventArgs pe) { if (this.InvokeRequired) { this.Invoke(new OnPaintMethodInvoker(this.OnPaint), pe); } else { try { base.OnPaint(pe); } catch { } } } </code></pre> <p>And two things happens to me: 1. the Invoke is never being called (i guess the ultragrid know how to handle it) 2. when i play with the screen (mouseover/resize) while the data is being updated - i recieve the following exception:</p> <p>Index was outside the bounds of the array.</p> <pre><code> at Infragistics.Shared.SparseArray.GetItemAtScrollIndex(Int32 scrollIndex, ICreateItemCallback createItemCallback) at Infragistics.Win.UltraWinGrid.ScrollCountManagerSparseArray.GetItemAtScrollIndex(Int32 scrollIndex, Boolean allocate) at Infragistics.Win.UltraWinGrid.RowsCollection.GetRowAtScrollIndex(Int32 scrollIndex, Boolean allocate) at Infragistics.Win.UltraWinGrid.RowsCollection.get_IsLastScrollableRowNotAllocatedYet() at Infragistics.Win.UltraWinGrid.RowScrollRegion.IsLastScrollableRowVisible(ScrollbarVisibility colScrollbarVisibility) at Infragistics.Win.UltraWinGrid.RowScrollRegion.GetMaxScrollPosition(Boolean scrollToFill) at Infragistics.Win.UltraWinGrid.RowScrollRegion.EnsureScrollRegionFilled(Boolean calledFromRegenerateVisibleRows) at Infragistics.Win.UltraWinGrid.RowScrollRegion.RegenerateVisibleRows(Boolean resetScrollInfo) at Infragistics.Win.UltraWinGrid.RowScrollRegion.RegenerateVisibleRows() at Infragistics.Win.UltraWinGrid.RowScrollRegion.WillScrollbarBeShown(ScrollbarVisibility assumeColScrollbarsVisible) at Infragistics.Win.UltraWinGrid.ScrollRegionBase.WillScrollbarBeShown() at Infragistics.Win.UltraWinGrid.RowScrollRegion.PositionScrollbar(Boolean resetScrollInfo) at Infragistics.Win.UltraWinGrid.ScrollRegionBase.SetOriginAndExtent(Int32 origin, Int32 extent) at Infragistics.Win.UltraWinGrid.RowScrollRegion.SetOriginAndExtent(Int32 origin, Int32 extent) at Infragistics.Win.UltraWinGrid.DataAreaUIElement.ResizeRowScrollRegions() at Infragistics.Win.UltraWinGrid.DataAreaUIElement.PositionChildElements() at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UltraWinGrid.DataAreaUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UltraWinGrid.DataAreaUIElement.set_Rect(Rectangle value) at Infragistics.Win.UltraWinGrid.UltraGridUIElement.PositionChildElements() at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UltraWinGrid.UltraGridUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics) at Infragistics.Win.UIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics) at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize, Boolean preventAlphaBlendGraphics) at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize) at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode) at Infragistics.Win.UltraWinGrid.UltraGridUIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode) at Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe) at Infragistics.Win.UltraWinGrid.UltraGrid.OnPaint(PaintEventArgs pe) at MyProject.Common.UI.Controls.GridControl.OnPaint(PaintEventArgs pe) </code></pre> <p>Anyone knows what could be the problem? I've tried to put lock(this) around the base.OnPaint(pe) but it didn't help.</p>
32,751,507
0
Wordpress Rest Api ionic app loading <p>I'm developing a Wordpress Ionic application using the Wordpress REST API and Jetpack. I followed a tutorial <a href="https://www.youtube.com/watch?v=jbopML8dnqg" rel="nofollow noreferrer">Hybrid Mobile Application with Ionic/Cordova</a>, but ran into an ugly problem. When I enter my REST API link in <code>$http.get()</code> and try it in my browser it keeps loading like this:</p> <p><a href="https://i.stack.imgur.com/tAY9L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tAY9L.png" alt="http://imgur.com/gallery/6lqUK2M/"></a></p> <p>On the other hand, the <a href="http://But%20when%20I%20but%20freshly-press%20api%20it%20works" rel="nofollow noreferrer">Freshy-Pressed Api</a> works, though I don't know why.</p> <p>Here is the HTML and JavaScript I'm using:</p> <pre class="lang-js prettyprint-override"><code>var FPApp = angular.module("FPApp", ["ionic"]); FPApp.service("FPSvc", ["$http", "$rootScope", FPSvc]); FPApp.controller("FPCtrl", ["$scope", "$sce", "$ionicLoading", "$ionicListDelegate", "$ionicPlatform", "FPSvc", FPCtrl]); function FPCtrl($scope, $sce, $ionicLoading, $ionicListDelegate, $ionicPlatform, FPSvc) { $ionicLoading.show({template: "Loading blogs..."}); $scope.deviceReady = false; $ionicPlatform.ready(function() { $scope.$apply(function() { $scope.deviceReady = true; }); }); $scope.blogs = []; $scope.params = {}; $scope.$on("FPApp.blogs", function(_, result) { result.posts.forEach(function(b) { $scope.blogs.push({ name: b.author.name, avatar_URL: b.author.avatar_URL, title: $sce.trustAsHtml(b.title), URL: b.URL, featured_image: b.post_thumbnail.URL }); }); $scope.params.before = result.date_range.oldest; $scope.$broadcast("scroll.infiniteScrollComplete"); $scope.$broadcast("scroll.refreshComplete"); $ionicLoading.hide(); }); $scope.loadMore = function() { FPSvc.loadBlogs($scope.params); } $scope.reload = function() { $scope.blogs = []; $scope.params = {}; FPSvc.loadBlogs(); } $scope.show = function($index) { cordova.InAppBrowser.open($scope.blogs[$index].URL, "_blank", "location=no"); } $scope.share = function($index) { $ionicListDelegate.closeOptionButtons(); window.socialmessage.send({ url: $scope.blogs[$index].URL }); } } function FPSvc($http, $rootScope) { this.loadBlogs = function(params) { $http.get("https://public-api.wordpress.com/rest/v1/sites/100060382/posts/", { params: params}) .success(function(result) { $rootScope.$broadcast("FPApp.blogs", result); }); } } </code></pre> <pre class="lang-html prettyprint-override"><code>&lt;html lang="en" data-ng-app="FPApp"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Document&lt;/title&gt; &lt;!--Setup Cordova--&gt; &lt;meta http-equiv="Content-Security-Policy" content="default-src *;"&gt; &lt;script src="cordova.js"&gt;&lt;/script&gt; &lt;!--Setup Ionic--&gt; &lt;link rel="stylesheet" href="lib/ionic/css/ionic.css"&gt; &lt;script src="lib/ionic/js/ionic.bundle.js"&gt;&lt;/script&gt; &lt;!--Setup Application--&gt; &lt;link rel="stylesheet" href="index.css"&gt; &lt;script src="index.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body data-ng-controller="FPCtrl"&gt; &lt;ion-pane&gt; &lt;div class="bar bar-header bar-energized"&gt; &lt;h1 class="title"&gt;ZahranPress&lt;/h1&gt; &lt;/div&gt; &lt;ion-content class="background"&gt; &lt;ion-refresher pulling-text="Pull" on-refresh="reload()"&gt; &lt;/ion-refresher&gt; &lt;div class="list card" data-ng-repeat="b in blogs"&gt; &lt;div class="item item-avatar"&gt; &lt;img data-ng-src="{{b.avatar_URL}}" alt=""&gt; &lt;h2 data-ng-bind-html="b.title"&gt;&lt;/h2&gt; &lt;p&gt; {{ b.name }} &lt;/p&gt; &lt;/div&gt; &lt;div class="item item-body"&gt; &lt;img data-ng-if="b.featured_image" data-ng-src="{{ b.featured_image }}" alt="" class="full-image"&gt; &lt;/div&gt; &lt;div class="item tabs tabs-secondary tabs-icon-left"&gt; &lt;a class="tab-item" data-ng-click="show($index)"&gt; &lt;i class="icon ion-ios-book"&gt;&lt;/i&gt; Read &lt;/a&gt; &lt;a class="tab-item" data-ng-click="share($index)"&gt; &lt;i class="icon ion-share"&gt;&lt;/i&gt; Share &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;ion-infinite-scroll on-infinite="loadMore()" ng-if="deviceReady"&gt;&lt;/ion-infinite-scroll&gt; &lt;/ion-content&gt; &lt;/ion-pane&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>How do I resolve this problem?</p>
30,335,255
0
<p>You could do something like this:</p> <pre><code>select ID, max(case when CVG = 'A' then 'TRUE' else 'FALSE' end), max(case when CVG = 'B' then 'TRUE' else 'FALSE' end), max(case when CVG = 'C' then 'TRUE' else 'FALSE' end), from table group by ID </code></pre> <p>The case + max will select the true if even one row is found for that ID, otherwise false.</p>
39,576,785
0
Using IF EXISTS with a CTE <p>I want to check if a CTE table has record or null. But I always get error message 'Incorrect syntax near the keyword 'IF'' for the SQL below. Now there is no matching record in ADMISSION_OUTSIDE TABLE. The result of the SQl should print 'NOT OK'. Thanks,</p> <pre><code>WITH ADMISSION_OUTSIDE AS ( ..... ..... ) IF EXISTS (SELECT * FROM ADMISSION_OUTSIDE) PRINT 'OK' ELSE PRINT 'NOT OK' </code></pre>
23,959,623
0
<p>Make the first function call the next one and add this to your HTML :</p> <pre><code> &lt;input&gt; type=button onclick="validateForm(); return false;" &lt;/input&gt; </code></pre> <p>Putting 'return false' will prevent redirection and will give time for your function to execute.</p> <pre><code>function validateForm(){ var email = document.forms["form"]["Email"].value; if(email == null || email == ""){ alert("Email must be filled out"); return false; } else redirect(); } </code></pre> <p>Additionally, I'd recommend to abstain from putting any code in your HTML. It is considered a "bad practice". However, if you still want to put your code, it'll be more appropriate to put it in the form as an "onsubmit" action:</p> <pre><code>&lt;form onsubmit="validateForm()"&gt; </code></pre> <p>If you want the function to execute when the submit button is clicked, you can just add an event listener in your script and an id to your button, like this:</p> <pre><code>var button = document.getElementById("submit"); button.onclick = function validateForm() { /*same code as above..*/ }; </code></pre> <p>Hope it helps!</p>
15,542,878
0
<p>This works fine for me:</p> <pre><code>$q3='SELECT users.uid, users.vr, users.br, AES_DECRYPT(users.nm1,"123") AS nm1, AES_DECRYPT(users.nm2,"123") AS nm2, AES_DECRYPT(users.nm3,"123") AS nm3, ussys.ty1, ussys.ty3 FROM users,ussys WHERE users.uid=ussys.uid ORDER BY nm1 DESC '; </code></pre> <p>It sorts nicely on nm1, giving me Zack-Willeke-Victor-Roiwan-Plop-Kwab-Krab-Karel-Johannes-Harry-Gerard-Dirk-Cornelis-Bernard-Anton as a result.</p>
38,288,304
0
Advice about INSERT statement performance in SQL Server <p>I need to generate random numbers in SQL Server and write these codes into the table. I used the SQL statement as follows:</p> <pre><code>while (select count(code) from tb_random) &lt;1000000 begin SET NOCOUNT ON declare @r int set @r = rand()*10000000 insert into tb_random values(@r) end </code></pre> <p>It takes over 20h to complete this query. Could you give me an idea to solve this performance problem?</p>
15,622,381
0
<p>An alternative solution might be to create a database view on table1, with a field called something like <code>title_Name</code> (defined as table1.Name for version #1, and as table1.title for version #2), and use the database view instead of table1 in your query, joined like so:</p> <pre><code>INNER JOIN table3 t3 on t1.title_Name = t3.Name </code></pre>
26,412,956
0
<p>This worked for me on a CentOS/Plesk server:</p> <p>mysql_upgrade -uadmin -p<code>&lt; /etc/psa/.psa.shadow</code> -f</p> <p>service mysqld restart</p> <p><a href="http://kb.sp.parallels.com/en/427" rel="nofollow">http://kb.sp.parallels.com/en/427</a></p>
16,919,086
0
Figuring out an offset in assembly with OllyDBG <p>Relevant assembly:</p> <pre><code>$ &gt; 94D3A705 PUSH hw.05A7D394 ; ASCII "glBegin" $+5 &gt; E8 99C80500 CALL &lt;JMP.&amp;SDL2.SDL_GL_GetProcAddress&gt; $+A &gt; 83C4 04 ADD ESP,4 $+D &gt; A3 04E03B06 MOV DWORD PTR DS:[63BE004],EAX $+12 &gt; 8B0D 04E03B06 MOV ECX,DWORD PTR DS:[63BE004] ; OPENGL32.glBegin $+18 &gt; 890D 38E83B06 MOV DWORD PTR DS:[63BE838],ECX </code></pre> <p>The first line pushes a string address onto stack as function argument. And the last line copy's value from ECX to this DWORD data object. This address is my target. I want to replace the containing DWORD value.</p> <p>In my C++ code I first obtain the address for the first line's push function and then I add an offset. By adding the offset 0x1A the code works, but when I try adding + 0x18 then it doesn't work.</p> <p>I don't fancy testing this for every function, what is the underlying idea that I'm missing?</p>
22,786,300
0
Give limited access to android app using Phonegap <p>I have created an android app using phonegap. I want to run the app to limit its usage to only 5 times means user can open this app only for 5 times after that user will not be able to open it instead it will show a message.</p> <p>How can i do this ?</p>
11,532,882
1
Show progress while running python unittest? <p>I have a very large TestSuite that I run with <code>TextTestRunner</code> from the python unittest framework. Unfortunately I have no idea how many tests are already done while the test are running.</p> <p>Basically I'd like to convert this output:</p> <pre><code>test_choice (__main__.TestSequenceFunctions) ... ok test_sample (__main__.TestSequenceFunctions) ... ok test_shuffle (__main__.TestSequenceFunctions) ... ok ---------------------------------------------------------------------- Ran 3 tests in 0.110s OK </code></pre> <p>to</p> <pre><code>[1/3] test_choice (__main__.TestSequenceFunctions) ... ok [2/3] test_sample (__main__.TestSequenceFunctions) ... ok [3/3] test_shuffle (__main__.TestSequenceFunctions) ... ok ---------------------------------------------------------------------- Ran 3 tests in 0.110s OK </code></pre> <p>Do I have to subclass <code>TextTestRunner</code> to achieve this and if yes, how?</p> <p><em>Note: I'm aware of nose and the available plugins, but it does not quite fit in my application and I'd like to avoid the dependency.</em></p> <p><strong>EDIT</strong> Why I'd like to avoid <em>nose</em>:</p> <p>My Application is basically an additional framework for the tests. It select the correct test cases, provides library functions for them and executes the tests multiple times for long term testing. (the tests run against an external machine)</p> <p>So here is how I run my tests right now:</p> <pre><code># do all sort of preperations [...] test_suite = TestSuite() repeatitions = 100 tests = get_tests() for i in range(0, repeatitions): test_suite.addTests(tests) TextTestRunner(verbosity=2).run(test_suite) </code></pre> <p>My problem with nose is, that it is designed to discover the tests from the filesystem and I was unable to find a clear documentation how to run it on a particular TestSuite directly from python.</p>
35,035,440
0
<p>Try this:</p> <pre><code>div class="container slideshowContainer" style="width: 100%;"&gt; &lt;!-- BEGIN REVOLUTION SLIDER --&gt; &lt;div class="fullwidthbanner-container slider-main margin-bottom-10"&gt; &lt;div class="fullwidthabnner"&gt; &lt;ul id="revolutionul" style="display:none;"&gt; &lt;!-- OUTPUT THE SLIDES --&gt; &lt;?php shuffle($slides); foreach($slides as $d){ ?&gt; &lt;li data-transition="fade" data-slotamount="8" data-masterspeed="700" data-delay="9400" data-thumb="assets/img/sliders/revolution/thumbs/thumb2.jpg"&gt; &lt;?php if($d['slideshow_image_sub_title_4'] != ""){ ?&gt; &lt;a href="&lt;?php echo $d['slideshow_image_sub_title_4']; ?&gt;"&gt; &lt;img src="uploads/images/&lt;?php echo $d['slideshow_image_file']; ?&gt;" title="&lt;?php echo $d['slideshow_image_title']; ?&gt;" style="width: 100%;" /&gt; &lt;/a&gt; &lt;?php } else { ?&gt; &lt;img src="uploads/images/&lt;?php echo $d['slideshow_image_file']; ?&gt;" title="&lt;?php echo $d['slideshow_image_title']; ?&gt;" style="width: 100%;" /&gt; &lt;?php } ?&gt; &lt;/li&gt; &lt;?php } ?&gt; &lt;/ul&gt; &lt;div class="tp-bannertimer tp-bottom"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- END REVOLUTION SLIDER --&gt; &lt;/div&gt; </code></pre> <p><a href="http://php.net/manual/de/function.shuffle.php" rel="nofollow">http://php.net/manual/de/function.shuffle.php</a></p>
20,382,107
0
Creating library project and integrating into existing project in android <p>I have an application that has got two basic screens, a home page and a sliding drawer menu fragment to the left of home page like the facebook sliding drawer. Now I am planning to create another page to the right of the home page that appears by sliding to the other side. i would like to create this as a library project and just import it to the existing project. how can I do this. I need to display the the new menu drawer on sliding after adding the library project. How can I achieve this ? That is, I will be having a fragment in the library project that populates data by all necessary api calls from server, and I need to inflate the fragment by sliding in the main project.</p>
3,187,810
0
How to build cross-IDE java GUI's using "interface builders"? <p>In a Java project with developers that use different IDEs, say Eclipse and IntelliJ, what's the best way of developing visual components using the tools offered by the IDEs ("<a href="http://eclipse.org/vep/" rel="nofollow noreferrer">Visual Editor Project</a>" for Eclipse and "<a href="http://www.jetbrains.com/idea/features/gui_builder.html" rel="nofollow noreferrer">Swing GUI Designer</a>" for IntelliJ)?</p> <p>If a developer using Eclipse needs to make changes to a GUI written by another developer in IntelliJ (and vice versa) he will have quite a hard time and maybe even make the code incompatible with the original tool that built it.</p> <p>Is there a solution or do all developer just need to use the same tool?</p>
5,323,317
0
<pre><code>package fileHandling; import java.io.File; import javax.swing.JFileChooser; import java.awt.BorderLayout; import java.awt.Color; import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.UIManager; import com.lowagie.text.Font; public class CreateNFiles extends JFrame implements ActionListener { JLabel lblFileName,lblNoOfPagesInPdf,lblPathToSave,lblExtension,lblError,lblHeading; JTextField txtFileName,txtNoOfPagesInPdf,txtPathToSave,txtExtension; JButton btnSubmit,btnBrowse; JPanel mainPanel,gridPanel; GridBagConstraints gbc; JDialog jdBrowse; int total; String absoluteFileName; String fileName; java.awt.Font textFont; CreateNFiles() { setLayout(new FlowLayout()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(500,400); setLocationRelativeTo(null); setVisible(true); initializeObjects(); addObjectsToFrame(this); } public void initializeObjects() { textFont=new java.awt.Font("TimesRoman",Font.BOLD + Font.ITALIC,15); lblFileName=new JLabel("File Name : "); lblFileName.setFont(textFont); lblNoOfPagesInPdf=new JLabel("No of Pages : "); lblNoOfPagesInPdf.setFont(textFont); lblPathToSave=new JLabel("Path To Save : "); lblPathToSave.setFont(textFont); lblExtension=new JLabel("Extension : "); lblExtension.setFont(textFont); lblError=new JLabel(""); lblError.setVisible(false); lblHeading=new JLabel("~~ Blank File Automatic ~~"); lblHeading.setFont(textFont); lblHeading.setForeground(Color.BLUE); lblHeading.setVisible(true); txtFileName=new JTextField(10); txtNoOfPagesInPdf=new JTextField(10); txtPathToSave=new JTextField(20); txtExtension=new JTextField(10); btnSubmit=new JButton("Submit"); btnSubmit.addActionListener(this); btnBrowse=new JButton("Browse"); btnBrowse.addActionListener(this); mainPanel=new JPanel(new BorderLayout()); gridPanel=new JPanel(new GridBagLayout()); gbc=new GridBagConstraints(); gbc.insets=new Insets(10,10,10,10); jdBrowse=new JDialog(); } public void addObjectsToFrame(CreateNFiles frame) { frame.setLayout(new FlowLayout()); gbc.gridx=0; gbc.gridy=0; gridPanel.add(lblFileName,gbc); gbc.gridx=1; gbc.gridy=0; gridPanel.add(txtFileName,gbc); gbc.gridx=0; gbc.gridy=1; gridPanel.add(lblNoOfPagesInPdf,gbc); gbc.gridx=1; gbc.gridy=1; gridPanel.add(txtNoOfPagesInPdf,gbc); gbc.gridx=0; gbc.gridy=2; gridPanel.add(lblPathToSave,gbc); gbc.gridx=1; gbc.gridy=2; gbc.gridwidth=2; gridPanel.add(txtPathToSave,gbc); gbc.gridx=3; gbc.gridy=2; gbc.gridwidth=1; gridPanel.add(btnBrowse,gbc); gbc.gridx=0; gbc.gridy=3; gridPanel.add(lblExtension,gbc); gbc.gridx=1; gbc.gridy=3; gridPanel.add(txtExtension,gbc); gbc.gridx=1; gbc.gridy=4; gridPanel.add(btnSubmit,gbc); gbc.gridx=0; gbc.gridy=5; gbc.gridwidth=4; gridPanel.add(lblError,gbc); frame.add(lblHeading,BorderLayout.PAGE_START); mainPanel.add(gridPanel,BorderLayout.CENTER); frame.add(gridPanel); frame.setVisible(true); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } catch(Exception e) { System.out.println("Exception : "+e); } CreateNFiles obj=new CreateNFiles(); } public void actionPerformed(ActionEvent ae) { if (ae.getActionCommand().equals("Submit")) { System.out.println("Button1 has been clicked"); process(); } else if (ae.getActionCommand().equals("Browse")) { System.out.println("Button1 has been clicked"); try { JFileChooser fileChooser = new JFileChooser(); fileChooser.setCurrentDirectory(new java.io.File(".")); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setAcceptAllFileFilterUsed(false); int returnValue = fileChooser.showOpenDialog(null); if (returnValue == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); txtPathToSave.setText(fileChooser.getSelectedFile().getAbsolutePath()); System.out.println(fileChooser.getCurrentDirectory()); } } catch(Exception ex) { System.out.println(ex.getMessage()); } } } public void process() { try { String ext=null; String path; fileName=txtFileName.getText(); total=Integer.parseInt(txtNoOfPagesInPdf.getText()); ext=txtExtension.getText(); path=txtPathToSave.getText(); for(int i=0;i&lt;total*2;i++) { if(i%2==0) { absoluteFileName=path+"\\"+fileName+(i/2)+'.'+ext; } else { absoluteFileName=path+"\\"+fileName+(i/2)+"A"+"."+ext; } File file=new File(absoluteFileName); try { file.createNewFile(); } catch(Exception e) { System.out.println(e.getMessage()); } System.out.println("Parent :: "+file.getAbsolutePath()); System.out.println("Parent :: "+file.getParent()); } } catch(Exception ae) { System.out.println(ae.getMessage()); lblError.setVisible(true); lblError.setText("Error :- "+ae.getMessage()); lblError.setFont(textFont); lblError.setForeground(Color.red); } } } </code></pre>
27,059,950
0
<p>Your only option in JSON for a null value is <code>null</code>. <code>""</code> isn't null, it's an empty string. <code>{}</code> is an empty object. <code>[]</code> is an empty array. I would use those where it was appropriate to have empty strings, objects, or arrays, but for null I'd use <code>null</code>.</p> <p>I don't like just leaving the property off entirely (which is what I think you mean by #3), because I prefer that the JSON structure be clear even when a value is omitted. But that's a subjective response, and people can have different opinions about it.</p>
4,184,920
0
git cherry-pick -x: link in details instead of in summary <p>Given a commit with the message "foo", i.e. with only a summary part, I do <code>git cherry-pick -x the_commit</code>. The result is a new commit with message <pre>foo<br>(cherry picked from commit eb42a6475d2c2e4fff7a1b626ce6e27eec21e886)</pre> Now that's not good, because it is a two-line summary, which seems like a bug in git.</p> <p>But how can I make git make the comment look like below without editing the comment manually?</p> <pre>foo<br><br>(cherry picked from commit eb42a6475d2c2e4fff7a1b626ce6e27eec21e886)</pre>
26,779,700
0
<p>Make MyClass <strong>Parcelable</strong>. See example below.</p> <pre><code>public class MyClass implements Parcelable { private int mData; public int describeContents() { return 0; } public void writeToParcel(Parcel out, int flags) { out.writeInt(mData); } public static final Parcelable.Creator&lt;MyParcelable&gt; CREATOR = new Parcelable.Creator&lt;MyParcelable&gt;() { public MyParcelable createFromParcel(Parcel in) { return new MyParcelable(in); } public MyParcelable[] newArray(int size) { return new MyParcelable[size]; } }; private MyParcelable(Parcel in) { mData = in.readInt(); } } // Send it using ArrayList&lt;MyClass&gt; list; intent.putParcelableArrayListExtra("list", list); </code></pre>
35,386,773
0
PHP Related items from database <p>I have been googling for a while and searching SO but I still can't find an answer.</p> <p>So my problem is that I want to pull related content from mySQL database on what id is currently being displayed on the page. In the database I have a column dedicated to keywords, and I am using the LIKE query to pull id's based on those keywords. However, I get only one id because the LIKE query looks at the keyword literally. For example, keyword1 = 'apples berries oranges' is not the same as keywords2 = 'apples' 'berries' 'oranges'. I want the latter so it can pull in more related data.</p> <p>I also think I may be approaching this wrong, but I don't know any other way to pull related items.</p> <p>Here's my code...</p> <pre><code>&lt;?php include 'data/data_connect.php'; if ($sugg_qs = $db-&gt;query("SELECT * FROM questions WHERE keywords LIKE '$keywords' LIMIT 4")) { if ($q_count = $sugg_qs-&gt;num_rows) { echo $q_count; while($row = $sugg_qs-&gt;fetch_assoc()) { echo $row-&gt;title; } $sugg_qs-&gt;free(); } else { die('error'); } } else { die('error'); } ?&gt; </code></pre> <hr> <p>UPDATE</p> <pre><code>if ($sugg_qs = $db-&gt;query("SELECT * FROM questions WHERE keywords LIKE CONCAT('%', '$keywords' ,'%') LIMIT 3")) { if ($q_count = $sugg_qs-&gt;num_rows) { $row = $sugg_qs-&gt;fetch_all(MYSQLI_ASSOC); foreach ($row as $rows) { echo $rows['title']; } } else { die('error'); } </code></pre> <p>This code does work with id's that only have one keyword. So I guess a possible (but undesired) solution would be to create a new column for each new keyword and use LIKE for each keyword.</p> <p>Is there a way to avoid creating more columns?</p> <p>THANKS for those who helped already :)</p> <hr> <p>FINAL UPDATE? Ok. So I figured it out in probably the messiest way to write code, but apparently it works for me. So first of all I standardized my table where each element is limited to only 5 keywords and 1 category. So in the query I call for items with similar keywords, and if there aren't similar results I then call for items from the same category from the original item. </p> <p>Here is the (messy) code for those looking for a solution!</p> <pre><code>$q_kw_arr = explode(' ', $keywords); if ($sugg_qs = $db-&gt;query("SELECT keywords, category, title FROM questions WHERE keywords LIKE CONCAT('%', '$q_kw_arr[0]' ,'%') OR CONCAT('%', '$q_kw_arr[1]' ,'%') OR CONCAT('%', '$q_kw_arr[2]' ,'%') OR CONCAT('%', '$q_kw_arr[3]' ,'%') OR CONCAT('%', '$q_kw_arr[4]' ,'%') OR category= '$category' LIMIT 4")) { if ($q_count = $sugg_qs-&gt;num_rows) { $row = $sugg_qs-&gt;fetch_all(MYSQLI_ASSOC); foreach ($row as $rows) { echo $rows['title']; } } else { echo 'error'; } } </code></pre> <p>SPECIAL THANKS TO..</p> <p>Terminus, Grzegorz J, and infidelsawyer</p>
39,168,883
0
A kernel module to transparently detour packets coming from a NIC and TCP application. Is it possible to make it done? <p>Is it possible for a Linux kernel module to transparently detour the packet coming from upper layer (i.e. L2,L3) and NIC? For example, <strong>1)</strong> a packet arrives from a NIC, the module gets the packet (do some processing on it) and delivers back to tcp/ip stack or <strong>2)</strong> an app sends data, the module gets the packet (do some processing) and then, delivers the packet to an output NIC.</p> <p>It is not like a sniffer, in which a copy of the packet is captured while the actual packet flow continues. </p> <p>I thought on some possibilities to achieve my goal. I thought in registering a <strong>rx_handler</strong> in the kernel to get access to the incoming packets (coming from a NIC), but how to delivers back to the kernel stack? I mean, to allow the packet to follow the path that it should have taken without the module in the middle.</p> <p>Moreover, let's say an app is sending a packet through TCP protocol. How the module could detour the packet (to literally get the packet)? Is it possible? In order to send it out through the NIC, I think <strong>dev_queue_xmit()</strong> does the job, but I'm not sure.</p> <p>Does anyone know a possible solution? or any tips? </p> <p>Basically, I'd like to know if there is a possibility to put a kernel module between the NIC and the MAC layer.. or in the MAC layer to do what I want. In positive case, does anyone has any hint like main kernel functions to use for those purposes?</p> <p>Thanks in advance. </p>
25,833,139
0
XML serialize - remove first default tag <p>I have the following class:</p> <pre><code>public class RecordDTO { public int TabIndex { get; set; } public int TaxYear { get; set; } } </code></pre> <p>I serialize an instance of the class: </p> <pre><code> System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(record.GetType()); string xmlstring = null; using (StringWriter writer = new StringWriter()) { x.Serialize(writer, record); xmlstring = writer.ToString(); } </code></pre> <p>The result is:</p> <pre><code> "&lt;?xml version="1.0" encoding="utf-16"?&gt; &lt;RecordDTO xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;TabIndex&gt;1&lt;/TabIndex&gt; &lt;TaxYear&gt;2014&lt;/TaxYear&gt; &lt;/RecordDTO&gt;" </code></pre> <p><strong>I want the first row</strong> <code>(&lt;?xml version="1.0" encoding="utf-16"?&gt;)</code> <strong>to not be created at the xmlstring.</strong> <strong>What should I do?</strong></p> <p><strong>About the 'duplicate' claim of rene, Unihedron, Infinite Recursion, har07, Athari: The other question use xmlWriter, and I need stringWriter. If you have way to do it by stringWriter; or you have a way to use xmlWriter and accept string - you can tell about.</strong></p>
40,714,106
0
Browsing and displaying pdf on html page not working in IE <p>I am using the following code to browse and display pdf file on the html. Its working in chrome but not in IE. Iam using iframe to show pdf. </p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;link class="jsbin" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css" rel="stylesheet" type="text/css" /&gt; &lt;script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&gt;&lt;/script&gt; &lt;script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"&gt;&lt;/script&gt; &lt;meta charset=utf-8 /&gt; &lt;script&gt; function readURL(input) { if (input.files &amp;&amp; input.files[0]) { var reader = new FileReader(); reader.onload = function (e) { // document.getElementById("blah").setAttribute('data', e.target.result); $('#blah') .attr('data', e.target.result) .width(150) .height(200); }; // alert("after attaching"); reader.readAsDataURL(input.files[0]); } } &lt;/script&gt; &lt;title&gt;JS Bin&lt;/title&gt; &lt;!--[if IE]&gt; &lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt; &lt;![endif]--&gt; &lt;style&gt; article, aside, figure, footer, header, hgroup, menu, nav, section { display: block; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;input type='file' onchange="readURL(this)"/&gt; &lt;object id="blah" data=""&gt;&lt;/object&gt; &lt;!-- &lt;div id="pdf"&gt; &lt;iframe src="http://www.oracle.com/events/global/en/java-outreach/resources/java-a-beginners-guide-1720064.pdf" id="blah" style="width: 100%; height: 100%;" frameborder="0" scrolling="no"&gt; &lt;p&gt;It appears your web browser doesn't support iframes.&lt;/p&gt; &lt;/iframe&gt; &lt;/div&gt; --&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I was using Object tag for attaching later on i changed to iframe for IE compactibility</p>
2,404,961
0
<p>If .NET 4 is an option, I'd strongly recommend having a look at the <a href="http://msdn.microsoft.com/en-us/library/dd267265(VS.100).aspx" rel="nofollow noreferrer"><code>ConcurrentQueue&lt;T&gt;</code></a> and possibly even wrapping it with a <a href="http://msdn.microsoft.com/en-us/library/dd267312(VS.100).aspx" rel="nofollow noreferrer"><code>BlockingCollection&lt;T&gt;</code></a> if that suits your needs.</p>
18,990,548
0
<p>I have found solution of my question's</p> <pre><code>@hotels = [] hotels.map{|hotel| @hotels &lt;&lt; hotel unless @hotels.map(&amp;:id).include? hotel.id} </code></pre> <p>and now <code>@hotels.map(&amp;:id)</code> return <code>[42, 47, 48, 41, 43, 39, 40, 44, 46, 45]</code></p>
4,631,584
0
<p>It seems to be the file <code>C:\Users\%USER%\AppData\LocalLow\Sun\Java\Deployment\deployment.properties</code> where the command line arguments are stored.</p> <p>Adding <code>test123</code> in the command line arguments changes the file to the following:</p> <pre><code>deployment.javaws.jre.1.location=http\://java.sun.com/products/autodl/j2se deployment.javaws.jre.1.args=test123 deployment.javaws.jre.1.enabled=true deployment.javaws.jre.1.registered=true deployment.javaws.jre.1.product=1.6.0_22 deployment.javaws.jre.1.path=C\:\\Program Files\\Java\\jre6\\bin\\javaw.exe deployment.javaws.jre.1.osarch=amd64 deployment.javaws.jre.1.osname=Windows deployment.javaws.jre.1.platform=1.6 </code></pre> <p>At least, I can manually edit the file and the changes show up in the Java Control Panel. The file's documentation can be found <a href="http://download.oracle.com/javase/6/docs/technotes/guides/deployment/deployment-guide/properties.html">here</a>.</p>
25,186,621
0
<p>This is a good example to use negative lookbehind, you can use this regex to get the content you want:</p> <pre><code>”.*?(?&lt;!\\)” </code></pre> <p><strong><a href="http://regex101.com/r/fB6dP2/1" rel="nofollow noreferrer">Working demo</a></strong></p> <p>Using capturing groups you can grab those strings:</p> <pre><code>(”.*?(?&lt;!\\)”) </code></pre> <p><img src="https://i.stack.imgur.com/K44gi.png" alt="enter image description here"></p> <p>Here is the matches</p> <pre><code>MATCH 1 1. [4-41] `”aaaa\”bbbbb\”ccccccc\”ddddd\”eeeeee”` MATCH 2 1. [46-80] `”ffffff\”ggggg\”hhhh\”iiiii\”jjjj”` </code></pre> <p>Then you can apply the logic you want on this strings.</p>
36,689,974
0
<pre><code>for (int i = 0; i &lt; PersonalIdentityNumber.Count &amp;&amp; i &lt; PostNr.Count; i++) </code></pre> <p>The best would be to create an object with all properties and create an array of these objects. Some times one of the properties can be null.</p>
5,866,204
0
<p>Given definition for all the classes Node, FoodSource etc is available, you need to do at least the following:</p> <p>1) Move the function definition to .h file</p> <p>2) The first line in main function is ambigous. It should be rewritten as <code>Catalog&lt;FoodSource&gt; test;</code> because <code>Catalog&lt;FoodSource&gt; test()</code> will be treated as function prototype</p>
29,114,889
0
<p>Most likely the folder variable is null - if the folder does not exist, retrieving it by name (<code>RDOFolder.Folders.Item("foldername"))</code> will return null:</p> <pre><code>RDOSession session = new RDOSession(); RDOPstStore store = session.LogonPstStore(newpstpath); RDOFolder folder = store.IPMRootFolder.Folders.Item(directoryEmlFile); if (folder == null) folder = store.IPMRootFolder.Folders.Add(directoryEmlFile); RDOMail mail = folder.Items.Add("IPM.Note"); </code></pre>
2,879,490
0
<p>You can have a forth 'lib' main Git repo, with:</p> <ul> <li><code>lib/vendor/package</code> content</li> <li>3 <strong>submodules</strong> (see "<a href="http://stackoverflow.com/questions/1979167/git-submodule-update/1979194#1979194">true nature of submodules</a>")</li> </ul> <p>But this reference is totally independent from any 'svn:external' property you may have setup in a mirror SVN repo.</p> <p>So if you have 3 SVN repos already, you can <code>git-svn</code> them, publish them on GitHub, and then create a fourth repo on GitHub in which you will add those 3 Git repos as submodules, following the <a href="https://git.wiki.kernel.org/index.php/GitSubmoduleTutorial" rel="nofollow noreferrer">submodules tutorial</a> (supposing here you have all 4 repos already on GitHub)</p> <pre><code>$ mkdir -p lib/vendor/package $ cd lib/vendor/package $ for package in a b c d; do $ git submodule add git://github.com/path/to/$package.git $package $ done $ cd .. $ git commit -m "lib with submodules" $ git push </code></pre>
37,165,971
0
How to create a strict 4-digit PIN input in plain JavaScript? <p>I'm trying to create a PIN input, wherein the user may only use 4 digits.</p> <p>In my code, I have managed to exclude A-Z and any other keys like curly braces, colons and so on, but I have faced some trouble with excluding the special characters (shift + 0-9).</p> <p>Regarding the length, I have successfully set it to 4, but if 4 is reached and one wants to delete it doesn't go past 3.</p> <p>My code:</p> <pre><code>var pin = document.forms.RegForm.pin; pin.onkeydown = function(key) { var allowedkeys = [], auxkeys = [8, 13, 17, 18, 46], specChars = "!@#$%^&amp;*()", keypressed = String.fromCharCode(key.which); allowedkeys.push(auxkeys); for (var i = 37; i &lt; 41; i++) allowedkeys.push(i); for (var i = 48; i &lt; 58; i++) allowedkeys.push(i); for (var i = 96; i &lt; 106; i++) allowedkeys.push(i); if (this.value.length &lt;= 3) { if (specChars.indexOf(keypressed) !== -1 || (key.which &lt; 48 || key.which &gt; 57) &amp;&amp; (key.which &lt; 96 || key.which &gt; 105)) key.preventDefault(); } else { if (auxkeys.indexOf(key.which) === -1) return false; } }; </code></pre> <p>I know the length can easily be done with maxlength = "4" in HTML, but for the purpose of getting to know JavaScript better, I would prefer an 'in JavaScript' solution.</p> <p>Should you provide an answer or a link to a similar question, if there is one, I would appreciate it. Fiddle: <a href="https://jsfiddle.net/qn968nhm/1/" rel="nofollow">https://jsfiddle.net/qn968nhm/1/</a></p>
22,920,020
0
Dojo ToggleButton Check Icon doesn't update <p>I am defining a toggle button in HTML and then updating it's checked state in JavaScript based on another toggle button.</p> <p>Toggle Button: <code>&lt;input type="checkbox" dojoType="dijit.form.ToggleButton" iconClass="dijitCheckBoxIcon" label="Assigned Work" id="AssignedWork" &gt;</code> </p> <p>When the app runs I want this toggle button to be un-checked. </p> <p>I can successfully call the checked property like this: </p> <p><code>Registry.byId("AssignedWork").checked = true;</code></p> <p>However my toggle button's icon isn't updating to indicate the "Check". When my mouse cursor hovers over the toggle button the button refreshes and shows the check mark. Is there a way to get the check icon to turn on with the .checked property?</p>
621,422
0
<p>You could take a look at <a href="http://www.aquafold.com/" rel="nofollow noreferrer">Aqua Data Studio</a>.</p>
37,663,764
0
Instagram api sandbox allowed or not <p>Which endpoints are allowed in just sandbox before approval process? I read about the "extended" permissions you can request after approval..but seem's like follower list and users/search?q= is not working. </p> <p>So how am I supposed to show them a screencast/video of my app working required for the approval? I have 2 sandbox users I'm testing with..</p>
34,236,365
0
<p><code>void checkCollisions();</code> (in <code>moveBalls</code>) is a function prototype, not a function call. Remove the <code>void</code>.</p>
17,444,285
0
<p>The best way to do this is to use something like <a href="http://nuget.org/packages/MoreLinq.Source.MoreEnumerable.Batch/" rel="nofollow">the <code>Batch</code> method from <code>MoreLinq</code></a>.</p> <p>This lets you partition the items in a sequence into batches of a specified size.</p> <p>If you want a simple approach which doesn't need to be threadsafe (i.e. you don't need to use it with <code>Parallel.ForEach()</code> for example) then you can use the following extension method.</p> <p>It has the advantage that you can produce all the batches without calling Skip multiple times:</p> <pre><code>public sealed class Batch&lt;T&gt; { public readonly int Index; public readonly IEnumerable&lt;T&gt; Items; public Batch(int index, IEnumerable&lt;T&gt; items) { Index = index; Items = items; } } public static class EnumerableExt { // Note: Not threadsafe, so not suitable for use with Parallel.Foreach() or IEnumerable.AsParallel() public static IEnumerable&lt;Batch&lt;T&gt;&gt; Partition&lt;T&gt;(this IEnumerable&lt;T&gt; input, int batchSize) { var enumerator = input.GetEnumerator(); int index = 0; while (enumerator.MoveNext()) yield return new Batch&lt;T&gt;(index++, nextBatch(enumerator, batchSize)); } private static IEnumerable&lt;T&gt; nextBatch&lt;T&gt;(IEnumerator&lt;T&gt; enumerator, int blockSize) { do { yield return enumerator.Current; } while (--blockSize &gt; 0 &amp;&amp; enumerator.MoveNext()); } } </code></pre> <p>And you use it like:</p> <pre><code> var items = Enumerable.Range(100, 510); // Pretend we have 50 items. int itemsPerPage = 20; foreach (var page in items.Partition(itemsPerPage)) { Console.Write("Page " + page.Index + " items: "); foreach (var i in page.Items) Console.Write(i + " "); Console.WriteLine(); } </code></pre> <p>But if you need threadsafe partitioning, use the MoreLinq Batch method I linked above.</p>
20,535,653
0
Resuse of Async task code in my various file <p>I want to create an class file for Async task operation and from creating the object of that class file i want to access these method of async task with no of different class files with different parameters. </p> <p><strong>Methods of Async task include:-</strong></p> <p><strong>OnPreExecute()</strong>-Want to start progress dialog same for each class.</p> <p><strong>doInbackground()</strong>-Want to perform background operation(like getting data from server) means passing parameter different for each class. </p> <p><strong>onPostExecute()</strong>-Dismiss the progress dialog and update the UI differnt for each class.</p> <p>Nw i m writing the async task in my every class as inner class like following:-</p> <pre><code>class loaddata extends AsyncTask&lt;String, String, String&gt; { @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(AddNewLineitem.this); pDialog.setMessage("Loading Data. Please wait..."); pDialog.setIndeterminate(false); pDialog.setCancelable(true); pDialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { } }); pDialog.show(); } @Override protected String doInBackground(String... params) { try { List&lt;NameValuePair&gt; params1 = new ArrayList&lt;NameValuePair&gt;(); JSONObject json = jparser.makeHttpRequest(url_foralldropdowns, "GET", params1); compoment = json.getJSONArray(COMPONENT_CODE); for (int i = 1; i &lt; compoment.length(); i++) { JSONObject c = compoment.getJSONObject(i); String code = c.getString(CODE); list_compoment.add(code); } } catch (Exception e) { e.printStackTrace(); } return null; } protected void onPostExecute(String file_url) { loadSpinnerData(); pDialog.dismiss(); } } </code></pre> <p>And JSON parser class is as follows:-</p> <pre><code>public class JSONParser { static InputStream is = null; static JSONObject jObj = null; static String json = ""; // constructor public JSONParser() { } // function get json from url // by making HTTP POST or GET mehtod public JSONObject makeHttpRequest(String url, String method, List&lt;NameValuePair&gt; params) { // Making HTTP request try { // check for request method if (method == "POST") { // request method is POST // defaultHttpClient DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); httpPost.setEntity(new UrlEncodedFormEntity(params)); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); } else if (method == "GET") { // request method is GET DefaultHttpClient httpClient = new DefaultHttpClient(); String paramString = URLEncodedUtils.format(params, "utf-8"); url += "?" + paramString; HttpGet httpGet = new HttpGet(url); HttpResponse httpResponse = httpClient.execute(httpGet); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { BufferedReader reader = new BufferedReader(new InputStreamReader( is, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); json = sb.toString(); } catch (Exception e) { Log.e("Buffer Error", "Error converting result " + e.toString()); } // try parse the string to a JSON object try { jObj = new JSONObject(json); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data " + e.toString()); } // return JSON String return jObj; } } </code></pre> <p>And in oncreate() i call this and it works fine:-</p> <pre><code>new loaddata().execute(); </code></pre> <p>Please Help yourself..Thanks in advance</p>
31,148,509
0
<p>Those are <a href="https://gcc.gnu.org/onlinedocs/cpp/Macros.html" rel="nofollow">macros</a> declarations.</p> <p>Whenever you have <code>lowByte(0x1234)</code> in your code, it will be replaced with the right part of the macro, substituting arguments with their values, that is <code>((uint8_t) ((0x1234) &amp; 0xff))</code>.</p> <p>This step is performed by the <a href="https://en.wikipedia.org/wiki/C_preprocessor" rel="nofollow">preprocessor</a> prior to compilation.</p>
22,944,451
0
<p>You can always render some widgets in places specific to your layout using </p> <pre><code>{{ form_widget(delete_form.yourWidgetName) }} </code></pre> <p>and then let Symfony complete the form with </p> <pre><code>{{ form_rest(delete_form) }} </code></pre>
13,154,824
0
<p>try using css <code>:hover</code></p> <pre><code>​ul li:hover{ color: black; font: 14px; font-weight: bold; }​ </code></pre>
31,659,043
0
BSoD on vagrant up (KMODE_EXCEPTION_NOT_HANDLED) - Windows 8 <p>I have a problem with <code>Vagrant</code>, trying to initialize a <code>virtualbox</code> with <code>laravel/homestead</code> box.</p> <p>I have installed latest version of <code>Vagrant (1.7.4)</code> on my Windows 8 OS. I have installed Oracle VirtualBox 5.5.0.</p> <p>Then I did this in windows Command Prompt:</p> <p><code>vagrant add box laravel/homestead</code> to add the laravel homestead box</p> <p><code>vagrant init laravel/homestead</code></p> <p>and</p> <p><code>vagrant up</code></p> <p>After <code>vagrant up</code> somewhere in the process the system fails with BSoD (KMODE_EXCEPTION_NOT_HANDLED)</p> <p>Any ideas of what i could have done wrong, or have anybody experienced this problem?</p> <p>Thank you!</p>
38,755,095
0
<p>Instead of increasing the indentation level with each request, you can return the request to the original promise chain and add a <code>then</code> there. Like this:</p> <pre><code>fetchUserById = function(id) { var user = {}; return knex_instance('user_info').where('id', id).first() .then(function(data) { if (!data) return null; user.info = data; return knex_instance('user_table').where('id', id).first(); }) .then(function(values) { if (!values) return null; user.values = values; return user; }); .catch(errorHandler('fetchUserById', id)); } </code></pre> <p>Problem with this approach, the <code>null</code> that can be returned by the first <code>then</code> must be passed through the second one (and the third, fourth, etc, if you had some). An alternate method would have been to use exceptions instead of returning null:</p> <pre><code>fetchUserById = function(id) { var user = {}; return knex_instance('user_info').where('id', id).first() .then(function(data) { if (!data) throw "NO_USER_INFO"; user.info = data; return knex_instance('user_table').where('id', id).first(); }) .then(function(values) { user.values = values; return user; }); .catch(function(err) { if (err==="NO_USER_INFO") return null; else return errorHandler('fetchUserById', id); } } </code></pre>
31,544,880
0
cant use variable counter inside loop <p>I have database connected to my app in vb.net</p> <p>if i want to get the value from any row or column i use this code and it's work fine</p> <pre><code>DataGridView1.Rows(1).Cells(1).Value.ToString </code></pre> <p>my problem is i have table contain 14 row and i want to make loop to check the first cell in every row if it's contain specific value to do other task</p> <p>if i use the variable i in counter i got an error </p> <p>in this code</p> <pre><code> Private Sub Button24_Click(sender As Object, e As EventArgs) Handles Button24.Click Dim see As String For i As Int32 = 0 To 14 see = DataGridView1.Rows(i).Cells(1).Value.ToString If see = "FLOWRATE" Then TextBox11.Text = TextBox11.Text &amp; see &amp; " " End If Next End Sub </code></pre> <p>when i press the button i got this error</p> <pre><code>An unhandled exception of type 'System.NullReferenceException' occurred in project1.exe Additional information: Object reference not set to an instance of an object. </code></pre>
14,843,094
0
EF creating procedures using ExecuteStoreCommand (running bulk scripts) <pre><code>SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- USP_TEST_SELECT -- ============================================= IF EXISTS (SELECT name FROM sysobjects WHERE name = 'usp_test_select' AND type = 'P') DROP PROCEDURE usp_test_select GO CREATE PROCEDURE usp_test_select @id int AS BEGIN SET NOCOUNT ON; SELECT * FROM MY_TABLE mt WHERE mt.id = @id END GO -- ********************************************** </code></pre> <p>I read this script from a textfile and would like to run it using EF <code>.ExecuteStoreCommand</code> (or any other execute method in EF).</p> <p>An exception is thrown : </p> <blockquote> <p><em>System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near 'GO'.<br> 'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.</em></p> </blockquote> <p>The scripts (text file) which I am running is generated by SQL Server Management Studio and runs with success if executed there.</p>
9,611,595
0
Why is += valid temporaries in standard library? <p>When I attempt to compile the following on <a href="http://ideone.com/BaQoe" rel="nofollow">ideone</a>:</p> <pre><code>class X { public: friend X&amp; operator+=(X&amp; x, const X&amp; y); }; X&amp; operator+=(X&amp; x, const X&amp; y) { return x; } int main() { X() += X(); } </code></pre> <p>As expected, this throws a compile error, because you can't pass a temporary to a non const reference.</p> <p>However, the following compiles successfully on <a href="http://ideone.com/PECyy" rel="nofollow">ideone</a>:</p> <pre><code>std::string() += std::string(); </code></pre> <p>Shouldn't this error like my example above? </p> <p><strong>Edit:</strong></p> <p>If std::string() defines <code>+=</code> as a member operation, why does it do this when such usage allows the left hand side to be a temporary? Why not define it as I have above and avoid the reference to temporary issues?</p>
21,671,606
0
<p>Like this. without the text()</p> <pre><code>$(".post-btn").html("&lt;img src='../images/loader.gif' /&gt;"); </code></pre>