pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
37,448,066
0
<p>1) <strong>I recommend that you check to see if this file is being written to already</strong> before you attempt to write to it.</p> <pre><code>void SaveTimer() { try { using (Stream stream = new FileStream(filename, FileMode.Open)) { yourTimer.Stop(); Save(); yourTimer.Start(); } } catch { Thread.Sleep(3000); } } } </code></pre> <ol start="2"> <li><strong>If possible, it is better to re-factor your code to avoid putting the thread to sleep.</strong></li> </ol>
13,117,913
0
<p>Try using <code>ICollectionViews</code> in combination with <code>IsSynchronizedWithCurrentItem</code> property when handling lists / ObservableCollection in Xaml. The ICollectionView in the viewmodel can handle all the things needed, e.g. sorting, filtering, keeping track of selections and states.</p> <p>Xaml:</p> <pre><code>&lt;Window x:Class="ComboBoxBinding.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition /&gt; &lt;ColumnDefinition /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;ListBox Grid.Column="0" ItemsSource="{Binding Reports}" DisplayMemberPath="Name" IsSynchronizedWithCurrentItem="True" /&gt; &lt;ComboBox Grid.Column="1" ItemsSource="{Binding CurrentReport.Performances}" DisplayMemberPath="Name" IsSynchronizedWithCurrentItem="True" /&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>ViewModel:</p> <pre><code>public class ViewModel : INotifyPropertyChanged { private readonly IReportService _reportService; private ObservableCollection&lt;ReportViewModel&gt; _reports = new ObservableCollection&lt;ReportViewModel&gt;(); private PerformanceViewModel _currentPerformance; private ReportViewModel _currentReport; public ObservableCollection&lt;ReportViewModel&gt; Reports { get { return _reports; } set { _reports = value; OnPropertyChanged("Reports");} } public ReportViewModel CurrentReport { get { return _currentReport; } set { _currentReport = value; OnPropertyChanged("CurrentReport");} } public PerformanceViewModel CurrentPerformance { get { return _currentPerformance; } set { _currentPerformance = value; OnPropertyChanged("CurrentPerformance");} } public ICollectionView ReportsView { get; private set; } public ICollectionView PerformancesView { get; private set; } public ViewModel(IReportService reportService) { if (reportService == null) throw new ArgumentNullException("reportService"); _reportService = reportService; var reports = _reportService.GetData(); Reports = new ObservableCollection&lt;ReportViewModel&gt;(reports); ReportsView = CollectionViewSource.GetDefaultView(Reports); ReportsView.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending)); ReportsView.CurrentChanged += OnReportsChanged; ReportsView.MoveCurrentToFirst(); } private void OnReportsChanged(object sender, EventArgs e) { var selectedReport = ReportsView.CurrentItem as ReportViewModel; if (selectedReport == null) return; CurrentReport = selectedReport; if(PerformancesView != null) { PerformancesView.CurrentChanged -= OnPerformancesChanged; } PerformancesView = CollectionViewSource.GetDefaultView(CurrentReport.Performances); PerformancesView.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending)); PerformancesView.CurrentChanged += OnPerformancesChanged; PerformancesView.MoveCurrentToFirst(); } private void OnPerformancesChanged(object sender, EventArgs e) { var selectedperformance = PerformancesView.CurrentItem as PerformanceViewModel; if (selectedperformance == null) return; CurrentPerformance = selectedperformance; } public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); } } </code></pre>
16,231,375
0
WPF get parent of menuItem <p>I don't know how to get the parent of a menuItem? I searched all arround but can't get a good answer...</p> <p>My XAML is:</p> <pre><code>&lt;DockPanel&gt; &lt;Menu DockPanel.Dock="Right" SnapsToDevicePixels="True" Margin="2,0,0,0"&gt; &lt;MenuItem Header="Devices"&gt; &lt;local:MenuItemWithRadioButton x:Name="MenuItemVideoDevices" Header="Video"&gt; &lt;/local:MenuItemWithRadioButton&gt; &lt;local:MenuItemWithRadioButton x:Name="MenuItemAudioDevices" Header="Audio"&gt; &lt;/local:MenuItemWithRadioButton&gt; &lt;/MenuItem&gt; &lt;/Menu&gt; &lt;/DockPanel&gt; private void MenuItemWithRadioButtons_Click(object sender, System.Windows.RoutedEventArgs e) { MenuItem mi = sender as MenuItem; if (mi != null) { RadioButton rb = mi.Icon as RadioButton; if (rb != null) { rb.IsChecked = true; } //Here I want to get the parent menuItem } } </code></pre> <p>In the code, when I click the submenuItem like "MenuItemVideoDevices", an event process function is triggered, but I don't know how to get the menuItem "Video" in this function.</p> <p>Anyone knows? </p>
10,541,712
0
Web app on android browser WIDTH issue <p>So I've only experienced this issue on the Android browser so far. Basically my site works fine almost all the time (and I've not seen the problem yet on Dolphin, Opera or Skyfire) but occasionally when I reopen the Android browser from a bookmark on one of my phone's homescreens my site appears stretched horizontally, so now I only see the first 2/3 of the left hand side. Its' as though the browser just lost the CSS or the meta information while it was minimized. Here are my meta tags, and I'm using width 100% in my table styles.</p> <pre><code>&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt; &lt;meta name="keywords" content="Task, Tasks, Goal, Goals, Habit, Habits, Track, Tracking, Best Habit Tracker"/&gt; &lt;meta name="description" content="Top Habit Tracker!"/&gt; &lt;meta name="mobileoptimized" content="0"/&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"/&gt; </code></pre> <p>This issue only seems to happen when the bookmark is clicked after about 30 min. to reopen the stock Android browser. Then, it seems browser gets the page from its cache, but still runs window onload for ajax, so I'm thinking the combination of it using a browser-cached page with (maybe?) the javascript DOM manipulations from ajax on top is something that the Android stock browser uniquely has problems with, breaking my table width outside the viewport. Or maybe the DOM changes have nothing to do with it.</p> <p>If the phone is switched off, then on, and the bookmarked clicked, the stock browser reloads the page from the server, then I don't get the problem. If the browser is minimized, and the bookmark re-clicked after just 2 minutes, no problem either because the browser just re-displays itself and the last page exactly as it was left, without doing anything.</p> <p>I've been thinking of some kind of hack I could throw on top to force a reload from server in the case where the page is grabbed from brower cache, or I guesss I could try turning off browser caching, but I'm wondering about the implications of doing that on images, css, load time etc. Weighing up my options... thoughts welcome.</p> <p>UPDATE: Well turning off browser caching may have reduced the incidence of this issue (not sure?) but definitely didn't cure it. I'm now thinking I may be having the same issue as described in this blog post:</p> <p><a href="http://www.gabrielweinberg.com/blog/2011/03/working-around-androids-screenwidth-bug.html" rel="nofollow">http://www.gabrielweinberg.com/blog/2011/03/working-around-androids-screenwidth-bug.html</a></p> <p>UPDATE: OK nothing I've tried so far has prevented this intermittent issue in my Android stock browser. I'm going to switch my regular use of my app to Dolphin for a while to see if the issue occurs in that browser. What I've tried so far is: using meta tags to disable browser caching (I think to some extent the Android browser ignores that anyway)... changing the table width (I may try that again in a different way)... Using the solution posted at comment 14 here (dynamically creating CSS link): <a href="https://code.google.com/p/android/issues/detail?id=11961#c14" rel="nofollow">https://code.google.com/p/android/issues/detail?id=11961#c14</a> and lastly I've tried appending Datetime ticks to the URL in an effort to alleviate caching, that hasn't worked either.</p> <p>More useful info here: <a href="http://f055.tumblr.com/post/6364300769/viewport-bugs-in-android-browser" rel="nofollow">http://f055.tumblr.com/post/6364300769/viewport-bugs-in-android-browser</a></p>
38,781,502
0
<blockquote> <p>Unfortunately the Symbol isn´t displayed correctly after the relocation, instead the String for the Symbol is displayed</p> </blockquote> <p>This is because the ampersand is escaped</p> <ol> <li>Right click the RESW file and select "Open With..."</li> <li>Choose "<strong>XML (Text) Editor</strong>" <a href="https://i.stack.imgur.com/YgNqC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YgNqC.jpg" alt="enter image description here"></a></li> </ol> <p>You will find the resource's value will be replaced by <a href="https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined%5Fentities%5Fin%5FXML" rel="nofollow noreferrer"><code>&amp;amp;</code></a>:</p> <pre><code>&lt;data name="UISymbol.Text" xml:space="preserve"&gt; &lt;value&gt;&amp;amp;#xE160;&lt;/value&gt; &lt;/data&gt; </code></pre> <p><a href="https://i.stack.imgur.com/0r5sI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0r5sI.jpg" alt="enter image description here"></a></p> <p><strong>Please modify it to <code>&amp;</code> character</strong></p> <pre><code>&lt;value&gt;&amp;#xE160;&lt;/value&gt; </code></pre> <p><strong>Screenshot:</strong></p> <p><a href="https://i.stack.imgur.com/D0P96.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D0P96.jpg" alt="enter image description here"></a></p> <p><strong>See my completed sample</strong> <a href="https://github.com/Myfreedom614/UWP-Samples/tree/master/SymbolResourceUWPApp1" rel="nofollow noreferrer">here</a></p>
27,406,825
0
<p>It's not necessary or even mandatory. But is it smart? Yes it is. Android Studio with Gradle and Maven are soooo powerful, that you are losing so much time using Eclipse. </p> <p>Of course, you will have to pass all these painful steps, like we all did. What is Gradle? What is Maven? How do I import library? Where is my code? Why my Manifest does not work? And so on...</p> <p>so I strongly advise you find a week of your time and learn new IDE by fixing all those things that will arise when you do conversion. </p> <p>But in the end, you can still use Eclipse or IntelliJ IDEA the old way and leave learning to some other time. </p>
36,065,747
0
RTMP Streaming does not work from Docker container <p>I have an application that streams data via RTMP with a command roughly like this:</p> <pre><code>ffmpeg -y -loglevel warning -f dshow -i - -vf crop=690:388:136:0 -r 30 -s 962x388 -threads 2 -vcodec libx264 -vpre baseline -vpre my_ffpreset -f flv rtmp://some.url.com/live/myStream.sdp </code></pre> <p>It works when I run it from the command line it works. But if I run it from the docker container it can't seem to connect to the RTMP URL</p> <p>If I run the container using:</p> <pre><code>docker run -it container_name /bin/bash </code></pre> <p>I can ping the URL successfully so I don't know what the problem is.</p> <p><strong>Update:</strong> Just to be extra clear, I want to be able to connect to an RMTP server that is on the Internet from within the Docker container. And it is this connection ffmpeg -> internet that can't be established.</p>
25,276,718
0
How do i create a dbo schema in the h2 sqlserver emulator? <p>I'm getting a </p> <pre><code>JdbcSQLException: Schema "dbo" not found; SQL statement: create table "dbo"."TableName" </code></pre> <p>when running some boilerplate sql against the h2 sqlserver emulator (ie, with config settings:</p> <pre><code>db.default.slickdriver=com.typesafe.slick.driver.ms.SQLServerDriver db.default.driver=net.sourceforge.jtds.jdbc.Driver db.default.url="jdbc:h2:file:~/data/test1;MODE=MSSQLServer" </code></pre> <p>running the following:</p> <pre><code>Database.forDataSource(DB.getDataSource()) withSession { </code></pre> <p>I've tried creating the schema:</p> <pre><code> Database.forDataSource(DB.getDataSource()) withSession { implicit session =&gt; Q.updateNA("CREATE SCHEMA \"dbo\" AUTHORIZATION sa;") } </code></pre> <p>but that doesn't seem to do the trick (or report an error message). Am I missing something?</p> <hr> <p>still unable to create the schema programatically. was able to easily create it via the h2 console, using the exact same query as above.</p> <hr> <pre><code>play.api.UnexpectedException: Unexpected exception[JdbcSQLException: Schema "dbo" not found; SQL statement: create table "dbo"."TestTable" ("TestTableId" CHAR(36)) at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:148) ~[play_2.10-2.2.3.jar:2.2.3] at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:112) ~[play_2.10-2.2.3.jar:2.2.3] at scala.Option.map(Option.scala:145) ~[scala-library-2.10.4.jar:na] at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:112) ~[play_2.10-2.2.3.jar:2.2.3] at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:110) ~[play_2.10-2.2.3.jar:2.2.3] at scala.util.Success.flatMap(Try.scala:200) ~[scala-library-2.10.4.jar:na] Caused by: org.h2.jdbc.JdbcSQLException: Schema "dbo" not found; SQL statement: create table "dbo"."TestTable" ("TestTableId" CHAR(36)) at org.h2.message.DbException.getJdbcSQLException(DbException.java:329) ~[h2-1.3.172.jar:1.3.172] at org.h2.message.DbException.get(DbException.java:169) ~[h2-1.3.172.jar:1.3.172] at org.h2.message.DbException.get(DbException.java:146) ~[h2-1.3.172.jar:1.3.172] at org.h2.command.Parser.getSchema(Parser.java:613) ~[h2-1.3.172.jar:1.3.172] at org.h2.command.Parser.getSchema(Parser.java:620) ~[h2-1.3.172.jar:1.3.172] at org.h2.command.Parser.parseCreateTable(Parser.java:5254) ~[h2-1.3.172.jar:1.3.172] </code></pre>
24,967,768
0
<p>You need to edit your sendrederct to : </p> <blockquote> <p>response.sendRedirect("/ProjectName/userhelp.html");</p> </blockquote> <p>You have response.sendRedirect("/userhelp.html"); arguement to your sendRedirect starts with a forward slash.Which means that 'realative to root of container'.So container builds URL relative to original URL of request.</p> <p>Your userhelp.html page exits in your project's webcontent.It's relative path from container's root should be /Projectname/userhelp.html.So you need to edit your path in response.sendRedirect.</p> <p>Edit : Problem is in your servlet mapping as @servletmapping(/) means that anything which comes for this url pattern(/) , should be send to this servlet.So what really happens is that when your servlet is called first time and response.sendredirect() is called ,a new request object is created and as path for it is / , So again your servlet gets called and this recursive process starts. </p> <p>So solution for this is to change servlet mapping to : @servletmapping(/test) and then call this servlet by calling yourlocalhost/test/ .So when this time redirection is done , Servlet is not called for that.</p>
4,564,924
0
<p>Not with pure CSS. The closest equivalent is this:</p> <pre><code>.class1, .class2 { some stuff } .class2 { some more stuff } </code></pre>
35,525,496
0
How does one add a partial index checking for NULL to a JSON column on Postgres? <p>I've got a <code>json</code> column called <code>data</code> on Postgres, and I'd like to add a partial index that applies only to rows where this column is <code>null</code> - I basically need to find all the rows where <code>data</code> is <code>null</code> so I can put some data into them. </p> <p>Trying to add an index gives an error about missing operator classes, though, because we can't index <code>json</code> types with a <code>btree</code> index. But I'm not trying to index a specific property either, for me to use <code>data-&gt;&gt;property</code>. How can I index just the rows which have a <code>json</code> null in them?</p> <p>Edit: The <code>jsonb</code> suggestion would work, but I'm stuck on 9.3 for this project.</p>
4,446,388
0
Wordpress Shortcodes and Conditional Statements <p>I am using custom shortcodes for my post editor and i now have multiple shortcodes i would like to make a shortode be stylized differently if another shortcode is enabled. Is there a filter or conditional function like is_shortcode('slideshow') if not has anyone written a workaround for this?</p>
18,492,859
0
System.IO.Directory.GetFiles VS My.Computer.FileSystem.GetFiles <p>I wanted to get the names of all the files in a specific directory which includes over 25,000 files. I tried using these methods:</p> <p><code>System.IO.Directory.GetFiles</code> and <code>My.Computer.FileSystem.GetFiles</code></p> <p>I've found out that <code>System.IO</code> is significantly faster <code>My.Computer</code></p> <p>By significantly I mean around 20 second faster.</p> <p>Could anyone explain to me the difference between These two methods?</p>
29,386,608
0
Google maps Places API not working <pre><code>package com.example.googlemapstestproject; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.os.AsyncTask; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AutoCompleteTextView; import android.widget.Button; import android.widget.SimpleAdapter; import android.widget.Toast; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.GoogleMap.OnMapLongClickListener; import com.google.android.gms.maps.GoogleMap.OnMyLocationButtonClickListener; import com.google.android.gms.maps.MapFragment; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MarkerOptions; public class MainActivity extends ActionBarActivity implements OnMapLongClickListener, OnMyLocationButtonClickListener, android.view.View.OnClickListener { private GoogleMap mMap; Button userLocation;`enter code here` GPSTracker gps; PlacesTask placesTask; ParserTask parserTask; AutoCompleteTextView autoCompView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); autoCompView = (AutoCompleteTextView) findViewById(R.id.atv_places); autoCompView.setThreshold(1); autoCompView.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { placesTask = new PlacesTask(); placesTask.execute(s.toString()); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); try { // Loading map initilizeMap(); } catch (Exception e) { e.printStackTrace(); } mMap.setOnMapLongClickListener(this); mMap.setMyLocationEnabled(true); mMap.getUiSettings().setZoomControlsEnabled(true); } private String downloadUrl(String strUrl) throws IOException { String data = ""; InputStream iStream = null; HttpURLConnection urlConnection = null; try { URL url = new URL(strUrl); // Creating an http connection to communicate with url urlConnection = (HttpURLConnection) url.openConnection(); // Connecting to url urlConnection.connect(); // Reading data from url iStream = urlConnection.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(iStream)); StringBuffer sb = new StringBuffer(); String line = ""; while ((line = br.readLine()) != null) { sb.append(line); } data = sb.toString(); br.close(); } catch (Exception e) { Log.d("Exception while downloading url", e.toString()); } finally { iStream.close(); urlConnection.disconnect(); } return data; } // Fetches all places from GooglePlaces AutoComplete Web Service private class PlacesTask extends AsyncTask&lt;String, Void, String&gt; { @Override protected String doInBackground(String... place) { // For storing data from web service String data = ""; // Obtain browser key from https://code.google.com/apis/console String key = "key=AIzaSyDTg7d-JNRLRxe75QDEEeAGr1xnSHGX9V4"; String input = ""; try { input = "input=" + URLEncoder.encode(place[0], "utf-8"); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } // place type to be searched String types = "types=(cities)"; // Sensor enabled String sensor = "sensor=false"; // Building the parameters to the web service String parameters = input + "&amp;" + types + "&amp;" + sensor + "&amp;" + key; // Output format String output = "json"; // Building the url to the web service String url = "https://maps.googleapis.com/maps/api/place/autocomplete/" + output + "?" + parameters; try { // Fetching the data from we service data = downloadUrl(url); } catch (Exception e) { Log.d("Background Task", e.toString()); } return data; } // Executed after the complete execution of doInBackground() method @Override protected void onPostExecute(String result) { // Instantiating ParserTask which parses the json data from // Geocoding webservice // in a non-ui thread ParserTask parserTask = new ParserTask(); // Start parsing the places in JSON format // Invokes the "doInBackground()" method of the class ParseTask parserTask.execute(result); } } // A class to parse the Google Places in JSON format private class ParserTask extends AsyncTask&lt;String, Integer, List&lt;HashMap&lt;String, String&gt;&gt;&gt; { JSONObject jObject; @Override protected List&lt;HashMap&lt;String, String&gt;&gt; doInBackground(String... jsonData) { List&lt;HashMap&lt;String, String&gt;&gt; places = null; PlaceJSONParser placeJsonParser = new PlaceJSONParser(); try { jObject = new JSONObject(jsonData[0]); // Getting the parsed data as a List places = placeJsonParser.parse(jObject); } catch (Exception e) { Log.d("Exception", e.toString()); } return places; } @Override protected void onPostExecute(List&lt;HashMap&lt;String, String&gt;&gt; result) { String[] from = new String[] { "description" }; int[] to = new int[] { R.layout.listview_layout }; // Creating a SimpleAdapter for the AutoCompleteTextView SimpleAdapter adapter = new SimpleAdapter(getBaseContext(), result, android.R.layout.simple_list_item_1, from, to); // Setting the adapter autoCompView.setAdapter(adapter); } } @Override public void onClick(View v) { // TODO Auto-generated method stub } } </code></pre> <p>Updated code update, everything looks fine it is just that there is nothing appearing still when I type in a place.</p> <p>I have made the google maps half and half with a listview as well so if anyone has any good solutions on how to get them to work together that would be great.</p>
27,647,983
0
<p>I got the error in ermenkoff's solution.</p> <p><strong>Error</strong>: AbsoluteAssetPathError</p> <p>It was fixed by <strong>removing</strong> "/assets/" from the url.</p> <pre><code>:default_url =&gt; ":style/missing_avatar.jpg" </code></pre> <p>Images are stored in:</p> <pre><code>app/assets/images/medium/missing_avatar.jpg app/assets/images/thumbs/missing_avatar.jpg </code></pre>
29,062,441
0
<p>Do you need to use JQuery? Why not use CSS?</p> <pre><code>&lt;span style="color:green;"&gt;//I need to color this line&lt;/span&gt; </code></pre>
40,456,580
0
<p>You can get browser dimensions with javascript using <code>window.innerHeight</code>.</p> <pre><code>var h=window.innerHeight; </code></pre> <p>You can use the <code>innerWidth</code> for width too. There is a table with browser compatibility at <a href="http://www.w3schools.com/jsref/prop_win_innerheight.asp" rel="nofollow noreferrer">w3schools</a>.</p>
39,905,583
0
Mapquest routes using custom icons <p>I'm using Mapquest's Javascript API for leaflet.</p> <p>My code looks like this: </p> <pre><code>dir = MQ.routing.directions() .on('success', function (data) { console.log(data); var legs = data.route.legs; var maneuvers; if (legs &amp;&amp; legs.length) { maneuvers = $.map(legs[0].maneuvers, function(m) { return new Maneuvers(m); }); self.maneuvers(maneuvers); } }); dir.route({ locations: [ self.from(), self.to() ] }); map.addLayer(MQ.routing.routeLayer({ directions: dir, fitBounds: true })); </code></pre> <p>The results I get looks like this: <a href="https://i.stack.imgur.com/aBg5h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aBg5h.png" alt="enter image description here"></a> Although, this looks good, the icons don't look anything like the Get Direction module on mapquest.com <a href="https://i.stack.imgur.com/OK5TT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OK5TT.png" alt="enter image description here"></a></p> <p>How can I change the icons so that they look more modern?</p>
27,946,528
0
Template friend function and return type deduction <p>Note: This question is really close to <a href="http://stackoverflow.com/questions/18931993/return-type-deduction-for-in-class-friend-functions">Return type deduction for in-class friend functions</a>, but I did not find the answer to my problem there.</p> <p>Tested with clang 3.4 with std=c++1y and clang 3.5 with std=c++14 and std=c++1z</p> <p>This code compiles:</p> <pre><code>#include &lt;iostream&gt; template&lt;class T&gt; class MyClass { public: MyClass(T const&amp; a) : impl(a) {} template&lt;class T0, class T1&gt; friend auto // requires operator+(T0,T1) exists operator+(MyClass&lt;T0&gt; const&amp; a, MyClass&lt;T1&gt; const&amp; b) { return MyClass&lt;decltype(a.impl+b.impl)&gt;{a.impl + b.impl}; } T getImpl() const { return impl; } private: T impl; }; int main() { MyClass&lt;int&gt; x(2); MyClass&lt;long&gt; y(2); auto z = x+y; std::cout &lt;&lt; z.getImpl() &lt;&lt; "\n"; } </code></pre> <p>Now if I define operator+ outside of the class, it does not compile anymore:</p> <pre><code>template&lt;class T&gt; class MyClass { public: MyClass(T const&amp; a) : impl(a) {} template&lt;class T0, class T1&gt; friend auto operator+(MyClass&lt;T0&gt; const&amp; a, MyClass&lt;T1&gt; const&amp; b); T getImpl() const { return impl; } private: T impl; }; template&lt;class T0, class T1&gt; auto operator+(MyClass&lt;T0&gt; const&amp; a, MyClass&lt;T1&gt; const&amp; b) { return MyClass&lt;decltype(a.impl+b.impl)&gt;{a.impl + b.impl}; } </code></pre> <p>Clang 3.4 says:</p> <pre><code>error: use of overloaded operator '+' is ambiguous (with operand types MyClass&lt;int&gt; and MyClass&lt;long&gt;) </code></pre> <p>And then points at what it believes to be two different functions: the declaration in the class and the definition outside the class.</p> <p>My question is: is it a clang bug, or just that template parameters are deduced for a friend function thus leading the two functions not being equivalent is some cases ? And what alternative would you suggest: make operator+ a member function, or define friend operator+ inside the class (which would in my opinion clutter the class interface) ?</p> <p>Just for your information, I have a real use case of such code, where I try to wrap a third -party matrix class and I need return type deduction because of the use of expression template for lazy evaluation.</p> <p><em>Edit</em>: The following does work (but still clutters the interface...)</p> <pre><code>template&lt;typename T&gt; class MyClass { T impl; public: explicit MyClass(T a) : impl(std::move(a)) { } T const&amp; getImpl() const { return impl; } template&lt;typename T0, typename T1&gt; friend auto operator +(MyClass&lt;T0&gt; const&amp; a, MyClass&lt;T1&gt; const&amp; b) -&gt; MyClass&lt;decltype(a.impl + b.impl)&gt;; }; template&lt;typename T0, typename T1&gt; auto operator +(MyClass&lt;T0&gt; const&amp; a, MyClass&lt;T1&gt; const&amp; b) -&gt; MyClass&lt;decltype(a.impl + b.impl)&gt; { return MyClass&lt;decltype(a.impl + b.impl)&gt;(a.impl + b.impl); } </code></pre>
30,673,331
0
Using `onRetainCustomNonConfigurationInstance` to retain data across configuration changes <p>I've been programming for Android for some time, and I'm still looking for solutions to retain data over configuration changes. Aside from saving <code>Parcelable</code>s to Activity's <code>Bundle</code> in <code>onSaveInstanceState</code> docs are suggesting using <code>Fragment</code> with <code>setRetainInstance</code> flag set to true.</p> <p>But I've just come across some code that uses <code>onRetainCustomNonConfigurationInstance</code> to hold arbitrary objects (in a fancy way, but essentially big objects without references to <code>Activity</code> etc.). I have never seen this method used, so I have some doubts:</p> <ul> <li>Is this method safe to call to store arbitrary objects (in a sense that I can be pretty sure it's gonna get called, and that it won't be deprecated/removed anytime soon)?</li> <li>How is this method different from <code>onRetainNonConfigurationInstance()</code>, which also should return <code>Object</code>, and in essence should work similarly?</li> <li>Is using retained fragment still better, for some reason?</li> </ul> <p>As a bonus, I would be grateful for any other tips or solutions to save state of objects like <code>AsyncTask</code>, <code>Observable</code>, view's presenters and go on</p>
33,354,772
0
PHP Open SSL Decrypt Failing Inconsistently <p>I'm having some weird behaviour with the <code>openssl_decrypt</code> method in PHP. It's failing, giving me an error: <code>Unknown cipher algorithm</code>, but only <em>sometimes</em> (about 6:10 times) i.e. If I run the command enough times, it will eventually work... My code is: </p> <p><code>$result = openssl_decrypt(base64_decode($hash), 'AES-128-CBC', $timestamp);</code></p> <p>running <code>openssl list-cipher-commands</code> lists AES-128-CBC as one of the available cipher methods. The specs don't really list anything on the subject - only specifying that <code>unknown cipher algorithm</code> is a possible exception from running the command.</p> <p>edit: Using the command line: i.e. running <code>echo "soemthing" | openssl enc -aes-128-cbc</code> on a random machine and then decrypting on the machine that fails with the above <code>echo "..." | openssl enc -aes-128-cbc -d</code> works consistently.</p>
11,532,902
0
<p>Growing buttons in Excel is a fairly common issue, with several theories about why this happens, including the use of multiple monitors or using proportional fonts. I have yet to see a definitive answer about this, but there are several workarounds that may work for you.</p> <ol> <li>Delete and re-create the buttons.</li> <li>Programmatically set the height and width of the buttons when the workbook is opened and when a button is clicked.</li> <li>Select the button with another object or two on the sheet and group them.</li> <li>Don't use them at all.</li> </ol> <p>My personal choice is #4. As an alternative to buttons, I either use hyperlinks or shapes with macros assigned to them.</p>
125,273
0
<p>Depending on the admins, automation is helpful. I've had windows admins that want a Word doc with step by step instructions and other admins that wanted a script.</p> <p>However, some helpful things to include, probably as sections</p> <ul> <li>Database changes <ul> <li>Scripts to run</li> <li>Verification that they worked</li> </ul></li> <li>Configuration changes <ul> <li>what are the change</li> <li>where is a version of the new file (In my case they diffed the two, which helped reduced errors concerning production-specific values)</li> </ul></li> <li>General verification <ul> <li>what should be different from the user perspective (feature changes)</li> </ul></li> <li>For web farm deployments, it might be helpful to have a coordination document concerning how the servers need to be pulled in and out of pool.</li> </ul>
30,364,861
0
<p>Finaly, I have found out what was the problem. composer.json file in the project I was trying to load - <a href="https://github.com/KoulSlou/UPS" rel="nofollow">UPS library</a> -was invalid. I was able to download files when I ran:</p> <pre><code>composer.phar install </code></pre> <p>but it looks like composer.json file was ignored. I found it out when I ran </p> <pre><code>composer.phar update </code></pre> <p>and got</p> <pre><code>No valid composer.json was found </code></pre> <p>With option -v I got error that "name" is undefined index. So, I simply added "name" field to the composer.json. Final version is:</p> <pre><code>{ "name":"KoulSlou/UPS", "autoload": { "files": [ "libraries/Ups/Ups.php", "libraries/Ups/Ups_Base.php", "libraries/Ups/Ups_Base_Response.php", "libraries/Ups/Ups_Live_Rates.php" ] } } </code></pre>
38,698,044
0
<p>You need to skip " on --query param</p> <pre> sqoopcom="sqoop import --direct --connect abcd --username abc --P --query \"queryname\" --target-dir /pwd/dir --m 1 --fetch-size 1000 --verbose --fields-terminated-by , --escaped-by \\ --enclosed-by '\"'/dir/part-m-00000" </pre>
13,452,637
0
Unable to Launch Chrome Browser in Selenium <p>I am launching chrome browser using</p> <pre><code>selenium = new DefaultSelenium("localhost", 4444, "*googlechrome", "https://example.com/"); </code></pre> <p>But i get a popup with following message and it freezes: </p> <blockquote> <p><em>An administrator has installed Google Chrome on this system, and it is available for all users. The system-level Google Chrome will replace your user-level installation now.</em></p> </blockquote> <p>Console Log till point of freeze:</p> <pre><code>Server started 16:06:37.792 INFO - Command request: getNewBrowserSession[*googlechrome, https://example.com/, ] on session null 16:06:37.796 INFO - creating new remote session 16:06:38.081 INFO - Allocated session beb925cd0418412dbe6319fedfb28614 for https://example.com/, launching... 16:06:38.082 INFO - Launching Google Chrome... </code></pre> <p>Any suggestions?</p>
34,215,065
0
read XML in SQL, no data being pulled <p>I am trying to retrieve data from an XML file. Below is how the XML doc looks and below that is my SQL code. It will run the code and show column headers - but will not populate with any data. What am I missing?</p> <pre><code>&lt;profile xmlns="http://feed.elasticstats.com/schema/mma/v1/participants-profile.xsd" generated="2015-12-10T17:34:54Z"&gt; &lt;fighters&gt; &lt;fighter id="01585452-852a-4b40-a6dc-fdd04279f02c" height="72" weight="170" reach="" stance="" first_name="Sai" nick_name="The Boss" last_name="Wang"&gt; &lt;record wins="6" losses="4" draws="1" no_contests="0" /&gt; &lt;born date="1988-01-16" country_code="UNK" country="Unknown" state="" city="" /&gt; &lt;out_of country_code="UNK" country="Unknown" state="" city="" /&gt; &lt;/fighter&gt; &lt;fighter id="0168dd6b-b3e1-4954-8b71-877a63772dec" height="" weight="0" reach="" stance="" first_name="Enrique" nick_name="Wasabi" last_name="Marin"&gt; &lt;record wins="8" losses="2" draws="0" no_contests="0" /&gt; &lt;born date="" country_code="UNK" country="Unknown" state="" city="" /&gt; &lt;out_of country_code="UNK" country="Unknown" state="" city="" /&gt; &lt;/fighter&gt; </code></pre> <hr> <pre><code>DECLARE @x xml SELECT @x = P FROM OPENROWSET (BULK 'C:\Python27\outputMMA.xml', SINGLE_BLOB) AS FIGHTERS(P) DECLARE @hdoc int EXEC sp_xml_preparedocument @hdoc OUTPUT, @x SELECT * FROM OPENXML (@hdoc, '/fighters/fighter', 1) --1\ IS ATTRIBUTES AND 2 IS ELEMENTS WITH ( id varchar(100), height varchar(10), last_name varchar(100) ) --THIS IS WHERE YOU SELECT FIELDS you want returned EXEC sp_xml_removedocument @hdoc </code></pre>
6,755,350
0
<p>One can retrieve $config from Entity manager like this:</p> <pre><code>$config = $em-&gt;getConfiguration(); </code></pre> <p>To dynamically update entities paths try this (i've not tried it myself):</p> <pre><code>$driverImpl = new Doctrine\ORM\Mapping\Driver\AnnotationDriver(array( APP_PATH . DIRECTORY_SEPARATOR . 'entities' )); $config-&gt;setMetadataDriverImpl($driverImpl); </code></pre> <p>P.S> I think this should work but I've not tried this so plz correct me if this wrong.</p>
36,138,531
0
AngularJS - $$ChildScope Vs $$childHead && $$childTail <p><code>angular.element($0).scope()</code> gives <code>$$ChildScope</code>, <code>$$childHead</code> and <code>$$childTail</code> as members.</p> <p>On debugging, <code>$$childHead</code> and <code>$$childTail</code> shows the immediate child scopes.</p> <p><a href="https://i.stack.imgur.com/A6Hz8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A6Hz8.png" alt="enter image description here"></a></p> <p>What does <code>$$ChildScope</code> signify?</p>
17,422,450
0
<p>The bracket notation returns DOM elements, which do not have a <code>slideToggle</code> method. What you want is <a href="http://api.jquery.com/eq/" rel="nofollow"><code>.eq</code></a>, which filters in the same manner but returns jQuery objects instead:</p> <pre><code>Div.eq(0).slideToggle(...) ; </code></pre>
13,374,893
0
<p>In WCF Ria Services you must put the <code>RoundTripOriginalAttribute</code> on your class members, not on the class itself. It's meant to let you round trip properties mainly for concurrency checks server-side.</p>
33,229,030
0
<p>Have you tried doing a <a href="http://www.smarty.net/docsv2/en/language.function.foreach.tpl" rel="nofollow">foreach</a> loop in Smarty?</p> <pre><code>&lt;ul&gt; {foreach from=$myArray item=foo} &lt;li&gt;{$foo}&lt;/li&gt; {/foreach} &lt;/ul&gt; </code></pre>
32,417,606
0
clear empty spaces array <p>I have this array, and I want go get rid of those indexes that have no value in them, so for example in the index[0] I want to get rid of the [0] and [4] so I would have a 3 value array and so on...</p> <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; [1] =&gt; [2] =&gt; 7 [3] =&gt; [4] =&gt; 8 [5] =&gt; ) [1] =&gt; Array ( [0] =&gt; [1] =&gt; [2] =&gt; 9 [3] =&gt; 10 [4] =&gt; ) [2] =&gt; Array ( [0] =&gt; [1] =&gt; 11 [2] =&gt; 12 [3] =&gt; ) ) </code></pre>
17,068,150
0
<p>Solution was to remove all changes and generate the scaffold correctly using:</p> <pre><code>rails g scaffold Category name:string description:text </code></pre>
37,744,206
0
<p>Add a <code>flush</code> before <code>close</code> of the <code>OutputStream</code>. </p> <pre><code> response.getOutputStream().flush(); </code></pre> <p>Or If you are using Spring MVC 4.2 you can make use of <code>StreamingResponseBody</code></p> <pre><code>public StreamingResponseBody stream(HttpServletRequest req) throws FileNotFoundException { File file = new File(req.getRealPath("/")+"js/loginPage/usermanual.pdf"); InputStream is = new FileInputStream(file); return (os) -&gt; { IOUtils.copy(is, os); }; } </code></pre> <p>For more information see this <a href="http://shazsterblog.blogspot.com/2016/02/asynchronous-streaming-request.html" rel="nofollow">post</a></p>
12,405,164
0
<p>you can use the jquery <code>toogle</code> api</p> <p>html</p> <pre><code>&lt;div id="clickhere "&gt; Click here &lt;/div&gt; &lt;img id="image" src="demo.png" alt="" width="120" height="120" /&gt; </code></pre> <p>jquery</p> <pre><code>$('#clickhere ').click(function() { $('#image').toggle('slow', function() { // Animation complete. }); }); </code></pre> <p>for further reference check this link of <a href="http://api.jquery.com/toggle/" rel="nofollow">jquery .toggle()</a></p>
34,551,176
0
<p>A pattern I use for such a thing looks like this…</p> <p>Factory code…</p> <pre><code>angular.module('myApp').factory('MyFactory', function () { var myVar; function MyFactory(param) { myVar = param; this.hello = hello; } function hello() { console.log('Hello ' + myVar); } return MyFactory; }); </code></pre> <p>Then when using the factory and needing to pass parameters…</p> <pre><code>angular.module(‘myApp’).controller(‘MyController’ function(MyFactory) { myFactory = new MyFactory(‘world’); myFactory.hello(); }); </code></pre>
9,042,497
0
<p>You may be looking for</p> <pre><code>Document doc = DTE.ActiveDocument; TextDocument txt = doc.Object() as TextDocument; </code></pre> <p>You should then be able to edit work with the TextDocument as needed.</p>
32,592,333
0
<p>I had a similar issue and digged quite deep into the polymer code - it seems like there is no way for doing this. I found a quite dirty workaround, using an invisible item, but maybe it helps for you :</p> <pre><code> &lt;paper-dropdown-menu label="List's Color Tag" id="colorTag"&gt; &lt;paper-menu class="dropdown-content"&gt; &lt;paper-item style="display:none"&gt;&lt;/paper-item&gt; {{#each colors}} &lt;paper-item&gt;{{.}}&lt;/paper-item&gt; {{/each}} &lt;/paper-menu&gt; &lt;/paper-dropdown-menu&gt; </code></pre> <p>Than you should be able to set it to display nothing as selected by calling</p> <pre><code>document.getElementById('colorTag').contentElement.selected = 0; </code></pre> <p>I hope it works for you, it is not tested completely as I don't use Meteor and I use special IDs. I have set the invisible item to have the ID -1, so it does not mess with my other IDs. </p> <p>So in my case it looks like this :</p> <pre><code>&lt;paper-dropdown-menu id="carSelector" label="[[label]]" attr-for-selected="car-id" selected="{{selectedId}}" always-float-label &gt; &lt;paper-menu attr-for-selected="car-id" selected="{{selectedId}}" class="dropdown-content"&gt; &lt;paper-item car-id="-1" style="display:none"&gt;&lt;/paper-item&gt; &lt;template is="dom-repeat" items="[[cars]]" as="c"&gt; &lt;paper-item car-id$="[[c.Id]]"&gt; &lt;paper-item-body&gt; [[c.Plate]] &lt;/paper-item-body&gt; &lt;/paper-item&gt; &lt;/template&gt; &lt;/paper-menu&gt; &lt;/paper-dropdown-menu&gt; </code></pre> <p>And the corresponding call : </p> <pre><code>this.selectedId=-1; </code></pre>
23,661,436
0
how to find result of matched query in php <p>i am having one probelm cant cant figure it out how i can proceed. I have string like </p> <pre><code> "Coolman United States Member Since January 2013 Loans 114.01 Active 66.00 Repaid Credentials 2 followers eBay windchester 42 Friends 2" </code></pre> <p>now with php i need to find the user name that is "Coolman" country, member sience, loans, active, repaid, followers.</p> <p>I know with preg_replace, regex i can find the exact text that is matched. but the problem is there are hundreds of data like this similar pattern, with different username with different countries, different dates etc so how can i have result like this?</p> <p>username : Coolman country:United State Member Since: January 2013 and so on...</p> <p>Thanks for your help</p>
4,343,289
0
<p>I see a few pitfalls in your code, there are a few places where things can go wrong:</p> <p>First, use of regular statements. Use <a href="http://download.oracle.com/javase/tutorial/jdbc/basics/prepared.html">prepared statements</a> so you won't have problems with <a href="http://en.wikipedia.org/wiki/Sql_injection">SQL injection</a>.</p> <p>Instead of</p> <pre><code>statement = connection.createStatement(); </code></pre> <p>use</p> <pre><code>statement = connection.prepareStatement(String sql); </code></pre> <p>With this, your query becomes</p> <pre><code>"select distinct group_name From group_members where username= ?" </code></pre> <p>and you set username with</p> <pre><code> statement.setString(1, username); </code></pre> <p>Next, I don't like use of your <code>myDB</code> class. What if results is <code>null</code>? You're not doing any error checking for that in your <code>public List&lt;InterestGroup&gt; getGroups()</code> method. </p> <p><code>public void sendQuery(String query)</code> seems to me like it shouldn't be <code>void</code>, but it should return a <code>ResultSet</code>. Also, search on the net for proper ways to do JDBC exception handling.</p> <p>Also, this line:</p> <pre><code>new InterestGroup(results.getString("group_name"), myDB) </code></pre> <p>Why do you have <code>myDB</code> as a parameter?</p> <p>I'd suggest adding more <code>System.out.println</code> statements in your code so you can see where things can go wrong.</p>
29,536,075
0
<p><a href="https://github.com/python-visualization/folium" rel="nofollow">Folium</a> builds on the data wrangling strengths of the Python ecosystem and the mapping strengths of the Leaflet.js library. Manipulate your data in Python, then visualize it in on a Leaflet map via Folium.</p> <p><a href="http://folium.readthedocs.org/en/latest/" rel="nofollow">Documentation</a></p> <blockquote> <p>Folium makes it easy to visualize data that’s been manipulated in Python on an interactive Leaflet map. It enables both the binding of data to a map for choropleth visualizations as well as passing Vincent/Vega visualizations as markers on the map.</p> <p>The library has a number of built-in tilesets from OpenStreetMap, Mapbox, and Stamen, and supports custom tilesets with Mapbox or Cloudmade API keys. Folium supports both GeoJSON and TopoJSON overlays, as well as the binding of data to those overlays to create choropleth maps with color-brewer color schemes.</p> </blockquote>
32,467,246
0
How to start something on a new line in Java SWING? <p>I am trying to set my JTextArea to take up the max horz length of the screen, so that the next thing, in this case a button, will start on a new line, but I have no clue how to do it. I have messed around by setting the size of the JTextArea to change from, say, 20 to 1000 but that does not do anything. </p> <p>How can I get my textarea to take up the entire first row and then have the next item that I add to begin on the following row? Here is what I have so far...</p> <pre><code>MyFrame(){//constructor super("Simple Calculator"); p = new JPanel(); grid = new GridLayout(4, 4, 3, 3); p.setLayout(grid); setSize(400, 500); setResizable(true); setDefaultCloseOperation(EXIT_ON_CLOSE); setUpTextScreen(); //create buttons for(int i = 0; i &lt; buttonValues.length; i++){ p.add(new JButton(buttonValues[i])); } add(p); setVisible(true); } private void setUpTextScreen() { textOnScreen = new JTextArea(7, 1000); textOnScreen.setText("0");//default textOnScreen.setEditable(false); p.add(textOnScreen); } </code></pre>
3,669,159
0
<p>I think a lot of the problem deals with the fact that search engines give something a high rank if a lot of people are linking to a specific page. Unless you can get all the people linking to your old documentation, to link to your new documentation, then you are going to have a problem with the older documents being rated artificially high. In order to overcome this, you might need to change the way you handle documentation pages. One good way would be to always show the newest information on a particular topic, and then only by clicking on a link on the page, do you get to the older versions. Optimally, this would be the same page, with a different parameter, to state which version you want to get documentation for.</p>
29,120,225
0
VoltDB - decimal values have too many zeroes <p>when I try to add a decimal value to a column in voltdb, it always adds extra zeroes to the decimal. The column type is DECIMAL, which equates to Java's BigDecimal type. Even if I format the BigDecimal value in java to a two decimal place BigDecimal before doing the insert, it still shows up with lots of trailing zeroes in the column.</p> <p>Any idea how to fix this?</p> <p>Thanks</p>
32,828,720
0
<p>Consider <a href="http://blog.pasker.net/2010/10/21/use-jdbc-jms-without-jta/" rel="nofollow">1.5 phase commit</a>. Basically:</p> <ul> <li>step 1: You commit the DB transaction</li> <li>step 2: You commit the JMS transaction.</li> </ul> <p>Possible error scenarios: </p> <ol> <li>DB transaction fails.</li> <li>DB transaction sucessful JMS transaction fails.</li> <li>all successful.</li> </ol> <p>Not 1, nor 3 leaves your system in inconsistent state. In case of 1, you just need to resend the message.</p> <p>To handle scenario 2. you need to introduce duplicate check to your system. So essentially your transaction management would look like similar to this:</p> <pre><code>//pseudo code if (isDublicate(message)) commitJMSTransaction(); else doYourBusinessLogic(); doYourDBOperation(); commitDBTransaction(); commitJMSTransaction(); </code></pre> <p>If the JMS transaction fails your message broker will retry to send the message (or you need to resend it manually depending on your broker setup) but you duplicate check will detect it and remove it from the queue.</p>
5,087,386
0
<p>You should be able to handle that by conditionally adding a <a href="http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#redirect" rel="nofollow">#redirect</a> attribute to the form.</p>
6,711,281
0
<p>An application using Surface controls needs to use SurfaceWindow as it's root visual in order to do all of the custom touch handling. I suspect that since you're trying to convert this you are probably still using a standard Window which is giving you this error.</p>
23,477,022
0
Test & Target - Return HTML Content <p>I am not at all a Test &amp; Target expert. I am an Application Architect. I had a discussion yesterday with my colleague, who has huge experience in Test &amp; Target. Today in my website the test &amp; target content is rendered with the below mentioned steps.</p> <p>1) Page loads 2) AJAX call to a T&amp;T url is made. The response is JS with multiple lines of document.write 3) When that JS executes the content AKA html markup is rendered in the page.</p> <p>Above steps does not help search engines to crawl that content. I asked my colleague if instead of sending JS(document.write) response, can you send just the content(html). If that is possible I will call for the content from the server side itself and there by append the content in response for search engine to crawl.</p> <p>He says it not at all possible. I do not believe. With my experience in web application architecture, this should be possible. But my knowledge about the product is ZERO.</p> <p>If anyone things that it is possible, can you please provide steps for doing it. I will share it with my colleague. Thanks a lot.</p> <p><strong>Update</strong></p> <p>As a temporary solution. Is there a way in C# .Net to run document.write JS inside an aspx file. For instance if I do document.write("test"). The text test should be part of response without the document.write js code.</p> <p>Regards, Ravishankar Rajendran</p>
2,996,094
0
<p># mysql &lt; create_mysql.sql</p>
7,953,315
0
<p>Fetch the root and use </p> <pre><code>qry.ViewAttributes = "Scope='RecursiveAll'"; </code></pre> <p>See also: <a href="http://stackoverflow.com/questions/4192873/query-to-get-all-items-in-a-list-including-items-in-the-sub-folders-in-sharepoin">Query to get all items in a list including items in the sub folders in SharePoint</a></p> <p>And: <a href="http://www.ktskumar.com/blog/2009/07/retrieve-all-folders-from-list/">http://www.ktskumar.com/blog/2009/07/retrieve-all-folders-from-list/</a></p> <p>HTH Alex</p>
5,011,052
0
<p>The Python std lib includes a diff module, difflib. Here is a stab at your problem:</p> <pre><code>&gt;&gt;&gt; import difflib &gt;&gt;&gt; f1 = "111xxx222" &gt;&gt;&gt; f2 = "111yyy222" &gt;&gt;&gt; sm = difflib.SequenceMatcher(a=f1, b=f2) &gt;&gt;&gt; diff_re = '' &gt;&gt;&gt; for a,b,n in sm.get_matching_blocks(): ... if not n: continue ... if diff_re: diff_re += "(.*)" ... diff_re += f1[a:a+n] ... &gt;&gt;&gt; print diff_re '111(.*)222' </code></pre>
812,502
0
<p>You might have some luck using <a href="http://en.wikipedia.org/wiki/IKVM" rel="nofollow noreferrer">IKVM.NET</a>. I'm not sure on its exact status, but it's worth a try if you're insistent on running Java code on the .NET Framework. It includes a .NET implementation of the Java base class library, so it seems reasonably complete.</p> <p>The only other option I might suggest is porting the code to the <a href="http://en.wikipedia.org/wiki/J_Sharp" rel="nofollow noreferrer">J#</a> language, a full .NET language (although not first class in the sense that C# or VB.NET is). The language was designed so that the differences with Java were minimal.</p>
26,030,379
0
<p>In Chrome 37 on my machine, window.localStorage does sync between tabs. I'm not sure about other browsers though and it wouldn't be reactive automatically if you used that method.</p> <p>You are probably best off using a collection with documents assigned by user ID, then you can rely on Meteor's reactivity.</p>
29,800,405
0
<p>Here the script version!</p> <pre><code> using UnityEngine; using System.Collections; using UnityEngine.UI; public class SetTransparancy : MonoBehaviour { public Button myButton; // Use this for initialization void Start () { myButton.image.color = new Color(255f,0f,0f,.5f); } // Update is called once per frame void Update () { } } </code></pre> <p>I tested it in Unity5</p>
24,837,015
0
<p>According to the discussion <a href="https://code.google.com/p/topic-modeling-tool/issues/detail?id=3" rel="nofollow">here</a>, people have been using it for French and Russian</p>
38,196,355
0
<p>The issue mostly has to do with stale cached data (I experienced the same). The following should solve your problem.</p> <ol> <li>Go to: 'Preferences > Available Software Sites'</li> <li>Mark all, and 'Export' to file.</li> <li>Delete everything (all the links)</li> <li>Close and Start STS</li> <li>Go to: 'Preferences > Available Software Sites'</li> <li>'Import' from the previously saved file.</li> <li>Go to, 'Help > Check for updates'</li> <li>Update</li> </ol> <p>Basically this procedure clears up all the stale data.</p>
38,428,949
0
<p>Either call <code>dialog.show()</code>; after all the initialization and interface registration, Or to separate the dialog from your activity for making your code modular, you can do to following:</p> <ol> <li>Create a <code>class</code> extending <code>Dialog</code>.</li> <li>Create a <code>method</code> in your dialog <code>class</code> to accept the <code>OnClickListener</code> and save it at <code>class</code> level inside dialog <code>class</code>. </li> <li>From <code>activity</code> after launching that dialog call than method with your <code>activity's</code> dialog.</li> <li>In your <code>Dialog class</code> set a New <code>OnClickListener</code> on your dialog's button.</li> <li>And onclick of that button just manually give callback to <code>activity's</code> <code>OnClickListener</code>.</li> </ol> <p>Hope it helps!</p>
1,301,365
0
PHP/Amazon S3: Query string authentication <p>I have been using the <code>Zend_Service_Amazon_S3</code> library to access Amazon S3, but have been unable to find anything that correctly deals with generating the secure access URLs.</p> <p>My issue is that I have multiple objects stored in my bucket with an ACL permission of access to owner only. I need to be able to create URLs that allow timed access. However, <a href="http://docs.amazonwebservices.com/AmazonS3/latest/S3_QSAuth.html" rel="nofollow noreferrer">the documentation for Amazon S3</a> is very brief on the subject.</p> <p>Could someone elaborate, or provide a link to something that explains how I might achieve this in PHP?</p>
33,788,003
0
JFileChooser GUI opens file XML correctly but then doesn't read it correclty <p>I am trying to do the following exercise:</p> <p>Write a graphics program that allows a user to load an XML file from the disk using a file chooser GUI component. Once the file is open, its content is displayed in a java text area GUI component. A sample XML file can be found on moodle ‘Books.xml’.</p> <p>It works but the xml document is not read correctly. The &lt;> appear. See picture below :</p> <p><a href="https://i.stack.imgur.com/UEOVT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UEOVT.png" alt="Image"></a></p> <p><strong>1- This is my class ReadFilewithGui:</strong></p> <pre><code>package Tut5Ex2Part1; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JTextArea; import java.awt.BorderLayout; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.Font; public class ReadFileWithGui { private JFrame frame; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { ReadFileWithGui window = new ReadFileWithGui(); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the application. */ public ReadFileWithGui() { initialize(); } /** * Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); JTextArea textArea = new JTextArea(); textArea.setBounds(56, 73, 346, 100); frame.getContentPane().add(textArea); JButton btnGetFile = new JButton("Get file"); btnGetFile.setFont(new Font("Lantinghei TC", Font.PLAIN, 13)); btnGetFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { OpenFile of= new OpenFile(); try{ of.PickMe(); } catch (Exception e){ e.printStackTrace(); } textArea.setText(of.sb.toString()); } }); btnGetFile.setBounds(175, 219, 117, 29); frame.getContentPane().add(btnGetFile); } </code></pre> <p><strong>This is my OpenFileClass:</strong></p> <pre><code>package Tut5Ex2Part1; import java.util.Scanner; import javax.swing.JFileChooser; public class OpenFile{ JFileChooser fileChooser = new JFileChooser(); StringBuilder sb = new StringBuilder(); //String builder is not inmutable public void PickMe() throws Exception{ //Opens open file dialog if(fileChooser.showOpenDialog(null)== JFileChooser.APPROVE_OPTION) { //returns selected file. We are using the GUI file chooser java.io.File file = fileChooser.getSelectedFile(); //creates a scanner for the file Scanner input = new Scanner(file); while(input.hasNext()){ sb.append(input.nextLine()); sb.append("\n"); } //closes scanner when we are finished input.close(); } else{ //if file not selected. example cancel botton. sb.append("You have not selected a file"); } } } </code></pre> <p><strong>This is my XML file</strong></p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;catalog&gt; &lt;book id="bk101"&gt; &lt;author&gt;Gambardella, Matthew&lt;/author&gt; &lt;title&gt;XML Developer's Guide&lt;/title&gt; &lt;genre&gt;Computer&lt;/genre&gt; &lt;price&gt;44.95&lt;/price&gt; &lt;publish_date&gt;2000-10-01&lt;/publish_date&gt; &lt;description&gt;An in-depth look at creating applications with XML.&lt;/description&gt; &lt;/book&gt; &lt;/catalog&gt; </code></pre> <p>Any help is welcome! Thanks :)</p>
38,700,795
0
<p>A correct solution FWIW:</p> <pre><code>$ awk 'NR==1{n=split($0,d)} {for (i=1;i&lt;=n;i++) printf "%s%s", (i&gt;NF ? d[i] : $i), (i&lt;n ? OFS : ORS)}' file a 12 17 bac 30 42 a 15 18 bac 30 42 a 18 22 bac 30 42 </code></pre>
19,971,085
0
<p>Just replace your code With this one 100% tested </p> <pre><code>&lt;?php $xd = 'Sria.plan|Fnzas|139|Lopez%20Portillo%20Alcantara%20Jorge%20Ernesto|29|2013-05-01|0000188B|T|Titular|1984-03-19|2011-07-16|H|341.45|6305|276|153|673.4|7407.4|1185.18|8592.58|8674.75,Sria.plan.fnzas|Tesoreria|1538|Rodriguez%20Guzman%20Noemi|58|2011-05-01|0000188A|T|Titular|1998-12-16|1994-07-09|M|1083.78|20841|276|153|2127|23397|3743.52|27140.5|27222.7,Sria.plan.fnzas|Tesoreria|1500|Martinez%20Rodriguez%20Edith|23|2013-05-01|0000188C|B|Hija|1989-07-25|2006-04-16|M|438.62|8208|276|153|863.7|9500.7|1520.11|11020.8|11103'; $datosCompletos = explode(',', $xd); $longArreglo = count($datosCompletos); for ($i = 0; $i &lt; $longArreglo; $i++) { $arregloInformacion = explode('|', $datosCompletos[$i]); $longInformacion = count($arregloInformacion); $dato = "dato" . $i; for ($u = 0; $u &lt; $longInformacion; $u++) { $final_array[$dato][$u] = $arregloInformacion[$u]; } } echo "&lt;pre&gt;"; print_r($final_array); ?&gt; </code></pre> <p>Output will be </p> <pre><code>Array ( [dato0] =&gt; Array ( [0] =&gt; Sria.plan [1] =&gt; Fnzas [2] =&gt; 139 [3] =&gt; Lopez%20Portillo%20Alcantara%20Jorge%20Ernesto [4] =&gt; 29 [5] =&gt; 2013-05-01 [6] =&gt; 0000188B [7] =&gt; T [8] =&gt; Titular [9] =&gt; 1984-03-19 [10] =&gt; 2011-07-16 [11] =&gt; H [12] =&gt; 341.45 [13] =&gt; 6305 [14] =&gt; 276 [15] =&gt; 153 [16] =&gt; 673.4 [17] =&gt; 7407.4 [18] =&gt; 1185.18 [19] =&gt; 8592.58 [20] =&gt; 8674.75 ) [dato1] =&gt; Array ( [0] =&gt; Sria.plan.fnzas [1] =&gt; Tesoreria [2] =&gt; 1538 [3] =&gt; Rodriguez%20Guzman%20Noemi [4] =&gt; 58 [5] =&gt; 2011-05-01 [6] =&gt; 0000188A [7] =&gt; T [8] =&gt; Titular [9] =&gt; 1998-12-16 [10] =&gt; 1994-07-09 [11] =&gt; M [12] =&gt; 1083.78 [13] =&gt; 20841 [14] =&gt; 276 [15] =&gt; 153 [16] =&gt; 2127 [17] =&gt; 23397 [18] =&gt; 3743.52 [19] =&gt; 27140.5 [20] =&gt; 27222.7 ) [dato2] =&gt; Array ( [0] =&gt; Sria.plan.fnzas [1] =&gt; Tesoreria [2] =&gt; 1500 [3] =&gt; Martinez%20Rodriguez%20Edith [4] =&gt; 23 [5] =&gt; 2013-05-01 [6] =&gt; 0000188C [7] =&gt; B [8] =&gt; Hija [9] =&gt; 1989-07-25 [10] =&gt; 2006-04-16 [11] =&gt; M [12] =&gt; 438.62 [13] =&gt; 8208 [14] =&gt; 276 [15] =&gt; 153 [16] =&gt; 863.7 [17] =&gt; 9500.7 [18] =&gt; 1520.11 [19] =&gt; 11020.8 [20] =&gt; 11103 ) ) </code></pre>
2,234,101
0
<p>If you're willing to shell out a little money, there's slickedit <a href="http://www.slickedit.com/" rel="nofollow noreferrer">http://www.slickedit.com/</a></p> <p>I used version 9 on Linux for development of a mixed C/C++ app. The completion is quite good, very similar to Visual Studio. It's worth a look anyway, there's a free trial.</p>
11,269,893
0
<p>Unfortunately no one has made a plugin for it yet. It's possible, it would just involve you figuring out how to do it. Might be worth a try. I'm sure a lot of people would use it/find it helpful since there is no plugin that does the job at the moment. </p>
26,009,744
0
Matlab Substring as function call? <p>I am trying to figure out this substring feature and whether there exists a function call for it or not. As far as I can find, <a href="http://stackoverflow.com/questions/16126847/how-do-i-get-substring-to-work-in-matlab">here</a> and <a href="http://stackoverflow.com/questions/20366333/extract-substring-from-the-last-position-in-matlab">here</a> along with various other places, there simply is no related function for this since strings are char arrays, and so they settled for only implementing the indexing feature.</p> <p>MWE:</p> <pre><code>fileID = fopen('tryMe.env'); outDate = fgetl(fileID); </code></pre> <p>Where the file <code>'tryMe.env'</code> only consists of 1 line like so:</p> <pre><code>2014/9/4 </code></pre> <p>My wanted result is:</p> <pre><code>outDate = '14/9/4' </code></pre> <p>I am trying to find a clean, smooth one liner to go with the variable definition of <code>outDate</code>, something along the lines of <code>outDate = fgetl(fileID)(3:end);</code>, and not several lines of code.</p> <p>Thank you for your time!</p>
4,408,398
0
<p>How about iterating over all the static dependency properties (using <code>Reflection</code>) of that control's type and resetting bindings on them?</p>
22,271,821
0
<p>If Scala / Java interoperability is not too much of an issue for you, and if you're willing to use an internal DSL with a couple of syntax quirks compared to the syntax you have suggested, then <a href="http://www.jooq.org" rel="nofollow">jOOQ</a> is growing to be a popular alternative to <a href="http://slick.typesafe.com/" rel="nofollow">Slick</a>. An example from the <a href="http://www.jooq.org/doc/latest/manual/getting-started/jooq-and-scala/" rel="nofollow">jOOQ manual</a>:</p> <pre><code>for (r &lt;- e select ( T_BOOK.ID * T_BOOK.AUTHOR_ID, T_BOOK.ID + T_BOOK.AUTHOR_ID * 3 + 4, T_BOOK.TITLE || " abc" || " xy" ) from T_BOOK leftOuterJoin ( select (x.ID, x.YEAR_OF_BIRTH) from x limit 1 asTable x.getName() ) on T_BOOK.AUTHOR_ID === x.ID where (T_BOOK.ID &lt;&gt; 2) or (T_BOOK.TITLE in ("O Alquimista", "Brida")) fetch ) { println(r) } </code></pre>
28,291,534
0
<pre><code>if(!empty($_SESSION['c_id']) || !empty($_SESSION['c_id'])) { //Login here } else { //Please Login } </code></pre>
6,080,405
0
<p>This is SQL Server backup database file. You can restore it by following these steps: <a href="http://msdn.microsoft.com/en-us/library/ms177429.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms177429.aspx</a></p>
36,824,585
0
Does RTCPeerConnection work in Microsoft Edge? <p>I am currently working on VoIP using WebRTC. It's going to be a UWP application written in JavaScript.</p> <p>Now, I am trying to check whether it works or not by testing samples from <a href="https://webrtc.github.io/samples" rel="nofollow">https://webrtc.github.io/samples</a> on Microsoft Edge. </p> <p>It turns out that it works fine <strong>except</strong> <code>RTCPeerConnection</code>. </p> <p>For example, when I opened <a href="https://webrtc.github.io/samples/src/content/peerconnection/audio" rel="nofollow">https://webrtc.github.io/samples/src/content/peerconnection/audio</a> in Edge, it gave me <code>getUserMedia() error: NotFoundError</code> when I clicked the call button. On Chrome, it works fine.</p> <p>Another example is when I tried <a href="https://apprtc.appspot.com" rel="nofollow">https://apprtc.appspot.com</a>, it gave me </p> <pre><code>Messages: Error getting user media: null getUserMedia error: Failed to get access to local media. Error name was NotFoundError. Continuing without sending a stream. Create PeerConnection exception: InvalidAccessError Version: gitHash: c135495bc71e5da61344f098a8209a255f64985f branch: master time: Fri Apr 8 13:33:05 2016 +0200 </code></pre> <p>So, how should I fix that? <code>Adapter.js</code> is also called. I also allow everything it needs.</p> <p>Or I shouldn't use WebRTC for this project. If so, what should I use?</p> <p>Cheers!</p>
39,696,189
0
How to use tabs in angular2 <p>I have an application that uses angular2 with routes.ts properly set. In the app, I have navbar set according to the routes defined in routes.ts.</p> <p>In one of the route, I want to use a tab that does not refer to routes.ts but instead I want it to refer to the tab-content class.</p> <p>When I tried to run my application, I got an error that said the route is not defined in the routes.ts.</p> <p>How do I make tabs that refer to tab-content class instead of routes.ts?</p> <p>app.component.ts code:</p> <pre><code>import { Component } from '@angular/core'; import { ROUTER_DIRECTIVES } from '@angular/router'; import { FooterComponent, HEADER_DIRECTIVES, NAVBAR_DIRECTIVES } from 'ui-core/core'; import { HomeComponent } from './components/home/home.component'; import { PrintJobComponent } from './components/printJob/printJob.component'; @Component({ selector: 'app-template', template: ` &lt;cui-header title="Sample App"&gt; &lt;cui-navbar&gt; &lt;cui-navbar-item route="/printJob"&gt;Print Job&lt;/cui-navbar-item&gt; &lt;cui-navbar-item route="/home"&gt;Home&lt;/cui-navbar-item&gt; &lt;/cui-navbar&gt; &lt;/cui-header&gt; &lt;router-outlet&gt;&lt;/router-outlet&gt; &lt;cui-footer [helpRoutePath]="helpRoutePath"&gt;&lt;/cui-footer&gt; `, directives: [FooterComponent, HEADER_DIRECTIVES, ROUTER_DIRECTIVES, NAVBAR_DIRECTIVES] }) export class AppComponent { } </code></pre> <p>routes.ts:</p> <pre><code>/** * angular2 imports */ import { RouterConfig, provideRouter } from '@angular/router'; /** * App Component imports */ import { HomeComponent } from './app/components/home/home.component'; import { PrintJobComponent } from './app/components/printJob/printJob.component'; export const APP_ROUTES: RouterConfig = [ { path: '', redirectTo: '/home', pathMatch: 'full' }, { path: 'printJob', component: PrintJobComponent }, { path: 'home', component: HomeComponent }, ]; export const APP_ROUTER_PROVIDERS = [ provideRouter(APP_ROUTES) ]; </code></pre> <p>printJob.component.ts code:</p> <pre><code> import { Component } from '@angular/core'; @Component({ selector: 'print-job', template: ` &lt;div class="container-fluid single-col-full-width-container"&gt; &lt;br&gt; &lt;ul class="nav nav-tabs"&gt; &lt;li&gt;&lt;a data-toggle="tab" href="#printJobTab"&gt;Print Job&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a data-toggle="tab" href="#reprintJobTab"&gt;Reprint Job&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div class="tab-content"&gt; &lt;div id="printJobTab" class="tab-pane fade"&gt; &lt;p&gt;table for print job here.&lt;/p&gt; &lt;/div&gt; &lt;div id="reprintJobTab" class="tab-pane fade"&gt; &lt;p&gt;table for reprint job here.&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; ` }) export class PrintJobComponent { } </code></pre>
24,924,051
0
How to route to static page with out change url path in asp.net mvc3 <p>Basically,I'm trying to route to a static page like this:</p> <p><code>http://127.0.0.1/mypage</code></p> <p>=route to=></p> <p>A static page in my website folder maybe <code>http://127.0.0.1/static/mypage.html</code></p> <p>I have tried:</p> <p>Add a route role: </p> <p><code>routes.MapRoute("StaticPage", "{pagename}", new { controller = "Common", action = "StaticPage" });</code></p> <p>Add an action in <code>Common Controller</code>:</p> <pre><code> public ActionResult StaticPage(string pagename) { return Redirect("/static/" + pagename + ".html"); } </code></pre> <p>But it will change the url and cause twice request, is there any other way(no iframe in view) to remain the url?</p>
12,446,175
0
How to order list according to the value of variable? (php) <p>First question to the people who know wordpress well: resource/system load wise is it better to query mysql directly and order result there? or use wordpress hooks WP_query fetch all posts and order them according to comments variable?</p> <p>I've this code, it fetches everything. I'd like to order this list according to <code>comments_number( '0', '1', '%' );</code> (higher commented ones at the top) and limit total number displayed to top 4.</p> <p>My code so far:</p> <pre><code> &lt;ul&gt; &lt;?php global $post; $all_events = tribe_get_events( array( 'eventDisplay'=&gt;'upcoming', 'posts_per_page'=&gt;-1 ) ); foreach($all_events as $post) { setup_postdata($post); ?&gt; &lt;li&gt; &lt;a title="&lt;?php the_title(); ?&gt;" href="&lt;?php the_permalink(); ?&gt;"&gt; &lt;?php if ( has_post_thumbnail () ) { echo get_the_post_thumbnail(array(100,100)); } else { echo '&lt;img width="100" height="100" alt="' .get_the_title().'" title="' .strip_tags(get_the_excerpt()).'" src="' .get_bloginfo('template_url') .'/thumbs/event-recent-thumb-na.png"&gt;'; } ?&gt; &lt;/a&gt; &lt;h3&gt;&lt;a title="&lt;?php the_title(); ?&gt;" href="&lt;?php the_permalink(); ?&gt;"&gt; &lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h3&gt; &lt;span&gt;&lt;?php echo tribe_get_start_date( $p-&gt;ID, true, 'M j, D.' ) . " - " . tribe_get_end_date( $p-&gt;ID, true, 'D.' ); ?&gt;&lt;/span&gt; &lt;p&gt;&lt;?php echo strip_tags(get_the_excerpt()); ?&gt;&lt;/p&gt; &lt;span class="eventinterested"&gt;&lt;?php comments_number( '0', '1', '%' ); ?&gt; &lt;?php _e('interested so far','holidayge'); ?&gt;&lt;/span&gt; &lt;/li&gt; &lt;?php } //endforeach ?&gt; &lt;?php wp_reset_query(); ?&gt; &lt;/ul&gt; </code></pre> <p>Is there a way to modify <code>foreach</code> and order list there? I'm not php programmer, but it seems logical... I'm reading about <a href="http://php.net/manual/en/function.sort.php" rel="nofollow">Sort</a> seems like correct solution?</p>
16,171,467
0
Instantiate a class in a case-insensitive way <p>I'm faced with a bit of an issue. I have my class name in a variable and I need to instantiate it, but I have no way of knowing that my variable has the exact same case than the class.</p> <p>Example:</p> <pre><code>//The class I'm fetching is named "App_Utils_MyClass" $var = "myclass"; $className = "App_Utils_".$var; $obj = new $className(); </code></pre> <p>How can I make this work?</p> <p>Additional info:</p> <ul> <li>I have a <code>class_exists()</code> check (case insensitive) before this snippet to make sure that the class I want actually exists.</li> <li>The class name is always properly camel-cased (e.g. <code>MySuperAwesomeClass</code>).</li> </ul>
4,595,294
0
<p>You can created a clustered index to keep these in the order you want.</p> <p><a href="http://msdn.microsoft.com/en-us/library/aa174523(v=sql.80).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa174523(v=sql.80).aspx</a></p>
34,851,795
0
How to get static image from google maps in iOS <p>I use google maps api for iOS. I want to get static image of special city and paste it in UIImageView. How can I make it?</p>
26,867,796
0
Generic mobile tests with appium <p>I'm new to mobile testing , and currently I research for an automation framework for mobile testing. I've started to look into Appium, and created some tests for the demo app I've made (one for IOS and the other for Android). I've managed to write a test for each of the platforms , but I was wondering , how difficult it might be to write a one generic test which will be executed on the both platforms with minimum adjustments ?</p> <p>Thanks </p>
34,251,834
0
<p>SSAS only accepts Windows auth. But you can close all Excel windows then start Excel from a command line like this:</p> <pre><code>runas /netonly /user:REALDOMAIN\YOURDOMAINUSERNAME "c:\path\to\excel.exe" </code></pre> <p>Then when it connects to Windows auth resources remotely it will connect as the user you mention in the runas command. </p>
24,805,490
0
Explain why storing the value of printf in a variable and then printing it gives an extra value? <p><code>int d; d=printf("\n%d%d%d%d",1,2,3,4); printf("%d",d); </code></p> <p>The code gives the output as 1,2,3,4,5. I don't understand why an integer greater than the last one is being printed.</p>
39,955,915
0
<p>As an alternative to the guard statement, you could also use the similar <code>if let</code> construct:</p> <pre><code>if let item = item["display-name"] as? String { print(item) } else { print("No display name") } </code></pre>
36,685,394
1
subprocess.CalledProcessError: returned non-zero exit status 0 <p>What is the meaning of this paradoxical error?</p> <blockquote> <p>subprocess.CalledProcessError: Command '/home/travis/build/fritzo/pomagma/build/debug/src/cartographer/cartographer' returned non-zero exit status 0</p> </blockquote> <p>It happens when I start a subprocess, then tell that subprocess to cleanly exit via a zmq socket. It appears that while zmq is polling, the process exits cleanly (exit code 0), and then this error is raised.</p> <p>Here's the whole traceback (from a <a href="https://travis-ci.org/fritzo/pomagma/builds/123794173" rel="nofollow">travis log</a>):</p> <pre><code>Traceback (most recent call last): File "/home/travis/virtualenv/python2.7_with_system_site_packages/bin/pomagma.make", line 9, in &lt;module&gt; load_entry_point('pomagma==0.2.8', 'console_scripts', 'pomagma.make')() File "/home/travis/virtualenv/python2.7_with_system_site_packages/local/lib/python2.7/site-packages/parsable.py", line 181, in dispatch dispatch(argv) File "/home/travis/virtualenv/python2.7_with_system_site_packages/local/lib/python2.7/site-packages/parsable.py", line 129, in dispatch parser(*args, **kwargs) File "/home/travis/virtualenv/python2.7_with_system_site_packages/local/lib/python2.7/site-packages/parsable.py", line 64, in parser fun(*typed_args, **typed_kwargs) File "/home/travis/build/fritzo/pomagma/pomagma/make.py", line 130, in test_atlas _test_atlas(theory) File "/home/travis/build/fritzo/pomagma/pomagma/make.py", line 59, in _test_atlas assert actual_size == expected_size File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__ self.gen.next() File "/home/travis/build/fritzo/pomagma/pomagma/cartographer/__init__.py", line 14, in load client.stop() File "/home/travis/build/fritzo/pomagma/pomagma/cartographer/client.py", line 207, in stop self._call(request) File "/home/travis/build/fritzo/pomagma/pomagma/cartographer/client.py", line 35, in _call self._poll_callback() File "/home/travis/build/fritzo/pomagma/pomagma/cartographer/server.py", line 66, in check self.log_error() File "/home/travis/build/fritzo/pomagma/pomagma/cartographer/server.py", line 73, in log_error raise CalledProcessError(self._proc.poll(), BINARY) subprocess.CalledProcessError: Command '/home/travis/build/fritzo/pomagma/build/debug/src/cartographer/cartographer' returned non-zero exit status 0 </code></pre>
36,256,635
0
mongoose right usage of multiple databases? <p>I have multiple <code>mongodb</code> connections in my project:</p> <pre><code>// db.coffee conn1 = mongoose.createConnection "mongodb://192.168.1.193/test" conn2 = mongoose.createConnection "mongodb://92.168.1.81/position" </code></pre> <p>I have a model named <code>PositionNoCity</code> which belongs to <code>conn2</code> and a model named <code>A</code> which belongs to <code>conn1</code>:</p> <pre><code>// a.coffee ASchema = new Schema { a: Number }, {collection: 'test'} mongoose.model 'A', ASchema // pos.coffee PositionNoCitySchema = new Schema { position_id: String, job_forward_stats: [{forward_position_num: Number, forward_position: String, forward_position_ratio: Number}], }, {collection: 'position_indicators_no_city'} mongoose.model 'PositionNoCity', PositionNoCitySchema </code></pre> <p>Now I want to use these models:</p> <pre><code>require './db' require './pos' require './a' mongoose = require 'mongoose' // I have to point out which connection to use here, but with index the code is very very bad A = mongoose.connections[1].model('A') PositionNoCity = mongoose.connections[2].model('PositionNoCity') PositionNoCity.findOne({position_id: "aaa"}).then(console.log).catch(console.log) A.findOne({'a': 1}).then(console.log).catch(console.log) </code></pre> <p>I have two questions:</p> <ol> <li>I just connect 2 times, why 3 connections?</li> <li>if I replace <code>mongoose.connections[2].model</code> with <code>mongoose.model</code>, I run failed. Anyway, <code>mongoose.connections[2].model</code> must be replaced somehow, so how to replace?</li> </ol>
40,524,081
0
<p>In the html code, replace:</p> <pre><code>&lt;a href="whatsapp://send?text=Hello"&gt; </code></pre> <p>with:</p> <pre><code>&lt;a href="intent://send?text=Hello#Intent;scheme=whatsapp;package=com.whatsapp;end"&gt; </code></pre> <p>See Chrome's docs about this here: <a href="https://developer.chrome.com/multidevice/android/intents#example" rel="nofollow noreferrer">https://developer.chrome.com/multidevice/android/intents#example</a></p>
30,379,123
0
<p>Java interfaces cannot have instance variables. If having them seems really appropriate to you, perhaps you should consider using <a href="https://docs.oracle.com/javase/tutorial/java/IandI/abstract.html" rel="nofollow">an abstract class</a> instead (or in addition) to an interface.</p>
21,805,767
0
<p>The problems are caused by this:</p> <pre><code> { (char) c = (int) c - 32 + key + 127; System.out.println(c); } </code></pre> <p>The <code>(char) c = ...;</code> is completely invalid syntax. </p> <p>An assignment is supposed to look like this <code>c = ...;</code>. </p> <p>If you want / need to do a type cast before assigning, the type cast belongs on the right hand side of the assignment operator; i.e. <code>c = (char)(...)</code>.</p> <hr> <p>Anyway, what you have written has cause the Java parser (in your IDE) to get thoroughly confused ... and <em>spectacularly</em> misdiagnose the error as an attempt to declare a constructor, it the wrong context.</p> <p>Unfortunately, this happens sometimes ... though it is compiler dependent. The compiler was trying to be helpful, but the compiler / compiler writer "guessed wrong" about what you were trying to write at that point.</p> <p>Then it appears that the compiler's syntax recovery has inserted a <code>{</code> symbol into its symbol stream in an attempt to fix things. The second error complains that there is no <code>}</code> to match the phantom <code>{</code> that it inserted. Again, it has guessed wrong.</p> <p>But the root cause of this was your original syntax error.</p> <hr> <p>For the record, the <code>int</code> cast in your original expression is not necessary. You <em>could</em> (and IMO should) write the assignment as this:</p> <pre><code>c = (char) (c - 32 + key + 127); </code></pre> <p><strong>Explanation:</strong> in Java, the arithmetic operators always promote their operands to <code>int</code> (or <code>long</code>) before performing the operation, and the result is an <code>int</code> (or <code>long</code>). That means that your explicit cast of <code>c</code> to an <code>int</code> is going to happen anyway.</p>
30,178,182
0
Collect RoutingError messages thrown <p>I've just put a rails 4 app into production, and I've noticed what look like a number of scripted attacks, mostly on urls that end with .php. They look like this:</p> <pre><code>I, [2015-05-11T22:03:01.715687 #18632] INFO -- : Started GET "/MyAdmin/scripts/setup.php" for 211.172.232.163 at 2015-05-11 22:03:01 +0100 F, [2015-05-11T22:03:01.719339 #18632] FATAL -- : ActionController::RoutingError (No route matches [GET] "/MyAdmin/scripts/setup.php"): actionpack (4.1.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' </code></pre> <p>I'd like to collect thee url from these RoutingError messages, mostly so I can set up routes for them, probably to simply render nothing.</p> <p>I'd also like to redirect to a site which might keep script runners busy.</p> <p>Anyway, here's the question. Is there any way I can intercept ActionController::RoutingError to run some code?</p> <hr> <p>Bonus question: Does anyone know if there's actually a lot of php apps out there which can be broken into with urls like the one above?</p>
35,692,662
0
Laravel - Multiple models for one table <p>In my project(laravel 4.2) I am using package for every module. I want every package independent to other, So is this recommend - Multiple models for one table?</p>
30,462,696
1
How add rows to list view in odoo? <p>I have a result data comming from wsdl file and I want to put this data in the treeview of my odoo module: </p> <p>This is my module architecture : init.py (where I import module.py) openerp.py (dependencies: Base) _module.py (where I've got the main code and everything works fine) templates.xml (Main view going with the main code, no problem)</p> <p>There is the .xml file:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;openerp&gt; &lt;data&gt; &lt;menuitem name="Document_Binov" id="Doc_Bin" sequence="30" /&gt; &lt;menuitem name="Documents" id="menu_list_doc" parent="Doc_Bin" sequence="10" /&gt; &lt;!-- Form example --&gt; &lt;record model="ir.ui.view" id="document_form"&gt; &lt;field name="name"&gt;document.form&lt;/field&gt; &lt;field name="model"&gt;document_binov.document_binov&lt;/field&gt; &lt;field name="type"&gt;form&lt;/field&gt; &lt;field name="arch" type="xml"&gt; &lt;form string="Documents"&gt; &lt;sheet&gt; &lt;group&gt; &lt;label string="Titre"/&gt; &lt;field name="titre"/&gt; &lt;label string="Description"/&gt; &lt;field name="description"/&gt; &lt;label string="Type"/&gt; &lt;field name="type"/&gt; &lt;/group&gt; &lt;/sheet&gt; &lt;/form&gt; &lt;/field&gt; &lt;/record&gt; &lt;!--Tree view example --&gt; &lt;record model="ir.ui.view" id="document_tree_view"&gt; &lt;field name="name"&gt;document.tree.view&lt;/field&gt; &lt;field name="model"&gt;document_binov.document_binov&lt;/field&gt; &lt;field name="type"&gt;tree&lt;/field&gt; &lt;field name="arch" type="xml"&gt; &lt;tree string="Documents"&gt; &lt;field name="titre"/&gt; &lt;field name="description"/&gt; &lt;field name="type" /&gt; &lt;/tree&gt; &lt;/field&gt; &lt;/record&gt; &lt;!-- déclaration d'action --&gt; &lt;record model="ir.actions.act_window" id="action_document_work"&gt; &lt;field name="name"&gt;Liste des documents&lt;/field&gt; &lt;field name="res_model"&gt;document_binov.document_binov&lt;/field&gt; &lt;field name="view_type"&gt;form&lt;/field&gt; &lt;field name="view_mode"&gt;tree,form&lt;/field&gt; &lt;!-- &lt;field name="help" type="html"/&gt; --&gt; &lt;field name="document_tree_view" ref="document_form"&gt;&lt;/field&gt; &lt;/record&gt; &lt;!--déclaration menu --&gt; &lt;!-- &lt;menuitem id="document" name="Documents" /&gt; --&gt; &lt;!-- déclaration de menu principale niveau 1--&gt; &lt;!-- déclaration de menu niveai 1.1(sans action=non cliquable) --&gt; &lt;menuitem id="document_menu" name="Liste des documents" parent="menu_list_doc" action="action_document_work" sequence="10"/&gt; &lt;/data&gt; &lt;/openerp&gt; </code></pre> <p>And there is the .py file:</p> <pre><code>class document_binov(models.Model): _name = 'document_binov.document_binov' _description = 'visualise les documents' titre = fields.Char(default='a') description = fields.Char('Description') type = fields.Char('Type') </code></pre> <p><img src="https://i.stack.imgur.com/EtSDr.png" alt="enter image description here"></p> <p>Please help me to put the my result data to the treeview. Thanks in advance</p>
27,177,474
0
<p>Assuming you have an image called <code>image.jpg</code>, paste this into a file called <code>go</code>, then type</p> <pre><code>php -f go </code></pre> <p>and you will see what your C++ should generate:</p> <pre><code>&lt;?php header("Content-type: image/jpeg"); readfile('image.jpg'); ?&gt; </code></pre>
20,194,605
0
<p>Only <code>functions</code> (and <code>subs</code>) can be referenced by <code>Set functionReference = GetRef("myFunction")</code> but not objects.</p> <p>When you want to have a string reference, you have to create one with each object you would want to refer to. You can use a dictionary for that:</p> <pre><code>Dim foo, bar Dim StringObjectReference : Set StringObjectReference = CreateObject("Scripting.Dictionary") ' Lets create some objects Set foo = CreateObject("System.Collections.ArrayList") Set bar = CreateObject("Scripting.Dictionary") ' Register the objects for referral, now we can reference them by string! StringObjectReference.Add "foo", foo StringObjectReference.Add "bar", bar ' Manipulate the objects through their string reference StringObjectReference("foo").Add "BMW" StringObjectReference("foo").Add "Chrysler" StringObjectReference("foo").Add "Audi" StringObjectReference("foo").Sort StringObjectReference("bar").Add "Bikes", array("Honda", "Thriumph") StringObjectReference("bar").Add "Quads", array("Honda", "Kawasaki", "BMW") ' Retrieve values from the objects ' real: msgbox "My Cars: " &amp; join(foo.ToArray(), ", ") msgbox "My Bikes: " &amp; join(bar("Bikes"), ", ") msgbox "My Quads: " &amp; join(bar("Quads"), ", ") ' From reference msgbox "My Cars: " &amp; join(StringObjectReference("foo").ToArray(), ", ") msgbox "My Bikes: " &amp; join(StringObjectReference("bar").Item("Bikes"), ", ") ' Shorthand notation (without item) msgbox "My Quads: " &amp; join(StringObjectReference("bar")("Quads"), ", ") </code></pre>
6,476,780
0
<p>There was a post from @niktrs that provided the right answer, but it's been deleted! </p> <p>So, here's the query I was looking for, with @niktrs help. If his post comes back, I'll accept it.</p> <pre><code>SELECT new_wage FROM hr_wages WHERE effective_date IN (SELECT effective_date,new_wage FROM hr_wages WHERE employee_code='06031-BOB') AND employee_code='06031-BOB' </code></pre> <p>This ugliness can be beautified, I'm sure.</p>
17,419,374
0
<p>Thanks to Sunil D.</p> <p>Finally I create extended <code>ItemRenderer</code> like below</p> <pre><code>public class LSLabelCircleItemRenderer extends CircleItemRenderer { private var _label:Label; public function LSLabelCircleItemRenderer():void { super(); _label = new Label(); } override protected function updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); if(data != null){ var ls:LineSeries = ChartItem(data).element as LineSeries; label.text = LineSeriesItem(data).yValue.toString(); skin.parent.addChild(label); label.setStyle("color",ls.getStyle("fill")); label.move(skin.x - label.getExplicitOrMeasuredWidth() / 5,skin.y - label.getExplicitOrMeasuredHeight()); } } } </code></pre>
10,153,577
0
<p>You can add .rc file to your project and include "wx/msw/wx.rc" in it. Then themes should be applied to your GUI (take a look at default samples bundled with wxWidgets - <a href="http://screencast.com/t/QTaQqCxO692w" rel="nofollow">http://screencast.com/t/QTaQqCxO692w</a>).</p>
2,220,730
0
<p>Just zero out the appropriate matrix elements. In a 4x4 3D-transform matrix, these are stored as the three first elements in either in the rightmost column or bottom row, depending on whether you use pre- or post-multiplication.</p> <p>If your Matrix class has a method to get the translation, it probably also has a method to add translations. In that case, just add the opposite translation of what you already have.</p>
29,541,993
0
<p>Its acctualy possible ;-)</p> <pre><code># not pep8 compatible^ sam = ['Sam',] try: print('hello',sam) if sam[0] != 'harry' else rais except: pass </code></pre> <p>You can do very ugly stuff in python like:</p> <pre><code>def o(s):return''.join([chr(ord(n)+(13if'Z'&lt;n&lt;'n'or'N'&gt;n else-13))if n.isalpha()else n for n in s]) </code></pre> <p>which is function for rot13/cesa encryption in one line with 99 characters. </p>
5,102,533
0
<p>You´ll want to use NSWindowLevel, in specific kCGDesktopWindowLevel. A short overview on NSWindowLevel can be found <a href="http://cocoadev.com/index.pl?NSWindowLevel" rel="nofollow">here</a>, and a <a href="http://stackoverflow.com/questions/4982584/how-do-i-draw-the-desktop-on-mac-os-x/4987525#4987525">more elaborate solution</a> has been posted to a <a href="http://stackoverflow.com/questions/4982584/how-do-i-draw-the-desktop-on-mac-os-x">similar stackoverflow question</a> before.</p>
36,079,592
0
Passing realmobject with parcel to activity has return null <p>can anyone help me with my problem with passing realmobject with parcel to another activity and in second activity my object is null? </p> <p>In Activity i get instatne of class Category from tag. </p> <pre><code> Intent intent = new Intent(context, CategoryListActivity.class); Category category = (Category)v.getTag(); Log.e("Id", " "+category.getId()); //this is ok it prints 1 Parcelable parcelable = Parcels.wrap(category); intent.putExtra("category", parcelable); startActivity(intent); </code></pre> <p>And in class CategoryListActivity v method onCreate is code </p> <pre><code>Intent intent = getIntent(); Category category = Parcels.unwrap(intent.getParcelableExtra("category")); Category category1= Parcels.unwrap(getIntent().getExtras().getParcelable("category")); Log.e("Id 1", " "+category.getId()); //retun 0 Log.e("Id 1", " "+category1.getId()); //return 0 </code></pre> <p>And this print 0 and i rly dont know why is 0. Can anyone has some suggestion to resolve this? thx, or if its necessery insert my Entity which extend RealmObject i can paste </p>
10,186,225
0
<p>It is possible to use a custom request handler that enables django's i18n trans tag with google app engine. But much better is use jinja2 like is said here, then the solution is official. You should import jinja2 from webapp2_extras and then your i18n will work and the translation tag for jinja2 will look like <code>{% trans %}</code> and <code>{ % endtrans %}</code>.</p> <p>If you must use django here is a link to an old blod post that presents a custom request handler that you can use if you must use django templates: <a href="http://blog.yjl.im/2009/02/using-django-i18n-in-google-app-engine.html" rel="nofollow">http://blog.yjl.im/2009/02/using-django-i18n-in-google-app-engine.html</a></p> <p>But we recommend that you use jinja2. Have you tried it?</p>
1,634,359
0
Is there a reverse function for strstr <p>I am trying to find a similar function to <code>strstr</code> that searches a substring starting from the end towards the beginning of the string.</p>
30,357,837
0
<p>You will need to combine it with AJAX or jQuery codes. It is not only php!</p> <p>Check this out: - <a href="http://stackoverflow.com/questions/10805187/jquery-login-form-in-div-without-refreshing-whole-page">jquery login form in div without refreshing whole page</a></p>