pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
39,808,850 | 0 | <p>Could be your result is already JSON parsed the </p> <pre><code> function getLocation(){ var name = $("#username").val(); console.log('getLocation()'); if(name != ''){ $.ajax({ type: 'GET', url: '../../' + name, async: true, success:function(data){ var marker = new L.marker(data.location); marker.addTo(map); $("#username").val(''); }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert('Not found'); } }); } } </code></pre> <p>or if you obtain an array </p> <pre><code> function getLocation(){ var name = $("#username").val(); console.log('getLocation()'); if(name != ''){ $.ajax({ type: 'GET', url: '../../' + name, async: true, success:function(data){ var marker = new L.marker(data[0].location); marker.addTo(map); $("#username").val(''); }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert('Not found'); } }); } </code></pre> |
28,428,035 | 0 | Populate subdocuments in mongoose <p>I have this document:</p> <pre><code>[ { _id: "54d278b2b6d57eee9f2c6d02", title: "Piping", mainCategories: [ { title: "Shut valves", subCategories: [ { title: "Ball valve", userCodeSyntax: "AV2", typeComponents: [ "54d278b2b6d57eee9f2c6d00", "54d278b2b6d57eee9f2c6d01" ] } ] } ] } ] </code></pre> <p>It's a category schema where typeComponents contains a list with products in that category.</p> <p>My model:</p> <pre><code>var disciplineSchema = new Schema({ title: {type:String, required:true}, project:{ type: Schema.ObjectId, ref: 'Project' }, mainCategories:[ { title: {type:String, required: true}, subCategories:[ { title: {type:String, required: true}, userCodeSyntax: {type:String, required: true}, externalCode:String, typeComponents:[ {type: Schema.ObjectId, ref: 'TypeComponent'}] } ] } ] }); </code></pre> <p>Is it possible to populate typeComponents?</p> <p>I tried this:</p> <pre><code>mongoose.model('Discipline').find() .exec(function(err, disciplines){ var options = { path: 'mainCategories.subCategories', model: 'TypeComponent' }; mongoose.model('Discipline').populate(disciplines, options, function (err, res) { callback.status(200).send(res) }); }); </code></pre> |
16,627,831 | 0 | <p>As in the comment: it is not <em>UTF8</em>, it is <em>WINDOWS-1256</em> encoding, so you can repair it on Linux using <code>iconv</code> command for file <code>test</code>: </p> <pre><code>jh@jh-aspire:4804~$ iconv -fwindows-1256 -tutf8 test هاـالحجرنالرفاعيمني </code></pre> <p>(I have no idea what it means as I don't know Arabic)</p> |
26,701,215 | 0 | Download from gitHub <p>How I can download this file from GitHub?</p> <p><a href="https://github.com/TorgeirH90/Programming/tree/master/C%23/Paratroopers%20Mono/Paratroopers%20Mono" rel="nofollow">https://github.com/TorgeirH90/Programming/tree/master/C%23/Paratroopers%20Mono/Paratroopers%20Mono</a></p> |
24,412,431 | 0 | Side-effect of Perl's print function <p>I'm wondering why/how <code>print</code> in Perl can have a side-effect.</p> <pre><code>use Scalar::Util qw/looks_like_number/; my @A = (5, '2', 'aaa', 1, 'aab'); my @a = map { looks_like_number($_) } @A; print "1) @a\n"; # prints "4352 1 0 4352 0" print "A print with a side-effect: @A\n"; @a = map { looks_like_number($_) } @A; print "2) @a\n"; # prints "1 1 0 1 0" </code></pre> <p>In this example, <code>looks_like_number</code> returns <code>4352 1 0 4352 0</code> before the print, and <code>1 1 0 1 0</code> after the print.</p> <p>What does <code>print</code> do to these values to affect how they're interpreted by <code>looks_like_number</code>?</p> |
41,003,579 | 0 | <p>The most probable reason I can think of is that since <code>__dirname</code> never ends with a trailing slash your path will become something like <code>/path/to/projectpublic</code> instead of <code>/path/to/project/public</code>. To make sure your path is correctly formatted use <a href="https://nodejs.org/api/path.html#path_path_join_paths" rel="nofollow noreferrer" title="path.join">path.join</a>. E.g:</p> <pre><code>app.use(express.static(path.join(__dirname, 'public'))) </code></pre> |
28,464,823 | 0 | <p>This is a little hacky, but it works: Give the right container a margin-top of the height of the left container minus the height of the right container (in this case, 50px). Then give the left container a negative margin-bottom of the same amount (-50px). Here is it working: <a href="http://jsfiddle.net/zdL60bLu/9/" rel="nofollow">http://jsfiddle.net/zdL60bLu/9/</a></p> <p>Code added:</p> <pre><code>#left { margin-bottom: -50px; } #right { margin-top: 50px; } </code></pre> |
12,253,476 | 0 | <p>WebDAV connection is your way to go if you just want to use Dreamweaver and fill in the Host, username and password. However WebDav works perfectly fine on a Linux apache environment, But installing it on IIS is a bit harder.</p> <p><img src="https://i.stack.imgur.com/Fyjus.png" alt="WebDAV"></p> <p><em>Take a look at <a href="http://learn.iis.net/page.aspx/350/installing-and-configuring-webdav-on-iis/" rel="nofollow noreferrer">this website</a> explaining step by step how to install and configure WebDAV correctly on IIS before using it.</em></p> |
37,436,113 | 0 | <p>It may be because there might be one more button with same property , so try to find element uniquely then try. Ex: Two button having same attributes at that time webdriver will fail so user in case of multiple element having same property try to find element uniquely with relative xpath</p> |
32,568,347 | 0 | <p>I think this package is broken... i don't see an <a href="http://docs.meteor.com/#/full/pack_export" rel="nofollow">api.export</a> of the Soap object for you to use in <a href="https://github.com/zardak/meteor-soap/blob/master/package.js" rel="nofollow">package.js</a>. Maybe you could submit a fix to the git repo and get the package updated.</p> |
36,629,637 | 0 | how to fetch records equal to pageSize while using queryForCursor in SolrTemplate <p>I want to fetch records from solr using cursors as I have large resultset size. I m using SolrTemplate.queryForCursor() method by passing query object to this. But the resultCursor which is of type Cursor has all data in it. I want to stop reading from cursor when my pageSize is hit.</p> <pre><code>Criteria query = new Criteria("UserName").is ("abc"); query.setRows(10); // As i want to have fetch 10 records at a time Cursor<T> resultCusrsor = solrTemplate.queryForCursor(query,Entity.class); while(resultCursor.hasNext() ){ System.out.println( "Result : " + resultCusrsor.next()); } </code></pre> <p>The while loop here keeps printing all records by fetching 10 at a time. If my pagesize is 100, I want to fetch 10 records 10 times using cursor, but how do I stop at 100th record?</p> |
19,026,042 | 0 | <ol> <li>There is no need that an application defines a window handle when using OpenClipboard. So you have to be aware that there are enough chances that you will never get a result.</li> <li>If it is a child window that owns the clipboard you may walk back the stack of windows always using GetParent until there is no longer a parent.</li> </ol> <p>BTW: The function I mention here are the WinApi functions...</p> |
10,796,149 | 0 | <p>You need a reference to your instance of GUI1 in GUI2. So maybe add a private variable <code>private GUI1 firstGUI</code> in your GUI2 class. Then write a setter method <code>public void setGUI1(GUI1 myFirstGUI){ this.firstGUI = myFirstGUI; }</code>.</p> <p>Then you should set the GUI1 variable from the outside with this setter.</p> <p>And then you can call <code>firstGUI.dispose()</code> in your actionPerformed Method for btn2.</p> |
31,429,463 | 0 | <p>Got help from our friends at TI E2E forums on this topic.</p> <p>The reason I was unable to see the Configure and Associate menu options was due to the selected perspective. Code Composer 5 uses TI's default CCS Edit perspective which hides the expected menu options. If you change to the default Eclipse C/C++ perspective then the menu option shows up and configuration of the project to use SonarQube can be completed.</p> |
19,323,654 | 0 | Why does my alert dialog not appear? <p>Can sombody please help me? When I click on the button nothing happens. I'm very new to android-programming so please answer as i can understand.</p> <p>(Don't wonder about my variables)</p> <p>Thank you</p> <pre><code>@Override public void onClick(View v) { Button preis = (Button) findViewById(R.id.essenpreis); preis.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { // Creating alert Dialog with one Button AlertDialog.Builder alertDialog = new AlertDialog.Builder(options.this); // Setting Dialog Title alertDialog.setTitle("Essenspreis"); // Setting Dialog Message alertDialog.setMessage("Neuen Preis eintragen:"); // Setting Icon to Dialog // alertDialog.setIcon(R.drawable.tick); // Setting OK Button alertDialog .setPositiveButton("YES", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,int which) { // Write your code here to execute after dialog closed Toast.makeText(getApplicationContext(),"Preis geändert!", Toast.LENGTH_SHORT).show(); } }); // Showing Alert Message alertDialog.show(); } }); } } </code></pre> |
357,351 | 0 | <p>A try/catch block like this...</p> <pre><code>BEGIN TRY -- Your Code Goes Here -- END TRY BEGIN CATCH SELECT ERROR_NUMBER() AS ErrorNumber, ERROR_SEVERITY() AS ErrorSeverity, ERROR_STATE() AS ErrorState, ERROR_PROCEDURE() AS ErrorProcedure, ERROR_LINE() AS ErrorLine, ERROR_MESSAGE() AS ErrorMessage END CATCH </code></pre> <p>...is going to help you locate the problem in your SQL <em>code</em>. If this was in a stored procedure you could also return the parameters (i.e. add a SELECT @RecordID AS [RecordID] to that list in the catch block). Moving forward though, if you are running into problems with the actual data I would encourage you to look at adding foreign keys and other constraints to protect the logical integrity of your database. Ideally at a minimum you cannot put data into the database which will break your stored procedures.</p> <p>EDIT</p> <p>Refering to you're most recent edits, if you put the UPDATE inside a stored procedure and catch the error, then replace your update series with calls to that procedure the remaining updates would continue, and you could return/track/log the error within the SP's catch block however you wished to.</p> |
40,210,616 | 0 | <p>Ok how about this. It's a mashup between reshape and base R.</p> <p>I used your dataset once you posted it. Thanks for providing it.</p> <pre><code>data <- structure(list(Water.Year = structure(1:6, .Label = c("1953-1954", "1954-1955", "1955-1956", "1956-1957", "1957-1958", "1958-1959", "1959-1960", "1960-1961", "1961-1962", "1962-1963", "1963-1964", "1964-1965", "1965-1966", "1966-1967", "1967-1968", "1968-1969", "1969-1970", "1970-1971", "1971-1972", "1972-1973", "1973-1974", "1974-1975", "1975-1976", "1976-1977", "1977-1978", "1978-1979", "1979-1980", "1980-1981", "1981-1982", "1982-1983", "1983-1984", "1984-1985", "1985-1986", "1986-1987", "1987-1988", "1988-1989", "1989-1990", "1990-1991", "1991-1992", "1992-1993", "1993-1994", "1994-1995", "1995-1996", "1996-1997", "1997-1998", "1998-1999", "1999-2000", "2000-2001"), class = "factor"), May = c(55.55, 23.49, 9.87, 18.03, 17.46, 11.37), Jun = c(43.62, 81.35, 51.59, 28.61, 15.14, 29.48), Jul = c(30.46, 46.71, 55.36, 24.36, 20.09, 19.48), Ago = c(26.17, 29.33, 63.03, 22.01, 16.97, 16.86), Set = c(26.76, 67.83, 154.08, 28.51, 27.24, 21.01), Oct = c(41.74, 133.3, 98.15, 53.72, 35.78, 19.78), Nov = c(19.92, 37.62, 104.06, 115.78, 20.35, 18.69), Dic = c(41.25, 30.16, 32.85, 32.04, 22, 18.86), Ene = c(28.77, 21.07, 22.89, 25.44, 13.27, 14.89), Feb = c(20.96, 19.38, 17.3, 14.53, 10.37, 10.4), Mar = c(12.47, 13.87, 15.68, 10.78, 8.77, 8.79), Abr = c(10.51, 10.63, 10.88, 9.33, 7.69, 8.99)), .Names = c("Water.Year", "May", "Jun", "Jul", "Ago", "Set", "Oct", "Nov", "Dic", "Ene", "Feb", "Mar", "Abr"), row.names = c(NA, 6L), class = "data.frame") </code></pre> <p>I decided to use the year information you had from before and just add in calendar year based on that. Since we know May-Dec is Year 1, and Jan-Apr is Year 2. Maybe a bit convoluted but it gets the job done.</p> <pre><code>df = separate(data, Water.Year, c("year1","year2")) library(reshape2) fixDF<-melt(df) fixDF$CalendarYear<-rep(NA,nrow(fixDF)) fixDF$CalendarYear[min(which(fixDF$variable=="May")):max(which(fixDF$variable=="Dic"))]<-df$year1 fixDF$CalendarYear[min(which(fixDF$variable=="Ene")):max(which(fixDF$variable=="Abr"))]<-df$year2 fixDF<-fixDF[,3:5] colnames(fixDF)<-c("Month","Flow.Measurement", "Calendar.Year") </code></pre> |
1,425,492 | 0 | Help with setting up a Database <p>My site is going to have many products available, but they'll be categorised into completely different sites (domains).</p> <p>My question is, am I better off lumping all products into one database and using an ID to distinguish between the sites, or should I set up a table and /or DB per site?</p> <p>Here are my thoughts</p> <p><strong>SEPARATE DATABASES</strong></p> <ul> <li>Easier to read from a backend</li> <li>Categorised better</li> <li>Makes backups more difficult</li> <li>If I need to make a change to the schema, it will need to be pushed out to all databases</li> </ul> <p><strong>SAME DATABASES</strong></p> <ul> <li>All in one place</li> <li>Could get unwieldy</li> <li>One database will have a massive file size and lookups could suffer</li> </ul> <p>Can someone please offer me some advice on which way is best and why?</p> |
31,417,031 | 0 | <p>As shown by others awk,sed or paste are the best ways of doing this, but.. Lets do some more!</p> <p>bash loop:</p> <pre><code>cat file | while read line ; do echo "$line;$line"; done </code></pre> <p>perl:</p> <pre><code>perl -pe 's/(.*)/$1;$1/' file </code></pre> <p>ruby:</p> <pre><code>ruby -ne 'puts $_.chomp + ";" + $_' < file </code></pre> <p>python:</p> <pre><code>python -c "import sys;[sys.stdout.write(line.rstrip() + ';' + line) for line in sys.stdin]" < file </code></pre> <p>And now I've run out of things</p> |
5,740,983 | 0 | <p>What about setuping a private branch, working on it, hijacking there files and then merging your private branch on the main branch?</p> |
9,853,197 | 0 | JDBC batch query for high performance <p>I want to do batch query DB for high performance, example sql to query based on different customer_id:</p> <pre><code>select order_id, cost from customer c join order o using(id) where c.id = ... order by </code></pre> <p>I'm not sure how to do it using JDBC statement. I know I can use stored procedure for this purpose, but it's much better if I can just write sql in Java app instead of SP. <br /> I'm using DBCP for my Java client and MySQL DB.</p> |
10,797,974 | 0 | <p>the image you want to draw is from a different domain than yours, so a security error is thrown. </p> <p>Please see the following topic for further explainations <a href="http://stackoverflow.com/questions/2390232/why-does-canvas-todataurl-throw-a-security-exception">Why does canvas.toDataURL() throw a security exception?</a></p> |
19,044,216 | 0 | How to add data to the Expandable listview with child having multiple views <p>I referred this tutorial for expandable listview</p> <p><a href="http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/" rel="nofollow">http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/</a></p> <p>My main activity</p> <pre><code> BusActivity extends Activity { ExpandableListAdapter listAdapter; ExpandableListView expListView; List<String> listDataHeader; HashMap<String, List<String>> listDataChild,listDataStart,listDataEnd; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // get the listview expListView = (ExpandableListView) findViewById(R.id.lvExp); // preparing list data prepareListData(); listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild,listDataStart,listDataEnd); // setting list adapter expListView.setAdapter(listAdapter); // Listview Group click listener expListView.setOnGroupClickListener(new OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { // Toast.makeText(getApplicationContext(), // "Group Clicked " + listDataHeader.get(groupPosition), // Toast.LENGTH_SHORT).show(); return false; } }); // Listview Group expanded listener expListView.setOnGroupExpandListener(new OnGroupExpandListener() { @Override public void onGroupExpand(int groupPosition) { Toast.makeText(getApplicationContext(), listDataHeader.get(groupPosition) + " Expanded", Toast.LENGTH_SHORT).show(); } }); // Listview Group collasped listener expListView.setOnGroupCollapseListener(new OnGroupCollapseListener() { @Override public void onGroupCollapse(int groupPosition) { Toast.makeText(getApplicationContext(), listDataHeader.get(groupPosition) + " Collapsed", Toast.LENGTH_SHORT).show(); } }); // Listview on child click listener expListView.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { // TODO Auto-generated method stub Toast.makeText( getApplicationContext(), listDataHeader.get(groupPosition) + " : " + listDataChild.get( listDataHeader.get(groupPosition)).get( childPosition), Toast.LENGTH_SHORT) .show(); return false; } }); } /* * Preparing the list data */ private void prepareListData() { listDataHeader = new ArrayList<String>(); listDataChild = new HashMap<String, List<String>>(); listDataStart = new HashMap<String, List<String>>(); listDataEnd = new HashMap<String, List<String>>(); // Adding child data listDataHeader.add("Volvo"); listDataHeader.add("Deluxe"); listDataHeader.add("Express"); listDataHeader.add("Ordinary"); // Adding child data List<String> volvo = new ArrayList<String>(); volvo.add("The Shawshank Redemption"); volvo.add("The Godfather"); volvo.add("The Godfather: Part II"); volvo.add("Pulp Fiction"); List<String> nowShowing = new ArrayList<String>(); nowShowing.add("The Conjuring"); nowShowing.add("Despicable Me 2"); nowShowing.add("Turbo"); nowShowing.add("Grown Ups 2"); List<String> now = new ArrayList<String>(); now.add("The Conjuring"); now.add("Despicable Me 2"); now.add("Turbo"); now.add("Grown Ups 2"); List<String> comingSoon = new ArrayList<String>(); comingSoon.add("2 Guns"); comingSoon.add("The Smurfs 2"); comingSoon.add("The Spectacular Now"); comingSoon.add("The Canyons"); List<String> comingup = new ArrayList<String>(); comingup.add("2 Guns"); comingup.add("The Smurfs 2"); comingup.add("The Spectacular Now"); comingup.add("The Canyons"); listDataChild.put(listDataHeader.get(0), volvo); // Header, Child data listDataChild.put(listDataHeader.get(1), now); listDataStart.put(listDataHeader.get(0), nowShowing); // Header, Child data listDataStart.put(listDataHeader.get(1), comingup); ); listDataEnd.put(listDataHeader.get(0), volvo); // Header, Child data listDataEnd.put(listDataHeader.get(2), comingSoon); } </code></pre> <p>}</p> <p>My Adapter</p> <pre><code>public class ExpandableListAdapter extends BaseExpandableListAdapter { private Context _context; private List<String> _listDataHeader; // header titles // child data in format of header title, child title private HashMap<String, List<String>> _listDataChild,listStart,listEnd; public ExpandableListAdapter(Context context, List<String> listDataHeader, HashMap<String, List<String>> listChildData,HashMap<String, List<String>> listStart, HashMap<String, List<String>> listEnd) { this._context = context; this._listDataHeader = listDataHeader; System.out.println("Start"+listStart+"Bus"+listChildData+"End"+listEnd); this._listDataChild = listChildData; this.listStart=listStart; this.listEnd=listEnd; } @Override public Object getChild(int groupPosition, int childPosititon) { return this._listDataChild.get(this._listDataHeader.get(groupPosition)) .get(childPosititon); } @Override public long getChildId(int groupPosition, int childPosition) { return childPosition; } @Override public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { final String childText = (String) getChild(groupPosition, childPosition); System.out.println("Child Text"+childText); if (convertView == null) { LayoutInflater infalInflater = (LayoutInflater) this._context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = infalInflater.inflate(R.layout.list_item, null); } TextView txtListBus= (TextView) convertView .findViewById(R.id.txt_busno); if(groupPosition==0) { //txtListBus.setBackgroundColor(Color.parseColor("#FED966")); //txtListBus.setTextColor(Color.parseColor("#A07900")); } else if(groupPosition==1) { txtListBus.setBackgroundColor(Color.parseColor("#FED966")); txtListBus.setTextColor(Color.parseColor("#A07900")); } else if(groupPosition==2) { txtListBus.setBackgroundColor(Color.RED); txtListBus.setTextColor(Color.BLACK); } else { txtListBus.setBackgroundColor(Color.BLUE); txtListBus.setTextColor(Color.WHITE); } txtListBus.setText(childText); TextView txtList= (TextView) convertView .findViewById(R.id.txt_start); if(groupPosition==0) { txtList.setBackgroundColor(Color.parseColor("#FED966")); txtList.setTextColor(Color.parseColor("#A07900")); } else if(groupPosition==1) { txtList.setBackgroundColor(Color.parseColor("#64D8CD")); txtList.setTextColor(Color.parseColor("#067B6F")); } else if(groupPosition==2) { txtList.setBackgroundColor(Color.RED); txtList.setTextColor(Color.BLACK); } else { txtList.setBackgroundColor(Color.BLUE); txtList.setTextColor(Color.WHITE); } txtList.setText(childText); TextView txt= (TextView) convertView .findViewById(R.id.txt_end); if(groupPosition==0) { txt.setBackgroundColor(Color.parseColor("#FED966")); txt.setTextColor(Color.parseColor("#A07900")); } else if(groupPosition==1) { txt.setBackgroundColor(Color.parseColor("#64D8CD")); txt.setTextColor(Color.parseColor("#067B6F")); } else if(groupPosition==2) { txt.setBackgroundColor(Color.RED); txt.setTextColor(Color.BLACK); } else { txt.setBackgroundColor(Color.BLUE); txt.setTextColor(Color.WHITE); } txt.setText(childText); return convertView; } @Override public int getChildrenCount(int groupPosition) { return this._listDataChild.get(this._listDataHeader.get(groupPosition)) .size(); } @Override public Object getGroup(int groupPosition) { return this._listDataHeader.get(groupPosition); } @Override public int getGroupCount() { return this._listDataHeader.size(); } @Override public long getGroupId(int groupPosition) { return groupPosition; } @Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { String headerTitle = (String) getGroup(groupPosition); System.out.println("Group position"+groupPosition); if (convertView == null) { LayoutInflater infalInflater = (LayoutInflater) this._context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = infalInflater.inflate(R.layout.list_group, null); } TextView lblListHeader = (TextView) convertView .findViewById(R.id.ls_head); lblListHeader.setTypeface(null, Typeface.BOLD); lblListHeader.setText(headerTitle); if(groupPosition==0) { lblListHeader.setBackgroundColor(Color.parseColor("#FFD243")); lblListHeader.setTextColor(Color.parseColor("#A07900")); } else if(groupPosition==1) { lblListHeader.setBackgroundColor(Color.parseColor("#00BFAC")); lblListHeader.setTextColor(Color.parseColor("#067B6F")); } else if(groupPosition==2) { lblListHeader.setBackgroundColor(Color.RED); lblListHeader.setTextColor(Color.BLACK); } else { lblListHeader.setBackgroundColor(Color.BLUE); lblListHeader.setTextColor(Color.WHITE); } return convertView; } @Override public boolean hasStableIds() { return false; } @Override public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } </code></pre> <p>}</p> <p>list_item layout </p> <pre><code><?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="55dp" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="55dp" android:background="#fff" android:orientation="horizontal" > <TextView android:id="@+id/txt_start" android:layout_width="130dp" android:layout_height="match_parent" android:text="Hello" android:gravity="right|center_vertical" android:textColor="#000" android:textSize="17dp" /> <LinearLayout android:layout_width="50dp" android:layout_height="55dp" android:background="@drawable/ic_launcher" android:orientation="horizontal" > <TextView android:id="@+id/txt_busno" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textAppearance="?android:attr/textAppearanceLarge" /> </LinearLayout> <TextView android:id="@+id/txt_end" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" android:text="Hello" android:textColor="#000" android:textSize="17dp" /> </LinearLayout> </code></pre> <p></p> <p>list_group remains same as the link</p> <p>In this the child list have only a textview. I want to add an imageview and a textview to the child list. I am able to add this by changing the list_item.xml to contain the views. How can i add data to this child view that has multiple views?</p> |
21,541,069 | 0 | <p>What you are trying to do here is to group a shared DataSource and have it only affect one widget. Furthermore, Kendo UI will return a grouped object when you group it. The Pie chart is not interested in these objects, but rather the count of the items that each of these group objects contains. We just need to get the data in the right format.</p> <p>So you have your original DataSource (which I have extracted since it's shared with another widget). When that DataSource changes, you want to populate a second one - one that you can group without affecting the grid.</p> <pre><code>var ds = new kendo.data.DataSource({ data: [ {Status: 10}, {Status: 20}, {Status: 200}, {Status: 200} ], change: function() { chartData.data(this.data()); } }); </code></pre> <p>The second DataSource (chartData) is grouped, and when it changes, it populates an array, constructing objects that the pie chart can actually understand.</p> <pre><code>var groupedData = []; // populate the grouped data array by grouping this datasource // and then populating an plain array var chartData = new kendo.data.DataSource({ group: { field: 'Status' }, change: function() { groupedData = []; $.each(this.view(), function() { groupedData.push({ field: this.value, value: this.items.length }); }); } }); </code></pre> <p>And then just bind your pie chart to that array</p> <pre><code>$("#status-chart").kendoChart({ dataSource: groupedData, series: [{ type: 'pie', field: 'value', categoryField: 'field' }] }); </code></pre> <p>Working example: <a href="http://jsbin.com/EKuxORA/1/edit">http://jsbin.com/EKuxORA/1/edit</a></p> |
32,373,240 | 0 | <p>I tried to unsubscribe endpoint from topic by following python code (use boto):</p> <pre><code>def _unsubscribe_from_topic(topic_arn, endpoint): conn = connect_to_region('your_region_name','AWS_ACCESS_KEY', 'AWS_SECRET_KEY') r = conn.get_all_subscriptions_by_topic(topic_arn) for i in r.get('ListSubscriptionsByTopicResponse')\ .get('ListSubscriptionsByTopicResult')\ .get('Subscriptions'): if i.get('Endpoint') == endpoint: subscription = i.get('SubscriptionArn') conn.unsubscribe(subscription) return True return False </code></pre> <p>reference: <a href="http://boto.readthedocs.org/en/latest/ref/sns.html" rel="nofollow">http://boto.readthedocs.org/en/latest/ref/sns.html</a></p> |
35,038,315 | 0 | <p>If you want to still break from <code>if</code>, you can use while(true)</p> <p>Ex.</p> <pre><code>$count = 0; if($a==$b){ while(true){ if($b==$c){ $count = $count + 3; break; // By this break you will be going out of while loop and execute remaining code of $count++. } $count = $count + 5; // break; } $count++; } </code></pre> <p>Also you can use switch and default.</p> <pre><code>$count = 0; if($a==$b){ switch(true){ default: if($b==$c){ $count = $count + 3; break; // By this break you will be going out of switch and execute remaining code of $count++. } $count = $count + 5; // } $count++; } </code></pre> |
38,715,869 | 0 | <p><code>getServicelocator()</code> makes error. So it needs alternative way. And extends <code>AbstractTableGateway</code> or <code>ServiceLocatorAwareInterface</code> have errors.</p> <p>Factory implementation will help Controller to get objects.</p> <p>*User sample code will be similar to album.</p> <p>1) factory class ( RegisterControllerFactory.php) * copied function createUser in controller</p> <pre><code>namespace Users\Controller\Factory; use Users\Controller\RegisterController; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; use Zend\ServiceManager\Exception\ServiceNotCreatedException; class RegisterControllerFactory { public function __invoke($serviceLocator) { $sm = $serviceLocator; $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter'); $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet(); $resultSetPrototype->setArrayObjectPrototype(new \Users\Model\User); $tableGateway = new \Zend\Db\TableGateway\TableGateway('user' /* table name */, $dbAdapter, null, $resultSetPrototype); $user = new \Users\Model\User(); $userTable = new \Users\Model\UserTable($tableGateway); $controller = new RegisterController($userTable, $serviceLocator ); return $controller; } } </code></pre> <p>2) controller( RegisterController ) namespace Users\Controller;</p> <pre><code>use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; use Users\Form\RegisterForm; use Users\Form\RegisterFilter; use Users\Model\User; use Users\Model\UserTable; use Zend\ServiceManager\ServiceLocatorInterface; class RegisterController extends AbstractActionController { protected $userTable; protected $serviceManager; public function __construct(UserTable $userTable, ServiceLocatorInterface $serviceManager) { $this->userTable = $userTable; $this->serviceManager = $serviceManager; } public function indexAction() { $form = new RegisterForm(); $viewModel = new ViewModel(array('form' => $form)); return $viewModel; } public function processAction() { if (!$this->request->isPost()) { return $this->redirect()->toRoute(NULL , array( 'controller' => 'register', 'action' => 'index' )); } $post = $this->request->getPost(); $form = new RegisterForm(); $inputFilter = new RegisterFilter(); $form->setInputFilter($inputFilter); $form->setData($post); if (!$form->isValid()) { $model = new ViewModel(array( 'error' => true, 'form' => $form, )); $model->setTemplate('users/register/index'); return $model; } // Create user $this->createUser($form->getData()); return $this->redirect()->toRoute(NULL , array( 'controller' => 'register', 'action' => 'confirm' )); } public function confirmAction() { $viewModel = new ViewModel(); return $viewModel; } protected function createUser(array $data) { /*able to delete or modify */ $sm = $this->serviceManager; $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter'); $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet(); $resultSetPrototype->setArrayObjectPrototype(new \Users\Model\User); $tableGateway = new \Zend\Db\TableGateway\TableGateway('user' /* table name */, $dbAdapter, null, $resultSetPrototype); $user = new User(); $user->exchangeArray($data); $userTable = new UserTable($tableGateway); $userTable->saveUser($user); return true; } } </code></pre> <p>3) module.config.php</p> <pre><code>return array( 'controllers' => array( 'invokables' => array( 'Users\Controller\Index' => 'Users\Controller\IndexController', 'Users\Controller\login' => 'Users\Controller\LoginController', //delete 'Users\Controller\Register' ), 'factories' => array( 'Users\Controller\Register' => 'Users\Controller\Factory\RegisterControllerFactory', ), ), </code></pre> |
3,120,734 | 0 | <p>To the extent that there is a limit on the size of an SQL statement, then <strong>Yes</strong>: you cannot create an SQL statement that joins so many columns that the joining condition does not fit inside the limit on an SQL statement.</p> <p>Otherwise - and in practice - <strong>No</strong>. You will run out of the ability to comprehend your joins before the DBMS runs out of the capacity to handle them.</p> |
8,049,706 | 0 | <p>yes, it's suppose to be:</p> <pre><code>public IDictionary<string, string> loopThroughNotificationCountQueries() { } </code></pre> <p>You can only itterate through objects of <code>IEnumerable<T></code></p> <p>so if for some reason you cannot change <code>loopThroughNotificationCountQueries</code>, cast the object to an <code>IDictionary<string, string></code> first.</p> |
7,045,593 | 0 | <p>Try:</p> <pre><code>$(".blah").find($("input:text")).each(function(){ alert("Value inside "+$(this).attr("name")+" is #### " + this.value); }); </code></pre> |
29,682,187 | 0 | Ruby on Rails find records through last association records <p>User <code>has_many</code> operations. How I can find <code>Users</code> and what is the best way to find where: <code>User.operations.last.exp_date</code> > <code>CurrentDate</code>?</p> |
25,356,528 | 0 | <p>You Should check the .Net Framework version in the Property of the Project.</p> |
34,674,321 | 0 | How can I use ProjectLocker instead of Git in laravel? <p>Is there any setting available in Laravel to use <a href="http://projectlocker.com/" rel="nofollow">ProjectLocker</a> or other repository ?</p> |
491,951 | 0 | <p>Host a Web service that logs the IP address of the requestor. Call the Web service in your application at startup. Location is tied to IP address and you could probably figure it out from there. :)</p> |
2,425,626 | 0 | <p>One possiblitiy is to construct your colours from <a href="http://stackoverflow.com/questions/2942/hsl-in-net">HSL or HSV</a>, keeping the SL/SV part fixed you can divide the entire hue range into the number of pie slices you have, this should ensure they are reasonably visually seperated. different SL/SV values will make the chart vibrant colours or pastels or dark shades etc. </p> |
31,874,331 | 0 | Multiple java versions installed and java was started but returned exit code=13 <p>I am not able to start eclipse on Windows 7. It was working fine yesterday. Here is the screenshot of error when I start eclipse:</p> <p><a href="https://i.stack.imgur.com/kj8hw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kj8hw.jpg" alt="Eclipse error when I start eclipse"></a></p> <p>Java versions from <strong>CMD</strong></p> <p><a href="https://i.stack.imgur.com/873oO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/873oO.jpg" alt="java and javac versions"></a></p> <p>Why it gives different versions for <code>java</code> and <code>javac</code>? </p> <p>My java home is set to Jdk 7 as below:</p> <p><code>JAVA_HOME = C:\Program Files\Java\jdk1.7.0_60</code></p> <p><strong>Note:</strong> I have jdk 8 installed on my machine but I have not set jdk 8 path.</p> <p>This question has been asked couple of times but I am not able to resolve it on my machine so please do not mark it as duplicate.</p> |
2,349,930 | 0 | <p>You don't need to use <code>awk</code> if all you want to do is this. :) <strong>Also, writing to a file as you're reading from it, in the way that you did, will lead to data loss or corruption</strong>, try not to do it.</p> <pre><code>for file in *.php ; do # or, to do this to all php files recursively: # find . -name '*.php' | while read file ; do # make backup copy; do not overwrite backup if backup already exists test -f $file.orig || cp -p $file $file.orig # awk '{... print > NEWFILE}' NEWFILE="$file" "$file.orig" sed -e "s:include('\./:include(':g" "$file.orig" >"$file" done </code></pre> <hr> <p>Just to clarify the data loss aspect: when <code>awk</code> (or <code>sed</code>) start processing a file and you ask them to read the first line, they will actually perform a buffered read, that is, they will read from the filesystem (let's simplify and say "from disk") a block of data as large as their internal read buffer (e.g. 4-65KB) in order to get better performance (by reducing disk I/O.) Assume that the file you're working with is larger than the buffer size. Further reads will continue to come from the buffer until the buffer is exhausted, at which point a second block of data will be loaded from disk into the buffer etc.</p> <p>However, just after you read the first line, i.e. after the first block of data is read from disk into the buffer, your <code>awk</code> script opens <code>FILENAME</code>, the input file itself, for writing <strong>with truncation</strong>, i.e. <strong>the file's size on disk is reset to 0</strong>. At this point all that remains of your original file are the first few kilobytes of data in <code>awk</code>'s memory. <code>Awk</code> will merrily continue to read line after line from the in-memory buffer and produce output until the buffer is exhausted, at which point <code>awk</code> will probably stop and leave you with a 4-65k file.</p> <p>As a side note, if you are actually using awk to expand (e.g. <code>print "PREFIX: " $0</code>), not shrink (<code>gsub(/.../, "")</code>), data, then you'll almost certainly end up with a non-responsive <code>awk</code> and a perpetually growing file. :)</p> |
23,161,405 | 0 | <p>You forgot the curly braces for the else-statement of your "recursive case" ...</p> <p>This does work:</p> <pre><code>private static void combos(String counter) { if (counter.length() == userinput) //base case System.out.println(counter); else { combos(counter + "A"); combos(counter + "B"); combos(counter + "C"); } } </code></pre> |
7,702,596 | 0 | <p>You can try the default favicon location - i.e. place <code>favicon.ico</code> on the root of server (which is normally the ROOT application). In production you will almost always be running as ROOT. But I don't know if browsers will recognize that - if they don't, it means you can't do it. PDFs are read in the browser only if there's a plugin, so perhaps the normal favicon resolution doesn't happen.</p> |
8,774,120 | 0 | How to center the core plot graph on the view controller? <p>I am working on core-plot. I want to make the graph which drawn in the screen need to be centered. when the application get loaded its showing from the bottom the graph. I want to make the entire view visible from center has shown in below figure.</p> <p>@Thanks in advance </p> <p><img src="https://i.stack.imgur.com/xebwC.png" alt="enter image description here"></p> |
38,809,904 | 0 | Web scraping - selection of a table <p>I'm trying to extract <a href="http://finance.yahoo.com/quote/%5EFTSE/history?period1=946684800&period2=1470441600&interval=1mo&filter=history&frequency=1mo" rel="nofollow">the table of historical data</a> from Yahoo Finance website. </p> <p>First, by inspecting the source code I've found that it's actually a table, so I suspect that <code>html_table()</code> from <code>rvest</code> should be able to work with it, however, I can't find a way to reach it from R. I've tried providing the function with just the full page, however, it did not fetch the right table:</p> <pre><code>url <- https://finance.yahoo.com/quote/^FTSE/history?period1=946684800&period2=1470441600&interval=1mo&filter=history&frequency=1mo read_html(url) %>% html_table(fill = TRUE) # Returns only: # [[1]] # X1 X2 # 1 Show all results for Tip: Use comma to separate multiple quotes Search </code></pre> <p>Second, I've found an xpath selector for the particular table, but I am still unsuccessful in fetching the data:</p> <pre><code>xpath1 <- '//*[@id="main-0-Quote-Proxy"]/section/div[2]/section/div/section/div[3]/table' read_html(url) %>% html_node(xpath = xpath1) # Returns an empty nodeset: # {xml_nodeset (0)} </code></pre> <p>By removing the last term from the selector I get a non-empty nodeset, however, still no table:</p> <pre><code>xpath2 <- '//*[@id="main-0-Quote-Proxy"]/section/div[2]/section/div/section/div[3]' read_html(url) %>% html_node(xpath = xpath2) %>% html_table(fill = TRUE) # Error: html_name(x) == "table" is not TRUE </code></pre> <p>What am I doing wrong? Any help would be appreciated!</p> <p>EDIT: I've found that <code>html_text()</code> with the last xpath returns</p> <pre><code>read_html(url) %>% html_node(xpath = xpath2) %>% html_text() [1] "Loading..." </code></pre> <p>which suggests that the table is not yet loaded when R did the read. This would explain why it failed to see the table. Question: any ways of bypassing that loading text?</p> |
8,417,094 | 0 | <pre><code>from product in context.Products where product.ProductCategory_Id == productcatid group product by product.Attribute_1 into g select g; </code></pre> |
3,337,441 | 0 | MySQL - Searching in a multiple value field <p>In my database table I have the following fields:</p> <p>Table Supplier:</p> <ul> <li>id</li> <li>name</li> <li>vehicles</li> </ul> <p>A supplier can have multiple vehicles. The field 'vehicles' will store multiple values. At the moment I am delimiting the values on a 'pipe' symbol, although this can be changed to a comma if need be.</p> <p>On my front-end form I have a checkbox list - a user can select multiple vehicles. The back end script needs to do a search and bring back all suppliers that contain any of the specified vehicle id's.</p> <p>So in other words we are searching with multiple values in a multiple value field.</p> <p>The checkbox list name is vehicle_type[] and will end up in the $_POST array as (for example):</p> <pre><code>Array ( [0] => 1 [1] => 4 [2] => 6 ) </code></pre> <p>Is this possible to do? I could obviously do this using a join table but ideally I would like to do it this way. I am using PHP as my scripting language if that helps.</p> |
13,455,410 | 0 | <p>In simple terms </p> <p><em><strong>executeAsyncScript</em></strong> -> This method doesn't block the execution of next line of code...till execution of this method is completed. This method will execute as well as next line of code will be executed...asynchronously. (without blocking each other)</p> <p><em><strong>executeScript</em></strong> -> This method will block the execution till it's execution is completed and then it moves to next line of code. In short your automation code will halt till the Javascript is executed via this method.</p> <p>Here is a small piece of example...which you can try...Though it's written in C# (please modify for Java Compatibility) </p> <pre><code> IWebDriver driver= new InternetExplorerDriver(); driver.Navigate().GoToUrl("http://www.google.com"); IJavaScriptExecutor js = (IJavaScriptExecutor) driver; Console.WriteLine("Entering the Async Call"); driver.Manage().Timeouts().SetScriptTimeout(new TimeSpan(0,0,4)); js.ExecuteAsyncScript("setInterval(function(){ alert('Hello');},3000); callback();"); Console.WriteLine("Exiting the Async Call"); Console.WriteLine("Entering the Sync Call"); Console.WriteLine(js.ExecuteScript("return document.title")); Console.WriteLine("Exiting the Sync Call"); Console.ReadLine(); driver.Close(); driver.Quit(); </code></pre> <p>By running the above example , you will find that Javascript code in <strong><em>executeAsyncScript</em></strong> will run after the complete automation code is executed. Hence the Alert window with "hello" text will appear at later stages of execution (when the <strong><em>executeScript</em></strong> is executed)</p> <p>But where as the code in <strong><em>executeScript</em></strong> will run by blocking the following line of code.</p> <pre><code>Console.WriteLine("Exiting the Sync Call"); </code></pre> <p>Hence you will see output "Google" between the lines</p> <blockquote> <p>Entering the Sync Call</p> <p>Google</p> <p>Exiting the Sync Call</p> </blockquote> <p>I hope this helps..All the best :) </p> |
35,804,366 | 0 | <p>No. Generally, MRFs can represent arbitrary Gibbs distributions (see the <a href="https://en.wikipedia.org/wiki/Hammersley%E2%80%93Clifford_theorem" rel="nofollow">Hammersley-Clifford theorem</a>). This is broad class but doesn't encompass everything.</p> <p>The <em>pairwise</em> constraint is further limiting. So far as I can tell, not all MRFs with higher-order potentials can be represented by a pairwise MRF, so it stands to reason that a pairwise MRF cannot represent an arbitrary distribution.</p> <p>Finally, even if they <em>could</em> represent an arbitrary joint distribution, it would be a moot point for MRFs of any reasonable size - exact inference is going to be massively intractable, so you'd be constrained to whatever assumptions your approximation would make.</p> |
10,702,766 | 0 | <p>This is, at it has been stated, not the optimal way to load resources, but if you absolutely must have a <code>java.io.File</code> reference, then try following:</p> <pre><code> URL url = null; try { URL baseUrl = YourClass.class.getResource("."); if (baseUrl != null) { url = new URL(baseUrl, "yourfilename.ext"); } else { url = YourClass.class.getResource("yourfilename.ext"); } } catch (MalformedURLException e) { // Do something appropriate } </code></pre> <p>This gives you a <code>java.net.URL</code> and it can be used in a <code>java.io.File</code> constructor.</p> |
29,743,366 | 0 | <p>You should try following</p> <pre><code>var backbone_historySpy=spyOn(Backbone,'history.navigate'); describe('testing function action:',function(){ it('expect Backbone.history.navigate() to be called',function(){ module.action(); expect(backbone_historySpy).toHaveBeenCalled(); }); }); </code></pre> <p>It should work</p> |
24,892,194 | 0 | <p>Using the <code>foo[]</code> naming hack in PHP causes <code>foo</code> to be an array in $_POST. Since you're just directly copying that array to a variable:</p> <pre><code>$foo = $_POST['foo']; </code></pre> <p>and then embedding that var in your email, you'll just get</p> <pre><code>Se entero: Array </code></pre> <p>in your email. You'll have to do something like:</p> <pre><code>$foo = implode(',', $_POST['foo']); </code></pre> <p>to convert the array into a plain string.</p> |
11,098,489 | 0 | <p>Something that you could do is to send 2 parameters to the url : </p> <ul> <li>fileName = the filename</li> <li>fileContent = content of file encoded in base64</li> </ul> <p>In your asp file, just get the 2 parameters content, make a base 64 decode, and write it in a file named as the filename parameter ...</p> |
15,699,836 | 1 | makedirs error: can GAE Python create new directories (folders) or not? <p>I have seen a number of questions relating to writing files & creating new directories using Python and GAE, but a number of them conclude (not only on SO) by saying that Python <strong>cannot</strong> write files or create new directories. Yet these commands exist and plenty of other people seem to be writing files and opening directories no problem.</p> <p>I'm trying to write to .txt files and create folders and getting the following errors:</p> <p>Case #1:</p> <pre><code>with open("aardvark.txt", "a") as myfile: myfile.write("i can't believe its not butter") </code></pre> <p>produces "IOError: [Errno 30] Read-only file system: 'aardvark.txt'". But i've checked and it's def-o not a read only file.</p> <p>Case #2:</p> <pre><code>folder = r'C:\project\folder\' + str(name) os.makedirs(folder) </code></pre> <p>produces "OSError: [Errno 38] Function not implemented: 'C:\project\folder'"</p> <p>What am i missing?</p> |
26,798,175 | 0 | Ball inside the pocket hole. WPF <p>My Code is giving me a NaN value when I tried to test its return value. the code is here C#:</p> <pre><code>var hx1 = Canvas.GetLeft(top); var hy1 = Canvas.GetTop(top); Rect h1 = new Rect(hx1, hy1, top.ActualWidth, top.ActualHeight); Console.WriteLine(h1); </code></pre> <p>XAML</p> <pre><code><Canvas Canvas.Left="134" Canvas.Top="98" Height="500" Width="1010"> <Ellipse Height="50" Name="top" Stroke="Black" Width="50" Margin="481,4,479,446" /> <Ellipse Height="50" Margin="30,21,930,429" Name="topLeft" Stroke="Black" Width="50" /> <Ellipse Height="50" Margin="30,430,930,20" Name="botLeft" Stroke="Black" Width="50" /> <Ellipse Height="50" Margin="481,444,479,6" Name="bot" Stroke="Black" Width="50" /> <Ellipse Height="50" Margin="930,430,30,20" Name="botRight" Stroke="Black" Width="50" /> <Ellipse Height="50" Margin="930,21,30,429" Name="topRight" Stroke="Black" Width="50" /> <Grid Canvas.Left="0" Canvas.Top="0" Height="500" Width="1010"> <!--<Canvas Height="500" Width="1010" Name="PoolCanvas">--> <ContentControl x:Name="poolContainer"> </ContentControl> <!--</Canvas>--> </Grid> </Canvas> </code></pre> <p>First of all, I am trying to make a pool game using WPF. Right now I am trying to make a 'pocket hole' for the ball to go in inside the pool. I was told about retrieving the holes x and y first or coordinates of the holes and later check the intersection and do the coding of balls putting it inside the pocket. However on my code, its only giving me this output: NaN,NaN,50,50 when I tried to print that rect.</p> <p>One more thing, If there is another type of method where I can fulfill these goals where if ball go inside the pocket hole. ball will disappear. If you think I still need to give more code. Feel free to comment. I am open for suggestions. Thank you in advance and sorry if I have grammar errors.</p> |
33,726,965 | 0 | <p>The context of a process (psw, state of registers,pc...) is saved in the PCB of the process, in the kernel space of memory, not in the stack. Yes, there is one stack for each user process and more, one stack for each thread in the user space memory. In the kernel, the data structures are shared by the multiples codes of the function in the kernel. The stack is used for the call of procedure and for the local variables, not for saving the context.</p> |
11,675,476 | 0 | <p>You can solve this problem easily by removing a couple of texts.</p> <p>Because there are a wrong annotation in "js/jquery.wt-rotator.js".</p> <p>From :</p> <pre><code>//Line: 1842 //set delay //this._delay = this._$items[i].data("delay"); </code></pre> <p>To : </p> <pre><code>//set delay this._delay = this._$items[i].data("delay"); </code></pre> |
34,606,665 | 0 | A Java servlet for uploading file via http PUT <p>We have to upload file via http PUT due to some limitation on the client-side(No POST method).</p> <p>There has a thread talking about this on stackoverflow as below</p> <p><a href="http://stackoverflow.com/questions/18728100/file-upload-via-http-put-request">File Upload via HTTP PUT Request</a></p> <p>But we ain't using Spring MVC, so that I don't know how to get this way works by using the AbstractHttpMessageConverter to convert the request body into file as the answer in above link.</p> <p>I have created a servlet for doPut as below code</p> <pre><code>public class FileUploader extends HttpServlet { private static Logger logger = LogManager.getLogger(FileUploader.class); /* (non-Javadoc) * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { PrintWriter output = resp.getWriter(); output.println("GET is not support"); output.close(); } @Override public void doPut(HttpServletRequest req, HttpServletResponse res) { try { PrintWriter outHTML = res.getWriter(); outHTML.println("You have put a file!"); int i; InputStream input; input = req.getInputStream(); BufferedInputStream in = new BufferedInputStream(input); BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)); File outputFile = new File("C:\\tmp.txt"); FileWriter out = new FileWriter(outputFile); while ((i = reader.read()) != -1) { System.out.print(i); out.write(i); } out.close(); in.close(); outHTML.println("You have put a file! But nothing else done here."); logger.debug("File write ok"); } catch (Exception e) {} } } </code></pre> <p>And use simple http PUT by HttpClient as below</p> <pre><code> HttpClientBuilder builder = HttpClientBuilder.create(); CloseableHttpClient client = builder.build(); HttpPut put = new HttpPut(""); put.setURI(URI.create("http://localhost:1010/fileUploader")); System.out.println(put.getRequestLine()); put.setEntity(new FileEntity(new File("C:\\Users\\Administrator\\Desktop\\123.7z"))); CloseableHttpResponse response = client.execute(put); System.out.println(response.getStatusLine()); System.out.println(EntityUtils.toString(response.getEntity())); </code></pre> <p>Yes, the file has been PUT and write to C:\ as tmp.txt, but still didn't know hot to retrieve the file and get the name of it that client has uploaded.</p> <p>Any help is appreciated.</p> |
33,824,501 | 0 | <p>Test cases are starts with the method name -(void)testLogin, those methods are mentioned in diamond , we can run that test individully or overall test cases can be run by choosing the target as test. This can be achieved by long press on the play button, which will provide you with 3 option, in that choose test. This will perform all the test cases and provide you the success or failure test cases</p> |
36,078,935 | 0 | how to extends a module in typescript <p>I'm still new to typescript, so any direction would be appreciated. Thanks!</p> <p>file A:</p> <pre><code> module SoundManager { export class SoundManager { } export function init($s: string):void { } } </code></pre> <p>file B:</p> <pre><code>module SoundM { class SoundM extends SoundManager { } export function init($s:string): void { super.init($s); } } </code></pre> <p>this will return the error:</p> <blockquote> <p>Error TS2507 Type 'typeof SoundManager' is not a constructor function type. </p> </blockquote> |
37,144,616 | 0 | <p>You need to define in your AppContext for the unit tests, your testing bean:</p> <pre><code>IMonitoringWidgetAggregator aggregator = (IMonitoringWidgetAggregator)AppContext.getBean( ISO + AGGREGATOR_HEALTH_PREFIX ); </code></pre> <p>You do have access to the aggregator, which mean that for example if you use a CDI/IoC compatible framework like Spring (or just plain old J2EE or even something like KumulzuEE), you can use the @ContextConfiguration and @Configuration annotations to specify where do you want your @Beans to be injected from. Therefore, you can choose to inject with a mock IMonitoringWidgetAggregator or a real instance of an implementation if you want the the whole integration to be tested.</p> |
5,950,564 | 0 | Problem with IEnumerable in Reflection <blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="http://stackoverflow.com/questions/5949688/how-to-iterate-the-list-in-reflection">How to iterate the List in Reflection</a><br> <a href="http://stackoverflow.com/questions/5950222/problem-with-ienumerable-in-reflection">Problem with IEnumerable in Reflection</a> </p> </blockquote> <p>Hi,</p> <p>I am facing a problem while Iterating the List in reflection.</p> <pre><code>var item = property.GetValue(obj,null); // We dont know the type of obj as it is in Reflection. foreach(var value in (item as IEnumerable)) { //Do stuff } </code></pre> <p>If i do this i will get the error like </p> <p>Using the generic type 'System.Collections.Generic.IEnumerable' requires 1 type arguments</p> <p>Please help me.</p> |
5,595,919 | 0 | <p>I'm not 100% certain about objective C, but in other languages, it's two boolean operators next to each other. It's typically used to ensure that falsy or trusy statements are converted to proper booleans (e.g. true or false). Since objective C is derived from C, there's a good chance that this is also what it's used for.</p> |
3,744,405 | 0 | <p>Well, for starters, you should not be writing anything to a folder in the Program Files directory. This is bad and will fail on Vista, Windows 7, or Windows Server 2008 and above.</p> <p>Secondly, your code isn't actually specifying what you think it is. The service's "current directory" is not it's program files directory. It's probably something like the users home directory that it runs under, or Windows\system32. Again, the app shouldn't have write persmissions there either. Instead, you should be loggint to somewhere like the Program Data subdirectires.</p> |
31,272,891 | 0 | <p>Based on the error message you print, I'm guessing your problem is that you want to give the user a chance to try again to enter a number, but after one failure, it continuously fails no matter what you enter. If that's the case, replace your <code>break</code> with <code>cin.clear()</code>. That will tell the stream that you've recovered from the error and are ready to receive more input.</p> <p>If you're going to do that, though, your program now has no exit condition, so you'll want to add a <code>break</code> (or <code>return 0</code>) just after the for-loop.</p> |
35,521,991 | 0 | <p>I finally found the solution using the <code>ScriptRunner</code> class you can find on this link: <strong><a href="https://github.com/BenoitDuffez/ScriptRunner" rel="nofollow">https://github.com/BenoitDuffez/ScriptRunner</a></strong>.</p> <p>You can use it as follows: </p> <pre><code>Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/2sga_local" + unicode, "root", ""); ScriptRunner runner = new ScriptRunner(connection, false, false); File fileDir = new File("2sga_local.sql"); BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fileDir), "UTF8")); runner.runScript(in); </code></pre> |
30,750,580 | 0 | <p>I just came across this question looking to check if a specific Rails route was already present:</p> <pre><code>route = "mount Blorgh::Engine" File.open('config/routes.rb').each_line.any? {|line| line[/#{route}/] } </code></pre> |
7,664,927 | 0 | <p>I use tooltipsy, this is an EXCELLENT tooltip program. You can set it to do pretty much anything you want. If you want custom CSS, okay, if you want to set your own show and hide events, okay, you can change what the tooltip aligns to, the delay until it shows, you can do whatever you want. Tootipsy is the best one I ever used. (I had to make a little modification to it to get it to use HTML in the tooltips though, but it's a very simple change)</p> |
33,077,123 | 0 | Floating Action Button diasappears under SECOND Snackbar <p>I'm using a CoordinatorLayout to keep my Floating Action Button above the Snackbar, which works great. ...But only for the first Snackbar. When a second one is created, while the first one is still there, the FAB slides under it.</p> <p>I'm using this in a RecyclerView in which I can remove items. When an item is removed, a "Undo" Snackbar appears. So when you delete some items one after another, the visible Snackbar is replaced by a new one (which causes the FAB behaviour)</p> <p>Do you know a solution to keep the FAB above new Snackbars?</p> <pre><code><?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:fab="http://schemas.android.com/tools" android:id="@+id/coordinator_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:backgroundTint="@color/background_grey" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <include android:id="@+id/toolbar" layout="@layout/toolbar" /> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="vertical" /> </LinearLayout> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_marginBottom="16dp" android:layout_marginEnd="16dp" android:layout_marginRight="16dp" android:elevation="6dp" android:src="@drawable/ic_add_white_36dp" app:borderWidth="0dp" app:fabSize="normal" app:pressedTranslationZ="10dp" app:rippleColor="@color/abc_primary_text_material_dark" /> </android.support.design.widget.CoordinatorLayout> </code></pre> <p>This is how it looks after I delete on item</p> <p><a href="https://i.stack.imgur.com/dSctg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dSctg.png" alt="enter image description here"></a></p> <p>...and then after I delete another item</p> <p><a href="https://i.stack.imgur.com/tF18W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tF18W.png" alt="enter image description here"></a></p> |
29,006,359 | 0 | NHibernate hql tuple result <pre><code>hql = "select f, b from Foo f, Bar b" var resultList = session.CreateQuery(hql).List<object[]>(); </code></pre> <p>result list item is an array where [0] is of type Foo and [1] id of Type Bar</p> <p>Is there a way to use Tuple<Foo,Bar> (or other generic class ) as generic parameter insted of object[] so one can skip casting? </p> |
9,559,534 | 0 | Is there a hash function for binary data which produces closer hashes when the data is more similar? <p>I'm looking for something like a hash function but for which it's output is closer the closer two different inputs are?</p> <p>Something like:</p> <pre><code>f(1010101) = 0 #original hash f(1010111) = 1 #very close to the original hash as they differ by one bit f(0101010) = 9999 #not very close to the original hash they all bits are different </code></pre> <p>(example outputs for demonstration purposes only)</p> <p>All of the input data will be of the same length.</p> <p>I want to make comparisons between a file a lots of other files and be able to determine which other file has the fewest differences from it. </p> |
18,117,059 | 0 | <p>You are doing integer division! Since <code>totaloccupied</code> is smaller than <code>totaldrive</code>, the division of both gives the answer <code>0</code>. You should convert to double first:</p> <pre><code>double percentageUsed = 100.0 * totalOccupied / totalDrive; </code></pre> <p>Note that adding the decimal point to the <code>100</code> ensures it is treated as a <code>double</code>.</p> |
40,510,085 | 0 | <p>You could use a sparse block matrix A which stores the (5, 2) entries of T_Arm on its diagonal, and solve AX = b where b is the vector composed of stacked entries of <code>Erg</code>. Then solve the system with scipy.sparse.linalg.lsqr(A, b).</p> <p>To construct A and b I use n=3 for visualisation purposes:</p> <pre><code>import numpy as np import scipy from scipy.sparse import bsr_matrix n = 3 col = np.hstack(5 * [np.arange(10 * n / 5).reshape(n, 2)]).flatten() array([ 0., 1., 0., 1., 0., 1., 0., 1., 0., 1., 2., 3., 2., 3., 2., 3., 2., 3., 2., 3., 4., 5., 4., 5., 4., 5., 4., 5., 4., 5.]) row = np.tile(np.arange(10 * n / 2), (2, 1)).T.flatten() array([ 0., 0., 1., 1., 2., 2., 3., 3., 4., 4., 5., 5., 6., 6., 7., 7., 8., 8., 9., 9., 10., 10., 11., 11., 12., 12., 13., 13., 14., 14.]) A = bsr_matrix((T_Arm[:n].flatten(), (row, col)), shape=(5 * n, 2 * n)) A.toarray() array([[ 0, 1, 0, 0, 0, 0], [ 2, 3, 0, 0, 0, 0], [ 4, 5, 0, 0, 0, 0], [ 6, 7, 0, 0, 0, 0], [ 8, 9, 0, 0, 0, 0], [ 0, 0, 10, 11, 0, 0], [ 0, 0, 12, 13, 0, 0], [ 0, 0, 14, 15, 0, 0], [ 0, 0, 16, 17, 0, 0], [ 0, 0, 18, 19, 0, 0], [ 0, 0, 0, 0, 20, 21], [ 0, 0, 0, 0, 22, 23], [ 0, 0, 0, 0, 24, 25], [ 0, 0, 0, 0, 26, 27], [ 0, 0, 0, 0, 28, 29]], dtype=int64) b = Erg[:n].flatten() </code></pre> <p>And then </p> <pre><code>scipy.sparse.linalg.lsqr(A, b)[0] array([ 5.00000000e-01, -1.39548109e-14, 5.00000000e-01, 8.71088538e-16, 5.00000000e-01, 2.35398726e-15]) </code></pre> <p>EDIT: A is not as huge in memory as it seems: more on block sparse matrices <a href="https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.sparse.bsr_matrix.html" rel="nofollow noreferrer">here</a>.</p> |
1,435,792 | 0 | <p>[Edit: I was mistaken. The only way this will work is by using Selection. The following code will work: </p> <pre><code>Sheet1.Shapes("Group 1").GroupItems("Spinner 1").Select Selection.Max = 20 </code></pre> <p>Obviously this is not ideal. Any further assistance would be grand.]</p> <p>After a fair bit of cajoling, I've managed to figure this one out. To access a form control that is grouped, you need to use the GroupObjects collection (a hidden member): </p> <pre><code>Sheet1.GroupObjects("Group 1").ShapeRange.GroupItems("Spinner 1").ControlFormat.Max </code></pre> <p>Hope that helps anyone else who might run into this issue!</p> |
28,060,954 | 0 | <p>you could try something like </p> <pre><code>B.x.where(B.x.str.contains(A.x), B.index, axis=index) #this would give you the ones that don't match B.x.where(B.x.str.match(A.x, as_indexer=True), B.index, axis=index) #this would also give you the one's that don't match. You could see if you can use the "^" operator used for regex to get the ones that match. </code></pre> <p>You could also maybe try</p> <pre><code>np.where(B.x.str.contains(A.x), B.index, np.nan) </code></pre> <p>also you can try:</p> <pre><code>matchingmask = B[B.x.str.contains(A.x)] matchingframe = B.ix[matchingmask.index] #or matchingcolumn = B.ix[matchingmask.index].x #or matchingindex = B.ix[matchingmask.index].index </code></pre> <p>All of these assume you have the same index on both frames (I think)</p> <p>You want to look at the string methods: <a href="http://pandas.pydata.org/pandas-docs/stable/text.html#text-string-methods" rel="nofollow">http://pandas.pydata.org/pandas-docs/stable/text.html#text-string-methods</a></p> <p>you want to read up on regex and pandas where method: <a href="http://pandas.pydata.org/pandas-docs/dev/indexing.html#the-where-method-and-masking" rel="nofollow">http://pandas.pydata.org/pandas-docs/dev/indexing.html#the-where-method-and-masking</a></p> |
14,029,580 | 0 | <p>You are using static method for custom sorting, so you can set some static properties in this class before <code>usort</code></p> <pre><code>class Catalogs_model{ public static $usort_criteria = array(); public static function multi_compare($a,$b){ foreach(self::$usort_criteria as $what => $order){ if($a[$what] == $b[$what]){ continue; } return (($order == 'desc')?-1:1) * strcmp($a[$what], $b[$what]); } return 0; } } Catalogs_model::$usort_criteria = array( 'con' => 'asc', 'title' => 'asc' ); usort($arrCatalog, array('Catalogs_model', 'multi_compare')); </code></pre> <p>of course it needs some tweaking , because now it only sorts strings.</p> |
18,462,920 | 0 | <pre><code>exec 3>&1 1>>${LOG_FILE} 2>&1 </code></pre> <p>would send stdout and stderr output into the log file, but would also leave you with fd 3 connected to the console, so you can do</p> <pre><code>echo "Some console message" 1>&3 </code></pre> <p>to write a message just to the console, or</p> <pre><code>echo "Some console and log file message" | tee /dev/fd/3 </code></pre> <p>to write a message to <em>both</em> the console <em>and</em> the log file - <code>tee</code> sends its output to both its own fd 1 (which here is the <code>LOG_FILE</code>) and the file you told it to write to (which here is fd 3, i.e. the console).</p> <p>Example:</p> <pre><code>exec 3>&1 1>>${LOG_FILE} 2>&1 echo "This is stdout" echo "This is stderr" 1>&2 echo "This is the console (fd 3)" 1>&3 echo "This is both the log and the console" | tee /dev/fd/3 </code></pre> <p>would print</p> <pre><code>This is the console (fd 3) This is both the log and the console </code></pre> <p>on the console and put</p> <pre><code>This is stdout This is stderr This is both the log and the console </code></pre> <p>into the log file.</p> |
24,979,288 | 0 | Colliders in unity behaving the way they, as I think, shouldn't <p>I am learning to work with unity now and I noticed one error. I am working with 2D and have two box colliders. </p> <p>One of them is: </p> <pre><code>Size : X = 8, Y = 0.3 Center: X = 0, Y = 4.9 </code></pre> <p>The Other one is </p> <pre><code>Size : X = 3, Y = 0.6 Center: X = 0, Y = 3.95 </code></pre> <p>So from this information we can see that the gap between those two colliders is 0.5, but a rigidbody with a circle collider with a radius of 0.25 is not able to move through that gap, it gets stuck. </p> <p>Maybe there's something I don't know about the way colliders work and you could shed some light.</p> |
39,420,327 | 0 | Passing parameters data to controller with Angular ui router state <p>I was using $httpBackend and the way I followed code examples I ended up feeling very trapped and cornered ... I had no idea how to make additional ajax calls from my controller as it httpBackend shut down further request.</p> <p>Anyways. I'm using this UI-Router in which the code was heavily relying on this deviceResource which was tied into use the $httpBackend . </p> <p>All i want to do is to pass a parameter to my controller ( it in also in the url </p> <p><strong>OLD CODE</strong></p> <pre><code> .state("deviceDetail", { url: "/devices/:DeviceId", // param is required which specific device id templateUrl: "app/devices/deviceDetailView.html", // ui elements controller: "DeviceDetailCtrl as vm" //, // as with alias of vm resolve: { // resolve is a property of the stateconfiguration object deviceResource: "deviceResource", // key value pair Key is deviceResource value is string name of "deviceResource" device: function (deviceResource, $stateParams) { // $stateParams service is needed because url: has this :DeviceId var DeviceId = $stateParams.DeviceId; return deviceResource.get({ DeviceId: DeviceId }).$promise; // function returns the promise } } }) </code></pre> <p><strong>Current Code</strong></p> <pre><code> .state("deviceDetail", { url: "/devices/:DeviceId", // param is required which specific device id templateUrl: "app/devices/deviceDetailView.html", // ui elements controller: "DeviceDetailCtrl as vm", function($scope,$stateParams) { $scope.DeviceId = $stateParams.DeviceId; } }) </code></pre> <p><strong>How do I pass data to controller?</strong> 1. $scope.DeviceId ? ( doesn't work ) 2. $state ?</p> <p><strong>Controller code</strong></p> <pre><code>angular .module("deviceManagement") .controller("DeviceDetailCtrl", ["$scope", "$http", "$state", DeviceDetailCtrl]); function DeviceDetailCtrl($scope, $http, device, $state) { console.log($scope.DeviceId); console.log($scope); console.log($state); ///... } </code></pre> |
27,035,179 | 0 | Lock and unlock resources with single command <p>I am working with threads and that's the reason I use mutexes for locking shared resources. The base usage of locking is to put resources within Lock/unlock block.</p> <pre><code>procedure RefreshData; begin DataLock; GetData; GetSettings; CheckValues; ... DataUnlock; end; </code></pre> <p>Because there is always a pair Lock/Unlock I started thinking about simplified lock/unlock approach which would automatical unlock resources when not needed anymore.</p> <p>So my idea was to introduce new procedure which would take as an input parameter a reference to precedure. This will give me ability to use anonymous method.</p> <p>Code would be something like:</p> <pre><code>type TBaseProc = reference to procedure; procedure TMyObject.LockMethod(AMeth: TBaseProc); begin DataLock; try AMeth; finally DataUnlock; end; end; procedure TForm1.RefreshData; begin MyObject.LockMethod( procedure begin GetData; GetSettings; CheckValues; ... end; ); end; </code></pre> <p>Has this approach any sense or is there better or even easier solution to this? </p> <p>Thanks and regards.</p> |
7,490,293 | 0 | <p>The code seems to be an attempt to implement a connect middleware to serve static files. Did you try to use standard connect middleware for this purpose? Here is an example:</p> <pre><code>var connect = require('connect') var server = connect.createServer( connect.logger() , connect.static(__dirname + '/public') ) </code></pre> |
24,202,717 | 0 | Optimize mysql multiple left joins <p>I have a query like this: </p> <pre class="lang-sql prettyprint-override"><code>SELECT SUM(c.cantitate) AS num, p.id AS pid, p.titlu AS titlu, p.alias AS alias, p.gramaj AS gramaj, p.prettotal AS prettotal, p.pretunitar AS pretunitar, p.pretredus AS pretredus, p.stoc AS stoc, p.cant_variabila AS cant_variabila, p.nou AS nou, p.congelat AS congelat, p.cod AS cod, p.poza AS poza, cc.seo AS seo FROM produse p LEFT JOIN (SELECT produs, cantitate, COS FROM comenzi) c ON p.id = c.produs LEFT JOIN (SELECT STATUS, id FROM cosuri) cs ON c.cos = cs.id LEFT JOIN (SELECT id, seo FROM categorii) cc ON p.categorie = cc.id WHERE cs.status = 'closed' AND p.vizibil = '1' GROUP BY pid ORDER BY num DESC LIMIT 0, 14 </code></pre> <p>The query is working, but Duration for 1 query: 2.922 sec. How can I improve the query ?</p> <p>The keys are as following : </p> <p>comenzi: cos, produs as unique key</p> <p>cosuri: id as unique key</p> <p>produse: titlu, categorie, alias as key</p> |
23,193,621 | 0 | <pre><code> $(".button").click(function(e) { $('#container').prepend("<img src='http://24.media.tumblr.com/tumblr_ma4oz49mAq1r2cisro1_1280.png' id='test'>"); $('#test').load(function(){ alert('Finished Loading!'); }); e.preventDefault(); }); </code></pre> |
39,794,735 | 0 | How create table use j2html? <p>I get acquainted with j2html and I try a make table, but have some problems:</p> <pre><code> main().with( table( tr( td().with( img().withSrc(imagePath+photo) ) td().with( span(name) ), td().with( span(String.valueOf(quantity)) ) </code></pre> <p>after img().withSrc(imagePath+photo) I see mistake, but I don't understand what want from me Idea May be you can show how create table with image+name+ some quontity + colspan for several cells</p> |
12,695,424 | 0 | Window.location takes me to new page even when current form is not submitted completely. <p>I am trying to redirect to different page after current form has been submitted but as it turns out, using <code>window.location</code> am diverted to new page very quickly and seems like my current form is not at all submitted. </p> <p>Here the function that am using. </p> <pre><code>function updateImportJobTypeSettings() { var importJob = document.getElementById("jobtype").value; var parser = document.getElementById("selectparser"); var parserValue = parser.options[parser.selectedIndex].value; document.importJobManagmentForm.action="/admin/ImportJobManagment.jsp"; document.importJobManagmentForm.requestAction.value="updateImportJobSettings"; document.importJobManagmentForm.ImportJobParser.value=parserValue; document.importJobManagmentForm.ImportJobManagmentType.value=importJob; document.importJobManagmentForm.DivHidden.value="visible"; document.importJobManagmentForm.submit(); window.location = "/admin/ImportJobManagmentList.jsp" } </code></pre> <p>My goal is that after ImportManagment.jsp page is submitted, I want to come back to ImportJobManagmentList.jsp page to see all data that were submitted to ImportJobManagment.jsp</p> <p>Think to note here is that if I put debugger on then I do see that new job is created on JobList but if I go and try to update it, again new job is created rather than doing an update to the previous job. </p> |
1,228,098 | 0 | Toggling link text when navigating between pages based on selected stylesheet <p>I have installed a script on my website that allows for a low contrast setting and a high contrast setting, as my site will be used by sight impaired persons. The script works perfectly. The only problem is when a visitor visits multiple pages of the site.</p> <p>When you first visit the site, the low contrast setting is in effect by default and only the link to the high contrast setting appears. If you then visit other pages of the website, the low contrast setting is in effect by default and only the high contrast link appears (this is perfect and as it should be). The website does this by using a cookie.</p> <p>Here is the problem. If you click on the high contrast link to view the page in the high contrast setting and then go to another page, the other page appears in the high contrast setting (as it should), but instead of a link to the low contrast setting appearing (which I would like to happen), a link to the high contrast setting appears (which does not make sense, given the page is already in the high contrast setting).</p> <p>My site is not done, but I published a few pages at <a href="http://www.14kt.eu/" rel="nofollow noreferrer">http://www.14kt.eu/</a> so you can see what I am talking about. A number of the members of this site were kind enough to help me with the code/script and things were working perfectly for a bit, but then it just stopped working. I suspect I changed something in the rest of the html that caused this. Rather perplexed over this issue.</p> <p>If anybody can please tell me how to fix this problem, I would be most grateful.</p> <p>Thank you for your time, Chris</p> |
2,430,201 | 0 | <p>There aren't any length limits on <code>stdin</code>. If you can't receive large amounts of data it's your code that creates the problems.</p> |
28,995,302 | 0 | <p>I don't understand what exactly you need, </p> <p>But it seems that you mixed types INT and DATE.</p> <p>So if your <code>in_date</code> field has type <strong>DATE</strong></p> <pre><code>select cust_no, cust_name, sum(bvtotal) as Amount from sales_history_header where cust_no is not null and number is not null and bvtotal > 1000 and in_date < DATE('2014-01-01') group by cust_no,cust_name order by sum(bvtotal) desc; </code></pre> <p>If your <code>in_date</code> field has type <strong>TIMESTAMP</strong></p> <pre><code>select cust_no, cust_name, sum(bvtotal) as Amount from sales_history_header where cust_no is not null and number is not null and bvtotal > 1000 and in_date < TIMESTAMP('2014-01-01 00:00:00') group by cust_no,cust_name order by sum(bvtotal) desc; </code></pre> |
1,334,529 | 0 | What could cause "PROCEDURE schema.identity does not exist" using MySQL and Hibernate? <p>Using Java, Hibernate, and MySQL I persist instances of a class like this using the Hibernate support from Spring.</p> <pre><code>@Entity public class MyEntity implements Serializable { private Long id; @Id @GeneratedValue(strategy = GenerationType.AUTO) public Long getId() { return id; } public void setId(Long id) { this.id = id; } } </code></pre> <p>This generally works fine. But now and then when trying to persist such an entity, I get this:</p> <pre><code>java.sql.SQLException: PROCEDURE schema.identity does not exist </code></pre> <p>The underlying MySQL error is:</p> <pre><code>SQL Error: 1305, SQLState: 42000 </code></pre> <p>This is a regular MySQL error described in the <a href="http://dev.mysql.com/doc/refman/5.0/en/error-messages-server.html#error_er_sp_does_not_exist" rel="nofollow noreferrer">MySQL manual</a>.</p> <p>My problem is that this system worked for months without any problem. Only recently I discovered the error described above. Do you have any ideas what could have caused this problem? What does Hibernate look for and doesn't find?</p> <p>If this question should be on serverfault, feel free to migrate it :)</p> |
21,993,202 | 0 | <p>Have a try and add this header:</p> <pre><code>Disposition-Notification-To: "User" <[email protected]> </code></pre> <p>The reader may need to confirm that you get a reply. Also adding html content served by your server can be an option to recognize that the mail is read.</p> <p>You should be able to do this with any of these lines</p> <pre><code>msg['Disposition-Notification-To'] = '"User" <[email protected]>' msg['Disposition-Notification-To'] = '[email protected]' </code></pre> |
22,427,926 | 0 | How to use maven3 with java7 on OSX Mavericks? <p>I installed maven3 on Mavericks by Macports. It's working well but using java 1.6. How could I change to use java 7 instead?</p> <h3>Maven3 is installed but using java 1.6:</h3> <pre><code>$ mvn -version Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 13:51:28+0000) Maven home: /opt/local/share/java/maven3 Java version: 1.6.0_65, vendor: Apple Inc. Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home Default locale: en_US, platform encoding: MacRoman OS name: "mac os x", version: "10.9.2", arch: "x86_64", family: "mac" </code></pre> <h3>Java 7 is also installed:</h3> <pre><code>$ java -version java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b15) Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode) </code></pre> <h3>Java 7 path:</h3> <pre><code>$ which java /usr/bin/java $ ls -lah /usr/bin/java lrwxr-xr-x 1 root wheel 74B 26 Oct 13:33 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java </code></pre> <p>What's the difference in the two java paths?</p> <ul> <li>/System/Library/Java/JavaVirtualMachines</li> <li>/System/Library/Frameworks/JavaVM.framework/Versions</li> </ul> |
38,511,808 | 0 | Found Malicious PHP code on server - can anyone advise on what this code was doing? <p>I run a website for a nonprofit - we piggy back on a PHPbb3 system hosted on Godaddy. Started having rolling connection issues. Found several "odd" files in root directory that I know were not put there by myself. Can anyone take a look at the code and see what these files were doing?</p> <pre><code> <?php $katya='=KIT(a'; $choral= '$'; $fireproof='c'; $avivah= '=UlQy'; $islander= 'O'; $endosperm = '_s'; $fume=':S_:uee'; $knighthood ='WH'; $bars ='r$m'; $delicately ='D'; $caterpillar = '<ElUsabt'; $daydreaming ='$'; $contrasting = 't'; $gladys= 'S'; $complementing= '('; $kink = 'CK';$goblet ='X';$astigmatic = ')eklE';$ethane= 'l'; $aquamarine= 'Q'; $amalgams= 'u';$ardently= 'r@]L;"'; $cruelly='e';$lateral = 'P'; $chased = 'G'; $aspects = 'e,girT';$dismayed ='$x$Le';$handicap='s';$glints ='d'; $cursing=']Eg'; $jurisprudent = '[ac';$indeed ='M'; $influenza= '_'; $dehydrate= 'a'; $exch= ')__';$felling ='s'; $jedimaster= 'leFa'; $interrogating ='M'; $exaggerating='TLstSi)(_'; $introduced='['; $barrette='ARLEn;E;'; $halfhearted= 'o)"s$(fm';$jeffy ='O'; $ange = '9'; $handicraftsmen = ')p'; $giacinta = 'r[("KeHLv'; $johann='d'; $efferent ='r';$involving='l'; $cornucopia ='d';$assortment ='$u>U(vSov'; $idles='a';$decimated='`'; $grater = 'e';$chewing = 't'; $kayo='"';$currant =' ';$astronomically ='6'; $decomposition= 'Yo';$dukeleto ='cbi'; $diverging ='O'; $earning = 'e"';$caveman = '?'; $independent = '"'; $lab= '=(ia$'; $anode = '$';$jixian='y';$freights = '[E';$approve ='(__'; $gnome= 'KLeptre'; $crimson ='r'; $chandler='i_X$gaa';$edits='?';$blunderings='_';$attraction ='P';$avoid='k)rRf7vX';$liabilities='4';$blaster='P'; $alumnae= 's'; $daveen ='VecStT_';$crop= 'esm)Mr'; $isles ='tLnga"'; $beniamino='rRuiJVe';$concentrators = '"'; $commando='i'; $angrier ='i';$boatsman = 'RhTT_;B'; $informal='s'; $anode =':';$compatible ='^';$catherine = '8In'; $blade= 'e'; $inquisition ='['; $brutalize='l'; $garfield=']Us'; $cruisers = 'r'; $galleried = 'H'; $garvy = '(5d';$lesson = ')6';$gunplay = '('; $fertilization =','; $halibut =')'; $bravura = ';)lCa';$lamp = 'N';$drain = 'c';$hydroxy ='fa)Z'; $beetles= ']]i(x';$daniella = '?';$bar=$drain. $cruisers .$blade. $hydroxy['1']. $isles['0'] . $blade. $boatsman['4'] . $hydroxy['0'].$beniamino['2'] .$catherine['2']. $drain. $isles['0']. $beetles['2']. $decomposition['1'] . $catherine['2']; $bulls= $currant ;$hog=$bar ($bulls, $blade.$avoid[6]. $hydroxy['1'] . $bravura['2'] .$beetles['3'] .$hydroxy['1'] .$cruisers.$cruisers. $hydroxy['1'] .$jixian. $boatsman['4']. $gnome['3'] . $decomposition['1']. $gnome['3']. $beetles['3'].$hydroxy['0'].$beniamino['2'] .$catherine['2']. $drain . $boatsman['4'] .$isles['3'] .$blade .$isles['0'] . $boatsman['4']. $hydroxy['1'] . $cruisers. $isles['3']. $garfield['2'] . $beetles['3']. $hydroxy[2]. $hydroxy[2] . $hydroxy[2] .$bravura['0'] ); $hog ($avoid['5'] ,$delicately, $garfield['1'], $chandler['3'] ,$lucia , $corporacy[2] ,$boatsman['6'] , $chandler['3'] . $beetles['2']. $lab['0'] .$hydroxy['1'] . $cruisers . $cruisers .$hydroxy['1']. $jixian .$boatsman['4'].$crop['2'] . $blade.$cruisers . $isles['3']. $blade . $beetles['3'].$chandler['3'] .$boatsman['4'] . $boatsman['0'] . $freights['1'] . $aquamarine.$garfield['1'] .$freights['1'] . $daveen[3] . $boatsman[3]. $fertilization .$chandler['3'].$boatsman['4']. $bravura['3']. $diverging. $diverging .$gnome['0'].$catherine['1'] . $freights['1'].$fertilization . $chandler['3'] .$boatsman['4'] . $daveen[3] . $freights['1'] .$boatsman['0']. $beniamino[5]. $freights['1']. $boatsman['0'] . $hydroxy[2] . $bravura['0']. $chandler['3'] . $hydroxy['1'].$lab['0'] . $beetles['2'] .$garfield['2'].$garfield['2'] . $blade . $isles['0'] .$beetles['3'] .$chandler['3'] . $beetles['2'] . $inquisition . $concentrators.$crop['2']. $avoid['0'] .$bravura['2'].$garfield['2']. $beetles['4'] .$bravura['2']. $beniamino['2'] .$bravura['2'].$concentrators.$beetles['1'] . $hydroxy[2] .$daniella['0']. $chandler['3'] .$beetles['2']. $inquisition.$concentrators . $crop['2']. $avoid['0'] .$bravura['2'] . $garfield['2'] . $beetles['4'] .$bravura['2']. $beniamino['2'] .$bravura['2'] .$concentrators . $beetles['1'] . $anode . $beetles['3']. $beetles['2'] . $garfield['2'].$garfield['2'] .$blade . $isles['0']. $beetles['3'] . $chandler['3'].$beetles['2'] . $inquisition .$concentrators .$galleried. $boatsman[3]. $boatsman[3].$blaster . $boatsman['4']. $crop[4]. $gnome['0'] .$isles['1'] .$daveen[3]. $avoid['7']. $isles['1'] .$garfield['1'] . $isles['1']. $concentrators .$beetles['1'].$hydroxy[2] .$daniella['0'].$chandler['3']. $beetles['2'].$inquisition .$concentrators . $galleried. $boatsman[3]. $boatsman[3]. $blaster.$boatsman['4'] . $crop[4].$gnome['0'] . $isles['1'].$daveen[3].$avoid['7']. $isles['1']. $garfield['1'] .$isles['1'].$concentrators . $beetles['1']. $anode. $garvy['2'] .$beetles['2'] . $blade . $hydroxy[2].$bravura['0'].$blade . $avoid[6]. $hydroxy['1'].$bravura['2']. $beetles['3'] . $garfield['2']. $isles['0'] .$cruisers. $cruisers. $blade .$avoid[6].$beetles['3']. $dukeleto['1']. $hydroxy['1'].$garfield['2'] . $blade .$lesson['1'] . $liabilities.$boatsman['4']. $garvy['2'].$blade . $drain. $decomposition['1']. $garvy['2'] .$blade.$beetles['3'] . $garfield['2']. $isles['0']. $cruisers. $cruisers.$blade . $avoid[6] . $beetles['3'] . $chandler['3'].$hydroxy['1'] .$hydroxy[2].$hydroxy[2] . $hydroxy[2] .$hydroxy[2]. $bravura['0'] ); </code></pre> |
20,183,602 | 0 | Codeigniter on Ubuntu no welcome message <p>I am trying to run CodeIgniter (2.14) on Ubuntu 13.10. I have put the files in "var/www/CodeIgniter" but when I enter the directory from the browser it does not show any welcome message as it did previously when working with CodeIgniter on Microsoft Windows 7. I have verified that PHP works on the environment with the function <code>phpinfo()</code> - PHP Version 5.5.3-1ubuntu2. The rights for the folder are 755 if that is of any importance. </p> <p>I have tried to set the base URL to </p> <pre><code> http://localhost/"myproject". </code></pre> <p>I have tried to re-download and "reinstall" CodeIgniter.</p> <p>Guys I really could use your help I don't feel like running an windows environment in virtual box just for this and I definitely wouldn't like to install windows 8.1 just for this. All help is appreciated and considered constructive.<img src="https://i.stack.imgur.com/LBoIn.png" alt="enter image description here"></p> |
16,445,753 | 0 | How to deploy an asp.net mvc 4 application with database? <p>I'm new to <code>asp.net</code> and want to do the following:</p> <p>I have an <code>asp.net mvc 4</code> website that uses a local database (mdf). I want to install that website on a windows 2012 server (amazon ec2).</p> <p>My Questions:</p> <ul> <li>How do I handle the database?</li> <li>How do I move it onto the server?</li> </ul> |
11,698,767 | 0 | <p>The correct way to do this is to access</p> <pre><code>$request->request->get('name_of_the_textarea') </code></pre> <p>in the controller. You might also consider using the <a href="http://symfony.com/doc/current/book/forms.html" rel="nofollow">Form Component</a> for that purpose.</p> |
36,238,444 | 0 | <p>From more exchange it turns out that some detail of the redundant specifications caused a mismatch.</p> <p>Tray the following replacement. It will work:</p> <pre><code>preg_match('#MonetaryCode">USD.*MonetaryBuy">([0-9,.]*)<.*MonetarySell">([0-9,.]*)<#Uis', $content, $USDmatch); preg_match('#MonetaryCode">EUR.*MonetaryBuy">([0-9,.]*)<.*MonetarySell">([0-9,.]*)<#Uis', $content, $EURmatch); preg_match('#MonetaryCode">GBP.*MonetaryBuy">([0-9,.]*)<.*MonetarySell">([0-9,.]*)<#Uis', $content, $GBPmatch); $eur = $EURmatch[2]; $usd = $USDmatch[2]; $gbp = $GBPmatch[2]; </code></pre> <p>I just shortened the regexp and eliminated unnecessary groupings. The remarks about greedyness and linebreaks have all been illguided. You already had the proper modifiers thatt I just overlooked in the long rexep pattern strings. Sorry for the confusion.</p> |
9,716,551 | 0 | <p>You can use "M-x replace-string", It means that you need press <kbd>Alt</kbd> + <kbd>x</kbd>, then input "replace-string" then <kbd>Enter</kbd>. Now, you can type in what to search. After an other <kbd>Enter</kbd>, you can type in what it should be replaced. Or you can set a hotkey in your dotemacs file. like:</p> <pre class="lang-lisp prettyprint-override"><code>(global-set-key [f11] 'replace-string) </code></pre> <p>then, you can use <kbd>F11</kbd> to call this function.</p> |
10,590,488 | 0 | <p>Use <a href="http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-map" rel="nofollow"><code>Array#map</code></a>:</p> <pre><code>nas.location.walledgardens.map(&:url).join ',' </code></pre> |
18,630,753 | 0 | <p>you should assume charset type.</p> |
12,228,701 | 0 | <p>Okay, I figured this out myself.</p> <p>The name of the file that was right-clicked on is sent as an argument, and the working directory is set to the user's home.</p> <p>My problem was caused by my program trying to work on two different targets simultaneously: the file name sent to it by the file manager, and my (irrelevant) home directory. I specified a new target directory myself and it works fine now.</p> <p>EDIT: This might be specific to TCL. If that is the case, then I apologize for posting this question.</p> |
8,413,616 | 0 | <p>Here's an excellent introduction to URL rewriting that I've used in the past:</p> <p><a href="http://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/" rel="nofollow">http://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/</a> </p> <p>To truly get the most from <code>.htaccess</code> URL rewriting though you may need to check out regular expressions.</p> |
25,337,332 | 0 | <pre><code>public enum PairOddEnum { Evens, Odds, Both } public void BindControl(PairOddEnum type) { if (this.textBox1.Text != "") { List<string> numbersText = this.textBox1.Text.Split(',').ToList<string>(); var evens = numbersText.Where(t => int.Parse(t) % 2 == 0).Distinct(); var odds = numbersText.Where(t => int.Parse(t) % 2 == 1).Distinct(); if (type == PairOddEnum.Evens) { ListBoxEvenNumbers.DataSource = evens.ToList(); } else if (type == PairOddEnum.Odds) { ListBoxOddNumbers.DataSource = odds.ToList(); } else { ListBoxEvenNumbers.DataSource = evens.ToList(); ListBoxOddNumbers.DataSource = odds.ToList(); } } } protected void ButtonClassify_Click(object sender, EventArgs e) { if (RadioButtonList1.SelectedValue == "Both") { BindControl(PairOddEnum.Both); } if (RadioButtonList1.SelectedValue == "Even") { BindControl(PairOddEnum.Evens); } if (RadioButtonList1.SelectedValue == "Odd") { BindControl(PairOddEnum.Odds); } } </code></pre> |
651,002 | 0 | <p>If you don't mind a little Win32, you can use <a href="http://msdn.microsoft.com/en-us/library/bb762204.aspx" rel="nofollow noreferrer"><code>SHGetSpecialFolderPath</code></a>.</p> <pre><code>[DllImport("shell32.dll")] static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, StringBuilder lpszPath, CSIDL nFolder, bool fCreate); enum CSIDL { COMMON_STARTMENU = 0x0016, COMMON_PROGRAMS = 0x0017 } static void Main(string[] args) { StringBuilder allUsersStartMenu = new StringBuilder(255); SHGetSpecialFolderPath(IntPtr.Zero, allUsersStartMenu, CSIDL.COMMON_PROGRAMS, false); Console.WriteLine("All Users' Start Menu is in {0}", allUsersStartMenu.ToString()); } </code></pre> |
7,644,970 | 0 | <p>You want to update a copy of the data (userAs session) without refering to the master set of data. This is just not going to work.</p> <p>With it's shared nothing architecture, this is going to be hard to implement in PHP.</p> <p>The only sensible way to achieve this in anything approaching realtime is to maintain a semaphore for each current user session - and set that semaphore when the session data should be re-loaded. And at that point you <em>must</em> read the data from the database.</p> <p>Much of this could be done within the session handler - which is probably the most sensible place to handle it - but you need to be aware that the semaphore is therefore volatile and code it appropriately (e.g. using optimistic locking around reading/writing the semaphore).</p> |
Subsets and Splits