pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
5,544,452 | 0 | <p>It's been deprecated for a while now. You're better off writing your own function, or taking some hints from the docs and comments on <a href="http://php.net/manual/en/function.mime-content-type.php" rel="nofollow">php.net</a></p> |
16,439,440 | 0 | <ul> <li>save those 8 positions in 8 CGRects.</li> <li>then generate a random number between 1 and 8 using <code>int r = arc4random() % 8</code>;.</li> <li>using <code>switch</code> statement set the <code>CGRect</code> of the button depending on r.</li> </ul> |
24,714,797 | 0 | Textwatcher in custom listview with SQLite database <p>I want to add a filter in custom listview which is getting values from sqlite database. Is it possible to filter according to two value of textview? Please help me to add a filter query . If you have any text watcher example then please tell me.</p> <p>I have added a listview adapter in MainActivity.java</p> <pre><code> lv = (ListView) findViewById(R.id.listView1); mydb = new DBHelper(this); Log.d("tag", mydb.listfromdb().toString()); lv.setAdapter(new ViewAdapter(mydb.listfromdb())); </code></pre> <p>and </p> <pre><code>public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub if (convertView == null) { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = mInflater.inflate(R.layout.list_item, null); } Listcollection o = collectionlist.get(position); if (o != null) { TextView idText = (TextView) convertView .findViewById(R.id.lvid); TextView nameText = (TextView) convertView .findViewById(R.id.lvname); TextView dateText = (TextView) convertView .findViewById(R.id.lvdate); TextView phoneText = (TextView) convertView .findViewById(R.id.lvjno); if (idText != null) { idText.setText(Integer.toString(o.getId())); } if (nameText != null) { nameText.setText("Name : " + collectionlist.get(position).getName()); } if (dateText != null) { dateText.setText("Date of Complain : " + collectionlist.get(position).getCdate()); } if (phoneText != null) { phoneText.setText("Job No.: " + collectionlist.get(position).getType()); } } return convertView; } </code></pre> <p>Here I am getting values from DBHelper.java</p> <pre><code>public ArrayList<Listcollection> listfromdb() { SQLiteDatabase db = this.getReadableDatabase(); ArrayList<Listcollection> results = new ArrayList<Listcollection>(); Cursor crs = db.rawQuery("select * from contacts", null); while (crs.moveToNext()) { Listcollection item = new Listcollection(); item.setId(crs.getInt(crs.getColumnIndex(CONTACTS_COLUMN_ID))); item.setName(crs.getString(crs.getColumnIndex(C_NAME))); item.setCdate(crs.getString(crs.getColumnIndex(C_CDATE))); item.setType(crs.getString(crs.getColumnIndex(C_TYPE))); results.add(item); } db.close(); return results; } </code></pre> <p>I have also included DBHelper.java after removing some methods.</p> <pre><code>public class DBHelper extends SQLiteOpenHelper { public static final String DATABASE_NAME = "MyDBName.db"; public static final String CONTACTS_TABLE_NAME = "contacts"; public static final String CONTACTS_COLUMN_ID = "id"; public static final String C_NAME = "name"; public static final String C_TYPE = "type"; public static final String C_ADDRESS = "address"; public static final String C_DATE = "sdate"; public static final String C_PHONE = "phone"; public static final String C_PNAME = "pname"; public static final String C_MNO = "mno"; public static final String C_CDATE = "cdate"; public static final String C_DNAME = "dname"; public static final String C_DPHONE = "dphone"; public static final String C_TSCHARGE = "tscharge"; public static final String C_DAMOUNT = "damount"; public static final String C_FANDSOL = "fandsol"; public static final String C_TRNO = "trno"; public static final String C_TCRAMOUNT = "tcramount"; private HashMap hp; public DBHelper(Context context) { super(context, DATABASE_NAME, null, 1); } public ArrayList<Listcollection> listfromdb() { SQLiteDatabase db = this.getReadableDatabase(); ArrayList<Listcollection> results = new ArrayList<Listcollection>(); Cursor crs = db.rawQuery("select * from contacts", null); while (crs.moveToNext()) { Listcollection item = new Listcollection(); item.setId(crs.getInt(crs.getColumnIndex(CONTACTS_COLUMN_ID))); item.setName(crs.getString(crs.getColumnIndex(C_NAME))); item.setCdate(crs.getString(crs.getColumnIndex(C_CDATE))); item.setType(crs.getString(crs.getColumnIndex(C_TYPE))); results.add(item); } db.close(); return results; } } </code></pre> |
13,240,785 | 0 | <p>I suspect that:</p> <ol> <li>in irb, when you <code>require 'cowboy'</code>, that tells rubygems to set up the load paths automatically to point to the currently installed gem dir.</li> <li>when you run <code>test/test_cowboy.rb</code> it doesn't <code>require 'cowboy'</code>. This makes sense because during development, you don't want to load the installed version of the gem, which could be different from the code in your working dir.</li> </ol> <p>I think you should create a <code>test/test_helper.rb</code> file that sets up the load path:</p> <pre><code>$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) </code></pre> <p>You may need to add other dirs if the compiled shared object file (<code>.so</code> or <code>.bundle</code>) isn't placed in <code>lib</code>.</p> <p>Then in each test file (e.g. <code>test/test_cowboy.rb</code>), require <code>test/test_helper.rb</code>:</p> <pre><code>require File.expand_path('../test_helper.rb', __FILE__) </code></pre> <p>You'll need to adjust that relative path if you have subdirs. E.g. if you have a file <code>test/shoes/spur.rb</code>, you'd use:</p> <pre><code>require File.expand_path('../../test_helper.rb', __FILE__) </code></pre> |
1,229,096 | 0 | <p>You should download leopard, not snow leopard. Snow won't be out until around september, so you have leopard.</p> |
10,430,694 | 0 | <pre><code>function changeImage(me){ alert(me.id) } </code></pre> |
21,615,296 | 0 | <p>When you inflate the layout for your fragment, you should ensure that the visibility is set to GONE. The default for a view (and thus your fragment) is VISIBLE.</p> <p>Also, you should use the constants View.VISIBLE and View.GONE instead of 0, 8.</p> |
36,010,623 | 0 | <p>Use AuthOozieClient and set system user.</p> <pre><code>OozieClient oc = new AuthOozieClient(OOZIE_URL); System.setProperty("user.name", userName); client.kill(jobId); </code></pre> |
32,056,796 | 0 | <p>First add <a href="https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem" rel="nofollow">this</a> certificate via script in this folder: {rubyfolder}\lib\ruby\2.1.0\rubygems\ssl_certs</p> |
307,889 | 0 | <p>Of course you can write a makefile by hand. A quick googling shows LOTS of tutorials. <a href="http://mrbook.org/tutorials/make/" rel="nofollow noreferrer">This one</a> looks promising.</p> <p>For the cliffs notes version, the example boils down this:</p> <pre><code>CC=g++ CFLAGS=-c -Wall LDFLAGS= SOURCES=main.cpp hello.cpp OBJECTS=$(SOURCES:.cpp=.o) EXECUTABLE=hello all: $(SOURCES) $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) -o $@ .cpp.o: $(CC) $(CFLAGS) $< -o $@ </code></pre> |
33,587,341 | 0 | Problems rendering output in nodejs from a neo4j server <p>I'm pretty sure this is really simple but I thought I should ask on here. I'm creating a function in nodejs that looks for a user in a neo4j server then renders that or outputs that onto the webpage.I am able to query the neo4j sever and output that to the console fine but I do not know how to output that info to the webpage. /** * GET / * Neo4j Graph page. */</p> <pre><code>exports.getGraph = function(req, res) { res.render('graph', { title: 'Graph', user: User }); }; /** * GET / * Get user from neo4j */ var neo4j = require('neo4j'); var db = new neo4j.GraphDatabase('http://neo4j:password@localhost:7474'); exports.getNeoUser = function (req, res){ db.cypher({ query: 'MATCH (user:User {email: {email}}) RETURN user', params: { email: '[email protected]', }, }, callback); function callback(err, results) { if (err) throw err; var result = results[0]; if (!result) { console.log('No user found'); } else { var user = result['user']; console.log(user); } } function output(req, res) { res.render('graph', { title: 'Graph', user: User }); }; }; </code></pre> <p>If I leave it like this nothing is rendered although the app won't crash. It starts loading the page but never actually finishes. I think it might be some sort of race condition. I have tried placing this res.render inside the callback function but that results in a method undefined error.</p> |
13,030,685 | 0 | <p>XML is one choice among many for serialization. You can do Java Serializable, XML, JSON, protobuf, or anything else that you'd like. I see no pitfalls.</p> <p>One advantage of XML is you can use JAXB to marshal and unmarshal objects. </p> |
35,364,007 | 0 | getLine doesn't stop <p>My program goes something like</p> <pre><code>main :: IO String main = do putStrLn "input a" a <- getChar putStrLn "input b" b <- getLine putStrLn "input c" c <- getChar return a:c:b </code></pre> <p>Behaviour: I get "input a" printed, and the program waits for me to type a Char and press return. From there, it scrolls past <strong>getLine</strong> without ever letting me input something. How can I make it do what I intend it to?</p> <p>P.S.: There are probably more problems with this code, but let's focus on my present question.</p> |
26,956,900 | 0 | <p>You could simply use grep instead of <code>sed</code> . The reason why i choose <code>grep</code> means, grep is a tool which prints each match in a separate line.</p> <pre><code>grep -oP 'tel:\K.*?(?=;)' file.txt </code></pre> <p><strong>Regular Expression:</strong></p> <pre><code>tel: 'tel:' \K '\K' (resets the starting point of the reported match) .*? matches any character except \n (0 or more times) non-greedily (?= look ahead to see if there is: ; ';' ) end of look-ahead </code></pre> <p><strong>Update:</strong></p> <pre><code>$ cat file tel:02134343, 3646848393; tel:02134343; tel:02134344; $ grep -oP '(?:tel:|(?<!^)\G)\K\d*(?=[^;\n]*;)' file 02134343 3646848393 02134343 02134344 </code></pre> |
12,757,945 | 0 | <p>there's no inbuild function in javascript to get full name of month. You can create an array of month names and use it to get full month name for e.g</p> <pre><code>var m_names = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; d = new Date(); var n = m_names[d.getMonth()]; </code></pre> |
17,532,620 | 0 | <p>The method Add on ColumnMappings collection allows you to map your columns from source table to destination table. The method ColumnMappings.Add accepts four different ways to map your columns.</p> <p>SQLBulkCopy is very much strict on data type of both the columns which you have to consider while adding it to ColumnMappings collection</p> |
2,812,285 | 0 | <p>ok, this is a little hard to explain ... first of all, here is how it works:</p> <pre><code>var test_inst:Number = 2.953; trace(test_inst); trace((test_inst as Object).constructor); </code></pre> <p>to my understanding, this comes from the fact, that the property <code>constructor</code> comes from the ECMAScript-nature of ActionScript 3. It is an ECMAScript property of <code>Object</code> instances and is inherited through <a href="http://en.wikipedia.org/wiki/Prototype-based_programming" rel="nofollow noreferrer">prototypes</a>. From the strictly typed world of ActionScript 3 (which also uses a different inheritance mechanism), this property is thus not available.</p> <p>greetz<br> back2dos</p> |
11,250,654 | 0 | <p>You can solve this problem with the mod(...) function and proper use of brackets and referencing. Consider</p> <ol> <li><code>Mod(x,3)</code> will return zero if your number is a multiple of 3. <code>mod(x,2)</code> will return 1 if x is odd.</li> <li>You can get all your <code>a1</code> or <code>a2</code> values in a vector by typing <code>[a.a1]</code>. Just typing a.a1 gives a mess.</li> <li>You can filter our from your <code>a</code> structure by writing <code>a = a([1 3]);</code> or by writing <code>a = a(logical([1 0 1]))</code> to get the same result.</li> <li>You can use the <code>&</code> for <em>logical and</em> and <code>|</code> for logical or (<a href="http://www.mathworks.com/help/techdoc/ref/logicaloperatorselementwise.html" rel="nofollow">see here</a>).</li> </ol> <p>Altogether, the following code solves your problem:</p> <pre><code>%% Part 1: a= struct('a1',{1,2,3},'a2',{4,5,6}); logForA1isMod3 = (mod([a.a1], 3) == 0); logForA2isMod3 = (mod([a.a2], 3) == 0); a = a(logForA1isMod3 & logForA2isMod3); %% Part 2: a= struct('a1',{1,2,3},'a2',{4,5,6}); logForA1isOdd = (mod([a.a1], 2) == 1); a = a(logForA1isOdd | logForA2isMod3); </code></pre> |
37,529,071 | 0 | jQuery datatable without bootstrap <p>I am using <a href="https://datatables.net" rel="nofollow">jQuery datatable</a> and it is working perfectly fine with basic UI (look and feel).I want to use bootstrap for other UI elements under same page but adding bootstrap css and js links ,datatable grid UI converts into bootstrap theme.I want to keep datatable UI as it ( no bootstrap/default ) and would like to use bootstrap for other UI in same page.What is the way to remove bootstrap theme from datatable only.</p> |
825,455 | 0 | <p>BEA used to have a product named JAM that was used to communicate with mainframe COBOL programs. It included a tool that would read copybooks and generate both corresponding Java POD classes and data conversion code.</p> <p>I don't know if this is still available, I lost track of it when I left BEA.</p> |
13,692,871 | 0 | <p>Do it like that:</p> <pre><code>$(".imgt").click(function() { $("#imgb").prop("src", this.src); }); </code></pre> |
14,078,223 | 0 | <p>Sorry, but no the Win32 API doesn't have such a thing. If you want anything like that, you'll pretty much need some sort of library on top of the API itself (or, of course, you can write it yourself).</p> |
30,238,413 | 0 | <p>Check this link </p> <p><a href="https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html" rel="nofollow">https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html</a></p> <p>Apple suggests that the receipt validation should be done at the server side.</p> <p>The status code received if the subscription has expired is 21006.</p> <hr> <p>For RESTORING PURCHASES</p> <pre><code>- (IBAction)retoreinApp:(id)sender { [[SKPaymentQueue defaultQueue] addTransactionObserver:self]; [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; self.restoringInAppStatusLabel.hidden = NO; } </code></pre> <p>It will call the method after getting restore details :</p> <pre><code>- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue { UIAlertView *alert ; if(queue.transactions.count >0) { for (SKPaymentTransaction *transaction in queue.transactions) { NSString *temp = transaction.payment.productIdentifier; NSLog(@"Product Identifier string is %@",temp); } alert = [[UIAlertView alloc ] initWithTitle:@"Restore Transactions" message:@"All your previous transactions are restored successfully." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; } else { alert = [[UIAlertView alloc ] initWithTitle:@"Restore Transactions" message:@"No transactions in your account to be restored." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; } [alert show]; } </code></pre> |
424,593 | 0 | <p>moo, cow, sheep, baa (in that order).</p> |
30,437,170 | 0 | Generate video with ffmpeg to play using JavaFX <p>People always say to post a new question so I am posting a new question that relates to <a href="http://stackoverflow.com/questions/27354320/generate-video-with-ffmpeg-for-javafx-mediaplayer">Generate video with ffmpeg for JavaFX MediaPlayer</a></p> <p>The images I use can be downloaded from here <a href="https://www.dropbox.com/s/mt8yblhfif113sy/temp.zip?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/mt8yblhfif113sy/temp.zip?dl=0</a>. It is a 2.2GB zip file with 18k images, still uploading, might take some time. The images are slices of a 3D object. I need to display images every 10ms to 20ms. I tried it with Java, but just couldn't get faster than 30ms+ so now I am trying to generate a video that will display images as fast as I want without worrying about memory or CPU power.</p> <p>People will be using my software to slice the objects and then generate the videos to be played later one. The player might run on a cheap laptop or might run on a Raspberry Pi. I need to make sure the slicer will work on any OS and that people don't need to install too much extra stuff to make it work. It would be best if I can just include everything that is needed in the download of the app.</p> <p>I also posted here <a href="https://ffmpeg.zeranoe.com/forum/viewtopic.php?f=15&t=2474&sid=4f7a752f909202fbec19afc9edaf418c" rel="nofollow noreferrer">https://ffmpeg.zeranoe.com/forum/viewtopic.php?f=15&t=2474&sid=4f7a752f909202fbec19afc9edaf418c</a></p> <p>I am using Windows 7 and I have VLC installed. The ffmpeg version is</p> <pre><code>ffmpeg version N-72276-gf99fed7 Copyright (c) 2000-2015 the FFmpeg developers built with gcc 4.9.2 (GCC) </code></pre> <p>I also tried the command lines posted on the linked question</p> <p>This line produced the video and JavaFX didn't have any errors</p> <pre><code>ffmpeg -f image2 -r 50 -i "Mandibular hollow 1 micron.gizmofill%d.gizmoslice.jpg" -s 1638x1004 -vcodec mpeg4 -qscale 1 -f mp4 Timelapse.mp4 </code></pre> <p><img src="https://i.stack.imgur.com/AXYW4.png" alt="enter image description here"></p> <p>This line also produced the video, but JavaFX had an error: "Caused by: MediaException: MEDIA_UNSUPPORTED : Unrecognized file signature!"</p> <pre><code>ffmpeg -f image2 -r 50 -i "Mandibular hollow 1 micron.gizmofill%d.gizmoslice.jpg" -s 1920x1080 -vcodec mpeg4 -qscale 1 Timelapse.avi </code></pre> <p><img src="https://i.stack.imgur.com/2Vmps.png" alt="enter image description here"></p> <p>I also tried this two pass encoding I believe. It produced the video, but didn't play</p> <pre><code>ffmpeg -r 50 -i "Mandibular hollow 1 micron.gizmofill%d.gizmoslice.jpg" -s 1638x1004 -r 50 -b:v 1550k -bt 1792k -vcodec libx264 -pass 1 -an combined50.flv && ffmpeg -y -r 50 -i "Mandibular hollow 1 micron.gizmofill%d.gizmoslice.jpg" -s 1638x1004 -r 50 -b:v 1550k -bt 1792k -vcodec libx264 -pass 2 -vpre hq -acodec libfaac -ab 128k combined50.flv </code></pre> <p>This is my JavaFX code. As you can see I tried the Oracle video and that worked fine.</p> <pre><code>public class FXMLDocumentController implements Initializable { @FXML private Label label; @FXML private MediaView mediaView; @FXML private void handleButtonAction(ActionEvent event) { System.out.println("You clicked me!"); // final File f = new File("http://download.oracle.com/otndocs/products/javafx/oow2010-2.flv"); final File f = new File("C:/Users/kobus/Dropbox/JavaProjects/Gizmetor/temp/Timelapse.avi"); // "C:/Users/kobus/Dropbox/JavaProjects/Gizmetor/temp/combined50.avi.flv" // http://download.oracle.com/otndocs/products/javafx/oow2010-2.flv Media media = new Media(f.toURI().toString()); // Media media = new Media("http://download.oracle.com/otndocs/products/javafx/oow2010-2.flv"); MediaPlayer mediaPlayer = new MediaPlayer(media); mediaPlayer.setAutoPlay(true); mediaPlayer.play(); mediaView.setMediaPlayer(mediaPlayer); label.setText("Hello World!"); System.out.println(mediaPlayer.isAutoPlay()); // mediaView } @Override public void initialize(URL url, ResourceBundle rb) { // TODO } } </code></pre> |
25,317,285 | 0 | <p>This is described in the specification:</p> <blockquote> <p>by default, record, union, and struct type definitions called structural types implicitly include compiler-generated declarations for structural equality, hashing, and comparison. These implicit declarations consist of the following for structural equality and hashing</p> </blockquote> <p><strong>8.15.4 Behavior of the Generated CompareTo implementations</strong></p> <blockquote> <p>If T is a union type, invoke Microsoft.FSharp.Core.Operators.compare first on the index of the union cases for the two values, and then on each corresponding field pair of x and y for the data carried by the union case. Return the first non-zero result.</p> </blockquote> |
7,320,674 | 0 | <p>Use a linked server <a href="http://msdn.microsoft.com/en-us/library/ms188279.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms188279.aspx</a></p> |
1,688,200 | 0 | How can I do a MouseOver of exact image shape? <p>The question below is not really a programming question, but more of "how can I do this" question, implementation advice.</p> <p>I have an image of the world map. I can make each continent a separate image.</p> <p>What I want to do is create a hover over feature for each continent. When the users mouse is over the continent - the <strong>EXACT</strong> shape of the continent that is - I want it to change colour.</p> <p>My main question is, how can I reference when the users mouse is over the <strong>exact</strong> shape of the continent? I do not want to use Flash for this, all though I am afraid there is no other way to do this?</p> <p>Thanks all</p> |
33,983,660 | 0 | <p>To change the padding and color you can do this.</p> <p>Add in CSS</p> <pre><code>.btn btn-info btn-lg{ color: green; padding-left: 30px; } </code></pre> |
26,681,383 | 0 | <p>For an object, you'd use <code>get</code>, not <code>getfield</code> (or dynamic access in a loop like you showed).</p> <pre><code>>> h = figure; >> get(h,{'Position','Renderer'}) ans = [1x4 double] 'opengl' </code></pre> <p>This doesn't work for all objects, but for MATLAB graphics objects it does work. To deal with any class, you can use your function, but with a custom cell output instead of <code>varargout</code>:</p> <pre><code>function C = getProps(object,propnames) for p = 1:numel(propnames), C{p} = object.(propnames{p}); end </code></pre> <p>Then inside whatever function you write, you can get a comma-separated list of all properties with <code>C{:}</code>, which will be suitable for a function that expects each property name input as a separate argument (e.g. <code>C = getProps(myObj,propnames); x = myFun(h,C{:})</code>.</p> |
7,758,768 | 0 | <p>Short answer; no.</p> <p>First, Core Data works with objects not raw values like this. </p> <p>Second, a <code>NSFetchedResultsController</code> is designed to return a set of objects that are of the same entity type and potentially separated into sections. What you are describing is a multi-level structure and does not fit into the goal of the <code>NSFetchedResultsController</code>.</p> <h2>Update</h2> <p>If you are just looking to get back a <code>NSArray</code> of <code>XEntity</code> sorted by <code>yProperty</code> without regard to the parent/child relationship within <code>XEntity</code> then you don't need a <code>NSFetchedResultsController</code>. Just create a <code>NSFetchedRequest</code> with the <code>-setEntity:</code> set to <code>XEntity</code> and add a <code>NSSortDescriptor</code> that sorts on <code>yProperty</code> and execute the fetch against the <code>NSManagedObjectContext</code>.</p> <p>If you want to be updated when that data changes then you would want to use a <code>NSFetchedResultsController</code> with that same <code>NSFetchRequest</code>.</p> |
40,576,223 | 0 | How to get a tuple based on list of template templates of variable size in C++? <p>I have created a template class which takes two plain template parameters (like int or double) and have derived several other classes from it:</p> <pre><code>template <typename A, typename B> class IClassBase {...} template <typename B> class Derived1Class : public IClassBase<std::string, B> {...} template <typename B> class Derived2Class : public IClassBase<std::string, B> {...} </code></pre> <p>I need to design a structure which would allow compiler to build a std::tuple based on list of template types and their parameters (B type in code snippet above).</p> <p>So given the list below </p> <pre><code>Derived1Class<int>, Derived1Class<double>, Derived2Class<bool>, Derived2Class<std::string> </code></pre> <p>compiler should infer following tuple:</p> <pre><code>std::tuple<int, double, bool, std::string> </code></pre> <p>Is this even possible, and if so, how it can be done in C++?</p> <p>Thanks in advance)</p> |
19,171,346 | 0 | Create a wordpress page with archives of a category <p>I'm a bit stumped on this one. I'd like to create a page that is an archive of all posts of a certain category - and show excerpts. However, Reading through the Wordpress docs, they say a page cannot be a post or associated with categories.</p> <p>So, I'm now wondering if this is possible or if there is a work around. I'd really like to put this on a page as I'd like to have a custom sidebar as well. Is this possible with a custom page template? Any other ways this can be done that I am not thinking of?</p> <p>Thanks!</p> |
40,546,168 | 0 | <p>The link on the comment is currently broken. Due to the fact that the folder "samples" might change path in the future again, whoever needs can start exploring from the <a href="https://github.com/mono/SkiaSharp" rel="nofollow noreferrer">https://github.com/mono/SkiaSharp</a> page.</p> <p>More information about using SkiaSharp can be found on the <a href="https://developer.xamarin.com/api/namespace/SkiaSharp/" rel="nofollow noreferrer">API documentation online</a></p> <p>For who needs a practical quick start on how to use it here some examples:</p> <p><strong>Getting an SKCanvas</strong></p> <pre><code>using (var surface = SKSurface.Create (width: 640, height: 480, SKColorType.N_32, SKAlphaType.Premul)) { SKCanvas myCanvas = surface.Canvas; // Your drawing code goes here. } </code></pre> <p><strong>Drawing Text</strong></p> <pre><code>// clear the canvas / fill with white canvas.DrawColor (SKColors.White); // set up drawing tools using (var paint = new SKPaint ()) { paint.TextSize = 64.0f; paint.IsAntialias = true; paint.Color = new SKColor (0x42, 0x81, 0xA4); paint.IsStroke = false; // draw the text canvas.DrawText ("Skia", 0.0f, 64.0f, paint); } </code></pre> <p><strong>Drawing Bitmaps</strong></p> <pre><code>Stream fileStream = File.OpenRead ("MyImage.png"); // clear the canvas / fill with white canvas.DrawColor (SKColors.White); // decode the bitmap from the stream using (var stream = new SKManagedStream(fileStream)) using (var bitmap = SKBitmap.Decode(stream)) using (var paint = new SKPaint()) { canvas.DrawBitmap(bitmap, SKRect.Create(Width, Height), paint); } </code></pre> <p><strong>Drawing with Image Filters</strong></p> <pre><code>Stream fileStream = File.OpenRead ("MyImage.png"); // open a stream to an image file // clear the canvas / fill with white canvas.DrawColor (SKColors.White); // decode the bitmap from the stream using (var stream = new SKManagedStream(fileStream)) using (var bitmap = SKBitmap.Decode(stream)) using (var paint = new SKPaint()) { // create the image filter using (var filter = SKImageFilter.CreateBlur(5, 5)) { paint.ImageFilter = filter; // draw the bitmap through the filter canvas.DrawBitmap(bitmap, SKRect.Create(width, height), paint); } } </code></pre> |
20,387,958 | 0 | <p>This works with arbitrary number of dicts:</p> <pre><code>def combine(**kwargs): return { k: { d: kwargs[d][k] for d in kwargs } for k in set.intersection(*map(set, kwargs.values())) } </code></pre> <p>For example:</p> <pre><code>print combine( one={'1': 3, '2': 4, '3':8, '9': 20}, two={'3': 40, '9': 28, '100': 3}, three={'3':14, '9':42}) # {'9': {'one': 20, 'three': 42, 'two': 28}, '3': {'one': 8, 'three': 14, 'two': 40}} </code></pre> |
36,741,279 | 0 | ListView is not displaying anything but is displayed when search view is clicked <p>I have an activity named FriendListActivity which contains 3 tabs namely CHAT ,GROUP and CONTACTS.FriendListActivity contains a viewpager which is being populated through Fragments using FragmentStatePagerAdapter .Now each fragment contains a list view which is being populated using BaseAdapter .</p> <p>Following is the code of SearchView in FriendListActivity :</p> <pre><code> SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() { public boolean onQueryTextChange(String query) { // this is your adapter that will be filtered Log.e("Text", query); PagerAdapter pagerAdapter = (PagerAdapter) viewPager.getAdapter(); for (int i = 0; i < pagerAdapter.getCount(); i++) { Fragment viewPagerFragment = (Fragment) viewPager.getAdapter().instantiateItem(viewPager, i); if (viewPagerFragment != null && viewPagerFragment.isAdded()) { if (viewPagerFragment instanceof ChatFragment) { ChatFragment chatFragment = (ChatFragment) viewPagerFragment; if (chatFragment != null) { chatFragment.beginSearch(query); // Calling the method beginSearch of ChatFragment } } else if (viewPagerFragment instanceof GroupsFragment) { GroupsFragment groupsFragment = (GroupsFragment) viewPagerFragment; if (groupsFragment != null) { groupsFragment.beginSearch(query); // Calling the method beginSearch of GroupsFragment } } else if (viewPagerFragment instanceof ContactsFragment) { ContactsFragment contactsFragment = (ContactsFragment) viewPagerFragment; if (contactsFragment != null) { contactsFragment.beginSearch(query); // Calling the method beginSearch of ContactsFragment } } } } return false; } public boolean onQueryTextSubmit(String query) { //Here u can get the value "query" which is entered in the search box. return false; } }; </code></pre> <p><strong>AdapterFriendList.java</strong></p> <p>The following code is populating the list view of ChatFragment :</p> <pre><code>public class Adapter_FriendsList extends BaseAdapter implements Filterable { private Context context; private List<Bean_Friends> listBeanFriends; private LayoutInflater inflater; private ApiConfiguration apiConfiguration; List<Bean_Friends> mStringFilterList; ValueFilter valueFilter; public Adapter_FriendsList(Context context, List<Bean_Friends> listBeanFriends) { this.context = context; this.listBeanFriends = listBeanFriends; mStringFilterList = listBeanFriends; } @Override public int getCount() { return listBeanFriends.size(); } @Override public Object getItem(int position) { return listBeanFriends.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View view, ViewGroup viewGroup) { Log.e("GetView", "Called"); if (inflater == null) inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (view == null) view = inflater.inflate(R.layout.feed_item_chat_list, null); //Getting Views ImageView img_friend = (ImageView) view.findViewById(R.id.imgFriend); TextView txtNameFriend = (TextView) view.findViewById(R.id.txtNameFriend); // ImageView imgMoreOption = (ImageView) view.findViewById(R.id.imgMoreoption); TextView txtFriendsID = (TextView) view.findViewById(R.id.txtFriendsID); /* imgMoreOption.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // hide the title bar dialog.setContentView(R.layout.more_option); dialog.show(); } });*/ //Setting values in the views //Data source of Adpater is List.At a specific position in the list ,we get Bean_Friends object Bean_Friends bean_friends = listBeanFriends.get(position); //Getting values from Bean_Friends String name = bean_friends.getName(); Log.e("FriendNAmeAD", name); String url = bean_friends.getUrl(); Log.e("urlAD", url); String extension = bean_friends.getExtension(); String friendID = bean_friends.getFriendsID(); //Initializing ApiConfiguration apiConfiguration = new ApiConfiguration(); String api = apiConfiguration.getApi(); String absoluteURL = api + "/" + url + "." + extension; Log.e("AbsoluteURLAD", absoluteURL); Picasso.with(context).load(absoluteURL).error(R.drawable.default_avatar).into(img_friend); //Loading image into the circular Image view using Picasso txtNameFriend.setText(name);//Setting name txtFriendsID.setText(friendID); return view; } public static boolean exists(String URLName) { try { HttpURLConnection.setFollowRedirects(false); // note : you may also need // HttpURLConnection.setInstanceFollowRedirects(false) HttpURLConnection con = (HttpURLConnection) new URL(URLName).openConnection(); con.setRequestMethod("HEAD"); return (con.getResponseCode() == HttpURLConnection.HTTP_OK); } catch (Exception e) { e.printStackTrace(); return false; } } @Override public Filter getFilter() { if (valueFilter == null) { valueFilter = new ValueFilter(); } return valueFilter; } private class ValueFilter extends Filter { @Override protected FilterResults performFiltering(CharSequence constraint) { String str = constraint.toString().toUpperCase(); Log.e("constraint", str); FilterResults results = new FilterResults(); if (constraint != null && constraint.length() > 0) { ArrayList<Bean_Friends> filterList = new ArrayList<Bean_Friends>(); for (int i = 0; i < mStringFilterList.size(); i++) { if ((mStringFilterList.get(i).getName().toUpperCase()) .contains(constraint.toString().toUpperCase())) { Bean_Friends bean_friends = mStringFilterList.get(i); filterList.add(bean_friends); } } results.count = filterList.size(); results.values = filterList; } else { results.count = mStringFilterList.size(); results.values = mStringFilterList; } return results; } @Override protected void publishResults(CharSequence constraint, FilterResults results) { listBeanFriends = (ArrayList<Bean_Friends>) results.values; notifyDataSetChanged(); } } </code></pre> <p>}</p> <p>My problem is that when i click on CHAT tab,nothing is displayed but when i click on SearchView presented on the Activity containing the chat tab,the contents of list view are displayed .I want the contents of CHAT tab to be displayed when the user press of swipe the screen.Please help me to fix the issue.</p> |
13,009,467 | 0 | <pre><code>$send = mail($to, $subject, $message); if(!$send){ echo 'Failed to send!'; } </code></pre> <p>The <a href="http://php.net/manual/en/function.mail.php" rel="nofollow">mail</a> function:</p> <blockquote> <p>Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.</p> </blockquote> |
21,189,394 | 0 | <p>I don think a sheebang line alone would do it.</p> <p>You could try putting in </p> <pre><code>#! /usr/bin/env python2.7 </code></pre> <p>though. - But the thing that really would be consistent for you would be to use virtual python environments through virtualenv.</p> <p>Please, check <a href="http://www.virtualenv.org/en/latest/virtualenv.html" rel="nofollow">http://www.virtualenv.org/en/latest/virtualenv.html</a> - Otherwise you will risk having code running with the 2.7 Python but trying to load python 2.6 modules and libraries, and worse scenarios still.</p> <p>Also, the recommendation for having two same-major-version Python in a system is to keep both in different prefixes, like the system one in /usr, and the other in /opt (/usr/local won't suffice for a clear separation).</p> |
29,073,140 | 0 | <p>I just figured it out. You have to include both the schema AND the catalog. The catalog, in my case, is the database name:</p> <pre><code><table name="TITLE" catalog="hibernatetest" schema="dbo" class="Jeffery_jump"> <primary-key> <generator class="identity"/> <key-column name="id" property="version"/> </primary-key> </table> </code></pre> <p>What's annoying is according to the official hibernate documentation, schema and catalog are optional. Well done, hibernate. Well done.</p> |
23,319,746 | 0 | decorator design pattern violating is-a relationship <p>I have recently started studying about decorator design pattern but I have a query. Decorators implement the same interface as the Component they are trying to decorate. Doesn't this violate the is-a relationship. Moreover since the decorator has the component (through composition) , why is it really required for the decorator to implement the same component interface which the concrete component implements.?</p> <p>Going through the decorator design pattern on Headfirst, it gives me a feeling that decorators can directly implement the component. There is no need to have an abstract class / interface for decorator. </p> <p>I am worries that this could really be a dumb question but help would allow me to have a strong foundation. </p> |
11,111,498 | 0 | <p>As explained on the NSView reference page, the z-order of a view's subview is given by their oder in the view's <code>subviews</code> array. You can insert a new subview relative to the others using <code>-addSubview:positioned:relativeTo:</code>, and you can reorder the existing subviews by getting the <code>subviews</code> property, reordering the views therein as you like, and then calling <code>-setSubviews:</code> to set the new order.</p> <p>Specifically, the docs say:</p> <blockquote> <p>The order of the subviews may be considered as being back-to-front, but this does not imply invalidation and drawing behavior.</p> </blockquote> |
20,928,108 | 0 | making text bold via code <p>I have the code:</p> <pre><code>label5.Font = new Font(label5.Font.Name, 12, FontStyle.Underline); </code></pre> <p>..But I can't figure how to change it to bold as well. How can I do that?</p> |
3,622,066 | 0 | <p>e to the power of something imaginary can be computed with sin and cos waves<br> <img src="https://i.stack.imgur.com/uqQ3i.png" alt="http://upload.wikimedia.org/math/4/0/d/40d9a3c31c4a52cb551dd4470b602d82.png"><br> <a href="http://en.wikipedia.org/wiki/E_(mathematical_constant)" rel="nofollow noreferrer">wikipedia entry for e</a></p> <p>and vector exponentiation has it's own page as well<br> <img src="https://i.stack.imgur.com/MAW0W.png" alt="alt text"><br> <a href="http://en.wikipedia.org/wiki/Matrix_exponential" rel="nofollow noreferrer">matrix exponential</a></p> |
23,507,112 | 0 | Get the empty page count using iText Java <p>I have 800 pages PDF file, I want to get the count how many pages has been blank, among these 800 pages</p> |
7,948,389 | 0 | Parsing XSD Schema with XSOM in Java. How to access element and complex types <p>I’m having a lot of difficuly parsing an .XSD file with a XSOM in Java. I have two .XSD files one defines a calendar and the second the global types. I'd like to be able to read the calendar file and determine that:</p> <p>calendar has 3 properties</p> <ul> <li>Valid is an ENUM called eYN</li> <li>Cal is a String</li> <li>Status is a ENUM called eSTATUS</li> </ul> <p><strong>Calendar.xsd</strong></p> <pre><code><?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gtypes="http://www.btec.com/gtypes" elementFormDefault="qualified"> <xs:import namespace="http://www.btec.com/gtypes" schemaLocation="gtypes.xsd"/> <xs:element name="CALENDAR"> <xs:complexType> <xs:sequence> <xs:element name="Valid" type="eYN" minOccurs="0"/> <xs:element name="Cal" minOccurs="0"> <xs:complexType> <xs:simpleContent> <xs:extension base="gtypes:STRING"> <xs:attribute name="IsKey" type="xs:string" fixed="Y"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element name="Status" type="eSTATUS" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="eSTATUS"> <xs:simpleContent> <xs:extension base="gtypes:ENUM"/> </xs:simpleContent> </xs:complexType> <xs:complexType name="eYN"> <xs:simpleContent> <xs:extension base="gtypes:ENUM"/> </xs:simpleContent> </xs:complexType> </code></pre> <p><strong>gtypes.xsd</strong></p> <pre><code><?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.btec.com/gtypes" elementFormDefault="qualified"> <xs:complexType name="ENUM"> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="TYPE" fixed="ENUM"/> <xs:attribute name="derived" use="optional"/> <xs:attribute name="readonly" use="optional"/> <xs:attribute name="required" use="optional"/> </xs:extension> </xs:simpleContent> </xs:complexType> <xs:complexType name="STRING"> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="TYPE" use="optional"/> <xs:attribute name="derived" use="optional"/> <xs:attribute name="readonly" use="optional"/> <xs:attribute name="required" use="optional"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:schema> </code></pre> <p>The code from my attempt to access this information is below. I'm pretty new to Java so any style criticism welcome. </p> <p>I really need to know</p> <ol> <li>How to I access the complex type cal and see that it's a string?</li> <li>How do I access the definition of Status to see it's a enumeration of type eSTATUS <em>emphasized text</em></li> </ol> <p>I've has several attempts to access the right information via ComplexType and Elements and Content. However I'm just don't get it and I cannot find any examples that help. I expect (hope) the best method is (relatively) simple when you know how. So, once again, if anyone could point me in the right direction that would be a great help.</p> <pre><code>xmlfile = "Calendar.xsd" XSOMParser parser = new XSOMParser(); parser.parse(new File(xmlfile)); XSSchemaSet sset = parser.getResult(); XSSchema s = sset.getSchema(1); if (s.getTargetNamespace().equals("")) // this is the ns with all the stuff // in { // try ElementDecls Iterator jtr = s.iterateElementDecls(); while (jtr.hasNext()) { XSElementDecl e = (XSElementDecl) jtr.next(); System.out.print("got ElementDecls " + e.getName()); // ok we've got a CALENDAR.. what next? // not this anyway /* * * XSParticle[] particles = e.asElementDecl() for (final XSParticle p : * particles) { final XSTerm pterm = p.getTerm(); if * (pterm.isElementDecl()) { final XSElementDecl ed = * pterm.asElementDecl(); System.out.println(ed.getName()); } */ } // try all Complex Types in schema Iterator<XSComplexType> ctiter = s.iterateComplexTypes(); while (ctiter.hasNext()) { // this will be a eSTATUS. Lets type and get the extension to // see its a ENUM XSComplexType ct = (XSComplexType) ctiter.next(); String typeName = ct.getName(); System.out.println(typeName + newline); // as Content XSContentType content = ct.getContentType(); // now what? // as Partacle? XSParticle p2 = content.asParticle(); if (null != p2) { System.out.print("We got partical thing !" + newline); // might would be good if we got here but we never do :-( } // try complex type Element Decs List<XSElementDecl> el = ct.getElementDecls(); for (XSElementDecl ed : el) { System.out.print("We got ElementDecl !" + ed.getName() + newline); // would be good if we got here but we never do :-( } Collection<? extends XSAttributeUse> c = ct.getAttributeUses(); Iterator<? extends XSAttributeUse> i = c.iterator(); while (i.hasNext()) { XSAttributeDecl attributeDecl = i.next().getDecl(); System.out.println("type: " + attributeDecl.getType()); System.out.println("name:" + attributeDecl.getName()); } } } </code></pre> |
8,336,241 | 0 | <p>Have you thought instead about using two separate views instead, and have your conditional logic in your controller determine which view to display.</p> |
3,251,117 | 0 | <p>I'd say follow the <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle" rel="nofollow noreferrer">Single Responsibility Principle</a>.</p> <p>What you have is a SportsCard that does nothing on itself. It's just a data container.</p> <pre><code>class SportsCard { protected $_price; protected $_sport; public function __construct($price, $sport) { $this->_price = $price; $this->_sport = $sport; } public function getPrice() { return $this->_price; } public function getSport() { return $this->_sport; } } </code></pre> <p>The SportsCards have to be stored in a CardBook. If you think about a CardBook, then it doesn't do much, except for storing SportsCards (not Pokemon or Magic The Gathering cards), so let's just make it do that:</p> <pre><code>class CardBook extends SplObjectStorage { public function attach($card) { if ($card instanceof SportsCard) { parent::attach($card); } return $this; } public function detach($card) { parent::detach($card); } } </code></pre> <p>While there is nothing wrong with adding Finder Methods to the SportsCard set, you do not want the finder method's logic inside it as well. It is fine as long as you only have</p> <pre><code>public function findByPrice($min, $max); public function findBySport($sport); </code></pre> <p>But the second you also add</p> <pre><code>public function findByPriceAndSport($sport, $min, $max); </code></pre> <p>you will either duplicate code or iterate over the collection twice. Fortunately, PHP offers an elegant solution for filtering collections with Iterators, so let's put the responsibility for filtering into separate classes as well:</p> <pre><code>abstract class CardBookFilterIterator extends FilterIterator { public function __construct($cardBook) { if ($cardBook instanceof CardBook || $cardBook instanceof self) { parent::__construct($cardBook); } else { throw new InvalidArgumentException( 'Expected CardBook or CardBookFilterIterator'); } } } </code></pre> <p>This class merely makes sure the child classes accept only children of itself or CardBooks. This is important because we are accessing methods from SportsCard in actual filters later and because CardBooks can contain only SportsCards, we make sure the iterated elements provide these methods. But let's look at a concrete Filter:</p> <pre><code>class SportCardsBySportFilter extends CardBookFilterIterator { protected $sport = NULL; public function filterBySport($sport) { $this->_sport = $sport; return $this; } public function accept() { return $this->current()->getSport() === $this->_sport; } } </code></pre> <p>FilterIterators work by extending the class and modifying it's accept() method with custom logic. If the method does not return FALSE, the currently iterated item is allowed to pass the filter. Iterators can be stacked, so you add Filter on Filter on top, each caring only for a single piece of filtering, which makes this very maintainable and extensible. Here is the second filter:</p> <pre><code>class SportCardsByPriceFilter extends CardBookFilterIterator { protected $min; protected $max; public function filterByPrice($min = 0, $max = PHP_INT_MAX) { $this->_min = $min; $this->_max = $max; return $this; } public function accept() { return $this->current()->getPrice() > $this->_min && $this->current()->getPrice() < $this->_max; } } </code></pre> <p>No magic here. Just the accept method and the setter for the criteria. Now, to assemble it:</p> <pre><code>$cardBook = new CardBook; $cardBook->attach(new SportsCard('10', 'Baseball')) ->attach(new SportsCard('40', 'Basketball')) ->attach(new SportsCard('50', 'Soccer')) ->attach(new SportsCard('20', 'Rugby')) ->attach(new SportsCard('30', 'Baseball')); $filteredCardBook = new SportCardsBySportFilter($cardBook); $filteredCardBook->setFilterBySport('Baseball'); $filteredCardBook = new SportCardsByPriceFilter($filteredCardBook); $filteredCardBook->filterByPrice(20); print_r( iterator_to_array($filteredCardBook) ); </code></pre> <p>And this will give:</p> <pre><code>Array ( [4] => SportsCard Object ( [_price:protected] => 30 [_sport:protected] => Baseball ) ) </code></pre> <p>Combining filters from inside the CardBook is a breeze now. No Code duplication or double iteration anymore. Whether you keep the Finder Methods inside the CardBook or in a CardBookFinder that you can pass CardBooks into is up to you.</p> <pre><code>class CardBookFinder { protected $_filterSet; protected $_cardBook; public function __construct(CardBook $cardBook) { $this->_cardBook = $this->_filterSet = $cardBook; } public function getFilterSet() { return $this->_filterSet; } public function resetFilterSet() { return $this->_filterSet = $this->_cardBook; } </code></pre> <p>These methods just make sure you can start new FilterSets and that you have a CardBook inside the Finder before using one of the finder methods:</p> <pre><code> public function findBySport($sport) { $this->_filterSet = new SportCardsBySportFilter($this->getFilterSet()); $this->_filterSet->filterBySport($sport); return $this->_filterSet; } public function findByPrice($min, $max) { $this->_filterSet = new SportCardsByPriceFilter($this->getFilterSet()); $this->_filterSet->filterByPrice(20); return $this->_filterSet; } public function findBySportAndPrice($sport, $min, $max) { $this->findBySport($sport); $this->_filterSet = $this->findByPrice($min, $max); return $this->_filterSet; } public function countBySportAndPrice($sport, $min, $max) { return iterator_count( $this->findBySportAndPrice($sport, $min, $max)); } } </code></pre> <p>And there you go</p> <pre><code>$cardBookFinder = new CardBookFinder($cardBook); echo $cardBookFinder->countBySportAndPrice('Baseball', 20, 100); $cardBookFinder->resetFilterSet(); foreach($cardBookFinder->findBySport('Baseball') as $card) { echo "{$card->getSport()} - {$card->getPrice()}"; } </code></pre> <p>Feel free to adapt and improve for your own CardBook.</p> |
5,942,149 | 0 | <p>You can build using your existing makefiles and create a wrapper project with a custom target with a 'Run Script' build phase that just calls down to your makefile. This means that you'll also be able to use the debugger, but you probably won't get the full benefit of the editor with autocompletion etc.</p> |
5,144,696 | 0 | Extract information from org.apache.cxf.binding.soap.SoapMessage <p>Is there a way to get the soap action from an instance of <code>org.apache.cxf.binding.soap.SoapMessage</code> ?</p> <p>I am writing an Interceptor which will log the incoming and outgoing messages to/from my CXF service, and as part of this it would be useful to include the specific soap action being requested. I've been able to extact useful information from the Soap header using <code>message.getHeader(name)</code> and just need the Soap action to complete the log.</p> <p>Thanks</p> |
12,686,965 | 0 | Primefaces PIE chart animation <p>Is there any way to animate primefaces <code>PieChart</code>. I searched all attributes but unable to find that How Can I animate it? Actually I want that Chart should draw in slow motion. Any help would be greatly appreciated</p> |
10,831,435 | 0 | <p>you could use jQuery to remove the title attribute like so...</p> <pre><code>$(document).ready(function() { $('[title]').removeAttr('title'); }); </code></pre> |
14,624,771 | 0 | <p>There is no reason to use a global variable, you can declare the variable in the main() then give a reference to that variable to the functions that use it</p> <pre><code>bool load(node** root, const char* dictionary); bool check(node* root, const char* word); int main() { node* root = NULL; load(&root, dictionary); ... if ( check(node,word) ) { ... } } </code></pre> |
15,844,099 | 0 | Can we have a mixed-type matrix in Matlab...and how? <p>I'm trying to write a function with a matrix (specifically a matrix) as the output, the rows of which show a double-type variable and a binary 'status'. For no real reason and just out of curiosity, I wonder if there is a way to have the rows to have different types.</p> <p>Many Thanks</p> |
17,443,682 | 0 | How to auto refresh list of session array items on submit? <p>I am working on a school comparing website. For this I need a plugin that handles that function. I save session data as school IDs so it can be passed on in the comparing table after choosing the schools.</p> <p>Tasks that I have trouble with:</p> <ol> <li>"Add button" - add post/school ID to session array - $_SESSION['schools']</li> <li>Dashboard at the top - echo $_SESSION['schools'] values (just for user experience list the schools that are currently in the list)</li> <li>when "Add button" is pressed update the dashboard list automaticly. Preferably not the whole page.</li> </ol> <p>My attempt so far:</p> <p>First of all I have I commented PHP form action:</p> <pre><code> <?php session_start(); $schools = array('post_id'); //If form not submitted, display form. if (!isset($_POST['submit_school'])){ //If form submitted, process input. } else { //Retrieve established school array. $schools=($_POST['school']); //Convert user input string into an array. $added=explode(',',$_POST['added']); //Add to the established array. array_splice($schools, count($schools), 0, $added); //This could also be written $schools=array_merge($schools, $added); } $_SESSION['schools'] = $schools; ?> </code></pre> <p>Next up is the form itself:</p> <pre><code> <form method="post" action="http://henrijeret.ee/7788/temp_add_button.php" id="add_school"> <input type="hidden" name="added" value="Value" size="80" /> <?php //Send current school array as hidden form data. foreach ($schools as $s){ echo "<input type=\"hidden\" name=\"school[]\" value=\"$s\" />\n"; } ?> <input type="submit" name="submit_school" value="Lisa võrdlusesse" /> </form> </code></pre> <p>And for the dashboard I use:</p> <pre><code> <?php foreach($_SESSION['schools'] as $key => $value){ // and print out the values echo 'The value of $_SESSION['."'".$key."'".'] is '."'".$value."'".' <br />'; } ?> </code></pre> <p>This is just a prototype to get my head wrapper around the task ahead of me...</p> <p><strong>Problems</strong> Something does not feel right.. :P</p> <p>When I submit the form, then the first change is not made. When I press it the second time, then it will update the the list leaving out the very last string. When refreshing then whole page, then the last one pops up</p> <p>I very appriciate the advice on this long topic.. Maby I do not know where to look, but I am a little stuck with searching a solution..</p> <p>Link to my running code <a href="http://henrijeret.ee/7788/" rel="nofollow">http://henrijeret.ee/7788/</a></p> |
19,624,433 | 0 | <p>There are several compilation errors in your example including a malformed lambda expression, mismatched parentheses, incorrect identitfiers (<code>SelectItem</code> is not a property, I'm assuming you mean <code>SelectedItem</code> not <code>SelectedItems</code>), and incorrect indentation following the <code>let feed</code> binding. </p> <p>Below is a simplified example that works as you intended. The selected item in the top ListBox is put into the bottom ListBox when the user hits Enter.</p> <pre><code>open System open System.Windows open System.Windows.Controls open System.Windows.Input [<EntryPoint>] [<STAThread>] let main argv = let panel = new DockPanel() let listBox = new ListBox() for i in [| 1 .. 10 |] do listBox.Items.Add i |> ignore DockPanel.SetDock(listBox, Dock.Top) let listBox2 = new ListBox(Height = Double.NaN) panel.Children.Add listBox |> ignore panel.Children.Add listBox2 |> ignore listBox.KeyUp |> Event.filter (fun e -> listBox.SelectedItems.Count > 0) |> Event.filter (fun e -> e.Key = Key.Enter) |> Event.add (fun e -> let i = unbox<int> listBox.SelectedItem listBox2.Items.Add(i) |> ignore) let win = new Window(Content = panel) let application = new Application() application.Run(win) |> ignore 0 </code></pre> |
20,133,232 | 0 | <p>Ahh! Google are locating you by GEO-IP or similar and redirecting you to your local google mirror. </p> <p>See: <a href="http://webapps.stackexchange.com/questions/46591/what-does-gws-rd-cr-in-the-url-indicate">http://webapps.stackexchange.com/questions/46591/what-does-gws-rd-cr-in-the-url-indicate</a></p> <p>So as they're redirecting you the 302 code is correct.</p> <p>Try using the URL: <a href="https://www.google.com/ncr" rel="nofollow">https://www.google.com/ncr</a> (ncr standing for No Country Redirect) and see how you go.</p> |
19,435,060 | 0 | <p>It looks like Tattletale was not able to read my war. It may be because it was created for Tomcat 7.</p> <p>I exploded the war to a directory with the "jar xvf" command and reran the same command on that folder:</p> <pre><code>java -Xmx512m -jar tattletale.jar myapp report </code></pre> <p>This created all of the reports. I was most interested in the "unused jar" report, and I can see that it is incorrectly reporting some jars as unused, but I have gotten past my initial hurdle.</p> |
17,969,272 | 0 | Dynamic rule validation persistence between validator calls <p>I've came across this problem a few times, but could never find a solution, only work arounds.</p> <p>Lets say I have multiple 10 jobs, but depending on the answers given the validation rules are different.</p> <pre><code>foreach($jobs as $job){ if(!$this->Job->validates()){ echo 'Oh no, it didn't validate'; } } </code></pre> <p>The main problem I'm finding is if I set a rule that was triggered only by the first job.</p> <pre><code>if($this->data['Job']['type'] == 'special'){ $this->validator()->add('special_field', 'notEmpty', array( 'rule' => array('notEmpty'), 'message' => 'Please provide data' )); } </code></pre> <p>It would also apply to the other 9. So the rules are persistent between calls. So can could remove the rule if it exists.</p> <pre><code>if($this->data['Job']['type'] == 'special'){ $this->validator()->add('special_field', 'notEmpty', array( 'rule' => array('notEmpty'), 'message' => 'Please provide data' )); }else{ $this->validator()->remove('special_field', 'notEmpty'); } </code></pre> <p>But if the rule doesn't exist when it tries to remove it a Fatal Error is thrown.</p> <p>Is there any way to check a rule exists before I remove it or a way to clear dynamic rules at the start of beforeValidate?</p> |
16,251,756 | 0 | <p>Database is meant for data not files! I have come across many situation where many prefer to store it to database, be it mangodb or others. Logically that's not worth. </p> <p>Your question "is it worth of programming effort?"; seriously no if you are doing once in a while. It takes a lot of effort to put things in database. However if you are a developer working on it frequently once you are get used to you, you will do it even if its not worth to do so :) </p> <p>I vote for you to go for file system storage for files and not database. And for difficulties of no. of files, you will find a way to resolve it for sure. </p> |
7,154,858 | 0 | How can I find what font was actually used for my CreateFont call? <p>In Windows, the <a href="http://msdn.microsoft.com/en-us/library/dd183500%28v=vs.85%29.aspx"><code>CreateFontIndirect()</code></a> call can silently substitute compatible fonts if the requested font is not requested. The <a href="http://msdn.microsoft.com/en-us/library/dd144904%28v=vs.85%29.aspx"><code>GetObject()</code></a> call does not reflect this substitution; it returns the same <code>LOGFONT</code> passed in. How can I find what font was <em>actually</em> created? Alternately, how can I force Windows to only return the exact font requested?</p> |
39,118,028 | 0 | <p>I didn't like any of the provided answers as they all clutter the global scope with the <code>isDisabled</code> variable, why not do it this way instead?</p> <pre><code><button type="submit" ng-click="disableButton($event)">Submit</button> </code></pre> <p>.</p> <pre><code>$scope.disableButton = function($event) { $event.currentTarget.disabled = true; }; </code></pre> <hr> <p>if if you need to submit a form before the disable. </p> <p><strong>this code is not tested</strong></p> <pre><code><form ng-submit="disableFormSubmitButton($event)"> <button type="submit">Submit</button> </form> </code></pre> <p>.</p> <pre><code>$scope.disableFormSubmitButton = function($event) { $($event).find('[type=submit]').prop('disabled',true); }; </code></pre> |
26,067,295 | 0 | <p>You can simple add</p> <pre><code><key>MinimumOSVersion</key> <string>6.0</string> </code></pre> <p>into your AppName-app.xml manifest into "InfoAdditions" section.</p> <p>This was the first thing I've tried. But this didn't help me to get rid of this error...</p> <p>UPD: Just found <a href="http://community.phonegap.com/nitobi/topics/error-itms-9000-invalid-bundle-the-bundle-my-app-app-does-not-support-the-minimum-os-version-specified-in-the-56qwo">here</a>:</p> <blockquote> <p>Hi,everyone. </p> <p>I have the same warning too. But I was just resolved. </p> <p>As a result of the update to the latest version of Mac OSX(10.9.5) that is installed in the Application loader, it came to success. </p> <p>I don't know this reason. Please try.</p> </blockquote> <p>Can anybody check if this really helps? Also it would be good to check both cases - with default MinimumOSVersion and with set to 6.0 (for example).</p> |
18,279,623 | 0 | <p>You have quite a number of formatting erros in your code!</p> <ul> <li>Declarations can't be inline with selector.</li> <li>There should be at least one space in every declaration immediately after the colon, otherwise it's treated as pseudoclass.</li> <li>A media block starts with a <code>@</code>, not <code>$</code>. <code>$</code> is for variables.</li> <li>Rules inside media blocks should be properly nested.</li> </ul> <p>Here's your code properly formatted:</p> <pre><code>.center text-align: center .right text-align: right .top vertical-align: top .middle vertical-align: middle @media (min-width: 950px) .row max-width: 980px @media (max-width: 900px) .row max-width: 760px .logo width: 300px </code></pre> |
782,494 | 0 | <p>Some more fair questions might be:</p> <p>Are new repositories being set up more in SVN or CVS?</p> <p>Are repositories changing more from CVS to SVN or the reverse?</p> <p>The overwhelming answers, as far as I can tell, are that many more new repositories use SVN than CVS, and the migration is all from CVS to SVN.</p> <p>There are arguments for keeping CVS if you already have it, but for virtually any other case I'd recommend SVN over CVS, and so would most of the people who use either heavily.</p> |
32,124,098 | 0 | rails-api nested attributes for a polymorphic association <p>I have a polymorphic association like so:</p> <pre><code>class Client < ActiveRecord::Base belongs_to :contractable, :polymorphic => true end class Individual < ActiveRecord::Base has_many :clients, :as => :contractable end class Business < ActiveRecord::Base has_many :clients, :as => :contractable end </code></pre> <p>If I want to send a POST to my controller for clients (<code>POST /clients</code>), when I send the JSON in the request body, how do I specify to create either an individual OR a business and set the association properly?</p> <p>Ex JSON (not working):</p> <pre><code>{ "client": { "name": "Person", "contractable": { "age": 50 } } } </code></pre> <p>Also, how do I tell strong_params to allow this to happen?</p> |
7,893,291 | 0 | SQLite Select Statement - Where two conditions are met? <p>Can someone please correct my select statement, the below works selecting everything from table 'games' where 'genre=fps'.</p> <pre><code>tx.executeSql('SELECT * FROM games WHERE genre=fps', [], renderResults); </code></pre> <p>I don't know how to, or if it is possible to expand upon this to to select everything where 'genre=fps' and 'decade=90' - something like this:</p> <pre><code>tx.executeSql('SELECT * FROM games WHERE genre=fps AND decade=90', [], renderResults); </code></pre> <p>or</p> <pre><code>tx.executeSql('SELECT * FROM games WHERE genre=fps AND WHERE decade=90', [], renderResults); </code></pre> <p>Is the above possible? This is probably really straightforward but I cant find any examples or tutorials to follow.</p> <p>Any help would be great.</p> <p>Thanks</p> |
23,258,240 | 0 | <p>I see "duck typing" more as a programming style, whereas "structural typing" is a type system feature.</p> <p>Structural typing refers to the ability of the type system to <strong>express</strong> types that include all values that have certain structural properties.</p> <p>Duck typing refers to writing code that just uses the features of values that it is passed that are actually needed for the job at hand, without imposing any other constraints.</p> <p>So I could <em>use</em> structural types to code in a duck typing style, by formally declaring my "duck types" as structural types. But I could also use structural types <em>without</em> "doing duck typing". For example, if I write interfaces to a bunch of related functions/methods/procedures/predicates/classes/whatever by declaring and naming a common structural type and then using that everywhere, it's very likely that some of the code units don't need <em>all</em> of the features of the structural type, and so I have unnecessarily constrained some of them to reject values on which they could theoretically work correctly.</p> <p>So while I can see how there is common ground, I don't think duck typing subsumes structural typing. The way I think about them, duck typing isn't even a thing that might have been able to subsume structural typing, because they're not the same kind of thing. Thinking of duck typing in dynamic languages as just "implicit, unchecked structural types" is missing something, IMHO. Duck typing is a coding style you choose to use or not, not just a technical feature of a programming language.</p> <p>For example, it's possible to use <code>isinstance</code> checks in Python to fake OO-style "class-or-subclass" type constraints. It's also possible to check for particular attributes and methods, to fake structural type constraints (you could even put the checks in an external function, thus effectively getting a named structural type!). I would claim that neither of these options is exemplifying duck typing (unless the structural types are quite fine grained and kept in close sync with the code checking for them).</p> |
21,104,231 | 0 | <p>Your "standard Ubuntu terminal" probably supports xterm escape codes: <a href="http://invisible-island.net/xterm/ctlseqs/ctlseqs.html" rel="nofollow">http://invisible-island.net/xterm/ctlseqs/ctlseqs.html</a></p> <p>See specifically:</p> <blockquote> <p>CSI P s ; P s ; P s t P s = 1 9 → Report the size of the screen in characters. Result is CSI 9 ; height ; width t</p> </blockquote> <p>...and...</p> <blockquote> <p>ESC Y P s P s Move the cursor to given row and column.</p> </blockquote> <p>"CSI" is explained at <a href="http://en.wikipedia.org/wiki/ANSI_escape_code" rel="nofollow">http://en.wikipedia.org/wiki/ANSI_escape_code</a></p> |
26,883,650 | 0 | Clean HTML table with Reshape2 <p>New user of R. Can't think how to even ask the question. I scraped a webpage for HTML tables. Generally, everything went well, except for one table. Instead of there being 7 separate tables, everything got collapsed into 1 table, with the column name and the value for the first table being two separate columns, and all the other tables being rows. The results is a table with something like this: </p> <pre><code>df <- data.frame(is_employed = c("Hobbies", "Has Previous Experience"), false = c("squash", "false")) </code></pre> <p>Obviously, I need to have the rows (and the column name) in the first column as their own columns, with the item in the second column as their values, preferably with underscores in the columns names. I tried: </p> <pre><code>df <- dcast(df, ~is_employed, value.var = "false") </code></pre> <p>But got an error message. Then I thought to add another column, as such:</p> <pre><code>df2 <- data.frame(number = c(1, 2), is_employed = c("Hobbies", "Has Previous Experience"), false = c("squash", "false")) </code></pre> <p>then I tried </p> <pre><code>df3 <- dcast(df2, number ~is_employed, value.var="false") </code></pre> <p>That placed the values in the first columns as their own columns, but produced two rows (instead of 1), with NAs. I'm sure this is really basic, but I can't figure it out.</p> <p>On edit: I think this gives me what I want, but I'm away from my computer so I can't confirm:</p> <pre><code>library("dplyr") library("tidyr") mat <- as.matrix(df) mat <- rbind(colnames(mat), mat) colnames(mat) <- c("variable", "value") df2 <- as.data.frame(mat) df3 <- df2 %>% mutate(n = 1) %>% spread(variable, value) %>% select(-n) </code></pre> <p>I need to add <code>n</code> or I get NAs, but I don't like it.</p> |
37,660,127 | 0 | <p>You can explicitly deal with larger numbers, even on 32 bit devices, if you explicitly specify <code>UInt64</code> or <code>Int64</code> (unsigned, and signed, respectively).</p> |
12,852,914 | 0 | <p><strong>Update :</strong> </p> <p>Zend Framework new release added FlashMessenger View Helper , found in path <code>/library/Zend/View/Helper/FlashMessenger.php</code></p> <p><a href="https://github.com/zendframework/zf2/blob/master/library/Zend/View/Helper/FlashMessenger.php">FlashMessenger.php</a></p> <hr> <p><strong>Old answer :</strong></p> <p>I have written a custom view helper, for printing flash messages </p> <p>In /module/Application/Module.php</p> <pre><code>public function getViewHelperConfig() { return array( 'factories' => array( 'flashMessage' => function($sm) { $flashmessenger = $sm->getServiceLocator() ->get('ControllerPluginManager') ->get('flashmessenger'); $message = new \My\View\Helper\FlashMessages( ) ; $message->setFlashMessenger( $flashmessenger ); return $message ; } ), ); } </code></pre> <p>Create a custom view helper in /library/My/View/Helper/FlashMessages.php</p> <pre><code>namespace My\View\Helper; use Zend\View\Helper\AbstractHelper; class FlashMessages extends AbstractHelper { protected $flashMessenger; public function setFlashMessenger( $flashMessenger ) { $this->flashMessenger = $flashMessenger ; } public function __invoke( ) { $namespaces = array( 'error' ,'success', 'info','warning' ); // messages as string $messageString = ''; foreach ( $namespaces as $ns ) { $this->flashMessenger->setNamespace( $ns ); $messages = array_merge( $this->flashMessenger->getMessages(), $this->flashMessenger->getCurrentMessages() ); if ( ! $messages ) continue; $messageString .= "<div class='$ns'>" . implode( '<br />', $messages ) .'</div>'; } return $messageString ; } } </code></pre> <p>then simple call from layout.phtml , or your view.phtml</p> <pre><code>echo $this->flashMessage(); </code></pre> <p>Let me show example of controller action </p> <pre><code>public function testFlashAction() { //set flash message $this->flashMessenger()->setNamespace('warning') ->addMessage('Mail sending failed!'); //set flash message $this->flashMessenger()->setNamespace('success') ->addMessage('Data added successfully'); // redirect to home page return $this->redirect()->toUrl('/'); } </code></pre> <p>In home page, it prints</p> <pre><code><div class="success">Data added successfully</div> <div class="warning">Mail sending failed!</div> </code></pre> <p>Hope this will helps !</p> |
6,308,118 | 0 | my javascript cookie works for my show and hide, but doesn't work for my toggle? <p>I have a cookie that remembers if my drop down is hidden or visible or not. Then I added a image to the drop down, and toggling the the photos also, but the cookie doesn't seem to remember what state the toggle is in.</p> <pre><code><script type="text/javascript"> <!-- var state; var stateTog; window.onload = function () { obj = document.getElementById('featured'); state = (state == null) ? 'hide' : state; obj.className = state; document.getElementById('featured-header').onclick = function () { var option = ['tel1', 'tel2']; for (var i = 0; i < option.length; i++) { objTog = document.getElementById(option[i]); objTog.className = (objTog.className == "visible") ? "hidden" : "visible"; } obj.className = (obj.className == 'show') ? 'hide' : 'show'; state = obj.className; stateTog = objTog.className; setCookie(); return false; } } function setCookie() { exp = new Date(); plusMonth = exp.getTime() + (31 * 24 * 60 * 60 * 1000); exp.setTime(plusMonth); document.cookie = 'State=' + state + ';expires=' + exp.toGMTString(); document.cookie = 'StateTog=' + stateTog + ';expires=' + exp.toGMTString(); } function readCookie() { if (document.cookie) { var tmp = document.cookie.split(';')[0]; state = tmp.split('=')[1]; stateTog = tmp.split('=')[1]; } } readCookie(); //--> </script> </code></pre> |
13,788,165 | 0 | Widget runs fine in emulator, Doesn't do anything on device itself <p>I'm trying to develop a widget which is a big miss on the samsung galaxy note 10.1: an S-pen note widget.</p> <p>So far, i've just got the interface, and just one action (which is showing and hiding some buttons). on the emulator it shows everything just fine, but on my note10.1 it just sits on the screen, doing nothing. No crashes, but no functionality either. (nor does it show my toaster messages, which the emulator shows fine as well)</p> <p>the receiver is mentioned in my manifest like so:</p> <pre><code> <receiver android:name="WidgetProvider"> <intent-filter > <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/> <action android:name="org.Note.Widget.ACTION_widgetClick"/> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/note_widget"/> </receiver> </code></pre> <p>i've tried many examples as guidelines for my Java code. This is what i have now:</p> <pre><code>@Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals(CLK)) { ToggleRibbon(context); } else { Toast.makeText(context, "action is: "+intent.getAction(), Toast.LENGTH_LONG).show(); super.onReceive(context, intent); } } static void ToggleRibbon(Context context) { RemoteViews localRemoteViews = BuildUpdate(context); ComponentName localComponentName = new ComponentName(context, WidgetProvider.class); AppWidgetManager.getInstance(context).updateAppWidget(localComponentName, localRemoteViews); } private static RemoteViews BuildUpdate(Context context) { RemoteViews rv = new RemoteViews(context.getPackageName(),R.layout.widget_layout); Intent active = new Intent(context, WidgetProvider.class); active.setAction(CLK); PendingIntent actionPendingIntent = PendingIntent.getBroadcast(context, 0, active, 0); rv.setOnClickPendingIntent(R.id.note_ribbon, actionPendingIntent); if(ShowRibbon) { ShowRibbon = false; rv.setViewVisibility(R.id.note_ribbon, View.INVISIBLE); Toast.makeText(context, "You clicked the Note!! (ribbon invisible)", Toast.LENGTH_LONG).show(); } else { ShowRibbon = true; rv.setViewVisibility(R.id.note_ribbon, View.VISIBLE); Toast.makeText(context, "You clicked the Note!! (ribbon visible)", Toast.LENGTH_LONG).show(); } return rv; } protected PendingIntent getPendingSelfIntent(Context context, String action) { Intent intent = new Intent(context, getClass()); intent.setAction(action); return PendingIntent.getBroadcast(context, 0, intent, 0); } @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { for (int i = 0; i < appWidgetIds.length; ++i) { int appWidgetId = appWidgetIds[i]; //Intent intent = new Intent(context, WidgetProvider.class); //intent.setAction("click"); //PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout); remoteViews.setOnClickPendingIntent(R.id.widget_root, getPendingSelfIntent(context, CLK)); remoteViews.setOnClickPendingIntent(R.id.menu_btn, getPendingSelfIntent(context, "menu click")); //remoteViews.setOnClickPendingIntent(R.id.widget_root, pendingIntent); //remoteViews.setOnClickPendingIntent(R.id.menu_btn, pendingIntent); // update widget appWidgetManager.updateAppWidget(appWidgetId, remoteViews); } super.onUpdate(context, appWidgetManager, appWidgetIds); } </code></pre> <p>My guess is that it will be something stupid i forgot, but i realy hope someone can help me get my widget to do something more than just sit there :P (toaster messages only would help a lot already!)</p> <p>Thanks in advance ;)</p> |
26,524,329 | 0 | Display the required error on the label of input type radio <p><br> I have replaced my radio inputs by some label pictures and set the display of the input to "none;" Now when I'm trying to validate a form without checking the radio inputs, I can't see the chrome "required message" to display, because the input radio is not displayed, how can I make the message appear (only with required attribute) on the labels instead of the input ? <br> Thanks</p> |
8,631,754 | 0 | <p>I can't give you the syntax off the type of my head, but consider a subquery to get the most recent backup date and add this to your WHERE clause of the main query. Then you can loose the ORDER clause as you will get one result (and also loose the COUNT).</p> |
35,563,204 | 0 | mongodb: Schema designs for social networking like app <p>As I can think, We can define Schemas like following:</p> <p><strong>First Approach:</strong></p> <pre><code> var schema = new Schema({ name: { type: String, required: true, trim: true }, acc_conns: {//accepted connection request ids,here connection status is accepted type: [Schema.Types.ObjectId ] }, pnd_conns: {//my pending connection request ids,here connection status is pending type: [Schema.Types.ObjectId ] } }, options); </code></pre> <p>or </p> <p><strong>Second Approach:</strong></p> <pre><code> var schema = new Schema({ name: { type: String, required: true, trim: true }, acc_conns: {//accepted connection request ids,here connection status is accepted type: [Schema.Types.ObjectId ] }, rec_conns: {//received connection request ids,here connection status is pending type: [Schema.Types.ObjectId ] }, sent_conns: {//sent connection request ids,here connection status is pending type: [Schema.Types.ObjectId ] } }, options); </code></pre> <p>I added comments to explain what I'm thinking about these schemas.</p> <p>For example in the first approach If I want to find my pending connections(i.e connection request sent or receieved) I have to use my pending list plus the list of user ids which as user objects contain me in their pending list. </p> <p>So if I use the first approach My query becomes large or more formally I have to use my id as the source for finding my pending connections because I have to look in other user docs for finding who sends me invitation.</p> <p>And In the second approach I'm storing these ids on the user's schema itself. So there is no need to query other documents because each user object contains required information in the sense that he contains the sent invitations , received invitations , accepted invitations. So if one user sent invitation to other he may update his sent list and also another user received list. If I further extend my requirements my queries may look like this as a resource found here:</p> <p><a href="https://gist.github.com/levicook/4132037" rel="nofollow">https://gist.github.com/levicook/4132037</a></p> <p><strong>I want to ask which schema design is better if in addition docs come after some sort of condition checking or say I also want to add pagination on the filtered result?</strong></p> <p><strong>What are the pros and cons of both approach?</strong></p> <p><strong>Do we have another solutions?</strong></p> |
3,750,109 | 0 | How to define and use a system property in Android Instrumentation test? <p>I am trying to use some arguments for an Instrumentation test. I noticed that I can read system properties with <code>System.getProperty()</code> function. So I use setprop command to set a system property. For example: <code>adb shell setprop AP 123</code>. Inside my Test code I try to read this AP property with : </p> <pre><code> tmp = System.getProperty("AP"); Log.d("MyTest","AP Value = " + tmp); </code></pre> <p>Then I use logcat to view this debug message but I get a null value for this property. Any ideas on what could be wrong? Note that I can still read the system property with <code>adb shell getprop AP</code> command.</p> |
14,053,911 | 0 | <p>Fancybox groups galleries together by using the 'rel' attribute on elements targeted with .fancybox(). </p> <p>You can specify multiple galleris by using different 'rel' values.</p> <p>Your gallery will appear in the same order as it is in jQuery's selection. </p> |
4,360,210 | 0 | <p>Look in the project build settings for the <em>Deployment Target</em> setting. This is the lowest version of the SDK that you're interested in supporting. If it's lower than 4.0 then all of the pre-4.0 methods will be stripped out by the compiler (since they won't be available on the devices you're planning to deploy to). Try setting it to 4.0 or later; that should help.</p> |
39,142,592 | 0 | <pre><code>NSLog(@"Show stack trace: %@", [NSThread callStackSymbols]); </code></pre> |
38,514,832 | 0 | Construct a javascript date from a string without timezone (for JqueryUI datepicker) <p>I'm using the jQueryUI Datepicker library and I need to supply it with a date that is dynamically loaded for the min date.</p> <p>I set up my datepicker:</p> <pre><code>$("#thePicker" ).datepicker({ dateFormat: 'yy-mm-dd', showOtherMonths: true, changeMonth: true, changeYear: true, minDate: new Date('2016-04-28'), }); </code></pre> <p>Where '2016-04-28' is a string that could vary when loaded.</p> <p>This though sets the minimum allowable date to April 27, 2016, due to a timezone conversion.</p> <p>How should I construct this new Date for the minDate when I have a string of the format shown above supplied so that no timezone is relevant?</p> |
40,742,626 | 0 | <p>Try this</p> <pre><code><input type='text' value='". $out[$x] ."' name='content[]'> </code></pre> |
15,654,776 | 0 | <p>The problem is in the predicate. It fetches all products without an image. If I download images, the result set for the predicate changes on a subsequent fetch and gets smaller every time. The solution is to process the result set in reverse order. So change:</p> <pre><code>for (NSUInteger offset = 0; offset < numberOfProducts; offset += batchSize) </code></pre> <p>Into:</p> <pre><code>for (NSInteger offset = MAX(numberOfProducts - batchSize, 0); offset > 0; offset -= batchSize) </code></pre> |
16,036,432 | 0 | <p>AFAIK T4CConnection should implement oracle.jdbc.OracleConnection. IMHO you have 2 driver implementation, one on the app server and one in your project dependencies, there must be a classloading issue as the retrieved driver implementation is loaded by the shared class loader and you try to cast it to a class loaded by the webApp class loader.</p> <p>You can ensure that your web-app dependency is the same than the server provided implementation or just exclude the dependency from the web app when packaging it.</p> <p>If you're using maven just set the scope to <code>provided</code>.</p> |
9,978,285 | 0 | <p>Seems both ways, direct URL and Javascript don't allow to use a list of ID's , just checked and verified it today</p> |
7,435,656 | 0 | <p>The first line of the error message is a telltale:</p> <pre><code>freeglut (./lineTest): ERROR: Internal error <FBConfig with necessary capabilities not found> in function fgOpenWindow </code></pre> <p>… it means, that the X11 server the client is connected to doesn't support setting a framebuffer format that's required by OpenGL.</p> <p>The first course of action is using <code>glxinfo</code> to check, what's actually supported. Please run <code>glxinfo</code> as you would your program and post its output here (most likely there's no OpenGL support somewhere in the line). Also execute <code>glxinfo</code> locally, since it is your local machine, that'll do all the OpenGL work.</p> |
3,822,709 | 0 | <p>Note also, each command's exit status is stored in the shell variable $?, which you can check immediately after running the command. A non-zero status indicates failure:</p> <pre><code>my_command if [ $? -eq 0 ] then echo "it worked" else echo "it failed" fi </code></pre> |
23,514,829 | 0 | <p>A hex dump for Android, should be suitable for other platforms as well.</p> <p><code>LOGD()</code>, same as <code>DLOG()</code>, plays the role of <code>printf()</code> because <code>printf()</code> does not work in Android. For platforms other than Android, you may <code>#define DLOG printf</code>.</p> <p><em>dlog.h:</em></p> <pre><code>// Android logging #include <android/log.h> #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG , "~~~~~~", __VA_ARGS__) #define DLOG(...) __android_log_print(ANDROID_LOG_DEBUG , "~~~~~~", __VA_ARGS__) #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR , "~~~~~~", __VA_ARGS__) #define ELOG(...) __android_log_print(ANDROID_LOG_ERROR , "~~~~~~", __VA_ARGS__) #ifdef __cplusplus extern "C" { #endif void log_dump(const void*addr,int len,int linelen); void log_dumpf(const char*fmt,const void*addr,int len,int linelen); #ifdef __cplusplus } #endif </code></pre> <p><em>dump.cpp:</em></p> <pre><code>#include <dlog.h> //#include <alloca.h> inline char hdigit(int n){return "0123456789abcdef"[n&0xf];}; #define LEN_LIMIT 8 #define SUBSTITUTE_CHAR '`' static const char* dumpline(char*dest, int linelen, const char*src, const char*srcend) { if(src>=srcend) { return 0; } int i; unsigned long s = (unsigned long)src; for(i=0; i<8; i++) { dest[i] = hdigit(s>>(28-i*4)); } dest[8] = ' '; dest += 9; for(i=0; i<linelen/4 ; i++) { if(src+i<srcend) { dest[i*3] = hdigit(src[i]>>4); dest[i*3+1] = hdigit(src[i]); dest[i*3+2] = ' '; dest[linelen/4*3+i] = src[i] >= ' ' && src[i] < 0x7f ? src[i] : SUBSTITUTE_CHAR; }else{ dest[i*3] = dest[i*3+1] = dest[i*3+2] = dest[linelen/4*3+i] = ' '; } } return src+i; } void log_dumpf(const char*fmt,const void*addr,int len,int linelen) { #if LEN_LIMIT if(len>linelen*LEN_LIMIT) { len=linelen*LEN_LIMIT; } #endif linelen *= 4; static char _buf[4096]; char*buf = _buf;//(char*)alloca(linelen+1); // alloca() causes the initialization to fail!!!! buf[linelen]=0; const char*start = (char*)addr; const char*cur = start; const char*end = start+len; while(!!(cur = dumpline(buf,linelen,cur,start+len))){DLOG(fmt,buf);} } void log_dump(const void*addr,int len,int linelen) { log_dumpf("%s\n",addr,len,linelen); } </code></pre> <p>Usage example:</p> <pre><code>log_dumpf("args: %s\n", &p, 0x20, 0x10); </code></pre> <p>Output:</p> <pre><code>args: 61efadc4 00 3c 17 01 6d bc 59 61 02 00 00 00 80 ae ef 61 `<``m`Ya```````a args: 61efadd4 00 3c 17 01 00 00 00 00 31 a5 59 61 80 ae ef 61 `<``````1`Ya```a </code></pre> <p><strong>UPDATE:</strong> see <a href="https://github.com/18446744073709551615/reDroid/blob/master/jni/reDroid/dump.cpp" rel="nofollow">dump.cpp</a> and <a href="https://github.com/18446744073709551615/reDroid/blob/master/jni/re_dump.h" rel="nofollow">re_dump.h</a> in <a href="https://github.com/18446744073709551615/reDroid/tree/master/jni" rel="nofollow">reDroid (github)</a>, it includes a recursive dump that checks if a pointer is valid.</p> |
7,352,643 | 0 | <p>You can do that using three possibles methods :</p> <ol> <li><p>Design a workflow that is fired on item creation and which is attached to the list</p></li> <li><p>Create an EventReveiver to handle ItemAdded event, and create the SP group</p></li> <li><p>Modify the new form of the list. I don't recommend this way because if customers are created from another place, the logic won't be fired.</p></li> </ol> <p>Another way to solve such problems, but it requires more background of your need, is to split your data into several site collections, one for each customer. Each site collection can have a "Customer" group (maybe created from a site template), which contains the customer. As each site collections have distinct users and groups, it can avoid cross customer data leaking (due to misconfiguration of authorizations).</p> |
34,973,591 | 0 | mysql multi group sum <p>Below is my payments mysql 5.7.9 table need hlpe to write a query</p> <p>payments</p> <pre><code>|s.no |transaction |order-id |order-item-code|amount-type |amount ------------------------------------------------------------------------------------- |1 |Order |1 |11 |ItemPrice |200 |2 |Order |1 |11 |ItemPrice |100 |3 |Order |1 |11 |ItemFees |-12 |4 |Order |1 |11 |ItemFees |-1.74 |5 |Order |1 |11 |ItemFees |-10 |6 |Order |1 |11 |ItemFees |-1.45 |7 |Order |1 |11 |ItemFees |-4 |8 |Order |1 |11 |ItemFees |-0.58 |9 |Order |1 |22 |ItemPrice |150 |10 |Order |1 |22 |ItemPrice |50 |11 |Order |1 |22 |ItemFees |-12 |12 |Order |1 |22 |ItemFees |-1.74 |13 |Order |1 |22 |ItemFees |-10 |14 |Order |1 |22 |ItemFees |-1.45 |15 |Order |1 |22 |ItemFees |-4 |16 |Order |1 |22 |ItemFees |-0.58 |17 |Ship |1 | |other-transaction|-55 |18 |Ship Tax |1 | |other-transaction|-7.98 |19 |Order |2 |33 |ItemPrice |450 |20 |Order |2 |33 |ItemPrice |150 |21 |Order |2 |33 |ItemFees |-36 |22 |Order |2 |33 |ItemFees |-5.22 |23 |Order |2 |33 |ItemFees |-30 |24 |Order |2 |33 |ItemFees |-4.35 |25 |Order |2 |33 |ItemFees |-12 |26 |Order |2 |33 |ItemFees |-1.74 |27 |Ship |2 | |other-transaction|-55 |28 |Ship Tax |2 | |other-transaction|-7.98 </code></pre> <p>Expected result</p> <pre><code> |order-id |order-item-code |Received --------------------------------------------- |1 |11 |238.74 |1 |22 |138.74 |2 |33 |447.71 </code></pre> <p>Calculation Logic:</p> <p>sum (itemprice per order-item-code) + sum(itemfees per order-item-code) + sum (other-transcation per order-id) / distinct of order-item-id in order-id</p> <p>other transcation is the shipping fee charged on a order, I need to divide the sum of other transcations with no of unique items present in the order. in case of order-id- 1, we have 2 items as only two item id code, in case of order-id -2 we have one item. it is the no of distinct order-item -code present</p> |
12,168,058 | 0 | <p>I think the best option to to have a class method on <code>HighScoresModel</code> that will access a single, shared instance of the model from any object that needs it.</p> <p>This is superior to the other options because no controller is responsible for instantiating the model, and the controllers are not unnecessarily coupled to the app delegate either.</p> <p>As an example:</p> <pre><code>@interface HighScoresModel : NSObject + (HighScoresModel *)sharedHighScoresModel; ... @end @implementation HighScoresModel static HighScoresModel *SharedHighScoresModel; + (HighScoresModel *)sharedHighScoresModel { if (!SharedHighScoresModel) { SharedHighScoresModel = [[HighScoresModel alloc] init]; } return SharedHighScoresModel; } ... @end </code></pre> <p>Hope this helps!</p> |
5,278,216 | 0 | <p>alert() is a method of the window object that cannot interpret HTML tags</p> |
3,540,754 | 0 | php & mysql converting non- to unicode <p>I have characters like these on our web site: Fémnyomó</p> <p>That is a street address, entered in another language (though I do not know which). Here's the db setup:</p> <pre><code>mysql 4.1.2log charset cp1252 West European (latin1) </code></pre> <p>I'm using PHP but without mbstrings() (though I do no string conversions on this address, just echo).</p> <p>If I changed the mysql charset from cp1252 to UTF-8 and made sure I used things like <code>header( 'Content-Type: text/html; charset=UTF-8' );</code> would that improve my situation? Or, is the data hosed because it was saved in the cp1252 charset and there is nothing I can do? The original database was created in 2002 and has been used/expanded since. We've upgraded servers and re-imported dumps but ashamedly I admit to not giving charsets much thought.</p> <p>If I'm hosed, I'll probably just remove the text in those fields but I'd like to support unicode going forward, so if I issue <code>ALTER database_name DEFAULT CHARACTER SET utf8;</code> will that make sure future multibyte encodings are saved correctly, taking at least storage out of the equation (leaving me to worry about PHP)?</p> <p>Thanks -</p> |
36,292,679 | 0 | Command failed due to signal: Segmentation fault: 11 due to TableViewController? <p>In my 'DictionaryTableViewController: UITableViewController' class I define the below variables: </p> <pre><code>var dataObj : [String: AnyObject]! var letters : Int! var currentSection : Int!; var currentRow : Int! </code></pre> <p>In 'viewDidLoad' I have:</p> <pre><code> let jsonUrl = NSBundle.mainBundle().URLForResource("dictionary", withExtension: "json") var data = NSData(contentsOfURL: jsonUrl!) func dataReturn(object: [String: AnyObject]) { dataObj = object letters = object["collection"]!.count } do { let object = try NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments) if let dictionary = object as? [String: AnyObject] { dataReturn(dictionary) } } catch { // Handle Error } </code></pre> <p>This is the basic structure of the JSON file that I am pulling in from NSBundle</p> <pre><code> { "collection": [{ "letter": "A", "words": [{ "word" : "Apple", "definition" : "Tasty fruit" }] },{ "letter": "B", "words": [{ "word" : "Banana", "definition" : "Meh, not bad." }] },{ "letter": "C", "words": [{ "word" : "Carrots", "definition" : "hooock twooo!" }] }] } </code></pre> <p>So now when I go style the tableView cell I believe that is what is causing this error:</p> <blockquote> <p>Command failed due to signal: Segmentation fault: 11</p> <ol> <li>While emitting SIL for 'tableView' at /Users/me/Desktop/.../DictionaryTableViewController.swift:70:14</li> </ol> </blockquote> <p>As a warning I am just getting this issue after updating to xcode 7.3. This issue was not present in 7.2 </p> <p>Line 70 from the where the error says to becoming from reads:</p> <pre><code>Line 70: override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath) //let currentSelection = dataObj["collection"]![indexPath.section]["words"]!![indexPath.row]! let currentSelection = dataObj["collection"]![indexPath.section]["words"]!![indexPath.row]!!! cell.textLabel?.text = currentSelection["word"] as? String cell.detailTextLabel?.text = currentSelection["definition"] as? String return cell } </code></pre> <p>Note: The commented out line in the above code was working correctly in xcode 7.2. Xcode7.3 gave me a syntax error (Ambiguous use of subscript). The code just below the commented out line are my changes that produce no syntax errors. Is this what is causing my issue? I am really at a loss here and can't seem to find an answer. Any help is appreciated! </p> |
3,543,415 | 0 | <p>You're on the right track, but mind that there is a column limit. </p> <ol> <li>In your <code>MEANING</code> table, the <code>key</code> would be a foreign key to the <code>WORD.key</code> value - this allows you to relate to the values in the <code>WORD</code> table without needing them duplicated in the <code>MEANING</code> table.</li> <li>If you make it so <code>MEANING.key</code> is not unique, you can support infinite <code>MEANING.meaning</code> values</li> </ol> <p>Example</p> <h2>WORD</h2> <ul> <li>key (primary key)</li> <li>wordname</li> <li>language</li> <li>POS</li> </ul> <p>Example:</p> <pre><code>key wordname language POS ---------------------------------- 1 'foobar' 'English' idk </code></pre> <h2>MEANING</h2> <ul> <li>key</li> <li>meaning</li> <li>unique constraint on both columns to stop duplicates</li> </ul> <p>Example:</p> <pre><code>key meaning ---------------- 1 'a' 1 'b' </code></pre> <p>If you want order of the meaning values, you'll have to define a column to indicate the order somehow - IE: <code>meaning_id</code></p> |
31,494,564 | 0 | <p>JSON works at EPUB-3 on iBooks. Download test book named "Create Dynamic Text and Footnote by JSON at EPUB-3" : <a href="http://teyid.org/testet/lib/?te=18072015" rel="nofollow">http://teyid.org/testet/lib/?te=18072015</a></p> |
20,940,591 | 0 | <pre><code>case Success(f) => case Failure(e: ExceptionType1) => case Failure(e: ExceptionType2) => case Failure(e) => // other </code></pre> <p>or</p> <pre><code>case Success(f) => case Failure(e) => e match { case e1: ExceptionType1 => case e2: ExceptioNType2 => case _ => } </code></pre> |
27,422,532 | 0 | <p>There was a glitch in handling custom protocols in the redirect URI therefore the error page. This was quickly resolved yesterday evening.</p> |
39,269,187 | 0 | <p>change the field collation to :-</p> <pre><code>utf8_general_ci </code></pre> <p><a href="https://i.stack.imgur.com/hlt7s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hlt7s.png" alt="enter image description here"></a></p> |
19,354,148 | 0 | <p>PS can only show the date because as per PS documentation at MAN page</p> <p>'Only the year will be displayed if the process was not started the same year ps was invoked, or "mmmdd" if it was not started the same day, or "HH:MM" otherwise.'</p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.