pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
10,893,759
0
<p>Another way to do this would be to create a singleton class.</p> <pre><code>#include &lt;fstream&gt; #include &lt;map&gt; #include &lt;string&gt; class ConfigStore { public: static ConfigStore&amp; get() { static ConfigStore instance; return instance; } void parseFile(std::ifstream&amp; inStream); template&lt;typename _T&gt; _T getValue(std::string key); private: ConfigStore(){}; ConfigStore(const ConfigStore&amp;); ConfigStore&amp; operator=(const ConfigStore&amp;); std::map&lt;std::string,std::string&gt; storedConfig; }; </code></pre> <p>Here the configuration is saved in a map, meaning as long as parseFile can read the file and getValue can parse the type there is no need to recompile the config class if you add new keys.</p> <p>Usage:</p> <pre><code>std::ifstream input("somefile.txt"); ConfigStore::get().parseFile(input); std::cout&lt;&lt;ConfigStore::get().getValue&lt;std::string&gt;(std::string("thing"))&lt;&lt;std::endl; </code></pre>
24,521,990
0
<p>easily done, you just need to set the display to inline-block for those two <code>iframe</code>s. </p> <pre><code>iframe:nth-child(2),iframe:nth-child(3){ display:inline-block; } </code></pre> <p><a href="http://codepen.io/lukeocom/pen/JkFhl" rel="nofollow">here's an example</a>.</p> <p><code>iframe</code>s are somewhat frowned upon. You might like to consider using <code>div</code>s with ajax instead, utilizing the jquery <code>$.load</code> function to load whatever you like into them. You can read up on that <a href="http://api.jquery.com/load/" rel="nofollow">here</a>. </p> <p>Hope that helps...</p>
27,996,685
0
<p>Skip to <strong>Processing the Image</strong> to find out how to convert <code>UIImage</code> to <code>NSData</code> (which is what Core Data uses)</p> <p>Or download from <a href="https://github.com/romainmenke/SimpleCam" rel="nofollow noreferrer">github</a></p> <p><strong>Core Data Setup:</strong></p> <p>Set up two entities : Full Resolution and Thumbnail. Full Resolutions is to store the original image. Thumbnail to store a smaller version to be used inside the app. You might use a smaller version in a <code>UICollectionView</code> overview for example.</p> <p>Images are stored as <code>Binary Data</code> in <code>Core Data</code>. The corresponding type in <code>Foundation</code> is <code>NSData</code>. Convert back to <code>UIImage</code> with <code>UIImage(data: newImageData)</code></p> <p><a href="https://i.stack.imgur.com/HJkRs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HJkRs.png" alt="enter image description here"></a></p> <hr> <p><a href="https://i.stack.imgur.com/WU38e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WU38e.png" alt="enter image description here"></a></p> <hr> <p>Check the <strong>Allows External Storage</strong> box for the Binary Data fields. This will automatically save the images in the file system en reference them in Core Data</p> <p><a href="https://i.stack.imgur.com/ctgDN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ctgDN.png" alt="enter image description here"></a></p> <p>Connect the two entities, creating a one to one relationship between the two. </p> <p><a href="https://i.stack.imgur.com/JXxf2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JXxf2.png" alt="enter image description here"></a></p> <p>Go to <strong>Editor</strong> en select Create <strong>NSManagedObjectSubclass</strong>. This will generate files with Classes representing your Managed Object SubClasses. These will appear in your project file structure.</p> <p><a href="https://i.stack.imgur.com/603At.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/603At.png" alt="enter image description here"></a></p> <hr> <p><strong>Basic ViewController Setup:</strong></p> <p>Import the following :</p> <pre><code>import UIKit import CoreData </code></pre> <hr> <ul> <li>Setup two <code>UIButtons</code> and an <code>UIImageView</code> in the Interface Builder</li> <li>Create two dispatch queues, one for CoreData and one for UIImage conversions</li> </ul> <hr> <pre><code>class ViewController: UIViewController { // imageview to display loaded image @IBOutlet weak var imageView: UIImageView! // image picker for capture / load let imagePicker = UIImagePickerController() // dispatch queues let convertQueue = dispatch_queue_create("convertQueue", DISPATCH_QUEUE_CONCURRENT) let saveQueue = dispatch_queue_create("saveQueue", DISPATCH_QUEUE_CONCURRENT) // moc var managedContext : NSManagedObjectContext? override func viewDidLoad() { super.viewDidLoad() imagePickerSetup() // image picker delegate and settings coreDataSetup() // set value of moc on the right thread } // this function displays the imagePicker @IBAction func capture(sender: AnyObject) { // button action presentViewController(imagePicker, animated: true, completion: nil) } @IBAction func load(sender: AnyObject) { // button action loadImages { (images) -&gt; Void in if let thumbnailData = images?.last?.thumbnail?.imageData { let image = UIImage(data: thumbnailData) self.imageView.image = image } } } } </code></pre> <hr> <p>This function sets a value to <code>managedContext</code> on the correct thread. Since CoreData needs all operations in one <code>NSManagedObjectContext</code> to happen in the same thread.</p> <pre><code>extension ViewController { func coreDataSetup() { dispatch_sync(saveQueue) { self.managedContext = AppDelegate().managedObjectContext } } } </code></pre> <hr> <p>Extend the <code>UIViewController</code> so it conforms to <code>UIImagePickerControllerDelegate</code> and <code>UINavigationControllerDelegate</code> These are needed for the <code>UIImagePickerController</code>.</p> <p>Create a setup function and also create the delegate function <code>imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?)</code></p> <pre><code>extension ViewController : UIImagePickerControllerDelegate, UINavigationControllerDelegate { func imagePickerSetup() { imagePicker.delegate = self imagePicker.sourceType = UIImagePickerControllerSourceType.Camera } // When an image is "picked" it will return through this function func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) { self.dismissViewControllerAnimated(true, completion: nil) prepareImageForSaving(image) } } </code></pre> <p>Immediately dismiss the <code>UIImagePickerController</code>, else the app will appear to freeze.</p> <hr> <p><strong>Processing the Image:</strong></p> <p>Call this function inside <code>imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?)</code>. </p> <ul> <li><p>First get the current date with <code>timeIntervalSince1970</code>. This returns an <code>NSTimerInterval</code> in seconds. This converts nicely to a <code>Double</code>. It will serve as a unique id for the images and as a way to sort them.</p></li> <li><p>Now is a good time to move to the separate queue and free up the main queue. I used <code>dispatch_async(convertQueue)</code> first to do the heavy lifting on a separate thread.</p></li> <li><p>Then you need to convert the <code>UIImage</code> to <code>NSData</code> this is done with <code>UIImageJPEGRepresentation(image, 1)</code>. The <code>1</code> represents the quality where <code>1</code> is the highest and <code>0</code> is the lowest. It returns an optional so I used optional binding.</p></li> <li><p>Scale the image to a desired thumbnail size and also convert to <code>NSData</code>.</p></li> </ul> <p><strong>Code:</strong></p> <pre><code>extension ViewController { func prepareImageForSaving(image:UIImage) { // use date as unique id let date : Double = NSDate().timeIntervalSince1970 // dispatch with gcd. dispatch_async(convertQueue) { // create NSData from UIImage guard let imageData = UIImageJPEGRepresentation(image, 1) else { // handle failed conversion print("jpg error") return } // scale image, I chose the size of the VC because it is easy let thumbnail = image.scale(toSize: self.view.frame.size) guard let thumbnailData = UIImageJPEGRepresentation(thumbnail, 0.7) else { // handle failed conversion print("jpg error") return } // send to save function self.saveImage(imageData, thumbnailData: thumbnailData, date: date) } } } </code></pre> <p>This function does the actual saving.</p> <ul> <li>Go the the CoreData thread with <code>dispatch_barrier_sync(saveQueue)</code></li> <li>First insert a new FullRes and a new Thumbnail object into the Managed Object Context.</li> <li>Set the values</li> <li>Set the relationship between FullRes and Thumbnail</li> <li>Use <code>do try catch</code> to attempt a save</li> <li>Refresh the Managed Object Context to free up memory</li> </ul> <p>By using <code>dispatch_barrier_sync(saveQueue)</code> we are sure that we can safely store a new image and that new saves or loads will wait until this is finished.</p> <p><strong>Code:</strong></p> <pre><code>extension ViewController { func saveImage(imageData:NSData, thumbnailData:NSData, date: Double) { dispatch_barrier_sync(saveQueue) { // create new objects in moc guard let moc = self.managedContext else { return } guard let fullRes = NSEntityDescription.insertNewObjectForEntityForName("FullRes", inManagedObjectContext: moc) as? FullRes, let thumbnail = NSEntityDescription.insertNewObjectForEntityForName("Thumbnail", inManagedObjectContext: moc) as? Thumbnail else { // handle failed new object in moc print("moc error") return } //set image data of fullres fullRes.imageData = imageData //set image data of thumbnail thumbnail.imageData = thumbnailData thumbnail.id = date as NSNumber thumbnail.fullRes = fullRes // save the new objects do { try moc.save() } catch { fatalError("Failure to save context: \(error)") } // clear the moc moc.refreshAllObjects() } } } </code></pre> <p><strong>To load an image :</strong></p> <pre><code>extension ViewController { func loadImages(fetched:(images:[FullRes]?) -&gt; Void) { dispatch_async(saveQueue) { guard let moc = self.managedContext else { return } let fetchRequest = NSFetchRequest(entityName: "FullRes") do { let results = try moc.executeFetchRequest(fetchRequest) let imageData = results as? [FullRes] dispatch_async(dispatch_get_main_queue()) { fetched(images: imageData) } } catch let error as NSError { print("Could not fetch \(error), \(error.userInfo)") return } } } } </code></pre> <p><strong>The functions used to scale the image:</strong></p> <pre><code>extension CGSize { func resizeFill(toSize: CGSize) -&gt; CGSize { let scale : CGFloat = (self.height / self.width) &lt; (toSize.height / toSize.width) ? (self.height / toSize.height) : (self.width / toSize.width) return CGSize(width: (self.width / scale), height: (self.height / scale)) } } extension UIImage { func scale(toSize newSize:CGSize) -&gt; UIImage { // make sure the new size has the correct aspect ratio let aspectFill = self.size.resizeFill(newSize) UIGraphicsBeginImageContextWithOptions(aspectFill, false, 0.0); self.drawInRect(CGRectMake(0, 0, aspectFill.width, aspectFill.height)) let newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return newImage } } </code></pre>
13,523,529
0
<p>JSON objects are made only to transfer strings, basic objects, integers and a few other things. They are not meant for sending images. However, if you still want to try implementing this in your own way, I can think of two ways to do it. Firstly, just send the name of the images (exact link) or upload it and provide the path.</p> <p>Or secondly, convert it to base64 in the browser, send it, and have code convert it back whenever required.</p> <p>That would look something like this:</p> <pre><code>&lt;form method="async" onsubmit="addImage(this.image)"&gt; &lt;input type="file" name="image" /&gt;&lt;br /&gt; &lt;input type="submit" value="Submit" /&gt; &lt;/form&gt; &lt;div id="content"&gt;&lt;/div&gt; &lt;script&gt; function addImage(img) { $.ajax({ type: "POST", url: "/chat", data: {'image': toBase64(img)}, cache: false }); } function toBase64(img) { // Create an HTML5 Canvas var canvas = $( '&lt;canvas&gt;&lt;/canvas&gt;' ) .attr( 'width', img.width ) .attr( 'height', img.height ); // Initialize with image var context = canvas.getContext("2d"); context.drawImage( img, 0, 0 ); // Convert and return return context.toDataURL("image/png"); } &lt;/script&gt; </code></pre>
20,717,852
0
<p>Vaadin provides a DefaultTableFieldFactory which does map</p> <ul> <li>Date to a DateField</li> <li>Boolean to a CheckBox</li> <li>other to TextField</li> </ul> <p>The DefaultTableFieldFactory is already set on the table. So in your case, if you just want to have CheckBoxes for your boolean fields, I wouldn't implement an own TableFieldFactory. Here's an example:</p> <pre><code>Table table = new Table(); table.addContainerProperty("text", String.class, ""); table.addContainerProperty("boolean", Boolean.class, false); table.setEditable(true); Object itemId = table.addItem(); table.getItem(itemId).getItemProperty("text").setValue("has accepted"); table.getItem(itemId).getItemProperty("boolean").setValue(true); </code></pre> <p>If you really need to have your own TableFieldFactory then Vaadin recommends:</p> <blockquote> <p>You could just implement the TableFieldFactory interface, but we recommend that you extend the DefaultFieldFactory according to your needs. In the default implementation, the mappings are defined in the createFieldByPropertyType() method (you might want to look at the source code) both for tables and forms.</p> </blockquote> <p>In your code given in the question you always return a TextField. For your missing CheckBoxes you need to return in the specific case a CheckBox.</p> <p>Don't forget to <code>setEditable(true)</code> when using FieldFactories.</p> <p>More information <a href="https://vaadin.com/book/-/page/components.table.html" rel="nofollow">here</a> under 5.16.3. Editing the Values in a Table.</p>
38,820,117
0
<p>check the class of the two objects (label and combined) you notice they are not the same. you can then subset the one with a different dimension with <strong><em>dimRid &lt;- combined[,1]</em></strong> </p>
549,850
0
<p>Is the link from a different domain? Browsers may restrict access to any information about what a user has open in other windows or frames if it's on another site as a security precaution.</p>
6,715,093
0
Why is there no edit in Blend option in WPF4? <p>I am a Silverlight 4 developer getting started with WPF4. In Silverlight 4, there is option available in menu "Edit in Blend" when you right click on any xaml file. Why is this option not available in WPF4?</p> <p>Do I need to download some patch for Visual Studio 2010?</p> <p>Thanks in advance :)</p>
31,450,970
0
php dll cannot be loaded into server when using apachelounge VC14 build and php.net VC11 build <p>I am following this <a href="http://superuser.com/questions/748117/how-to-manually-install-apache-php-and-mysql-on-windows">great post</a></p> <p>Version details;</p> <p>Apache 2.4.16 php 5.6.11 mysql community installer 5.6.25</p> <p>Directory structure:</p> <p>C: server Every setup goes here</p> <p>Windows System - 7 - 64 bit.</p> <p><strong>Error</strong></p> <pre><code>httpd.exe: Syntax error on line 178 of C:/server/httpd/Apache24 /conf/httpd.conf: Cannot load C:\\server\\php\\php5apache2_4.dll into server: The specified module could not be found. </code></pre> <p><strong>code which causes</strong></p> <pre><code>LoadModule php5_module C:\server\php\php5apache2_4.dll ----&gt; This Line &lt;IfModule php5_module&gt; DirectoryIndex index.html index.php AddHandler application/x-httpd-php .php PHPIniDir "C:\server\php" &lt;/IfModule&gt; </code></pre> <p>It was worked earlier - I just put a new OS and trying the same under <code>C;\server</code> for generic setup so that I can make use of it in every windows 64 bit system with same directory structure.</p> <p><strong>My doubt</strong> : Is it due to version incompatible problems</p> <p><strong>Download locations:</strong></p> <pre><code> mysql is from mysql domain php from php domain apache from apachelongue </code></pre> <p>Please help me to solve the error.</p> <p><strong>EDIT FOR A COMMENT:</strong></p> <p>php apache dll is present in the php directory </p> <p><strong>A NOTE</strong></p> <p>A question becomes stupid when you know the answer like you remember <code>a-z</code>. So no question is stupid generally.</p>
1,130,301
0
Uninstalling Excel add-in using VBScript <p>I'm trying to create a MSI installer that installs an Add-In (.xla) into Microsoft Excel (2007 in my case). Installing it goes well. I use a 'Custom Action' that runs this VBScript file:</p> <pre><code>Dim SourceDir Dim objExcel Dim objAddin SourceDir = Session.Property("CustomActionData") Set objExcel = CreateObject("Excel.Application") objExcel.Workbooks.Add Set objAddin = objExcel.AddIns.Add(SourceDir &amp; "addin.xla", True) objAddin.Installed = True objExcel.Quit Set objExcel = Nothing </code></pre> <p>I pass the location of the addin to the script using the CustomActionData property. The Add-in is copied to a folder inside 'Program Files', where it will stay until it is uninstalled. This is handled by the installer itself.</p> <p>The problem is when I use the uninstall script:</p> <pre><code>Dim objExcel Dim addin On Error Resume Next Set objExcel = CreateObject("Excel.Application") For i = 0 To objExcel.Addins.Count Set objAddin= objExcel.Addins.item(i) If objAddin.Name = "addin.xla" Then objAddin.Installed = False End If Next objExcel.Quit Set objExcel = Nothing </code></pre> <p>The addin creates a custom toolbar in Excel u[ installation. The toolbar is not removed upon uninstall, and the entry of the add-in in the 'Add-in' section of Excel's settings isn't either.</p> <p>Can anyone tell me if these two things can be done programmatically using VBScript?</p> <p>thanks in advance</p>
10,597,501
0
<p>The problem is that you're not escaping the special characters in the text, such as the <code>/</code> delimiter.</p> <p>The easiest solution is to pick a different delimiter and to specify only a part of the string, for instance</p> <pre><code>find . -name '*.html' -o -name '*.htm' | xargs fgrep -l '&lt;script&gt;i=0;try' | xargs perl -i.infected -pe 's#&lt;script&gt;i=0;try.*?&lt;/script&gt;##g' </code></pre> <p>(untested) may do the job. (The <code>.*?</code> construct picks the shortest match; I don't know how to do that in <code>sed</code>.)</p> <p>Verify with something like</p> <pre><code>find . -name '*.infected' | sed -e 's#.*#diff &amp; &amp;#' -e 's#.infected##' | sh -x </code></pre>
694,603
0
<p>The main problem is C run-time library. Python 2.4/2.5 linked against msvcr71.dll and therefore all C-extensions should be linked against this dll.</p> <p>Another option is to use gcc (mingw) instead of VS2005, you can use it to compile python extensions only. There is decent installer that allows you to configure gcc as default compiler for your Python version:</p> <p><a href="http://www.develer.com/oss/GccWinBinaries" rel="nofollow noreferrer">http://www.develer.com/oss/GccWinBinaries</a></p>
30,486,321
0
<p>Try the following idea: </p> <pre><code>try { File file = new File(path); FileWriter writer = new FileWriter(file); BufferedWriter output = new BufferedWriter(writer); for (int[] array : matrix) { for (int item : array) { output.write(item); output.write(" "); } output.write("\n"); } output.close(); } catch (IOException e) { } </code></pre>
12,785,604
0
<p>You don't specify, but assuming that JSON string is what your ajax code is receiving as the response, then you're actually re-JSONing that text, so it becomes a double-encoded string.</p> <p>jquery can auto-decode that back to a native structure for you, if you tell is that you're expecting json as a response, e.g.</p> <pre><code>$.ajax({ dataType: 'json', etc... }); </code></pre> <p>then you'd simply have</p> <pre><code>alert(result[0]['key']); </code></pre> <p>or</p> <pre><code>data = jquery.parseJSON(result); alert(data[0]['key']); </code></pre>
10,100,237
0
<p>You probably need to set <a href="http://developer.android.com/reference/android/view/animation/Animation.html#attr_android%3afillEnabled" rel="nofollow"><code>android:fillEnabled="true"</code></a> and/or <a href="http://developer.android.com/reference/android/view/animation/Animation.html#attr_android%3afillAfter" rel="nofollow"><code>android:fillAfter="true"</code></a>. </p> <p>If that does not work you can apply the change to the layout in <a href="http://developer.android.com/reference/android/view/animation/Animation.AnimationListener.html#onAnimationEnd%28android.view.animation.Animation%29" rel="nofollow"><code>AnimationListener#onAnimationEnd</code></a>. </p>
21,046,262
0
<p>You need to call <code>addNewMessageToPage</code> in your <code>Post</code> action method.</p> <pre><code>var hubContext = GlobalHost.ConnectionManager.GetHubContext&lt;ChatHub&gt;(); hubContext.Clients.All.addNewMessageToPage(chat.Name, chat.Message); </code></pre> <p>Then in your JS file:</p> <pre><code>var chatHub = $.connection.chatHub; chatHub.client.addNewMessageToPage= function (name, message) { //Add name and message to the page here }; $.connection.hub.start(); </code></pre>
34,873,261
0
<p>The size itself does't matter, the whole point of a layout is that it should be reactive to the size available. Some items will be exact sizes and others will be proportional. The proportions are based around the overall size available and the parts that you need to be exact or to fit exactly to their contents.</p> <p>It's opinion but I guess the size shown in storyboard is big enough to allow easy layout but not so big it's hard to fit on screen with other panes for code and inspectors.</p>
20,430,823
0
<p>The statement <code>Foo f();</code> is a function declaration, not a declaration of a local variable <code>f</code> of type <code>Foo</code>. To declare a local <code>Foo</code> value using the parameterless constructor you must omit the <code>()</code> </p> <pre><code>Foo f; f.doSomething(); </code></pre>
6,155,073
0
<p>If you end up going the route of uploading directly to S3 which offloads the work from your Rails server, please check out my sample projects:</p> <p>Sample project using Rails 3, Flash and MooTools-based FancyUploader to upload directly to S3: <a href="https://github.com/iwasrobbed/Rails3-S3-Uploader-FancyUploader" rel="nofollow">https://github.com/iwasrobbed/Rails3-S3-Uploader-FancyUploader</a></p> <p>Sample project using Rails 3, Flash/Silverlight/GoogleGears/BrowserPlus and jQuery-based Plupload to upload directly to S3: <a href="https://github.com/iwasrobbed/Rails3-S3-Uploader-Plupload" rel="nofollow">https://github.com/iwasrobbed/Rails3-S3-Uploader-Plupload</a></p> <p>By the way, you can do post-processing with Paperclip using something like this blog post describes:</p> <p><a href="http://www.railstoolkit.com/posts/fancyupload-amazon-s3-uploader-with-paperclip" rel="nofollow">http://www.railstoolkit.com/posts/fancyupload-amazon-s3-uploader-with-paperclip</a></p>
34,713,327
0
Appending elements to parents that called the createElement() function <p>I am trying to create a function that creates an element and takes the parameter of <code>element</code> (an object).</p> <pre><code>var createElement = function(element) { var newElement = document.createElement(element.type); var newElement_textNode = document.createTextNode(element.text); newElement.appendChild(newElement_textNode); element.parent.appendChild(newElement); }; </code></pre> <p>The only problem is I want to append the element to the element that called the function. For example: </p> <pre><code>var list = document.getElementById('ulList'); list.createElement({ type: 'li', text: 'Another item' }); </code></pre> <p>My question is how do I append it to the element that called the function, in this case, the ul <code>list</code></p>
13,807,696
0
<p>You can apply the Holo theme using the <a href="https://github.com/ChristopheVersieux/HoloEverywhere" rel="nofollow">HoloEverywhere</a> library. I use it in all my apps, and it works very well.</p> <p>You have to add it as a library project to use it. If you use Git, you can add it as a submodule.</p>
31,189,695
0
Imagemagick transitions between multiple images -- need idea <p>I am using Fred's Imagemagick scripts, particularly, <a href="http://www.fmwconcepts.com/imagemagick/fxtransitions/index.php" rel="nofollow">fxtransitions</a> to create a transition effect between two images. I am creating jpeg image frames. Later, I will use ffmpeg to turn them into video. It is my third day with Imagemagick and currently I can successfully apply the transition effect between two images with the following script. However, I also need to meet two following criteria:</p> <pre><code>$result = shell_exec("bash /cygdrive/path/to/fxtransitions -e explode -f 50 -d 1 -p 1 -r first.jpg second.jpg output.jpg"); echo $result; </code></pre> <ol> <li><p>Each image must stay for some 9 seconds without distortion and then quickly transforms into the next image. </p></li> <li><p>Currently, Fred's script allows two image inputs. Is it possible to use more than two images within the script? How can I loop through multiple images with php? </p></li> </ol>
532,319
0
Replicate Database <p>I want to execute proc of database 'A' from database 'B'. My situation is this that I have a database 'A' and a database 'B'. I want that when a proc is executed on database 'A' it will also execute on database 'B'. This is because the whole structure is the same on both databases but some procs are different in database 'B'. I want to match the result effected by both procs in DB 'A' and DB 'B'. Is there is any solution for this problem? Please help me. Thanks in advance.</p>
26,416,074
0
<p>I can give you a part of the solution: how to select full words. My script is for textarea but you can make a few changes if you want to use div contenteditable instead.</p> <p><strong><a href="http://jsfiddle.net/pmrotule/ypv5y06j/2/" rel="nofollow">JSFIDDLE DEMO</a></strong></p> <pre><code>var lastSelectStart = 0; var lastSelectEnd = 0; saveSelection = function(){ lastSelectStart = document.getElementById("text").selectionStart; lastSelectEnd = document.getElementById("text").selectionEnd; } selectWords = function(){ var divEditable = document.getElementById("text"); html = divEditable.innerHTML; var start = lastSelectStart; var end = lastSelectEnd; var before = html.substring(0,start); var after = html.substring(end); var split = before.match(/[ .,;]/gi); var startIndex = before.lastIndexOf(split[split.length-1]) + 1; split = after.match(/[ .,;]/gi); var endIndex = after.indexOf(split[0]); endIndex = end + endIndex; divEditable.selectionStart = startIndex; divEditable.selectionEnd = endIndex; // startIndex is where you insert your stars and // (endIndex + number of stars added) is where you insert your stars again } </code></pre>
40,596,310
0
Drop down value replicates in nog options Angular <p>I have a dynamically generated html table that adds rows based on the record that is displayed. I'm adding a column that will contain a dropdown. I used ng-options for it, however every time I change one record, the rest are also updated. Tried changing it to ng-repeat and get the same result. See code below:</p> <pre><code> &lt;td&gt; &lt;select class="form-control" ng-model="$ctrl.selectedRC" ng- options="r.ccd as (r.OName + ' -- '+ r.RCName) for r in $ctrl.RC track by r.ccd"&gt; &lt;/select&gt; &lt;!--if I have 5 records, all dropdowns in the table change --&gt; &lt;/td&gt; </code></pre> <p>Using ng-repeat:</p> <pre><code> &lt;select class="form-control" ng-model="$ctrl.selectedRC" &lt;option value="" ng-selected="true"&gt;--Select one--&lt;/option&gt; &lt;option ng-repeat="r in $ctrl.RC" value="{{r.OName}}" ng-selected="{{r.OName === selectedRC}}"&gt;{{r.RCName}} &lt;/option&gt; &lt;/select&gt; </code></pre> <p>I know that these two are currently displaying two different things (one a concatenated set of values, the other juts one). But my main interest is to figure out how to have each <code>&lt;td&gt;</code> have its own dropdown without affecting the rest of the rows.</p>
7,431,008
0
Should a reference table include numeric PK identity column value of 0? <p>We have a table that contains the valid currency codes. We are choosing to use a numeric value as the primary key rather than a 3 char ISO Currency code, for example. </p> <p>General consensus has concluded that this <code>CurrencyId</code> column should contain values that begin with zero. Since the US dollar is the primary currency for us, it claimed the first position with a value of 0.</p> <p>My thought is that identity columns should not start at zero for the sole reason that some languages initialize numerics to zero and as a result the currency code may be unintentionally set to <code>USD</code> when really it was never assigned.</p> <p>Am I all wet? I would prefer to assign a <code>CurrencyId</code> of 1 to <code>USD</code>.</p>
37,215,952
0
iPad Retina model recognition with swift <p>I'm trying to recognise if the iPad Retina has my app and then change something in my code. Until now i have this model map from the internet and also i have found fro iPad Pro.</p> <pre><code>public enum Model : String { case simulator = "simulator/sandbox", iPod1 = "iPod 1", iPod2 = "iPod 2", iPod3 = "iPod 3", iPod4 = "iPod 4", iPod5 = "iPod 5", iPad2 = "iPad 2", iPad3 = "iPad 3", iPad4 = "iPad 4", iPhone4 = "iPhone 4", iPhone4S = "iPhone 4S", iPhone5 = "iPhone 5", iPhone5S = "iPhone 5S", iPhone5C = "iPhone 5C", iPadMini1 = "iPad Mini 1", iPadMini2 = "iPad Mini 2", iPadMini3 = "iPad Mini 3", iPadAir1 = "iPad Air 1", iPadAir2 = "iPad Air 2", iPhone6 = "iPhone 6", iPhone6plus = "iPhone 6 Plus", iPhone6S = "iPhone 6S", iPhone6Splus = "iPhone 6S Plus", iPadPro = "iPad Pro", iPadRetina = "iPad Retina", unrecognized = "?unrecognized?" } public extension UIDevice { public var type: Model { var systemInfo = utsname() uname(&amp;systemInfo) let modelCode = withUnsafeMutablePointer(&amp;systemInfo.machine) { ptr in String.fromCString(UnsafePointer&lt;CChar&gt;(ptr)) } var modelMap : [ String : Model ] = [ "i386" : .simulator, "x86_64" : .simulator, "iPod1,1" : .iPod1, "iPod2,1" : .iPod2, "iPod3,1" : .iPod3, "iPod4,1" : .iPod4, "iPod5,1" : .iPod5, "iPad2,1" : .iPad2, "iPad2,2" : .iPad2, "iPad2,3" : .iPad2, "iPad2,4" : .iPad2, "iPad2,5" : .iPadMini1, "iPad2,6" : .iPadMini1, "iPad2,7" : .iPadMini1, "iPhone3,1" : .iPhone4, "iPhone3,2" : .iPhone4, "iPhone3,3" : .iPhone4, "iPhone4,1" : .iPhone4S, "iPhone5,1" : .iPhone5, "iPhone5,2" : .iPhone5, "iPhone5,3" : .iPhone5C, "iPhone5,4" : .iPhone5C, "iPad3,1" : .iPad3, "iPad3,2" : .iPad3, "iPad3,3" : .iPad3, "iPad3,4" : .iPad4, "iPad3,5" : .iPad4, "iPad3,6" : .iPad4, "iPhone6,1" : .iPhone5S, "iPhone6,2" : .iPhone5S, "iPad4,1" : .iPadAir1, "iPad4,2" : .iPadAir2, "iPad4,4" : .iPadMini2, "iPad4,5" : .iPadMini2, "iPad4,6" : .iPadMini2, "iPad4,7" : .iPadMini3, "iPad4,8" : .iPadMini3, "iPad4,9" : .iPadMini3, "iPhone7,1" : .iPhone6plus, "iPhone7,2" : .iPhone6, "iPhone8,1" : .iPhone6S, "iPhone8,2" : .iPhone6Splus, "iPad6,3" : .iPadPro, "iPad6,4" : .iPadPro, "iPad6,7" : .iPadPro, "iPad6,8" : .iPadPro ] if let model = modelMap[String.fromCString(modelCode!)!] { return model } return Model.unrecognized } } </code></pre> <p>And i check out the model that the user has with this simple case switch code</p> <pre><code> switch UIDevice().type { case .iPhone4S: print("iphone4s") case .iPhone5: print("iphone5") case .iPadAir2: print("mos def im an ipad air 2") case .iPadPro: print("am i an ipad Pro?") default: print("i'm a pretty little simulator") } </code></pre> <p>So my questions are these First of all, because i dont have an ipad Pro, is the code correct? And lastly, what should i do so i can recognise also the ipad Retina ???</p> <p>Thanks a lot!</p>
19,135,152
0
<p>Try to use <code>Grid</code> with <code>IsSharedSizeScope</code>, instead of <code>StackPanel</code>, like below:</p> <pre><code>&lt;Grid Grid.IsSharedSizeScope="true" HorizontalAlignment="Center"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition SharedSizeGroup="buttons"/&gt; &lt;ColumnDefinition SharedSizeGroup="buttons"/&gt; &lt;ColumnDefinition SharedSizeGroup="buttons"/&gt; &lt;ColumnDefinition SharedSizeGroup="buttons"/&gt; &lt;ColumnDefinition SharedSizeGroup="buttons"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Button x:Name="PreviousPage" Content="Previous" Grid.Column="0"/&gt; &lt;Button x:Name="Info" Content="Information" Grid.Column="1"/&gt; &lt;Button x:Name="InetTicket" Content="Internet ticket" Grid.Column="2"/&gt; &lt;Button x:Name="FindStation" Content="Find station" Grid.Column="3"/&gt; &lt;Button x:Name="NextPage" Content="Next" Grid.Column="4"/&gt; &lt;/Grid&gt; </code></pre>
18,531,911
0
<pre><code>use HTML::TreeBuilder; my $t = HTML::TreeBuilder-&gt;new-&gt;parse_file("China.data"); sub list {my ($t, $d) = @_; $d //= 0; if (ref($t)) {say " "x$d, $t-&gt;tag; for($t-&gt;content_list) {list($_, $d+1); } } else {say " "x$d, dump($t)} } </code></pre> <p>list($t);</p>
7,255,263
0
<p>Marshaling is almost the same as serialization. The difference (in Java context) is in remote object handling, as specified in <a href="http://tools.ietf.org/html/rfc2713" rel="nofollow">rfc2713</a>. </p> <p>As for hash code value: it depends on how the object calculates its hash code. If it's calculated from the fields only, then it obviously is same as the unmarshaled object is <em>equal</em> to the original one. But if it uses <code>Object</code>'s original <code>hashCode</code>, then it's whatever the JVM happens to give to that object, and will vary from instance to instance.</p>
28,567,484
0
Does stopping query with a rollback guarantee a rollback <p>Say I have a query like this:</p> <pre><code>BEGIN Transaction UPDATE Person SET Field=1 Rollback </code></pre> <p>There are one hundred million people. I stopped the query after twenty minutes. Will SQL Server rollback the records updated?</p>
8,057,866
0
<p>In C arrays are constants, you can't change their value (that is, their address) at all, and you can't resize them.</p>
18,181,567
0
<p>This error is commonly because of a DLL version mismatch. Try deleting your <code>bin</code> folder and rebuilding the application.</p>
31,994,313
0
Multi-Part Identifier - Namespace Issue I believe <pre><code>USE VISION_DB SELECT tpi.ProfileName, tic.ChannelName FROM T_PROFILE_INFO tpi, T_INPUT_CHANNEL_INFO tic, T_PROFILE_CHANNELS INNER JOIN T_PROFILE_CHANNELS tpc ON tpc.ProfileID = ***T_PROFILE_INFO.ProfileID*** AND tpc.ChannelID = ***T_INPUT_CHANNEL_INFO.ChannelID*** </code></pre> <p>I am able to return the multi-part identifier alert for each of the two entries highlighted.</p> <p>The alias <code>tpc</code> is referenced correctly, but the right side of each expression will not. I have substituted the alias' from the <code>FROM</code> clause, but they are out of scope here.</p> <p>I have been trying to sort this for some time. I believe there is a namespace issue, but do not know how to reference the changes required.</p> <p>I run across this issue regularly, but have always been able to resolve it with a search. I can find nothing that appears to clear this up.</p>
5,393,900
0
<p>I would add that LTE implementation of TPT inheritance is nothing short of criminal. See my question <a href="http://stackoverflow.com/questions/4126668/when-quering-over-a-base-type-why-does-the-ef-provider-generate-all-those-union-a">here</a>.</p> <p>And while I'm at it, I believe that the many <a href="http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias=aps&amp;field-keywords=entity+framework+in+books&amp;x=0&amp;y=0" rel="nofollow">published EF pundits</a> are at least in part complicit. I have yet to find any published material on EF that cautions against queries of base types. If I were to try it on the model that I have, SQL Server simply gives up with the exception.</p> <blockquote> <p>Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries.</p> </blockquote> <p>I would love to rewrite the query, but LTE as absolved me of that burden. Thanks (^not)</p>
15,107,414
0
<p>It's a lambda. It replaces the integers <code>c</code> in the container <code>ln</code> with <code>0</code> if <code>c == '\n'</code> or <code>c == ' '</code>. Since the container seems to hold characters, you can basically say it replaces spaces and newlines with null-terminating characters.</p>
26,823,044
0
Distributable java files only work in dev machine <p>I created a Java application in NetBeans. That Java application contains a GUI and some external Jars.</p> <p>In the dist folder I can see a Jar file and a folder called lib where are the jars I use in the project. If I execute the Jar file the application works as expected. If I change the name of the lib folder the application does not work (meaning that the Jar is using the correct files). But when I copy the dist folder to a different machine (with the same Java version) the application does not work as expected. The user interface is shown but the functionalities does not work (the functionalities are in the external Jars i mentioned in the beginning). Can anyone help?</p> <p>EDIT:</p> <p>I checked the class-path in the MANIFEST file and everything is ok.</p>
19,931,631
0
<blockquote> <p>Are these calls equal in terms of performance?</p> </blockquote> <p>In C++11 with the new move semantics, the performance is about the same. If you are using your own classes, make sure they implement a move constructor and a move assignment operator.</p> <blockquote> <p>In the case of storing a vector of B objects in type A, would it be more efficient to pass a nameless object of type B, store them in the vector, and return pointers to the vector elements, or to create an object of type B, and pass a pointer to storage.add() and store my objects of type B in a vector of pointers?</p> </blockquote> <p>If you're refering to STL vectors, the best performance will be achieved with anonym objects, because otherwise, your object will be copied, as STL stores values, not references.</p> <p>The rule of thumb for returning objects from a collection is to return them by <em>reference</em>. That's the pattern followed by STL <a href="http://www.cplusplus.com/reference/vector/vector/at/" rel="nofollow">vector</a></p> <p>When you store pointers instead of values, you are changing the ownership of memory to the client of the vector class, because, normally, who creates an object should be responsible for deallocating it too.</p>
38,485,256
0
<p>You can add a comma-delimited list of selectors:</p> <pre><code>$('#editable-detail, #editable-detail2').editableTableWidget(); </code></pre>
30,448,081
0
Angular radio buttons are not checked correctly <p>I have two radio buttons, and they should be checked depending on some condition.</p> <pre><code>&lt;input data-ng-checked="user.contract1 || user.contract2" data-ng-model="user.agreed" type="radio" data-ng-value="true"&gt; Yes &lt;input data-ng-checked="!user.contract1 &amp;&amp; !user.contract2" data-ng-model="user.agreed" type="radio" data-ng-value="false"&gt; No </code></pre> <p>So here, we have a model <code>user.agreed</code> which holds true/false depending on whether that user has agreed:</p> <ul> <li><p>If the user has agreed to either contract, then <code>user.agreed = true</code></p></li> <li><p>If the user has not agreed to either contract, then <code>user.agreed = false</code></p></li> </ul> <p>I have noticed that when I load the page, the radio button is sometimes selected on 'No' instead of 'Yes'. I think this has to do with the digest cycle completing before my data has loaded from the server.</p> <p>But I thought doing this would be two-way binding, so if the <code>user</code> model changes, the view will change. When data gets loaded from the server, the model gets updated with the new info, and so the view should reflect this change. </p> <p>But that's not happening. How can I force <code>ng-checked</code> to reflect my model changes?</p> <p><strong>EDIT</strong> controller code:</p> <pre><code>app.controller('TestCtrl', ["QueryService", function(QueryService) { $scope.user = { contract1 = false; contactt2 = false; }; QueryService.getUser().success(function(user) { $scope.user = user; }); }); </code></pre>
35,826,555
0
DataGridRow in DataGrid MVVM <p>How can I change row color in my DataGrid using MVVM?</p> <pre><code>&lt;DataGrid x:Name="dataGrid" AutoGenerateColumns="False" SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}" SelectedItem="{Binding SelectedAction, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding students1}"&gt; </code></pre> <p>and I have property as</p> <pre><code> public Model.Student SelectedAction { get; set; } public int SelectedIndex { get; set; } </code></pre> <p>How change DataGrid Row Color for selected item?</p>
10,941,584
0
<p>Does it have to be interface? Maybe abstract class will be better.</p> <pre><code>public abstract class Square { public int getSize() { return getWidth() * getHeight(); } //no body in abstract methods public abstract int getHeight(); public abstract int getWidth(); } public class Square1 extends Square { public int getHeight() { return 1; } public int getWidth() { return 1; } } </code></pre>
6,017,361
0
<p>I think when you load the page you should subtract the offerClosing time - Datetime.Now. Then you need to use javascript to subtract every second. This is similar to what Ebay does when an auction is nearing close. As far as the actual javascript I dont know offhand but I think you could google that</p>
11,904,934
0
How to change images directory to my resource file <p>I am new to cocos2d and I am trying to learn how to change my images directory to resource file inside my project rather than my desktop. The images only show up if the images are on the desktop instead of inside resource file of my game project. Any help will be appreciated. The error is something like this 012-08-10 15:30:55.884 again[9753:1be03] cocos2d: Couldn't add image:soundoff.png in CCTextureCache</p>
28,149,097
0
Determinate finish loading website in webView with Swift in Xcode <p>i'm trying to create a webapp with swift in xcode, this is my current code:</p> <pre><code>IBOutlet var webView: UIWebView! var theBool: Bool = false var myTimer = NSTimer() @IBOutlet var progressBar: UIProgressView! override func viewDidLoad() { super.viewDidLoad() let url = NSURL(string: "http://stackoverflow.com") let request = NSURLRequest(URL: url) webView.loadRequest(request) } </code></pre> <p>I've a question, How i can determinate the finish loading of the page in webView?</p> <p>Do you know a documentation that contains all the definitions of the WebView? I mean .. (start / end load, the current url, title page, etc ..)?</p> <p>(Sorry for my English).</p>
7,112,197
0
<p>It looks like <a href="http://pypi.python.org/pypi/stdeb" rel="nofollow">stdeb</a> will do what you want.</p> <p>Also, for installing scripts, I strongly recommend <a href="http://pythonhosted.org/setuptools/setuptools.html#automatic-script-creation" rel="nofollow">distribute's console_scripts</a> entry point support.</p>
32,712,587
0
<p>So, you are hitting tomcat hot-redeploy <code>ClassLoader</code> issues.</p> <p>There are two things you should do:</p> <ol> <li><p>Make sure that when your application is shutdown, your Hibernate <code>SessionFactory</code> gets <code>close()</code>ed as well. The best place to do this is a <code>ServletContextListener</code>. Otherwise, on hot redeploy, c3p0 Threads from a now-discarded app will continue to be running. See <a href="http://docs.jboss.org/hibernate/orm/5.0/javadocs/org/hibernate/SessionFactory.html#close--" rel="nofollow">SessionFactory.close()</a></p></li> <li><p>Try the settings described <a href="http://www.mchange.com/projects/c3p0/#tomcat-specific" rel="nofollow">here</a> to prevent stray references to objects from a defunct <code>ClassLoader</code>. You can just add</p></li> </ol> <hr> <pre><code>&lt;property name="hibernate.c3p0.privilegeSpawnedThreads"&gt;true&lt;/property&gt; &lt;property name="hibernate.c3p0.contextClassLoaderSource"&gt;library&lt;/property&gt; </code></pre> <hr> <p>to your c3p0 config section.</p> <p>(p.s. Be sure you are using a recent version of c3p0. These settings are new-ish.)</p>
3,685,705
0
<p>Given that both identified lines contain calls to methods of 'issue' and, as everyone else has already pointed out, there are no obvious leaks within your posted code, it stands to reason there may be something wrong with those two methods since your code assumes that they either don't return objects with a reference you have to release.</p>
4,084,534
0
Error: overloaded function with no contextual type information - SetWindowLong() <p><a href="http://friendpaste.com/2FgBfMlNYM3IfBDuNol9i1" rel="nofollow">http://friendpaste.com/2FgBfMlNYM3IfBDuNol9i1</a></p> <p>I get the error on line 62. The enumCW callback function simply sets the lvmHwnd variable. The dll is injected into the processes that i'm trying to subclass.</p> <p>Any help on this error is appreciated.</p>
13,888,883
0
Would these lines of code affect each other? <p>I am listening/watching the tutorial on Paul Hegarty from the App Store. In his lesson he states that you should ALWAYS synthesize your properties on the implementation file like so:</p> <pre><code>@sysnthesize example = _example; </code></pre> <p>I am also doing a apple documentation tutorial that does not synthesize properties. It also has init methods like so:</p> <pre><code>- (id)initWithName:(NSString *)name location:(NSString *)location date:(NSDate *)date { self = [super init]; if (self) { _name = name; _location = location; _date = date; return self; } return nil; } @end </code></pre> <p>Will these to interact, cancel or otherwise mess with each other if add them together like so:</p> <pre><code>@implementation BirdSighting @synthesize name = _name; @synthesize location = _location; @synthesize date = _date; - (id)initWithName:(NSString *)name location:(NSString *)location date:(NSDate *)date { self = [super init]; if (self) { _name = name; _location = location; _date = date; return self; } return nil; } @end </code></pre> <p>Thanks for the help. </p>
37,264,706
0
names of a dataset returns NULL- R version 3.2.4 Revised-Ubuntu 14.04 LTS <p>I have a small issue regarding a dataset I am using. Suppose I have a dataset called <code>mergedData2</code> defined using those command lines from a subset of <code>mergedData</code>: </p> <pre><code>mergedData=rbind(test_set,training_set) lookformean&lt;-grep("mean()",names(mergedData),fixed=TRUE) lookforstd&lt;-grep("std()",names(mergedData),fixed=TRUE) varsofinterests&lt;-sort(c(lookformean,lookforstd)) mergedData2&lt;-mergedData[,c(1:2,varsofinterests)] </code></pre> <p>If I do <code>names(mergedData2)</code>, I get: </p> <pre><code> [1] "volunteer_identifier" "type_of_experiment" [3] "body_acceleration_mean()-X" "body_acceleration_mean()-Y" [5] "body_acceleration_mean()-Z" "body_acceleration_std()-X" </code></pre> <p>(I takes this 6 first names as MWE but I have a vector of 68 names)</p> <p>Now, suppose I want to take the average of each of the measurements per <code>volunteer_identifier</code> and <code>type_of_experiment</code>. For this, I used a combination of <code>split</code> and <code>lapply</code>:</p> <pre><code>mylist&lt;-split(mergedData2,list(mergedData2$volunteer_identifier,mergedData2$type_of_experiment)) average_activities&lt;-lapply(mylist,function(x) colMeans(x)) average_dataset&lt;-t(as.data.frame(average_activities)) </code></pre> <p>As <code>average_activities</code> is a list, I converted it into a data frame and transposed this data frame to keep the same format as <code>mergedData</code> and <code>mergedData2</code>. The problem now is the following: when I call <code>names(average_dataset)</code>, it returns <code>NULL</code> !! But, more strangely, when I do:<code>head(average_dataset)</code> ; it returns : </p> <pre><code> volunteer_identifier type_of_experiment body_acceleration_mean()-X body_acceleration_mean()-Y 1 1 0.2773308 -0.01738382 2 1 0.2764266 -0.01859492 3 1 0.2755675 -0.01717678 4 1 0.2785820 -0.01483995 5 1 0.2778423 -0.01728503 6 1 0.2836589 -0.01689542 </code></pre> <p>This is just a small sample of the output, to say that the names of the variables are there. So why <code>names(average_dataset)</code> returns <code>NULL</code> ?</p> <p>Thanks in advance for your reply, best </p> <p>EDIT: Here is an MWE for mergedData2:</p> <pre><code> volunteer_identifier type_of_experiment body_acceleration_mean()-X body_acceleration_mean()-Y 1 2 5 0.2571778 -0.02328523 2 2 5 0.2860267 -0.01316336 3 2 5 0.2754848 -0.02605042 4 2 5 0.2702982 -0.03261387 5 2 5 0.2748330 -0.02784779 6 2 5 0.2792199 -0.01862040 body_acceleration_mean()-Z body_acceleration_std()-X body_acceleration_std()-Y body_acceleration_std()-Z 1 -0.01465376 -0.9384040 -0.9200908 -0.6676833 2 -0.11908252 -0.9754147 -0.9674579 -0.9449582 3 -0.11815167 -0.9938190 -0.9699255 -0.9627480 4 -0.11752018 -0.9947428 -0.9732676 -0.9670907 5 -0.12952716 -0.9938525 -0.9674455 -0.9782950 6 -0.11390197 -0.9944552 -0.9704169 -0.9653163 gravity_acceleration_mean()-X gravity_acceleration_mean()-Y gravity_acceleration_mean()-Z 1 0.9364893 -0.2827192 0.1152882 2 0.9274036 -0.2892151 0.1525683 3 0.9299150 -0.2875128 0.1460856 4 0.9288814 -0.2933958 0.1429259 5 0.9265997 -0.3029609 0.1383067 6 0.9256632 -0.3089397 0.1305608 gravity_acceleration_std()-X gravity_acceleration_std()-Y gravity_acceleration_std()-Z 1 -0.9254273 -0.9370141 -0.5642884 2 -0.9890571 -0.9838872 -0.9647811 3 -0.9959365 -0.9882505 -0.9815796 4 -0.9931392 -0.9704192 -0.9915917 5 -0.9955746 -0.9709604 -0.9680853 6 -0.9988423 -0.9907387 -0.9712319 </code></pre> <p>My duty is to get this average_dataset (which is a dataset which contains the average value for each physical quantity (column 3 and onwards) for each volunteer and type of experiment (e.g 1 1 mean1 mean2 mean3...mean68 2 1 mean1 mean2 mean3...mean68, etc)</p> <p>After this I will have to export it as a txt file (so I think using write.table with row.names=F, and col.names=T). Note that for now, if I do this and import the dataset generated using read.table, I don't recover the names of the columns of the dataset; even while specifying col.names=T.</p>
17,427,852
0
<p>When $asp is an array like this:</p> <pre><code>[0] =&gt; 1 [1] =&gt; 2 [2] =&gt; 3 </code></pre> <p>You can get the values by doing</p> <pre><code>foreach($asp as $key =&gt; $value){ echo $value; } </code></pre> <p>Since you are a lazy programmer, this is wat you can do: You want to insert $asp and $asp2 into your database if I get the question right.</p> <pre><code>$new_array = array_combine($asp,$asp2); foreach($new_array as $key =&gt; $value){ $sql = "INSERT INTO dea (did,c1, c2, timestamp) VALUES ('',$key, $value,'".date("Y-m-d H:i:s")."')"; $stmt = mysql_query($sql) or die(mysql_error()); } </code></pre> <p>And by the way, like Doon said: Your if statements doesn't make any sense.</p> <pre><code>if ($tube11==$tube11 &amp;&amp; $fan1==$fan1 &amp;&amp; $bulb1==$bulb1) </code></pre> <p>This will always be true.</p>
34,420,330
0
<p>Use this method as per notes here <a href="http://quickblox.com/developers/Android#How_to:_add_SDK_to_IDE_and_connect_to_the_cloud" rel="nofollow">http://quickblox.com/developers/Android#How_to:_add_SDK_to_IDE_and_connect_to_the_cloud</a></p> <p><strong>Note</strong> there is no "User" field for this create session method</p> <p>QBAuth.createSession(new QBEntityCallbackImpl() {}</p>
28,341,976
0
Node js functions : sql query result call twice <p>I've got a problem with javascript/node js functions.</p> <p>When I send an sql query with function query of "request.service.mssql" object, the result function is called twice...</p> <p>I don't understand because my sql query is an "update" and the result is empty (I do not have multiple lines of results)</p> <p>For example, I have a function that send an email with a new password. The email is sent twice... I found a temp solution with an index but it's not very clean.</p> <p><strong>Can you explain this ?</strong></p> <pre><code>//construct SQL query var email = "[email protected]"; var password = require("crypto").randomBytes(4).toString('hex'); var password_md5 = require("crypto").createHash("md5").update(password).digest("hex"); var sql = "update dbo.mytable SET password='"+password_md5+"' where id=12"; var id = 0; //temp solution mssql.query(sql, { success: function(results) { //Send email with new pwd if(id == 0) { response.send(statusCodes.OK,password_md5); sendEmail(email,password); } id++; //temp solution }, error: function(err) { response.send(statusCodes.INTERNAL_SERVER_ERROR,"Error : " + err); } }); </code></pre> <p>Thank you :-)</p> <p>Steve</p>
20,957,067
0
<p>If you look at the <a href="https://www.relishapp.com/rspec/rspec-rails/v/2-14/docs/controller-specs/render-views" rel="nofollow">relish documentation for the current 2.14 version of Rspec</a> you'll see that they're using <code>match</code> now instead:</p> <pre><code>expect(response.body).to match /Listing widgets/m </code></pre> <p>Using the <code>should</code> syntax, this should work:</p> <pre><code>response.body.should match(/Welcome to the home page/) </code></pre>
7,174,732
0
<p>Please show us some code. My best guess is that you called <em>gl{Push,Pop}Matrix</em> and or <em>glEnable</em> within a <em>glBegin…glEnd</em> block, where those are not allowed.</p>
36,968,531
0
Split website page on two parts with diagonal line <p>I'm building a website and my home page(index) needs to be splitted on two parts. Left(white) and Right(blue). So both sides needs to be links and to have hover effect. For example, when I hover on right side it should be a little bit extended.</p> <p>So my question is: How can I split page on two parts with diagonal line and made them links?</p> <p><img src="https://i.stack.imgur.com/IgqAu.jpg" alt="Wireframe Image"></p>
31,159,016
0
How to efficiently calculate cotangents from vectors <p>I'm trying to implement a function to compute the cotangents of vectors (the mathematical ones) via the standard formula:</p> <blockquote> <p>cot(<strong>a</strong>, <strong>b</strong>) = (<strong>a</strong> * <strong>b</strong>) / |<strong>a</strong> x <strong>b</strong>|, where <strong>a</strong> and <strong>b</strong> are vectors</p> </blockquote> <p>A colleague told me that calculating <code>1/|a x b|</code> is not the best thing to give a computer to calculate. Another alternative coming to my head is first calculating the angle and than using cotan functions for radians angles.</p> <p>What would be the method of choice here? (Is there maybe another one, other than the mentioned ones)</p>
32,726,689
0
<p>I'd set up a message listener in B, and send a message from A. You'll need to attach to a window or compatible object, in B.js:</p> <pre><code> window.addEventListener('message', function (event) { try { var data = JSON.parse(event.data); // Do whatever } catch (exception) { // Didn't work } } ); </code></pre> <p>In A.js:</p> <pre><code>// This you could call on some event and provide the parameters function update(uname, pwd, fname, lname, dob, gend) { if (window.opener) { var data = { 'uname':uname, 'pwd':pwd, 'fname':fname, 'lname':lname, 'dob':dob, 'gend':gend }; window.opener.postMessage(JSON.stringify(data), '*'); } } </code></pre> <p>So in this case, the window running a script B.js needs to open another window running A.js.</p>
17,037,371
0
<p>In modern browsers you can do this without any external libraries in a few lines:</p> <pre><code>Array.prototype.flatten = function() { return this.reduce(function(prev, cur) { var more = [].concat(cur).some(Array.isArray); return prev.concat(more ? cur.flatten() : cur); },[]); }; console.log([['dog','cat',['chicken', 'bear']],['mouse','horse']].flatten()); //^ ["dog", "cat", "chicken", "bear", "mouse", "horse"] </code></pre>
14,864,029
0
Sorting algorithm which alternates equal items <p>What would be a good (simple) algorithm/method for this sorting situation:</p> <p>I have an array of items where each item consists of 2 fields: (ID, Timestamp)</p> <p>There are many pairs of items with the same ID's.</p> <p>I want to sort the array such that the items are alternating among ID's as much as possible, starting from the item with the earliest Timestamp.</p> <p>For example, with this input:</p> <p>(1, 15:00)<br> (1, 15:05)<br> (1, 15:10)<br> (2, 15:15)<br> (2, 15:20)<br> (2, 15:25)<br> (3, 15:30)<br> (4, 15:35)<br> (3, 15:40)</p> <p>I would get this output:</p> <p>(1, 15:00)<br> (2, 15:15)<br> (3, 15:30)<br> (4, 15:35)<br> (1, 15:05)<br> (2, 15:20)<br> (3, 15:40)<br> (1, 15:10)<br> (2, 15:25) </p> <p>I'm primarily looking for a algorithm which is conceptually simple, but of course it's nice if it's performant.</p> <p>Right now the best I can think of is something like: </p> <ol> <li>Init/create temporary array T</li> <li>From the array A: Get item X with earliest Timestamp where ID is not in T</li> <li>Add X to result set R, add X.ID to T, pop X from A</li> <li>As long as X exists, repeat step 2-3, otherwise restart at step 1</li> <li>Quit when A is empty</li> </ol>
27,078,536
0
Convert integer to datetime java <p>I have an integer value with following.How can I convert integer to Datetime?</p> <p>int input DateTime=1 6 25;</p> <p>convert input to output</p> <p>int output DateTime=1:06:25;</p>
30,042,617
0
<p>This is not possible using <a href="http://www.django-rest-framework.org/api-guide/filtering/#orderingfilter">the default <code>OrderingFilter</code></a>, because the ordering is implemented <em>on the database side</em>. This is for efficiency reasons, as manually sorting the results can be <em>incredibly</em> slow and means breaking from a standard <code>QuerySet</code>. By keeping everything as a <code>QuerySet</code>, you benefit from the built-in filtering provided by Django REST framework (which generally expects a <code>QuerySet</code>) and the built-in pagination (which can be slow without one).</p> <p>Now, you have two options in these cases: figure out how to retrieve your value on the database side, or try to minimize the performance hit you are going to have to take. Since the latter option is very implementation-specific, I'm going to skip it for now.</p> <p>In this case, you can use <a href="https://docs.djangoproject.com/en/1.8/ref/models/querysets/#id7">the <code>Count</code> function</a> provided by Django to do the count on the database side. This is provided as part of <a href="https://docs.djangoproject.com/en/1.8/topics/db/aggregation/">the aggregation API</a> and works like <a href="https://msdn.microsoft.com/en-us/library/ms175997.aspx">the SQL <code>COUNT</code> function</a>. You can do the equivalent <code>Count</code> call by modifying your <code>queryset</code> on the view to be</p> <pre><code>queryset = Topic.objects.annotate(vote_count=Count('topicvote_set')) </code></pre> <p>Replacing <code>topicvote_set</code> with <a href="https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ForeignKey.related_name">your <code>related_name</code> for the field</a> (you have one set, right?). This will allow you to order the results based on the number of votes, and even do filtering (if you want to) because it is available within the query itself.</p> <p>This would require making a slight change to your serializer, so it pulls from the new <code>vote_count</code> property available on objects.</p> <pre><code>class TopicSerializer(serializers.ModelSerializer): vote_count = serializers.IntegerField(read_only=True) class Meta: model = Topic </code></pre> <p>This will override your existing <code>vote_count</code> method, so you may want to rename the variable used when annotating (if you can't replace the old method).</p> <hr> <p>Also, you can pass a method name as the <code>source</code> of a Django REST framework field and it will automatically call it. So technically your current serializer could just be</p> <pre><code>class TopicSerializer(serializers.ModelSerializer): vote_count = serializers.IntegerField(read_only=True) class Meta: model = Topic </code></pre> <p>And it would work <em>exactly</em> like it currently does. Note that <code>read_only</code> is required in this case because a method is not the same as a property, so the value cannot be set.</p>
40,333,042
0
<p>Yes, you can send a <code>GET</code> request with no query string. In fact, whenever you hit a webpage using with your browser, you <em>are</em> sending a <code>GET</code> request, e.g. when you type <code>http://google.com</code> in the address bar and hit enter, your browser sends <code>GET</code> request to the URI and google server returns its page.</p> <p>As Mardzis noted in comments, you can use <code>empty()</code> function in your PHP code:</p> <pre><code>&lt;?php if (!empty($_GET['query'])) { $query = $_GET['query']; // Return results for specific query... } else { // Return all results... } </code></pre> <p><strong>EDIT</strong></p> <p>Since you've posted your Javascript code, I noticed something:</p> <pre><code>function showResults(str) { if (str.length == 0) { // If str is empty - isn't this where you want your "empty" query? But you don't } else { // If str is not empty, you send the request. } </code></pre> <p>Seems like if <code>str</code> is empty, you're not sending the request at all. Am I correct?</p>
29,277,137
0
<p>This should do:</p> <pre><code>awk -F. '$1!=a &amp;&amp; NR&gt;1 {print ""} 1; {a=$1}' file foo.foo=Some string foo.bar=Some string bar.foo=Some string bar.bar=Some string baz.foo=Some string baz.bar=Some string </code></pre>
10,976,544
0
<p>Please checkout my new plugin that displays a specific widget.</p> <p>Visit: <a href="http://wordpress.org/extend/plugins/widget-instance/" rel="nofollow">http://wordpress.org/extend/plugins/widget-instance/</a></p>
5,159,431
0
Java reverse server communication <p>I have two machines. One machine is a client and the other is a server running JBoss. I have no trouble having the client make requests and the server respond to those requests. However, for a new project that I need to do I have to reverse the roles. I have to implement a push model, so the server will need to make requests from the client. Specifically I need the server to be able to ask the client for files in a directory, copy files from the server to the client, and run programs on the client. I'd like to do this without adding a psedo server on the client (a small daemon process).</p> <p>Is there a good way to do this?</p> <p>Thanks</p> <p>EDIT: So it would appear that I have to set up a server on the client machine to do what I need because I need to have the server push to the client while the client is not running the Java process (but the machine is on). With that in mind, what's the lightest weight Java server?</p>
1,968,195
0
Delta row compression in PCLXL <p>Is there a difference in the implementation of delta row compression between PCLXL and PCL5?</p> <p>I was using Delta Row compression in PCL5, but when I used the same method in PCLXL, the file is not valid. I checked the output using EscapeE and it says that the image data size is incorrect..</p> <p>Could anyone point me to some material explaining how delta row compression is implemented in PCLXL?</p> <p>Thanks,</p> <p>kreb</p>
21,349,507
1
How to check python codes by reduction? <pre><code>import numpy def rtpairs(R,T): for i in range(numpy.size(R)): o=0.0 for j in range(T[i]): o +=2*(numpy.pi)/T[i] yield R[i],o R=[0.0,0.1,0.2] T=[1,10,20] for r,t in genpolar.rtpairs(R,T): plot(r*cos(t),r*sin(t),'bo') </code></pre> <p>This program is supposed to be a generator, but I would like to check if i'm doing the right thing by first asking it to return some values for pheta (see below)</p> <pre><code>import numpy as np def rtpairs (R=None,T=None): R = np.array(R) T = np.array(T) for i in range(np.size(R)): pheta = 0.0 for j in range(T[i]): pheta += (2*np.pi)/T[i] return pheta </code></pre> <p>Then I typed import omg as o in the prompt</p> <pre><code>x = [o.rtpairs(R=[0.0,0.1,0.2],T=[1,10,20])] # I tried to collect all values generated by the loops </code></pre> <p>It turns out to give me only one value which is 2 pi ... I have a habit to check my codes in the half way through, Is there any way for me to get a list of angles by using the code above? I don't understand why I must use a generator structure to check (first one) , but I couldn't use normal loop method to check.</p> <p>Normal loop e.g. </p> <pre><code>x=[i for i in range(10)] x=[0,1,2,3,4,5,6,7,8,9] </code></pre> <p>Here I can see a list of values I should get. </p>
23,661,274
0
<p>If you dont want to use an external library, you need to write your own ClassLoader. The most simple implementation i found is <a href="https://kenai.com/projects/btrace/sources/hg/content/src/share/classes/com/sun/btrace/MemoryClassLoader.java?rev=452" rel="nofollow">here</a>.</p> <pre><code>/* * Copyright 2008-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ package com.sun.btrace; /** * A simple class loader that loads from byte buffer. * * @author A. Sundararajan */ final class MemoryClassLoader extends ClassLoader { MemoryClassLoader() { this(null); } MemoryClassLoader(ClassLoader parent) { super(parent); } Class loadClass(String className, byte[] buf) throws ClassNotFoundException { return defineClass(className, buf, 0, buf.length); } } </code></pre>
22,135,976
0
<p>Did you try <a href="http://wwww.myserver.com/app/public" rel="nofollow">http://wwww.myserver.com/app/public</a> ?</p> <p>If you didn't configure your bootstrap/paths.php and public/index.php, your site should open via <a href="http://wwww.myserver.com/app/public" rel="nofollow">http://wwww.myserver.com/app/public</a>. But you also have to configure the database paths and credentials in app/config/database.php</p> <p>In a normal setup, only the contents of your Laravel project's "public" folder should be placed in your "app" folder. All the other files are kept in a separate folder, in the root of your server. </p> <p>This article shows how to configure the paths: <a href="http://myquickfix.co.uk/2013/08/hosting-laravel-4-on-cpanel-type-hosting-public_html/" rel="nofollow">http://myquickfix.co.uk/2013/08/hosting-laravel-4-on-cpanel-type-hosting-public_html/</a></p>
2,954,900
0
Simple MultiThread Safe Log Class <p>What is the best approach to creating a simple multithread safe logging class? Is something like this sufficient? How would I purge the log when it's initially created?</p> <pre><code>public class Logging { public Logging() { } public void WriteToLog(string message) { object locker = new object(); lock(locker) { StreamWriter SW; SW=File.AppendText("Data\\Log.txt"); SW.WriteLine(message); SW.Close(); } } } public partial class MainWindow : Window { public static MainWindow Instance { get; private set; } public Logging Log { get; set; } public MainWindow() { Instance = this; Log = new Logging(); } } </code></pre>
40,027,897
0
<p>Your regular expression has nested quantifiers (e.g. <code>(a+)*</code>). This <a href="https://swtch.com/~rsc/regexp/regexp1.html" rel="nofollow">works well with re2</a> but <a href="http://www.regular-expressions.info/catastrophic.html" rel="nofollow">not with most other regular expression engines</a>.</p>
14,296,186
0
<p>I think your current regexp isn't working because it's matching the entire line. Just eyeballing it, it looks like you're matching the opening string "<code>&lt;input</code>" then as many characters as you can, with the final character being something other than a <code>/</code>, and then the closing <code>&gt;</code>.</p> <p>In the case of <code>&lt;input type='submit' value='Save' /&gt;&lt;/td&gt;&lt;/tr&gt;</code> since it's greedy, it'll run all the way to the last <code>&gt;</code> that works. Which happens to be the <code>&gt;</code> for the <code>td</code> (since your grep finishes with a <code>.</code>) </p> <p>As a bit of a hack-y replacement (I'm sure there's a more elegant way to do this..):</p> <pre><code>grep -P -o "&lt;input.*?(?&lt;=( .)|([^/]))&gt;" test.html </code></pre> <p>(grep 2.6.3/cygwin if that's of relevance)</p> <p>which roughly translates: get me anything starting with "<code>&lt;input</code>", then ending with "<code>&gt;</code>" (lazily), then look back and check that either that the 2nd last character before the closing <code>&gt;</code> isn't a space, or that the last character isn't a close slash.</p> <p>if test.html has (for argument's sake):</p> <pre><code>&lt;input type='submit' value='Save' /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;input type="text" name="name" id="name"/&gt; &lt;input type='submit' value='Save'&gt; &lt;a&gt;&lt;input type="blah" /&gt;&lt;/a&gt; &lt;input/&gt; &lt;input&gt;&lt;/i&gt; </code></pre> <p>the output is:</p> <pre><code>&lt;input type='submit' value='Save' /&gt; &lt;input type='submit' value='Save'&gt; &lt;input type="blah" /&gt; &lt;input&gt; </code></pre> <p>More generally though, if you're looking to test for compliance with xhtml, would <a href="http://lxml.de/parsing.html" rel="nofollow">lxml</a> make your life easier?</p>
13,313,728
0
<p>Replace NSNull objects with nil.</p> <p>This will prevent your crash from accessing "objectForKey" (doesNotRecognizeSelector).</p>
15,051,944
0
<p>Try <code>M-x string-insert-rectangle</code>. This command inserts a string on every line of the rectangle.</p>
31,146,357
0
<p>You're very likely missing a DLL. Try running the generated <code>.exe</code> file straight from windows console, as it often reports which DLL is missing. Come back with the error you're getting.</p> <p>I haven't used VS2005, but maybe you're missing the VC++2005 Redistributable (available <a href="https://www.microsoft.com/en-us/download/details.aspx?id=3387" rel="nofollow">here</a>).</p>
10,439,382
0
Change img src in responsive designs? <p>I'm about to code a responsive layout which will probably contain three different "states".</p> <p>The quirky part is that much of the text, for example menu items will be images – not my idea and that's nothing i can change i'm afraid.</p> <p>Since the images will differ slightly, other than size, for each state (for example in the smallest state the menu becomes floating buttons instead of a regular header), i will need to switch images instead of just scaling the same ones.</p> <p>If it weren't for that i'd probably go with "adaptive-images.com".</p> <p>So, i need some input on a best practice solution for this.</p> <p>What i could think of:</p> <ul> <li><p>Loading the images as backgrounds – feels a little bit filthy.</p></li> <li><p>Insert both versions and toggle css display property – very filthy!</p></li> <li><p>Write a javascript that sets all img links – feels a bit overkill?</p></li> </ul> <p>Anyone sitting on a good solution? :)</p>
39,232,791
0
how to get the same font effect in photoshop image <p>I am really new at photoshop and I created some some effect on text few days back now I Want to get the same effect and apply it again in different image It's basically a date and now I want to modify it but I need same effect</p> <p>Here is the image that I created <a href="https://i.stack.imgur.com/2WwCG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2WwCG.jpg" alt="enter image description here"></a></p> <p>I now want to edit it to todays date but I don't remember how I did.. Please help me people..</p>
14,221,388
0
<p>So your problem is that it affects other queries than the main query, if I understand your situation correctly. This is pretty much why <a href="http://codex.wordpress.org/Function_Reference/is_main_query" rel="nofollow">is_main_query</a> exists. So try this:</p> <pre><code>function hide_some_posts( $query ) { if (!is_user_logged_in() &amp;&amp; $query-&gt;is_main_query() ) { $query-&gt;set( 'meta_query', array( array( 'key' =&gt; 'smartPrivate', 'value' =&gt; 'smartPrivate_loggedIn', 'compare' =&gt; '!=' ), array( 'key' =&gt; 'smartPrivate', 'value' =&gt; 'smartPrivate_loggedInMentors', 'compare' =&gt; '!=' ) )); } return $query; } add_filter( 'pre_get_posts', 'hide_some_posts' ); </code></pre>
36,565,701
0
<p>Well, in <code>combineTours</code> function you're calling <code>.pop()</code> method on one array and <code>.shift()</code> method on another, which removes one element from each of these arrays. In <code>calculateAllSavings</code> you're calling <code>calculateSaving</code> in a loop and it's calling <code>combineTours</code>, so you're effectively removing all elements from the sub-arrays.</p> <p>Maybe you should just remove these lines from <code>combineTours</code>:</p> <pre><code>tourA.pop(); tourB.shift(); </code></pre> <p>For the future: use <a href="https://developer.mozilla.org/en/docs/Web/API/Console/log" rel="nofollow"><code>console.log()</code></a> for debugging, it could help you identify the issue.</p>
36,596,218
0
The application, MyEAR, is trying to modify a cookie which matches a pattern in the restricted programmatic session cookies list <p>I am getting below exception while deploying my application on WebSphere Application Server 8.5.5 </p> <p>java.lang.RuntimeException: SRVE8111E: The application, MyEAR, is trying to modify a cookie which matches a pattern in the restricted programmatic session cookies list [domain=*, name=JSESSIONID, path=/]. </p> <p>I found that if I remove below entry from my web.xml [session-config], then no error is shown with deployment and every things works fine. </p> <pre><code>&lt;cookie-config&gt; &lt;http-only&gt;true&lt;/http-only&gt; &lt;/cookie-config&gt; &lt;tracking-mode&gt;COOKIE&lt;/tracking-mode&gt; </code></pre> <p>The same ear is able to deploy and run perfectly with JBOSS and WebLogic server. </p> <p>Please let me know what configuration change I have to do in which xml file to overcome this issue. </p> <p>My application has application.xml, jboss-deployment-structure.xml and weblogic-application.xml. </p> <p>Thanks in advance. </p>
26,224,226
0
async nodejs execution order <p>When does processItem start executing. Does it start as soon as some items are pushed onto the queue? Or must the for loop finish before the first item on the queue starts executing?</p> <pre><code>var processItem = function (item, callback) { console.log(item) callback(); } var myQueue = async.queue(processItem, 2) for (index = 0; index &lt; 1000; ++index) { myQueue.push(index) } </code></pre>
1,210,397
0
<p>Outer joins can be viewed as a hack because SQL lacks "navigation". </p> <p>What you have is a simple if-statement situation.</p> <pre><code>for line in someRangeOfLines: for col in someRangeOfCols: try: cell= FooVal.objects().get( col = col, line = line ) except FooVal.DoesNotExist: cell= None </code></pre> <p>That's what an outer join really is -- an attempted lookup with a NULL replacement.</p> <p>The only optimization is something like the following.</p> <pre><code>matrix = {} for f in FooVal.objects().all(): matrix[(f.line,f.col)] = f for line in someRangeOfLines: for col in someRangeOfCols: cell= matrix.get((line,col),None) </code></pre>
12,492,112
0
<p>It looks like you're source code and binary are out of sync, ie. you're debugging a DLL/EXE that has been compiled with different version of the source code. </p> <p>During debug activate the Debug->Windows->Modules window and check that the DLL/EXE you're debugging is the same as the one you've been compiling with your source code (check date/times, symbol files etc.).</p>
8,176,402
0
<p>Both dates are indeed slightly different. Quick example to show the difference:</p> <pre><code>NSDate *one = [[NSDate alloc]initWithTimeIntervalSinceNow:4000000]; NSDate *two = [[NSDate alloc]initWithTimeIntervalSinceNow:4000000]; NSComparisonResult difference = [two compare:one]; NSLog(@"Date one: %@",one); NSLog(@"Date two: %@",two); NSLog(@"Exact difference: %ld",difference); </code></pre> <p>Output:</p> <pre><code>Date one: 2012-01-03 07:47:40 +0000 Date two: 2012-01-03 07:47:40 +0000 Exact difference: 1 </code></pre> <p><strong>EDIT</strong></p> <p><code>isEqualToDate:</code> returns <code>true</code> in the following example:</p> <pre><code>NSDate *one = [[NSDate alloc]initWithTimeIntervalSince1970:4000000]; NSDate *two = [[NSDate alloc]initWithTimeIntervalSince1970:4000000]; if ([one isEqualToDate:two]) NSLog(@"Equal"); </code></pre> <p>Output:</p> <pre><code>Equal </code></pre>
7,402,852
0
<p>You could do this, and give up the exactly on the hour, but it will be close...</p> <p>(Example came from a app I was debuging)</p> <pre><code>cron: - description: Description of what you want done... url: /script/path/goes/here schedule: every 60 minutes synchronized timezone: America/New_York </code></pre> <p>Below is a screenshot of the logs, the app gets no traffic right now, 99% of those entries are all the cron entry.</p> <p><img src="https://i.stack.imgur.com/DPk1a.png" alt="enter image description here"></p> <p>--- <strong><em>edit</em></strong> ---</p> <p>Just re-read the docs as well and maybe this might be better,</p> <pre><code> schedule: every 60 minutes from 00:00 to 23:59 </code></pre>
25,622,987
0
Authenticating the cobrand <p>I created a new developer account and I am having a problem authenticating with the REST API.</p> <pre><code>POST https://rest.developer.yodlee.com/services/srest/restserver/v1.0/authenticate/coblogin { cobrandLogin: 'sbCob*****', cobrandPassword: '**********' } </code></pre> <p>the system responds with:</p> <pre><code>{ Error: [ { errorDetail: 'Internal Core Error has occurred' } ] } </code></pre> <p>am I doing something wrong?</p>
18,059,638
0
PHP array into Javascript Array <p>Afternoon all. The code below works perfectly, however, I need to pull each row of the php sql array out and into the script var. Any ideas on how to write a while loop that could do this? Thanks for any help</p> <pre><code> var enableDays = ["&lt;?php echo mysql_result($result, 0, 'date'); ?&gt;"]; enableDays.push("&lt;?php echo mysql_result($result, 1, 'date'); ?&gt;"); </code></pre> <p>Additional Code::</p> <pre><code>$rows = array(); while ($row = mysql_fetch_assoc($result)) { $rows[] = $row; } var enableDays = [&lt;?php echo json_encode($rows); ?&gt;]; console.log(enableDays[1]); </code></pre>
10,447,660
0
Switch View on Gingerbread <p>I've coded an app which uses Switch as a toggler. When I run it on ICS I have no problems, but when I run it on gingerbread it crashes:</p> <pre><code>05-04 11:00:43.261: E/AndroidRuntime(1455): FATAL EXCEPTION: main 05-04 11:00:43.261: E/AndroidRuntime(1455): java.lang.RuntimeException: Unable to start activity ComponentInfo{it.android.smartscreenon/it.android.smartscreenon.ActivityImpostazioni}: android.view.InflateException: Binary XML file line #58: Error inflating class Switch 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.app.ActivityThread.access$1500(ActivityThread.java:123) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.os.Handler.dispatchMessage(Handler.java:99) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.os.Looper.loop(Looper.java:130) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.app.ActivityThread.main(ActivityThread.java:3835) 05-04 11:00:43.261: E/AndroidRuntime(1455): at java.lang.reflect.Method.invokeNative(Native Method) 05-04 11:00:43.261: E/AndroidRuntime(1455): at java.lang.reflect.Method.invoke(Method.java:507) 05-04 11:00:43.261: E/AndroidRuntime(1455): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 05-04 11:00:43.261: E/AndroidRuntime(1455): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 05-04 11:00:43.261: E/AndroidRuntime(1455): at dalvik.system.NativeStart.main(Native Method) 05-04 11:00:43.261: E/AndroidRuntime(1455): Caused by: android.view.InflateException: Binary XML file line #58: Error inflating class Switch 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.view.LayoutInflater.inflate(LayoutInflater.java:408) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 05-04 11:00:43.261: E/AndroidRuntime(1455): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:212) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.app.Activity.setContentView(Activity.java:1657) 05-04 11:00:43.261: E/AndroidRuntime(1455): at it.android.smartscreenon.ActivityImpostazioni.onCreate(ActivityImpostazioni.java:43) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722) 05-04 11:00:43.261: E/AndroidRuntime(1455): ... 11 more 05-04 11:00:43.261: E/AndroidRuntime(1455): Caused by: java.lang.ClassNotFoundException: android.view.Switch in loader dalvik.system.PathClassLoader[/data/app/it.android.smartscreenon-1.apk] 05-04 11:00:43.261: E/AndroidRuntime(1455): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 05-04 11:00:43.261: E/AndroidRuntime(1455): at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 05-04 11:00:43.261: E/AndroidRuntime(1455): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.view.LayoutInflater.createView(LayoutInflater.java:471) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549) 05-04 11:00:43.261: E/AndroidRuntime(1455): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66) 05-04 11:00:43.261: E/AndroidRuntime(1455): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568) 05-04 11:00:43.261: E/AndroidRuntime(1455): ... 23 more </code></pre> <p>It looks like Switch doesn't exist on Gingerbread. How can I solve the problem?</p>
20,740,949
0
<p>You should use set_error_handler() to check the error return from the SQL call. For instance:</p> <pre><code>set_error_handler( "NormalErrorHandler" ) ; function NormalErrorHandler( $errno, $errstr, $errfile, $errline ) { $ErrType = DecodeErrno( $errno ) ; $Backtrace = debug_backtrace() ; // The first item in debug_backtrace() is this function, so no use printing it unset( $Backtrace[ 0 ] ) ; $FullError = "Server: {$_SERVER['SERVER_NAME']}\nIP: {$_SERVER['REMOTE_ADDR']}\n" . "$ErrType: $errstr\nLine: $errline\nFile: $errfile\n" . "debug_backtrace():\n" . print_r( $Backtrace, TRUE ) . "GLOBALS:\n" . print_r( $GLOBALS, TRUE ) ; die( $FullError ) ; } </code></pre>
29,594,782
0
<p>one thing that is missing is the <code>authorize</code> function in the directive, which is required (see the <a href="https://atmospherejs.com/edgee/slingshot" rel="nofollow">API</a>) so add</p> <pre><code>Slingshot.createDirective("Test", Slingshot.S3Storage, { bucket: "test", acl: "public-read", authorize: function () { // do some validation // e.g. deny uploads if user is not logged in. if (!this.userId) { throw new Meteor.Error(403, "Login Required"); } return true; }, key: function (file) { return file.name; } }); </code></pre> <p>Please note that also <code>maxSize</code> and <code>allowedFileTypes</code> are required, so you should add to client and server side code (e.g. in lib/common.js)</p> <pre><code>Slingshot.fileRestrictions("Test", { allowedFileTypes: ["image/png", "image/jpeg", "image/gif"], maxSize: 10 * 1024 * 1024 // 10 MB (use null for unlimited) }); </code></pre> <p>hope that helps.</p>
36,383,307
0
Should i use delete[] in a function? <pre><code>void work() { int *p; p=new int[10]; //some code.... } </code></pre> <p>I have a short question that in the <strong>work</strong> function, should i use delete[] operator? since when <strong>work</strong> function is over, <strong>p</strong> will be destroyed, which is wrong or right ? (My English is bad, i am sorry).</p>
4,160,505
0
How can I Center an image within a fixed specified crop frame with graphicsmagick C library <p>Hey, I was wondering if someone knows a good way to scale an image while maintaining aspect ratio, and then center it with respect to a specified fixed crop area.</p> <p>The first part is straight forward (resizing while maintaining ratio), just need help with the second part. </p> <p>Here is a link to something that does this with php and image gd.. <a href="http://stackoverflow.com/questions/3255773/php-crop-image-to-fix-width-and-height-without-losing-dimension-ratio">PHP crop image to fix width and height without losing dimension ratio</a></p> <p>Another link to what I want to achieve is the "Crop" strategy on this page: <a href="http://transloadit.com/docs/image-resize#resize-strategies" rel="nofollow">http://transloadit.com/docs/image-resize#resize-strategies</a></p> <p>I want to do this using the graphicsmagick C library.</p> <p>Thanks a lot.</p>
3,996,939
0
how to use operators while making calc in java <p>i used this code and I am having problem in the very basic step of how to use operator. Moreover I am even having problem taking more then 1 digit. If you please just add up the missing statements which would help me out. In the given code I have removed those steps that created problems in <code>actionPerformed</code> function</p> <pre><code>import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.swing.event.*; public class calculator1 implements ActionListener { private JFrame f; private JButton a,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15; JTextField tf; String msg=""; public calculator1() { f=new JFrame("Calculator"); f.setLayout(null); a=new JButton("1"); a.setActionCommand("1"); a1=new JButton("2"); a1.setActionCommand("2"); a2=new JButton("3"); a2.setActionCommand("3"); a3=new JButton("4"); a3.setActionCommand("4"); a4=new JButton("5"); a4.setActionCommand("5"); a5=new JButton("6"); a5.setActionCommand("6"); a6=new JButton("7"); a6.setActionCommand("7"); a7=new JButton("8"); a7.setActionCommand("8"); a8=new JButton("9"); a8.setActionCommand("9"); a9=new JButton("0"); a9.setActionCommand("0"); a10=new JButton("+"); a10.setActionCommand("+"); a11=new JButton("-"); a11.setActionCommand("-"); a12=new JButton("*"); a12.setActionCommand("*"); a13=new JButton("/"); a13.setActionCommand("/"); a14=new JButton("="); a14.setActionCommand("="); a15=new JButton("00"); a15.setActionCommand("00"); tf= new JTextField(30); } public void launchframe() { f.setSize(500,600); a.setBounds(100,200,50,50); a.addActionListener(this); a1.setBounds(160,200,50,50); a1.addActionListener(this); a2.setBounds(220,200,50,50); a2.addActionListener(this); a3.setBounds(100,300,50,50); a3.addActionListener(this); a4.setBounds(160,300,50,50); a4.addActionListener(this); a5.setBounds(220,300,50,50); a5.addActionListener(this); a6.setBounds(100,400,50,50); a6.addActionListener(this); a7.setBounds(160,400,50,50); a7.addActionListener(this); a8.setBounds(220,400,50,50); a8.addActionListener(this); a9.setBounds(100,500,50,50); a9.addActionListener(this); a10.setBounds(300,200,50,50); a10.addActionListener(this); a11.setBounds(300,300,50,50); a11.addActionListener(this); a12.setBounds(300,400,50,50); a12.addActionListener(this); a13.setBounds(300,500,50,50); a13.addActionListener(this); a14.setBounds(160,500,50,50); a14.addActionListener(this); a15.setBounds(220,500,50,50); a15.addActionListener(this); f.add(a); f.add(a1); f.add(a2); f.add(a3); f.add(a4); f.add(a5); f.add(a6); f.add(a7); f.add(a8); f.add(a9); f.add(a10); f.add(a11); f.add(a12); f.add(a13); f.add(a14); f.add(a15); tf.setBounds(100,150,250,30); f.add(tf); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); } public void actionPerformed(ActionEvent ae) { String s=ae.getActionCommand(); tf.setText(s); } public static void main(String[]arg) { calculator1 c1=new calculator1(); c1.launchframe(); } } </code></pre>
22,457,685
0
<p>inttypes is a c99 header. probably your compiler does not fully support c99. you may try <code>#include &lt;cinttypes&gt;</code> which is the c++ variant. or the more basic stdint.h or cstdint</p>
2,607,564
0
<p>If you are simply geocoding cities, you may want to consider starting to build your own cities-to-coordinates cache.</p> <p>This is one approach that you may want to consider: </p> <ul> <li>Prompt the user to enter a city name.</li> <li>First issue an AJAX request to your server to check if that city name is present in your cache.</li> <li>If it is, proceed your JavaScript logic, as if you obtained the coordinates from the Google Geocoder.</li> <li>If the city name was not present in your cache, send a request to the Google Geocoder, as you are currently doing.</li> <li>If the Google Geocoder returns a positive result, issue another AJAX request to your server in order to store this city and its coordinates in your cache. You will never ask Google again for the coordinates of this city. Then proceed normally within your JavaScript application.</li> <li>If the Google Geocoder returns "Unknown address" tell the user that this city name was not found, and suggest to retry using a more common city name. Keep note of the original city name that was attempted. Test the second attempt with the Google Geocoder, and if it succeeds, save into your cache both synonyms of the city name (the first one attempted, and the second on that succeeded if not already present). </li> </ul> <p>With this approach you can also seed your cache, in such a way to resolve city names which you are already aware that Google is not able to geocode.</p>
30,134,037
0
<p>It finally worked. Thank you @Oleg! I saw another post here <a href="http://goo.gl/Pg5CMn" rel="nofollow">http://goo.gl/Pg5CMn</a></p> <p>Additionally, I figured that I was making another mistake. I forgot to enclose btnContactList in double quotes. After debugging in Internet explorer, I found that out. Secondly, as @Oleg suggested that the jsonReader attribute is required. Probably because of the version of jqGrid that I am using.</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function () { //alert("this is a test"); $("#btnContactList").click(function () { $("#ContactTable").jqGrid({ url: "/Contact/ContactList", datatype: "json", colNames: ["ID", "First Name", "Last Name", "EMail"], colModel: [ { name: "ContactId", index: "ContactId", width: 80 }, { name: "FirstName", index: "FirstName", width: 100 }, { name: "LastName", index: "LastName", width: 100 }, { name: "EMail", index: "EMail", width: 200 } ], //data: result, mtype: 'GET', loadonce: true, viewrecords: true, gridview: true, caption: "List Contact Details", emptyrecords: "No records to display", jsonReader: { repeatitems: false, //page: function () { return 1; }, root: function (obj) { return obj; }, //records: function (obj) { return obj.length; } }, loadComplete: function () { alert("Complete ok!") }, loadError: function (jqXHR, textStatus, errorThrown) { alert('HTTP status code: ' + jqXHR.status + '\n' + 'textstatus: ' + textstatus + '\n' + 'errorThrown: ' + errorThrown); alert('HTTP message body (jqXHR.responseText: ' + '\n' + jqXHR.responseText); } }); alert("after completion"); }); }); &lt;/script&gt; </code></pre>
39,248,968
0
<pre><code>SELECT A.SETMOD, B.DESCRP FROM PMS.PSBSTTBL A JOIN PMS.PR029TBL B ON A.SETMOD =convert(decimal, B.PAYMOD) </code></pre>
40,802,499
0
Symfony Doctrine Migration error <p>When install <code>doctrine/doctrine-migrations-bundle</code> have error</p> <pre><code>FatalErrorException in appDevDebugProjectContainer.php line 4719: Parse Error: syntax error, unexpected ':', expecting ';' or '{' "require": { "php": "&gt;=5.5.9", "symfony/symfony": "3.1.6", "doctrine/orm": "^2.5", "doctrine/doctrine-bundle": "^1.6", "doctrine/doctrine-cache-bundle": "^1.2", "symfony/swiftmailer-bundle": "^2.3", "symfony/monolog-bundle": "^2.8", "symfony/polyfill-apcu": "^1.0", "sensio/distribution-bundle": "^5.0", "sensio/framework-extra-bundle": "^3.0.2", "incenteev/composer-parameter-handler": "^2.0", "doctrine/doctrine-migrations-bundle": "^1.0" }, </code></pre> <p>when deleted doctrine/doctrine-migrations-bundle in composer and all work</p> <pre><code> - Removing doctrine/doctrine-migrations-bundle (v1.2.0) - Removing doctrine/migrations (1.4.1) - Removing ocramius/proxy-manager (2.0.4) - Removing zendframework/zend-code (3.1.0) - Removing zendframework/zend-eventmanager (3.0.1) - Removing ocramius/package-versions (1.1.1) </code></pre> <p>my version php (5.6.28-1) without migration bundle everything fine how to fix this ?</p>