pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
3,014,157 | 0 | <p>Rox suggested WordPress. I would second that. You don't need your own domain to start a Wordpress blog. Just go to wordpress.com and sign up. You will probably get an address like wordpress.com/. The advantage would be that when you get your own domain, you probably can export all your content and import it in your own wordpress installation on that domain.</p> |
28,986,657 | 0 | <p>Restlet uses JDK's logging API that you can bridge to log4j.</p> <p>Your own classes can use the SLF4J API, if you prefer (I prefer the logj4 API though), which also can bridge to log4j.</p> <p>You'll need two bridges in the runtime classpath: log4j-jul e log4j-slf4j-impl.</p> <p>In Maven, do:</p> <pre><code><dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-jul</artifactId> <version>2.2</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-slf4j-impl</artifactId> <version>2.2</version> <scope>runtime</scope> </dependency> </code></pre> <p>That way, you can configure both using Log4j.</p> |
19,787,198 | 1 | Logging in web2py <p>I'm working on a web application that handles a bit of traffic. I tried using FileHandler, set up when handling each request, for logging but that resulted in wsgi crashing from too many open files, current limit is 1024 which seems reasonable.</p> <p>How do people handle logging when dealing with a bit of traffic? Is there a way for the wsgi process to use one filehandle for all requests?</p> |
40,384,521 | 0 | R: replace values in a vector before and after a condition is met <p>Consider a vector with missing values:</p> <pre><code>myvec <- c('C', NA, 'test', NA, 'D') [1] "C" NA "test" NA "D" </code></pre> <p>How to replace all the elements in the vector before 'test' with, say, 'good' and after it with 'bad'? The outcome should be:</p> <pre><code>[1] "good" "good" "test" "bad" "bad" </code></pre> <p>My attempt below succeeds only in replacing everything with 'good', which is not so good:</p> <pre><code>replace(myvec, is.na(myvec) | myvec!='test', 'good') [1] "good" "good" "test" "good" "good" </code></pre> |
34,526,156 | 0 | HTML5 Notification With PHP <p>I noticed Facebook started using the HTML5 notification for desktop and I thought I would start dabbling in it for fun for my blog. My idea is pretty simple: new blog comes out, apache cronjob runs every X minutes and calls a file, does some PHP wizardry and out goes the notification. </p> <p>I have looked online and found examples using <a href="https://codeforgeek.com/2014/10/desktop-notification-like-facebook-using-html5/">node.js and angular</a>, but I'm not comfortable using either of those so I'd rather stick with PHP. </p> <p>Here is my process: The user goes to my blog and will click a button to allow notifications. For brevity, the below code sends the users a notification when they click the "notify" button. This works perfectly, and in theory should subscribe them to any future notifications. </p> <pre><code>if ('Notification' in window) { function notifyUser() { var title = 'example title'; var options = { body: 'example body', icon: 'example icon' }; if (Notification.permission === "granted") { var notification = new Notification(title, options); } else if (Notification.permission !== 'denied') { Notification.requestPermission(function (permission) { if (permission === "granted") { var notification = new Notification(title, options); } }); } } $('#notify').click(function() { notifyUser(); return false; }); } else { //not happening } </code></pre> <p>You can see the <a href="https://jsfiddle.net/qdb1d414/">fiddle</a> of the above. </p> <p>Access to the user is granted and now I should be able to send them notifications whenever I want. Awesome! I then write up a blog entry and it has the ID of XYZ. My cronjob goes and calls the following PHP script, using the above node.js example as a template.</p> <p>(In this example I am just calling the script manually from my phone and watching my desktop screen. Since my desktop is "subscribed" to the same domain, I think the following would/should work.)</p> <pre><code>$num = $_GET['num']; $db = mysql_connect(DB_HOST, DB_USER, DB_PASS); if($db) { mysql_select_db('mydb', $db); $select = "SELECT alert FROM blog WHERE id = ".$num." && alert = 0 LIMIT 1"; $results = mysql_query($select) or die(mysql_error()); $output = ''; while($row = mysql_fetch_object($results)) { $output .= "<script> var title = 'new blog!'; var options = { body: 'come read my new blog!', icon: 'same icon as before or maybe a new one!' }; var notification = new Notification(title, options); </script>"; $update = "UPDATE blog SET alert = 1 WHERE id = ".$num." && alert = 0 LIMIT 1"; mysql_query($update) or die(mysql_error()); } echo $output; } </code></pre> <p>I then check the database and blog entry XYZ's "alert" is now set to "1", yet my desktop browser never got notified. Since my browser is subscribed to the same URL that is pushing out the notification, I would imagine I'd get a message. </p> <p>Either I'm doing something wrong (perhaps PHP isn't the right language for this?), or I'm misunderstanding the spec. Could somebody help point me in the right direction? I think I'm missing something. </p> <p>Thanks a lot. </p> <p><strong>Update 1</strong></p> <p>According to the comments, if I just call a script with this in it:</p> <pre><code> var title = 'new blog!'; var options = { body: 'come read my new blog!', icon: 'same icon as before or maybe a new one!' }; var notification = new Notification(title, options); </code></pre> <p>It should hit all devices that are subscribed to my notifications. I tried this on my phone but my desktop still didn't get a notification. I still think I'm missing something as my notifications seem stuck to one device and can only be called on page-load or on click as opposed to Facebook which sends you notifications even if the page isn't open in your browser. </p> |
15,442,310 | 0 | <p>Try this:</p> <pre><code>Select area, PARSENAME(userip,4) + '.' + PARSENAME(userip,3) UserIp, COUNT(*) from mytable group by area, PARSENAME(userip,4) + '.' + PARSENAME(userip,3) </code></pre> <p><a href="http://sqlfiddle.com/#!3/06d2f/1" rel="nofollow">SQL DEMO</a></p> |
36,420,714 | 0 | <p>I had the same issue and I used command line in order to import the SQL file. This method has 3 advantages:</p> <ol> <li>It is a very easy way by running only 1 command line</li> <li>It runs way faster</li> <li>It does not have limitation</li> </ol> <p>If you want to do this just follow this 3 steps:</p> <ol> <li><p>Navigate to this path (i use wamp):</p> <p>C:\wamp\bin\mysql\mysql5.6.17\bin></p></li> <li><p>Copy your sql file inside this path (ex file.sql)</p></li> <li><p>Run this command: </p> <p>mysql -u username -p database_name < file.sql</p></li> </ol> <p><sup>Note: if you already have your msql enviroment variable path set, you don't need to move your file.sql in the bin directory and you should only navigate to the path of the file.</sup></p> |
8,084,077 | 0 | <p>The literal-object syntax cannot be used for non-literal keys. To use a non-literal key with an object requires the <code>object[keyExpression]</code> notation, as below. (This is equivalent to <code>object.key</code> when <code>keyExpression = "key"</code>, but note the former case takes an <em>expression</em> as the key and the latter an identifier.)</p> <pre><code>var output = [] $('.grab').each(function(index) { var obj = {} obj[$(this).attr('name')] = $(this).val() output.push(obj) }) </code></pre> <p>Happy coding.</p> <hr> <p>Also, consider using <a href="http://api.jquery.com/map/"><code>.map()</code></a>:</p> <pre><code>var output = $('.grab').map(function() { var obj = {} obj[$(this).attr('name')] = $(this).val() return obj }) </code></pre> |
10,662,650 | 0 | Need help understanding this macro from ltp testsuite file tst_res.c <p>What does this macro do? I am not able to understand its definition:</p> <pre><code>#define PAIR(def) [def] = { .name = #def, .val = def, }, </code></pre> <p>From : ltp-full-20120401/lib/tst_res.c line 183</p> <p>You can get the source from this <a href="http://sourceforge.net/projects/ltp/files/LTP%20Source/ltp-20120401/ltp-full-20120401.bz2/download" rel="nofollow">link</a></p> |
30,541,402 | 0 | <p>Being new to sails and jade i found the following link helpful. Turns out you need to go into config > views.js & then change the "engine:" from saying 'ejs' to 'jade'</p> <p>After doing this you'll have to also install jade as a dependency:</p> <pre><code>npm install jade --save </code></pre> <p><a href="http://stackoverflow.com/questions/20473326/sails-cant-find-layout-jade">sails can't find layout.jade</a></p> |
21,302,588 | 0 | <p>Documents directory will not be removed during an app update so your file will be there. However the app bundle will be replaced by the new bundle. But if your code copy the Plist from bundle to Document directory then it will be overwrite so you can put your logic for reading the data or updating the file!</p> |
5,224,759 | 1 | is python good for making games? <p>i hear people say python is just as good as c++ and java but i cant find many good games made in python. a few in pygames but not many</p> <p>just trying to choose the right language</p> <p>edit: sorry, many games really, i would love to make a roguelike, basically my dream. also an overhead rpg. nothing to complex, i dont want to reinvent the wheel but i would like to make a fun game. i have minor java experience, but like the looks of python. i dont plan on making a 3d game really.</p> |
27,743,330 | 0 | <p>You can achieve this using Jackson JSON library: <a href="http://jackson.codehaus.org/" rel="nofollow">http://jackson.codehaus.org/</a></p> <p>One good tutorial which particularly addresses nested objects is here: <a href="http://www.mkyong.com/java/how-to-convert-java-object-to-from-json-jackson/" rel="nofollow">http://www.mkyong.com/java/how-to-convert-java-object-to-from-json-jackson/</a></p> <p>Apart from these, Google is your friend :)</p> |
31,688,704 | 0 | <p>The <code><-></code> "distance between" operator applies to PostgreSQL geometric data types, not to the PostGIS <code>geography</code> data type. With the <code>geography</code> data type you can use the PostGIS function <code>ST_Distance()</code> and find the minimum value.</p> <pre><code>WITH this_cafe (latlng) AS ( SELECT latlng FROM cafes WHERE id = '3' ) SELECT cafes.*, ST_Distance(cafes.latlng, this_cafe.latlng, 'false') AS dist FROM cafes, this_cafe ORDER BY dist ASC LIMIT 1 </code></pre> <p>Note that the third argument <code>useSpheroid</code> to the function is set to <code>false</code> which will make the function much faster. It is unlikely going to affect the result because cafes tend to lie close to each other.</p> <p>This assumes that there is only 1 cafe with <code>id = 3</code>. If there could be more, then restrict the CTE to return just 1 row.</p> |
40,914,729 | 0 | <p>First, you have to get the instance holding your sketch. That means using the <code>runSketch()</code> function instead of calling <code>main()</code> directly:</p> <pre><code>Game game = new Game(); String[] args = {}; PApplet.runSketch(args, game); </code></pre> <p>Now that you have a reference to your sketch instance, you can use it to get to the internal window. How you do this depends on which renderer you're using, but you can figure it out using a mix of <a href="http://processing.github.io/processing-javadocs/core/" rel="nofollow noreferrer">the Processing JavaDoc</a> and <a href="https://github.com/processing/processing/tree/master/core/src/processing" rel="nofollow noreferrer">the Processing source code</a>.</p> <p>Here's an <strong>untested</strong> example using the default renderer:</p> <pre><code>PSurface surface = game.getSurface(); SmoothCanvas smoothCanvas = (SmoothCanvas)surface.getNative(); JFrame frame = (JFrame) smoothCanvas.getFrame(); </code></pre> <p>Now that you have the parent window, you can do whatever you want with it, including:</p> <pre><code>frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.setVisible(false); </code></pre> <p>Like I said I haven't tested this code, and this is going to depend on exactly which renderer you're using, but this process of using the source code and JavaDoc to figure out what's going on under the hood to get to the underlying window is what you have to do.</p> |
10,838,263 | 0 | <p>1) Assuming you want your key to be unique, have you considered how you will handle this using a standard field? There is no out-of-the-box way to enforce uniqueness with a standard field. There is an <a href="http://success.salesforce.com/ideaView?id=08730000000Bqct" rel="nofollow">Idea Exchange request</a> for such a feature.</p> <p>That said, you can create a custom field that accepts the value from a standard field (via a workflow or trigger), and force the custom field to be unique.</p> <p>You can also just use a custom field and not use the equivelant standard field: per your example. you could easily create a custom field with the label "Email" and simply hide the standard Email field from the page layouts and/or profiles.</p> <p>2) Standard fields definitely have <a href="http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_contact.htm#topic-title" rel="nofollow">API names</a>.</p> <p>3) Are you asking for the definition of a <a href="http://en.wikipedia.org/wiki/Key_field" rel="nofollow">key field</a>?</p> |
9,663,794 | 0 | <pre><code>var modules = Process.GetCurrentProcess() .Modules .Cast<ProcessModule>() .Select(m=>new {Name = m.ModuleName, Size = m.ModuleMemorySize }) .ToArray(); </code></pre> |
20,007,406 | 0 | Breeze.js and Entity Framework - How do I expose xref table when generating an EDMX from the DB? <p>Breeze.js doesn't handle many to manys, so I need to spell out the 1 to many with xref tables. But how do I force EF to expose those xrefs when generating my EDMX from the database?</p> |
22,110,960 | 0 | wordpress comment spamming even no form in website <p>Hello i have wordpress website i have no comment form in my website on any page </p> <p>but when i see in admin comment section i see lots of unnecessary comments.</p> <p>So how people are able to comment on website?</p> <p>is this from any media image or else i don't know.</p> <p>how ever i have disabled it from some templates which are used in front end </p> <pre><code><?php comments_template(); ?> </code></pre> <p>what should i do to prevent it, how ever i have i have recently installed plugin and testing if comment appears or not.</p> <pre><code>http://wordpress.org/plugins/disable-comments/ </code></pre> |
1,984,039 | 0 | <p>You could have your <code>Line</code> object implement the <a href="http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html" rel="nofollow noreferrer"><code>Comparable</code></a> interface. You could then put the comparison logic within the <code>Line</code> class in the <code>compareTo</code> method. The logic there will test whether the slope and the intercept match, and if so return <code>0</code>. Other results could return <code>1</code> or <code>-1</code> to enforce ordering, if you want.</p> <p>Obviously, you don't need to implement this interface to effect your desired results. However, as this is homework, doing so will allow you to play around with some features of the JDK, like using sorted Lists, etc. With a sorted list, for example, you could obviate the need for a nested loop, as you would only need to compare the object in question against one you just removed from the <code>Iterator</code> in the previous iteration to see if you need to add it to an existing linelist or start a new one.</p> |
6,403,317 | 0 | <p>You could do something like</p> <pre><code>current_user.views.where(:post_id => post.id) # this may work, not sure current_user.views.where(:post => post) </code></pre> <p>or</p> <pre><code>post.views.where(:user_id => current_user.id) # this may work, not sure post.views.where(:user => current_user) </code></pre> |
34,728,508 | 0 | <p>There seems to be a character limit for iOS push notifications based on the type of notification. These values can be seen in a similar Stackoverflow question:</p> <p><a href="http://stackoverflow.com/questions/6307748/what-is-the-maximum-length-of-a-push-notification-alert-text">What is the maximum length of a Push Notification alert text?</a></p> <blockquote> <p><strong>Alerts</strong>: Prior to iOS 7 the alerts display limit was 107 characters. Bigger messages were truncated and you would get a "..." at the end of the displayed message. With iOS 7 the limit seems to be increased to 235 characters. If you go over 8 lines your message will also get truncated.</p> <p><strong>Banners</strong>: Banners get truncated around 62 characters or 2 lines.</p> <p><strong>Notification Center</strong>: The messages in notification center get truncated around 110 characters or 4 lines.</p> <p><strong>Lock Screen</strong>: Same as notification center.</p> </blockquote> <p>I would also recommend looking further into the Push Notification documentation provided by Apple:</p> <p><a href="https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html" rel="nofollow">Apple Push Notification Service</a></p> |
27,115,609 | 0 | Remove columns in a matrix that have a match with the column name in R <p>I have a matrix in a R script and i want to remove columns in a matrix in R that have a match with the label.</p> <p>For example :</p> <pre><code>A <- matrix(c(4,5,4,4), nrow=1) dimnames(A)= list(c("row1"),c("foo","bar","alfa","foo")) foo bar alfa foo row1 4 5 4 4 </code></pre> <p>I want remove the column foo-4 because match with the label but not the column alfa-4</p> <p>I try</p> <pre><code>duplicated.columns <- duplicated(t(A)) A <- A[, !duplicated.columns] </code></pre> <p>but the result is </p> <pre><code>foo bar 4 5 </code></pre> <p>How can I fix this?</p> |
15,622,618 | 0 | Where should i store current user in node.js? <p>As with almost any web application, I need a way to reference the current user in my node.js app.</p> <p>I have the login/session system working, but I noticed today that when I login to my app in one browser, and view it in another, I can see the same data that I see in the first browser.</p> <p>I am currently storing the information about the current user in a global app.current_user object, but I realize now that this is shared across all requests/sessions because node.js is single-threaded - and therefore, is a bad idea.</p> <p>What would be the correct way to store the reference to the current user? The current user is not just a hash of user data, but a Mongoose model, so I guess storing in a cookie would not be a good idea?</p> <p>BTW - I also store the user's settings and a few more things that I do not want to fetch again each time I do something with the user and their settings (which can happen quite a few times during a single request). I guess you could say I'm caching the current user in memory.</p> |
22,181,178 | 0 | <p>If I understand you correctly you want the final product to look like this:</p> <p><img src="https://i.stack.imgur.com/TixFy.png" alt="I think this is what you are looking for."></p> <p>The current order of the row you want changed is DEAD MAIN’S CACHE (Text), BENJAMIN (Portrait), and then PROTECT YOUR NECK (Coffee Bean?).</p> <p>Switch DEAD MAIN’S CACHE (Text) and PROTECT YOUR NECK (Coffee Bean?).</p> <p>Remove all references to <code>small</code> and use push and pull to correct the order for large screens.</p> <p>Your current code:</p> <pre><code><div class="row"> <div class="small-12 small-push-12 large-4 columns">DEAD MAIN’S CACHE (Text)</div> <div class="large-4 columns">BENJAMIN (Portrait)</div> <div class="small-12 small-push-12 large-4 columns">PROTECT YOUR NECK (Coffee Bean?)</div> </div> </code></pre> <p>My suggestion:</p> <pre><code><div class="row"> <div class="large-4 large-push-8 columns">PROTECT YOUR NECK (Coffee Bean?)</div> <div class="large-4 columns">BENJAMIN (Portrait)</div> <div class="large-4 large-pull-8 columns">DEAD MAIN’S CACHE (Text)</div> </div> </code></pre> <p>In essence, design for mobile first and use the push/pull to "fix" larger screen sizes.</p> <p>If I misunderstood your question please let me know.</p> <p>I hope that helps.</p> |
5,863,233 | 0 | <p>You could use php to load the page into your current page. A lot of people consider iframes bad practice. It would only take a couple lines of php to load the page elements, instead of an iframe, which is sometimes slower.</p> <p>Here is how you would do it....</p> <pre><code><?php include('file.html'); ?> </code></pre> <p>You would put this line in a and contain it on the page just as you would with the iframe. You can use ajax/js to seamlessly change the content of the html and even load things from a server if you wish.</p> |
16,616,337 | 0 | <p>It appears to work like this. I still haven't tried saving or retrieving data from the database, but it's error free initializing controllers etc. The rest of the code is like in the tutorial <a href="http://docs.castleproject.org/Windsor.Windsor-tutorial-part-one-getting-Windsor.ashx" rel="nofollow">http://docs.castleproject.org/Windsor.Windsor-tutorial-part-one-getting-Windsor.ashx</a>.</p> <p>NHibernate configuration is in the config file (web.config or nhibernate.cfg.xml).</p> <pre><code><hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> ... </session-factory> </hibernate-configuration> </code></pre> <p>Then the <code>PersistenceFacility</code> can simply be like this.</p> <pre><code>public class PersistenceFacility : AbstractFacility { protected override void Init() { // NHibernate configures from the <hibernate-configuration> section of a config file var config = new Configuration().Configure(); Kernel.Register( Castle.MicroKernel.Registration.Component.For<ISessionFactory>() .UsingFactoryMethod(_ => config.BuildSessionFactory()), Castle.MicroKernel.Registration.Component.For<ISession>() .UsingFactoryMethod(k => k.Resolve<ISessionFactory>().OpenSession()) .LifestylePerWebRequest() ); } } </code></pre> <p>The difference between the tutorial is there is no need for the Fluent configuration and instead using NHibernates <code>Configuration().Configure()</code> works.</p> |
32,247,633 | 0 | not all code paths return a value error on web method <p>I have a web method function has checks if a name exists in the database but I am getting the error:</p> <blockquote> <p>Error 114 'lookups_Creditor.CheckIfNameExists(string)': not all code paths return a value</p> </blockquote> <p>Here is the web method:</p> <pre><code>[WebMethod] public static bool CheckIfNameExists(string Name)//error on this line { try { Creditor.CheckIfNameCreditorExists(Company.Current.CompanyID, Name); } catch (Exception ex) { } } </code></pre> <p>And here is the search function for the sql:</p> <pre><code>public static string CheckIfNameCreditorExists(int CompanyID, string Name) { DataSet ds = new DataSet(); string accNo = ""; string sql = "proc_CheckIfACCreditorExists"; string query = "SELECT c.* " + " FROM Creditor c " + " WHERE c.Company_ID = " + CompanyID + " AND c.Name LIKE '" + Name + "' "; DataTable dt = new DataTable(); using (MySql.Data.MySqlClient.MySqlDataAdapter adapter = new MySql.Data.MySqlClient.MySqlDataAdapter(query, DataUtils.ConnectionStrings["TAT"])) { adapter.SelectCommand.CommandType = CommandType.Text; adapter.SelectCommand.CommandText = query; adapter.Fill(dt); if (dt.Rows.Count > 0) { accNo = Convert.ToString(dt.Rows[0]["AccoutCode"]); } } return accNo; } </code></pre> <p>I am trying to create a method that searches for the name in the database. If the name exists, then return the account code associated with that name. I will the display a message on the screen telling the user that the name already exists on the account ABC.</p> |
22,054,892 | 0 | Rails 4 multiple form (User and Address) <p>I have problem with creating multiple form for User and Address models. When I load page, I don't see address fields.</p> <p>Me source code is below</p> <p>models/address</p> <pre><code>class Address < ActiveRecord::Base has_one :user end </code></pre> <p>models/user</p> <pre><code>class User < ActiveRecord::Base belongs_to :address accepts_nested_attributes_for :address end </code></pre> <p>controllers/users_controller</p> <pre><code>class UsersController < ApplicationController before_filter :require_user, :only => [:show, :edit, :update] def new @user = User.new @user.build_address end private def user_params params.require(:user).permit( :first_name, :last_name, :email, :password, :password_confirmation, addresses_attributes: [:id, :city] ) end end </code></pre> <p>views/users/new.html.erb</p> <pre><code><%= form_for @user do |form| %> ... <% form.fields_for :address do |builder| %> <p> <%= builder.label :city %><br /> <%= builder.text_field :city %> </p> <% end %> <%= form.submit "Register" %> <% end %> </code></pre> <p>Thank you.</p> |
38,352,993 | 0 | Why Promise.all cannot work after all asynchronous function are completed? <p>Hi I'm new to Js and I'd like to wait some async functions complete before print <code>ni</code>. But the code never print it I cannot understand why. Please help me:(</p> <pre><code>// public function this.run = function() { 'use strict'; let compile_lib = lib_array.map((item) => { return new Promise(() => {compileEntry(item);}) }); Promise.all(compile_lib).then(() => { console.log("ni"); }); } </code></pre> |
31,400,404 | 0 | mvc : convert view model code to viewbag or viewdata <p>I am sending my table data to mvc web page through using viewmodel....my code is below..now i am given the task to send it through viewbag or viewdata. Any passionate programer plz edit the code to send it throgh viewbag or viedata and give a basic overview about how we use them i.e viewmodel or viebag difrntly. Much thanx in advance.</p> <pre><code> @{ ViewBag.Title = "Index"; } <h2>Index</h2> <div> <br /><br /> <table style="width: 100%;"> <tr> <th>UserID</th> <th>UserName</th> <th>Adress</th> </tr> @foreach(var item in ViewData.Model) { <tr> <td>@item.UserID</td> <td>@item.Username</td> <td>@item.Adress</td> </tr> } </table> </div> public class DetailController : Controller { public ActionResult Index() { ViewData.Model = DetailModels.GetData(); return View(); } } public class DetailModels { public static List<User> GetData() { EmployeeEntities context = new EmployeeEntities(); List<User> dt = context.Users.AsEnumerable().ToList(); return dt; } } </code></pre> |
18,043,445 | 0 | <p>So you basically want to <em>detect</em> whether a file is an ISO file or not, and not so much check the file, to see if it's valid (e.g. incomplete, corrupted, ...) ?</p> <p>There's no easy way to do that and there certainly is not a C# function (that I know of) that can do this.</p> <p>The best way to approach this is to guess the amount of bytes per block stored in the ISO. Guess, or simply try all possible situations one by one, unless you have an associated CUE file that actually stores this information. PS. If the ISO is accompanied by a same-name .CUE file then you can be 99.99% sure that it's an ISO file anyway.</p> <p>Sizes would be 2048 (user data) or 2352 (raw or audio) bytes per block. Other sizes are possible as well !!!! I just mentioned the two most common ones. In case of 2352 bytes per block the user data starts at an offset in this block. Usually 16 or 24 depending on the Mode.</p> <p>Next I would try to detect the CD/DVD file-systems. Assume that the image starts at sector 0 (although you could for safety implement a scan that assumes -150 to 16 for instance).</p> <p>You'll need to look into specifics of ISO9660 and UDF for that. Sectors 16, 256 etc. will be interesting sectors to check !!</p> <p>Bottom line, it's not an easy task to do and you will need to familiarize yourself with optical disc layouts and optical disc file-systems (ISO9660, UDF but possibly also HFS and even FAT on BD).</p> <p>If you're digging into this I strongly suggest to get IsoBuster (<a href="http://www.isobuster.com" rel="nofollow">www.isobuster.com</a>) to help you see what the size per block is, what file systems there are, to inspect the different key blocks etc.</p> |
34,858,358 | 0 | If expression in Qlikview <p>My expression:</p> <p>IF(Min(MONTHYEAR) > Min(MONTHYEAR2) and isnull(FIELD1),FIELD1B,if(Min(MONTHYEAR) > Min(MONTHYEAR2) and len(FIELD1)>0,FIELD1)) as Value</p> <p>I need this: 1.-if(Min(MONTHYEAR) > Min(MONTHYEAR2) and isnull(FIELD1) output FIELD1B 2.-if(Min(MONTHYEAR) > Min(MONTHYEAR2) and isnotnull(FIELD1) output FIELD1</p> <p>What I am doing wrong? Thanks!</p> |
29,233,127 | 0 | <p>The Control is generic class, to show the decimalplaces you need to make a typecast to convert the Control to the specific type (NumericUpDown).</p> <p>Below code will work:</p> <pre><code>public CustomToolStripControlHost(Control c) : base(c) { NumericUpDown numUpDown = (NumericUpDown)c; numUpDown.DecimalPlaces = 10; } </code></pre> |
40,356,067 | 1 | Sqlalchemy: automatically calculate the value of a column upon another column changed <p>I want the value of a column (<code>is_dangerous_token</code>) to be calculated using a method. Here is what I have gone so far.</p> <pre><code>class PassRecovery(DeclarativeBase): __tablename__ = 'pass_recoveries' id = Column(Integer, primary_key=True) account_email_address = Column(Unicode(255), ForeignKey('accounts.email_address'), index=True) account = relationship('Account', backref=backref('pass_recoveries', cascade='all, delete-orphan')) _is_dangerous_token = Column('is_dangerous_token', Unicode(255)) def _set_is_dangerous_token(self, account_email_address): secret_key = config.get('is_dangerous_key') signer = TimestampSigner(secret_key) self._is_dangerous_token = signer.sign(account_email_address) def _get_is_dangerous_token(self): return self._is_dangerous_token is_dangerous_token = synonym( '_is_dangerous_token', descriptor=property(_get_is_dangerous_token, _set_is_dangerous_token) ) </code></pre> <p>But the problem is that when I create a row by passing in the email_address, the <code>is_dangerous_token</code> is not generated using the code I wrote. The created row only has the <code>id</code> and the relation to the <code>account</code> and <code>is_dangerous_token</code> has no value in the database. thanks for any help</p> |
5,328,493 | 0 | IBAction Doesn't Get Called in Subview <p>I am creating a simple app that let's the user view movies after clicking buttons. The first screen you see is the Main Menu with 2 buttons. One of them sends the user to a sub view which I coded as this in an IBAction method:</p> <pre><code>ViewConroller *nextView = [[ViewController alloc] initWithNibName:@"NextMenu" bundle nil]; [self.view addSubview:[nextView view]]; [nextView release]; </code></pre> <p>This part is fine except that the sub view shows a 20 px bar across the bottom of the previous view. I looked around and none of the solutions like <a href="http://stackoverflow.com/questions/3032773/my-view-is-displaying-y-20-dispite-its-frame-set-to-y-0-after-rotation-it-snaps">this one</a> work for me. This isn't even the main problem. On the sub view, whenever I click a button, the app explodes. The IBAction methods break before even executing a line inside the method. Here, in the goBack IBAction method, I am trying to dismiss the subview and go back to the main menu:</p> <pre><code>[self.view removeFromSuperview]; </code></pre> <p>My connections are correct in my XIB files and everything seems to be in order. The buttons just aren't executing. I'm not sure if it has to do with adding the sub view or what. I have done a lot of searching around on google and this website, but I still can't find a solution. </p> <p>Here is an example of the error I'm getting:</p> <pre><code>Terminating app due to uncaught exception 'NSInvalidArgumentException, reason: '-[__NSCFType goBack:]: unrecognized selector sent to instance 0x5640b70' </code></pre> <p>Hopefully you guys can help me out, this is really quite frustrating. I feel like I've tried everything. Thanks for your time. Let me know if I need to provide any more information. Thanks again.</p> |
17,989,674 | 0 | <p>best way is </p> <p>on defining css put some class in front (or <code>id</code> if only one time your are using the div). for eg:</p> <pre><code>.container a { text-decoration: none; color:#fff; font-size:15px; font-family: 'Ropa Sans', sans-serif; sans-serif;sans-serif; text-shadow: 1px 1px 1px #000; } </code></pre> <p>now you can use this in a <code><div class ="container"><a href="#">sdfadsf</a></code></p> |
31,904,860 | 0 | <pre><code>$str = sprintf('%o', $octal_value); </code></pre> |
10,230,959 | 0 | Joining two relations with default values <p>I have two views:</p> <pre><code>view1 view2 obj obj attribute +-+ +-+--+ |A| |C|27| +-+ +-+--+ |B| +-+ |C| +-+ </code></pre> <p>How can I combine the values and return the output,</p> <pre><code>obj attribute +-+--+ |A| 0| +-+--+ |B| 0| +-+--+ |C|27| +-+--+ </code></pre> <p>with 0's as default values in SQL? I don't want to use PL/SQL.</p> |
24,127,391 | 0 | <p>What ended up working was:</p> <pre><code>if (defined('BCC_EMAIL')) { $headers .= 'Bcc: '.BCC_EMAIL.'' . "\r\n"; } </code></pre> |
2,079,146 | 0 | <p>My <em>.emacs</em> file loads <em>~/.emacs.d/init.el</em>, which defines the following functions, written first for XEmacs, but working well enough for Emacs these days:</p> <pre><code>(defconst user-init-dir (cond ((boundp 'user-emacs-directory) user-emacs-directory) ((boundp 'user-init-directory) user-init-directory) (t "~/.emacs.d/"))) (defun load-user-file (file) (interactive "f") "Load a file in current user's configuration directory" (load-file (expand-file-name file user-init-dir))) </code></pre> <p>Then the rest of the file goes and loads lots of individual files with forms like this:</p> <pre><code>(load-user-file "personal.el") </code></pre> <p>My current set of files is as follows:</p> <ul> <li>personal.el</li> <li>platform.el</li> <li>cygwin.el</li> <li>variables.el</li> <li>paths.el</li> <li>mail-news.el</li> <li>misc-funcs.el</li> <li>bbdb.el</li> <li>calendar.el</li> <li>gnus-funcs.el</li> <li>c-and-java.el</li> <li>lisp.el</li> <li>clojure.el</li> <li>go.el</li> <li>markdown.el</li> <li>sgml-xml.el</li> <li>tex.el</li> <li>spelling.el</li> <li>org.el</li> <li>packages.el</li> <li>fonts.el</li> <li>color-theme.el</li> <li>frame.el</li> <li>server.el</li> <li>keys.el</li> <li>aquamacs.el</li> </ul> <p>Some of them are much more specific in intent than others, as the names suggest. The more fine-grained the files, the easier it is to disable a cluster of forms when you're reinstalling a package or library. This is especially useful when "moving in" to a new system, where you drag your configuration files over but don't yet have all the supporting packages installed.</p> |
3,765,695 | 0 | <p>You could have him use a dynamic DNS service like dyndns.com or no-ip.com. That way he can setup a domain name like someguy.dyndns.com which would always resolve to his ip (he'll probably need to install a small daemon/service/program to automatically update the IP though). Then you can add a rule into your .htaccess like <code>allow from someguy.dyndns.com</code>.</p> |
32,093,937 | 0 | <p>there is 2 options one is you need to use namespace otherwise use that way</p> <pre><code>public function index() { return \App\MemberModel::test(); } </code></pre> |
22,013,601 | 0 | Why WalkingFileTree is faster the second time? <p>I am using the function <code>Files.walkfiletree()</code> from <code>java.NIO</code>, I am looking over a really big tree so when I run the app the first time (with first time I mean each time I turn on my computer) the app takes some time but the second time is really fast. why? is some cache working? Can I use this in some permanent way?</p> |
17,049,336 | 0 | <p>You can try using <a href="http://lucene.apache.org/solr/api-4_0_0-BETA/org/apache/solr/schema/RandomSortField.html" rel="nofollow">RandomSortField</a> which will enable you to sort results randomly.<br> For ordering the for the first few results, you can boost the criteria e.g. <code>bq=name:Peter</code> and try using random as secondary sort e.g. <code>sort = score desc, random_1 desc</code></p> |
7,334,272 | 0 | Multi return statement STRANGE? <p>Today while playing with a De-compiler, i Decompiled the .NET C# Char Class and there is a strange case which i don't Understand</p> <pre><code>public static bool IsDigit(char c) { if (char.IsLatin1(c) || c >= 48) { return c <= 57; } return false; return CharUnicodeInfo.GetUnicodeCategory(c) == 8;//Is this Line Reachable if Yes How does it work ! } </code></pre> <p>i Used <strong>Telerik JustDecompile</strong></p> |
13,168,806 | 0 | Calling a function on a table of async populted data in Meteor <p>I am using Meteor and the jquery data table library. I have a table that I am loading meteor/handlebars using something like this:</p> <pre><code><table> {{each x}} // code to insert rows of data {{/each}} </table> </code></pre> <p>I need to call this on the table once it has been fully populated with data to turn it into a sortable table:</p> <pre><code>$('#tableID').dataTable(); </code></pre> <p>It works when I call it from the console once the DOM is fully loaded and the data is in there, but using Template.rendered() doesn't work, nor does listening for changes with .observe since the data is loaded before that particular view is rendered.</p> <p>Where can I run this code to ensure that the data is fully loaded, and if there are updates to the data in the table that it will run again?</p> |
18,135,106 | 0 | Google Maps Api v2 key does not work properly <p>So everything works fine with the key that i generate for me. i wanted to export the apk and did as follows:</p> <ol> <li>generate sha-1</li> <li>get google apikey1, include in manifest(if i run the app from eclipse directly to my phone, the map works)</li> <li>generate keystore1 in debug mode & apk1 </li> <li>generate another sha-1 using keystore1</li> <li>use last sha-1 to get apikey2 (include apikey2 in manifest)</li> <li>generate keystore2 in debug mode and apk2 which i can use to install on any phone and it should work. </li> </ol> <p>but it doesnt work on my phone. What am i doing wrong?</p> |
31,893,360 | 0 | How to free up unused space after deleting documents in ElasticSearch? <p>When deleting records in ElasticSearch, I heard that the disk space is not freed up. So if I only wanted to keep rolling three months of documents in a type, how do I ensure that disk space is reused?</p> |
1,313,883 | 0 | <p>Based on how CSS selectors work, it should be <code>.bear, .dog</code></p> |
26,521,630 | 0 | <p>I found this same bug. Worked on all Nexus devices but <strong>all</strong> Samsung devices lost my user changes. I know the below method is <strong>deprecated</strong> but it solved my issue.</p> <pre><code>webview.getSettings().setDatabasePath("/data/data/" + webview.getContext().getPackageName() + "/databases/"); </code></pre> |
324,323 | 0 | <p>A view is barely more expensive to the computer than writing out the query longhand. A view can save the programmer/user a lot of time writing the same query out time after time, and getting it wrong, and so on. The view may also be the only way to access the data if views are also used to enforce authorization (access control) on the underlying tables.</p> <p>If the query does not perform well, you need to review how the query is formed, and whether the tables all have the appropriate indexes on them. If your system needs accurate statistics for the optimizer to perform well, have you updated those statistics sufficiently recently?</p> <p>Once upon a long time ago, I came across a system where a query generator had created one query that listed seventeen tables in a single FROM clause, including several LEFT OUTER JOIN of a table with itself. And, in fact, closer scrutiny revealed that several of the 'tables' were in fact multi-table views, and some of these also involved self outer joins, and were themselves involved in self outer joins of the view. To say "<em>ghastly</em>" is an understatement. There was a lot of cleanup possible to improve the performance of that query - eliminating unnecessary outer joins, self joins, and so on. (It actually pre-dated the explicit join notation of SQL-92 - I said a long time ago - so the outer join syntax was DBMS-specific.)</p> |
7,633,965 | 0 | PHP - XML conversion <p>I'm new to stackoverflow and after some searching didn't find an answer to my question so I'm hoping someone can help me out.</p> <p>I have to use this web service method that takes three parameters, a string and two xml params.</p> <p>Below's an example of the code I'm using. The web service method throws an exception, 'Required parameters for method SubmitXml are null.'</p> <p>So I'm guessing it's not receiving any xml on the 2nd and 3rd params. Can anyone give me a hint on how to correctly use the DOM or any other with PHP here? thank you in advance. </p> <pre><code> $soapClient = new SoapClient($this-SOAPURL, array('login'=>$this->account,'password'=>$this->password)); $xmlstr ='<xmlbody>'; $xmlstr.='<someXML>Some XML text content here!</someXML>'; $xmlstr.='</xmlbody>'; $dom = new DOMDocument(); $dom->loadXML($xmlstr); $filter = new DOMDocument(); $filter->loadXML('<_ xmlns=""/>'); print_r ($soapClient->SubmitXml('userIDString',$dom->saveXML(), $fil->saveXML())); </code></pre> |
1,149,878 | 0 | <p>If the input is read by the script from <code>stdin</code>, just redirect input from a file (using a wrapper script).</p> <pre><code>#! /bin/sh test.sh < data.in </code></pre> <p>If this does not work for you (i.e. you have your script calling some interactive shell program like telnet, you can use <a href="http://expect.nist.gov/" rel="nofollow noreferrer"><code>Expect</code></a> to automate the interaction.</p> |
34,054,141 | 0 | How to transfer a DataTable between pages <p>I have a DataTable at page1.aspx and want page2.aspx to read and storage that DataTable so i can freely use this one too.</p> <p>There is a simple way to do that?</p> <p>It's only for a college homework so nothig too big or complicated, only a DataTable with simple items.</p> |
30,967,702 | 0 | Send UDP data from Windows Service to browser running webpage on same machine <p>Let's say I have the following code running on a Windows service. I have to send data from a Windows service on a machine to a webpage that is open on the same machine(<em>but not hosted on that machine</em>).</p> <pre><code> static void Main(string[] args) { Int32 counter = 0; while (counter < 100) { SendUDP("127.0.0.1", 49320, counter.ToString(), counter.ToString().Length); Thread.Sleep(2000); counter++; } } public static void SendUDP(string hostNameOrAddress, int destinationPort, string data, int count) { IPAddress destination = Dns.GetHostAddresses(hostNameOrAddress)[0]; IPEndPoint endPoint = new IPEndPoint(destination, destinationPort); byte[] buffer = Encoding.ASCII.GetBytes(data); Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); for (int i = 0; i < count; i++) { socket.SendTo(buffer, endPoint); } socket.Close(); System.Console.WriteLine("Sent: " + data); } </code></pre> <p>I have to listen for the data sent to port 49320 and then process it in the browser.</p> <p>I can create a listener on the webpage with Node.js like below, but I have to start this service separately and also install node.js on the client.</p> <p><strong>Is there any alternative to this?</strong> Something more lightweight ?</p> <p>I could also create an AJAX to query a webservice every 2 seconds that would do the same thing as Windows Service, but it seems like a lot of queries sent all the time for nothing.</p> <pre><code>//websocket gateway on 8070 var app = require('http').createServer(handler) , io = require('socket.io').listen(app) , fs = require('fs'); var mysocket = 0; app.listen(8070); function handler (req, res) { fs.readFile(__dirname + '/index.html', function (err, data) { if (err) { res.writeHead(500); return res.end('Error loading index.html'); } res.writeHead(200); res.end(data); }); } io.sockets.on('connection', function (socket) { console.log('index.html connected'); mysocket = socket; }); //udp server on 49320 var dgram = require("dgram"); var server = dgram.createSocket("udp4"); server.on("message", function (msg, rinfo) { console.log("msg: " + msg); if (mysocket != 0) { mysocket.emit('field', "" + msg); mysocket.broadcast.emit('field', "" + msg); } }); server.on("listening", function () { var address = server.address(); console.log("udp server listening " + address.address + ":" + address.port); }); server.bind(49320); </code></pre> |
26,208,978 | 0 | <p>change the option, then re-initialize:</p> <pre><code>$('ul').circleMenu({direction:'bottom-right'}).circleMenu('init'); </code></pre> |
38,989,100 | 0 | <p>So to do this I made a unit test, that passes:</p> <pre><code>// // CloudKitLocationsTests.swift // import XCTest import UIKit import CoreLocation import CloudKit class CloudKitLocationsTests: XCTestCase { let locations = [ CLLocation(latitude: 34.4, longitude: -118.33), CLLocation(latitude: 32.2, longitude: -121.33) ] func storeLocationToCloud(location:CLLocation) { let locationRecord = CKRecord(recordType: "location") locationRecord.setObject(location, forKey: "location") let publicData = CKContainer.defaultContainer().publicCloudDatabase publicData.saveRecord(locationRecord) { (records, error) in if error != nil { print("error saving locations: \(error)") } else { print("Locations saved: \(records)") } } } func fetchLocationsFromCloud(completion: (error:NSError?, records:[CKRecord]?) -> Void) { let query = CKQuery(recordType: "Location", predicate: NSPredicate(value: true)) CKContainer.defaultContainer().publicCloudDatabase.performQuery(query, inZoneWithID: nil){ (records, error) in if error != nil { print("error fetching locations") completion(error: error, records: nil) } else { print("found locations: \(records)") completion(error: nil, records: records) } } } func testSavingLocations(){ let testExpectation = expectationWithDescription("saveLocations") var n = 0 for location in self.locations { let locationRecord = CKRecord(recordType: "Location") locationRecord["location"] = location let publicData = CKContainer.defaultContainer().publicCloudDatabase publicData.saveRecord(locationRecord) { (records, error) in if error != nil { print("error saving locations: \(error)") } else { print("Locations saved: \(records)") } n += 1 if n >= self.locations.count { testExpectation.fulfill() } } } // do something then call fulfill (in callback) waitForExpectationsWithTimeout(10){ error in if error != nil { XCTFail("timed out waiting on expectation: \(testExpectation)") } } } func testFetchingLocations(){ let testExpectation = expectationWithDescription("FetchLocations") fetchLocationsFromCloud(){ (error, records) in if error != nil { XCTFail("error fetching locations") } else { XCTAssertGreaterThan(records!.count, 0) } // do something then call fulfill (in callback) testExpectation.fulfill() } waitForExpectationsWithTimeout(10){ error in if error != nil { XCTFail("timed out waiting on expectation: \(testExpectation)") } } } } </code></pre> <p>Note that you had case mismatch Location/location. Also, I am doing a subscript to set the field value.</p> <p>Run this it works. Getting the location from the location manger callback has nothing to do with CloudKit so you should be able to plug this in as you require.</p> <p>One other thing: I did turn on the option to allow you to query on ID field for the Location record type.</p> |
26,026,088 | 0 | search bar in TableView : App crashes when type last character of search text string <p>Added search bar in the storyboard on top of tableview app crashes when type last character of search text string with the error </p> <p>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PFUser copyWithZone:]: unrecognized selector sent to instance</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; PFQuery *query = [PFUser query]; [query orderByAscending:@"username"]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (error){ NSLog(@"Error:%@ %@", error, [error userInfo]); } else { self.allUsers = objects; self.searchResults = [[NSArray alloc] init]; [self.tableView reloadData]; } }]; - (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"username like %@", searchText]; self.searchResults = [self.allUsers filteredArrayUsingPredicate:predicate]; } -(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString { [self filterContentForSearchText:searchString scope:[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]]; return YES; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (tableView == self.searchDisplayController.searchResultsTableView){ return [self.searchResults count]; } else { //[self filterData]; return [self.allUsers count]; } } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; if (tableView == self.searchDisplayController.searchResultsTableView) { cell.textLabel.text = [self.searchResults objectAtIndex:indexPath.row]; } else { PFUser *user = [self.allUsers objectAtIndex:indexPath.row]; cell.textLabel.text = user.username; } return cell; } -(void) tableView:(UITableView *) tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (tableView == self.tableView){ self.title = [self.allUsers objectAtIndex:indexPath.row]; } else { self.title = [self.searchResults objectAtIndex:indexPath.row]; } } </code></pre> <p>EDIT: </p> <p>When i type bt at lldb prompt this is what i get </p> <pre><code> * thread #1: tid = 0x86e99, 0x029b68b9 libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x029b68b9 libobjc.A.dylib`objc_exception_throw frame #1: 0x02cd4243 CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:] + 275 frame #2: 0x02c2750b CoreFoundation`___forwarding___ + 1019 frame #3: 0x02c270ee CoreFoundation`__forwarding_prep_0___ + 14 frame #4: 0x029c8bcd libobjc.A.dylib`-[NSObject copy] + 41 frame #5: 0x018317b6 UIKit`-[UILabel _setText:] + 129 frame #6: 0x0183194d UIKit`-[UILabel setText:] + 40 * frame #7: 0x000138d8 -[EditFriendsViewController tableView:cellForRowAtIndexPath:](self=0x0aca3e50, _cmd=0x01e3b31f, tableView=0x0baed600, indexPath=0x0ac92b70) + 456 at EditFriendsViewController.m:204 frame #8: 0x0176f11f UIKit`-[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412 frame #9: 0x0176f1f3 UIKit`-[UITableView _createPreparedCellForGlobalRow:] + 69 frame #10: 0x01750ece UIKit`-[UITableView _updateVisibleCellsNow:] + 2428 frame #11: 0x017656a5 UIKit`-[UITableView layoutSubviews] + 213 frame #12: 0x016e5964 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355 frame #13: 0x029c882b libobjc.A.dylib`-[NSObject performSelector:withObject:] + 70 frame #14: 0x00aa545a QuartzCore`-[CALayer layoutSublayers] + 148 frame #15: 0x00a99244 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 380 frame #16: 0x00a990b0 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 26 frame #17: 0x009ff7fa QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 294 frame #18: 0x00a00b85 QuartzCore`CA::Transaction::commit() + 393 frame #19: 0x00a01258 QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92 frame #20: 0x02bff36e CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30 frame #21: 0x02bff2bf CoreFoundation`__CFRunLoopDoObservers + 399 frame #22: 0x02bdd254 CoreFoundation`__CFRunLoopRun + 1076 frame #23: 0x02bdc9d3 CoreFoundation`CFRunLoopRunSpecific + 467 frame #24: 0x02bdc7eb CoreFoundation`CFRunLoopRunInMode + 123 frame #25: 0x036135ee GraphicsServices`GSEventRunModal + 192 frame #26: 0x0361342b GraphicsServices`GSEventRun + 104 frame #27: 0x01676f9b UIKit`UIApplicationMain + 1225 frame #28: 0x000144cd `main(argc=1, argv=0xbfffee04) + 141 at main.m:16 </code></pre> <p>Have no idea what is causing this.</p> <p>Help will be appreciated.</p> <p>Thanks</p> |
14,959,037 | 0 | type conversion can not have aggregate operand (error in modelsim) <p>I'm novice to VHDL. I'm getting the following errors while compiling in modelsim6.5b </p> <blockquote> <ol> <li>type conversion(to g) cannot have aggregate operand, </li> <li>No feasible entries for infix operator "and",</li> <li>Target type ieee.std_logic_1164.std_ulogic in variable assignment is different from - expression type std.stadard.integer</li> </ol> </blockquote> <p>any help on these and the reason behind that will be helpful.</p> <p>This is the package I've written</p> <pre><code>library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; package enc_pkg is constant n : integer := 1; constant k : integer := 2; constant m : integer := 3; constant L_total : integer := 10; constant L_info : integer := 10; type t_g is array (1 downto 1, 3 downto 1)of std_logic; signal g:t_g; type array3_10 is array (3 downto 1, 10 downto 0) of std_logic; type array2_10 is array (2 downto 1, 10 downto 0) of std_logic; procedure rsc_encoder( x : in std_logic_vector(1 to 10); terminated : in std_logic; y : out array2_10); procedure encode_bit(input : in std_logic; state_in : in std_logic_vector(1 to 2); output : out std_logic_vector(1 to 2); state_out : out std_logic_vector(1 to 2)); procedure encoderm (infor_bit : in std_logic_vector(1 to 8); en_output : out std_logic_vector(1 to 20)); end enc_pkg; package body enc_pkg is procedure rsc_encoder( x : in std_logic_vector(1 to 10); terminated : in std_logic; y : out array2_10)is variable state : std_logic_vector(1 to 2); variable d_k : std_logic; variable a_k : std_logic; variable output_bit : std_logic_vector(1 to 2); variable state_out : std_logic_vector(1 to 2); begin for i in 1 to m loop state(i) := '0'; end loop; for i in 1 to L_total loop if(terminated = '0' or (terminated = '1' and i <= L_info)) then d_k := x(i); elsif(terminated = '1' and i > L_info)then d_k := (g(1, 2) and state(1)) xor (g(1, 3) and state(2)); end if; a_k := (g(1, 1) and d_k) xor (g(1, 2) and state(1)) xor (g(1, 3)) and state(2)); encode_bit(a_k, state, output_bit, state_out); state := state_out; output_bit(1) := d_k; y(1, i) := output_bit(1); y(2, i) := output_bit(2); end loop; end rsc_encoder; procedure encode_bit(input : in std_logic; state_in : in std_logic_vector(1 to 2); output : out std_logic_vector(1 to 2); state_out : out std_logic_vector(1 to 2))is variable temp : std_logic_vector(1 to 2); begin for i in 1 to n loop temp(i) := g(i, 1) and input; for j in 2 to k loop temp(i) := temp(i) xor (g(i, j) and state_in(j-1)); end loop; end loop; output := temp; state_out := input & state_in(m-1); end encode_bit; procedure encoderm (infor_bit : in std_logic_vector(1 to 8); en_output : out std_logic_vector(1 to 20))is --type array2_10 is array (2 downto 1, 10 downto 0) of integer; --type array3_10 is array (3 downto 1, 10 downto 0) of integer; variable interleaved : std_logic_vector(1 to 10); variable input : std_logic_vector(1 to 10); variable puncture : std_logic; variable output : array3_10; variable y : array2_10; variable en_temp : std_logic_vector(1 to 10); begin input := "0000000000"; for i in 1 to 8 loop input(i) := infor_bit(i); end loop; rsc_encoder(input, terminated 1, y); for i in 1 to 10 loop output(1, i) := y(1, i); output(2, i) := y(2, i); end loop; interleaved(1) := output(1, 1); interleaved(2) := output(1, 4); interleaved(3) := output(1, 7); interleaved(4) := output(1, 10); interleaved(5) := output(1, 2); interleaved(6) := output(1, 5); interleaved(7) := output(1, 8); interleaved(8) := output(1, 3); interleaved(9) := output(1, 6); interleaved(10) := output(1, 9); rsc_encoder(interleaved, terminated 0, y); for i in 1 to 10 loop output(3, i) := y(2, i); end loop; if puncture = '1'then for i in 1 to 10 loop for j in 1 to 3 loop en_output(3*(i-1)+j) := output(j, i); end loop; end loop; elsif puncture = '0' then for i in 1 to L_total loop en_temp(n*(i-1)+1) := output(1, i); if((i rem 2) = 1)then en_temp(n*i) := output(2, i); else en_temp(n*i) := output(3, i); end if; end loop; end if; en_output := en_temp; end encoderm; end enc_pkg; </code></pre> |
2,269,101 | 0 | <p>try using the "url"-option of the form-helper, like:</p> <pre><code><?= $form->create('Car',array('url' => '/.../search')) ?> </code></pre> <p>EDIT (quick n' dirty fix):</p> <pre><code><form action=".../search" method="post"> <input type="text" name="data[Car][model]" /> <input type="text" name="data[Car][year]" /> <?=$form->end("Search")?> </code></pre> |
23,067,475 | 0 | How do I obtain pseudo R2 measures in stata when using GLM regression? <p>I am using GLM estimation method (family = poisson and link = log). This should be equivalent to a poisson estimation method. Therefore, I should be able to calculate pseudo R2 measures. How can I do this?</p> <p>Thanks,</p> <p>Bruno</p> |
36,100,916 | 0 | <p>You can use PHPmailer class to send the mail. It is very easy option to send mails.</p> <p>To use PHPMailer:</p> <ul> <li>Download the PHPMailer script from here: <a href="http://github.com/PHPMailer/PHPMailer" rel="nofollow">http://github.com/PHPMailer/PHPMailer</a></li> <li>Extract the archive and copy the script's folder to a convenient place in your project.</li> <li>Include the main script file -- <code>require_once('path/to/file/class.phpmailer.php');</code></li> </ul> <p>Now, sending emails with attachments goes from being insanely difficult to incredibly easy:</p> <pre><code>$email = new PHPMailer(); $email->From = '[email protected]'; $email->FromName = 'Your Name'; $email->Subject = 'Message Subject'; $email->Body = $bodytext; $email->AddAddress( '[email protected]' ); $file_to_attach = 'PATH_OF_YOUR_FILE_HERE'; $email->AddAttachment( $file_to_attach , 'NameOfFile.pdf' ); return $email->Send(); </code></pre> <p>It's just that one line $email->AddAttachment(); to add an attachment.</p> |
26,302,016 | 0 | Getting the address of a statically allocated array into a pointer inside a struct <p>The simplified version of my code is the following:</p> <pre><code>struct args { int p; int *A; }; typedef struct sort_args sort_args; void func(int A[], int p) { args new_struct = {&A, p}; args *args_ptr = &new_struct; } </code></pre> <p>I'm trying to convert a statically (I think that's the term) allocated array into a pointer, but the compiler keeps throwing these warnings:</p> <blockquote> <p>warning: initialization makes integer from pointer without a cast [enabled by default] args new_struct = {&A, p, r};</p> <p>warning: (near initialization for ‘new_struct.p’) [enabled by default] warning: initialization makes pointer from integer without a cast [enabled by default] warning: (near initialization for ‘new_struct.A’) [enabled by default]</p> </blockquote> <p>What am I doing wrong?</p> |
8,893,436 | 0 | <p>Quick question: is the image the same every time or specific to a customer order? I presume it is different or you wouldn't be asking.</p> <p>To clarify: attachments are okay if you sending out invoices/delivery notes/order confirmation. However you are advised to setup your email so that the IP address can be verified directly. You are also advised to use a SPFrecord in your DNS so that the remote mail server can check that your server is allowed to send emails for you. Furthermore, in your order success page you can also ask your customers to add you to their address book, in that way your emails will not be marked as SPAM, regardless of whether you have SPF records and things setup. The only thing is you cannot guarantee customers will do that, so the SPF records and the IP reverse lookup is best. You can also use DomainKeys DKIM for the likes of Yahoo mail - mail delivery isn't what this question is about so you will have to Google DKIM for yourself...</p> <p>Otherwise, attaching an image is simple. See the example at the top of the page of the Zend Programmers Reference Guide on attachments:</p> <p><a href="http://framework.zend.com/manual/en/zend.mail.attachments.html" rel="nofollow">http://framework.zend.com/manual/en/zend.mail.attachments.html</a></p> <p>Keep reading the comments for clarification on how to get the image data included.</p> <p>Hope that helps!</p> |
32,551,620 | 0 | <p>Here is how I solved this issue with Win2D. First of all, add <code>Win2D.uwp</code> nuget package to your project. Then use this code:</p> <pre><code>CanvasDevice device = CanvasDevice.GetSharedDevice(); CanvasRenderTarget renderTarget = new CanvasRenderTarget(device, (int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight, 96); using (var ds = renderTarget.CreateDrawingSession()) { ds.Clear(Colors.White); ds.DrawInk(inkCanvas.InkPresenter.StrokeContainer.GetStrokes()); } using (var fileStream = await file.OpenAsync(FileAccessMode.ReadWrite)) await renderTarget.SaveAsync(fileStream, CanvasBitmapFileFormat.Jpeg, 1f); </code></pre> |
29,751,233 | 0 | <p>I use this trick to deploy apk's wirelessly to my device from Android Studio, with IIS. Just go on your computer, open a command prompt, type <code>ipconfig</code> and see what your local network IP address is. Type that exact IP address into your phone and forward-slash into your asp page.</p> <p>Hope this helps!</p> |
37,262,183 | 0 | <p>I can't say I understand the root of the issue or why my solution even works for me, but I ran into the same problem and simply added <code>pdf(NULL)</code> at the beginning of my script and everything seems to work just fine. No <code>dev.off()</code> needed (adding it in threw an error for me).</p> |
22,104,179 | 0 | AngularJS how to style JSON message <p>I am trying to style the JSON message to the required style. </p> <p>the required style of JSON message looks like: </p> <pre><code>[ { “question”: “Write down Nhat’s email”, “answer”: “[email protected]”, “inline”: true }, { <% NEXT QUESTION/ANSWER %> }, { <%…%> } ] </code></pre> <p>and currently my JSON message looks like: </p> <p>[{"Question":"Question","Note":"","notePlaceholder":"enter text","inlineChecked":false},{"Question":"Question","Note":"","notePlaceholder":"enter text...","inlineChecked":""}]</p> <p>Any idea on that? </p> <p><a href="http://plnkr.co/edit/7erVt8?p=preview" rel="nofollow">This is the link of my code</a></p> |
34,304,780 | 0 | <p>Simply uncompress the archive <a href="https://github.com/git-for-windows/git/releases/download/v2.6.4.windows.1/PortableGit-2.6.4-64-bit.7z.exe" rel="nofollow"><code>PortableGit-2.6.4-64-bit.7z.exe</code></a> anywhere you want.</p> <p>Then open <code>C:\path\to\PortableGit-2.6.4-64-bit\git-bash.exe</code>: you won't see that error message.</p> |
24,704,597 | 0 | <p>Ended up with creating a new stringbuilder object with ," " quote. And appended each string to the text view. Finally I got the output working as required when used with linear layout n stuffs. Thanks for ur help :)</p> |
36,778,120 | 0 | <p>You can also give weightage while modelling. you can assign higher weight to minority class it will compensate the imbalance. </p> |
2,638,493 | 0 | <p>With Jquery</p> <pre> $(document).ready(function () { $("#live").load("ajax.php"); var refreshId = setInterval(function () { $("#live").load('ajax.php?randval=' + Math.random()); }, 3000); }); </pre> <p>it calls ajax.php in first load and every 3 seconds to #live div.</p> |
17,815,000 | 0 | <p>You can <code>effectively</code> name ranges using the text box in the top left of the screen (where appears the "B2" or whatever coordinate the cell has). Select entire column and insert the name there.</p> <p>Then the name is valid to use in formulas.</p> |
35,692,426 | 0 | <p>Send the request to PHP page on click of like button and handle it there to update the database.</p> |
37,432,517 | 1 | Neo4j 3.0.1 - Neomodel 2.0.7 - Parameter provided for node creation is not a Map <p>I am trying out the Neomodel Source Code to make it work with Neo4j 3.0.1. I am facing this eeror saying that the Parameters provided for node creation is not a Map.</p> <p>{u'errors': [{u'message': u'Parameter provided for node creation is not a Map', u'code': u'Neo.ClientError.Statement.TypeError'}], u'results': []}</p> <pre><code> Traceback (most recent call last): File "/Users/adaggula/Documents/workspace/Collective[i]-pve/test_revised.py", line 32, in <module> jim = Person(name='jim5').save() File "/Users/adaggula/workspace/python/pve/lib/python2.7/site-packages/neomodel/signals.py", line 25, in hooked val = fn(self, *args, **kwargs) File "/Users/adaggula/workspace/python/pve/lib/python2.7/site-packages/neomodel/core.py", line 160, in save self._id = self.create(self.__properties__)[0]._id File "/Users/adaggula/workspace/python/pve/lib/python2.7/site-packages/neomodel/core.py", line 290, in create results = db.cypher_query(query, params) File "/Users/adaggula/workspace/python/pve/lib/python2.7/site-packages/neomodel/util.py", line 219, in cypher_query results = self._execute_query(query, params) File "/Users/adaggula/workspace/python/pve/lib/python2.7/site-packages/neomodel/util.py", line 212, in _execute_query results = self.session.cypher.execute(query, params) File "/Users/adaggula/workspace/python/pve/lib/python2.7/site-packages/py2neo/cypher/core.py", line 113, in execute results = tx.commit() File "/Users/adaggula/workspace/python/pve/lib/python2.7/site-packages/py2neo/cypher/core.py", line 325, in commit return self.post(self.__commit or self.__begin_commit) File "/Users/adaggula/workspace/python/pve/lib/python2.7/site-packages/py2neo/cypher/core.py", line 280, in post raise self.error_class.hydrate(error) File "/Users/adaggula/workspace/python/pve/lib/python2.7/site-packages/py2neo/cypher/error/core.py", line 54, in hydrate error_cls = getattr(error_module, title) AttributeError: 'module' object has no attribute 'TypeError' </code></pre> <p>What are the changes I should make to make it work?</p> |
35,315,325 | 0 | <p>The problem was the missing '/' from the definition of the parent state ..</p> <pre><code>.state('manage', { url: '/manage', abstract: true, template:'<div ui-view></div>', resolve: { authorize: ['authorization', function(authorization) { return authorization.authorize(); } ] } }) </code></pre> |
13,713,916 | 0 | Am I using default arguments incorrectly? <p>I've just started going through a beginners book of C++. I have some java experience (but having said that, I've never used default arguments in java to be honest)</p> <p>So, as mentioned, my issue is with default arguments..</p> <p>This is the code snippet I'm using:</p> <pre><code>#include <iostream> using namespace std; //add declaration int add(int a, int b); int main (void) { int number1; cout << "Enter the first value to be summed: "; cin >> number1; cout << "\nThe sum is: " << add(number1) << endl; } int add(int a=10, int b=5) { return a+b; } </code></pre> <p>The response I get from g++ compiler is: "too few arguments to function 'int add(int, int)'</p> <p>Am I doing this wrong? (I've also tried it with literal arguments)</p> <p>P.S. I can't seem to get the code snippet to display properly? Has the system changed?</p> |
1,276,968 | 0 | Transparent gif/black background? <p>I have the following, it works except the gif is suppose to be transparent and it is creating a black background, if I change all the (imagesavealpha, etc) stuff to the $container then it created a transparent background for the text I add to this image. How would I go about getting rid of the black background? Basically this is a signature type image. I write stuff too, which I don't think you need to see.</p> <pre><code> $im = imagecreatefromgif("bg.gif"); $container = imagecreatetruecolor(400, 160); imagesavealpha($im, true); imagealphablending($im, false); $trans_colour = imagecolorallocatealpha($im, 0, 0, 0, 127); $w = imagecolorallocate($container, 255, 255, 255); imagefill($im, 0, 0, $trans_colour); imagecopymerge($container, $im, 0, 0, 0, 0, 460, 180, 100); </code></pre> |
34,964,409 | 0 | <p>You can use the code snippet given below as it will serve your purpose. Here use <strong>time.h</strong> header file for required <strong>localtime()</strong> function and then using the <strong>strftime()</strong> function with required parameters will give the output and it returns it as a string.</p> <pre><code>#include <iostream> #include <string> #include <time.h> std::string current_date(); std::string current_time(); int main(){ std::cout<<"Current date => "<<current_date()<<"\n"; std::cout<<"Current time => "<<current_time()<<"\n"; } std::string current_date(){ time_t now = time(NULL); struct tm tstruct; char buf[40]; tstruct = *localtime(&now); //format: day DD-MM-YYYY strftime(buf, sizeof(buf), "%A %d/%m/%Y", &tstruct); return buf; } std::string current_time(){ time_t now = time(NULL); struct tm tstruct; char buf[40]; tstruct = *localtime(&now); //format: HH:mm:ss strftime(buf, sizeof(buf), "%X", &tstruct); return buf; } </code></pre> |
39,935,239 | 0 | <p>"mlm" model class is not widely known by <code>lm()</code> users. For an introductory example, please refer to <a href="http://stackoverflow.com/q/39262534/4891738">Fitting a linear model with multiple LHS</a>. Also read <a href="http://stackoverflow.com/q/15296833/4891738">Run lm with multiple responses and weights</a> for the limitations of "mlm".</p> <hr> <p>R does not have full support for "mlm" class at the moment. Here is an overview:</p> <ul> <li><p>The following generic functions work and would return a matrix:</p> <pre><code>coef(), residuals(), fitted(), vcov() </code></pre></li> <li><p>The following generic functions work and would return a list:</p> <pre><code>summary(), anova() </code></pre></li> <li><p>The following generic functions have limited support for "mlm":</p> <pre><code>predict() </code></pre></li> <li><p>The following generic functions do not work at all for "mlm":</p> <pre><code>rstandard(), plot(), confint() </code></pre></li> </ul> <hr> <p>The aim of this wiki page is to direct "mlm" users to efficient solutions of various inference and diagnostic tasks. Here is a good collection:</p> <p><strong>Model Summary</strong></p> <ul> <li><a href="http://stackoverflow.com/q/19740292/4891738">Obtain standard errors of regression coefficients for an “mlm” object returned by <code>lm()</code></a></li> <li><a href="http://stackoverflow.com/q/15820623/4891738">Obtain t-statistic for regression coefficients of an “mlm” object returned by <code>lm()</code></a></li> <li><a href="http://stackoverflow.com/q/28442141/4891738">Get confidence intervals for regression coefficients of “mlm” object returned by <code>lm()</code></a></li> <li><a href="http://stackoverflow.com/q/15254543/4891738">Obtain residual standard errors of an “mlm” object returned by <code>lm()</code></a></li> </ul> <p><strong>Model Prediction</strong></p> <ul> <li><a href="http://stackoverflow.com/q/39553770/4891738">Prediction of 'mlm' linear model object from <code>lm()</code></a></li> <li><a href="http://stackoverflow.com/q/40710992/4891738">Applying lm() and predict() to multiple columns in a data frame</a></li> </ul> <p><strong>Model Diagnostic</strong></p> <ul> <li><a href="http://stackoverflow.com/q/39562631/4891738">Obtain standardised residuals and “Residual v.s. Fitted” plot for “mlm” object from <code>lm()</code></a></li> </ul> <hr> <p>Please read above questions carefully, and only ask a new question when it is not answered in above.</p> |
23,905,917 | 0 | <p>As far as I know this is currently only supported for fields of a class or top level fields but not for local variables inside a method/function when reflecting at runtime. Maybe source mirrors has more capabilities (I haven't used it yet) but I think this can only be used at compile time.</p> |
4,821,501 | 0 | <p>This is <strong>(maybe)</strong> because of the theme for root isn't the same.</p> <p>Try to change the theme by starting the appereance manager as sudo:</p> <pre><code>sudo gnome-appearance-properties </code></pre> |
15,143,434 | 0 | <p>The @ in that case is a SQL Server construct. Parameters to SQL Server queries are specified with the @ symbol since T-SQL (SQL Server programming language) uses the @ symbol for variables. </p> |
24,415,793 | 0 | <p>Figured it out. I started ignoring the whitespace, changed a few rules, and resolved the conflicts. The parser returns a function that is used to determine if some object matches the query. Here is the final result:</p> <pre><code>/* Google-Like Parser */ /* Lexical Grammar */ %lex %% \s+ { /* ignore whitespace */ } "AND"|"&&" { return "AND" } "OR"|"||" { return "OR" } "NOT"|"!" { return "NOT" } "(" { return "OPEN" } ")" { return "CLOSE" } ":" { return "QUAL" } "-" { return "NEG" } "\""|"'" { return "QUOTE" } \w+ { return "WORD" } "." { return "DOT" } <<EOF>> { return "EOF" } . { return "INVALID" } /lex /* Operators */ %right AND OR %right NOT %right QUAL NEG DOT %start START %% /* Language Grammar */ START : EXP EOF { return $1; } ; EXP : EXP AND EXP { $$ = function(obj) { return ($1(obj) && $3(obj)); }; } | EXP OR EXP { $$ = function(obj) { return ($1(obj) || $3(obj)); }; } | NOT EXP { $$ = function(obj) { return !($2(obj)); }; } | OPEN EXP CLOSE { $$ = $2; } | ARGS { $$ = function(obj) { return parser.processArgs(obj, $1)(obj); }; } ; ARGS : ARG ARGS { $$ = [ $1, $2]; } | OP ARGS { $$ = [ $1, $2]; } | ARG { $$ = [ $1 ]; } | OP { $$ = [ $1 ]; } ; OP : NEG ARG {{ $2.not = true; $$ = $2; }} | NEG ARG QUAL ARG {{ $$ = { "not": true, "operator": $2.operand, "operand": $4.operand }; }} | ARG QUAL ARG {{ $$ = { "not": false, "operator": $1.operand, "operand": $3.operand }; }} ; ARG : QUOTE TERMS QUOTE {{ $$ = { "not": false, "operator": null, "operand": $2.join(" ") }; }} | TERM {{ $$ = { "not": false, "operator": null, "operand": $1 }; }} ; TERMS : TERM TERMS { $$ = [ $1 ].concat($2); } | TERM { $$ = [ $1 ]; } ; TERM : WORD DOT TERM { $$ = $1 + $2 + $3; } | WORD { $$ = $1; } ; %% parser.processArgs = function(obj, args) { if (args.length > 1) { if (args[0].operator) return function(obj) { return (parser.matchArg(obj, args[0]) && parser.processArgs(args[1])(obj)); }; else return function(obj) { return (parser.matchArg(obj, args[0]) || parser.processArgs(args[1])(obj)); }; } else { return function(obj) { return parser.matchArg(obj, args[0]); }; } } /* Override Later */ parser.matchArg = function(obj, arg) { return true; } </code></pre> |
13,348,849 | 0 | An interface that allows to pick specific color through a modal dialog box. |
26,959,290 | 0 | <p>This issue was solved using the Index property of the partition. <strong>Partition Index number is permanent. Win32_DiskPartition</strong></p> |
27,549,182 | 0 | <p>I know this is an old thread but I tried the above example in a SP 2010 environment and it didn't work so I thought I'd add my working CAML. Instead of using the ContentTypeID field, I just used ContentType=Folder</p> <pre><code><Where> <And> <Eq> <FieldRef Name='ContentType'/> <Value Type='Text'>Folder</Value> </Eq> <Eq> <FieldRef Name="Title"/> <Value Type='Text'>Folder Name</Value> </Eq> </And> </Where> </code></pre> |
36,810,178 | 0 | Cannot send signal to another process in perl <p>I have to send a sigusr2 signal number 12 to a process named xyz in a cgi perl script. I do the following:</p> <pre><code>my $pid = `pidof xyz`; kill 12, $pid or die "could not kill: $pid"; </code></pre> <p>It dies when I press the button on which this command run.</p> <p>How can I send signal to a process named "xyz" in a cgi perl script.</p> |
12,598,915 | 0 | <p>Well, some were faster, but here's yet another solution, that's works: <a href="http://jsfiddle.net/FsrbZ/6/" rel="nofollow">http://jsfiddle.net/FsrbZ/6/</a></p> |
36,514,045 | 0 | UIColor expected a type after update to xCode 7.3 <p>My project stop to compile after was updated to 7.3 version. For this moment main problem is in header files when I want to return <code>UIColor</code>. xCode tells me <code>Expected a type</code> error. Is there some way to handle with this situation?</p> <p><strong>Edit:</strong> my code (nothing special)</p> <pre><code>#import <Foundation/Foundation.h> @interface NSString (Color) - (UIColor *)rgbColor; //Expected a type - (UIColor *)hexColor; //Expected a type @end </code></pre> |
26,229,371 | 0 | <p>Since there are only 5 constant columns, I would go with the simple solution:</p> <pre><code>var data = ctx.tblEmp.SingleOrDefault(e => e.Id == model.Id); switch (columnName) { case "Id": data.id = newValue; //newValue should have a correct type. break; case "name": data.name = newValue; break; case "desig": data.desig = newValue; break; case "depart": data.depart = newValue; break; case "Sal": data.Sal = newValue; break; } </code></pre> |
27,350,762 | 0 | Chain of functions for variadic template arguments <p>I am trying to design a generic, type-safe way to load interleaved data into a OpenGL VBO. My problem is now how to organize the various glVertexAttribPointer() calls. I have defined the buffer data descriptor as follows.</p> <pre><code>template <typename T> struct Descriptor { T vertex; }; template <typename T, typename U> struct Descriptor { T vertex; U normal; }; ... </code></pre> <p>This is basically now all well and simple. However, my problem is that the template functions to actually set the attributes turned out as follows.</p> <pre><code>template <template <class> class Desc, typename T> void setAttributes(const Desc<T>& desc) { // set attributes for vertices ... glVertexAttribPointer(0, sizeof(desc.vertex), ...); } template <template <class, class> class Desc, typename T, typename U> void setAttributes(const Desc<T, U>& desc) { // set attributes for vertices ... glVertexAttribPointer(0, sizeof(desc.vertex), ...); // set attributes for normals ... glVertexAttribPointer(1, sizeof(desc.normal), ...); } ... </code></pre> <p>Basically the problem is that I still ended up with a lot of repetition. Is there a way break these down into two template functions where one only sets vertex attributes and one sets only normals? In pseudocode something like the following.</p> <pre><code>template <class Desc, class T, Args...> void setAttributes(Desc desc) { setVertexAttributes(...); // somehow decide that if there are args left, call again... } template <class Desc, class U, Args...> void setAttributes(Desc desc) { // ...ending up here setNormalAttributes(...); } </code></pre> |
4,805,554 | 0 | Database Snapshot SQL Server 2000 <p>We have a large database that receives records concerning several hundred thousand persons per year. For a multitude of reasons I won't get into when information is entered into the system for a specific person it is often the case that the individual entering the data will be unable to verify whether or not this person is already in the database. Due to legal reqirements, we have to strive towards each individual in our database having a unique identifier (and no individual should have two or more.) Because of data collection issues it'll often be the case that one individual will be assigned many different unique identifiers.</p> <p>We have various automated and manual processes that mostly clean up the database on a set schedule and merge unique identifiers for persons who have had muliple assigned to them.</p> <p>Where we're having problems is we are also legally required to generate reports at year end. We have a set of year-end reports we always generate, however it is also the case that every year several dozen ad hoc reports will be requested by decision makers. Where things get troublesome is because of the continuous merging of unique identifiers, our data is not static. So any reports generated at year end will be based on the data as it existed the last day of the year, 3 weeks later if a decision maker requests a report, whatever we give them can (and will) often conflict direcly with our legally required year end reports. Sometimes we'll merge up to 30,000 identifiers in a month which can greatly change the results of any query.</p> <p>It is understood/accepted that our database is not static, but we are being asked to come up with a method for generating ad hoc reports based off of a static snapshot of the database. So if a report is requested on 1/25 it will be based off the exact same dataset as our year end reports.</p> <p>After doing some research I'm familiar with database snapshots, but we have a SQL Server 2000 database and we have little ability to get that changed in the short-to-medium term and database snapshots are a new feature in the 2005 edition. So my question would be what is the best way to create a queryable snapshot of a database in SQL Server 2000?</p> |
15,087,397 | 0 | <p>Since your scheduled task is actually changing the permissions on the error log file, the only viable options I can see are:</p> <p>1) Make the scheduled task not write to the error_log. Add the following to the top of the cron job:</p> <p><code>error_reporting(E_NONE);</code></p> <p>2) Make the scheduled task write to the system log (event viewer in windows) by issuing the following command at the start of your scheduled task (PHP file):</p> <p><code>ini_set('error_log', 'syslog');</code></p> <p>3) If all of the above do not suit you, you can try scheduling the task as the IIS User/Group. This would insure that the permissions are met and error 500 is no longer caused. </p> <p>There is no magic fix to this, you can either change the scheduled task so it has the same UID/GID as the PHP process, or you can stop logging in the scheduled_task. </p> |
6,075,216 | 0 | <p>You cannot generally retrieve missing information.</p> <p>If you know what it is an image of, in this case a Gaussian or Airy profile then it's probably an out of focus image of a point source - you can determine the characteristics of the point.</p> <p>Another technique is to try and determine the character tics of the blurring - especially if you have many images form the same blurred system. Then iteratively create a possible source image, blur it by that convolution and compare it to the blurred image.<br> This is the general technique used to make radio astronomy source maps (images) and was used for the flawed Hubble Space Telescope images</p> |
40,394,830 | 0 | I am using javascript sort function on angular scope inside an if condition. My condition is false still it is going inside <p>Here is the code snippet:</p> <pre><code>$scope.notes = notes.data; if($scope.notes) { console.log("notes", $scope.notes); } else { console.log("no notes"); } if($scope.notes) { console.log("in this if"); $scope.singleNote = $scope.notes.sort(function(a,b) { return new Date(b.date_posted).getTime() - new Date(a.date_posted).getTime() })[0]; } </code></pre> <p>Even if the logic goes in else, it is also going in the 2nd if. It does not display the console of 2nd if but gives an error called: $scope.notes.function is not defined. It should not go in the 2nd if, if it goes in the else block.</p> |
31,175,394 | 0 | <p>You can do the same if slickPrev function doesn't work. You can pass the function name as parameter to slick.</p> <pre><code>$('.next').click(function(){ $("#sliderId").slick('slickNext'); }); </code></pre> |
26,006,257 | 0 | How to add a double with a variable only using one double <pre><code>public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Insert value for year (Ez = 2014): "); double year = in.nextDouble(); System.out.println("Insert value for day (Ex = 12): "); double day = in.nextDouble(); System.out.println("Insert number for month (Ex = 3): "); double month = in.nextDouble(); double totalDays = day; if (month == 1) { } else if (month == 2) { double totalDays = (totalday + 31); } } </code></pre> <p>I'm trying to take the <code>totalDays</code> double and use it in the if statement. I want to add it with a variable without using anymore doubles. How?</p> |
16,357,625 | 0 | Creating HTML tag using XSLT <p>I have an XML (Here I have shown only a fragment and it has several Control elements,</p> <pre><code> <Control Name="submit" ID=""> <Properties> <Property Name="id" Value="btn_Submit" /> <Property Name="value" Value="Submit" /> </Properties> </Control> </code></pre> <p>and I want to get html as</p> <pre><code><html> <head> <title>example_htmlPage</title> </head> <body> <input id="btn_Submit" type="submit" value="Submit"/> </body> </html> </code></pre> <p>by using XSLT. I have written an XSLT as</p> <pre><code> <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head> <title>example_htmlPage</title> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="/"> <xsl:for-each select="//Control[@Name='submit']"> <input type="submit" value="//Property/@Value/text()"/> </xsl:for-each> <xsl:apply-templates/> </xsl:template> </xsl:stylesheet> </code></pre> <p>So, my question is how to get the value of an attribute into HTML tag? I couldnt solve it by creating local variable as well as by using </p> <pre><code> <input type="submit" value=&lt;xsl:select="(//Property/@Value/text())"/&gt;/> </code></pre> <p>Please help me.</p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.