pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
13,929,117
0
Use VB Library that made by VB Net in C# <p>Sometimes we meet some code of VB.net that doesn't support on C#, such as Mid, AscW,Asc, Right, Left .. etc so that i have made the Libraries that made by VBnet. well, my question is simple</p> <p><strong>is this going to get any problem? if i'm developing with 2 language of NET?</strong></p>
40,894,719
0
Can search Elasticsearch 5.0 (Windows) using simple query, but prefixed with field name fails (search by example) <p>I am trying to get "search by example" functionality out of ElasticSearch. I have a number of objects which have fields, e.g. name, description, objectID, etc. I want to perform a search where, for example, "name=123" and "description=ABC"</p> <p>Mapping:</p> <pre><code>{ "settings": { "number_of_replicas": 1, "number_of_shards": 3, "refresh_interval": "5s", "index.mapping.total_fields.limit": "500" }, "mappings": { "CFS": { "_routing": { "required": true }, "properties": { "objectId": { "store": true, "type": "keyword", "index": "not_analyzed" }, "name": { "type": "text", "analyzer": "standard" }, "numberOfUpdates": { "type": "long" }, "dateCreated": { "type": "date", "format": "strict_date_optional_time||epoch_millis" }, "lastModified": { "type": "date", "format": "strict_date_optional_time||epoch_millis", "index": "not_analyzed" } } } } </code></pre> <p>}</p> <p>Trying a very simple search, without field name, gives correct result:</p> <p>Request: GET <a href="http://localhost:9200/repository/CFS/_search?routing=CFS&amp;q=CFS3" rel="nofollow noreferrer">http://localhost:9200/repository/CFS/_search?routing=CFS&amp;q=CFS3</a></p> <p>Returns:</p> <pre><code>{ "took": 1, "timed_out": false, "_shards": { "total": 1, "successful": 1, "failed": 0 }, "hits": { "total": 1, "max_score": 0.7831944, "hits": [ { "_index": "repository", "_type": "CFS", "_id": "589a9a62-1e4d-4545-baf9-9cc7bf4d582a", "_score": 0.7831944, "_routing": "CFS", "_source": { "doc": { "name": "CFS3", "description": "CFS3Desc", "objectId": "589a9a62-1e4d-4545-baf9-9cc7bf4d582a", "lastModified": 1480524291530, "dateCreated": 1480524291530 } } } ] } } </code></pre> <p>But trying to prefix with a field name fails (and this happens on all fields, e.g. objectId):</p> <p>Request: GET <a href="http://localhost:9200/repository/CFS/_search?routing=CFS&amp;q=name:CFS3" rel="nofollow noreferrer">http://localhost:9200/repository/CFS/_search?routing=CFS&amp;q=name:CFS3</a></p> <p>Returns:</p> <pre><code>{ "took": 6, "timed_out": false, "_shards": { "total": 1, "successful": 1, "failed": 0 }, "hits": { "total": 0, "max_score": null, "hits": [] } } </code></pre> <p>Eventually I want to do something like:</p> <pre><code>{ "bool" : { "must" : [ { "wildcard" : { "name" : { "wildcard" : "*CFS3*", "boost" : 1.0 } } }, { "wildcard" : { "description" : { "wildcard" : "*CFS3Desc*", "boost" : 1.0 } } } ] } } </code></pre> <p>Maybe related? When I try to use a "multi_match" to do this, I have to prefix my field name with a wildcard, e.g.</p> <pre><code>POST http://localhost:9200/repository/CFS/_search?routing=CFS { "query": { "multi_match" : { "query" : "CFS3", "fields" : ["*name"] } } } </code></pre> <p>If I don't prefix it, it doesn't find anything. I've spent 2 days searching StackOverflow and the ElasticSearch documentation. But these issues don't seem to be mentioned. There's lots about wildcards for search terms, and even mention of wildcards AFTER the field name, but nothing about BEFORE the field name. What piece of information am I missing from the field name, that I need to deal with by specifying a wildcard?</p> <p>I think the types of my fields in the mapping are correct. I'm specifying an analyzer.</p>
11,380,835
0
<pre><code>private ByteArrayInputStream getPhoto() { Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, id); Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY); Cursor cursor = getContentResolver().query(photoUri, new String[] {ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null); if (cursor == null) { return null; } try { if (cursor.moveToFirst()) { byte[] data = cursor.getBlob(0); if (data != null) { return new ByteArrayInputStream(data); } } } finally { cursor.close(); } return null; } </code></pre> <p>This is my code. It is working.</p>
26,682,699
0
Use case for not declaring a function as a prototype of another custom function? <p>I'm trying to get my head around the proper way of declaring js functions within my existing custom objects.</p> <p>E.g. Usually I've done it this way to add functions to my existing object(s):</p> <pre><code>function whateverController() { this.doSomething = function() { } } </code></pre> <p>What is the advantage of doing it the following way?</p> <pre><code>function whateverController() { ...some random code } whateverController.prototype.doSomething = function() { } </code></pre> <p>From what I've been reading the latter example is the optimum way of declaring these functions to avoid having to recreate these functions every single a time I create a new whateverController object.</p> <p>Could someone please provide a good use case though where my former example would be better suited? If at all? Any good reading links would be helpful too!</p> <p>Is the latter method considered standard?</p>
7,453,229
0
<p>it is byDefault set, if you dont want any color then you can set a <strong>transparent</strong> color in xml</p> <pre><code>android:listSelector="#00000000" </code></pre>
9,770,068
0
<p>By looking at the HotSpot code there is a node.hpp/node.cpp that declares a node class without a namespace. <br/> Perhaps there is a collision with the pure virtual functions. <br/> I don't have enough VM knowledge to dig any further...</p>
3,553,244
0
Android OpenGL ES and 2D <p>Well, here's my request. I don't know OpenGL already, and I'm not willing to learn it, I want to learn OpenGL ES directly since I'm targeting my development to android, however. I want to learn OpenGL ES in order to develop my <em>2D</em> games. I chose it for performances purpose (since basic SurfaceView drawing isn't that efficient when it comes to RT games). My question is: where to start? I've spent over a month browsing Google and reading/trying some tutorials/examples I've found anywhere but to be honest, it didn't help much and this is for two reasons:</p> <ol> <li>Almost <em>all</em> the articles/tutorials I've came across are 3D related (I only want to learn how to do my 2D Sprites drawing)</li> <li>There's no base to start from since all the articles targets a specific things like: "How to draw a triangle (with vertices)", "How to create a Mesh"... etc.</li> </ol> <p>I've tried to read some source code too (ex.: replica island) but the codes are too complicated and contains a lot of things that aren't necessary; result: I get lost among 100 .java files with weird class names and stuff.</p> <p>I guess there's no course like the one I'm looking for, but I'll be very glad if somebody could give me some guidelines and some <em>links</em> maybe to learn what I'm up to (only OpenGL ES 2D Sprites rendering! nothing 3D).</p>
11,025,128
0
pl/sql Compare with previous row <p>The goal is to combine Time_a within 10 min interval that has same ID. And group the ID.</p> <pre><code>ID Time_a -&gt; ID ------------ ---------- 1 12:10:00 1 1 12:15:00 2 1 12:20:00 2 2 12:25:00 2 12:35:00 2 02:00:00 </code></pre> <p>It became two '2' because time interval between row5 and row6 is more than 10 min. I was able to combine within 10-min difference, but it doesn't distinguish ID.</p> <pre><code>select ID from( select id, Time_a, min(time) OVER (order by id, time rows between 1 preceding and 1 preceding) prev_t_stamp from dual ) where abs(Time_a-prev_t_stamp)&gt;10/1440 </code></pre>
12,724,893
0
Android AndEngine : sprite.detachSelf() doesnt remove the sprite <p>I'm creating small balloon game. where balloons pop up randomly and disappear after a little while. When i clicked on them those i want to disappear them and show +1 instead of the balloon. When i click on the balloon, i want to deattach the balloon sprite. My problem is when i call sprite.detachSelf() in the code, the sprite just disapears but actually the sprite hasn't being removed. It only becomes invisible. When i click again on that place the balloon appears, even after the balloon has disappear it shows +1. Which means i think the balloon hasn't deattached correctly.</p> <p>Here is my code:</p> <pre><code>@Override protected Scene onCreateScene() { //this.mEngine.registerUpdateHandler(new FPSLogger()); scene = new Scene(); backgroundSprite = new Sprite(0, 0, this.mBackgroundTextureRegion, getVertexBufferObjectManager()); backgroundSprite.setSize(CAMERA_WIDTH, CAMERA_HEIGHT); scene.attachChild(backgroundSprite); scene.unregisterTouchArea(backgroundSprite); text = new Text(0, 0, font, "Score : 00", getVertexBufferObjectManager()); scene.attachChild(text); textTime = new Text(displayMetrics.widthPixels - 220, 0, font, "00 : 60", getVertexBufferObjectManager()); scene.attachChild(textTime); timer = new TimerClock(1, new TimerClock.ITimerCallback() { TimerClock t = timer; public void onTick() { System.out.println("timer inside"); if (time &gt; 0) { time = time - 1; System.out.println("timer inside : " + time); scene.detachChild(textTime); textTime = new Text(displayMetrics.widthPixels - 220, 0, font, "00 : " + time, getVertexBufferObjectManager()); if (time &lt; 10) { textTime.setColor(1, 0, 0); } scene.attachChild(textTime); deleteSpriteSpawnTimeHandler(sprite); } else{ scene.unregisterUpdateHandler(this.t); } } }); this.mEngine.registerUpdateHandler(timer); createSpriteSpawnTimeHandler(); return scene; } private void deleteSpriteSpawnTimeHandler(final IEntity ball) { TimerHandler spriteTimerHandler1; final Engine e = mEngine; this.getEngine().registerUpdateHandler( spriteTimerHandler1 = new TimerHandler(0.5f, true, new ITimerCallback() { @Override public void onTimePassed( final TimerHandler spriteTimerHandler1) { spriteTimerHandler1.reset(); deleteSprite(ball); } })); } private void gameOverSpawnTimeHandler() { TimerHandler spriteTimerHandler1; final Engine e = mEngine; this.getEngine().registerUpdateHandler( spriteTimerHandler1 = new TimerHandler(60, true, new ITimerCallback() { @Override public void onTimePassed( final TimerHandler spriteTimerHandler1) { spriteTimerHandler1.reset(); timeDue = 0; scene.detachChild(textComment); textComment = new Text(CAMERA_WIDTH / 2 - 100, CAMERA_HEIGHT / 2, font, "Game Over...!!!", getVertexBufferObjectManager()); textComment.setColor(1.0f, 0.0f, 0.0f); scene.attachChild(textComment); SharedPreferences myPrefs = getApplicationContext().getSharedPreferences("myPrefs", MODE_WORLD_READABLE); SharedPreferences.Editor prefsEditor = myPrefs.edit(); String score1 = myPrefs.getString("SCORE1", "0"); String score2 = myPrefs.getString("SCORE2", "0"); int scoreInt1 = Integer.parseInt(score1); int scoreInt2 = Integer.parseInt(score2); System.out.println("session in" + score1 + " " + score2); currScore = totalScore; if (currScore &gt; scoreInt1 &amp;&amp; currScore &gt; scoreInt2) { prefsEditor.clear(); prefsEditor.commit(); prefsEditor.putString("SCORE1", String.valueOf(currScore)); prefsEditor.putString("SCORE2", String.valueOf(scoreInt1)); prefsEditor.commit(); } else if (currScore &lt; scoreInt1 &amp;&amp; currScore &gt; scoreInt2) { prefsEditor.clear(); prefsEditor.commit(); prefsEditor.putString("SCORE1", String.valueOf(scoreInt1)); prefsEditor.putString("SCORE2", String.valueOf(currScore)); prefsEditor.commit(); } else { } } })); } private void createSpriteSpawnTimeHandler() { TimerHandler spriteTimerHandler; final Engine e = mEngine; this.getEngine().registerUpdateHandler( spriteTimerHandler = new TimerHandler(0.75f, true, new ITimerCallback() { @Override public void onTimePassed( final TimerHandler spriteTimerHandler) { spriteTimerHandler.reset(); // scene.detachChild(backgroundSprite); // scene.attachChild(backgroundSprite); // Random Position Generator final float xPos = MathUtils.random(50.0f, (CAMERA_WIDTH - 50.0f)); final float yPos = MathUtils.random(75.0f, (CAMERA_HEIGHT - 75.0f)); gameOverSpawnTimeHandler(); if (timeDue &gt; 0) { createSprite(xPos, yPos); }else{ //scene.unregisterUpdateHandler(spriteTimerHandler); } } })); } private void createSpriteTextSpawnTimeHandler() { TimerHandler spriteTimerHandler; final Engine e = mEngine; this.getEngine().registerUpdateHandler( spriteTimerHandler = new TimerHandler(mEffectSpawnDelay, true, new ITimerCallback() { @Override public void onTimePassed( final TimerHandler spriteTimerHandler) { spriteTimerHandler.reset(); if (totalScore &gt; 50 &amp;&amp; totalScore &lt; 60) { textComment = new Text(150, 100, font, "Ohhhh...you are doing good.", getVertexBufferObjectManager()); textComment.setColor(1.0f, 0.0f, 0.0f); scene.attachChild(textComment); } deleteSpriteSpawnTimeHandler(textComment); // e.getScene().detachChild(backgroundSprite); // e.getScene().attachChild(backgroundSprite); } })); } private void createSprite(final float pX, final float pY) { sprite = new Sprite(pX, pY, this.mrball, getVertexBufferObjectManager()) { Engine e = mEngine; TextureRegion gball = mgball; float x = pX; float y = pY; private int score = totalScore; private Text textComment;; @Override public boolean onAreaTouched( org.andengine.input.touch.TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) { if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_DOWN) { this.e.getScene().detachChild(this); if (timeDue &gt; 0) { mBrushDrawingSound.play(); totalScore = totalScore + 1; String score = "Score : " + totalScore; scene.detachChild(text); text = new Text(0, 0, font, score, getVertexBufferObjectManager()); scene.attachChild(text); //sprite.detachSelf(); createSpriteTextSpawnTimeHandler(); textScorePlus = new Text(x, y, font, "+1", getVertexBufferObjectManager()); scene.attachChild(textScorePlus); scene.unregisterTouchArea(textScorePlus); deleteSpriteSpawnTimeHandler(textScorePlus); } } else if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_UP) { } // e.getScene().unregisterTouchArea(sprite); return true; } }; spriteBalloon.add(sprite); sprite.setSize(100, 100); sprite.setAlpha(0.8f); Random randomGenerator = new Random(); red = randomGenerator.nextInt(255); green = randomGenerator.nextInt(255); blue = randomGenerator.nextInt(255); sprite.setColor(red, green, blue); scene.registerTouchArea(sprite); scene.attachChild(sprite); deleteSpriteSpawnTimeHandler(sprite); } private void deleteSprite(IEntity pBall) { IEntity gball = pBall; scene.detachChild(gball);; } </code></pre>
16,710,054
0
<p>I faced this issue couple of days before.</p> <p>Right click your project, Go to properties->Java Build path->Order and Export</p> <p>Check Android Private Library->Click Ok</p> <p>Clean the project and run it.it will work.</p>
12,181,689
0
IllegalStateException while creating a stage in another thread <p>I have a problem with opening one more stage in another thread. No exceptions appears if I'm opening this stage in the same thread.</p> <pre><code>void hashMapDeclaration(){ actions2methods.put("NEW", new Runnable() {@Override public void run() { newNetCreation(); }}); actions2methods.put("LOAD", new Runnable() {@Override public void run() { loadNetState(); }}); ...... //other hashes } HBox buttonBuilder(double spacing,double layoutX,String... bNames){ HBox lBar = new HBox(10); .... //some code for(final String text : bNames){ //in my case text variable value is "NEW" so it should run method newNetCreation Button newButton = new Button(); newButton.setText(text); .... //code newButton.setOnAction(new EventHandler&lt;ActionEvent&gt;() { @Override public void handle(ActionEvent paramT) { Thread t; EventQueue.isDispatchThread(); t = new Thread(actions2methods.get(text)); t.start(); // Start the thread System.out.println("button pressed"); } }); lBar.getChildren().add(newButton); } return lBar; } void newNetCreation(){ final Stage dialogStage = new Stage(); final TextField textField; dialogStage.initOwner(stage); dialogStage.initModality(Modality.WINDOW_MODAL); dialogStage.setFullScreen(false); dialogStage.setResizable(false); dialogStage.setScene(SceneBuilder .create() .fill(Color.web("#dddddd")) .root(textField = TextFieldBuilder .create() .promptText("Enter user name") .prefColumnCount(16) .build() ) .build() ); textField.textProperty().addListener(new ChangeListener() { public void changed(ObservableValue ov, Object oldValue, Object newValue) { System.out.println("TextField text is: " + textField.getText()); } }); dialogStage.show(); System.out.println("new net"); } </code></pre> <p>Method newNetCreation is the one that cause the problem. All actions in my program are store in a HashMap. Method buttonBuilder creates the new thread and should launch methods according to variable value and in my case he must call newNetCreation method, but when he tries, the following exception occurs:</p> <pre><code>Exception in thread "Thread-3" java.lang.IllegalStateException: Not on FX application thread; currentThread = Thread-3 at com.sun.javafx.tk.Toolkit.checkFxUserThread(Unknown Source) at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(Unknown Source) at javafx.stage.Stage.&lt;init&gt;(Unknown Source) at javafx.stage.Stage.&lt;init&gt;(Unknown Source) at projavafx.starterapp.ui.StarterAppMain.newNetCreation(StarterAppMain.java:400) at projavafx.starterapp.ui.StarterAppMain$7.run(StarterAppMain.java:354) at java.lang.Thread.run(Thread.java:722) </code></pre>
18,864,100
0
<p>table:</p> <pre><code>CREATE TABLE MyTable ( _id INT(10) AUTO_INCREMENT, imagePath VARCHAR(50) ); </code></pre> <p>HTML/PHP</p> <pre><code>&lt;img src="&lt;?php echo $row['imagePath'] ?&gt;" /&gt; </code></pre>
15,174,929
0
<p>Right click the server name and choose Activity Montior.</p> <p>Alternatively, you can query the process list with:</p> <pre><code>select * from sys.dm_exec_requests </code></pre> <p>An even better solution is <a href="http://sqlblog.com/files/default.aspx" rel="nofollow"><code>sp_WhoIsActive</code></a> from Adam Machanic, but that might be overkill for your situation.</p>
33,552,505
0
Scanner continuous loop <p>Why isn't my inputScanner blocking after the first input? It goes into a continous loop. Ignore other details of this code.</p> <pre><code>public class Test { public static void main(String[] args) { boolean finished; do { Scanner inputScanner = new Scanner(System.in); finished = inputScanner.hasNext("exit"); boolean validNumber = inputScanner.hasNextDouble(); if (validNumber) { double number = inputScanner.nextDouble(); System.out.print(number); } else if (!finished) { System.out.println("Please try again."); } inputScanner.close(); } while (!finished); } } </code></pre> <p><strong>EDIT:</strong> On a previous post which was related to this, it was mentioned that "So if you are going use System.in later don't close it (if it is closed, we can't reopen it and read any data from it, hence exception)". Why is this happening? </p>
40,508,995
0
type is not a member of package controllers <p>I'm currently working on a web app with the play2 framework.</p> <p>Most of the time everything works fine. However when I decide to rebuild the project I get the error: "type HomeController is not a member of package controllers".</p> <p>I've done some research on the web and encountered discussions and topics about this error. However, on all of them this seems to be the answer: </p> <p>"Play 2.4, by default, generates a dependency injected router, unlike previously, when it used a static router. You have two options, remove the routesGenerator line from build.sbt so play will generate a static router, or (better) make your controllers classes instead of objects, and use dependency injection."</p> <p>But, in my project, the HomeController is of type class instead of object and there doesn't seem to be a routesGenerator lin in build.sbt.</p> <p>It is kinda bugging me out, so if someone has an answer to it, that would be super awesome.</p> <p>I managed to get around it two times already but I don't remember how :(.</p> <p>Ok. Time for some specs.</p> <ol> <li>Intellij IDEA 2016.2.5</li> <li>Play 2.5.9</li> <li>Windows 10</li> <li>Java Version 8 Update 111</li> </ol> <p>And now for the code:</p> <p>HomeController:</p> <pre><code>package controllers; import com.avaje.ebean.Ebean; import com.avaje.ebean.Model; import models.Strike; import play.data.Form; import play.data.FormFactory; import play.mvc.*; import views.html.*; import javax.inject.Inject; import java.util.List; import static play.libs.Json.toJson; /** * This controller contains an action to handle HTTP requests * to the application's home page. */ public class HomeController extends Controller { @Inject FormFactory formFactory; public Result index() { return ok(index.render("", formFactory.form(Strike.class))); } public Result addStrike() { Form&lt;Strike&gt; st = formFactory.form(Strike.class).bindFromRequest(); st.get().save(); return redirect(routes.HomeController.index()); } public Result getStrikes(){ List&lt;Strike&gt; strikes = new Model.Finder(Strike.class).all(); return ok(toJson(strikes)); } } </code></pre> <p>Routes:</p> <pre><code>GET / controllers.HomeController.index() POST /strike controllers.HomeController.addStrike() GET /strikes controllers.HomeController.getStrikes() </code></pre> <p>Build.sbt:</p> <pre><code>name := "" version := "1.0-SNAPSHOT" lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean) scalaVersion := "2.11.7" libraryDependencies ++= Seq( javaJdbc, cache, javaWs ) </code></pre> <p>Anyone have any idea?</p> <p>Thanks in advance!</p>
26,477,548
1
Filter one dataframe using multi-index of another dataframe <p>I have the following two dataframes DF1 and DF2. I would like to filter DF1 based on the multi-index of DF2.</p> <pre><code>DF1: Value Date ID Name 2014-04-30 1001 n1 1 2014-05-31 1002 n2 2 2014-06-30 1003 n3 3 2014-07-31 1004 n4 4 DF2 (index = Date, ID, Name): Date ID Name 2014-05-31 1002 n2 2014-06-30 1003 n3 What i would like is this: Value Date ID Name 2014-05-31 1002 n2 2 2014-06-30 1003 n3 3 </code></pre> <p>To do this i simply use:</p> <pre><code>f_df = df1.ix[df2.index] </code></pre> <p>However, when doing this what i am getting is this (notice the tuple index)</p> <pre><code> Value (2014-05-31, 1002, n2) 2 (2014-06-31, 1003, n3) 4 </code></pre> <p>How can i achieve what i am looking for? which is a resulting dataframes without a tuple index?</p>
8,760,264
0
<p>You can use <a href="http://api.jquery.com/one/" rel="nofollow"><code>.one()</code></a> for that.</p> <pre><code>$("a").one("click", function() { // do your stuff } </code></pre> <p>Or you could store the fact that the link has already been clicked by adding a <a href="http://api.jquery.com/jQuery.data/" rel="nofollow"><code>.data()</code></a> attribute.</p> <pre><code>$('a').click(function() { var a = $(this); if (a.data('clicked') == 'clicked') return false; // do your stuff a.data('clicked', 'clicked'); }); </code></pre> <p>Whatever you do you should really drop that inline js (for maintainability and clean code).</p>
5,869,224
0
Serialize large files - store in memory or on disk? <p>I do a networking app using iPhones and their limited memory is something I must consider. My <code>Message</code> class holds both a image and a video. Now I am about to implement the video file transfer (image already implemented, and is working). I guess the image can be loaded to memory because of their relatively small size (1+ MB), but large video files must reside on disk to avoid filling the memory. </p> <p>To be able to encode the <code>Message</code> instance for sending it over the network (using <code>NSCoding</code> protocol), I convert the <code>UIImage</code> instance to NSData that resides in memory:</p> <pre><code> NSData *imageData = UIImagePNGRepresentation(self.image); </code></pre> <p>The video is stored on disk and is accessed by using an <code>NSURL videoURL</code>. The content of this url (the video file itself) should also be encoded, and it have to be converted to NSData as well. If I init an NSData instance with this url, the <code>videoData</code> will be loaded into and occupying all available space in memory...</p> <pre><code>NSData *videoData = [[NSData alloc] initWithContentsOfURL:videoURL]; </code></pre> <p>...(am I wrong?) so this must be accomplished using another technique.</p> <p>Should I send the <code>Message</code> instance (without the video) first, and then send the video separately using some unknown technique? Or maybe I did miss some conceptual steps here?</p>
13,222,947
0
How to import data to the database from a CSV file? <p>I am using Ruby 1.9.2, the Ruby on Rails v3.2.2 gem and the MySQL database. I would like to import data to the database from a <a href="http://www.maxmind.com/download/worldcities/worldcitiespop.txt.gz" rel="nofollow">CSV file</a> containing world cities. I think this process should be made by running a RoR migration but I don't know how to properly proceed.</p> <p>In particular, I don't know <em>where</em> (that is, in which directory relating my RoR application) I should put the CSV file and <em>how to access</em> that file from my migration file in order to add data to the database.</p>
8,530,676
0
<p>There is two approach check which one you prefers. but I think if possible i will follow first approach. But I have never done it.</p> <p><strong>First Approach</strong> Copy the first database and paste with some othername see following url</p> <p><a href="http://stackoverflow.com/questions/5662181/how-to-copy-existing-database-from-one-app-to-another">How to copy existing database from one app to another</a></p> <p><strong>Second Approach</strong> copy the contents of two database</p> <p><strong>Step-1</strong> First Attach two databases</p> <pre><code>ATTACH DATABASE filename AS database-name; </code></pre> <p>The DATABASE keyword is optional, but I like the clarity of it. filename should be the path to the database file you wish to attach, and the database-name is a unique name. </p> <p><strong>Step-2</strong> Run Insert Into commands for the tables you want to transfer.</p> <pre><code>INSERT INTO X.TABLE(Id, Value) SELECT * FROM Y.TABLE; </code></pre>
31,960,883
0
Text Box custom source as data table <p>I'm trying to set a custom source for my Text Box for the suggest option. I've got so far to this.</p> <pre><code> private void Input_Box_Load(object sender, EventArgs e) { sc.Open(); SqlCommand cmd = new SqlCommand("select MoM_ID from dbo.MoM_Form ORDER BY MoM_ID ASC", sc); SqlDataReader R_1; R_1 = cmd.ExecuteReader(); DataTable dt_1 = new DataTable(); dt_1.Columns.Add("MoM_ID", typeof(string)); dt_1.Load(R_1); TextBox_FormID.AutoCompleteMode = AutoCompleteMode.Suggest; TextBox_FormID.AutoCompleteSource = dt_1 ; sc.Close(); } </code></pre> <p>Is there any way to convert dt_1 to the type of autocomplete collection ? Or I should iterate the values into a new list and then add that list as a source?</p> <p>Thanks</p>
23,077,284
1
Stomp.py how to return message from listener <p>I've already read this topic: <a href="http://stackoverflow.com/questions/9328863/stomp-py-return-message-from-listener">Stomp.py return message from listener</a></p> <p>But i still don't get how this works, and why there's no way to retrieve a message from the stomp object, or the listener directly?</p> <p>If i can send a message via the send method, and If i can receive a message with an on_message listener method, why can't I return that message to my original function, so I could return it to the frontend?</p> <p>So if i have:</p> <pre><code>class MyListener(object): def on_error(self, headers, message): print '&gt;&gt;&gt; ' + message def on_message(self, headers, message): print '&gt;&gt;&gt; ' + message </code></pre> <p>how could I return a message from the on_message method?</p> <p>or could I do it somehow after the conn.subscribe(...) ??</p>
22,039,351
0
Set Selected System Font to TextView <p>I'm doing one demo. In that I'm loading the system fonts into the <code>Spinner</code> and I want to set the selected font to <code>TextView</code>. I done with font loading but I'm not able to set it to <code>TextView</code>. I'm confused with the <code>TypeFace</code> ... Following is my code..</p> <pre><code> package com.example.accessingsystemfonts; import java.io.File; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.graphics.Typeface; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.Spinner; import android.widget.TextView; public class MainActivity extends Activity { TextView tv; Button b1; Spinner sp1; List&lt;String&gt; fontNames ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tv=(TextView)findViewById(R.id.tv); b1=(Button)findViewById(R.id.buttonset); sp1=(Spinner)findViewById(R.id.spinnersystemfonts); readAllFonts(); b1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tv.setTypeface(?); **How to set selected font??** } }); } private List&lt;String&gt; readAllFonts() { fontNames = new ArrayList&lt;String&gt;(); File temp = new File("/system/fonts/"); String fontSuffix = ".ttf"; for(File font : temp.listFiles()){ String fontName = font.getName(); if(fontName.endsWith(fontSuffix)) { fontNames.add(fontName.subSequence(0,fontName.lastIndexOf(fontSuffix)).toString()); } } sp1.setAdapter(new ArrayAdapter&lt;String&gt;(getBaseContext(),android.R.layout.simple_spinner_dropdown_item,fontNames)); return fontNames; } } </code></pre>
30,141,968
0
Julia file input reading speed <p>I'm giving Julia a go while solving Code Jam problems, in this case Rope Intranet from round 1C 2010 (<a href="https://code.google.com/codejam/contest/619102/dashboard" rel="nofollow">https://code.google.com/codejam/contest/619102/dashboard</a>)</p> <p>Solution is basically: </p> <pre><code>for tc = 1:int(readline()) n = int(readline()) a = [map(int, split(readline())) for _ = 1:n] ans = 0 for (i, x) in enumerate(a) for y in a[i + 1:end] ans += (x[1] - y[1]) * (x[2] - y[2]) &lt; 0 end end println("Case #", tc, ": ", ans) end </code></pre> <p>However, time results for the large input are not very impressive comparing to solutions in c++ and python:</p> <pre><code>julia real 0m6.196s user 0m6.028s sys 0m0.373s c++ real 0m0.392s user 0m0.338s sys 0m0.053s pypy real 0m0.529s user 0m0.507s sys 0m0.016s </code></pre> <p>Situation changes, when I replace file input with random numbers (still slower than c++ though):</p> <pre><code>julia real 0m3.065s user 0m2.868s sys 0m0.338s c++ real 0m1.413s user 0m1.348s sys 0m0.055s pypy real 0m22.491s user 0m22.257s sys 0m0.160s </code></pre> <p>Is there any way I can optimize file reading times in Julia (I'm using v0.3.7)?</p>
7,686,072
0
<pre><code>NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:4]; [variables setObject:[NSString stringWithFormat:@"Hi."] forKey:@"message"]; [variables setObject:@"http://icon.png" forKey:@"picture"]; //http://tinyurl.com/45xy4kw [variables setObject:@"Create post" forKey:@"name"]; [variables setObject:@"Write description." forKey:@"description"]; [_facebook requestWithGraphPath:[NSString stringWithFormat:@"/%@/feed",facebook_user_id] andParams:variables andHttpMethod:@"POST" andDelegate:self]; </code></pre>
25,831,462
0
how to make the text box show the date directly without putting the cursor and tap in the keybaord <p>please help me with this issue. I'm using windows forms in C# and I have textbox that I want to display the date on it. but its not working without putting the cursor on the text box and click on the keyboard after that the date is display. I want it to be display directly.</p> <p>see the my code</p> <pre><code> private void rdate_TextChanged(object sender, EventArgs e) { DateTime d = DateTime.Now; rdate.Text = d.ToString(); } </code></pre>
7,275,243
0
<pre><code>;WITH n(n) AS -- just 4 rows - makes it easy to extend to 5 weeks, 6 weeks, etc. ( SELECT 0 UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 ), d(dt) AS -- single row with the end of the current week -- this could be a variable but I get a lot of flack for not inlining ( SELECT dt = CONVERT(DATE, DATEADD(DAY, 7-DATEPART(WEEKDAY, CURRENT_TIMESTAMP), CURRENT_TIMESTAMP))), w(dt) AS -- get the end of each week based on the rows in n ( SELECT DATEADD(WEEK, -n.n, d.dt) FROM n CROSS JOIN d ) SELECT w.dt, SUM(CASE WHEN e.term_date &gt;= DATEADD(DAY, -90, w.dt) AND e.term_date &lt; DATEADD(DAY, 1, w.dt) AND e.hired_date &gt;= DATEADD(DAY, -90, w.dt) AND e.hired_date &lt; DATEADD(DAY, 1, w.dt) THEN 1 ELSE 0 END) FROM dbo.Employees AS e CROSS JOIN w GROUP BY w.dt ORDER BY w.dt DESC; </code></pre>
31,678,421
0
<p>Walk the array, find the relevant month, and update its value:</p> <pre><code>var newData = { "year" : 2015, "month" : "FEB", "value" : 2.33 }; for (var i = 0; i &lt; data.length; i++) { var entry = data[i]; if (entry.year == newData.year &amp;&amp; entry.month == newData.month) entry.value = newData.value; } </code></pre> <p>Your structure is not ideal for this kind of update, however. If you had 10.000 entries, you may need to examine all of them to update a single one.</p> <p>You should instead organize data by year and month. For example:</p> <pre><code>var data = { '2015-FEB': 2.5 '2015-MAR': 3.8 }; </code></pre> <p>Updating this other structure is a single operation:</p> <pre><code>data[year + '-' + month] = value; </code></pre> <p>If you need your objects in the form you posted, you can have the best of both worlds:</p> <pre><code>var data = { '2015-FEB': { "year" : 2015, "month" : "FEB", "value" : 2.33 } }; </code></pre> <p>If you need them in sorted order, you can have <strong>both</strong> structures: the date-to-object map <strong>and</strong> the array, storing references to the same objects.</p>
37,094,776
0
<p>There is a major flaw in your design. The error is obvious. In this line</p> <pre><code>final helpers helpers = new helpers(); </code></pre> <p>you are trying to create an object of an activity which is a very very bad practice. You cannot simply create an object of an activity like this. All Activities in Android must go through the Activity lifecycle so that they have a valid context attached to them. In this case a valid context is not attached to the helper instance. So as a result the line </p> <pre><code>SharedPreferences sharedPref = this.getPreferences(Context.MODE_PRIVATE); </code></pre> <p>causes a null pointer as 'this' is null. (Why? Because this refers to the context which has not yet been created as the activity is not started using startActivity(intent))</p> <p><em>Another thing though this is not an error, you must use activity names starting with an upper case letter. It is the convention followed and will make your code more readable. Your code is pretty confusing due to the weird use of upper and lower case names. You declare your class with a lower case letter while at some places the variables are upper case. which causes confusion. The rule is that classes, interfaces, etc should start with upper case letters and variables as lower case.</em></p> <p>So in this case what do you do?</p> <p>You never start your Helper activity and I think you do not need to show it to the user. That is it needs to do some work without user interaction. You should make it a service. And then start it using <code>startService(intent).</code>Or you may also create it as a Java class, depends on your use case. </p> <p>Edit: By the way I answered <a href="http://stackoverflow.com/questions/37092965/android-calling-intentservice-class-from-a-service-class/37096620#37096620">another</a> similar question having the same problem but involving services later today. </p>
4,973,986
0
Why the naming: NodeList vs childNodes <p>I have been wondering about a stupid thing about the DOM. Why do the standards define NodeList with the postfix <code>List</code> to make it clear it is an array while have a some properties or functions like <code>childNodes</code> or <code>getElementsByTagName</code> which use the postfix letter <code>s</code>?</p> <p>I find it contradictory when the standards define members with different suffixes for the same purpose (to describe an array).</p> <p>Edit: It actually seems that NodeList is not even an array. Does this explain this?</p>
16,732,393
0
<p>I think, you can use <code>space-bar</code> like this:</p> <pre><code>$('#container1 .item') </code></pre> <p>And, if <code>.item</code> element was under the <code>#container1</code> directly, you can also use this:</p> <pre><code>$('#container1 &gt; .item') </code></pre>
34,891,278
0
<p>A simple approach to error-checking user input is with a while loop. For example:</p> <pre><code>def make_score(): while True: score = raw_input('Air, Water, or Grass? ') if score in Attack: break else: print 'Invalid selection.' return score </code></pre> <p>This will loop to input until the user enters a string that matches one of your list items (in the Attack list).</p>
6,647,049
0
<p>I finally found the problem. It's fixed.</p> <p>The problem was the Application Pool. On every recycle, the session was lost. So we did turn off the application pool recycling, and are scheduling the recycle once a day.</p>
20,617,177
0
<p>As I was writing the question, I figured out the answer, so I decided to post it right here. But if someone has a different solution, that is more stable or clean, I'm still interested.</p> <p>The dictionary to be passed to <code>.format</code> should be:</p> <p><code>vars(sys.modules[func.__module__])</code></p>
35,874,023
1
Python: list is not mutated after for loop <pre><code>a =[1,2] for entry in a: entry = entry + 1 print a </code></pre> <p>Shouldn't the list be mutated to<code>[2,3]</code>? The result came out as <code>[1,2]</code>. Why?</p>
1,091,457
0
<p>There's one more issue you might need to address if you are using the <strong>Windows 2008 Server</strong> with <strong>IIS7</strong>. The server might report the following error:</p> <p><em>Microsoft Office Excel cannot access the file 'c:\temp\test.xls'. There are several possible reasons:</em></p> <ul> <li><em>The file name or path does not exist.</em></li> <li><em>The file is being used by another program.</em></li> <li><em>The workbook you are trying to save has the same name as a currently open workbook.</em></li> </ul> <p>The solution is posted here (look for the text posted by user Ogawa): <a href="http://social.msdn.microsoft.com/Forums/en-US/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91?prof=required" rel="nofollow noreferrer">http://social.msdn.microsoft.com/Forums/en-US/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91?prof=required</a></p>
10,736,964
0
gitolite-admin clone issue <p>I am going nuts with a problem cloning the gitolite-admin repository. I have followed this <a href="http://sitaramc.github.com/gitolite/install.html#migr" rel="nofollow">http://sitaramc.github.com/gitolite/install.html#migr</a> and it went perfectly.</p> <p>I ran <code>ssh-keygen -t rsa</code> and <code>scp ~/.ssh/id_rsa.pub morten@ubuntu-server:/tmp/morten.pub</code></p> <p>authorized_keys on the server looks like this:</p> <pre><code># gitolite start command="/home/morten/gitolite/src/gitolite-shell morten",no-port-forwarding,no-X11-forwarding,no-agent-forward$ # gitolite end </code></pre> <p>Which AFAIK is okay.</p> <p>When I run <code>git clone morten@ubuntu-server:gitolite-admin</code> on my client, I get</p> <pre><code>fatal: 'gitolite-admin' does not appear to be a git repository fatal: The remote end hung up unexpectedly </code></pre> <p>I have no idea what I missed!</p>
27,025,300
0
<p>I ran into this same problem. It turned out that I was inadvertently using my machine's version of django-admin.py to start my Django project, rather than the one installed within the virtualenv. I ended up having to <code>source bin/activate</code> again after installing django within the virtualenv, before running any of the django-admin commands.</p>
32,371,753
0
Delete duplicate lines in a file after a match in a particular subset of columns <p>I've an unsorted file, containing row data disposed in many columns, as in this example:</p> <pre><code>10:23:55.521803 [INFO] eceb [ 41] 235 870 1 26601 349 910 10:24:11.771454 [INFO] eceb [ 41] 41 870 0 26601 349 910 10:25:18.858675 [INFO] eceb [ 41] 235 870 3 26601 349 910 10:25:18.814763 [INFO] eceb [ 41] 60 1247 0 38490 163 715 10:25:19.844738 [INFO] eceb [ 41] 60 1248 0 38490 163 715 10:24:11.771454 [INFO] eceb [ 41] 41 870 0 26641 389 920 </code></pre> <p>I want to identify all the lines that, considering only the columns 4,5 and 6, are the same, and delete all this lines from the file.</p> <p>Therefore, the result should be, in this example:</p> <pre><code>10:25:18.814763 [INFO] eceb [ 41] 60 1247 0 38490 163 715 10:25:19.844738 [INFO] eceb [ 41] 60 1248 0 38490 163 715 </code></pre> <p>How can I do this?</p>
37,726,516
0
<p>When you invoke the <code>printloop</code> function with <code>5</code> the for loop essentially becomes</p> <pre><code>for (x = 5; x &lt; 5; x++) { //... } </code></pre> <p>And <code>x &lt; 5</code> will never be true.</p> <hr> <p>I guess what you meant was something like </p> <pre><code>for (x = 0; x &lt; valx; x++) { //... } </code></pre>
18,885,272
0
<p>you can do it in css</p> <pre><code>#rolling { height: 80px !important; } </code></pre> <p><a href="http://screencast.com/t/VNpe7ODkh2Ar" rel="nofollow">http://screencast.com/t/VNpe7ODkh2Ar</a></p>
20,533,516
0
<p>May be you're missing "px" at the end:</p> <pre><code>function resizeText(multiplier) { var elements = document.getElementsByClassName('Resizable'); for(var i = 0; i &lt; elements.length; i++) { elements[i].style.fontSize = parseFloat(elements[i].style.fontSize) + (multiplier + * 0.2) + "px"; } } </code></pre>
6,674,893
0
<p>Alt+Key is one way, like AresAvatar posted above.</p> <p>if you want some more possibilities you can use the <a href="http://msdn.microsoft.com/de-de/library/system.windows.input.keybinding.aspx" rel="nofollow">KeyBinding</a> class</p>
37,718,576
0
How to change the ViewControllers frame position inside the PageViewController? <p>The Code I Have written for loading view controllers in Page View Controllers. Programatically creating four view controllers and adding them to Page View Controller. I have changed the view controllers frame position but still not changing in the app </p> <pre><code> let controller: UIViewController = UIViewController() print(controller.view.frame) controller.view.frame = CGRectMake(10, 20, self.view.frame.width/2, self.view.frame.height - 20) print(controller.view.frame) controller.view.backgroundColor = UIColor.blackColor() let controller2: UIViewController = UIViewController() controller2.view.backgroundColor = UIColor.redColor() let controller3: UIViewController = UIViewController() controller3.view.backgroundColor = UIColor.blackColor() let controller4: UIViewController = UIViewController() controller4.view.backgroundColor = UIColor.greenColor() let p1 = controller let p2 = controller2 let p3 = controller3 let p4 = controller4 myViewControllers = [p1,p2,p3,p4] for index in 0 ..&lt; myViewControllers.count { NSLog("\(myViewControllers[index])") } let startingViewController = self.viewControllerAtIndex(0) let viewControllers: NSArray = [startingViewController] self.setViewControllers(viewControllers as? [UIViewController], direction: UIPageViewControllerNavigationDirection.Forward, animated: true, completion: {(done: Bool) in }) </code></pre>
5,430,987
0
<p>You don't need EXECUTE IMMEDIATE in this context.</p> <pre><code>DECLARE long_var long:=0; BEGIN DBMS_OUTPUT.PUT_LINE(LENGTH(long_var)); SELECT filesize INTO long_var FROM files; DBMS_OUTPUT.PUT_LINE(LENGTH(long_var)); END; / </code></pre> <p>EXECUTE IMMEDIATE runs a stand alone statement of SQL from your PL/SQL code. It can't return anything to your code. The statement you're using isn't valid SQL so you get the ORA-00905. It is valid PL/SQL code and so works as you'd expect once EXECUTE IMMEDIATE is removed.</p> <p><strong>Edit</strong></p> <p>Code for your follow on question: To do this with more than one row you can use this</p> <pre><code>DECLARE CURSOR C1 IS SELECT filesize FROM files; BEGIN FOR files IN c1 LOOP DBMS_OUTPUT.PUT_LINE(LENGTH(files.filesize)); END LOOP; END; / </code></pre>
18,362,027
0
<pre><code>function GetAnImage(src) { var newImg = document.createElement('img'); newImg.src = src; return newImg; } var newImg = GetAnImage("abc.jpg"); newImg.onload = function () { var height = this.height; var width = this.width; //do with the image as you want } </code></pre> <p>i hope it helps.</p>
14,680,916
0
On listview only want to click one item at a time <p>I have a listview with item. Click on an item it goes to another activity. My problem is on clicking on multiple items (say 3 0r4 ) all clicked are loaded. But i dont need it. Only want to load 1 item at a time. Tested on HTC one,samsung galaxy s plus. Please help.</p>
19,173,979
0
<p>This 'Class' definitoin is special only because it use 'generic' type parameter? if you do not know what 'generic' means, I think you should read a java book before read/write java code like this ~</p> <p><code>class ListNode&lt;K, V&gt;</code> means the <code>ListNode</code> class uses two 'unknown' or 'general' variable type (i.e. K V), you can indicate the specific type when you use the class</p> <p><code>K extends Comparable&lt;K&gt;</code> meands that the 'K' type is restricted to be 'Comparable'</p>
5,963,907
0
<p>Although <code>harry.getObject()</code> is a reference to the original object, you then ruin it with the assignment:</p> <pre><code>harry1 = harry.getObject(); </code></pre> <p>which performs a copy.</p> <p>Instead:</p> <pre><code>Student const&amp; harry1 = harry.getObject(); </code></pre>
18,407,201
0
Html file works locally on IE, but not on server. Works fine for Opera, Chrome, Safari and Firefox <p>Basically, as the title states, the file works locally, but not when uploaded to a server.</p> <p>Here's a live working version: <a href="http://jsfiddle.net/guisasso/WKjT8/" rel="nofollow noreferrer"><strong>jsfiddle</strong></a> </p> <p>Code extracted from <a href="http://www.onextrapixel.com/2013/07/31/creating-content-tabs-with-pure-css/" rel="nofollow noreferrer">http://www.onextrapixel.com/2013/07/31/creating-content-tabs-with-pure-css/</a></p> <p>*The divs are displaying right below their parent tab. That's ok, I just striped down the code to post the question.</p> <p><strong>This is all in one file, there's no reference to any external files, so path problems should be ruled out.</strong></p> <p>Thanks.</p> <p><strong>Google Chrome</strong> <img src="https://i.stack.imgur.com/Dig8S.png" alt="Google Chrome"></p> <p><strong>IE Local</strong> <img src="https://i.stack.imgur.com/0kSrh.png" alt="Local IE"></p> <p><strong>IE when uploaded to webserver</strong> <img src="https://i.stack.imgur.com/74AB9.png" alt="IE online"></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8" /&gt; &lt;title&gt;Pure CSS Tabs with Fade Animation Demo 1&lt;/title&gt; &lt;style type="text/css"&gt; body, html { height: 100%; margin: 0; -webkit-font-smoothing: antialiased; font-weight: 100; background: #aadfeb; text-align: center; font-family: helvetica; } .tabs input[type=radio] { position: absolute; top: -9999px; left: -9999px; } .tabs { width: 650px; float: none; list-style: none; position: relative; padding: 0; margin: 75px auto; } .tabs li{ float: left; } .tabs label { display: block; padding: 10px 20px; border-radius: 2px 2px 0 0; color: #08C; font-size: 24px; font-weight: normal; font-family: 'Roboto', helveti; background: rgba(255,255,255,0.2); cursor: pointer; position: relative; top: 3px; -webkit-transition: all 0.2s ease-in-out; -moz-transition: all 0.2s ease-in-out; -o-transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out; } .tabs label:hover { background: rgba(255,255,255,0.5); top: 0; } [id^=tab]:checked + label { background: #ececec; border-bottom: 3px orange solid; color: black; top: 0; } [id^=tab]:checked ~ [id^=tab-content] { display: block; } .tab-content{ z-index: 2; display: none; text-align: left; width: 100%; font-size: 20px; line-height: 140%; padding-top: 10px; margin-top:10px; background: #ffffff; padding: 15px; color: black; position: absolute; box-sizing: border-box; -webkit-animation-duration: 0.5s; -o-animation-duration: 0.5s; -moz-animation-duration: 0.5s; animation-duration: 0.5s; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="container"&gt; &lt;div class="main"&gt; &lt;ul class="tabs"&gt; &lt;li&gt; &lt;input type="radio" checked name="tabs" id="tab1"&gt; &lt;label for="tab1"&gt;test 1&lt;/label&gt; &lt;div id="tab-content1" class="tab-content animated fadeIn"&gt; "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." &lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;input type="radio" name="tabs" id="tab2"&gt; &lt;label for="tab2"&gt;test 2&lt;/label&gt; &lt;div id="tab-content2" class="tab-content animated fadeIn"&gt; "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? &lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;input type="radio" name="tabs" id="tab3"&gt; &lt;label for="tab3"&gt;test 3&lt;/label&gt; &lt;div id="tab-content3" class="tab-content animated fadeIn"&gt; "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?" &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p></p>
17,736,385
0
<p>You have <code>;</code> after the if. Remove it.</p> <p>if statements can't have ; at the end:</p> <pre><code>if(someCondition); is not valid </code></pre>
3,612,795
0
<p>i tried your code, it fades out on first feed, but it doesn't enter the animationDidStop event. thats why it cant call performAnimation again. is there any set for animation (delegate or protocol etc..)</p>
8,740,252
0
Why are these two queries different? <p>Display the details of the employees who have subscribed for Football and Chess but not for Tennis.</p> <pre><code>SELECT * FROM employee WHERE empid IN (SELECT empid FROM subscription WHERE facid IN (SELECT facid FROM facility WHERE facility = 'Chess' OR facility = 'Football')) AND empid NOT IN (SELECT empid FROM subscription WHERE facid = (SELECT facid FROM facility WHERE facility = 'Tennis')); SELECT DISTINCT empid FROM subscription WHERE facid IN (SELECT facid FROM facility WHERE facility = 'Chess' OR facility = 'Football') AND facid != (SELECT facid FROM facility WHERE facility = 'Tennis'); </code></pre> <p>The first one gives correct result.</p>
3,347,454
0
<p>I might not be understanding this completely, but if all you want to do is to output a list of names with their respective email addresses, you could try simplifying to this:</p> <pre><code>name = rs("name") email = rs("email") do while rs.eof &lt;&gt; true response.write(name &amp; " " &amp; email &amp; "&lt;br /&gt;") rs.movenext loop </code></pre> <p>…at least for testing purposes. Alternatively, you could concatenate the name and email in the SQL statement into one column:</p> <pre><code>SELECT name + '|' + email as nameemail FROM emails WHERE email IN ('" &amp; emails &amp; "') </code></pre> <p>...will give you "name|email" that you can easily string manipulate.</p>
26,473,660
0
<p>Using <a href="http://underscorejs.org/#object">underscore's object function</a>, you can do this:</p> <pre><code>form_values = _.object([f.name, f.value] for f in $('input, textarea, select')) </code></pre>
5,453,517
0
<p>Do you want to keep the session variable? If not you can just use the header function:</p> <pre><code>header('http://domain.com/category/health-beauty/'); </code></pre>
5,996,862
0
cakePHP + php5-fpm + memcached = lots of open TCP connections to memcached? <p>I'm pretty sure this is a CakePHP bug, but figured someone here may have run across this and know how to fix. FYI - I've created a <a href="http://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/1705-cake-138-memcacheengine-does-not-close-connection" rel="nofollow">ticket</a>.</p> <p>I run PHP as fastcgi under nginx via php5-fpm. When I use 'Memcache' as the engine for my cake cache, I notice that TCP connections are not closed. I notice that cake's <a href="http://api.cakephp.org/view_source/memcache-engine/#line-198" rel="nofollow">MemcacheEngine</a> does not ever call PHP <a href="http://www.php.net/manual/en/memcache.close.php" rel="nofollow">memcache::close()</a>.</p> <p>For people who run PHP under non-fastcgi processes, I think this is OK as at the end of the PHP request the process ends, and "breaks" the TCP connection between PHP and memcached.</p> <p>Using php5-fpm this is not the case, as the PHP process stays running to be re-used.</p> <p>Does anyone know a best practice for this? I'm thinking of modifying the CakePHP code to close the connection at the end of processing - but I'm wondering if there is a better way.</p> <p>Note: CakePHP's MemcacheEngine does NOT use <a href="http://www.php.net/manual/en/memcache.pconnect.php" rel="nofollow">pconnect</a>.</p> <p>My version info:</p> <pre><code>Ubuntu 10.10 64bit PHP 5.3.3 PECL memcache 3.0.5 memcached 1.4.5 cakephp 1.3.8 </code></pre>
21,586,693
0
<p>Make will read and operate on a makefile which is in the current directory, unless you specify a different one with <code>-f</code>. From your comments above it sounds like your current directory is not the right one when you run <code>make</code>, so it can't find the makefile</p> <p>You have to either run <code>make -f public/cards/gallery/Makefile card FILE=...</code>, to allow make to find your makefile, or else change working directories first with <code>make -C public/cards/gallery card FILE=...</code></p> <p>Also I find it unlikely that <code>FILE=public/cards/gallery/*</code> is going to work, because the wildcard <code>*</code> expands to ALL the files in the directory.</p>
24,521,695
0
<p><strong>This should do it for you without an array...</strong></p> <pre><code> Dim intcount As Integer = 0 'Used to make sure commas are in order For Each item As Integer In myReader("SchType_ID").ToString.Split("~") If intcount &gt;= 1 Then builder.Append(",") builder.Append(item.ToString) Else builder.Append(item.ToString) intcount += 1 End If Next </code></pre> <p><strong>Another example adding the items to an array</strong></p> <pre><code> Dim strArray As New List(Of Integer) Dim intcount As Integer = 0 'Used to make sure commas are in order 'Add items to the array For Each item As Integer In myReader("SchType_ID").ToString.Split("~") strArray.Add(item) Next 'Add each item to the string builder For Each intItem As Integer In strArray If intcount &gt;= 1 Then builder.Append(",") builder.Append(intItem.ToString) Else builder.Append(intItem.ToString) intcount += 1 End If Next MessageBox.Show(builder.ToString) 'Only for testing purposes </code></pre> <p><strong>Here's a function for you as well</strong></p> <pre><code> Public Function BuildArray(ByVal strItems As String) As List(Of Integer) Dim lstArray As New List(Of Integer) For Each item As Integer In strItems.Split("~") lstArray.Add(item) Next Return lstArray End Function </code></pre> <p>*To use the function, you can use it this way...</p> <pre><code> Dim lstArray As List(Of Integer) Dim intcount As Integer = 0 lstArray = New List(Of Integer)(BuildArray(myReader("SchType_ID").ToString)) 'Add each item to the string builder For Each intItem As Integer In lstArray If intcount &gt;= 1 Then builder.Append(",") builder.Append(intItem.ToString) Else builder.Append(intItem.ToString) intcount += 1 End If Next MessageBox.Show(builder.ToString) 'Testing purpose only </code></pre> <p>Happy Coding!</p>
18,963,054
0
PySide/QT - How to add horizontal or vertical layout to a grid layout <p>If I wanted to create a window where a grid layout didn't cover the whole frame? Could I do it by adding a horizontal layout to the grid layout and adding a stretch to the horizontal layout. When I try it in the following code, I get this error: </p> <blockquote> <p>TypeError: PySide.QtGui.QGridLayout.addLayout(): not enough arguments</p> </blockquote> <pre><code>import sys from PySide import QtGui class Example(QtGui.QWidget): def __init__(self): super(Example, self).__init__() self.initUI() def initUI(self): names = ['Cls', 'Bck', '', 'Close', '7', '8', '9', '/', '4', '5', '6', '*', '1', '2', '3', '-', '0', '.', '=', '+'] hbox = QtGui.QHBoxLayout() hbox.addStretch() vbox = QtGui.QVBoxLayout() vbox.addStretch() grid = QtGui.QGridLayout() grid.addLayout(vbox) self.setLayout(grid) self.move(300, 150) self.setWindowTitle('Calculator') self.show() def main(): app = QtGui.QApplication(sys.argv) ex = Example() sys.exit(app.exec_()) if __name__ == '__main__': main() </code></pre> <p>This error does not occur when adding a horizontal layout to a vertical layout or vice versa. </p> <p>Thanks for the help!</p>
20,759,916
0
<p>When using escaped table names take care about this "bug" : <a href="https://github.com/doctrine/doctrine2/pull/615" rel="nofollow">https://github.com/doctrine/doctrine2/pull/615</a> . Doctrine takes the first character of the table name as aliasprefix and thus a quote is used, crushing all your SQLs</p>
10,345,097
0
<p>My Solution</p> <pre><code>Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON); buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK)); getContext().sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED"); </code></pre>
11,310,045
0
<p>Try a simple trick. Apple has got samples on its site to show how to zoom into a photo using code. Once done zooming, using graphic context take the frame size of the bounding view, and take the image with that. Eg Uiview contains scroll view which has the zoomed image. So the scrollview zooms and so does your image, now take the frame size of your bounding UIview, and create an image context out of it and then save that as a new image. Tell me if that makes sense.</p> <p>Cheers :)</p>
29,459,285
0
Combining Classes through Methods in Java <p>I have two working classes that function independently. I want to combine them, yet I have no working location to add a <code>public void (String Name){</code>. I keep getting a "remove this" or "Add }".</p> <p>Code I have: </p> <pre><code>import java.io.File; import java.awt.event.*; import javax.swing.*; import java.awt.*; public class WordDocument extends JFrame { private JButton btnOpen; private JLabel jLabel1; private JTextField txtDocNumber; public void SystemFiles() { private static String DIR ="c:\\Users\\tyler's account\\folders\\JavaReaderFiles\\"; // folder where word documents are present. public WordDocument() { super("Open Word Document"); initComponents(); } private void initComponents() { jLabel1 = new JLabel(); txtDocNumber = new JTextField(); btnOpen = new JButton(); Container c = getContentPane(); c.setLayout(new java.awt.FlowLayout()); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLabel1.setText("Enter Document Number : "); c.add(jLabel1); txtDocNumber.setColumns(5); c.add(txtDocNumber); btnOpen.setText("Open Document"); btnOpen.addActionListener(new ActionListener() { // anonymous inner class public void actionPerformed(ActionEvent evt) { Desktop desktop = Desktop.getDesktop(); try { File f = new File( DIR + txtDocNumber.getText() + ".doc"); desktop.open(f); // opens application (MSWord) associated with .doc file } catch(Exception ex) { // WordDocument.this is to refer to outer class's instance from inner class JOptionPane.showMessageDialog(WordDocument.this,ex.getMessage(),"Error", JOptionPane.ERROR_MESSAGE); } } }); c.add(btnOpen); } public static void main(String args[]) { WordDocument wd = new WordDocument(); wd.setSize(300,100); wd.setVisible(true); } } </code></pre> <p>I don't know where to add the Method. I have tried changing Private/Public classes and kept receiving multiple errors. I need this to run as a part of an IF loop.</p>
6,721,227
0
AVURLAsset's loadValuesAsynchronouslyForKeys method doesn't call completion block when executed in modal view controller <p>I'm using AV Foundation to replay in-bundle .mov files. I followed Apple's guide to initiate an AVURLAsset instance and called its <strong>- (void)loadValuesAsynchronouslyForKeys:(NSArray *)keys completionHandler:(void (^)(void))handler</strong> method.</p> <p>In the view controller loaded firstly, doing this works. </p> <p>My app architecture adds modal view controllers on top of the base one, I found calling loadValuesAsynchronouslyForKeys in the following modal view controllers doesn't work well: the completion block handler has never got called.</p> <p>I copy+paste the AV Foundation code shown below, so my thought is this code snippt doesn't work in modal view controllers, but why?</p> <pre><code>NSString *path = [[NSBundle mainBundle] pathForResource:@"video001" ofType:@"mov"]; NSURL *url = [NSURL fileURLWithPath:path isDirectory:NO]; AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil]; [asset loadValuesAsynchronouslyForKeys:[NSArray arrayWithObjects:@"tracks", nil] completionHandler:^(void){ NSLog(@"compltion"); }]; </code></pre>
13,334,341
0
LabWindows/CVI is an event-driven, ANSI C89 programming environment developed by National Instruments.
15,265,844
0
<p>Might be a typo but <code>Accounts.OnCreateUser(fn);</code> should be <code>Accounts.onCreateUser(fn);</code> Meteor docs: <a href="http://docs.meteor.com/#accounts_oncreateuser" rel="nofollow">http://docs.meteor.com/#accounts_oncreateuser</a></p> <p>And then another post on the same subject: <a href="http://stackoverflow.com/questions/13660219/meteor-login-with-external-service-how-to-get-profile-information">Meteor login with external service : how to get profile information?</a></p> <p>EDIT: Posting as edit due the formatting of the below piece of code. In the meantime I have got it running on my own project with this piece of code:</p> <pre><code>Accounts.onCreateUser(function(options, user) { if(!options || !user) { console.log('error creating user'); return; } else { if(options.profile) { user.profile = options.profile; } } return user; }); </code></pre> <p>Which is working just fine. Have you placed the <code>Accounts.onCreateUser();</code> on the server?</p>
13,461,708
0
How is for...in implemented in JavaScript? <p>I saw a question about the <a href="http://daniel.gredler.net/2008/09/10/javascript-iteration-order/" rel="nofollow">iteration order</a> of for...in statements, and warning that the order cannot be trusted. How is the iteration and tracking of the current and visited nodes done internally, and how does it differ among JavaScript engines?</p>
28,335,272
0
Noode.js ws: Server doesn't know that the client is disconnected <p>We have a problem in our project using the node <a href="https://github.com/websockets/ws" rel="nofollow">ws websockets library</a>. When the client looses network connection the only way to know that the client is disconnected is by sending a ws.ping() from the server. This is too resource consuming for us.</p> <p>Does anybody know if there is a default way to get the ws server to use TCP level keepalives instead of using the ping/pong functionality?</p>
14,453,535
0
<p>Consider the following example:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } // I will use tempDict Object for your understandings, otherwise it can be used directly. Here array1 is Main DataSource for UITableView. NSDictionary *tempDict = [array1 objectAtIndex:indexPath.row]; // key1 is the key to get the object from the dictionary. cell.title.text = [tempDict valueForKey:key1]; return cell; } </code></pre> <p>Here, array1 is the main <code>DataSource</code> for your table view, which contains <code>NSDictionary</code> objects.</p> <p>Hope this helps.</p>
4,517,071
0
Controller Namespaces and Routing issue <p>I created a routing test rails3 app with one model 'User':</p> <pre><code>rails new routing_test_app rails generate model User name:string rails generate scaffold_controller admin/user rake db:migrate </code></pre> <p>Added to routes.db: </p> <pre><code>namespace :admin do resources :users end </code></pre> <p>rake routes</p> <pre><code>admin_users GET /admin/users(.:format) {:action=&gt;"index", :controller=&gt;"admin/users"} admin_users POST /admin/users(.:format) {:action=&gt;"create", :controller=&gt;"admin/users"} new_admin_user GET /admin/users/new(.:format) {:action=&gt;"new", :controller=&gt;"admin/users"} edit_admin_user GET /admin/users/:id/edit(.:format) {:action=&gt;"edit", :controller=&gt;"admin/users"} admin_user GET /admin/users/:id(.:format) {:action=&gt;"show", :controller=&gt;"admin/users"} admin_user PUT /admin/users/:id(.:format) {:action=&gt;"update", :controller=&gt;"admin/users"} admin_user DELETE /admin/users/:id(.:format) {:action=&gt;"destroy", :controller=&gt;"admin/users"} </code></pre> <p>views/admin/users/_form.html.erb</p> <pre><code>&lt;%= form_for(@admin_user) do |f| %&gt; &lt;% if @admin_user.errors.any? %&gt; &lt;div id="error_explanation"&gt; &lt;h2&gt;&lt;%= pluralize(@admin_user.errors.count, "error") %&gt; prohibited this admin_user from being saved:&lt;/h2&gt; &lt;ul&gt; &lt;% @admin_user.errors.full_messages.each do |msg| %&gt; &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt; &lt;% end %&gt; &lt;/ul&gt; &lt;/div&gt; &lt;% end %&gt; &lt;%= f.text_field :name %&gt; &lt;div class="actions"&gt; &lt;%= f.submit %&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre> <p>When I go to 'http://localhost:3000/admin/users/new' rails throws an error:</p> <pre><code>undefined method `users_path' for #&lt;#&lt;Class:0x0000010116ca90&gt;:0x000001011588d8&gt; </code></pre> <p>Extracted source (around line #1):</p> <pre><code>1: &lt;%= form_for(@admin_user) do |f| %&gt; 2: &lt;% if @admin_user.errors.any? %&gt; 3: &lt;div id="error_explanation"&gt; 4: &lt;h2&gt;&lt;%= pluralize(@admin_user.errors.count, "error") %&gt; prohibited this admin_user from being saved:&lt;/h2&gt; </code></pre>
26,826,856
0
<p>I realized it was as simple as using setMaximumSize().</p> <p><a href="https://docs.oracle.com/javase/tutorial/uiswing/layout/box.html#size" rel="nofollow">https://docs.oracle.com/javase/tutorial/uiswing/layout/box.html#size</a> - got it from here.</p>
5,644,871
0
What's wrong with this PHP/JavaScript form validation? <p>I’m not sure whether the problem I’m having is with JavaScript or with PHP. </p> <p>My objective: To validate a simple yes no form using JavaScript then process it via PHP and have a message displayed.</p> <p>My problem: When JavaScript is enabled and I click the radio button and submit it the PHP doesn’t output “YES status checked”. Instead it refreshes the page (ie. I think it simply posts the form to user_agreement4.php and does nothing else) When JavaScript is disabled and I click on the YES radio button and submit it, the message “YES status checked” displays correctly. Please note that the code below is for user_agreement4.php. The form will be submitted to itself.</p> <p>What am I doing wrong?</p> <p>Please note that this is unfinished code-I haven't added things like cookies, redirection etc. yet.</p> <p>Also I have a question about choosing answers. May I choose more than one reply as an answer?</p> <pre><code>&lt;?php // Set variables $selected_radio = 'test'; session_start(); // start up your PHP session! // The below code ensures that $dest should always have a value. if(isset($_SESSION['dest'])){ $dest = $_SESSION['dest']; } // Get the user's ultimate destination if(isset($_GET['dest'])){ $_SESSION['dest'] = $_GET['dest']; // original code was $dest = $_GET['dest']; $dest = $_SESSION['dest']; // new code } else { echo "Nothing to see here Gringo."; //Notification that $dest was not set at this time (although it may retain it's previous set value) } // Show the terms and conditions page //check for cookie if(isset($_COOKIE['lastVisit'])){ /* Add redirect &gt;&gt;&gt;&gt; header("Location: http://www.mywebsite.com/".$dest); &lt;&lt;This comment code will redirect page */ echo "aloha amigo the cookie is seto!"; } else { echo "No cookies for you"; } //Checks to see if the form was sent if (isset($_POST['submitit'])) { //Checks that a radio button has been selected if (isset($_POST['myradiobutton'])) { $selected_radio = $_POST['myradiobutton']; //If No has been selected the user is redirected to the front page. Add code later if ($selected_radio == 'NO') { echo "NO status checked"; } //If Yes has been selected a cookie is set and then the user is redirected to the downloads page. Add cookie code later else if ($selected_radio == 'YES') { echo "YES status checked"; // header("Location: http://www.mywebsite.com/".$dest); } } } ?&gt; &lt;HTML&gt; &lt;HEAD&gt; &lt;TITLE&gt;User Agreement&lt;/TITLE&gt; &lt;script language="javascript"&gt; function valbutton(thisform) { // validate myradiobuttons myOption = -1; for (i=thisform.myradiobutton.length-1; i &gt; -1; i--) { if (thisform.myradiobutton[i].checked) { myOption = i; } } if (myOption == -1) { alert("You must choose either YES or NO"); return false; } if (myOption == 0) { alert("You must agree to the agreement to download"); return false; } thisform.submit(); // this line submits the form after validation } &lt;/script&gt; &lt;/HEAD&gt; &lt;BODY&gt; &lt;H1&gt; User Agreement &lt;/H1&gt; &lt;P&gt;Before downloading you must agree to be bound by the following terms and conditions;&lt;/P&gt; &lt;form name="myform" METHOD ="POST" ACTION ="user_agreement4.php"&gt; &lt;input type="radio" value="NO" name="myradiobutton" /&gt;NO&lt;br /&gt; &lt;input type="radio" value="YES" name="myradiobutton" /&gt;YES&lt;br /&gt; &lt;input type="submit" name="submitit" onclick="valbutton(myform);return false;" value="ANSWER" /&gt; &lt;/form&gt; &lt;/BODY&gt; &lt;/HTML&gt; </code></pre>
3,272,026
0
<p>Orthogonality is feature of your design independent of the language. Sure some language make it easier for you to have an orthogonal design for your system but you shouldn't focus on a specific language to keep your system's design as orthogonal as possible.</p>
4,377,744
0
<p>This is a perfect case for which <code>git submodule</code> was designed: <a href="http://git-scm.com/docs/git-submodule" rel="nofollow">http://git-scm.com/docs/git-submodule</a></p> <p>Within the Project1 and Project2, you add submodule of the Common. And then you <code>git submodule checkout</code></p> <p>In the cloned repo it only stores the hash of the Common git. So you <code>git submodule init</code> and checkout.</p>
34,888,739
0
if JS wrapper objects are considered bad style, is type-checking with lodash _.isString etc. considered bad style as well? <p>As other questions and answers have already noted, Google and Douglas Crockford both consider JS wrapper objects bad style and shouldn't be used.</p> <p>If that's the case, should using lodash <code>_.isString</code>, which works for primitive and object-wrapped strings, just to check if something is a string, be considered bad style as well?</p> <p>It seems to me some lodash functions such as these are designed primarily to be used for functional programming, e.g. <code>_.filter(myArray, _.isString)</code>, but if one is following best practices of using only primitive strings, a simple <code>typeof</code> check would suffice for the implementation.</p> <p>But the lodash code for <code>_.isString</code> does much more than that:</p> <pre><code> /** * Checks if `value` is classified as a `String` primitive or object. * * @static * @memberOf _ * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. * @example * * _.isString('abc'); * // =&gt; true * * _.isString(1); * // =&gt; false */ function isString(value) { return typeof value == 'string' || (!isArray(value) &amp;&amp; isObjectLike(value) &amp;&amp; objectToString.call(value) == stringTag); } </code></pre> <p>What was the motivation for this? Users who use object wrappers complaining that the lodash methods didn't work on them?</p>
20,317,775
0
<p>As @page with pagenumbers don't work in browsers for now I was looking for alternatives.<br> I've found an <a href="http://stackoverflow.com/questions/15797161/browser-support-for-css-page-numbers/16651296#16651296">answer</a> posted by <strong><em>Oliver Kohll</em></strong>.<br> I'll repost it here so everyone could find it more easily:<br> For this answer we are <strong>not using @page</strong>, which is a pure CSS answer, but work in FireFox 20+ versions. Here is the <a href="http://jsfiddle.net/okohll/QnFKZ/">link</a> of an example.<br> The CSS is:<br></p> <pre><code>#content { display: table; } #pageFooter { display: table-footer-group; } #pageFooter:after { counter-increment: page; content: counter(page); } </code></pre> <p>And the HTML code is:<br></p> <pre><code>&lt;div id="content"&gt; &lt;div id="pageFooter"&gt;Page &lt;/div&gt; multi-page content here... &lt;/div&gt; </code></pre> <p>This way you can customize your page number by editing parametrs to <em>#pageFooter</em>. My example:<br></p> <pre><code>#pageFooter:after { counter-increment: page; content:"Page " counter(page); left: 0; top: 100%; white-space: nowrap; z-index: 20px; -moz-border-radius: 5px; -moz-box-shadow: 0px 0px 4px #222; background-image: -moz-linear-gradient(top, #eeeeee, #cccccc); background-image: -moz-linear-gradient(top, #eeeeee, #cccccc); } </code></pre> <p>This trick worked for me fine. Hope it will help you.</p>
10,655,238
0
<p>You would need to capture the three key events separately and fire your action only after the third one.</p> <pre><code>var keys = { d: { code: 100, pressed: false, next: 'e' }, e: { code: 101, pressed: false, next: 'v' }, v: { code: 118, pressed: false, next: 'd' } }, nextKey = 'd'; $(document).keypress(function(e) { if (e.keyCode === keys[nextKey].code) { keys[nextKey].pressed = true; nextKey = keys[nextKey].next; } else { keys.d.pressed = false; keys.e.pressed = false; keys.v.pressed = false; nextKey = 'd'; } if (keys.d.pressed &amp;&amp; keys.e.pressed &amp;&amp; keys.v.pressed) { alert('Entering dev mode...'); } });​ </code></pre> <p>There's a number of ways to do this of course. This example doesn't require you to hold the keys down simultaneously, just that you type them in order: <kbd>d</kbd> <kbd>e</kbd> <kbd>v</kbd>. </p> <p>If you used this, you might want to augment it to clear the <code>pressed</code> flags after some time interval.</p> <p>Here's a <a href="http://jsfiddle.net/6eCx2/" rel="nofollow">working example</a>.</p> <hr> <p><sub>Disclaimer: I realize the original question said that the keys should be "pressed together". This is just an alternative as other answerers have already provided sufficient solutions for the keys being pressed together.</sub></p>
5,514,324
0
<p>You could try setting the ActiveRecord logger to stdout in your test somewhere. If you're using rspec, maybe in the spec helper?</p> <pre><code>ActiveRecord::Base.logger = Logger.new(STDOUT) </code></pre>
25,156,169
0
Show HTML table side Columns on middle column hover <p>See <a href="http://jsfiddle.net/38QZ6/1/" rel="nofollow noreferrer">http://jsfiddle.net/38QZ6/1/</a></p> <pre><code>.feelo_table:hover .labels { display:table-cell; } </code></pre> <p>In the above code the expected output is when I hover the middle table column , I need to popup the side columns, as a wing like projection sideways. I am half way to it. I couldn't align the side columns properly.</p> <p>Below is the expected output:</p> <p><img src="https://i.stack.imgur.com/1OY4q.png" alt="http://i.stack.imgur.com/Pumgy.png"></p>
30,918,657
0
PHP HTML MySQL for offline solution <p>I am trying to develop a website using PHP and MySQL that support for offline.</p> <p>My requirement would be:</p> <ul> <li>when internet is down, user able to use the browser and browse to my full website and doing normal operation. 2</li> <li><p>By doing normal operation, it means user are able to perform normal CRUD functionality.</p></li> <li><p>CRUD work with mysql, which when internet is down, mysql is still running locally and when internet is back, there will be a sync process to sync local mysql into server db.</p></li> </ul> <p>Any suggestion of solution or links to the solution for this is much appreciated.</p>
24,754,536
0
How can i remove NSInvalidArgumentException Trace: <redacted> <redacted> .. My App Name.. <redacted>.. from Google Analytics? <p>Smart Peoples!!</p> <p>I turned on the uncaught exception logging in my iOS app:</p> <pre><code>[GAI sharedInstance].dispatchInterval = 120; [[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelVerbose]; id&lt;GAITracker&gt; tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-########-#"]; [GAI sharedInstance].defaultTracker = tracker; [GAI sharedInstance].trackUncaughtExceptions = YES; </code></pre> <p>In Google Analytics, I can click Crashes and Exceptions under Behavior and see a couple of crash reports, but they look like this:</p> <p><strong>ALL»EXCEPTION DESCRIPTION: NSInvalidArgumentException Trace: &lt; redacted > &lt; redacted > _CF_forwarding_prep_0 &lt; redacted > 0x0005f4d3 My App Name &lt; redacted > &lt; redacted > &lt; redacted > &lt; redacted ></strong></p> <p>What's with all the "redacted"? How do I get to see the actual exception message and stack trace? As is, this message is not very useful.</p> <p>Also my client have'nt reported me about any kind of crashes So How can I remove this Exception from Google Analytics ? Any Help Would be Highly Appreciable.</p> <p>Thanks in Advance!!</p>
23,066,609
0
Manual tree fitting memory consumption in sklearn <p>I'm using sklearn's <code>RandomForestClassifier</code> for a classification problem. I would like to train the trees of the a forest individually as I am grabbing subsets of a (VERY) large set for each tree. However, when I fit trees manually, memory consumption bloats.</p> <p>Here's a line-by-line memory profile using <code>memory_profiler</code> of a custom fit vs using the <code>RandomForestClassifier</code>'s <code>fit</code> function. As far as I can tell the source fit function performs the same steps as the custom fit. So what gives with all the extra memory??</p> <p>normal fit:</p> <pre><code>Line # Mem usage Increment Line Contents ================================================ 17 28.004 MiB 0.000 MiB @profile 18 def normal_fit(): 19 28.777 MiB 0.773 MiB X = random.random((1000,100)) 20 28.781 MiB 0.004 MiB Y = random.random(1000) &lt; 0.5 21 28.785 MiB 0.004 MiB rfc = RFC(n_estimators=100,n_jobs=1) 22 28.785 MiB 0.000 MiB rfc.n_classes_ = 2 23 28.785 MiB 0.000 MiB rfc.classes_ = array([False, True],dtype=bool) 24 28.785 MiB 0.000 MiB rfc.n_outputs_ = 1 25 28.785 MiB 0.000 MiB rfc.n_features_ = 100 26 28.785 MiB 0.000 MiB rfc.bootstrap = False 27 37.668 MiB 8.883 MiB rfc.fit(X,Y) </code></pre> <p>custom fit:</p> <pre><code>Line # Mem usage Increment Line Contents ================================================ 4 28.004 MiB 0.000 MiB @profile 5 def custom_fit(): 6 28.777 MiB 0.773 MiB X = random.random((1000,100)) 7 28.781 MiB 0.004 MiB Y = random.random(1000) &lt; 0.5 8 28.785 MiB 0.004 MiB rfc = RFC(n_estimators=100,n_jobs=1) 9 28.785 MiB 0.000 MiB rfc.n_classes_ = 2 10 28.785 MiB 0.000 MiB rfc.classes_ = array([False, True],dtype=bool) 11 28.785 MiB 0.000 MiB rfc.n_outputs_ = 1 12 28.785 MiB 0.000 MiB rfc.n_features_ = 100 13 73.266 MiB 44.480 MiB for i in range(rfc.n_estimators): 14 72.820 MiB -0.445 MiB rfc._make_estimator() 15 73.262 MiB 0.441 MiB rfc.estimators_[-1].fit(X,Y,check_input=False) </code></pre>
28,846,410
0
Select Weekly/Bi-weekly/twice a week in multidatespicker <p>i'm not sure if this is possible but i can't find any clue of doing this with multidatespicker.. i'm creating a web booking system which need to allow customer to select any booking date which they like. But now my client was requesting to create package like weekly package(4 times per month), biweekly(1 times per 2 weeks) and etc..For weekly example.. when customer choose tuesday of that week.. the rest of 6 days all will be disable.. and for biweekly.. for that week and next week will be disable.. </p> <p>Thousand appreciate for someone who could help :)</p>
31,790,460
0
Haproxy - How to parse and store parts of an incoming URL <p>If I have an incoming url like so:</p> <p>foo.com/FooID/1234/FooLocation/NYC</p> <p>How do I go about extracting these values from the incoming request so I can use them for a lookup in a map file. I know this must be doable with regex, but I was hoping for a more elegant solution similar to extracting url parameters:</p> <p>Example:</p> <p><code>http-request set-header X-FooId %[url_param(FooID)].</code></p> <p>If not, which regex function would be best used in this instance so I could either store this value or access it directly via a header?</p>
17,824,017
0
<p>Try this:</p> <pre><code>SELECT count(MobileNo), count( case when m.Month=1 then m.Month else 0 end ) as Month 1, count( case when m.Month=2 then m.Month else 0 end ) as Month 2, count( case when m.Month=3 then m.Month else 0 end ) as Month 3, . . . count( case when m.Month=12 then m.Month else 0 end ) as Month 12 FROM MonthlySubscriber m GROUP BY m.Month </code></pre>
17,701,718
0
Combining solve and dsolve to solve equation systems with differential and algebraic equations <p>I am trying to solve equation systems, which contain algebraic as well as differential equations. To do this symbolically I need to combine dsolve and solve (do I?).</p> <p>Consider the following example: We have three base equations</p> <pre><code>a == b + c; % algebraic equation diff(b,1) == 1/C1*y(t); % differential equation 1 diff(c,1) == 1/C2*y(t); % differential equation 2 </code></pre> <p>Solving both differential equations, eliminating int(y,0..t) and then solving for c=f(C1,C2,a) yields</p> <pre><code>C1*b == C2*c or C1*(a-c) == C2*c c = C1/(C1+C2) * a </code></pre> <p>How can I convince Matlab to give me that result? Here is what I tried:</p> <pre><code>syms a b c y C1 C2; Eq1 = a == b + c; % algebraic equation dEq1 = 'Db == 1/C1*y(t)'; % differential equation 1 dEq2 = 'Dc == 1/C2*y(t)'; % differential equation 2 [sol_dEq1, sol_dEq2]=dsolve(dEq1,dEq2,'b(0)==0','c(0)==0'); % this works, but no inclusion of algebraic equation %[sol_dEq1, sol_dEq2]=dsolve(dEq1,dEq2,Eq1,'c'); % does not work %solve(Eq1,dEq1,dEq2,'c') % does not work %solve(Eq1,sol_dEq_C1,sol_dEq_C2,'c') % does not work </code></pre> <p>No combination of solve and/or dsolve with the equations or their solutions I tried gives me a useful result. Any ideas?</p>
6,279,882
0
Tutorials for Writing Common Code for use on Windows, OS X, iOS, and potentially Android <p>I'm looking at writing an application that I would like to use on Windows, OSX, and iOS (maybe pushing into Android if other people want to use it). I want to duplicate as little work as possible and I'm having a hard time finding information on the best way to do this. </p> <p>From what I've found so far I can't use a framework like QT because iOS doesn't support QT so it looks like I'm stuck recreating the interface for each target. I'm looking at writing the business logic in C++ because it seems to be supported by the native tools (Visual Studio and xCode).</p> <p>Has anyone had experience with a setup like this and if so can you point me towards a good reference for this kind of development?</p>
14,508,920
0
<p>The new <code>JLabel</code> is not appearing as you would need to call <code>revalidate()</code> and <code>repaint()</code> to update the container to account for the newly added component.</p> <p>From your use of <code>setBounds</code>, it appears you are using absolute positioning (If not, a layout manager will pay no heed to this call). <em>Always</em> better to use a <a href="http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html" rel="nofollow">layout manager</a> for positioning &amp; sizing components..</p> <p>You could simply call <code>setText</code> on an existing <code>JLabel</code> instead of adding a new one to the container:</p> <pre><code>b3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { final JFileChooser fc = new JFileChooser(); int returnVal = fc.showOpenDialog(fc); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); String fileName = file.getName(); l6.setText(fileName); } } }); </code></pre>
27,698,375
0
How to generate 32 bit UUID in iOS? <p>I know that can generate a UUID with <a href="https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSUUID_Class/index.html" rel="nofollow">NSUUID</a>:</p> <pre><code>NSString *uuid = [[NSUUID UUID] UUIDString]; </code></pre> <p>But this is 128-bit values.</p> <p>I want to get a 32-bit UUID how to do that?</p>
7,987,073
0
<p><a href="http://en.wikipedia.org/wiki/Indent_style" rel="nofollow">http://en.wikipedia.org/wiki/Indent_style</a> http://en.wikipedia.org/wiki/Coding_conventions</p> <p>Are a good place to start. I personally use the K&amp;R style for clarity. When it comes down to it though all you need to do is find a style you like and stick with it. Consistency ;]</p>
40,384,206
0
<p>I found a solution! Thanks largely to <a href="https://turbofuture.com/computers/Creating-Dynamic-Charts-using-the-OFFSET-function-and-Named-Ranges-in-Excel-2007-and-Excel-2010" rel="nofollow noreferrer">this page</a>. Here's what I did:</p> <p>I created made a named range using this formula: <code>=OFFSET(Report!$B$1,1,0,COUNTIF(Report!$B$2:$B$30,"&lt;&gt;-"),1)</code></p> <p>For that to work, I had to change all the empty cells to output <code>"-"</code> when empty in stead of <code>""</code>. I couldn't get <code>COUNTIF</code> to accept <code>"&lt;&gt;"""</code> or <code>"&lt;&gt;"</code> or any other weird tricks I tried. Using <code>"-"</code> was easier.</p> <p>That makes a dynamic named range that changes size as I put data into the sheet. I named a similar range for everything I'm trying to chart (Approved Status, Call Ready, Not Ready). The chart was able to accept those names and now it's dynamically sized. If I only have three agents on the sheet, it shows three huge bars. With twenty, it shows twenty bars (exactly what I was looking for).</p> <p>One other tip: I changed my first row to output <code>""</code> when empty, so that <code>COUNTIF(Report!$B$2:$B$30,"&lt;&gt;-")</code> always returns at least 1 (otherwise you get annoying errors because you have a named range referencing a 0-length array).</p>
37,343,369
1
Is there a way to sort custom objects in a custom way in Python? <p>I'm using web.py to spin up endpoints and as such, I present a list of endpoints like so</p> <pre><code>urls = ('/(.*)', 'base', '/shapes/(.*)', 'shapes', '/sounds/(.*)', 'sounds', '/shapes/rectangualar/(.*)', 'rectangualarShapes', '/sounds/loud/(.*)', 'loudSounds') </code></pre> <p>As web.py will see the first one and match all possible endpoints to it, they need to be ordered, most specific first, i.e.</p> <pre><code>urls = ('/shapes/rectangualar/(.*)', 'rectangualarShapes', '/shapes/(.*)', 'shapes', '/sounds/loud/(.*)', 'loudSounds' '/shapes/(.*)', 'shapes', '/sounds/(.*)', 'sounds', '/(.*)', 'base') </code></pre> <p>I want to order these, by URI. Firstly if there's a simple way to do it, as tuples, it would be great but I figure I need to convert them to objects</p> <pre><code>class Endpoint(object): def __init__(self, id, classname): self.id = id self.classname = classname def getId(item): return self.id </code></pre> <p>and <code>print sorted(endpointList, key=id)</code> them. How would I do this in Python 3+? I've come across comparator functions but it seems they are deprecated.</p> <p>What is the best way to do custom sorting?</p>
23,432,284
0
<p>Well, you can check if a variable is an array or string using instanceOf or typeOf or .constuctor: See here <a href="http://tobyho.com/2011/01/28/checking-types-in-javascript/" rel="nofollow">http://tobyho.com/2011/01/28/checking-types-in-javascript/</a> </p> <pre><code> if(myVariable instanceOf Array){ //multi select } else if(myVariable.constructor === String){ //single select } </code></pre> <hr> <p>or you can simply convert your string to an array and check the length of the array.</p> <pre><code> $scope.myVariable = $scope.myPreviousVar.split(','); // or however you want to delimit this if($scope.myVariable.length === 1){ //single select } else if($scope.myVariable.length &gt; 1){ //multi select } </code></pre>
14,997,339
0
<p>One other idea for you is CodeIgniter Template.</p> <p>Here you have the link: <a href="http://williamsconcepts.com/ci/codeigniter/libraries/template/reference.html" rel="nofollow">http://williamsconcepts.com/ci/codeigniter/libraries/template/reference.html</a></p> <p>You can download, read the documentation and create your own template easly.</p>
12,595,562
0
<p>u can solve it by using support v4 make the tab2 extends fragment-activity and wish item of list extends fragment and than u call those fragment and open them in the tab2 wish this can help u</p>
15,590,052
0
<p>I tried to understand your code and failed... However I believe that I can recommend you to create special flag, (e.g. <code>buttonClicked</code>). The value of this variable will be <code>false</code>.</p> <p>When user clicks button the flow should arrive to code like this:</p> <pre><code>if (buttonClicked) { return; } buttonClicked = true; // do other stuff hrere </code></pre> <p>Please do not forget to synchronize this piece of code. Otherwise it could be executed simultaneously if user clicks fast enough.</p>
32,698,932
0
<p>Try this. Simply test for what button was pressed when Sale is selected. </p> <p>As always, it is recommended that you validate this in your backend, too.</p> <pre><code>$(document).on('change', '#transfertype', function () { var purchaseprice = $('#purchaseprice'); if ($(this).val() === '' || $(this).val() === 'Sale') { purchaseprice.val('').prop('readOnly', false); $("#purchaseprice").keydown(function (e) { // Allow: backspace, delete, tab, escape, enter and . if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 || // Allow: Ctrl+A, Command+A (e.keyCode == 65 &amp;&amp; (e.ctrlKey === true || e.metaKey === true)) || // Allow: home, end, left, right, down, up (e.keyCode &gt;= 35 &amp;&amp; e.keyCode &lt;= 40)) { // let it happen, don't do anything return; } // Ensure that it is a number and stop the keypress if ((e.shiftKey || (e.keyCode &lt; 48 || e.keyCode &gt; 57)) &amp;&amp; (e.keyCode &lt; 96 || e.keyCode &gt; 105)) { e.preventDefault(); } }); } else { purchaseprice.val($(this).val()).prop('readOnly', true); purchaseprice.valid(); } calculateTotal(); </code></pre> <p>});</p> <p><a href="https://jsfiddle.net/2qmre9rv/3/" rel="nofollow">jsfiddle</a></p> <p><a href="http://stackoverflow.com/questions/995183/how-to-allow-only-numeric-0-9-in-html-inputbox-using-jquery">Original function</a></p>
13,009,926
0
<p>Is this what you are looking for?</p> <pre><code>#footer { display: inline-block; max-width: 1600px; min-width: &lt;your min width&gt;; text-align: center; } #footer&gt;* {display: inline-block;text-align: left;} #footer #navJumpMenu{float:right;} #footer #jumperMenu{float:left;} </code></pre> <p>Hope that helps.</p>
32,823,117
0
<p>Put a info.php file on your server having code </p> <pre><code> &lt;?php phpinfo(); ?&gt; </code></pre> <p>if this code execute and show you server information then your server configuration is ok and your file name is added with some other extention, if not then you need to first setup it.</p>