title
stringlengths
15
150
body
stringlengths
38
32.9k
label
int64
0
3
How to match user input with arraylist
<pre><code>package BankingSystem; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Bank { public static void main(String [] args){ List&lt;String&gt; AccountList = new ArrayList&lt;String&gt;(); AccountList.add("45678690"); Scanner AccountInput = new Scanner(System.in); System.out.println("Hi whats your pin code?"); AccountInput.nextLine(); for (int counter = 0; counter &lt; AccountList.size(); counter++){ if (AccountInput.equals(AccountList.get(counter))){ //If Input = ArrayList number then display "hi" System.out.println("Hi"); } else { //If not = to ArrayList then display "Incorrect" System.out.println("Incorrect"); } } } } </code></pre> <p>Hi, in here I am trying to match the userInput to arrayList, if its correct then display "hi" if not display "Incorrect", for the incorrect part do I to use exception handling? and how can I get it to match the ArrayList number - 45678690?</p>
1
Only load a javascript file depending on screen size
<p>I'm working on making a website responsive. For now the website will have to have two banners- one for desktop and one fro the mobile site.</p> <p>I've got everything in place with media querys etc. however I've now noticed that something in the <code>desktop banner javascript file</code> is causing the <code>mobile banner javascript</code> to not function properly. </p> <p>So I figured I could try to only load the <code>desktop banner js file</code> only if the screen is above a certain size, let's say 1000px.</p> <p>I'm not sure if that's possible though and how? Or is there some other way to cancel out the <code>desktop js file</code> when the mobile banner is displayed?</p> <p>Any suggestions are appreciated!</p>
1
Using custom icons/font in SAP Fiori launchpad
<p>I am searching for a way to use custom icon fonts already in the Fiori Launchpad.</p> <p>I found one way using the <em>UI theme designer</em>: <a href="https://blogs.sap.com/2015/12/19/custom-icons-in-fiori-launchpad/" rel="nofollow noreferrer">https://blogs.sap.com/2015/12/19/custom-icons-in-fiori-launchpad/</a>. But as I understand these icons are only available with a custom theme.</p> <p>I am searching a way to register my own font so that the icons are available similar as the <em>Fiori launch icons</em>.</p> <p>Looks like they are stored here: <code>/UI5/sap/ushell/themes/base/fonts/</code> and referenced by the default themes, like here: <code>/UI5/sap/fiori/themes/sap_bluecrystal/library.css</code></p> <pre class="lang-css prettyprint-override"><code>@font-face { font-family: 'Fiori2'; src: url(&quot;../../../../../UI5/sap/ushell/themes/base/fonts/sap-launch-icons.eot&quot;); src: url(&quot;../../../../../UI5/sap/ushell/themes/base/fonts/sap-launch-icons.eot?#iefix&quot;) format('embedded-opentype'), url(&quot;../../../../../UI5/sap/ushell/themes/base/fonts/sap-launch-icons.ttf&quot;) format('truetype'); font-weight: normal; font-style: normal; } </code></pre> <p>The icons are also available in the &quot;Icon&quot; selector of <em>Fiori Launchpad Designer</em> (FLPD) by name. So the questions are:</p> <ol> <li>Is it possible to use own fonts similar to existing fonts?</li> <li>If so, where and how should the font be placed?</li> <li>If so, where and how should the icon names be defined, so that they can be used like this: <code>&quot;sap-icon://myNameSpace/iconname&quot;</code>?</li> </ol> <p>I know already how to do it inside my own apps using <code>sap/ui/core/IconPool</code> (For reference: <a href="https://ui5.sap.com/#/topic/21ea0ea94614480d9a910b2e93431291" rel="nofollow noreferrer">https://ui5.sap.com/#/topic/21ea0ea94614480d9a910b2e93431291</a>). But how to do it <strong>in a standard theme</strong> inside the Fiori Launchpad / Fiori launchpad Designer?</p>
1
How to delete groups containing less than 3 rows of data in R?
<p>I'm using the dplyr package in R and have grouped my data by 3 variables (Year, Site, Brood). </p> <p>I want to get rid of groups made up of less than 3 rows. For example in the following sample I would like to remove the rows for brood '2'. I have a lot of data to do this with so while I could painstakingly do it by hand it would be so helpful to automate it using R. </p> <pre><code>Year Site Brood Parents 1996 A 1 1 1996 A 1 1 1996 A 1 0 1996 A 1 0 1996 A 2 1 1996 A 2 0 1996 A 3 1 1996 A 3 1 1996 A 3 1 1996 A 3 0 1996 A 3 1 </code></pre> <p>I hope this makes sense and thank you very much in advance for your help! I'm new to R and stackoverflow so apologies if the way I've worded this question isn't very good! Let me know if I need to provide any other information.</p>
1
Creating JSON objects in Typescript
<p>How to create/save an array of JSON objects only when there is a new item? The problem I am having is:</p> <ol> <li>How can I create/save JSON objects directly or do I have to have a corresponding class object created?</li> <li>What Is the best way to check if particular item exists or not?</li> </ol>
1
ProgressBar in an AppCompatActivity toolbar
<p>I need to show a <code>ProgressBar</code> in any <code>Fragment</code> in a <code>ViewPager</code> inside an <code>AppCompatActivity</code>. </p> <p>Tried the <code>requestWindowFeature</code> and <code>supportRequestWindowFeature</code> approaches to no avail. So based on <a href="https://stackoverflow.com/questions/27788195/setprogressbarindeterminatevisibilitytrue-not-working">this answer</a>, here's what I am trying: </p> <p>Set up a progress bar like this:</p> <pre><code>public class MyMain extends AppCompatActivity { public static ProgressBar progressBar; : : @Override protected void onCreate(Bundle savedInstanceState) { : : setContentView(...); : : toolbar = (android.support.v7.widget.Toolbar)findViewById(R.id.toolbar); setSupportActionBar(toolbar); progressBar = (ProgressBar) findViewById(R.id.toolbarProgress); : : } } </code></pre> <p>The XML snippet is like so:</p> <pre><code>&lt;RelativeLayout android:id="@+id/rlMyMain" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;android.support.v4.widget.DrawerLayout android:id="@+id/mainDrawer" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/mainDrawerBackground"&gt; &lt;!-- Main content layout --&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"&gt; &lt;LinearLayout android:id="@+id/toolbarLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"&gt; &lt;android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/primaryColor"&gt; &lt;ProgressBar android:id="@+id/toolbarProgress" style="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:indeterminate="true" android:visibility="gone"/&gt; &lt;/android.support.v7.widget.Toolbar&gt; &lt;/LinearLayout&gt; : : : : </code></pre> <p><code>MyMain</code> contains a <code>ViewPager</code> that contains <code>Fragment</code>s. From any of the <code>Fragment</code>s, I am trying to show the progress using this code: </p> <pre><code>((MyMain)getActivity()).progressBar.setVisibility(View.VISIBLE); </code></pre> <p>Since there are no compile or runtime errors, the progress bar seems to be available to the <code>Fragment</code>, but just doesn't show up in the toolbar. </p> <p>There should be something wrong with this, but am unable to figure it out. Or is there a better approach? </p> <p>Many thanks in advance. </p>
1
'Input' does not contain a definition for 'GetMouseButton' how is this possible?
<p>I've wanted to try developing for touch screen but for some reason it said: </p> <blockquote> <p>'Input' does not contain a definition for 'touched'</p> </blockquote> <p>Then I tried with the old fashioned way, which worked for me a million times, but now doesn't.</p> <blockquote> <p>'Input' does not contain a definition for 'GetMouseButton'</p> </blockquote> <p>Does someone know the source of my problem?</p> <pre><code> void Update() { if(Input.GetMouseButton(0)) Debug.Log("Pressed left click."); if(Input.GetMouseButton(1)) Debug.Log("Pressed right click."); if(Input.GetMouseButton(2)) Debug.Log("Pressed middle click."); } </code></pre>
1
Python Requests Cannot Find Connection Adapters
<p>When I run the following code in Python3.4 on Windows8.1:</p> <pre><code>r = requests.get(url) </code></pre> <p>It returns, among other things:</p> <pre><code>File "C:\Python34\lib\site-packages\requests\sessions.py", line 644, in get_adapter raise InvalidSchema("No connection adapters were found for '%s'" % url) requests.exceptions.InvalidSchema: No connection adapters were found for '"http://example.com"' </code></pre> <p>Is this simply a problem with my code, my firewall or something else entirely? How would I go about fixing it?</p>
1
CSS z-index not working with child-elements
<p>Ive tried for a personal project to do menus, that are opened on highest layer (z-index 3) so they overlay my board, but the header in which they are is at lowest layer (z-index 1), so the board was assigned to mid-layer (z-index 2). Logically this looks fine to me, but menu is displayed as it was below z-index 2... Ive ran out of ideas how to fix that.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>* { margin: 0; padding: 0; } #header { width: 512px; height: 256px; position: fixed; z-index: 1; background-color: red; } div&gt;ul { width: 512px; height: 128px; position: fixed; z-index: 3; background-color: blue; } ol { width: 480px; height: 320px; margin: 32px 16px 0 16px; position: fixed; z-index: 2; background-color: green; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="header"&gt; &lt;ul&gt;&lt;/ul&gt; &lt;/div&gt; &lt;ol&gt; &lt;/ol&gt;</code></pre> </div> </div> </p> <p><a href="http://codepen.io/PaHell/pen/mVGJxd" rel="nofollow noreferrer">CodePen Sample</a></p>
1
Scrollview inside a viewpager fragment doesnt scroll when keyboard is shown
<p>I have an activity which has a layout content as follows:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"&gt; &lt;android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" android:minHeight="?attr/actionBarSize" style="@style/ToolBarStyle.Event" /&gt; &lt;com.mypackage.corecode.ui.view.SlidingTabLayout android:id="@+id/sliding_tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/primary_color" /&gt; &lt;android.support.v4.view.ViewPager android:id="@+id/vendor_main_tabview_pager" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>And inside viewpager, I have a fragment which has the following layout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"&gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:weightSum="3" android:orientation="horizontal"&gt; &lt;EditText android:theme="@style/ScrollableContentThemeNoActionBar" android:id="@+id/edit_text_vendor_sms_phone_number" android:layout_width="0dp" android:layout_weight="2" android:layout_height="wrap_content" android:inputType="number" /&gt; &lt;Button android:id="@+id/button_send_sms" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; &lt;/ScrollView&gt; </code></pre> <p>When the content inside the fragment doesn't fit the screen, the scrollview allows the user to see the content which is below the screen. (Works as expected)</p> <p>The problem is when the edittext gets focus, the keyboard overlaps the edittext area, rather than the scrollview causing the content to scroll.</p> <p>I expect the fragment to handle keyboard shown and scrollview to fit the keyboard on the screen.</p> <p>Or am I wrong and is activity responsible for the keyboard? Since the root view in activity layout is linearlayout, is it restricting the expansion?</p> <p>I tried wrapping the whole content of the activity layout with a scrollview, but this time viewpager doesnt appear on the screen if I don't give it a fixed size. Even when I do, I end up having a scrollview inside the fragment which is under the scrollview of the main layout and still keyboard is hovering over the edittext.</p> <p>I'm a bit lost here, my objective is to be able to scroll the fragment content when the edittext gets focused, but rather the keyboard overlaps the edittext currently.</p>
1
What happen to SketchFlow and what we should use instead?
<p>What is the new <strong>Microsoft way</strong> of UI prototyping since VS2015 doesn't support SketchFlow projects. <em>(I'm having hard time to accept that they removed such a useful tool without providing alternative)</em></p> <blockquote> <p>I know we still have <em>PowerPoint StoryBoards</em> for basic UI mock-ups but I would like to use interactive prototypes through Visual Studio. <em><strong>Therefore please do not suggest alternative products</strong></em></p> </blockquote>
1
How to get possibly overlapping matches in a string
<p>I'm looking for a way, either in Ruby or Javascript, that will give me all matches, possibly overlapping, within a string against a regexp.</p> <hr> <p>Let's say I have <code>str = "abcadc"</code>, and I want to find occurrences of <code>a</code> followed by any number of characters, followed by <code>c</code>. The result I'm looking for is <code>["abc", "adc", "abcadc"]</code>. Any ideas on how I can accomplish this?</p> <p><code>str.scan(/a.*c/)</code> will give me <code>["abcadc"]</code>, <code>str.scan(/(?=(a.*c))/).flatten</code> will give me <code>["abcadc", "adc"]</code>.</p>
1
HC-05(ZS-040) not responding to AT+INIT
<p>I'm using HC-05 Bluetooth module(ZS-040) right now. the module goes into command mode and respond to only few commands like, AT,AT+ROLE?,AT+ADDR? But as soon as I use AT+INIT it comes out of command mode and light starts to blink faster. Can you kindly help me out? I have even tried replacing the module in case that is not working but still the problem remains.</p> <p><strong>The code I'm using is given below-</strong></p> <p><a href="http://i.stack.imgur.com/kFxzp.png" rel="nofollow">code for HC-05 to enter command mode</a></p>
1
download local html file on client side
<p>I have a local file called test.html. The path to this file (relative) is "../slides/test.html".</p> <p>I would like to :</p> <ul> <li>Have a button to download this file</li> <li>Have a button to open this file in a new tab</li> </ul> <p>How can i do these 2 things ?</p> <p>I tried to get the file with ajax, i get data object containing html code of the file, but i don't know how to do to download and opening this file.</p> <pre><code>$.ajax({ url: "../slides/test.html", success: function(data){ alert(data); } }); </code></pre> <p><strong>UPDATE</strong></p> <p>I solve the problem by doing this :</p> <pre><code>&lt;ul class="buttonsList"&gt; &lt;li&gt;&lt;a href="#" id="fullscreenBtn"&gt;View in fullScreen&lt;/a&gt;&lt;/button&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" id="downloadBtn" download&gt;Download&lt;/a&gt;&lt;/button&gt;&lt;/li&gt; &lt;/ul&gt; // Register click on download button $("#downloadBtn").off().on('click', function() { var slideURL = $(".helpActive").attr("data-textTour-url"); $('#downloadBtn').attr({href : slideURL}); }); // Register click on download button $("#fullscreenBtn").off().on('click', function() { var slideURL = $(".helpActive").attr("data-textTour-url"); $('#fullscreenBtn').attr({target: '_blank', href : slideURL}); }); </code></pre>
1
Automatic export from SAP GUI (no direct access to Database)
<p>I'm looking for making <strong>automatic</strong> exports (extractions) from SAP. </p> <p>But there is some restraints :</p> <ul> <li>It's impossible to work with the SAP Support team on this subject</li> <li>I don't have direct access to SAP Database (Just a login/password for the SAP Gui)</li> <li><p>I want to computerize the action of a simple SAP User : </p> <p>-> Login to SAP Gui</p> <p>-> Access to the right menu (by name or transaction code)</p> <p>-> Put informations relating to the user (Site code, Department code, Material code, etc...) </p> <p>-> Put a dynamic range date (which could change every day)</p> <p>-> Extract data as a CSV file</p></li> </ul> <p>The final objective is to build a job schedule (every days at 00:00 for example) which create an export file (with SAP Data) on a file server. </p> <p>Every ideas are welcome (official or not).</p>
1
mysql using DISTINCT for only one column
<p>Is there a way to use DISTINCT (or another keyword) to not display duplicate results on one column? For example if I have a table with columns: id, name and countryCode</p> <pre><code>id name countryCode 1 Dan IE 2 John US 3 John UK 4 Bob DE </code></pre> <p>And I don't want to display duplicates where the name is the same so the result would be:</p> <pre><code>id name countryCode 1 Dan IE 2 John US 4 Bob DE </code></pre> <p>If I use DISTINCT here it needs to match the whole row but I only want to omit a row if the names match. Is there a way to do this? I found a similar solution here:<a href="https://stackoverflow.com/questions/5021693/distinct-for-only-one-column">DISTINCT for only one Column</a></p> <p>But this does not work for mySQL. Any help would be much appreciated.</p>
1
Python MySQLdb variables as table names
<p>I have a syntax error in my python which which stops MySQLdb from inserting into my database. The SQL insert is below.</p> <pre><code>cursor.execute("INSERT INTO %s (description, url) VALUES (%s, %s);", (table_name.encode("utf-8"), key.encode("utf-8"), data[key].encode("utf-8"))) </code></pre> <p>I get the following error in my stack trace.</p> <pre><code>_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''four' (description, url) VALUES ('', 'http://imgur.com/a/V8sdH')' at line 1") </code></pre> <p>I would really appreciate assistance as I cannot figure this out.</p> <p>EDIT:</p> <p>Fixed it with the following line:</p> <pre><code>cursor.execute("INSERT INTO " + table_name + " (description, url) VALUES (%s, %s);", (key.encode("utf-8"), data[key].encode("utf-8"))) </code></pre> <p>Not the most sophisticated, but I hope to use it as a jumping off point.</p>
1
How to underline active div
<p>I am trying to make a jQuery function for switching between two divs, but I don't know how to make an "active" link underlined. Like link with selected div.</p> <p>Here is the code:</p> <p>JS:</p> <pre><code>function toggleDiv(target) { var div = document.getElementById('wrapper').getElementsByTagName("div"); if (target == 1) { div[0].style.display = 'none'; div[1].style.display = 'block'; } else { div[0].style.display = 'block'; div[1].style.display = 'none'; } }; </code></pre> <p>HTML:</p> <pre><code>&lt;div id="button" onclick="toggleDiv(0)" style="padding-right: ;"&gt; &lt;p align="center"&gt;PSYCHOLOGIE A PSYCHOTERAPIE&lt;/p&gt; &lt;/div&gt; &lt;div id="button2" onclick="toggleDiv(1)" style="padding-left: ;"&gt; &lt;p align="center"&gt;PSYCHOLOGIE PRÁCE&lt;/p&gt; &lt;/div&gt; </code></pre>
1
.attr("value") is always returning undefined?
<p>I have a hidden element and within my jQuery:</p> <pre><code>&lt;input type="hidden" id="1val" value="24"&gt; var valID = $("#1val").attr("value"); </code></pre> <p>However when I try to print valID it is always printed as undefined? What am I doing wrong?</p> <p>Thanks</p>
1
How to implement badges in angular js
<p>I want to display a badge on my angular "ion-tab". I have one "tabs.html" file where my tabs code is written.</p> <pre><code>&lt;!-- some code --&gt; &lt;ion-tab icon-off="notificationIconDisabled" icon-on="notificationIconEnabled" href="#/tab/newjob" badge="{{newJobsCount}}" badge-style="badge-assertive"&gt; &lt;ion-nav-view name="tab-newjob"&gt;&lt;/ion-nav-view&gt; &lt;/ion-tab&gt; &lt;!-- some code --&gt; </code></pre> <p>I have another files as tab-setting.html, tab-myjobs.html and tab-newjobs.html. "myjobs.html" and "tab-newjobs.html" are using controller "jobCtrl.js". Now as I am trying to set badge through "jobCtrl.js" as follows, </p> <pre><code>$scope.newJobsCount = $scope.jobList.length; </code></pre> <p>I am unable to do it, and I am getting following error in browser for badge</p> <blockquote> <p>Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the expression [{{newJobsCount}}] starting at [{newJobsCount}}].</p> </blockquote> <p>can anybody please help me with an example how to implement badges in angular js??</p> <p>Thanks in advance.</p>
1
how to use goto statement in objective c?
<p>I want to skip some line of code by checking if condition in the same method. I used goto statement but it showed "cannot jump from this goto statement to the label". Is there any other way I can skip code? what I do is..</p> <pre><code>if(condition) goto skipped; //code to skip //code to skip skipped: //code to execute </code></pre>
1
OneSignal - cannot open activity after push clicked
<p>I am trying that. I send some AdditionalData from push and redirect user to spesific activity but not redirect. </p> <p>For example i send a push contains AdditionalData like imageID and redirect user ImageDetail activity with passing imageID parameter to other activity.</p> <p>When i click push, Main activity opens and nothing happens</p> <p>I tried but cannot be succeed. </p> <p>How can i fix it</p> <pre><code>public class MainActivity extends Activity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBarDrawerToggle mDrawerToggle; // nav drawer title private CharSequence mDrawerTitle; // used to store app title private CharSequence mTitle; // slide menu items private String[] navMenuTitles; private TypedArray navMenuIcons; private ArrayList&lt;NavDrawerItem&gt; navDrawerItems; private NavDrawerListAdapter adapter; private static MainActivity mInstance; private AccessToken facebookAccessToken; private SessionManager session; private String pushAdURL; private boolean isAdActive = false; private boolean isQRActive = false; private boolean isMaintenanceMode = false; SharedPreferences sp ; SharedPreferences.Editor editor; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); sp = PreferenceManager.getDefaultSharedPreferences(this); Log.e("MAIN", "Main activity has been called"); session = new SessionManager(getApplicationContext()); OneSignal.startInit(this) .setNotificationOpenedHandler(new NotificationHandler()) .init(); public static synchronized MainActivity getInstance() { return mInstance; } private class NotificationHandler implements OneSignal.NotificationOpenedHandler { /** * Callback to implement in your app to handle when a notification is opened from the Android status bar or * a new one comes in while the app is running. * This method is located in this Application class as an example, you may have any class you wish implement NotificationOpenedHandler and define this method. * * @param message The message string the user seen/should see in the Android status bar. * @param additionalData The additionalData key value pair section you entered in on onesignal.com. * @param isActive Was the app in the foreground when the notification was received. */ @Override public void notificationOpened(String message, JSONObject additionalData, boolean isActive) { Toast.makeText(getApplicationContext(), "Notification opened:" + message + "Addional: "+additionalData, Toast.LENGTH_SHORT).show(); Log.d("MESAJ:","message: " +message + "AditionData: " +String.valueOf(additionalData)); try{ if (additionalData != null) { Log.d("MESAJ:","Additionaldata is not null"); if (additionalData.has("action")) { Log.d("MESAJ:", "Title " + additionalData.getString("title")); Log.d("MESAJ:", "Additionaldata has action"); Log.d("MESAJ:", "Action is " + additionalData.getString("action")); Log.d("MESAJ:", "Action id is " + additionalData.getString("id")); if (additionalData.getString("action") == "openimage") { Log.d("MESAJ:","Additionaldata action is openimage"); String pusedImageId = additionalData.getString("id"); Log.d("MESAJ:", "Additionaldata action is " + pusedImageId); Intent intent = new Intent(getApplicationContext(), ImageDetail.class); intent.putExtra("imageid", pusedImageId); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else if (additionalData.getString("action") == "openboard") { Log.d("MESAJ:","Additionaldata action is openboard"); String pusedBoardId = additionalData.getString("id"); Log.d("MESAJ:","Additionaldata action is " +pusedBoardId); Intent intent = new Intent(getApplicationContext(), BoardDetail.class); intent.putExtra("boardid", pusedBoardId); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } } } } catch (Throwable t) { t.printStackTrace(); } /*try { if (additionalData != null) { if (additionalData.has("actionSelected")) additionalMessage += "Pressed ButtonID: " + additionalData.getString("actionSelected"); additionalMessage = message + "\nFull additionalData:\n" + additionalData.toString(); } Log.d("OneSignalExample", "message:\n" + message + "\nadditionalMessage:\n" + additionalMessage); } catch (Throwable t) { t.printStackTrace(); } android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(MainActivity.this); builder.setTitle("Bilgilendirme"); builder.setMessage(message + String.valueOf(additionalData)); builder.setPositiveButton("Tamam", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); android.app.AlertDialog alert = builder.create(); alert.show();*/ } } </code></pre> <p>}</p> <p>Here is the logcat results</p> <pre><code> 1-31 08:17:47.410 20682-20682/com.harmankaya.otokatalog D/MESAJ:: message: klAditionData: {"action":"openboard","id":"23123","title":"dsga"} 01-31 08:17:47.410 20682-20682/com.harmankaya.otokatalog D/MESAJ:: Additionaldata is not null 01-31 08:17:47.415 20682-20682/com.harmankaya.otokatalog D/MESAJ:: Title dsga 01-31 08:17:47.415 20682-20682/com.harmankaya.otokatalog D/MESAJ:: Additionaldata has action 01-31 08:17:47.415 20682-20682/com.harmankaya.otokatalog D/MESAJ:: Action is openboard 01-31 08:17:47.415 20682-20682/com.harmankaya.otokatalog D/MESAJ:: Action id is 23123 01-31 08:17:47.445 20682-20682/com.harmankaya.otokatalog D/OneSignal: curActivity is NOW: null 01-31 08:17:47.600 20682-20682/com.harmankaya.otokatalog V/BitmapFactory: DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/sym_def_app_icon.png 01-31 08:17:47.610 20682-20682/com.harmankaya.otokatalog D/AbsListView: Get MotionRecognitionManager 01-31 08:17:47.615 20682-20682/com.harmankaya.otokatalog E/MAIN: Main activity has been called </code></pre> <p>EDİT:Hımm i am near to finish :) I've added these lines to OnCreate method and i want to move mu push redirect logic to OnCreate method of MainActivity. But now i can not parse Bundle Intent extras :) </p> <pre><code> Intent intent = getIntent(); Bundle bundle = intent.getExtras(); Toast.makeText(getApplicationContext(), "Sonuç: " +bundle, Toast.LENGTH_SHORT).show(); Log.d("mesaj", "Result: " + bundle); if (bundle != null) { try { //TODO Push redirect logic Log.d("mesaj","String bundle : "+bundle.getString("onesignal_data")); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); Log.d("PUSH",String.valueOf(e)); } } </code></pre> <p>LOGCAT results</p> <pre><code>Sonuç: Bundle[{onesignal_data=[{"custom":"{\"a\":{\"action\":\"openboard\",\"id\":\"2345\"},\"i\":\"159c4c5d-37d2-45ec-ae90-6f103a4b8e83\"}","from":"111189706423","alert":"demopushbody","title":"demotitle","android.support.content.wakelockid":1,"collapse_key":"do_not_collapse"}]}] </code></pre>
1
R: how to get a user-defined function to return multiple outputs?
<p>I want to make a function that takes one variable and returns multiple outputs, so that I can use the latter for other purposes beyond the function. Take the simplified version below for example:</p> <pre><code>user &lt;- function(x){a &lt;- x+1; a &lt;- a+0.1; b &lt;- a*-1} sum(a,b) </code></pre> <p>So if I input <code>user(10)</code>, <code>a</code> would be 11.1, <code>b</code> would be -11.1, and <code>sum(a,b)</code> would return 0. But currently R is telling me neither object 'a' or object 'b' is found. How can I fix this?</p>
1
libevent - event_base_loop() should it get events repeatly?
<p>Here is a simple program using <code>libevent</code> on linux, it tracks the <code>stdout</code> fd, when it's writable, the callback will print some info to <code>stdout</code>.</p> <hr> <h2>Code</h2> <p><strong>hello_libevent.c:</strong></p> <pre><code>// libevent hello #include &lt;stdio.h&gt; #include &lt;string.h&gt; #include &lt;errno.h&gt; #include &lt;unistd.h&gt; #include &lt;event2/event.h&gt; #include &lt;event2/thread.h&gt; void event_callback(evutil_socket_t fd, short events, void *arg) { if(events | EV_WRITE) { write(fd, "hello\n", 7); } sleep(1); } int libevent_test() { int opr; // enable pthread if(evthread_use_pthreads() == -1) { printf("error while evthread_use_pthreads(): %s\n", strerror(errno)); return -1; } // create event_base struct event_base* eb; if((eb = event_base_new()) == NULL) { printf("error while event_base_new(): %s\n", strerror(errno)); return -1; } // create event int fd_stdout = fileno(stdout); struct event* event_stdout; event_stdout = event_new(eb, fd_stdout, EV_WRITE, &amp;event_callback, NULL); // add event as pending struct timeval timeout = {10, 0}; if(event_add(event_stdout, &amp;timeout) == -1) { printf("error while event_add(): %s\n", strerror(errno)); return -1; } // dispatch if((opr = event_base_loop(eb, EVLOOP_NONBLOCK)) == -1) { printf("error while event_base_dispatch(): %s\n", strerror(errno)); return -1; } else if(opr == 1) { printf("no more events\n"); } else { printf("exit normally\n"); } // free event event_free(event_stdout); return 0; } int main(int argc, char * argv[]) { return libevent_test(); } </code></pre> <p><strong>Compile:</strong></p> <blockquote> <p>gcc -Wall hello_libevent.c -levent -levent_pthreads</p> </blockquote> <p><strong>Execution result:</strong></p> <pre><code>hello no more events </code></pre> <hr> <h2>Questions:</h2> <ul> <li>In the test, event only occur once, is that the expected behavior? Or it should loop to get more event until timeout?</li> <li>How to make it get event continuously? Is it necessary to call <code>event_base_loop</code> within a loop, while it's already a <code>loop</code>?</li> </ul>
1
Use Lambda expression to get value from model
<p>Despite a lot of searching, I can't get the correct Lambda expression the get the info I want from the DB. My problem is this:</p> <p>An Action method in the controller gets an id value as an in parameter. With the id, I want to get the Name in the Products class that match the id with the Products CategoriesID. I have started, but I don't know how to finish it. Can I get some help with this? I guess I'm doing wrong here?</p> <pre><code>ViewBag.Categori = db.Products.Where(x =&gt; x.Name.Equals(??)) </code></pre>
1
how search a user input for a keyword in python
<p>How do I search a user input and find a specific keyword and then search a text file for this key word?</p> <p>This is what I have so far:</p> <pre><code>foods = str(input("what takeaway would you like today go sir/madame reply with one word answers")) with open("pizza.txt", "r") as f: searchlines = f.readlines() for i, line in enumerate(searchlines): if foods in line: print(line) </code></pre>
1
Raspberry Pi 7 inch Touchscreen rotate
<p>I have a small problem: I would like using Raspberry PI 7 inch LCD on portrait (standing) mode. (Kivy application) I added on /boot/config.txt: lcd_rotate=2 and display_rotate=1 The display is OK, but touch screen not good! The touch not rotating 90 degrees. How I rotate touch screen 90 degrees?</p>
1
Loading html and Controller from server and creating dynamic states UI - router
<p>I am looking for a Solution to load my App Content dynamically from the Server.</p> <p>My Scenario:</p> <p>Lets say we have 2 Users (A and B), my App consists of different Modules like lets say a shoppingList and a calculator, now my goal would be the User logs into my App from the Database I get the User rights and depending what rights he has, i would load the html for the views and the controller files for the logic part from the Server, while doing that I would create the states needed for the html and ctrl. So basically my App is very small consistent of the Login and everything else is getting pulled from the Server depending on the Userrights.</p> <p>What I use:</p> <ol> <li>Cordova </li> <li>AngularJs</li> <li>Ionic Framework</li> </ol> <p>Why I need it to be all dynamic:</p> <p>1)The possiblity to have an App that contains just the login logic, so when fixing bugs or adding Modules I only have to add the files to the server give the User the right for it and it is there without needing to update the app.</p> <p>2)The User only has the functionality he needs, he doesnt need to have everything when he only has the right for 1 module.</p> <p>3)The App grows very big at the moment, meaning every Module has like 5-10 states, with their own html and Controllers. currently there are 50 different Modules planned so you can do the math.</p> <p>I looked at this to get some inspiration:</p> <p><a href="https://stackoverflow.com/questions/26834507/angularjs-oclazyload-loading-dynamic-states">AngularJS, ocLazyLoad &amp; loading dynamic States</a></p> <p>What I tried so far:</p> <p>I created 1 Html file which contains the whole module so I only have 1 http request:</p> <p>Lets say this is my response from the server after the User logged in</p> <p>HTML Part:</p> <pre><code>var rights= [A,B,C,D] angular.forEach(rights, function (value, key) { $http.get('http://myServer.com/templates/' + value + '.html').then(function (response) { //HTML file for the whole module splits = response.data.split('#'); //Array off HTMl strings for (var l = 1; l &lt;= splits.length; l++) { //Putting all Html strings into templateCache $templateCache.put('templates/' + value +'.html', splits[l - 1]); } } }); </code></pre> <p>Controller Part:</p> <pre><code>var rights= [A,B,C,D] angular.forEach(rights, function (value, key) { $http.get('http://myServer.com/controller/' + value + '.js').then(function (response) { // 1 file for the whole module with all controllers splits = response.data.split('#'); //Array off controller strings for (var l = 1; l &lt;= splits.length; l++) { //Putting all Controller strings into templateCache $templateCache.put('controllers/' + value +'.js', splits[l - 1]); } } }); </code></pre> <p>After loading the Controllers I try to register them:</p> <pre><code>$controllerProvider.register('SomeName', $templateCache.get('controllers/someController)); </code></pre> <p>Which is not working since this is only a string...</p> <p>Defining the Providers:</p> <pre><code>.config(function ($stateProvider, $urlRouterProvider, $ionicConfigProvider, $controllerProvider) { // turns of the page transition globally $ionicConfigProvider.views.transition('none'); $stateProviderRef = $stateProvider; $urlRouterProviderRef = $urlRouterProvider; $controllerProviderRef = $controllerProvider; $stateProvider //the login state is static for every user .state('login', { url: "/login", templateUrl: "templates/login.html", controller: "LoginCtrl" }); //all the other states are missing and should be created depending on rights $urlRouterProvider.otherwise('/login'); }); </code></pre> <p>Ui-Router Part:</p> <pre><code>//Lets assume here the Rights Array contains more information like name, url... angular.forEach(rights, function (value, key) { //Checks if the state was already added var getExistingState = $state.get(value.name) if (getExistingState !== null) { return; } var state = { 'lang': value.lang, 'params': value.param, 'url': value.url, 'templateProvider': function ($timeout, $templateCache, Ls) { return $timeout(function () { return $templateCache.get("templates" + value.url + ".html") }, 100); }, 'ControllerProvider': function ($timeout, $templateCache, Ls) { return $timeout(function () { return $templateCache.get("controllers" + value.url + ".js") }, 100); } $stateProviderRef.state(value.name, state); }); $urlRouter.sync(); $urlRouter.listen(); </code></pre> <p>Situation so far:</p> <p>I have managed to load the html files and store them in the templateCache, even load them but only if the states were predefined.What I noticed here was that sometimes lets say when I remove an item from a List and come back to the View the item was there again maybe this has something to do with cache I am not really sure...</p> <p>I have managed to load the controller files and save the controllers in the templateCache but I dont really know how to use the $ControllerPrioviderRef.register with my stored strings...</p> <p>Creating the states did work but the Controller didnt fit so i could not open any views...</p> <p>PS: I also looked at require.js and OCLazyLoad as well as this example <a href="http://weblogs.asp.net/dwahlin/dynamically-loading-controllers-and-views-with-angularjs-and-requirejs" rel="nofollow noreferrer">dynamic controller example</a></p> <p>Update:</p> <p>Okay so I managed to load the <code>Html</code> , create the <code>State</code> with the <code>Controller</code> everything seems to work fine, except that the Controller does not seem to work at all, there are no errors, but it seems nothing of the Controller logic is executed. Currently the only solution to register the controller from the previous downloaded file was to use <code>eval(),</code> which is more a hack then a proper solution.</p> <p>Here the code:</p> <pre><code>.factory('ModularService', ['$http', ....., function ( $http, ...., ) { return { LoadModularContent: function () { //var $state = $rootScope.$state; var json = [ { module: 'Calc', name: 'ca10', lang: [], params: 9, url: '/ca10', templateUrl: "templates/ca/ca10.html", controller: ["Ca10"] }, { module: 'SL', name: 'sl10', lang: [], params: 9, url: '/sl10', templateUrl: "templates/sl/sl10.html", controller: ['Sl10', 'Sl20', 'Sl25', 'Sl30', 'Sl40', 'Sl50', 'Sl60', 'Sl70'] } ]; //Load the html angular.forEach(json, function (value, key) { $http.get('http://myserver.com/' + value.module + '.html') .then(function (response) { var splits = response.data.split('#'); for (var l = 1; l &lt;= value.controller.length; l++) { $templateCache.put('templates/' + value.controller[l - 1] + '.html', splits[l - 1]); if (l == value.controller.length) { $http.get('http://myserver.com//'+value.module+'.js') .then(function (response2) { var ctrls = response2.data.split('##'); var fullctrl; for (var m = 1; m &lt;= value.controller.length; m++){ var ctrlName = value.controller[m - 1] + 'Ctrl'; $controllerProviderRef .register(ctrlName, ['$scope',...., function ($scope, ...,) { eval(ctrls[m - 1]); }]) if (m == value.controller.length) { for (var o = 1; o &lt;= value.controller.length; o++) { var html = $templateCache .get("templates/" + value.controller[o - 1] + ".html"); var getExistingState = $state.get(value.controller[o - 1].toLowerCase()); if (getExistingState !== null) { return; } var state = { 'lang': value.lang, 'params': value.param, 'url': '/' + value.controller[o - 1].toLowerCase(), 'template': html, 'controller': value.controller[o - 1] + 'Ctrl' }; $stateProviderRef.state(value.controller[o - 1].toLowerCase(), state); } } } }); } } }); }); // Configures $urlRouter's listener *after* your custom listener $urlRouter.sync(); $urlRouter.listen(); } } }]) </code></pre> <p>Any help appreciated</p>
1
how to split a column into two cells without effecting the rows in table
<p>I want to split column into two cells and without effecting below rows.</p> <p>Sample image: <img src="https://i.stack.imgur.com/9FACC.png" alt="sample image"></p>
1
Criteriabuilder lower() vs Java toLowerCase()
<p>According to this <a href="https://stackoverflow.com/questions/16611904/ignorecase-in-criteria-builder-in-jpa">Link</a></p> <blockquote> <p>Predicate lcSurnameLikeSearchPattern = criteriaBuilder.like( criteriaBuilder.<strong>lower</strong>(Person_.surname), searchPattern.<strong>toLowerCase</strong>());</p> </blockquote> <p>This seems like Hibernate would generate an SQL that would look something like</p> <pre><code>LOWER(PERSON.SURNAME) LIKE 'searchPattern' </code></pre> <p>Where searchPattern would have been lowered in Java using whatever implementation toLowerCase would provide. Whereas the query LOWER would use Oracle implementation. For ASCII characters, I'm guessing things are pretty simple, but would there ever be discrepancies on international UTF characters?</p> <p>How would I get JPA to lower both operands of LIKE in the query? So the generated query looks like</p> <pre><code>LOWER(PERSON.SURNAME) LIKE LOWER('searchPattern') </code></pre>
1
Difference between EAX,1 and EBX,1 in assembly?
<pre><code>section .text global _start ;must be declared for linker (ld) _start: ;tell linker entry point mov edx,len ;message length mov ecx,msg ;message to write mov ebx,1 ;file descriptor (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel mov eax,1 ;system call number (sys_exit) int 0x80 ;call kernel section .data msg db 'Hello, world!',0xa ;our dear string len equ $ - msg ;length of our dear string </code></pre> <p>Kernel source references:</p> <p>How does the system know that it has to exit when it read EAX,1 and not EBX,1 ? Since 1 means Sys_Exit.</p>
1
testing an API with postman & simulating logged in user in request
<p>I am building an API in ruby on rails. The API has a authentification system created with Devise. I wanted to test my API methods using postman with http request but everytime I try I get the following response :</p> <pre><code>{ "error": "You need to sign in or sign up before continuing." } </code></pre> <p>How can I simulate a logged in user in my postman request to make my request work ? Or is there a better way to test my API ?</p>
1
How to set UTF-8 properly in Hibernate?
<p>I'm using Hibernate for a JEE solution. And I need to database connection to be UTF-8. Here're what I tried :</p> <h2>Database side</h2> <pre><code>mysql&gt; select c.character_set_name from information_schema.tables as t, information_schema.collation_character_set_applicability as c where c.collation_name = t.table_collation and t.table_schema = "ir2016" and t.table_name = "personne"; +--------------------+ | character_set_name | +--------------------+ | utf8 | +--------------------+ 1 row in set (0.01 sec) </code></pre> <p>I've also inserted example data from MySQL Workbench. Results are well encoded in UTF-8. So the problem must come from the JEE server side.</p> <h2>JEE side</h2> <p><strong>hibernate.cfg.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;!DOCTYPE hibernate-configuration SYSTEM "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt; &lt;hibernate-configuration&gt; &lt;session-factory&gt; &lt;!--Databaseconnectionsettings --&gt; &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt; &lt;property name="connection.url"&gt;jdbc:mysql://localhost/ir2016?useUnicode=true&amp;amp;characterEncoding=utf-8&lt;/property&gt; &lt;property name="connection.username"&gt;root&lt;/property&gt; &lt;property name="connection.password"&gt;xxxx&lt;/property&gt; &lt;property name="connection.useUnicode"&gt;true&lt;/property&gt; &lt;property name="connection.characterEncoding"&gt;utf8&lt;/property&gt; &lt;property name="connection.CharSet"&gt;utf8&lt;/property&gt; &lt;!--JDBC connectionpool (use the built-in) --&gt; &lt;property name="connection.pool_size"&gt;1&lt;/property&gt; &lt;!--SQL dialect--&gt; &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt; &lt;!--EnableHibernate'sautomaticsession contextmanagement --&gt; &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt; &lt;!--Disablethe second-levelcache --&gt; &lt;property name="cache.provider_class"&gt;org.hibernate.cache.NoCacheProvider&lt;/property&gt; &lt;!--Echo all executedSQL to stdout--&gt; &lt;property name="show_sql"&gt;true&lt;/property&gt; &lt;mapping resource="Quiz.hbm.xml"/&gt; &lt;mapping resource="Proposition.hbm.xml"/&gt; &lt;mapping resource="Question.hbm.xml"/&gt; &lt;mapping resource="Personne.hbm.xml"/&gt; &lt;mapping resource="Choisir.hbm.xml"/&gt; &lt;/session-factory&gt; &lt;/hibernate-configuration&gt; </code></pre> <p><strong>server.xml</strong></p> <pre><code>&lt;Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8"/&gt; &lt;Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8"/&gt; </code></pre> <p><strong>JSP pages</strong></p> <pre><code>&lt;%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="UTF-8"%&gt; </code></pre> <p>Can somebody help ?</p>
1
Where can I download com.sun.security.* package?
<p><strong>Download <em>com.sun</em> libraries</strong></p> <pre><code>new com.sun.security.auth.module.NTSystem() </code></pre> <p>This is what I am using code and it's required necessary libraries and where can I download them ? I did search on google but couldn't find.</p>
1
$ionicLoading is not showing on controller load first method
<p>I am loading data from server by calling <code>init()</code> method in angular .I am using <code>$ionicLoading.show();</code> for loader but it is not showing on loading time. I am able to get data from server successfully but loader is not showing.</p> <p>I tried with <code>angular.element(document).ready(function () { });.</code> But still loader is not visible for me. I need some data on page load itself.</p> <p>sample code : </p> <pre><code>angular.module('App.controllers').controller('WorkoutCtrl', function ($scope,$state,$ionicModal,serviceEngine,$ionicPopup,$rootScope,$ionicLoading,$location) { var init = function(){ $ionicLoading.show({template: 'Loading...&lt;/p&gt;'}); if(deviceApi.checkConnectionStatus() === 'online'){ console.log('We are inside online'); serviceEngine.getMethod()//server call .success(function(data,status,headers){ $ionicLoading.hide(); }) .error(function(){ $ionicLoading.hide(); }) }else{ $ionicLoading.hide(); $ionicPopup.alert({title: 'ERROR',template: 'Application is offline. Check your network connection.'}); } } init(); </code></pre>
1
Passing a large text to bash curl url
<p>I'm crawling the json results from a web api that takes text as input. Example:</p> <pre><code>curl http://www.example.com/annotate?text=${long_text}&amp;input_format=html&amp;output=json </code></pre> <p>I get the error of list of arguments is too long. Then I changed to:</p> <pre><code>curl -d "text=${long_text}&amp;input_format=html&amp;output=json" http://www.example.com/annotate? </code></pre> <p>I still get the same error. I read the ${long_text} from an html file since the api doesn't accept file as parameter. Any suggestions to overcome this error? </p>
1
Unsupported test framework error in NUnit
<p>I am using NUnit testing with Visual Studio 2013. We are using NUnitTestAdapter for integration of test run of NUnit with Visual Studio.</p> <p>Visual Studio 2013 NUnit is version="3.0.1" NUnitTestAdapter version="2.0.0" .Net Framework 4.5.2</p> <p>All packages are latest &amp; installed from Nuget. There is no build error. We are getting error in test result window:</p> <pre><code>Attempt to load assembly with unsupported test framework in D:\JuniorAchievement\Git\jaums\JA.UMS.Tests\bin\Debug\JA.UMS.Tests.dll </code></pre> <p>while running or debugging test using Visual Studio Test Explorer.</p> <p><a href="https://i.stack.imgur.com/8xtTc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8xtTc.png" alt="enter image description here"></a></p> <p>Test is able to run on one machine with same code on Visual Studio 2013 ultimate. We all other have Visual Studio 2013 professional version, although I doubt it has nothing to do with the problem.</p> <p>Please Help.</p> <p><strong>Update</strong></p> <p><strong>__________</strong></p> <p>After update to NUnit3 Test Adapter no error but still no test are discovered. </p> <p><a href="https://i.stack.imgur.com/GuWhz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GuWhz.png" alt="enter image description here"></a></p> <p>Somehow both Adapter are available but with Nuget &amp; VS extension I can find only NUnit3 Test Adapter.</p> <p>Installed NUnit3 Test Adapter from <a href="https://visualstudiogallery.msdn.microsoft.com/0da0f6bd-9bb6-4ae3-87a8-537788622f2d" rel="noreferrer">https://visualstudiogallery.msdn.microsoft.com/0da0f6bd-9bb6-4ae3-87a8-537788622f2d</a></p>
1
Java ArrayList vs Libgdx Array
<p>I want to know that whether or not using <strong>Java</strong> specific code breaks cross platform utility. For example, does it matter I use <strong>Java</strong> <code>ArrayList</code> or <strong>Libgdx</strong> <code>Array</code>?</p>
1
Laravel 5: Bulk insertion in mongo DB showing error
<p>I am using <a href="https://github.com/jenssegers/laravel-mongodb" rel="nofollow">jenssegers</a> package in Laravel 5 for mongodb. I am inserting multiple data in below described way and data is inserted successfully in mongodb but then it through error before the script completes. </p> <pre><code>$AllTrans=array(); $AllTrans[]=array("InvoiceID"=&gt;1,"Amount"=&gt;50); $AllTrans[]=array("InvoiceID"=&gt;2,"Amount"=&gt;150); $mongo_connnection-&gt;collection('invoices')-&gt;insert($AllTrans); </code></pre> <p>Here is the error:</p> <pre><code>MongoException in Collection.php line 42: No write ops were included in the batch </code></pre> <p>But i can not figure out problem, I have tried passing option like array('multi' => true) with insert query but it was not working. </p>
1
Multiple ion-scroll both with infinite scroll
<p>I have two ion scroll tags. Inside each of these ion-scroll tags is a list. Each of these lists start with 10 items, and when a user reaches the bottom of a particular ion scroll it should load more. The problem I am facing is this is quite not working correctly. If I scroll through the first it scroll window and paginate through all the items it should say no more content. This does not happen though, instead if I scroll through the second scroll window then it will load more items in the first and second ion scroll window(which I don't want). Essentially I would like the two ion scrolls to be completely independent of each other. I would like each to load it's own content. I hope that made sense. Here is my codepen: </p> <p><a href="http://codepen.io/polska03/pen/jWKRwP" rel="noreferrer">http://codepen.io/polska03/pen/jWKRwP</a></p> <p>HTML:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"&gt; &lt;title&gt;Ionic Pull to Refresh&lt;/title&gt; &lt;link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet"&gt; &lt;script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body ng-app="ionicApp" ng-controller="MyCtrl" class="background-places"&gt; &lt;ion-view&gt; &lt;ion-content class="" scroll='false'&gt; &lt;ion-scroll style="height:50%"&gt; &lt;ion-list&gt; &lt;ion-item collection-repeat="list in _list"&gt; &lt;h2&gt;Item&lt;/h2&gt; &lt;/ion-item&gt; &lt;/ion-list&gt; &lt;button class="button button-full button-outline button-positive" ng-if="noMoreContent"&gt; No more Content &lt;/button&gt; &lt;ion-infinite-scroll ng-if="canWeLoadMoreContent()" on-infinite="populateList()" distance="1%"&gt; &lt;/ion-infinite-scroll&gt; &lt;/ion-scroll&gt; &lt;hr&gt; &lt;hr&gt; &lt;ion-scroll style="height:50%"&gt; &lt;ion-list&gt; &lt;ion-item collection-repeat="list2 in _list2"&gt; &lt;h2&gt;Item&lt;/h2&gt; &lt;/ion-item&gt; &lt;/ion-list&gt; &lt;button class="button button-full button-outline button-positive" ng-if="noMoreContent2"&gt; No More Content &lt;/button&gt; &lt;ion-infinite-scroll ng-if="canWeLoadMoreContent2()" on-infinite="populateList2()" distance="1%"&gt; &lt;/ion-infinite-scroll&gt; &lt;/ion-scroll&gt; &lt;/ion-content&gt; &lt;/ion-view&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Javascript:</p> <pre><code>angular.module('ionicApp', ['ionic']) .controller('MyCtrl', function($scope) { $scope._list = []; $scope.populateList = function() { for (var i = 0; i &lt;= 9; i++) { $scope._list.push({}); } console.log($scope._list.length); $scope.$broadcast('scroll.infiniteScrollComplete'); } $scope.noMoreContent = false; $scope.canWeLoadMoreContent = function() { if($scope._list.length &gt; 15) { $scope.noMoreContent = true; return false; }else{ return true; } } $scope.populateList(); $scope._list2 = []; $scope.populateList2 = function() { for (var i = 0; i &lt;= 9; i++) { $scope._list2.push({}); } console.log($scope._list2.length); $scope.$broadcast('scroll.infiniteScrollComplete'); } $scope.noMoreContent2 = false; $scope.canWeLoadMoreContent2 = function() { if($scope._list2.length &gt; 15) { $scope.noMoreContent2 = true; return false; }else{ return true; } } $scope.populateList2(); }); </code></pre>
1
FFMPEG amerge fails when one audio stream is missing
<p>I am trying to combine two video files (of size 320x240) and create a single, horizontally extended output video file (of size 640x240) but for the audio merging, the command fails when one of the input files does not contain audio stream.</p> <p>Here's the command I am using:</p> <p><strong>C:\ffmpeg\bin\ffmpeg.exe -y -i "input1.flv" -i "input2.flv" -filter_complex "nullsrc=size=640x240[base];[0:v]scale=320x240[upperleft];[1:v]scale=320x240[upperright];[base][upperleft]overlay=shortest=1[tmp1];[tmp1][upperright]overlay=shortest=1:x=320:y=0;[0:a][1:a]amerge=inputs=2[aout]" -map [aout] -ac 2 "output.mp4"</strong></p> <p>This command works fine when both input1.flv and input2.flv contain audio tracks. When either one lacks an audio track, the command gives the following error:</p> <blockquote> <p>[flv @ 0000000004300660] Stream discovered after head already parsed [flv @ 0000000004300660] Could not find codec parameters for stream 1 (Audio: none, 0 channels): unspecified sample format Consider increasing the value for the 'analyzeduration' and 'probesize' options Input #1, flv, from 'input2.flv': Metadata: creationdate : Tue Jan 26 16:50:12 Duration: 00:25:59.10, start: 0.000000, bitrate: 212 kb/s Stream #1:0: Video: flv1, yuv420p, 320x240, 1k tbr, 1k tbn, 1k tbc Stream #1:1: Audio: none, 0 channels Stream #1:2: Data: none [abuffer @ 0000000004335620] Value inf for parameter 'time_base' out of range [0 - 2.14748e+009] [abuffer @ 0000000004335620] Unable to parse option value "(null)" as sample format [abuffer @ 0000000004335620] Value inf for parameter 'time_base' out of range [0 - 2.14748e+009] [abuffer @ 0000000004335620] Error setting option time_base to value 1/0. [graph 0 input from stream 1:1 @ 00000000042e4d60] Error applying options to the filter. Error configuring filters.</p> </blockquote> <p>Is there a way to make this command work even when one audio stream lacks an audio track or both of the audio streams lack audio tracks?</p>
1
which one is faster binarysearch or indexof?
<p>I have a very big ArrayList of string in C#, and periodically I'm searching for a string in this ArrayList. Which one is faster , using <code>ArrayList.IndexOf()</code> or <code>ArrayList.BinarySearch()</code>? I can sort the ArrayList. </p>
1
Java User Input - Enter integer within certain range or loop back and try again
<p>I have to build a user input template where you can enter a number between 100 and 200. If you type "goodbye", it needs to exit, if you enter a letter, symbol, number outside the range, etc. it needs to prompt you to try again. if you enter a number within the range, it will move on to another question (I haven't included that in the code below).</p> <p>I got almost everything to work. If you enter a correct number the first time, it works. The "goodbye" and wrong character functions also work. BUT if you enter the wrong character (number or letter) and then, when it prompts you to try again, you put a CORRECT number in the range, it does not accept it and again prompts you to try again.</p> <p>I need to figure out how to input a wrong character (such as a letter or number outside of range), and then when it prompts you to try again and you put a number between 100-200, it works and exits the loop (which will enable it to go on to the next question/loop).</p> <p>Here is my code:</p> <pre><code>Scanner console = new Scanner(System.in); String Input; int Number; boolean isValid = true; do { System.out.println("Enter a valid number:"); Input = console.nextLine(); if (Input.equals("goodbye") || Input.equals("GOODBYE")){ System.out.println("You have left"); System.exit(0); } char[] numberTester = Input.toCharArray(); for (int i = 0; i&lt;Input.length(); i++){ Character currentChar = new Character (numberTester[i]); if (!currentChar.isDigit(numberTester[i])){ isValid = false; System.out.println("Invalid. Try again."); i = Input.length(); } if (isValid == true){ Number = Integer.parseInt(Input); if (Number &lt; 100 || Number &gt; 200){ isValid = false; System.out.println("Invalid. Try again."); } } } } while (isValid == false); } } </code></pre>
1
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 1206: ordinal not in range(128)
<p>I have an array <code>W</code> containing float numbers. </p> <pre><code>W.dtype = float32 type(W) = &lt;type 'numpy.ndarray'&gt; </code></pre> <p>Then I <code>pickle.dump()</code> it into a <code>mr.pkl</code> file, </p> <pre><code>pickle.dump(W, open("/home/mr.pkl", "wb")) </code></pre> <p>but when I load it,</p> <pre><code>pickle.load(open("/home/mr.pkl","rb")) </code></pre> <p>an error occurs:</p> <blockquote> <p>UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 1206: ordinal not in range(128)</p> </blockquote> <p>I don't know why, I was confused about it for a week, can any one help me about this? any help is appreciated, thank you a lot!</p>
1
Amazon ECS - Persistent data between instances
<p>How would you best handle persistent data between instances with a load-balanced service in Amazon ECS? Data only containers will not work and neither will the volumes you can specify in the tasks, they will both only persist on the instance itself. I have been trying to read up on attaching a EBS upon instance creation with User Data in Launch Configuration but i had no luck there.</p>
1
Android disable HDMI output?
<p>I'm trying to figure out if there is a way for me to block HDMI output when my application is running on Android? I need to support minimum API 17 (Android 4.2). </p> <p>Is there such method I can call to control (hide/show) HDMI output?</p> <pre><code>/sys/class/switch/hdmi/state </code></pre> <p>this file value changes depending on the state of the HDMI</p> <p><code>1</code> for HDMI connected<br> <code>0</code> for HDMI disconnected </p> <p>Can I do something with that?</p> <p>Thank you.</p>
1
EWS java.lang.NoSuchMethodError: org.joda.time.format.DateTimeFormatter.withZoneUTC
<p>My application is trying to get a email from the inbox in java with the API EWS and I have a exception: </p> <blockquote> <p>java.lang.NoSuchMethodError: org.joda.time.format.DateTimeFormatter.withZoneUTC()Lorg/joda/time/format/DateTimeFormatter; at microsoft.exchange.webservices.data.util.DateTimeUtils.createDateTimeFormats(DateTimeUtils.java:99)</p> </blockquote> <p>I added <code>joda</code> in my dependencies but I still have the error. Here is my complete <code>pom.xml</code>. I know you need joda-time 2.8 for EWS, I can't find the dependency that causes me a problem.</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;parent&gt; &lt;groupId&gt;com.lbc.scheduler&lt;/groupId&gt; &lt;artifactId&gt;LBCSchedulerParent&lt;/artifactId&gt; &lt;version&gt;1.0.0&lt;/version&gt; &lt;relativePath&gt;../LBCSchedulerParent&lt;/relativePath&gt; &lt;/parent&gt; &lt;groupId&gt;com.lbc.scheduler&lt;/groupId&gt; &lt;artifactId&gt;LBCSchedulerEJB&lt;/artifactId&gt; &lt;version&gt;1.0.0&lt;/version&gt; &lt;packaging&gt;ejb&lt;/packaging&gt; &lt;name&gt;LBCSchedulerEJB&lt;/name&gt; &lt;url&gt;http://LBCSchedulerEJB&lt;/url&gt; &lt;distributionManagement&gt; &lt;repository&gt; &lt;id&gt;deployment&lt;/id&gt; &lt;name&gt;Internal Releases&lt;/name&gt; &lt;url&gt;http://nd1981dav02.blc.banquelaurentienne.ca:8084/nexus/content/repositories/releases/&lt;/url&gt; &lt;/repository&gt; &lt;snapshotRepository&gt; &lt;id&gt;deployment&lt;/id&gt; &lt;name&gt;Internal Releases&lt;/name&gt; &lt;url&gt;http://nd1981dav02.blc.banquelaurentienne.ca:8084/nexus/content/repositories/snapshots/&lt;/url&gt; &lt;/snapshotRepository&gt; &lt;/distributionManagement&gt; &lt;properties&gt; &lt;quartz.version&gt;2.1.6&lt;/quartz.version&gt; &lt;hibernate-entitymanager.version&gt;4.1.7.Final&lt;/hibernate-entitymanager.version&gt; &lt;maven-ejb-plugin.version&gt;2.3&lt;/maven-ejb-plugin.version&gt; &lt;commons-configuration.version&gt;1.6&lt;/commons-configuration.version&gt; &lt;junit.version&gt;4.8.2&lt;/junit.version&gt; &lt;commons-discovery.version&gt;0.2&lt;/commons-discovery.version&gt; &lt;aspectj.version&gt;1.6.9&lt;/aspectj.version&gt; &lt;jboss-7.1.1-home&gt;C:\jboss-as-7.1.1.Final&lt;/jboss-7.1.1-home&gt; &lt;jaxrs.version&gt;1.1.1&lt;/jaxrs.version&gt; &lt;sonar.plugin.version&gt;2.8&lt;/sonar.plugin.version&gt; &lt;spring-security.version&gt;3.0.5.RELEASE&lt;/spring-security.version&gt; &lt;commons.collections.version&gt;3.2.1&lt;/commons.collections.version&gt; &lt;soapui-plugin.version&gt;4.0.1&lt;/soapui-plugin.version&gt; &lt;persistence-api.version&gt;1.0.2&lt;/persistence-api.version&gt; &lt;dozer.version&gt;5.3.2&lt;/dozer.version&gt; &lt;war-plugin.version&gt;2.2&lt;/war-plugin.version&gt; &lt;javax-jsp-api.version&gt;2.1&lt;/javax-jsp-api.version&gt; &lt;bean-validation.version&gt;1.0.0.GA&lt;/bean-validation.version&gt; &lt;wtp.version&gt;2.0&lt;/wtp.version&gt; &lt;jboss-as-maven-plugin.version&gt;7.1.1.Final&lt;/jboss-as-maven-plugin.version&gt; &lt;netty.version&gt;3.5.9.Final&lt;/netty.version&gt; &lt;ear-plugin.version&gt;2.8&lt;/ear-plugin.version&gt; &lt;ejb.version&gt;3.0&lt;/ejb.version&gt; &lt;jboss-ejb-api_3.1_spec.version&gt;1.0.1.Final&lt;/jboss-ejb-api_3.1_spec.version&gt; &lt;hibernate-jpa-2.0-api.version&gt;1.0.1.Final&lt;/hibernate-jpa-2.0-api.version&gt; &lt;jboss-jaxws-api_2.2_spec.version&gt;2.0.0.Final&lt;/jboss-jaxws-api_2.2_spec.version&gt; &lt;thirdPartyPlugin.version&gt;1.0&lt;/thirdPartyPlugin.version&gt; &lt;opencsv.version&gt;2.3&lt;/opencsv.version&gt; &lt;ehcache-core.version&gt;2.6.0&lt;/ehcache-core.version&gt; &lt;ojdbc5.version&gt;11.2.0.3&lt;/ojdbc5.version&gt; &lt;source-plugin.version&gt;2.2&lt;/source-plugin.version&gt; &lt;javax-jstl.version&gt;1.2&lt;/javax-jstl.version&gt; &lt;gilenya.build.id&gt;1.0.0-${maven.build.timestamp}&lt;/gilenya.build.id&gt; &lt;jboss-ejb-api.version&gt;3.0.0.GA_SP1&lt;/jboss-ejb-api.version&gt; &lt;compiler-plugin.version&gt;2.3.2&lt;/compiler-plugin.version&gt; &lt;wls-maven-plugin.version&gt;12.1.1.0&lt;/wls-maven-plugin.version&gt; &lt;commons-logging.version&gt;1.1.1&lt;/commons-logging.version&gt; &lt;hibernate-validator.version&gt;4.1.0.Final&lt;/hibernate-validator.version&gt; &lt;commons-beanutils.version&gt;1.8.3&lt;/commons-beanutils.version&gt; &lt;jdom.version&gt;2.0.2&lt;/jdom.version&gt; &lt;commons-lang3.version&gt;3.1&lt;/commons-lang3.version&gt; &lt;javax.mail.version&gt;1.4.2&lt;/javax.mail.version&gt; &lt;slf4j.version&gt;1.6.6&lt;/slf4j.version&gt; &lt;java.version&gt;1.6&lt;/java.version&gt; &lt;c3p0.version&gt;0.9.1.1&lt;/c3p0.version&gt; &lt;commons-lang.version&gt;2.6&lt;/commons-lang.version&gt; &lt;updateimpact.apikey&gt;PbCCTaotiyWhRDEtrjQIrNALip0c1f3C&lt;/updateimpact.apikey&gt; &lt;spring.version&gt;3.0.5.RELEASE&lt;/spring.version&gt; &lt;easymock.version&gt;3.0&lt;/easymock.version&gt; &lt;log4j.version&gt;1.2.16&lt;/log4j.version&gt; &lt;javax.ejb.version&gt;3.1.0&lt;/javax.ejb.version&gt; &lt;javax-servlet-api.version&gt;2.5&lt;/javax-servlet-api.version&gt; &lt;updateimpact.openbrowser&gt;true&lt;/updateimpact.openbrowser&gt; &lt;dom4j.version&gt;1.6.1&lt;/dom4j.version&gt; &lt;axis.version&gt;1.4&lt;/axis.version&gt; &lt;nexus.url&gt;http://nd1981dav02.blc.banquelaurentienne.ca:8084/nexus&lt;/nexus.url&gt; &lt;javax-jsr311-api.version&gt;1.1.1&lt;/javax-jsr311-api.version&gt; &lt;/properties&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;joda-time&lt;/groupId&gt; &lt;artifactId&gt;joda-time&lt;/artifactId&gt; &lt;version&gt;2.8&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.microsoft.ews-java-api&lt;/groupId&gt; &lt;artifactId&gt;ews-java-api&lt;/artifactId&gt; &lt;version&gt;2.0&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.lbc.gateway&lt;/groupId&gt; &lt;artifactId&gt;LBCClient&lt;/artifactId&gt; &lt;version&gt;1.0.0&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.lbc.gateway&lt;/groupId&gt; &lt;artifactId&gt;LBCGatewayCommon&lt;/artifactId&gt; &lt;version&gt;1.0.0&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;log4j&lt;/groupId&gt; &lt;artifactId&gt;log4j&lt;/artifactId&gt; &lt;version&gt;1.2.16&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.slf4j&lt;/groupId&gt; &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt; &lt;version&gt;1.6.6&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.slf4j&lt;/groupId&gt; &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt; &lt;version&gt;1.6.6&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;c3p0&lt;/groupId&gt; &lt;artifactId&gt;c3p0&lt;/artifactId&gt; &lt;version&gt;0.9.1.1&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.quartz-scheduler&lt;/groupId&gt; &lt;artifactId&gt;quartz&lt;/artifactId&gt; &lt;version&gt;2.1.6&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.quartz-scheduler&lt;/groupId&gt; &lt;artifactId&gt;quartz-oracle&lt;/artifactId&gt; &lt;version&gt;2.1.6&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.quartz-scheduler&lt;/groupId&gt; &lt;artifactId&gt;quartz-weblogic&lt;/artifactId&gt; &lt;version&gt;2.1.6&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.quartz-scheduler&lt;/groupId&gt; &lt;artifactId&gt;quartz-jboss&lt;/artifactId&gt; &lt;version&gt;2.1.6&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.oracle.javax.ejb&lt;/groupId&gt; &lt;artifactId&gt;javax.ejb&lt;/artifactId&gt; &lt;version&gt;3.1.0&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;javax.mail&lt;/groupId&gt; &lt;artifactId&gt;mailapi&lt;/artifactId&gt; &lt;version&gt;1.4.2&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;commons-codec&lt;/groupId&gt; &lt;artifactId&gt;commons-codec&lt;/artifactId&gt; &lt;version&gt;1.8&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt; &lt;artifactId&gt;httpclient-cache&lt;/artifactId&gt; &lt;version&gt;4.2.5&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt; &lt;artifactId&gt;httpmime&lt;/artifactId&gt; &lt;version&gt;4.2.5&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;xpp3&lt;/groupId&gt; &lt;artifactId&gt;xpp3&lt;/artifactId&gt; &lt;version&gt;1.1.4c&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.moonrug&lt;/groupId&gt; &lt;artifactId&gt;moonrug&lt;/artifactId&gt; &lt;version&gt;1.0&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt; &lt;artifactId&gt;httpcore&lt;/artifactId&gt; &lt;version&gt;4.4.1&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt; &lt;artifactId&gt;httpclient&lt;/artifactId&gt; &lt;version&gt;4.4.1&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;commons-logging&lt;/groupId&gt; &lt;artifactId&gt;commons-logging&lt;/artifactId&gt; &lt;version&gt;1.2&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;junit&lt;/groupId&gt; &lt;artifactId&gt;junit&lt;/artifactId&gt; &lt;version&gt;4.8.2&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;repositories&gt; &lt;repository&gt; &lt;releases&gt; &lt;enabled&gt;true&lt;/enabled&gt; &lt;/releases&gt; &lt;snapshots&gt; &lt;enabled&gt;true&lt;/enabled&gt; &lt;/snapshots&gt; &lt;id&gt;central&lt;/id&gt; &lt;url&gt;http://central&lt;/url&gt; &lt;/repository&gt; &lt;/repositories&gt; &lt;pluginRepositories&gt; &lt;pluginRepository&gt; &lt;releases&gt; &lt;enabled&gt;true&lt;/enabled&gt; &lt;/releases&gt; &lt;snapshots&gt; &lt;enabled&gt;true&lt;/enabled&gt; &lt;/snapshots&gt; &lt;id&gt;central&lt;/id&gt; &lt;url&gt;http://central&lt;/url&gt; &lt;/pluginRepository&gt; &lt;/pluginRepositories&gt; &lt;build&gt; &lt;sourceDirectory&gt;C:\WorkingJava\DaVinci_Projet\LBCSchedulerEJB\src\main\java&lt;/sourceDirectory&gt; &lt;scriptSourceDirectory&gt;C:\WorkingJava\DaVinci_Projet\LBCSchedulerEJB\src\main\scripts&lt;/scriptSourceDirectory&gt; &lt;testSourceDirectory&gt;C:\WorkingJava\DaVinci_Projet\LBCSchedulerEJB\src\test\java&lt;/testSourceDirectory&gt; &lt;outputDirectory&gt;C:\WorkingJava\DaVinci_Projet\LBCSchedulerEJB\target\classes&lt;/outputDirectory&gt; &lt;testOutputDirectory&gt;C:\WorkingJava\DaVinci_Projet\LBCSchedulerEJB\target\test-classes&lt;/testOutputDirectory&gt; &lt;resources&gt; &lt;resource&gt; &lt;filtering&gt;false&lt;/filtering&gt; &lt;directory&gt;C:\WorkingJava\DaVinci_Projet\LBCSchedulerEJB\src\main\resources&lt;/directory&gt; &lt;/resource&gt; &lt;resource&gt; &lt;filtering&gt;true&lt;/filtering&gt; &lt;directory&gt;C:\WorkingJava\DaVinci_Projet\LBCSchedulerEJB\src\main\filtered-resources&lt;/directory&gt; &lt;/resource&gt; &lt;/resources&gt; &lt;testResources&gt; &lt;testResource&gt; &lt;directory&gt;C:\WorkingJava\DaVinci_Projet\LBCSchedulerEJB\src\test\resources&lt;/directory&gt; &lt;/testResource&gt; &lt;/testResources&gt; &lt;directory&gt;C:\WorkingJava\DaVinci_Projet\LBCSchedulerEJB\target&lt;/directory&gt; &lt;finalName&gt;LBCSchedulerEJB-1.0.0&lt;/finalName&gt; &lt;pluginManagement&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt; &lt;version&gt;1.3&lt;/version&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt; &lt;version&gt;2.2-beta-5&lt;/version&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt; &lt;version&gt;2.1&lt;/version&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-release-plugin&lt;/artifactId&gt; &lt;version&gt;2.0&lt;/version&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/pluginManagement&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-ejb-plugin&lt;/artifactId&gt; &lt;version&gt;2.3&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;default-ejb&lt;/id&gt; &lt;phase&gt;package&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;ejb&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;ejbVersion&gt;3.0&lt;/ejbVersion&gt; &lt;archive&gt; &lt;manifest&gt; &lt;addDefaultImplementationEntries&gt;true&lt;/addDefaultImplementationEntries&gt; &lt;addDefaultSpecificationEntries&gt;true&lt;/addDefaultSpecificationEntries&gt; &lt;addClasspath&gt;true&lt;/addClasspath&gt; &lt;/manifest&gt; &lt;manifestEntries&gt; &lt;Application-Name&gt;LBCSchedulerEJB-1.0.0&lt;/Application-Name&gt; &lt;Application-Version&gt;1.0.0&lt;/Application-Version&gt; &lt;Iteration-Name&gt;${iteration}&lt;/Iteration-Name&gt; &lt;JenkinsBuildNumber&gt;${BUILD_NUMBER}&lt;/JenkinsBuildNumber&gt; &lt;JenkinsBuildId&gt;${BUILD_ID}&lt;/JenkinsBuildId&gt; &lt;JenkinsJobName&gt;${JOB_NAME}&lt;/JenkinsJobName&gt; &lt;JenkinsBuildTag&gt;${BUILD_TAG}&lt;/JenkinsBuildTag&gt; &lt;JenkinsExecutorNumber&gt;${EXECUTOR_NUMBER}&lt;/JenkinsExecutorNumber&gt; &lt;JenkinsWorkspace&gt;${WORKSPACE}&lt;/JenkinsWorkspace&gt; &lt;JenkinsSvnRevision&gt;${SVN_REVISION}&lt;/JenkinsSvnRevision&gt; &lt;/manifestEntries&gt; &lt;/archive&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;configuration&gt; &lt;ejbVersion&gt;3.0&lt;/ejbVersion&gt; &lt;archive&gt; &lt;manifest&gt; &lt;addDefaultImplementationEntries&gt;true&lt;/addDefaultImplementationEntries&gt; &lt;addDefaultSpecificationEntries&gt;true&lt;/addDefaultSpecificationEntries&gt; &lt;addClasspath&gt;true&lt;/addClasspath&gt; &lt;/manifest&gt; &lt;manifestEntries&gt; &lt;Application-Name&gt;LBCSchedulerEJB-1.0.0&lt;/Application-Name&gt; &lt;Application-Version&gt;1.0.0&lt;/Application-Version&gt; &lt;Iteration-Name&gt;${iteration}&lt;/Iteration-Name&gt; &lt;JenkinsBuildNumber&gt;${BUILD_NUMBER}&lt;/JenkinsBuildNumber&gt; &lt;JenkinsBuildId&gt;${BUILD_ID}&lt;/JenkinsBuildId&gt; &lt;JenkinsJobName&gt;${JOB_NAME}&lt;/JenkinsJobName&gt; &lt;JenkinsBuildTag&gt;${BUILD_TAG}&lt;/JenkinsBuildTag&gt; &lt;JenkinsExecutorNumber&gt;${EXECUTOR_NUMBER}&lt;/JenkinsExecutorNumber&gt; &lt;JenkinsWorkspace&gt;${WORKSPACE}&lt;/JenkinsWorkspace&gt; &lt;JenkinsSvnRevision&gt;${SVN_REVISION}&lt;/JenkinsSvnRevision&gt; &lt;/manifestEntries&gt; &lt;/archive&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;version&gt;2.3.2&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;default-testCompile&lt;/id&gt; &lt;phase&gt;test-compile&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;testCompile&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;source&gt;1.6&lt;/source&gt; &lt;target&gt;1.6&lt;/target&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;default-compile&lt;/id&gt; &lt;phase&gt;compile&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;compile&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;source&gt;1.6&lt;/source&gt; &lt;target&gt;1.6&lt;/target&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;configuration&gt; &lt;source&gt;1.6&lt;/source&gt; &lt;target&gt;1.6&lt;/target&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;com.oracle.weblogic&lt;/groupId&gt; &lt;artifactId&gt;wls-maven-plugin&lt;/artifactId&gt; &lt;version&gt;12.1.1.0&lt;/version&gt; &lt;configuration&gt; &lt;middlewareHome&gt;C:\Oracle\Middleware&lt;/middlewareHome&gt; &lt;domainHome&gt;C:\Oracle\Middleware\user_projects\domains\base_domain3&lt;/domainHome&gt; &lt;weblogicHome&gt;C:\Oracle\Middleware\wlserver_12.1&lt;/weblogicHome&gt; &lt;user&gt;weblogic&lt;/user&gt; &lt;password&gt;adminadmin1&lt;/password&gt; &lt;source&gt;C:\WorkingJava\DaVinci_Projet\LBCSchedulerEJB\target\classes&lt;/source&gt; &lt;source&gt;C:\WorkingJava\DaVinci_Projet\LBCSchedulerEJB\target/LBCSchedulerEJB-1.0.0.jar&lt;/source&gt; &lt;name&gt;LBCSchedulerEJB&lt;/name&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-clean-plugin&lt;/artifactId&gt; &lt;version&gt;2.4.1&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;default-clean&lt;/id&gt; &lt;phase&gt;clean&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;clean&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-install-plugin&lt;/artifactId&gt; &lt;version&gt;2.3.1&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;default-install&lt;/id&gt; &lt;phase&gt;install&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;install&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt; &lt;version&gt;2.5&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;default-resources&lt;/id&gt; &lt;phase&gt;process-resources&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;resources&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;default-testResources&lt;/id&gt; &lt;phase&gt;process-test-resources&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;testResources&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt; &lt;version&gt;2.10&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;default-test&lt;/id&gt; &lt;phase&gt;test&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;test&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-deploy-plugin&lt;/artifactId&gt; &lt;version&gt;2.7&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;default-deploy&lt;/id&gt; &lt;phase&gt;deploy&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;deploy&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-site-plugin&lt;/artifactId&gt; &lt;version&gt;3.0&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;default-site&lt;/id&gt; &lt;phase&gt;site&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;site&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;outputDirectory&gt;C:\WorkingJava\DaVinci_Projet\LBCSchedulerEJB\target\site&lt;/outputDirectory&gt; &lt;reportPlugins&gt; &lt;reportPlugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-project-info-reports-plugin&lt;/artifactId&gt; &lt;/reportPlugin&gt; &lt;/reportPlugins&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;default-deploy&lt;/id&gt; &lt;phase&gt;site-deploy&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;deploy&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;outputDirectory&gt;C:\WorkingJava\DaVinci_Projet\LBCSchedulerEJB\target\site&lt;/outputDirectory&gt; &lt;reportPlugins&gt; &lt;reportPlugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-project-info-reports-plugin&lt;/artifactId&gt; &lt;/reportPlugin&gt; &lt;/reportPlugins&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;configuration&gt; &lt;outputDirectory&gt;C:\WorkingJava\DaVinci_Projet\LBCSchedulerEJB\target\site&lt;/outputDirectory&gt; &lt;reportPlugins&gt; &lt;reportPlugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-project-info-reports-plugin&lt;/artifactId&gt; &lt;/reportPlugin&gt; &lt;/reportPlugins&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;reporting&gt; &lt;outputDirectory&gt;C:\WorkingJava\DaVinci_Projet\LBCSchedulerEJB\target\site&lt;/outputDirectory&gt; &lt;/reporting&gt; &lt;/project&gt; </code></pre>
1
How can I make an div span the entire width of my screen
<p>Im making a little project and I just cant seem to get my css right... I need my header div(I used a regular div instead of an actual header because I wanted everything in the body). I want the blue header span my entire screen, but I just dont know how. I tried somethings with margin and padding but thats it.</p> <p>Also I tried getting those buttons to the bottom of the Div, but just cant seem to get it right...</p> <p>SCREENSHOT: <a href="http://prntscr.com/9slfw2" rel="nofollow">http://prntscr.com/9slfw2</a> Description: See my website here </p> <p>CSS: </p> <pre><code>body { margin: 0px; padding: 0px; } ul { list-style-type: none; } .page-header{ background-color: #0094ff; margin-top: 0px; display: block } .panel, .list-group-item, .btn { border-color: #0094ff; } #btnRegister { margin-right: 10px; vertical-align: bottom; } .input-group-addon { min-width: 40px; } legend.scheduler-border { width:inherit; padding:0 10px; border-bottom:none; } </code></pre> <p>HTML:</p> <pre><code>&lt;!-- Carousel --&gt; &lt;div id="homeCarousel" class="carousel slide"&gt; &lt;!-- Menu --&gt; &lt;ol class="carousel-indicators"&gt; &lt;li data-target="#myCarousel" data-slide-to="0" class="active"&gt;&lt;/li&gt; &lt;li data-target="#myCarousel" data-slide-to="1"&gt;&lt;/li&gt; &lt;li data-target="#myCarousel" data-slide-to="2"&gt;&lt;/li&gt; &lt;/ol&gt; &lt;!-- Items --&gt; &lt;div class="carousel-inner"&gt; &lt;!-- Item 1 --&gt; &lt;div class="item active"&gt; &lt;img class="c_img" src="~/Images/chevy.jpg" /&gt; &lt;div class="container"&gt; &lt;div class="carousel-caption"&gt; &lt;h1&gt;Contact&lt;/h1&gt; &lt;p style="background-color:#428bca;"&gt;Om gemakkelijk met Rent-a-Car contact op te nemen kunt u ook bellen!&lt;/p&gt; &lt;p style="background-color:#428bca;"&gt;Tel: 0534891034, Adres: Vuurnatieweg 69420&lt;/p&gt; &lt;p&gt; &lt;a class="btn btn-lg btn-primary" href="~/Home/Contact" &gt;Klik hier voor meer contact informatie!&lt;/a&gt; &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- Item 2 --&gt; &lt;div class="item"&gt; &lt;img class="c_img" src="~/Images/42-RT-76.jpg" /&gt; &lt;div class="container"&gt; &lt;div class="carousel-caption"&gt; &lt;h1&gt;Changes to the Grid&lt;/h1&gt; &lt;p style="background-color:#428bca;"&gt;Bootstrap 3 still features a 12-column grid, but many of the CSS class names have completely changed.&lt;/p&gt; &lt;p style="background-color:#428bca;"&gt;&lt;a class="btn btn-large btn-primary" href="#"&gt;Learn more&lt;/a&gt;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- Controls --&gt; &lt;a class="left carousel-control" href="#myCarousel" data-slide="prev"&gt; &lt;span class="icon-prev"&gt;&lt;/span&gt; &lt;/a&gt; &lt;a class="right carousel-control" href="#myCarousel" data-slide="next"&gt; &lt;span class="icon-next"&gt;&lt;/span&gt; &lt;/a&gt; &lt;div id="carouselButtons"&gt; &lt;button id="playButton" type="button" class="btn btn-default btn-xs"&gt; &lt;span class="glyphicon glyphicon-play"&gt;&lt;/span&gt; &lt;/button&gt; &lt;button id="pauseButton" type="button" class="btn btn-default btn-xs"&gt; &lt;span class="glyphicon glyphicon-pause"&gt;&lt;/span&gt; &lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; $(function () { $('#homeCarousel').carousel({ interval:5000, pause: "false" }); $('#playButton').click(function () { $('#homeCarousel').carousel('cycle'); }); $('#pauseButton').click(function () { $('#homeCarousel').carousel('pause'); }); }); &lt;/script&gt; </code></pre> <p>EDIT: HTML code and .. I am using Bootstrap, just so you know</p>
1
Laravel5 AJAX set cookie not working
<p>Could you give me advice please?</p> <p>I'm saving in COOKIES some data. I create method for this in Laravel, so I call ajax on this method to set cookie but when I try to call next request where I access this cookie value, it is not saved and I can access it in second request... I don't know why... it's quite strange :/ </p> <p>I have this code:</p> <pre><code>public function setCookie: method in laravel controller to set cookie var setCookie: function in javascript where I call ajax request to set cookie var loadEvents: method called after ajax call where I set cookie. public function setCookie(Request $request) { $cookieName = $request-&gt;input('cookie_name'); $cookieVal = $request-&gt;input('cookie_val'); return response()-&gt;json(['status' =&gt; 'success'])-&gt;withCookie(cookie($cookieName, $cookieVal)); } var setCookie = function (cookieName, cookieVal) { $.ajax({ type: 'POST', url: window.setCookieUrl, data: { cookie_name: cookieName, cookie_val: cookieVal, _token: getCsrfToken() } }).done(); }; public function loadEvents(Request $request) { $activeCalendarsIds = $request-&gt;input('active_calendars_ids'); if($activeCalendarsIds == null) $activeCalendarsIds = Cookie::get('adminActiveCalendars'); $eventsPage = $this-&gt;getPostParam('page'); $eventsLimit = $this-&gt;getPostParam('limit'); $this-&gt;service-&gt;setFilter('page', $eventsPage); $this-&gt;service-&gt;setFilter('limit', $eventsLimit); $events = $this-&gt;service-&gt;getCalendarsEvents($activeCalendarsIds); $eventList = view('admin/calendar/event_list', ['events' =&gt; $events]); return response()-&gt;json([ 'status' =&gt; 'success', 'data' =&gt; '' . $eventList . '' ]); } </code></pre>
1
Getting the following error in R: Error: 1: Start tag expected, '<' not found
<p>I searched the site thoroughly but didn't find an answer. The script looks into a file directory and appends into a vector of filenames (which I then turn into a dataframe). For is then used to iterate through custom function which consumes as argument the file name. The parser works fine with one file name (i.e. when I force it in <code>parser(filename)</code> otherwise fails when runs through the for loop). So I suspect it's how I'm passing the argument.</p> <pre><code>files &lt;- list.files(path=&quot;~/pathname&quot;, pattern=&quot;*.xml&quot;, full.names = F, recursive=FALSE) files.df &lt;- as.data.frame(files) for (i in 1:nrow(files.df)) { parser(as.character(files.df[i,])) } </code></pre> <p>When I <code>print(as.character(files.df[i,])</code>, the output is as expected. Again, running the custom parser with one file name (outside the for loop) as argument works perfectly. The <code>setwd</code> is the same as that of where the files are read from.</p> <p>Anything you may have come across before?</p> <p><em>Update:</em> the script worked fine yesterday with one file but now I get the same error. It seems to happen at this line:</p> <pre><code>xmlfile=xmlParse(filename, useInternalNodes = TRUE) </code></pre>
1
Storing digits of numbers in array
<p>Hello fellow programmers ! I am a beginner with Java and i am looking for a method or a way maybe to store the digits of a 6 digit number entered by the user , in an int array. For example :- if the number is 675421. then i want to store the digits in an array like :-</p> <pre><code>int[] array = new int[6]; int number = 675421 array[0] = 6; array[1] = 7; array[2] = 5; array[3] = 4; array[4] = 2; array[5] = 1; </code></pre> <p>I want to do so so that i can work with the array to maybe sort or change the order or numbers in array. Thanks!</p>
1
Should we be using Faker in Rails Factories?
<p>I love <a href="https://github.com/stympy/faker" rel="noreferrer">Faker</a>, I use it in my <code>seeds.rb</code> all the time to populate my dev environment with real-ish looking data.</p> <p>I've also just started using <a href="https://github.com/thoughtbot/factory_girl_rails" rel="noreferrer">Factory Girl</a> which also saves a lot of time - but when i sleuth around the web for code examples I don't see much evidence of people combining the two.</p> <p>Q. Is there a good reason why people don't use faker in a factory? </p> <p>My feeling is that by doing so I'd increase the robustness of my tests by seeding random - but predictable - data each time, which hopefully would increase the chances of a bug popping up.</p> <p>But perhaps that's incorrect and there is either no benefit over hard coding a factory or I'm not seeing a potential pitfall. Is there a good reason why these two gems should or shouldn't be combined?</p>
1
Alternatives to Appcache
<p>I am developing a site using PHP, and I was a bit mislead by how Appcache works; it turns out that it also caches the current page. Which, in the case of a PHP app, is a problem. :)</p> <p>I'd still like to cache my javascript, css and images on the client, but not my actual generated page. What is a good alternative for that? Just the plain old cache headers? The problem I see with them is, that they still produce requests. I am trying to mimize the amount of requests a client needs to make - this includes <code>304</code>s.</p>
1
java -version is giving me the version of openJDK installed, instead of JRE in $JAVA_HOME
<p>I have downloaded the java jdk from Oracle website and extracted it in the system. I have also don the entry of $JAVA_HOME to this one.</p> <p>But I have to install dbeaver (sql client) software which also installs openjdk with it.</p> <p>Now my system has two jres. OpenJDK and Oracle($JAVA_HOME). Whenever I am doing</p> <pre><code>java -version </code></pre> <p>It's giving me the version of that OpenJDK jre. Is it possible to make system use the Oracle jre(manually installed) instead of OpenJDK jre(keeping that installed in the system)</p>
1
Open the Front camera in a surface view
<p>I am getting exception <code>java.lang.RuntimeException: Fail to get camera info</code> at <code>Camera.getCameraInfo(cameraId,info);</code></p> <p>My code is:</p> <pre><code>public void surfaceCreated(SurfaceHolder holder) { int cameraId = -1; for(int i=0;i&lt;Camera.getNumberOfCameras();i++){ Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(cameraId,info); if(info.facing== Camera.CameraInfo.CAMERA_FACING_FRONT){ cameraId = i; break; } } camera = Camera.open(cameraId); } </code></pre> <p>and manifest also have:</p> <pre><code>&lt;uses-permission android:name="android.permission.CAMERA" /&gt; &lt;uses-feature android:name="android.hardware.camera" /&gt; &lt;uses-feature android:name="android.hardware.camera.front" /&gt; &lt;uses-feature android:name="android.hardware.camera.autofocus" /&gt; </code></pre> <p>What thing is missing, and how can I solve that? Any help is welcome.</p>
1
A solution to SQLAlchemy temporary table pain?
<p>It seems like the biggest drawback with SQLAlchemy is that it takes several steps backwards when it comes to working with temporary tables. A very common use case, for example, is to create a temporary table that is very specific to one task, throw some data in it, then join against it.</p> <p>For starters, declaring a temporary table is verbose, and limited. Note that in this example I had to edit it because my classes actually inherit a base class, so what I give here may be slightly incorrect.</p> <pre><code>@as_declarative(metaclass=MetaBase) class MyTempTable(object): __tablename__ = "temp" __table_args__ = {'prefixes': ['TEMPORARY']} id = Column(Integer(), primary_key=True) person_id = Column(BigInteger()) a_string = Column(String(100)) </code></pre> <p>Creating it is unintuitive:</p> <pre><code>MyTempTable.__table__.create(session.bind) </code></pre> <p>I also have to remember to explictly drop it unless I do something creative to get it to render with ON COMMIT DROP:</p> <pre><code>MyTempTable.__table__.drop(session.bind) </code></pre> <p>Also, what I just gave doesn't even work unless the temporary table is done "top level". I still haven't fully figured this out (for lack of wanting to spend time investigating why it doesn't work), but basically I tried creating a temp table in this manner inside of a nested transaction using session.begin_nested() and you end up with an error saying the relation does not exist. However, I have several cases where I create a temporary table inside of a nested transaction for unit testing purposes and they work just fine. Checking the echo output, it appears the difference is that one renders before the BEGIN statement, while the other renders after it. This is using Postgresql.</p> <p>What does work inside of a nested transaction, and quite frankly saves you a bunch of time, is to just type out the damned sql and execute it using session.execute. </p> <pre><code> session.execute(text( "CREATE TEMPORARY TABLE temp (" " id SERIAL," " person_id BIGINT," " a_string TEXT" ") ON COMMIT DROP;" )) </code></pre> <p>Of course, if you do this, you still need a corresponding table model to make use of ORM functionality, or have to stick to using raw sql queries, which defeats the purpose of SQLAlchemy in the first place.</p> <p>I'm wondering if maybe I'm missing something here or if someone has come up with a solution that is a bit more elegant.</p>
1
ORA-01839 "date not valid for month specified" for to_date in where clause
<p>I have following query (<code>BOCRTNTIME - varchar e.g 2015-02-28 12:21:45, VIEW_BASE_MARIX_T - some view</code>):</p> <pre><code>select BOCRTNTIME from VIEW_BASE_MARIX_T where to_date(substr(BOCRTNTIME,1,10),'YYYY-MM-DD') between (to_date ('2016-01-01', 'YYYY-MM-DD')) and (to_date ('2016-02-01', 'YYYY-MM-DD')) </code></pre> <p>On executing I get error:</p> <pre><code>ORA-01839: "date not valid for month specified" </code></pre> <p>I thought that there are can be incorrect data in <code>BOCRTNTIME</code>, so execute following query:</p> <pre><code>select distinct substr(BOCRTNTIME,1,8), substr(BOCRTNTIME,9,2) from VIEW_BASE_MARIX_T order by substr(BOCRTNTIME,9,2); </code></pre> <p>But everything looks fine: <a href="http://pastebin.com/fNjP4UAu" rel="nofollow">http://pastebin.com/fNjP4UAu</a>. Also following query executes without any error:</p> <pre><code>select to_date(substr(BOCRTNTIME,1,10),'YYYY-MM-DD') from VIEW_BASE_MARIX_T; </code></pre> <p>I already tried add <code>trunc()</code> to all <code>to_date()</code> but no luck. Also I create pl/sql procedure that takes one by one item form <code>VIEW_BASE_MARIX_T</code> and convert it to date - and everything works just fine. Any ideas why I get error on first query?</p> <p>UPD: Query on table that used in view works fine, but in view - not</p> <p>UPD2: We have few enviroments with same products, but get error only on one</p> <p>UPD3: Issue was resolved by search non valid dates in table that used in view</p>
1
Why mesos-slave asked to kill a task?
<p>I'm running a mesos cluster with with three masters and slaves currently on the same machines.</p> <p>My question is that sometime I see that a process gets abruptly stopped both in Marathon and Chronos. After checking the logs I saw, that every time, mesos-slave asked the frameworks to kill those tasks. I've tried to google it, find it here but I haven't found a relevant answer.</p> <p>How can I log or get to know, why the mesos-slave asks one of the registered framework to kill a task?</p> <p>Log with relevant lines following:</p> <pre><code>Jan 25 02:48:58 hostname mesos-slave[9817]: I0125 02:48:58.143537 9843 slave.cpp:1372] Asked to kill task TASKNAME.4b060055-b85a-11e5-8a34-52eb089dbeb2 of framework 20150311-145345-20031680-5050-2698-0000 Jan 25 02:48:59 hostname mesos-slave[9817]: I0125 02:48:59.108821 9834 slave.cpp:2215] Handling status update TASK_KILLED (UUID: abad489c-73bb-4f45-abbe-85f033ddde51) for task TASKNAME.4b060055-b85a-11e5-8a34-52eb089dbeb2 of framework 20150311-145345-20031680-5050-2698-0000 from executor(1)@192.168.49.1:42710 Jan 25 02:49:05 hostname mesos-slave[9817]: I0125 02:49:04.976814 9823 status_update_manager.cpp:317] Received status update TASK_KILLED (UUID: abad489c-73bb-4f45-abbe-85f033ddde51) for task TASKNAME.4b060055-b85a-11e5-8a34-52eb089dbeb2 of framework 20150311-145345-20031680-5050-2698-0000 Jan 25 02:49:05 hostname mesos-slave[9817]: I0125 02:49:05.108389 9823 status_update_manager.hpp:346] Checkpointing UPDATE for status update TASK_KILLED (UUID: abad489c-73bb-4f45-abbe-85f033ddde51) for task TASKNAME.4b060055-b85a-11e5-8a34-52eb089dbeb2 of framework 20150311-145345-20031680-5050-2698-0000 Jan 25 02:49:05 hostname mesos-slave[9817]: I0125 02:49:05.280825 9848 slave.cpp:2458] Forwarding the update TASK_KILLED (UUID: abad489c-73bb-4f45-abbe-85f033ddde51) for task TASKNAME.4b060055-b85a-11e5-8a34-52eb089dbeb2 of framework 20150311-145345-20031680-5050-2698-0000 to [email protected]:5050 Jan 25 02:49:05 hostname mesos-slave[9817]: I0125 02:49:05.346415 9848 slave.cpp:2391] Sending acknowledgement for status update TASK_KILLED (UUID: abad489c-73bb-4f45-abbe-85f033ddde51) for task TASKNAME.4b060055-b85a-11e5-8a34-52eb089dbeb2 of framework 20150311-145345-20031680-5050-2698-0000 to executor(1)@192.168.49.1:42710 Jan 25 02:49:05 hostname mesos-slave[9817]: I0125 02:49:05.443266 9820 status_update_manager.cpp:389] Received status update acknowledgement (UUID: abad489c-73bb-4f45-abbe-85f033ddde51) for task TASKNAME.4b060055-b85a-11e5-8a34-52eb089dbeb2 of framework 20150311-145345-20031680-5050-2698-0000 Jan 25 02:49:05 hostname mesos-slave[9817]: I0125 02:49:05.443447 9820 status_update_manager.hpp:346] Checkpointing ACK for status update TASK_KILLED (UUID: abad489c-73bb-4f45-abbe-85f033ddde51) for task TASKNAME.4b060055-b85a-11e5-8a34-52eb089dbeb2 of framework 20150311-145345-20031680-5050-2698-0000 Jan 25 02:49:34 hostname mesos-slave[9817]: I0125 02:49:34.419437 9833 slave.cpp:2898] Executor 'TASKNAME.4b060055-b85a-11e5-8a34-52eb089dbeb2' of framework 20150311-145345-20031680-5050-2698-0000 exited with status 0 Jan 25 02:49:34 hostname mesos-slave[9817]: I0125 02:49:34.445489 9833 slave.cpp:3007] Cleaning up executor 'TASKNAME.4b060055-b85a-11e5-8a34-52eb089dbeb2' of framework 20150311-145345-20031680-5050-2698-0000 Jan 25 02:49:34 hostname mesos-slave[9817]: I0125 02:49:34.471329 9837 gc.cpp:56] Scheduling '/tmp/mesos/slaves/20150512-155858-53586112-5050-11767-S0/frameworks/20150311-145345-20031680-5050-2698-0000/executors/TASKNAME.4b060055-b85a-11e5-8a34-52eb089dbeb2/runs/473a2313-0147-44ae-ab9c-b39f5a23be22' for gc 6.99999454929185days in the future Jan 25 02:49:34 hostname mesos-slave[9817]: I0125 02:49:34.471817 9837 gc.cpp:56] Scheduling '/tmp/mesos/slaves/20150512-155858-53586112-5050-11767-S0/frameworks/20150311-145345-20031680-5050-2698-0000/executors/TASKNAME.4b060055-b85a-11e5-8a34-52eb089dbeb2' for gc 6.99999454685037days in the future Jan 25 02:49:34 hostname mesos-slave[9817]: I0125 02:49:34.471911 9837 gc.cpp:56] Scheduling '/tmp/mesos/meta/slaves/20150512-155858-53586112-5050-11767-S0/frameworks/20150311-145345-20031680-5050-2698-0000/executors/TASKNAME.4b060055-b85a-11e5-8a34-52eb089dbeb2/runs/473a2313-0147-44ae-ab9c-b39f5a23be22' for gc 6.99999454636444days in the future Jan 25 02:49:34 hostname mesos-slave[9817]: I0125 02:49:34.471997 9837 gc.cpp:56] Scheduling '/tmp/mesos/meta/slaves/20150512-155858-53586112-5050-11767-S0/frameworks/20150311-145345-20031680-5050-2698-0000/executors/TASKNAME.4b060055-b85a-11e5-8a34-52eb089dbeb2' for gc 6.99999454594963days in the future </code></pre> <p>One answer I found to someone's question with the same error suggested to check if it gets killed by the OOM killer, I checked and there is no out of memory problem, no relevant kernel log. The mesos-slave itself logs that is asks the framework to kill it so I don't think it's an outside process, correct me if I'm wrong.</p> <p>I currently use:<br> Mesos: 0.21.1-1.2.debian77<br> Marathon: 0.8.0-1.1.97.debian77<br> Chronos: 2.3.2-0.1.20150207000917.debian77 </p> <p>I do know they are outdated, but this problem occurs for a long time seemingly at random times affecting random containers, and even if it occurs less in future releases I still bothered why a slave decides to kill a task without logging any reason...</p> <p>If you need any more logs just ask which one to provide. I only included so little because that container was running for more than a day without any problem or error/warn log in mesos or stderr and suddenly the first line appeared in the log asking the slave to kill it.</p>
1
R Shiny app progress Indicator for loading data
<p>Shiny is our internal BI tool. For our Shiny apps, we load data before shinyServer running:</p> <pre><code>load("afterProcessedData.RData") # or dt = fread("afterProcessedData.csv") shinyServer(function(input, output, session){ ... </code></pre> <p>However, some of apps are loading big files and they take up to 30s to load up. Many users, when they open a page, don't know whether the page is broken since it is stuck when it is loading. They may close it or click filters, which may cause an error. In this case, a progress bar will be very helpful. I notice <code>withProgress()</code> may help but it has to be inside <code>reactive()</code> or <code>renderXx()</code>. </p> <p>One way I can do is to have <code>laod()</code> warpped with <code>reactive()</code> inside the <code>shinyServer(function(input, output, session){</code> but my concern is it will slower the performance. And my users very care about the responsive performance.</p> <p>Any suggestions for this situation? </p> <p>Edit: I guess there is not an easy way to do this. I have another thought. Maybe I can show a text on the screen saying 'the data is loading', but I have to make it disappear after the first table gets show up. However, I don't know how to set up the condition. Below is my code showing first table:</p> <pre><code>dashboardBody( fluidRow( tabBox(width = 12, tabPanel("Summary", dataTableOutput("data1")), </code></pre> <p>Thank you in advance!</p>
1
Standard format for REST pagination, field selection, querying?
<p>When designing a REST API, following guidance such as <a href="http://blog.mwaysolutions.com/2014/06/05/10-best-practices-for-better-restful-api/" rel="nofollow">10 Best Practices for Better RESTful API</a>, there seem to be all sorts of ways to provide a query syntax, pagination, selecting fields to return, etc. </p> <p>For example, some ways to do pagination:</p> <ul> <li>/orders?max=20&amp;start=100</li> <li>/orders?per_page=20&amp;page=5</li> </ul> <p>Some ways to provide a query interface:</p> <ul> <li>/orders?q=value>20</li> <li>/orders?q={'value': 'gt 20'}</li> </ul> <p>Are there any standards for how to design an API that offers these features? If not, standards in development or best practice guidelines would be useful.</p>
1
Javascript form submit preventDefault not working when form is retrieved with AJAX
<p>I have a form, which I submit with Javascript and preventDefault. Everything works fine. However, when I retrieve the form with an AJAX call together with other data from a DB, the form will not submit with Javascript anymore, but tries to refresh the entire page with the normal action="" and method="post". It seems that due to the AJAX call, the preventDefault is somehow disabled?</p> <p>AJAX Call to get form and other data from DB:</p> <pre><code>&lt;a href="#" onClick="return false" onmousedown="javascript:loadnames('&lt;?php echo $postid;?&gt;');"&gt;Load Names&lt;/a&gt; &lt;div id="form-container"&gt;&lt;/div&gt; &lt;!-- is empty, but contains the form upon ajax call above--&gt; </code></pre> <p>The AJAX retrieved HTML Form to submit with Javascript:</p> <pre><code>&lt;div id="form-container"&gt; &lt;!--let user add a name to DB not contained in DB list below--&gt; &lt;form method="post" action="" id="addnameform"&gt; &lt;input name="name" id="name" type="text" value=""/&gt; &lt;input type="submit" name="add-name-submit" value="Add"/&gt; &lt;/form&gt; &lt;!--get a list of names from DB--&gt; &lt;?php $sql = "SELECT * FROM names ORDER BY name ASC"; $query = mysqli_query($connection, $sql); while ($row = mysqli_fetch_array($query)) { $name = $row["name"]; echo ... } // end while ?&gt; &lt;/div&gt;&lt;!--end-container--&gt; </code></pre> <p>Javascript to submit HTML form above:</p> <pre><code>$("#addnameform").submit(function(event) { event.preventDefault(); var $form = $("#addnameform"); var name = $form.find( "input[name='name']" ).val(); $.ajax({ url: "ajax.php", type: "POST", ... </code></pre> <p>As said, everything works perfectly when the form is displayed on the page upon page load. But as soon as I wrap it inside a container, which at first is "empty", but shows up upon an AJAX call, the preventDefault is somehow disabled.</p>
1
How To Get Next JSON Item
<p>I am wondering how would I get the next JSON item if I have the key in JavaScript. For example, if I provide the key 'Josh' how would I get the contents of 'Annie' along with the key 'Annie'? Would I have to process the JSON in an array and extract from there?</p> <p>In addition, I believe that there is a proper term for transforming data from one type to another. Any chance anyone knows what it is... it is just on the tip of my tongue!</p> <pre><code>{ "friends": { "Charlie": { "gender": "female", "age": "28" }, "Josh": { "gender": "male", "age": "22" }, "Annie": { "gender": "female", "age": "24" } } } </code></pre>
1
Send latitude and longitude to server every 5 minutes even the app was closed
<p>I need to send latitude and longitude values to the server for every 5 minutes.Our team members can be close this application during the travels that time also latitude and longitude value send to the server.I didn't have idea to how to implement this method.</p>
1
WebTorrent.IO is not working with other magnet links?
<p>I tried finding it out, but couldn't. I am following the steps from here — <a href="https://webtorrent.io/intro" rel="nofollow">https://webtorrent.io/intro</a>. I have following code in the file. </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt; StreamTest &lt;/title&gt; &lt;script type="text/javascript" src="webtorrent.min.js"&gt;&lt;/script&gt; &lt;script&gt; var client = new WebTorrent() var torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d' client.add(torrentId, function (torrent) { // Torrents can contain many files. Let's use the first. var file = torrent.files[0] // Display the file by adding it to the DOM. Supports video, audio, image, etc. files file.appendTo('body') }) &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;Torrent Stream Test&lt;/h2&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This code works fine with infohash — 6a9759bffd5c0af65319979fb7832189f4f3c35d But when I use it other info hash or magnet link, it doesn't work. An example of other info hash is 80096C11147EEE4D2B6B6AC0B96C951E48298BE3</p> <p>Any idea, why doesn't it work with other infohash or magnet link?</p>
1
Get last id of an entity in hibernate
<p>I need a way to fetch the last id of an entity in database, let's say for example </p> <p>Product entity:</p> <p>I try this but its not working:</p> <pre><code> public int lastInsertedId() { try { if (!session.isOpen()) session = DatabaseUtil.getSessionFactory().openSession(); session.beginTransaction(); Query query = session.createSQLQuery("select last_value from purchase_idpurchase_seq "); int lastid = query.getFirstResult(); session.getTransaction().commit(); session.close(); return lastid; } catch (Exception e) { e.printStackTrace(); return -1; } } </code></pre>
1
How to change the toolbar name and put icon with tool bar
<p>I have just made the app using android studio template of Navigation view. Its all working fine but I have the following two requirements </p> <ol> <li>I want to center the toolbar title. </li> <li>I want to put the image beside the title.</li> </ol> <p>Here is my xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context="com.abdulsalam.lahoreqalander.MainActivity"&gt; &lt;android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"&gt; &lt;android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /&gt; &lt;/android.support.design.widget.AppBarLayout&gt; &lt;include layout="@layout/content_main" /&gt; &lt;!--&lt;android.support.design.widget.FloatingActionButton--&gt; &lt;!--android:id="@+id/fab"--&gt; &lt;!--android:layout_width="wrap_content"--&gt; &lt;!--android:layout_height="wrap_content"--&gt; &lt;!--android:layout_gravity="bottom|end"--&gt; &lt;!--android:layout_margin="@dimen/fab_margin"--&gt; &lt;!--android:src="@android:drawable/ic_dialog_email" /&gt;--&gt; </code></pre> <p></p> <p><strong>Problem :</strong></p> <p>I do not know where the title string is saved, I have checked the string.xml and there is the app name and that is exactly showing on the toolbar title. </p> <p>So Any suggestion where can I change the title string without changing the app name , In fact I want to change it custom and also how to put the image beside it. </p> <blockquote> <p>Note I am using the template made by Android studio</p> </blockquote> <p>. </p>
1
Regex to match start of string or space or comma
<p>I am looking to match a postcode using the following regex:</p> <pre><code>(GIR ?0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]([0-9ABEHMNPRV-Y])?)|[0-9][A-HJKPS-UW]) ?[0-9][ABD-HJLNP-UW-Z]{2}) </code></pre> <p>I am trying to parse an address from an HTML document and as such I only want to match nodes that start with a postcode or contain a postcode that is preceded by a space or comma. Otherwise there are too many false positives e.g. matching colours (preceded by #).</p> <p>I need to amend the regex to either find the postcode with no preceding characters or a space or comma immediately preceding it and any number of characters before this. How can I do this?</p> <p>For example, I would want to match:</p> <pre><code>IP14 2PL 1 The street, ipswich, IP14 2PL 1 The street, ipswich,IP14 2PL </code></pre> <p>BUT NOT</p> <pre><code>https://t.co/ip142plzruc </code></pre>
1
White space on either side of navbar html
<p>I'm very new to writing html and am trying to create a navigation bar for the first time. The issue I'm having is that there is (a varying degree) of white space either side of the bar. I've made a quick mock up and screen shot to show what I mean: <a href="http://i.stack.imgur.com/QQVMp.png" rel="nofollow">Image</a></p> <p>I've spent a lot of time over the last couple hours going through questions that are similar and sometimes identical, but none of the solutions I've tried have worked. </p> <p>My code is as follows:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>#navbar { margin: 0px; padding: 0px; width: auto; } #navbar ul { background-color: #FAFAD2; } #navbar li { float: left; width: 20%; text-align: center; display: table-cell; background-color: #FAFAD2; } #navbar li a { display: block; color: #4682B4; text-align: center; padding: 14px 16px; text-decoration: none; } #navbar li a:hover:not(.active) { background-color: #FAF0E6; } #navbar .active { background-color: #FAFAD2; } #header { width: 100%; text-align: center; position: relative; } html, body { margin: 0; padding: 0; width: 100%; height: 100%; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="header"&gt; &lt;h1&gt;Reserved&lt;/h1&gt; &lt;/div&gt; &lt;div id="navbar"&gt; &lt;ul&gt; &lt;li&gt;&lt;a class="active" href="#home"&gt;Home&lt;/a&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=“#Experience”&gt;Experience&lt;/a&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=“#Consulting Services“&gt;Consulting Services&lt;/a&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=“#Contact”&gt;Contact&lt;/a&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=“#About”&gt;About&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>Any help would be greatly appreciated!<br> Also, sorry for any formatting issues with this post!</p>
1
print(foo, end="") not working in terminal
<p>So this is some code that is supposed to print text, similar to how Pokemon does. Purely for fun. </p> <p>The problem is that <code>print(x, end="")</code> does not work when the program is run in the terminal, but it works fine when run using IDLE.</p> <pre><code>import time lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit." for x in lorem: print(x, end="") time.sleep(0.03) </code></pre> <p>For some reason the program works fine if I put a print statement before <code>print(x, end="")</code>.</p> <pre><code>for x in lorem: print() print(x, end="") time.sleep(0.03) </code></pre> <p>Does anyone have any idea what is causing this? And maybe how to fix it?</p>
1
NSAttributedString changing the font size
<p>I am using this extension of String to get proper attributed text from the HTML tags in a String.</p> <pre><code>extension String { var html2AttributedString: NSAttributedString? { guard let data = dataUsingEncoding(NSUTF8StringEncoding) else { return nil } do { return try NSAttributedString(data: data, options: [NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType,NSCharacterEncodingDocumentAttribute:NSUTF8StringEncoding ], documentAttributes: nil) } catch let error as NSError { print(error.localizedDescription) return nil } } var html2String: String { return html2AttributedString?.string ?? "" } } </code></pre> <p>And I am using the value in a <code>UILabel</code> inside a <code>UICollectionView</code>.</p> <pre><code>if let value = mainNote.html2AttributedString { cell.note.attributedText = value } else { cell.note.text = mainNote } </code></pre> <p>This method works great. But by default it comes with the "Times New Roman" font with size of 11. So I wanted to make it little bigger. I tried using <code>NSMutableAttributedString</code>.</p> <pre><code>if let value = mainNote.html2AttributedString { let mutableString = NSMutableAttributedString(string: value.string, attributes: [NSFontAttributeName : UIFont(name: "Times New Roman", size: 20)!]) cell.note.attributedText = mutableString } else { cell.note.text = mainNote } </code></pre> <p>Which actually did nothing. </p> <p>If I increase the font size of <code>UILabel</code> directly then the font size gets increased but the italic attribute does not work.</p> <pre><code>cell.note.font = UIFont(name: "Times New Roman", size: 16) </code></pre> <p>Please help me out here to make the String little bigger.</p>
1
Align image and list on same line in html
<p>Currently I am trying to create a header section in HTML, which contains a logo image and a list which is being used as a navigation menu. The problem which I am facing right now is that, when I am giving a certain height to the list(equivalent to image height) the height of the list is going downwards against the image, and I want to be on the same line and text of the list in the middle. The following is the code snippet of my page.</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.header-section&gt;img { display:inline-block; padding:10px; background-color:yellow; } .navigation,.navigation ul { list-style:none; } .navigation { background-color:red; display:inline-block; } .navigation&gt;li { display:inline; text-align:center; line-height:50px; } .navigation ul { display:none; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!--Header section--&gt; &lt;div class="header-section"&gt; &lt;img src="images/logo/logo.png" alt="logo" width="90px" height="30px"&gt; &lt;!--Navigation section--&gt; &lt;ul class="navigation"&gt; &lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li class="sub-menu"&gt; &lt;a href="#"&gt;About &amp;#x25BC;&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;The Company&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;The Founders&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;The Team&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;The Mission&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li class="sub-menu"&gt; &lt;a href="#"&gt;Products &amp;#x25BC;&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Solar Panels&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Solar Lamps&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Solar Heaters&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Solar Cookers&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li class="sub-menu"&gt; &lt;a href="#"&gt;Services &amp;#x25BC;&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Solar Equipment Repair&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Installation&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Maintenance&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Training&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li class="sub-menu"&gt; &lt;a href="#"&gt;Support &amp;#x25BC;&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Training&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li class="sub-menu"&gt; &lt;a href="#"&gt;Contact &amp;#x25BC;&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Email Us&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Contact Form&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;!--Social Icons--&gt; &lt;img src="images/icons/twitter.png"&gt; &lt;img src="images/icons/facebook.png"&gt; &lt;img src="images/icons/google-plus.png"&gt; &lt;/div&gt; &lt;!--Header section closed--&gt;</code></pre> </div> </div> </p>
1
GOOGLE PLAY SERVICES EXCEPTION: com.google.android.gms.common.GooglePlayServicesUtil
<p>I am trying to integrate Google Play Games into my app. It is currently working in debug mode. However, it does not seem to work in release mode. I am getting errors. I tried clean and rebuild.</p> <blockquote> <p>java.lang.RuntimeException: Unable to get provider com.google.android.gms.measurement.AppMeasurementContentProvider: java.lang.ClassNotFoundException</p> </blockquote> <p>And then this one:</p> <blockquote> <p>GOOGLE PLAY SERVICES EXCEPTION: com.google.android.gms.common.GooglePlayServicesUtil</p> </blockquote> <p>Followed by this one:</p> <blockquote> <p>There is a problem with the Google Play Services library, which is required for Android Advertising ID support. The Google Play Services library should be integrated in any app shipping in the Play Store that uses analytics or advertising.</p> </blockquote> <p>What could be wrong? I tried experimenting with Gradle, but no luck yet.</p> <p>If I disable Proguard, it works! This seems to be a known issue, but not resolved yet. Any ideas?</p>
1
How do I capture the data passed in SqlBulkCopy using the Sql Profiler?
<p>I am using Sql Profiler all the time to capture the SQL statements and rerun problematic ones. Very useful.</p> <p>However, some code uses the SqlBulkCopy API and I have no idea how to capture those. I see creation of temp tables, but nothing that populates them. Seems like SqlBulkCopy bypasses Sql Profiler or I do not capture the right events.</p>
1
MySQL GROUP BY on multiple columns, codeigniter
<p>I know the title sounds like the a common question, but I have looked around here and can't seem to find problems (with answers) the same as mine.</p> <p>So this is my case: I have three tables (major_criteria, questions, and results) ... There are multiple major criteria, and one major criteria has multiple questions. The table results holds all the users' answers to those questions.. Using this code: </p> <pre><code>$this-&gt;db-&gt;simple_query('set session group_concat_max_len=1000000'); $this-&gt;db-&gt;select('*, GROUP_CONCAT(CONCAT("&lt;tr&gt;&lt;td&gt;", eq_question, "&lt;/td&gt;&lt;td id=fix&gt;", r_value) SEPARATOR "&lt;/td&gt;&lt;/tr&gt;") as quesrate', false); $this-&gt;db-&gt;from('evaluation_result'); $this-&gt;db-&gt;join('evaluation_question', 'evaluation_question.eq_ai=evaluation_result.er_eq_ai', left); $this-&gt;db-&gt;join('evaluation_major_criteria', 'evaluation_major_criteria.emc_ai=evaluation_question.eq_emc_ai', left); $this-&gt;db-&gt;join('rating', 'rating.r_ai=evaluation_result.er_rate', left); $this-&gt;db-&gt;where('er_il_ai', $inst); $this-&gt;db-&gt;where('er_ay_ai', $aca); $this-&gt;db-&gt;where('er_sem_ai', $sem); $this-&gt;db-&gt;where('er_et_ai', $evaltype); $this-&gt;db-&gt;order_by('emc_code', 'asc'); $this-&gt;db-&gt;group_by('emc_code', 'asc'); $query=$this-&gt;db-&gt;get(); </code></pre> <p>Assuming I have three users who answered, I was able to achieve this:</p> <p>A. Major Criteria 1</p> <p>Question 1 | Answer 1</p> <p>Question 1 | Answer 2</p> <p>Question 1 | Answer 3</p> <p>Question 2 | Answer 1</p> <p>Question 2 | Answer 2</p> <p>Question 2 | Answer 3</p> <p>B. Major Criteria 2</p> <p>Question 1 | Answer 1</p> <p>Question 1 | Answer 2</p> <p>Question 1 | Answer 3</p> <p>Question 2 | Answer 1</p> <p>Question 2 | Answer 2</p> <p>Question 2 | Answer 3</p> <p>...</p> <p>I was successfully able to group them by major criteria. But It's close to what I want to achieve. What I want is to group it by question too, so it doesn't repeat by how many the users have answered.</p> <p>Something like this:</p> <p>A. Major Criteria 1</p> <p>Question 1 | Answer 1, Answer 2, Answer 3</p> <p>Question 2 | Answer 1, Answer 2, Answer 3</p> <p>B. Major Criteria 2</p> <p>Question 1 | Answer 1, Answer 2, Answer 3</p> <p>Question 2 | Answer 1, Answer 2, Answer 3</p> <p>...</p> <p>I have tried using two group_by and it doesn't work like how I want it to, according to this: <a href="https://stackoverflow.com/questions/2421388/using-group-by-on-multiple-columns">Using group by on multiple columns</a></p> <p>I have tried putting DISTINCT in GROUP_CONCAT but it gives me really weird combination of questions (some still repeated) under correctly grouped major criteria.</p> <p>I have tried nested select statements with one or two group_by.</p> <p>Idk. Maybe I'm looking at the wrong direction?</p> <p>I have ran out of resources. I've looked around and tried everything I found, still no luck. This is my last resort. I'm using codeigniter for this, btw.</p> <p>EDIT:</p> <p>I also have this code from when I first made the page:</p> <pre><code>$this-&gt;db-&gt;select('*', false); $this-&gt;db-&gt;from('evaluation_result'); $this-&gt;db-&gt;join('evaluation_question', 'evaluation_question.eq_ai=evaluation_result.er_eq_ai', left); $this-&gt;db-&gt;join('evaluation_major_criteria', 'evaluation_major_criteria.emc_ai=evaluation_question.eq_emc_ai', left); $this-&gt;db-&gt;join('rating', 'rating.r_ai=evaluation_result.er_rate', left); $this-&gt;db-&gt;where('er_il_ai', $inst); $this-&gt;db-&gt;where('er_ay_ai', $aca); $this-&gt;db-&gt;where('er_sem_ai', $sem); $this-&gt;db-&gt;where('er_et_ai', $evaltype); $this-&gt;db-&gt;where('eq_s_ai', 2); $this-&gt;db-&gt;order_by('emc_code', 'asc'); $this-&gt;db-&gt;group_by('eq_ai'); $query=$this-&gt;db-&gt;get(); </code></pre> <p>And it groups by question. Now I have two queries, one that groups by major criteria, and one that groups by question. I guess I just have to combine them? But idk how.</p>
1
JQuery Change Background Color of Dropdown List Element Based on Title
<p>In this code, it originated with just a blank table with a select tag:</p> <pre><code>&lt;table class="table"&gt; &lt;tr&gt; &lt;td&gt; &lt;select id="e2"&gt; &lt;option value="green"&gt;Green&lt;/option&gt; &lt;option value="yellow"&gt;Yellow&lt;/option&gt; &lt;option value="red"&gt;Red&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>This is generated with jQuery functions that format the selection as a list of nested spans:</p> <pre><code>&lt;table class="table"&gt; &lt;tr&gt; &lt;td&gt; &lt;b class="tablesaw-cell-label"&gt;Status&lt;/b&gt; &lt;span class="tablesaw-cell-content"&gt; &lt;select tabindex="-1" class="select2-hidden-accessible" id="e2" aria-hidden="true"&gt; &lt;option value="green"&gt;Green&lt;/option&gt; &lt;option value="yellow"&gt;Yellow&lt;/option&gt; &lt;option value="red"&gt;Red&lt;/option&gt; &lt;/select&gt; &lt;span class="select2 select2-container select2-container--default select2-container--below" style="width: 64px;" dir="ltr"&gt; &lt;span class="selection"&gt; &lt;span tabindex="0" class="select2-selection select2-selection--single" role="combobox" aria-expanded="false" aria-haspopup="true" aria-labelledby="select2-e2-container"&gt; &lt;span title="Green" class="select2-selection__rendered" id="select2-e2-container"&gt;Green&lt;/span&gt; &lt;span class="select2-selection__arrow" role="presentation"&gt;&lt;b role="presentation"&gt;&lt;/b&gt;&lt;/span&gt; &lt;/span&gt; &lt;/span&gt; &lt;span class="dropdown-wrapper" aria-hidden="true"&gt;&lt;/span&gt; &lt;/span&gt; &lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I am trying to change the color by using jQuery of the individual background colors based on the title of the element after the page is loaded. Here is my current color change function. This runs after the dropdown list is created and formatted by the <code>select2</code> function.</p> <pre><code>$(document).ready(function () { $('#e1').select2(); $('#e2').select2(); $('.select2-selection.select2-selection--single span.select2-selection__rendered').each(function () { var title = $(this).attr('title'); console.log(title); if (title === 'Green') { $(this).parent().css('background-color', 'green'); } if (title === 'Yellow') { $(this).parent().css('background-color', 'yellow'); } if (title === 'Red') { $(this).parent().css('background-color', 'red'); } }); }); </code></pre> <p>I have been able to simplify the code and change the color of all elements as a single color. However, I'm trying to change the color of each selection element based on the title of that element and not change the other elements's background color.</p>
1
Convert between c++11 clocks
<p>If I have a <code>time_point</code> for an arbitrary clock (say <code>high_resolution_clock::time_point</code>), is there a way to convert it to a <code>time_point</code> for another arbitrary clock (say <code>system_clock::time_point</code>)?</p> <p>I know there would have to be limits, if this ability existed, because not all clocks are steady, but is there any functionality to help such conversions in the spec at all?</p>
1
How to edit a table field value in PHPMyAdmin
<p>In PHPMyAdmin, I am looking at a table, but I see no way to edit a table entry (not sure of the correct terminology sorry).</p> <p><a href="https://i.stack.imgur.com/FWZ8l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FWZ8l.png" alt="enter image description here"></a></p> <p>The value I want to edit is <code>DisableAdminPWReset</code> (to 0).</p> <p>How do I do this? There are no methods of editing this value that I can see. I am a SQL newb too.</p>
1
ctypes - numpy array with no shape?
<p>I am using a python wrapper to call functions of a c++ dll library. A ctype is returned by the dll library, which I convert to numpy array</p> <pre><code>score = np.ctypeslib.as_array(score,1) </code></pre> <p>however, the array has no shape?</p> <pre><code>score &gt;&gt;&gt; array(-0.019486344729027664) score.shape &gt;&gt;&gt; () score[0] &gt;&gt;&gt; IndexError: too many indices for array </code></pre> <p>How can I extract a double from the score array?</p> <p>Thank you.</p>
1
Variable name same as function name giving compiler error... Why?
<p>Ran into an interesting issue today and am trying to understand why.</p> <p>Consider the following:</p> <pre><code>class Base { public: Base(){} ~Base(){} static void function1(){} void function2() { int function1; function1 = 0; function1(); //&lt;-compiler error function1 = 1; } }; </code></pre> <p>I am getting the following error:</p> <blockquote> <p>expression preceding parentheses of apparent call must have (pointer-to-) function type</p> </blockquote> <p>I think I understand why I am getting this error:</p> <ol> <li><p>When <code>function1</code> is called by itself outside of <code>function2()</code>, it is actually a function pointer to <code>function1()</code>.</p></li> <li><p>Inside the scope of <code>function2</code>, when <code>int function1</code> is declared, '<code>function1</code> the variable' shadows '<code>function1</code> the function pointer'.</p></li> <li><p>When <code>function1()</code> is called inside <code>function2()</code>, it is assuming <code>function1</code> is the variable and is giving an error.</p></li> <li><p>This is fixed by calling <code>Base::function1();</code> inside <code>function2()</code>.</p></li> </ol> <p>My question is this: Why doesn't the compiler give an error when declaring <code>int function1;</code>? Shouldn't this not be allowed?</p>
1
Display content on single product page in Woocommerce based on category
<p>I'm sooooo close - but I can't get this last little bit. </p> <p>I am adding the authors name to books we have for sale in woo. The style needs to be different from the book title so I'm using a custom meta field to put it under the title and style it the way I want. I have everything working and where I want it, now I just need for it only show on a particular category instead of on all products. </p> <p>There seems to me to be two ways to do this. 1 - Only display it for products in a particular category 2 - Only display it if there is content. </p> <p>I'm currently trying to only display if it's a particular category, but while writing this, its seems a more elegant solution to only display if content exists.</p> <p>Here's what I have</p> <pre><code>function cn_add_add_subhead_to_title() { global $woocommerce, $post; if ( is_product() &amp;&amp; has_term( 'books-media', 'product_cat' ) ) { ?&gt; &lt;div class="cn-subhead"&gt; by &lt;?php echo get_post_meta( $post-&gt;ID, '_text_field', true ); ?&gt; &lt;/div&gt; &lt;?php } } add_action( 'woocommerce_single_product_summary', 'cn_add_add_subhead_to_title', 6 ); </code></pre> <p>This doesn't display anywhere, but when I take out the if statement it shows on all products. </p> <p>Any idea where I went awry? </p>
1
Clang cross-compilation for ARM
<p>I'm trying to compile a file containing <code>stdint.h</code> for ARM (specifically Cortex-M3) using <code>arm-none-eabi</code> (which is a Debian's package) headers. The command is:</p> <pre><code>clang -I/usr/lib/gcc/arm-none-eabi/4.8/include \ -target arm-none-eabi cfile.c -o cfile.o </code></pre> <p>(<code>-mcpu</code>, <code>-mfpu</code>, <code>-mfloat-abi</code> are left out for simplicity)</p> <p>Returns an error:</p> <pre><code>In file included from cfile.c:1: In file included from ./cfile.h:4: In file included from /usr/lib/gcc/arm-none-eabi/4.8/include/stdint.h:9: In file included from /usr/lib/llvm-3.5/bin/../lib/clang/3.5.0/include/stdint.h:61: In file included from /usr/include/stdint.h:25: /usr/include/features.h:374:12: fatal error: 'sys/cdefs.h' file not found # include &lt;sys/cdefs.h&gt; ^ 1 error generated. </code></pre> <p>I've been generally following <a href="http://clang.llvm.org/docs/CrossCompilation.html" rel="nofollow noreferrer">this guide</a>.</p> <p>My versions:</p> <pre><code>$ clang --version Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0) $ arm-none-eabi-gcc --version arm-none-eabi-gcc (4.8.4-1+11-1) 4.8.4 20141219 (release) </code></pre> <p>Any ideas on how to approach solving this?</p> <p>P.S.: Not a duplicate of <a href="https://stackoverflow.com/questions/14697614/clang-cross-compiling-for-arm">this question</a>.</p>
1
How to pass two arrays to functions in javascript
<p>I want to sort the wordList array and wordCount array. They are parralel arrays and I want to sort it according to the count of each word. I cannot use its built-in sort function so I need to write one. But I don't know why my codes failed:</p> <pre><code>wordList = ["apple", "have", "pear", "here"]; wordCount = [3, 1, 3, 5]; sortWords(wordList, wordCount); function sortWords(arr1, arr2) { ..... } </code></pre> <p>Does my code successfully pass these two arrays to the function?</p>
1
TimeZone to Offset?
<p>I want to get the offset in seconds from a specified time zone. That is exactly what <code>tz_offset()</code> in Perl's <a href="https://metacpan.org/source/GBARR/TimeDate-2.30/lib/Time/Zone.pm" rel="nofollow">Time::Zone</a> does: "determines the offset from GMT in seconds of a specified timezone".</p> <p>Is there already a way of doing this in Go? The input is a string that has the time zone name <em>and that's it</em>, but I know that Go has <code>LoadLocation()</code> in the <code>time</code> package, so <em>string => offset</em> or <em>location => offset</em> should be fine.</p> <p><strong>Input:</strong> "MST"</p> <p><strong>Output:</strong> -25200</p>
1
How to implement 2 or more recyIclerview in an activity
<p>How to implement 2 or more recyIclerview in an activity ? I am trying to implement 2 or more recyclerview in my activity</p> <p>in this code line I am declaring the first adapter</p> <pre><code>private RecyclerView.Adapter mAdapter; </code></pre> <p>how to declare my second adapter?</p> <p>by the way while running my app with the below code , the recyclerview is not scrolling and displaying correcly</p> <p>mainactivity</p> <pre><code> private RecyclerView mRecyclerView; private RecyclerView mRecyclerView1; private RecyclerView.Adapter mAdapter; private RecyclerView.LayoutManager mLayoutManager; private static String LOG_TAG = "RecyclerViewActivity"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_recycler_view); //first recycler mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); // LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); mLayoutManager = new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, false); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new MyAdapter(getDataSet()); mRecyclerView.setAdapter(mAdapter); RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(this, LinearLayoutManager.VERTICAL); mRecyclerView.addItemDecoration(itemDecoration); //second recycler mRecyclerView1 = (RecyclerView) findViewById(R.id.my_recycler_view1); mRecyclerView1.setHasFixedSize(true); LinearLayoutManager mLayoutManager1 = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); mRecyclerView1.setLayoutManager(mLayoutManager1); // mAdapter1 = new MyAdapter1(getDataSet1()); mRecyclerView1.setAdapter(mAdapter1); </code></pre> <p>myadapter</p> <pre><code>public class MyAdapter extends RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt; { private ArrayList&lt;String&gt; mDataset; public class ImageViewHolder extends RecyclerView.ViewHolder { //ImageView mImage; public TextView txtHeader; public TextView txtFooter; public ImageViewHolder(View itemView) { super (itemView); txtHeader = (TextView) itemView.findViewById(R.id.firstLine); txtFooter = (TextView) itemView.findViewById(R.id.secondLine); } } public void add(int position, String item) { mDataset.add(position, item); notifyItemInserted(position); } public void remove(String item) { int position = mDataset.indexOf(item); mDataset.remove(position); notifyItemRemoved(position); } // Provide a suitable constructor (depends on the kind of dataset) public MyAdapter(ArrayList&lt;String&gt; myDataset) { mDataset = myDataset; } // Create new views (invoked by the layout manager) @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { // create a new view View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.rowlayout, parent, false); // set the view's size, margins, paddings and layout parameters ImageViewHolder vh = new ImageViewHolder(v); return vh; } private static final int TYPE_IMAGE = 1; private static final int TYPE_GROUP = 2; @Override public int getItemViewType(int position) { // here your custom logic to choose the view type return position; } // Replace the contents of a view (invoked by the layout manager) @Override public void onBindViewHolder(RecyclerView.ViewHolder TextViewHolder, int position) { ImageViewHolder viewHolder = (ImageViewHolder) TextViewHolder; // viewHolder.txtHeader.setText(...) final String name = mDataset.get(position); viewHolder.txtHeader.setText(mDataset.get(position)); viewHolder.txtFooter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { remove(name); } }); // viewHolder.txtFooter.setText("Footer: " + mDataset.get(position)); } // Return the size of your dataset (invoked by the layout manager) @Override public int getItemCount() { return mDataset.size(); } } </code></pre> <p>my adpater1</p> <p>public class MyAdapter1 extends RecyclerView.Adapter { private ArrayList mDataset;</p> <pre><code>public class ImageViewHolder extends RecyclerView.ViewHolder { //ImageView mImage; public TextView txtHeader; public TextView txtFooter; public ImageViewHolder(View itemView) { super (itemView); txtHeader = (TextView) itemView.findViewById(R.id.firstLine); txtFooter = (TextView) itemView.findViewById(R.id.secondLine); } } public void add(int position, String item) { mDataset.add(position, item); notifyItemInserted(position); } public void remove(String item) { int position = mDataset.indexOf(item); mDataset.remove(position); notifyItemRemoved(position); } // Provide a suitable constructor (depends on the kind of dataset) public MyAdapter1(ArrayList&lt;String&gt; myDataset) { mDataset = myDataset; } // Create new views (invoked by the layout manager) @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { // create a new view View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.rowlayout1, parent, false); // set the view's size, margins, paddings and layout parameters ImageViewHolder vh = new ImageViewHolder(v); return vh; } private static final int TYPE_IMAGE = 1; private static final int TYPE_GROUP = 2; @Override public int getItemViewType(int position) { // here your custom logic to choose the view type return position; } // Replace the contents of a view (invoked by the layout manager) @Override public void onBindViewHolder(RecyclerView.ViewHolder TextViewHolder, int position) { ImageViewHolder viewHolder = (ImageViewHolder) TextViewHolder; // viewHolder.txtHeader.setText(...) final String name = mDataset.get(position); viewHolder.txtHeader.setText(mDataset.get(position)); viewHolder.txtFooter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { remove(name); } }); // viewHolder.txtFooter.setText("Footer: " + mDataset.get(position)); } // Return the size of your dataset (invoked by the layout manager) @Override public int getItemCount() { return mDataset.size(); } </code></pre> <p>mainactivity layout</p> <p></p> <pre><code> &lt;TextView android:id="@+id/textView" android:layout_width="150dp" android:layout_height="30dp" android:paddingLeft="@dimen/activity_horizontal_margin" android:layout_alignParentTop="true" android:paddingTop="5dp" android:text="Recomanded for you" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;android.support.v7.widget.RecyclerView android:id="@+id/my_recycler_view" android:layout_width="400dp" android:layout_height="180dp" android:layout_below="@id/textView" android:scrollbars="vertical" /&gt; &lt;TextView android:id="@+id/textView1" android:layout_width="150dp" android:layout_height="30dp" android:paddingLeft="@dimen/activity_horizontal_margin" android:layout_alignParentTop="true" android:paddingTop="5dp" android:layout_below="@id/my_recycler_view" android:text=" for you" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;android.support.v7.widget.RecyclerView android:id="@+id/my_recycler_view1" android:layout_width="400dp" android:layout_height="180dp" android:layout_below="@id/textView1" android:scrollbars="vertical" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p><a href="https://i.stack.imgur.com/6SxvT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6SxvT.png" alt="enter image description here"></a></p>
1
How to disable 'save' option in Excel but 'save as' should be still working
<p>I need to disable the save option in Excel but I still need the save as option to be working... So I know how to disable both of the option by this VBA: </p> <pre><code>Private Sub Workbook_BeforeSave(ByVal SaveUI As Boolean, Cancel As Boolean) MsgBox "You can't save this workbook!" Cancel = True End Sub </code></pre> <p>But How is it possible to disable save but save us to be working still. Thank you for helping me</p>
1
Uncaught TypeError: Cannot use 'in' operator to search for 'length' in false
<p>P.S-I know this has been asked. But the answers are too complicated for me to comprehend, besides I'm a newbie in JavaScript/jQuery 2.1.4.</p> <p>Whenever I start my web app project, this error occurs. But the thing about this error is that it didn't stop the function from executing so it's good. Anyway I don't want to see this error, because I want my app to be error free; so I traced it up and here is my code: </p> <pre><code>//populate locations select options $(document).ready(function(){ $.ajax({ type: "GET", url: "asset_management/poploc", //the script to call to get data data:'', //you can insert url argumnets here to pass to api.php dataType: 'json', //data format success: function(data){ //on recieve of reply $.each(data, function(index,item){ $("#pop_loc").append("&lt;option value=\""+item.location_id+"\"&gt;"+item.location_name+"&lt;/option&gt;"); }); } }); }); </code></pre> <p>Kindly check please.</p>
1
ClassNotFoundException after adding JAX-RS annotations (@Path etc.) in classes in Java
<p>I need some help with JAX-RS and Jersey in my multi module Java EE App.</p> <p>I will start with describing my environment:</p> <ol> <li>Java 8 (Java EE 7)</li> <li>Maven 3.3.3</li> <li>GlassFish 4.1.</li> </ol> <p>After properly deploying on GlassFish there are such errors in logs:</p> <pre><code>[2016-02-08T14:06:10.302+0100] [glassfish 4.1] [WARNING] [AS-WEB-UTIL-00035] [javax.enterprise.web.util] [tid: _ThreadID=44 _ThreadName=admin-listener(2)] [timeMillis: 1454936770302] [levelValue: 900] [[ Unable to load class pl.com.softnet.rest.RestConfig, reason: java.lang.ClassNotFoundException: pl.com.softnet.rest.RestConfig]] [2016-02-08T14:06:10.304+0100] [glassfish 4.1] [WARNING] [AS-WEB-UTIL-00035] [javax.enterprise.web.util] [tid: _ThreadID=44 _ThreadName=admin-listener(2)] [timeMillis: 1454936770304] [levelValue: 900] [[ Unable to load class pl.com.softnet.rest.GraphConfig, reason: java.lang.ClassNotFoundException: pl.com.softnet.rest.GraphConfig]] [2016-02-08T14:06:10.304+0100] [glassfish 4.1] [WARNING] [AS-WEB-UTIL-00035] [javax.enterprise.web.util] [tid: _ThreadID=44 _ThreadName=admin-listener(2)] [timeMillis: 1454936770304] [levelValue: 900] [[ Unable to load class pl.com.softnet.rest.GraphConfig, reason: java.lang.ClassNotFoundException: pl.com.softnet.rest.GraphConfig]] [2016-02-08T14:06:10.304+0100] [glassfish 4.1] [WARNING] [AS-WEB-UTIL-00035] [javax.enterprise.web.util] [tid: _ThreadID=44 _ThreadName=admin-listener(2)] [timeMillis: 1454936770304] [levelValue: 900] [[ Unable to load class pl.com.softnet.rest.GraphConfig, reason: java.lang.ClassNotFoundException: pl.com.softnet.rest.GraphConfig]] [2016-02-08T14:06:10.305+0100] [glassfish 4.1] [WARNING] [AS-WEB-UTIL-00035] [javax.enterprise.web.util] [tid: _ThreadID=44 _ThreadName=admin-listener(2)] [timeMillis: 1454936770305] [levelValue: 900] [[ Unable to load class pl.com.softnet.rest.GraphConfig, reason: java.lang.ClassNotFoundException: pl.com.softnet.rest.GraphConfig]] [2016-02-08T14:06:10.305+0100] [glassfish 4.1] [WARNING] [AS-WEB-UTIL-00035] [javax.enterprise.web.util] [tid: _ThreadID=44 _ThreadName=admin-listener(2)] [timeMillis: 1454936770305] [levelValue: 900] [[ Unable to load class pl.com.softnet.rest.RestConfig, reason: java.lang.ClassNotFoundException: pl.com.softnet.rest.RestConfig]] </code></pre> <p>Here is my poms dependency of Web Service module:</p> <pre><code> &lt;!-- JAVAEE API 7--&gt; &lt;dependency&gt; &lt;groupId&gt;javax&lt;/groupId&gt; &lt;artifactId&gt;javaee-api&lt;/artifactId&gt; &lt;version&gt;7.0&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;!-- SERVLET--&gt; &lt;dependency&gt; &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt; &lt;artifactId&gt;jsp-api&lt;/artifactId&gt; &lt;exclusions&gt; &lt;exclusion&gt; &lt;groupId&gt;javax.el&lt;/groupId&gt; &lt;artifactId&gt;el-api&lt;/artifactId&gt; &lt;/exclusion&gt; &lt;/exclusions&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt; &lt;artifactId&gt;jersey-container-servlet&lt;/artifactId&gt; &lt;version&gt;2.22&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt; &lt;artifactId&gt;jersey-client&lt;/artifactId&gt; &lt;version&gt;2.22&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;!-- RICHAFACES --&gt; &lt;dependency&gt; &lt;groupId&gt;org.richfaces&lt;/groupId&gt; &lt;artifactId&gt;richfaces&lt;/artifactId&gt; &lt;version&gt;4.5.0.Final&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;javax.el&lt;/groupId&gt; &lt;artifactId&gt;el-api&lt;/artifactId&gt; &lt;version&gt;2.1.2-b04&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;!-- JSF --&gt; &lt;dependency&gt; &lt;groupId&gt;org.glassfish&lt;/groupId&gt; &lt;artifactId&gt;javax.faces&lt;/artifactId&gt; &lt;version&gt;2.2.0&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; </code></pre> <p>This is the resource class:</p> <pre><code>package pl.com.softnet.rest; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; import pl.com.softnet.ejb3.localBeans.FSMAdministratorBean; import pl.com.softnet.ejb3.localBeans.ModulBezpieczenstwaBean; import pl.com.softnet.entity.ProcesyDef; import pl.com.softnet.entity.Uzytkownik; import pl.com.softnet.filters.TestFilter; import pl.com.softnet.util.ServiceLocator; import pl.com.softnet.util.XmlUtils; import pl.com.softnet.wyjatki.ModyfikacjaProcesuException; import javax.naming.NamingException; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.xpath.XPathExpressionException; import java.io.IOException; import java.util.UUID; @Path("config") public class GraphConfig { @GET @Path("{id}") @Produces(MediaType.APPLICATION_XML) public Response getMethod { } @POST @Path("{id}") @Consumes(MediaType.APPLICATION_XML) public Response postMethod() { } } </code></pre> <p>There is a Web Service class:</p> <pre><code>package pl.com.softnet.rest; import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; import java.util.HashSet; import java.util.Set; @ApplicationPath("/rest/*") public class RestConfig extends Application { @Override public Set&lt;Class&lt;?&gt;&gt; getClasses() { Set&lt;Class&lt;?&gt;&gt; myResources = new HashSet&lt;Class&lt;?&gt;&gt;(); myResources.add(GraphConfig.class); return myResources; } } </code></pre> <p>My web.xml file:</p> <pre><code>&lt;servlet&gt; &lt;servlet-name&gt;jersey-servlet&lt;/servlet-name&gt; &lt;servlet-class&gt;pl.com.softnet.rest.RestConfigr&lt;/servlet-class&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;jersey-servlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; </code></pre>
1
How to add an image to a C++ project in Xcode
<p>I would like to add an image to my C++ project in Xcode so that I can read that image and do something with it. How do I include the image into my project?</p> <p><a href="https://i.stack.imgur.com/jrY8g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jrY8g.png" alt="enter image description here" /></a></p> <p>tried copy pasting both into my project and into the folder with my c++ source.</p>
1
Error in using Non Linear SVM in Scikit-Learn
<p>I have a code to try to use Non Linear SVM (RBF kernel).</p> <pre><code>raw_data1 = open("/Users/prateek/Desktop/Programs/ML/Dataset.csv") raw_data2 = open("/Users/prateek/Desktop/Programs/ML/Result.csv") dataset1 = np.loadtxt(raw_data1,delimiter=",") result1 = np.loadtxt(raw_data2,delimiter=",") clf = svm.NuSVC(kernel='rbf') clf.fit(dataset1,result1) </code></pre> <p>However, when I try to fit, I get the error</p> <pre><code>Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/Users/prateek/Desktop/Programs/ML/lib/python2.7/site-packages/sklearn/svm/base.py", line 193, in fit fit(X, y, sample_weight, solver_type, kernel, random_seed=seed) File "/Users/prateek/Desktop/Programs/ML/lib/python2.7/site-packages/sklearn/svm/base.py", line 251, in _dense_fit max_iter=self.max_iter, random_seed=random_seed) File "sklearn/svm/libsvm.pyx", line 187, in sklearn.svm.libsvm.fit (sklearn/svm/libsvm.c:2098) ValueError: specified nu is infeasible </code></pre> <p><a href="http://1drv.ms/1VTOsJF" rel="nofollow">Link for Results.csv</a></p> <p><a href="http://1drv.ms/1Ku80Un" rel="nofollow">Link for dataset</a></p> <p>What is the reason for such an error?</p>
1
Android Camera two preview from single camera
<p>I want to build application android about camera two preview from a single camera <a href="http://i.stack.imgur.com/sQHtb.png" rel="nofollow">enter image description here</a></p> <p>I tried build app,I using SurfaceView in Android Studio but I have problem, <a href="http://i.stack.imgur.com/fkROB.png" rel="nofollow">enter image description here</a></p> <p>I want example code, Can you help me please? Thank you so much.</p> <hr> <p>I tried app. </p> <p>AndroidSurfaceviewExample.java <div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>package th.in.cybernoi.cardboardview; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import android.app.Activity; import android.content.Context; import android.content.pm.PackageManager; import android.hardware.Camera; import android.hardware.Camera.PictureCallback; import android.hardware.Camera.CameraInfo; import android.hardware.Camera.ShutterCallback; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.view.WindowManager; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; public class AndroidSurfaceviewExample extends Activity implements SurfaceHolder.Callback { TextView testView; Camera camera; SurfaceView surfaceView; SurfaceHolder surfaceHolder; PictureCallback rawCallback; ShutterCallback shutterCallback; PictureCallback jpegCallback; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); surfaceView = (SurfaceView) findViewById(R.id.surfaceView); surfaceHolder = surfaceView.getHolder(); // Install a SurfaceHolder.Callback so we get notified when the // underlying surface is created and destroyed. surfaceHolder.addCallback(this); // deprecated setting, but required on Android versions prior to 3.0 surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); jpegCallback = new PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) { FileOutputStream outStream = null; try { outStream = new FileOutputStream(String.format("/sdcard/%d.jpg", System.currentTimeMillis())); outStream.write(data); outStream.close(); Log.d("Log", "onPictureTaken - wrote bytes: " + data.length); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { } Toast.makeText(getApplicationContext(), "Picture Saved", 2000).show(); refreshCamera(); } }; } //Surfacrview public void captureImage(View v) throws IOException { //take the picture camera.takePicture(null, null, jpegCallback); } public void refreshCamera() { if (surfaceHolder.getSurface() == null) { // preview surface does not exist return; } // stop preview before making changes try { camera.stopPreview(); } catch (Exception e) { // ignore: tried to stop a non-existent preview } // set preview size and make any resize, rotate or // reformatting changes here // start preview with new settings try { camera.setPreviewDisplay(surfaceHolder); camera.startPreview(); } catch (Exception e) { } } public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { // Now that the size is known, set up the camera parameters and begin // the preview. refreshCamera(); } public void surfaceCreated(SurfaceHolder holder) { try { // open the camera camera = Camera.open(); } catch (RuntimeException e) { // check for exceptions System.err.println(e); return; } Camera.Parameters param; param = camera.getParameters(); // modify parameter param.setPreviewSize(352, 288); camera.setParameters(param); try { // The Surface has been created, now tell the camera where to draw // the preview. camera.setPreviewDisplay(surfaceHolder); camera.startPreview(); } catch (Exception e) { // check for exceptions System.err.println(e); return; } } public void surfaceDestroyed(SurfaceHolder holder) { // stop preview and release camera camera.stopPreview(); camera.release(); camera = null; } }</code></pre> </div> </div> </p> <p>activity_main.xml</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" tools:context="th.in.cybernoi.cardboardview.MainActivity"&gt; &lt;SurfaceView android:id="@+id/surfaceView" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" /&gt; &lt;SurfaceView android:id="@+id/surfaceView" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" /&gt; &lt;/LinearLayout&gt;</code></pre> </div> </div> </p> <hr> <p>Update Edit code Now :9/02/16</p> <ol> <li>edit to AndroidSurfaceviewExample.java <ul> <li>add public void onPreviewFrame() </li> </ul></li> </ol> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code> public class AndroidSurfaceviewExample extends Activity implements SurfaceHolder.Callback { TextView testView; Camera camera; SurfaceHolder camera01; SurfaceHolder camera02; SurfaceView surfaceViewLeft; SurfaceHolder surfaceHolderLeft; SurfaceView surfaceViewRight; SurfaceHolder surfaceHolderRight; PictureCallback rawCallback; ShutterCallback shutterCallback; PictureCallback jpegCallback; /** * ATTENTION: This was auto-generated to implement the App Indexing API. * See https://g.co/AppIndexing/AndroidStudio for more information. */ private GoogleApiClient client; /** * Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); surfaceViewLeft = (SurfaceView) findViewById(R.id.surfaceViewLeft); surfaceHolderLeft = surfaceViewLeft.getHolder(); surfaceViewRight = (SurfaceView) findViewById(R.id.surfaceViewRight); surfaceHolderRight = surfaceViewRight.getHolder(); // Install a SurfaceHolder.Callback so we get notified when the // underlying surface is created and destroyed. surfaceHolderLeft.addCallback(this); surfaceHolderRight.addCallback(this); // deprecated setting, but required on Android versions prior to 3.0 surfaceHolderLeft.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); surfaceHolderRight.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); /* jpegCallback = new PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) { FileOutputStream outStream = null; try { outStream = new FileOutputStream(String.format("/sdcard/%d.jpg", System.currentTimeMillis())); outStream.write(data); outStream.close(); Log.d("Log", "onPictureTaken - wrote bytes: " + data.length); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { } Toast.makeText(getApplicationContext(), "Picture Saved", 2000).show(); refreshCamera(); } }; */ // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); } //Surfacrview public void refreshCamera() { if (surfaceHolderLeft.getSurface() == null) { // preview surface does not exist return; } // stop preview before making changes try { camera.stopPreview(); } catch (Exception e) { // ignore: tried to stop a non-existent preview } // set preview size and make any resize, rotate or // reformatting changes here // start preview with new settings try { camera.setPreviewDisplay(surfaceHolderLeft); camera.startPreview(); } catch (Exception e) { } } public void onPreviewFrame() { if (surfaceHolderRight.getSurface() == null) { // preview surface does not exist return; } // stop preview before making changes try { camera.stopPreview(); } catch (Exception e) { // ignore: tried to stop a non-existent preview } // set preview size and make any resize, rotate or // reformatting changes here // start preview with new settings try { surfaceHolderLeft.lockCanvas(); camera.setPreviewDisplay(surfaceHolderRight); camera.setPreviewCallback((Camera.PreviewCallback) surfaceHolderLeft); camera.startPreview(); } catch (Exception e) { } } public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { // Now that the size is known, set up the camera parameters and begin // the preview. refreshCamera(); onPreviewFrame(); } public void surfaceCreated(SurfaceHolder holder) { try { // open the camera camera = Camera.open(); } catch (RuntimeException e) { // check for exceptions System.err.println(e); return; } Camera.Parameters param; param = camera.getParameters(); // modify parameter param.setPreviewSize(352, 288); camera.setParameters(param); try { // The Surface has been created, now tell the camera where to draw // the preview. camera.setPreviewDisplay(surfaceHolderLeft); camera.startPreview(); } catch (Exception e) { // check for exceptions System.err.println(e); return; } } public void surfaceDestroyed(SurfaceHolder holder) { // stop preview and release camera camera.stopPreview(); camera.release(); camera = null; } @Override public void onStart() { super.onStart(); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. client.connect(); Action viewAction = Action.newAction( Action.TYPE_VIEW, // TODO: choose an action type. "AndroidSurfaceviewExample Page", // TODO: Define a title for the content shown. // TODO: If you have web page content that matches this app activity's content, // make sure this auto-generated web page URL is correct. // Otherwise, set the URL to null. Uri.parse("http://host/path"), // TODO: Make sure this auto-generated app deep link URI is correct. Uri.parse("android-app://th.in.cybernoi.cardboardview/http/host/path") ); AppIndex.AppIndexApi.start(client, viewAction); } @Override public void onStop() { super.onStop(); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. Action viewAction = Action.newAction( Action.TYPE_VIEW, // TODO: choose an action type. "AndroidSurfaceviewExample Page", // TODO: Define a title for the content shown. // TODO: If you have web page content that matches this app activity's content, // make sure this auto-generated web page URL is correct. // Otherwise, set the URL to null. Uri.parse("http://host/path"), // TODO: Make sure this auto-generated app deep link URI is correct. Uri.parse("android-app://th.in.cybernoi.cardboardview/http/host/path") ); AppIndex.AppIndexApi.end(client, viewAction); client.disconnect(); } }</code></pre> </div> </div> </p>
1
Access denied to SSH server running in raspberry pi
<p>I am trying to do ssh connection from Ubuntu machine to a pi. I am getting the following messages Command:</p> <pre><code>ssh -vv PI_ipaddress -l pi </code></pre> <p>Screen output:</p> <pre><code>OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 19 Oct 2007 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug2: ssh_connect: needpriv 0 debug1: Connecting to 10.218.96.209 [10.218.96.209] port 22. debug1: Connection established. debug1: identity file /home/hadoop-user/.ssh/identity type -1 debug2: key_type_from_name: unknown key type '-----BEGIN' debug2: key_type_from_name: unknown key type '-----END' debug1: identity file /home/hadoop-user/.ssh/id_rsa type 1 debug2: key_type_from_name: unknown key type '-----BEGIN' debug2: key_type_from_name: unknown key type '-----END' debug1: identity file /home/hadoop-user/.ssh/id_dsa type 2 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-4+deb7u2 debug1: match: OpenSSH_6.0p1 Debian-4+deb7u2 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1.2 debug2: fd 3 setting O_NONBLOCK debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 debug2: kex_parse_kexinit: ssh-rsa,ssh-dss debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,[email protected],zlib debug2: kex_parse_kexinit: none,[email protected],zlib debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug2: kex_parse_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 debug2: kex_parse_kexinit: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256 debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,[email protected] debug2: kex_parse_kexinit: none,[email protected] debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug2: mac_setup: found hmac-md5 debug1: kex: server-&gt;client aes128-cbc hmac-md5 none debug2: mac_setup: found hmac-md5 debug1: kex: client-&gt;server aes128-cbc hmac-md5 none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024&lt;1024&lt;8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug2: dh_gen_key: priv key bits set: 141/256 debug2: bits set: 509/1024 debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Host '10.218.96.209' is known and matches the RSA host key. debug1: Found key in /home/hadoop-user/.ssh/known_hosts:16 debug2: bits set: 525/1024 debug1: ssh_rsa_verify: signature correct debug2: kex_derive_keys debug2: set_newkeys: mode 1 debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug2: set_newkeys: mode 0 debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug2: key: /home/hadoop-user/.ssh/identity ((nil)) debug2: key: /home/hadoop-user/.ssh/id_rsa (0xb7f1e598) debug2: key: /home/hadoop-user/.ssh/id_dsa (0xb7f1e5b0) debug1: Authentications that can continue: publickey,password debug1: Next authentication method: publickey debug1: Trying private key: /home/hadoop-user/.ssh/identity debug1: Offering public key: /home/hadoop-user/.ssh/id_rsa debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,password debug1: Offering public key: /home/hadoop-user/.ssh/id_dsa debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,password debug2: we did not send a packet, disable method debug1: Next authentication method: password [email protected]'s password: debug2: we sent a password packet, wait for reply debug1: Authentications that can continue: publickey,password Permission denied, please try again. [email protected]'s password: debug2: we sent a password packet, wait for reply debug1: Authentications that can continue: publickey,password Permission denied, please try again. [email protected]'s password: </code></pre> <p>Note:</p> <ol> <li>If I use ssh in my pi, it works. But from other systems, I am unable to access. </li> <li>The password I entered is correct. No issues there.</li> <li>I reinstalled ssh in pi, still it does not work. </li> <li>I tried disabling GSSAPI from a windows machine(just cross-checking).Still no connection</li> <li>I googled the issue and I could not arrive at a solution</li> <li>Ping works from </li> </ol> <p>any system to the pi. </p> <p>Any help is appreciated. </p>
1
Thread Safety of StringBuilder in Parallel.For
<p>I have created a struct, say <code>AStruct</code>, and override its <code>ToString()</code> method. Then I have written a parallel for to return some <code>AStruct</code> and put them in a list so I can use a <code>StreamWriter</code> to output them, like</p> <pre><code>StreamWriter sw = new StreamWriter(@"ABC.txt"); StringBuilder sb = new StringBuilder(); List&lt;AStruct&gt; AList = new List&lt;AStruct&gt;(); Parallel.For(0,10,i =&gt; // generate 10 AStruct(s) { AList.Add(DoSomethingThatReturnsAStruct); }); for(int i =0; i&lt; AList.Count();i++) //put in a StringBuilder { sb.AppendLine(AList[i].ToString()); } sw.Write(sb.ToString()); sw.Close(); </code></pre> <p>The problem is the output file only print 7/8 lines of AList, while AList actually got all the 10 elements. I wonder does this relate to thread-safety of StringBuilder. Could someone explain why not all lines are output?</p>
1
how to reset std::condition_variable
<p>I am trying to use condition variable to trigger a second thread to do some work after a certain number of buffers are in a deque. </p> <ul> <li>main() is reading ADC data in a tight and time sensitive loop</li> <li>main() adds the buffer to a deque (that is processed by a thread pool manager)</li> <li>the deque depth is variable so a test in main() for depth >= 4 and then calling notify_one is not possible (ie: during heavy processing times, the depth of the deque could be as much as 200 or 300 buffers or as little as 4 during light processing)</li> <li>thrd() never needs to signal main()</li> </ul> <p>My problem is that in thrd(), after getting the signal and buffers &lt; 4, it cycles back through the while loop and immediately gets the condition again. Is there a way to reset the cv? </p> <pre><code>deque&lt;int&gt; vbufs; std::mutex thrdLock; void thrd() { while (true) { cout &lt;&lt; "thrd() waiting for lock\n"; std::unique_lock &lt; std::mutex &gt; lock(thrdLock); cout &lt;&lt; "thrd() waiting for condition\n"; cv.wait(lock, []{ return (vbufs.size() &gt; 0); }); thrdLock.unlock(); cout &lt;&lt; "thrd() condition set\n"; if (vbufs.size() &gt;= 4) { // pretend to do something with 4 buffers and remove them std::lock_guard &lt; std::mutex &gt; lock(thrdLock); vbufs.pop_front(); vbufs.pop_front(); vbufs.pop_front(); vbufs.pop_front(); cout &lt;&lt; "thrd() reducing buffers:" &lt;&lt; vbufs.size() &lt;&lt; endl; } } } int main(int argc, char* argv[]) { std::thread t1(thrd); int tctr = 0; while (true) { usleep(1000); { cout &lt;&lt; "main() waiting for lock\n"; std::lock_guard &lt; std::mutex &gt; lock(thrdLock); vbufs.push_back(++tctr); cout &lt;&lt; "main() incremented buffers:" &lt;&lt; vbufs.size() &lt;&lt; endl; } cv.notify_one(); } return 0; } </code></pre>
1
Error:(50, 28) No resource found that matches the given name (at 'value' with value '@string/google_maps_key')
<p>I'm making an Android program using Android Studio. After open Android Studio and Gradle process finished, I got</p> <blockquote> <p>Error:(50, 28) No resource found that matches the given name (at 'value' with value '@string/google_maps_key')".</p> </blockquote> <p>What is happening? This is the first time I got this error.</p>
1
Symfony3 error Namespace does not contain any mapped entities
<p>I tried generate getters and setters in Symfony 3.0.1</p> <p>when i run command </p> <pre><code>php bin/console doctrine:generate:entities VendorName/MyBundle/EntityName </code></pre> <p>i have error</p> <pre><code>Namespace "VendorName\MyBundle\EntityName" does not contain any mapped entities. </code></pre> <p><strong>where is the mistake?</strong></p> <p><strong>Edit-1:</strong> First generate entity with YAML format</p> <p><strong>Edit-2:</strong> I tried generate getters and setters for vendor bundle</p> <p>Also i try with command <strong>php bin/console doctrine:generate:entities VendorNameMyBundle:EntityName</strong> and have another error: </p> <pre><code>Can't find base path for "VendorName\MyBundle\Entity\EntityName" (path: "/home/site/vendor/vendorname/mybundle/Entity", destination: "/home/site/vendor/vendorname/mybundle/Entity"). </code></pre>
1
HTTP 500 Error on php document IIS 8 and PHP 7.0.2
<p>I'm trying to migrate my LAMP application to Windows/IIS. I have a Windows 2012 R2 server. I'm following the instructions at <a href="https://technet.microsoft.com/en-us/library/hh994592.aspx" rel="nofollow">https://technet.microsoft.com/en-us/library/hh994592.aspx</a> (modified slightly: I used add-windowsfeature Web-Server -includeAllSubFeature to install IIS +CGI). I have the vc++ 2015 redist installed (both x86 and x64). PHP 7.0.2 is installed at d:\php. IIS Module Handler for php is configured: </p> <pre><code>name : PHP_via_FastCGI path : *.php verb : * modules : FastCgiModule scriptProcessor : D:\php\php-cgi.exe resourceType : Either requireAccess : Script </code></pre> <p>d:\php is in the PATH environment variable. My php.ini settings are the php.ini-development settings with these changes:</p> <ul> <li>extension_dir = "ext"</li> <li>cgi.force_redirect = 0</li> <li>fastcgi.impersonate = 1</li> <li>fastcgi.logging = 0</li> <li>extension=php_ curl.dll</li> <li>log_errors = On</li> <li>error_log = syslog</li> </ul> <p>The above configuration works on a Windows 7 desktop and on a 2012 R2 server NOT joined to the corporate domain, but on two 2012 R2 servers in the domain I get a 500 Internal Server error when trying to launch <a href="http://localhost/test.php" rel="nofollow">http://localhost/test.php</a>.</p> <p>c:\inetpub\wwwroot\test.php contains:</p> <pre><code>&lt;?php phpinfo(); ?&gt; </code></pre> <p>I'm not seeing any error information in the Windows Event log.</p> <p>Running "php c:\inetpub\wwwroot\test.php" in the cmd window gives me the expected phpinfo.</p> <p>I have checked the NTFS permissions on the d:\php folder and the c:\inetpub\wwwroot folder. They are too many to list, but SYSTEM has full control on both folders and the WWWPublishing service is running as Local System.</p> <p>Any ideas of what to look for to find out why this isn't working?</p>
1
How to assign an image from URL to NSData by swift?
<p>I am new to swift.</p> <p>I have one code. It encode a local image logo.png to NSData.</p> <pre><code>let testImage = NSData(contentsOfFile: NSBundle.mainBundle().pathForResource("logo", ofType: "png")!) </code></pre> <p>How to encode an image from a URL to NSData? </p>
1
How to start minecraft 1.8.9 from Command Prompt (Windows)
<p>I came up with this command so far:</p> <pre><code>java -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx1G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M -Djava.library.path=C:\Users\root\AppData\Roaming\.minecraft\versions\1.8.9\1.8.9-natives -cp C:\Users\root\AppData\Roaming\.minecraft\libraries\oshi-project\oshi-core\1.1\oshi-core-1.1.jar net.minecraft.client.main.Main --username Stefan15ist --version, 1.8.9 --gameDir C:\Users\root\AppData\Roaming\.minecraft --assetsDir C:\Users\root\AppData\Roaming\.minecraft\assets --assetIndex 1.8 --uuid 00000000-0000-0000-0000-000000000000 --accessToken --userProperties --userType legacy </code></pre> <p>but when i run it, I get the following error:</p> <pre><code>Error: Could not find or load main class net.minecraft.client.main.Main </code></pre> <p>any help is appreciated.</p>
1
Celery: how to limit number of tasks in queue and stop feeding when full?
<p>I am very new to Celery and here is the question I have:</p> <p>Suppose I have a script that is constantly supposed to fetch new data from DB and send it to workers using Celery.</p> <p>tasks.py</p> <pre><code># Celery Task from celery import Celery app = Celery('tasks', broker='amqp://guest@localhost//') @app.task def process_data(x): # Do something with x pass </code></pre> <p>fetch_db.py</p> <pre><code># Fetch new data from DB and dispatch to workers. from tasks import process_data while True: # Run DB query here to fetch new data from DB fetched_data process_data.delay(fetched_data) sleep(30); </code></pre> <p>Here is my concern: the data is being fetched every 30 seconds. process_data() function could take much longer and depending on the amount of workers (especially if too few) the queue might get throttled as I understand. </p> <ol> <li>I cannot increase number of workers.</li> <li>I can modify the code to refrain from feeding the queue when it is full.</li> </ol> <p>The question is how do I set queue size and how do I know it is full? In general, how to deal with this situation?</p>
1
Codeigniter call Function in Controller without index.php
<p>I know there are so many posts concering that problem. I tried everything, but without success.</p> <p>I use xampp v3.2.2 on my windows 10 machine. In my htdocs I got a project called mysite. In there I have codeigniter 3.0.3. </p> <p><strong>config.php</strong></p> <pre><code>$config['base_url'] = 'http://localhost/mysite/'; $config['index_page'] = ''; </code></pre> <p><strong>routes.php</strong></p> <pre><code>$route['default_controller'] = 'CI_home'; </code></pre> <p>Controller CI_home.php:</p> <pre><code>class CI_home extends CI_Controller{ function __construct() { parent::__construct(); } public function index($lang = ''){ $this-&gt;load-&gt;helper('url'); $this-&gt;load-&gt;helper('language'); $this-&gt;lang-&gt;load($lang, $lang); $this-&gt;load-&gt;view('view_home'); } } </code></pre> <p>When I call <code>http://localhost/mysite</code>, the page is shown correctly. </p> <p>The problem is, when I try to <code>http://localhost/mysite/en</code> or <code>http://localhost/mysite/index/en</code> I received a 404 from xampp. </p> <p>But if I try <code>http://localhost/mysite/index.php/CI_home/index/en</code> it works fine. </p> <p>What I am doing wrong? How can I remove the "CI_home/index"?</p> <p><code>http://localhost/mysite/.htaccess:</code></p> <p><strong>.htaccess</strong></p> <pre><code>RewriteEngine On RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA] </code></pre> <p>I already checked if the mod_rewrite is enabled.</p> <p>Please help me! </p> <p>Thanks in advance, yab86</p>
1