qid
int64
10
74.7M
question
stringlengths
15
26.2k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
27
28.1k
response_k
stringlengths
23
26.8k
1,412,442
here is the current complex query given below. ``` SELECT DISTINCT Evaluation.ETCode, Training.TTitle, Training.Tcomponent, Training.TImpliment_Partner, Training.TVenue, Training.TStartDate, Training.TEndDate, Evaluation.EDate, Answer.QCode, Answer.Answer, Count(Answer.Answer) AS [Count], Questions.SL, Questions.Quest...
2009/09/11
[ "https://Stackoverflow.com/questions/1412442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/169965/" ]
try ``` select ..., count(distinct Training.Tcode) as ..., ... ``` **EDIT - please now look at this...** Take the following SQL code. The first select is how SQL server would do this and the second query should be access compliant... ``` declare @t table (eCode int, tcode int) insert into @t values(1,1) insert int...
I managed to do a count distinct value in Access by doing the following: ``` select Job,sum(pp) as number_distinct_fruits from (select Job, Fruit, 1 as pp from Jobtable group by Job, Fruit) t group by Job ``` You have to be careful as if there is a blank/null field (in my code fruit field) the group by will coun...
40,132,831
I have a program to calculate tax payable on an income. The first method taxPayable() calculates the amount of tax that would be paid on this income and the second one incomeRemaining() should calculate the income remaining after the tax has been deducted but the variable tax is changing back to its first assignment of...
2016/10/19
[ "https://Stackoverflow.com/questions/40132831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7042553/" ]
``` double $$ = income - tax;//here tax is using your class static variable tax, which is never changed from 0. ``` To debug.. change your class variable to 1000 instead of 0 as a default value. In your taxPayable() method dont declare double tax again. Just use the variable without declaring it
because you are re-declaring variable `tax` - please read about [scopes](http://www.java2s.com/Tutorial/Java/0020__Language/VariableScope.htm). change each `double tax = ...` in your method `taxPayable(int income)` to just `tax`.
14,111,951
How do you mix the concepts of ASP.NET MVC and entityframework in a elegant and robust way when it comes to retrieving stuff from the database and visualizing it via the controller and view? The example below will throw Dispose exceptions because the View will be displayed after the using statement is closed. ``` ...
2013/01/01
[ "https://Stackoverflow.com/questions/14111951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1470327/" ]
I think you are using navigation properties of the User object in the view. These are probably evaluated in a lazy way. The User object is created before you exit the method. Somehow you are requesting extra info which is queried in the view. But since the dispose already happended, this results in the exception. One...
``` User user; using (var usersDb = new UsersDb(new WebSecurityWrapper())) { user = usersDb.GetUser(User.Identity.Name); } return View(user); ```
6,586,886
Which technique is better: ``` <span onclick="dothis();">check</span> ``` or: ``` <span class="bla">check</span> <script type="text/javascript"> $('.bla').click(function(e) {} ); </script> ``` Are there any differences according to usability, performance etc.? Thank you!
2011/07/05
[ "https://Stackoverflow.com/questions/6586886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/830209/" ]
The second is better from a code quality standpoint since it is considered to be [unobtrusive](http://en.wikipedia.org/wiki/Unobtrusive_JavaScript). I am not certain if either approach has measurable performance benefits. My advice is to stick to the unobtrusive approach - it will save you a lot of time when you are d...
Technique 1 is intrusive or obstrusive JavaScript: Your markup is intermixed with your JavaScript calls, which can be really messy and is not a separation of concerns. Technique 2 is [unobstrusive](http://en.wikipedia.org/wiki/Unobtrusive_JavaScript): Your JavaScript is kept separate from the markup, keeping both clea...
11,781,358
Very strange error indeed. I have an item that clones itself every month, setting the next object to have a `scheduled_on` date, `+ 1.months` in the future. But then this happened : ``` Sun, 01 Apr 2012 16:00:00 PDT -07:00 Tue, 01 May 2012 16:00:00 PDT -07:00 Fri, 01 Jun 2012 16:00:00 PDT -07:00 Sun, 01 Jul 2012 16:0...
2012/08/02
[ "https://Stackoverflow.com/questions/11781358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/93311/" ]
have you tried .next\_month ? <http://api.rubyonrails.org/classes/Time.html#method-i-months_since>
Time calculations are always problematic. 1.month might be 30 days, 31 days, 28 days, or anything in between. It depends on the month being added, what you're adding to it, and so on. So errors like this are unfortunately and annoyingly common-place when doing date arithmetic. To correct this code, I would always ensu...
26,854,301
I was playing around with [JavaFX's `Tooltip`](https://docs.oracle.com/javafx/2/api/javafx/scene/control/Tooltip.html). I realized that for me personally the delay between hovering over something and the tooltip actually appearing is too long. A look in the API reveals: > > Typically, the tooltip is "activated" when ...
2014/11/10
[ "https://Stackoverflow.com/questions/26854301", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4216641/" ]
There is an existing feature request for this: [JDK-8090477 Customizable visibility timing for Tooltip](https://bugs.openjdk.java.net/browse/JDK-8090477). The feature request is currently scheduled for integration into Java 9. Attached to the issue I linked is a patch you can apply to allow you to get this functional...
I find that with the above implementation there's still a delay sometimes that I cannot explain. The following has worked for me and removed the delay entirely: ``` public static void bindTooltip(final Node node, final Tooltip tooltip){ node.setOnMouseMoved(new EventHandler<MouseEvent>(){ @Override p...
15,657,115
We have one function called `.any` in Prototype. I want the same like in Jquery. My Prototype code is: ``` if (item_name == '' || $R(1,ind).any(function(i){return($F("bill_details_"+i+"_narration") == item_name)})) { alert("This item already added."); } ``` I want to perform the Equivalent function using Jq...
2013/03/27
[ "https://Stackoverflow.com/questions/15657115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1968826/" ]
JQuery has [.is()](https://api.jquery.com/is/) method, from documentation: `Check the current matched set of elements against a selector, element, or jQuery object and return *true* if at least one of these elements matches the given arguments`. Thus an equivalent code is: ``` if (item_name == '' || $([1,ind]).is(fun...
According to JQuery's documentation if you return a false in the callback function it will break the loop: > > We can break the $.each() loop at a particular iteration by making the callback function return false. Returning non-false is the same as a continue statement in a for loop; it will skip immediately to the n...
55,816
I enjoy my road bike, but recently my children have become old enough to ride, but still very slowly. I'd like to be able to ride with them on all or mostly flat pavement, but the road bike just isn't pleasant for slow riding as it takes more effort to balance and isn't that comfortable. What type(s) of bike is well-s...
2018/07/13
[ "https://bicycles.stackexchange.com/questions/55816", "https://bicycles.stackexchange.com", "https://bicycles.stackexchange.com/users/2313/" ]
You might want to consider a fat-bike. They're naturally slower, because they're meant for really rough terrain, so they have low gearing, high frame mass to be sturdy and higher rolling resistance due to the fat wheels. The fat wheels also make them pretty stable. Plus, if you're so inclined, after you don't need it ...
I have a foldable bike which is quite comfy at low speeds (especially so probably due to the low CG). With the added advantage that you can transport it easily to kid friendly bike paths.
68,415,104
In Java, if I want to associated one value with an other I would simply do the following: ``` static final Map<String, String> VALUES_BY_NAME; static { final Map<String, String> valuesByName = new HashMap<>(); valuesByName.put("fruit", "apple"); valuesByName.put("drink", "Coke"); VALUES_BY_NAME = Col...
2021/07/16
[ "https://Stackoverflow.com/questions/68415104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15856421/" ]
In Groovy you could do ``` def myMap = [fruit: 'apple', drink: 'coke'].asUnmodifiable() ```
> > I would simply > > > That isn't simple at all, though. Try this: ``` static final Map<String, String> VALUES_BY_NAME = Map.of( "fruit", "apple", "drink", "Coke"); ``` > > Is there something similar with groovy for Jenkins? > > > Groovy is a different language but uses the same java runtime library ...
7,320,443
I would like to minimize w'Hw, with respect to w, where w is a vector, and H is matrix. And with the following constraint, |w1|+|w2|+|w3| < 3, ie. the l1 norm of the weights vector is less that 3. How can I do this in matlab? Thanks
2011/09/06
[ "https://Stackoverflow.com/questions/7320443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/914738/" ]
you need to use the optimization toolbox, specifically [fmincon](http://www.mathworks.com/help/toolbox/optim/ug/fmincon.html): use fun to establish w'Hw, and you want `c(eq) = (|w1|+|w2|+|w3| - 3)` <0 which you set with nonlcon (in the documentation).
I'd suggest you look at the fminsearch function in the matlab documentation.
69,621,626
**Comment**: While I understand some concerns about the 'accuracy' of the data, I think it is really immaterial to the question. The data is what it is. Assuming so, would be interested in a possible solution. **---------** I need to read a file containing lines that have unicode characters. The lines contain multipl...
2021/10/18
[ "https://Stackoverflow.com/questions/69621626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11731250/" ]
When you `line.encode()` the default encoding is `utf-8`. As you can see below, the `¥` symbol becomes two bytes `\xc2\xa5` throwing off your count: ``` >>> line = '00041235957A CORU¥A ABC\n' >>> line.encode() b'00041235957A CORU\xc2\xa5A ABC\n' ``` As the comments mentioned, you are likely mis-reading t...
Is you want to divide the line character-wise in a readable, repeatable way you can use [slice](https://docs.python.org/3/library/functions.html#slice) objects. ``` >>> s1 = slice(0, 4) >>> s2 = slice(4, 11) >>> s3 = slice(11, 26) >>> s4 = slice(26, 29) >>> slices = line[s1], line[s2], line[s3], line[s4] >>> slices ('...
40,534,687
I need to retrieve a list of Distribution groups with their x400 and x500 addresses. I have determined the attributes are proxyaddresses and TextEncodedORAddress. We are running Exchange 2013. When I look at a high level searchbase like "OU=Exchange,OU=company,DC=company,DC=com" and use Get-ADUser it returns the user a...
2016/11/10
[ "https://Stackoverflow.com/questions/40534687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6901837/" ]
It's important to note that this system referenced in question was built from source code and supported nginx was replaced with Apache (not officially supported by gitlab). Here is the deal - in the standard nginx config on my system I can see this ``` upstream gitlab-workhorse { server unix:/var/opt/gitlab/gitla...
First, double-check your [gitlab workhorse](https://gitlab.com/gitlab-org/gitlab-workhorse) version and if it is compatible with your current GitLab installation. Of all the GitLab issues you reference, the comments on [22484](https://gitlab.com/gitlab-org/gitlab-ce/issues/22484#note_16594090) seem the most promising:...
27,999,030
I need to install my app only on some devices and does not allow installation on another devices. I thought that maybe I can pair a unique ID to install apps. **I can do this?** **How I can block the installation of a single application on some devices?**
2015/01/17
[ "https://Stackoverflow.com/questions/27999030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3626214/" ]
You cannot control app installation based on Device Id (IMEI) either by google play store or direct install... However you can check at the start of the launcher activity, you can check that the Device Id (or Imei) is in the list of imei you are allowing... Then allow user to use the apk... ELSE finish() the launcher a...
> > I thought that maybe I can pair a unique ID to install app > > > There's no platform provided, reliable uniquie ID of the device. > > How I can block the installation of a single application on some devices? > > > You cannot block installation on device - as long as device meets your manifest requirement...
235,928
Gravitational wave is produced by change in gravitational field, [source](http://stuver.blogspot.com/2012/05/q-what-is-gravitational-wave.html). If something is moving away from me at constant speed, its gravitational field will vary. But why only accelerating bodies produce GW?
2016/02/13
[ "https://physics.stackexchange.com/questions/235928", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/76520/" ]
Because radiation from such a body undergoing inertial motion would gainsay Galileo's postulate of relativity, *i.e.* that there is no measurement one can make within an inertial frame that could detect that frame's motion relative to another inertial frame. Gravitational radiation would bear energy away from the body,...
Gravitational wave is a concept predicted by General Relativity by Albert Einstein. The very first point to look is that how a theory extended from explaining the symmetry of physical laws in inertial frames to include accelerated frames become a theory of gravitation. This is the starting point of General Relativity. ...
33,299,265
This one is tricky! I've spent hours and hours on this, can't find anything similar on Stackoverflow, probably because I'm not sure what to search for. **The issue:** 1. In a container I have 3 boxes that each have an open/close toggle button — that toggles them individually — **it works fine.** 2. I have one Open-C...
2015/10/23
[ "https://Stackoverflow.com/questions/33299265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4218116/" ]
I think your solution is very easy. Basically what you have to do is check the number of items are you showing when the user click de main button out site the box. Take a look below: // Open/close all boxes $('.open-close-all-button').on('click', function(){ event.preventDefault(); ``` var numOfItems = $('.is-vis...
I guess you are looking for `:hidden` selector: ``` $('.open-close-all-button').on('click', function(){ event.preventDefault(); $('.small-box:hidden').addClass('is-visible'); }); ```
41,302,132
What I want to accomplish is this: I have created button component based on TouchableOpacity. In my app I have 3 types of differently looking buttons, they all share some styles and have something specific as well. Below is how my Button.js looks like: ``` import React, { Component } from 'react'; import { Text, Touch...
2016/12/23
[ "https://Stackoverflow.com/questions/41302132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5018179/" ]
I think this would be the shortest and cleanest way ``` import React, { PropTypes } from 'react'; import { Text, TouchableOpacity } from 'react-native'; const Button = ({ children, onPress, type }) => ( <TouchableOpacity onPress={onPress} style={[styles.defaultButton, styles[type].button]}> <Text style={[styles...
You could do something like this: ``` import React, { PropTypes } from 'react'; import { StyleSheet, Text, TouchableOpacity } from 'react-native'; // Commonly shared button styles const defaultStyle = StyleSheet.create({ textStyle: { alignSelf: 'center', fontSize: 17, paddingTop: 15, paddingBottom: ...
2,392,238
I am currently Developing application in MVC2 I have want to used mutiple form tags in My application In My View I have Created a table which has Delete option which i am doing through Post for Individual Delete so i have Create form tag for each button. i also want user to give option to delete mutiple records so i am...
2010/03/06
[ "https://Stackoverflow.com/questions/2392238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/280448/" ]
Conceptually, a form within a form doesn't really make sense. Can you not use Action Links in place of the buttons on the inner forms? You can still style them to look like buttons.
I think this will not be possible using post. Since using post we can find which submit button was clicked but will not able to find the value of submit button if we want to display some value to show the user and other value which we want to submit to database. in this case my submit button is generated Dynamically ...
64,696,233
**Environment:** Python 3.7.7 Flask 1.1.2 Werkzeug 1.0.1 **Introduction:** I made a FLask application where my users can add some "Platform" and edit them. Each platform has a category. For example : the platform "Facebook" is in the Category "Social Network". the platform "Instagram" is in the Category "Social...
2020/11/05
[ "https://Stackoverflow.com/questions/64696233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10551444/" ]
```py def show_reservations(filename): reservations = [] with open(filename) as f: for line in f.readlines(): splitted_line = line.replace(',', '').split() status = splitted_line[2] if status == "CONFIRMED": time = splitted_line[1] name...
Instead of directly printing, `append` the entries to a list of tuples `(time, name)`. Then after the list, sort it (`li.sort()`), and loop through it again, this time printing.
10,568,732
For some reason I can't get this batch file to run in my .NET 4.0 MVC3 project. I am using server 2008R2 64 bit - does cmd.exe operate differently? ``` System.Diagnostics.Process process1; process1 = new System.Diagnostics.Process(); process1.EnableRaisingEvents = false; string strCmdLine = "d:\audioTemp\test.bat"; ...
2012/05/13
[ "https://Stackoverflow.com/questions/10568732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/547794/" ]
``` System.Diagnostics.Process.Start("cmd.exe", @"/c d:\audioTemp\test.bat") ```
Your string contains a tab character `\t`. Either escape the backslashes: ``` strCmdLine = "d:\\audioTemp\\test.bat"; ``` Or use a [verbatim string literal](http://msdn.microsoft.com/en-us/library/aa691090%28v=vs.71%29.aspx): ``` strCmdLine = @"d:\audioTemp\test.bat"; ```
6,244,578
I am trying to post an image file to a server. Initially I tested my script without proxy at my home and it worked fine. But when I used the same script in my college it is throwing some error. The function for uploading images is as below ``` function upload($filepath,$dir) { $ch = curl_init(); curl_setopt($...
2011/06/05
[ "https://Stackoverflow.com/questions/6244578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/784583/" ]
The problem is the proxy our institute using is "SQUID". And Squid doesn't support Expect: 100-continue. So finally added this to my options ``` curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); ``` and its all working fine.
We had a similar error where adding the header `Expect:` fixed our proxy error. However, the problem was a problem with curl itself. Versions <= 7.68 didn't work and versions >= 7.70 worked fine.
16,039,911
I am getting an exception in this program. I have tried to do some changes but its still not working. I am trying to write data from demo.txt to demo1.txt but its giving a `NullPointerException`. What am I doing wrong here? ``` import java.io.*; class CopyFile{ public static void main(String[] args){ St...
2013/04/16
[ "https://Stackoverflow.com/questions/16039911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2229178/" ]
Don't underestimate the use of curly braces with loops. Here's your code: ``` while((str=din.readLine())!=null) System.out.println(str); writeTextFile("/home/newlabuser/workspace/CopyFileDemo/src/demo1.txt",str); din.close(); ``` Here, only `System.out.println(str)` will be running in a loop, and the nex...
Try this: ``` File fdir = new File("/home/newlabuser/workspace/CopyFileDemo/src"); FileWriter file = new FileWriter(new File(fdir,"demo1.txt")); file.write(new Scanner(new File(fdir,"demo.txt")).useDelimiter("\\Z").next()); file.close(); ```
46,311,673
I don't even know how to change the network security group of an Azure VM via the portal... I hardly found anything useful from the official doc.
2017/09/20
[ "https://Stackoverflow.com/questions/46311673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8637292/" ]
For the **Invalid VCS root mapping error** you can fix it by deleting the `vcs.xml` file located in the `.idea` folder of your project and then rebuild your project.
all you need is to delete the vcs.xml file inside an .idea folder this works!
16,716,851
I'm creating a basic game, and I can load images fine. Now, I'm trying to load sounds but I keep getting **NullPointerExceptions**. I'm 100% sure the path is correct, I've tried loading more then one sounds and I always get this error. I've only been able to use it once. Here is my sound bank: ``` public class Sound...
2013/05/23
[ "https://Stackoverflow.com/questions/16716851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1580953/" ]
`usleep(50000)` blocks the thread Use `NSTimer` instead to updated the progressView. ``` [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(updateProgressView) userInfo:nil repeats:YES]; duration = 0; ... - (void)updateProgressView { // Update the progress } } ... ```
Both your `drawRect:` and your `progressView:…` methods will be called on the main thread. `setNeedsDisplay:` doesn't immediately call `drawRect:`; it queues it up to be called the next time your application's main thread passes through its run loop. Use an `NSTimer` or read up on CoreAnimation to see if it provides s...
11,364,111
I am writing a particle based game that is mainly built by drawing lots of colored shapes. **Question 1)** For most of the enemy units I am drawing 4 layered rectangles by setting the paint and then drawing the rectangle through the canvas. I was wondering if it is better to draw using bitmaps, or to draw using th...
2012/07/06
[ "https://Stackoverflow.com/questions/11364111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/831913/" ]
I'm facing the same issues. I recently found this: ``` document.addEventListener('touchmove', function(event){ if(event.touches.length >=2) { event.stopPropagation(); event.preventDefault(); } }); ``` But if the users acts really fast it still works. This is really annoying in a kiosk setti...
easy, use an applet to prevent zoom, java rulez.
24,067
I want perform demand forecast for particular item based on attributes.Did I need to train the model with unsold items ? **by maintaining sales Quantity as zero** or go with only items sold in training period.
2017/10/25
[ "https://datascience.stackexchange.com/questions/24067", "https://datascience.stackexchange.com", "https://datascience.stackexchange.com/users/37626/" ]
> > Has anyone done any benchmarks? > > > Yes, [the 2014's benchmark in question](https://github.com/Rdatatable/data.table/wiki/Benchmarks-%3A-Grouping) has turned into foundation for [db-benchmark](https://h2oai.github.io/db-benchmark) project. Initial step was to reproduce 2014's benchmark on recent version of s...
A colleague and I have conducted some preliminary studies on the performance differences between pandas and data.table. You can find the study (which was split into two parts) on our [Blog](https://www.statworx.com/de/blog/pandas-vs-data-table-a-study-of-data-frames/) (You can find part two [here](https://www.statworx....
49,371,467
I am writing a Vue.js app with Bootstrap 4 and I can't loaded though I followed the documentation. Added to main.js `Vue.use(BootstrapVue);` Added to css file related to App.vue: ``` @import '../../node_modules/bootstrap/dist/css/bootstrap.css'; @import '../../node_modules/bootstrap-vue/dist/bootstrap-vue.css'; ``...
2018/03/19
[ "https://Stackoverflow.com/questions/49371467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2970627/" ]
Try importing the files using JavaScript. ``` import 'bootstrap/dist/css/bootstrap.css' import 'bootstrap-vue/dist/bootstrap-vue.css' ``` --- On closer inspection it looks like you're missing `<b-tabs>` also `<b-modal>` is controlled by `v-model` ``` <div class="main"> <div> <b-modal id="modal1" t...
I had to do a combination/variation of some of the other answers. App.vue: ``` import { BootstrapVue, IconsPlugin } from 'bootstrap-vue' import Vue from 'vue' // Install BootstrapVue Vue.use(BootstrapVue) // Optionally install the BootstrapVue icon components plugin Vue.use(IconsPlugin) import 'bootstrap/dist/css/b...
15,353
From a tester's point of view when do we say that a product is **stable**? Is the product still **stable** when it contains a known bug?
2015/10/28
[ "https://sqa.stackexchange.com/questions/15353", "https://sqa.stackexchange.com", "https://sqa.stackexchange.com/users/13179/" ]
I would call a software that runs consistently without crashing as stable. To answer the second question, yes a 100% bug free software is a myth (if i may). There still can be numerous bugs which are hidden and to name a few : * Bugs of implementation. * Bugs of unclear specification. * Bugs of poor documentation. ...
I would say that a product is stable when it is obsolete - cynical but often true (40 years of experience as a software engineer / architect).
2,037,745
I am referring to the [solution for the Singleton Pattern by Bill Pugh](https://en.wikipedia.org/wiki/Singleton_pattern#Initialization-on-demand_holder_idiom) on Wikipedia: ``` public class Singleton { // Private constructor prevents instantiation from other classes private Singleton() {} /** * Sin...
2010/01/10
[ "https://Stackoverflow.com/questions/2037745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/206450/" ]
Here is the explanation from Wikipedia on this phenomenon (emphasis mine): > > When the class Something is loaded by > the JVM, the class goes through > initialization. Since the class does > not have any static variables to > initialize, the initialization > completes trivially. **The static class > definition...
There are two differences here that need to be noted. The first is the Singleton design pattern and the other is a singleton instance. The Singleton design pattern is problematic due to the fact that the design pattern represents a singleton instance as is implemented using static state (which is a bad thing for a var...
1,860,292
I'm returning results from the following query which is taking too long when running. I'm not sure how to eliminate the where parameters when they are not used in SSRS. All the @variables are strings ``` select S.SBSB_ID, LTRIM(RTRIM(M.MEME_FIRST_NAME)) + ' ' + LTRIM(RTRIM(M.MEME_LAST_NAME)) AS Names, (CASE M.MEME_RE...
2009/12/07
[ "https://Stackoverflow.com/questions/1860292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5831/" ]
You can do something like this: ``` // Load the file contents string contents = File.ReadAllText("example.txt"); // Obtain the data using regular expressions string id = string id = Regex.Match( contents, @"CoreDBCaseID=(?<id>\d+)").Groups["id"].Value; string server = string.Empty; // Add regex here string...
Open the file and read it in one line at a time. You can use Regular Expressions [(cheat sheet)](http://www.mikesdotnetting.com/Article/46/CSharp-Regular-Expressions-Cheat-Sheet) to match and parse only the text you want to find.
5,713,825
My app uses ClickOnce tehcnology. Today I needed to run it as administrator. I modified the manifest file from ``` <requestedExecutionLevel level="asInvoker" uiAccess="false" /> ``` to ``` <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> ``` However VS cannot compile the project: > > ...
2011/04/19
[ "https://Stackoverflow.com/questions/5713825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/627193/" ]
``` private void Form1_Load(object sender, EventArgs e) { if (WindowsIdentity.GetCurrent().Owner == WindowsIdentity.GetCurrent().User) // Check for Admin privileges { try { this.Visible = false; ProcessStartInfo info = new ProcessStartI...
If you launching ClickOnce app from IE, to have Administrative privileges just run IE with Administrative privileges and your app will have it too.
46,729
We are installing the Windows Resource Kit, and that installs RoboCopy. We want to have access to a few windows scripts that uses RoboCopy so we can start from those to build something else. Any ideas on where I can find a few samples? NOTE 1: A bit of information. Every time we try to copy D drive to E drive (new dr...
2009/07/27
[ "https://serverfault.com/questions/46729", "https://serverfault.com", "https://serverfault.com/users/4310/" ]
I used Robocopy to synchronize website content across 9 web servers. Here's a sample of the batch file that ran robocopy.exe. This batch file was scheduled to run every 5 or 10 minutes or could be run manually to push changes immediately. ``` robocopy.exe d:\inetpub\wwwroot\ \\webserver1\d$\inetpub\wwwroot\ *.* /E /PU...
To solve the second problem, (the locked file error and subsequent wait), use the switches `/r`, `/w` and `/reg`, for example: ``` robocopy D:\ E:\ /r:1 /w:1 /reg ``` This means **r**etry one time only after **w**aiting one second and make these settings default in the **reg**istry.
17,788,510
I have a simple select menu with some list items which are dynamically inserted when the page is loaded. ``` <select id="viewTasks" name="viewTasks" size=10 style="width: 100%;"> <option>Task 1</option> <option>Task 2</option> <option>Task 3</option> <option>Task 4</option> </select> ``` I would like...
2013/07/22
[ "https://Stackoverflow.com/questions/17788510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1954511/" ]
``` $('#viewTasks option').dblclick(function() { //do something }); ``` or raw: ``` <select id="viewTasks" name="viewTasks" size=10 style="width: 100%;"> <option ondblclick="someFunction(1);">Task 1</option> <option ondblclick="someFunction(2);">Task 2</option> <option ondblclick="someFunction(3);">Task...
[Check out the MDN definition of the DOM event `ondblclick` here.](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers.ondblclick) [Here is a working example jsFiddle from referencing that definition.](http://jsfiddle.net/R2Nrf/) jQuery was only used in this example to run the initialization event in...
64,723,778
I have been using VSCode with the Microsoft Python extension for a couple of months now. However just today I found that the green button I had in the top right that executed my code is gone. I have tried uninstalling the python extension and reinstalling, I have deleted and redownloaded VSCode, I have tried installing...
2020/11/07
[ "https://Stackoverflow.com/questions/64723778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14593690/" ]
It may also come from the restricted mode. Please make sure you're in a trusted window.
Kindly install the Python interpreter from the following site: <https://www.python.org/downloads/> Then vs code will ask for permission to run the interpreter. and then its done
2,057,137
I'm building a simple dropdown where I'd like to add a class to parent if UL exists: HTML: ``` <ul id="menu"> <li><a href="#">Parent 1</a></li> <li><a href="#">Parent 2</a> <ul> <li><a href="#">Sub 2.1</a></li> <li><a href="#">Sub 2.2</a></li> </ul> </li> </ul> ``` So I'd like to: * hide ...
2010/01/13
[ "https://Stackoverflow.com/questions/2057137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/172637/" ]
You wrote: ``` $("ul#menu li ul li:has(ul)") ``` Given your HTML structure, shouldn't this be: ``` $("ul#menu li:has(ul)") ```
This *should* do the trick (untested): ``` $('ul#menu > li > ul').each(function() { var list = $(this); list.hide(); list.parent().hover(list.hide, list.show); list.parent().parent().addClass('dropdown'); }); ```
25,988,258
``` Array ( [0] => Array ( [questionID] => 47 [surveyID] => 51 [userID] => 31 [question_Title] => Choose Any One? [question_Type] => Dropdown [response] => 1.Android 2.Windows 3.Blackberry [required...
2014/09/23
[ "https://Stackoverflow.com/questions/25988258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3928821/" ]
``` if($yourArr[0]['required']==0) //Just check for first element in your array echo "Zero"; else echo "One"; ```
This is probably the most hackish solution I'll come up with all this morning, but if you are shooting for a quick one-liner, this should do: ``` if(in_array(1, array_column($myArray, 'required'))) echo 'required'; ``` *Edit: This assumes you've got PHP 5.5+ at hand* **Update:** After a closer look at the docume...
49,277,583
My current Android application allows users to search for content remotely. e.g. The user is presented with an `EditText` which accepts their search strings and triggers a remote API call that returns results that match the entered text. Worse case is that I simply add a `TextWatcher` and trigger an API call each tim...
2018/03/14
[ "https://Stackoverflow.com/questions/49277583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/423199/" ]
your query can be easily solved by using RxJava2 methods, before i post code i will add the steps of what i am doing. 1. add an PublishSubject that will take your inputs and add a filter to it which will check if the input is greater than two or not. 2. add debounce method so that all input events that are fired befor...
You might find what you need in the [`as`](http://reactivex.io/RxJava/javadoc/io/reactivex/Observable.html#as-io.reactivex.ObservableConverter-) operator. It takes an `ObservableConverter` which allows you to convert your source `Observable` into an arbitrary object. That object can be another `Observable` with arbitra...
40,545,533
I would be interested in making an app Android that starts functions with vocal commands (example: instead of clicking on the button, use a voice command). My idea was to use speech recognition to store a result in a variable, and if the result corresponds to a keyword set, the function is started. The questions I hav...
2016/11/11
[ "https://Stackoverflow.com/questions/40545533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7145451/" ]
Don't use a regular expression for this; they are not really designed for verifying numeric *values*. Instead, parse the `String` into an integral type (`num`, say), reject if any exception is thrown, then use `num % 2 == 0` as your test for evenness. If, for some reason, you absolutely *must* use a regular expressi...
Change your regex to below for checking if the string length is even. ``` Pattern p5 = Pattern.compile("^(..)*$"); ``` It matches zero or more sets of two characters, all of which is anchored to the start and end of the string
45,309,173
I have the following stored procedure: ``` @offset INT, @fetch INT SELECT col1 AS col FROM tab1 UNION SELECT col1 FROM tab2 ORDER BY col OFFSET @offset ROWS FETCH NEXT @fetch ROWS ONLY ``` Now I want to add a third table as UNION, after the offset and fetch has been executed. Is that possible? ``` UNION SELECT TOP...
2017/07/25
[ "https://Stackoverflow.com/questions/45309173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2822465/" ]
``` @offset INT, @fetch INT WITH CTE1 AS (SELECT TOP 100 PERCENT col1 AS col FROM tab1 UNION SELECT TOP 100 PERCENT col1 FROM tab2 ORDER BY col OFFSET @offset ROWS FETCH NEXT @fetch ROWS ONLY) SELECT * FROM CTE1 UNION SELECT TOP 1 col1 FROM tab3 ORDER BY NEWID() ```
use derived table ``` Select col from ( SELECT col1 AS col FROM tab1 UNION SELECT col1 FROM tab2 ORDER BY col OFFSET @offset ROWS FETCH NEXT @fetch ROWS ONLY ) a UNION SELECT TOP 1 col1 FROM tab3 ORDER BY NEWID() ``` **Note :** You can replace `UNION` with `UNION ALL` if you aren't looking for removing duplicates ...
107,409
After seeing [this answer](https://physics.stackexchange.com/questions/106808/why-is-jumping-into-water-from-high-altitude-fatal/106814#106814) claiming that displacing matter "In a very short time", "no matter whether the matter is solid, liquid, or gas" (even though he concludes that falling from a high altitude is f...
2014/04/08
[ "https://physics.stackexchange.com/questions/107409", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/42491/" ]
It's not the falling that's fatal, it's the deceleration at the end that kills you. Something like water or concrete does this on a sub-meter distance (which requires extremely high forces). On the other hand a gas is much less dense, so it cannot decelerate a falling object nearly as quick. Sometimes [inflatable cush...
I don't have exact statistics for any of this. The fall is not what kills you, it is the sudden deceleration at the end. The only thing that can cause a change in speed is another force being applied to you. During the fall, the 2 forces of air resistance and gravity are acting on you constantly in opposite directions...
616,097
Is it possible?
2009/03/05
[ "https://Stackoverflow.com/questions/616097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15884/" ]
See here: [How to install perl modules using CPAN without root](http://sial.org/howto/perl/life-with-cpan/non-root/) I have just set this up on a server without root access and CPAN does everything automatically. But if you *really* wanna install a module without CPAN and you don't have root (assuming this since you...
If you are using Red Hat (Fedora, CentOS), you should use RPM for Perl dependencies wherever possible. Perl packages are *almost always* named perl-Module-Name, e.g. perl-DBI, perl-Spreadsheet-WriteExcel, etc. On Ubuntu the naming scheme is libmodule-name-perl.
54,771,214
i have a query which looks like this ``` select max(mytime), type, id from my table where id = 1 group by id, type ``` This gives me results similar to ``` time type id 2018-01-01 green 1 2017-01-03 blue 1 2017-03-03 red 1 ``...
2019/02/19
[ "https://Stackoverflow.com/questions/54771214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8150454/" ]
You most likely have no `Sessions` or `members` arrays in your state before the network request is complete. You could add default values of empty arrays to get around this. ``` class App extends React.Component { state = { Sessions: [], members: [] }; // ... } ```
You can also run the map function only when the sessions or members exists. For that you can do below check like: ``` {this.state.Sessions && this.state.Sessions.map(UsersSession ....... rest of the logic} ```
3,619,036
I'm using JDK1.6. When I implement an interface and in the implementing class, if I give `@override` before my function names, Eclipse throws an compilation error. i.e. below code is wrong according to Eclipse. ``` public class SomeListener implements ServletContextListener { @Override public void contextDestr...
2010/09/01
[ "https://Stackoverflow.com/questions/3619036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42372/" ]
@Override works on method implementation since java 1.6. --- **Resources :** * [Sun's forums - Java Programming - Should @Override apply to implementation of interface/abstract methods?](http://forums.sun.com/thread.jspa?threadID=5446210) * [dertompson.com - @Override specification changes in Java 6](http://dertomps...
The @Override annotation changed in Java 1.6 version. In Java 1.5, the compiler didn't allow @Override annotation on implemented interface methods, from 1.6 it does. ![Java Compiler](https://i.stack.imgur.com/LAues.png) You must change java compiler version in properties project -> Java Compiler
14,521,585
I'm not 100% comfortable with a PHP class defined here: [mysqli](https://github.com/opencart/opencart/blob/master/upload/system/database/mysqli.php) I stripped out the guts to shorten it somewhat and get a parse error at runtime. ``` <?php function query($x) { if ($x > 8) { return 'greater than eight!'; ...
2013/01/25
[ "https://Stackoverflow.com/questions/14521585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1409731/" ]
The code provided may not reach one of the `return`s for any input `a,b` and that's what the compiler is complaining about. Actually in your case the `if-else` will be reached with the very first iteration - unfortunately something which the compiler cannot deduce. Therefore, it goes the save way and issues this error...
You don't have a return statement after the for loop but even then h++ is dead code becaue it will never get past the first iteration.
25,725,817
Sorry if this makes no sense, but I will try to give all the information needed! I would like to use rsync to copy a range of sequentially numbered files from one folder to another. I am archiving a DCDM (Its a film thing) and it contains in the order of 600,000 individually numbered, sequential .tif image files (~10...
2014/09/08
[ "https://Stackoverflow.com/questions/25725817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4019417/" ]
Globing is the feature of the shell to expand a wildcard to a list of matching file names. You have already used it in your question. For the following explanations, I will assume we are in a directory with the following files: ```sh $ ls -l ``` ```none -rw-r----- 1 5gon12eder staff 0 Sep 8 17:26 file.txt -rw-r---...
You can check for the file name starting with a digit by using [pattern matching](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html): ``` for file in [0-9]*; do # do something to $file name that starts with digit done ``` Or, you could enable the `extglob` option and loop over all file nam...
12,642,991
I'm using Font Awesome to create icons on my site, and while they look fantastic on the iPod Touch with Retina display, on my iMac they looks a bit blurred and less defined. Here's an image to demonstrate: ![enter image description here](https://i.stack.imgur.com/CISge.png) As you can see, the font looks really nice...
2012/09/28
[ "https://Stackoverflow.com/questions/12642991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1261316/" ]
there's a strange trick that works sometime, try: ``` -webkit-transform:rotateZ(0); -moz-transform:rotateZ(0); -o-transform:rotateZ(0); transform:rotateZ(0); ``` if you have a block centered, try to check if left offset is an integer. You can use Javascript to check and fix it. I can help you if you want.
-webkit-perspective: 1000; Fixed it for me
186,082
I use Windows Vista 64-bit and I have 6GB of RAM. Today I installed a new harddrive, and started with moving 465GB of data from my old harddrive to the new one. This process is very slow, the speed is `10,5 MB per second` and I'm not doing anything else on the computer. The estimated time is 12h for this process. Why ...
2010/09/08
[ "https://superuser.com/questions/186082", "https://superuser.com", "https://superuser.com/users/27037/" ]
One of the main complain about Vista is the slow file copy or move operations. It seems that it is the new "Remote Differential Compression" who is the culprit. To turn it off go in Control Panel / Programs and features / Turn on or turn off Windows features and uncheck "Remote Differential Compression". EDIT: Altern...
You shouldn't use Windows Explorer for large copies : It's the planet's slowest copier. Use any Explorer replacement that doesn't come up with Explorer's silly copying dialog. My own favorite is the free [Servant Salamander 1.52](http://www.altap.cz/download.html#salrel). If you have an antivirus, turn it off, s...
9,013,127
I am using boost-thread in my application. When I deploy this application on a client machine (running Ubuntu 11.10), I need to make sure that libboost\_thread.so is available on the machine. However, when I run "apt-get install libboost-thread1.46," it seems to pull in the whole development enviornment (libgcc, libbos...
2012/01/26
[ "https://Stackoverflow.com/questions/9013127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730194/" ]
No such package exception: The package "libboost-thread1.46" does not exist on Ubuntu, is treated by `apt-get` as a regular expression, and the development package *also* matches the expression. The two candidate packages are named `libboost-thread1.46-dev` and [libboost-thread1.46.1](http://packages.ubuntu.com/precise...
You could link statically against boost.
1,142,405
In C++ a statement like this is valid: ``` &Variable; ``` IMO it doesn't make any sense, so my question is, if you do this, will it affect the compiled result in any way, or will the compiler optimize it away? Thanks!
2009/07/17
[ "https://Stackoverflow.com/questions/1142405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/97688/" ]
It's worth remembering that operator&() might be overloaded for the variable type, have some side effects and optimizing away such statement would change program behaviour. One example is a smart pointer used for controlling the non-C++ objects - [\_com\_ptr\_t](http://msdn.microsoft.com/en-us/library/417w8b3b(VS.80)....
It seems you take a reference to a local variable on stack or register. The best way to find out what the compiler does at the moment is to view the Disassembly view in Visual Studio. [Disassembly view in Debugger (Visual Studio Orcas)](http://social.msdn.microsoft.com/Forums/en-US/vcplus2008prerelease/thread/b8412c3b...
34,432
A planet (as well as a dwarf planet) must, according to the IAU definition, have sufficient mass to assume **hydrostatic equilibrium** (a nearly round shape). Does it mean they would break apart or explode if gravity vanishes, unlike small bodies like comets or minor planets, whose integrity doesn't depend on gravity?
2019/12/21
[ "https://astronomy.stackexchange.com/questions/34432", "https://astronomy.stackexchange.com", "https://astronomy.stackexchange.com/users/25871/" ]
While, as far as we know, this is impossible, it is interesting to consider what would happen. Most likely the planet would break apart and possibly, depending on several factors, explode. Rotation speed of the planet, strength of the planet, and presence of liquids or gasses on the planet would all come into play. He...
A solid planet is kept on place and shape by electromagnetic forces, ie chemistry. Imagine a giant piece of rock. If you turn off gravity nothing change, the big rock would expand for a certain amount, and that is. Obviously this is oversimplified. If gravity was off it could have not formed depending on its history, o...
10,168,333
I use Dictionary in my code but my colleagues use Hashtable. MSDN says they work on Key Value pair & examples of Hashtable and dictionary are same on MSDN. Then how different are they from each other & which is the best of them or are they suited for difference occasions?
2012/04/16
[ "https://Stackoverflow.com/questions/10168333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1011959/" ]
`KeyValuePair` is the unit of data stored in a `Hashtable` (or `Dictionary`). They are not equivalent to each other. A key value pair contains a single key and a single value. A dictionary or hashtable contains a mapping of many keys to their associated values. `KeyValuePair` is useful when you want to store two rela...
One major difference is that `Hashtable` is thread-safe, while `Dictionary` is not. The [documentation](http://msdn.microsoft.com/en-us/library/system.collections.hashtable.aspx) says: > > `Hashtable` is thread safe for use by multiple reader threads and a single writing thread. It is thread safe for multi-thread us...
36,765,577
First off, I saw it and [this other post](https://stackoverflow.com/questions/14831246/access-scalatest-test-name-from-inside-test) sounds exactly like what I need except for one thing, I can't use fixture.TestDataFixture because I can't extend fixture.FreeSpecLike, and I am sure that there must be *some* way to get th...
2016/04/21
[ "https://Stackoverflow.com/questions/36765577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/162325/" ]
While you already came to basically this solution, here is a safer variation: ``` private val _currentTestName = new ThreadLocal[String] override def withFixture(test: NoArgTest) = { _currentTestName.set(test.name) val outcome = super.withFixture(test) _currentTestName.set(null) outcome } protected def curre...
And found an answer(well a collegue did), not sure I like it but works: on the trait that other tests depend on ``` class MySpec extends FlatSpecLike { //... other stuff var testName = "UndefinedTestName" override def withFixture (test: NoArgTest) :Outcome= { testName = test.name super.withFixt...
4,705,331
Part 1 ====== What is the easiest way to create a text filter which outputs only text surrounded by two predefined marks. I don't mind using any standard tool: sed, awk, python, ... For example, i would like only the text surrounded by "Mark Begin" and "Mark End" to appear. ``` input: Text 1 Mark Begin Text 2 Mark E...
2011/01/16
[ "https://Stackoverflow.com/questions/4705331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264250/" ]
``` $ awk '/Mark End/{f=0}/Mark Begin/{f=1;next}f' file Text 2 Text 4 $ awk '/Mark End/{f=0}/Mark Begin/{f=1;next}f{p=$0}END{print p}' file Text 4 ```
I found a good solution: ``` awk '/Mark End/, /Mark Begin/' file.lst ``` for second case, but it will require mark filtering after all.
38,599,504
So I'm pretty new to development world and I already know how to localize on XAML [just put a x:Uid, pretty easy]. But how can I do that on code? I already tried a few things, but with no success. Can someone help me? Here is the code I'm trying to assign: ``` private void OnShowLoadingChanged(Visibility newVisibil...
2016/07/26
[ "https://Stackoverflow.com/questions/38599504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6641732/" ]
You need a resource loader, but you can get one and reuse it like this: ``` private ResourceLoader MyResourceLoader { get { if (_resourceLoader == null) _resourceLoader = new ResourceLoader(); return _resourceLoader; } } private ResourceLoader _resourceLoader { get; set; } ```...
In the resource file, [tbImage.Text], [imgMain.Source] have been setted. You can use x:Uid in xaml. And in c# methods, to get resource according to the language, you can use this code snippet: ``` ResourceContext resourceContext = new ResourceContext(); resourceContext.Languages = new string[] { language }; Resource...
280,000
I have to calculate the determinant of this matrice. I want to use the rule of sarrus, but this does only work with a $3\times3$ matrice: $$ A= \begin{bmatrix} 1 & -2 & -6 & u \\ -3 & 1 & 2 & -5 \\ 4 & 0 & -4 & 3 \\ 6 & 0 & 1 & 8 \\ \end{bmatrix} $$ $|A|=35$ Any idea how to solve this?
2013/01/16
[ "https://math.stackexchange.com/questions/280000", "https://math.stackexchange.com", "https://math.stackexchange.com/users/36656/" ]
$$A=\begin{pmatrix}1 & -2 & -6 & u \\-3 & 1 & 2 & -5 \\4 & 0 & -4 & 3 \\6 & 0 & 1 & 8 \\\end{pmatrix}\stackrel{ 3R\_1+R\_2}{\stackrel{-4R\_1+R\_3}{\stackrel{-6R\_1+R\_4}\longrightarrow}}\begin{pmatrix}1 & -2 & \;\;-6 & \;\;\;u \\0 & -5 & -16 & \;\;\,3u-5 \\0 & \;\;\;8 & \;\;\;20 &-4u+ 3 \\0 & \;\,12 & \;\;\;37 & -6u+8 ...
Use [Leibniz formula](http://en.wikipedia.org/wiki/Leibniz_formula_for_determinants) or the [Laplace expansion](http://en.wikipedia.org/wiki/Laplace_expansion). For more an Laplace expansion see [youtube video](http://www.youtube.com/watch?v=louFpVlOhK8) .
4,000,713
If i have a loop such as ``` users.each do |u| #some code end ``` Where users is a hash of multiple users. What's the easiest conditional logic to see if you are on the last user in the users hash and only want to execute specific code for that last user so something like ``` users.each do |u| #code for everyo...
2010/10/22
[ "https://Stackoverflow.com/questions/4000713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/94150/" ]
Another solution is to rescue from StopIteration: ``` user_list = users.each begin while true do user = user_list.next user.do_something end rescue StopIteration user.do_something end ```
There are no last method for hash for some versions of ruby ``` h = { :a => :aa, :b => :bb } last_key = h.keys.last h.each do |k,v| puts "Put last key #{k} and last value #{v}" if last_key == k end ```
472,312
My challenge ------------ We have Exchange servers at various sites, but also aboard ships. The ships are connected to our network through satellite links when at sea, but switch to WiFi bridges when in port. Due the high latency (500+ ms) and not-uncommon drop-outs (e.g. when the ships are turning), attempting to se...
2013/01/25
[ "https://serverfault.com/questions/472312", "https://serverfault.com", "https://serverfault.com/users/105219/" ]
To solve the problem the way you have requested, you could write your own Transport Agent using the [Microsoft Exchange Transport Agent SDK](http://www.microsoft.com/en-us/download/details.aspx?id=13156). Transport Agents are event based so Exchange will call a function in your library when a message is received. Your ...
**Message Moderation** One probably non-ideal solution is to use a transport rule to forward messages over a certain size to either the sender's manager or a designated mailbox (on the ship's Exchange server) for moderation. This way if they are at sea, large messages can be essentially queued up in another mailbox. W...
17,995,962
I created a custom component which extended from `JTextField`. I want to prevent calling `getText()` method from my component. Is there a solution for this problem?
2013/08/01
[ "https://Stackoverflow.com/questions/17995962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/971067/" ]
Override it and throw [UnsupportedOperationexception](http://docs.oracle.com/javase/7/docs/api/java/lang/UnsupportedOperationException.html) in method body or just leave it empty. Throwing exception will guarantee you that this method is never used since you'll be getting exceptions otherwise and fix.
Override it with a dummy implementation and add documentation mentioning `Not to be used!` or throw an exception from inside.
23,806
Why video call has no (even if there is, it is lower than human perception can discern) latency, but no matter what options of ffmpeg I tried to transmit video to a remote server, the lowest I can get is ~0.2s latency (estimated, not sure how to profile)? ***What is the technology behind video call that allows it to ...
2018/04/13
[ "https://avp.stackexchange.com/questions/23806", "https://avp.stackexchange.com", "https://avp.stackexchange.com/users/21908/" ]
Try using UDP. It should be faster than TCP but with possibility of losing paackets.
Sources of any delays: 1. TCP protocol. Long handshake, possible error with time loss in future 2. Long encoder initialization (video call already prepared it) 3. Long decoder initialization (video call already prepared it), buffering for analyze data 4. Unoptimized protocol / format for low-time communication, like M...
42,468
What is the difference between Strict Avalanche Criterion(SAC) and Avalanche criterion?
2016/12/21
[ "https://crypto.stackexchange.com/questions/42468", "https://crypto.stackexchange.com", "https://crypto.stackexchange.com/users/42265/" ]
The definition of avalanche effect is given in the paper of Webster, A. F. ["On the design of S-boxes". Advances in Cryptology - Crypto '85](https://link.springer.com/chapter/10.1007%2F3-540-39799-X_41#page-1) as : > > For a given transformation to exhibit the avalanche effect, **an average of one half of the output ...
Avalanche criterion, or Avalanche effect is informal. Small changes in inputs should always lead to large changes in outputs. Consider a vector Boolean function $$f:F\_2^n \rightarrow F\_2^m$$ with $n$ bit input and $m$ bit output. Strict Avalanche Criterion (SAC) says that if any input bit is flipped then exactly ha...
18,464,346
I am getting a a request like this and the url looks like this : <http://domain.com/page.php?text=>{Arabic Word} Now am trying to get the text using $\_GET['text'] but i keep getting it like "????????" , whats the problem ``` <?php header('Content-type: text/html; charset=UTF-8'); include('EnTransliteration.c...
2013/08/27
[ "https://Stackoverflow.com/questions/18464346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2017288/" ]
Your HTML form needs to explicitly declare that the data must be sent as UTF-8. Otherwise, it will use the user's locale, which may not mean windows-1256, and certainly doesn't mean UTF-8. e.g. ``` <form action="" method="get" accept-charset="UTF-8"> ```
1-open start 2-open notepad 3-write your code 4-when you saving file make Encoding: utf-8 5-file name name.html name.php
4,794
I am curious to the information and level of detail that people are storing on Kanban cards? Or beter yet some templates of how they are put together. For reference here is a description of a Kanban Card <http://en.wikipedia.org/wiki/Kanban_cards>
2010/09/04
[ "https://pm.stackexchange.com/questions/4794", "https://pm.stackexchange.com", "https://pm.stackexchange.com/users/3284/" ]
Why not apply Kaizen to your Kanban cards? Start with the smallest thing that gives you value - probably a title, so you can identify what the card represents. Get feedback from the team about the next most important thing that's missing. Add that. Repeat. Stop when adding information would no longer be an improvemen...
Its all up to how big is your Dev Team and how they are comfortable with, kid of information. From my point of view> Agile < Kan-ban card don't have any set value to fill with the information. Default values are already discussed here. SO GO agile and using Kan-ban system at your ease level.
2,846,872
I'm currently using the following code for thread-safe access of a variable. ``` int gnVariable; void getVariableValue(int *pnValue) { acquireLock(); //Acquires the protection mechanism *pnValue = gnVariable; releaseLock(); //Releasing the protection mechanism } ``` I would like to change my API signatu...
2010/05/17
[ "https://Stackoverflow.com/questions/2846872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/293407/" ]
Since you gave C++ as an option, you can wrap the mutex lock/unlock. You can then return the value directly: ``` class lock_wrapper { public: lock_wrapper() { acquireLock(); } ~lock_wrapper() { releaseLock(); } }; int getVariableValue() { lock_wrapper lw; return gnVaria...
You return a copy of the local variable. Something like: ``` int getVariableValue(void) { int local= 0; acquireLock(); local = gnVariable; releaseLock(); return local; } ``` As a side note, it is better to [RAII](http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization) principle for locking ins...
20,970,980
I earlier learned that abstract class can extend concrete class. Though I don't see the reason for it from JAVA designers, but it is ok. I also learned that abstract class that extends concrete class can make overriden methods abstract. Why? Can you provide with use case where it is useful? I am trying to learn design ...
2014/01/07
[ "https://Stackoverflow.com/questions/20970980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2764414/" ]
This becomes useful if I have a set of classes that I want a default implementation of `test()` for (so they can extend from `Foo`), and a subset of those classes that I want to force to provide their own implementation (in which case making it abstract in the subclass would enforce this.) Of course, the alternative w...
If you make the `test` method abstract it forces anyone deriving from the `Bar` class provide an implementation of the method. If you remove the abstract method from the `Bar` class then anyone deriving from `Bar` would not *have* to implement the `test` method as `Foo` already provides an (empty) implementation.
170,318
To my understanding, mixed states is composed of various states with their corresponding probabilities, but what is the actual difference between [maximally mixed states](http://www.google.com/search?as_epq=maximally+mixed+state) and [maximally entangled states](http://www.google.com/search?as_epq=maximally+entangled+s...
2015/03/14
[ "https://physics.stackexchange.com/questions/170318", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/74564/" ]
Suppose we have two Hilbert spaces $\mathcal{H}\_A$ and $\mathcal{H}\_B$. A quantum state on $\mathcal{H}\_A$ is a normalized, positive trace-class operator $\rho\in\mathcal{S}\_1(\mathcal{H}\_A)$. If $\mathcal{H}\_A$ is finite dimensinal (i.e. $\mathbb{C}^n$), then a quantum state is just a positive semi-definite matr...
When the state space for a system can be expressed as a tensor product of the state spaces of individual components of the system, an entangled state is one that can't be expressed as a tensor product of states of those individual components. Thus an entangled state is a particular type of (pure, i.e. non-mixed) state....
3,457,697
friend's I have a task to place the horizontal scroll or swipe menu tabs in my application i did it where the appears top of the header,but my problem is to place the scroll menu has below the header i have RelativeLayout where it contains two elements one after another, ----------------------------------------------...
2010/08/11
[ "https://Stackoverflow.com/questions/3457697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/407506/" ]
Solved this by using CURL. Here's the code. It will work with remote files e.g. **<http://yourdomain.com/file.ext>** ``` $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ''.$file_path_str.''); curl_setopt($ch, CURLOPT_HTTPGET, 1); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_USERAGENT, sprintf("Mo...
I recently solved this problem. On my windows machine it is acceptable to have spaces in your folder names. However PHP wasnt able to read this path. I changed my folder name From: ``` C:\Users\JasonPC\Desktop\Jasons Work\Project ``` To: ``` C:\Users\JasonPC\Desktop\JasonsWork\Project ``` Then PHP was able ...
29,115,837
I'm currently making a program which asks the user for the input for two integers and compare if they are correct. I need help coding this program. (sorry I am new to c++). For example, this is my desired output. Enter your positive integer: 123 Enter your positive integer: 124 number 1: 123 number 2: 124 number ...
2015/03/18
[ "https://Stackoverflow.com/questions/29115837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4330757/" ]
``` void twoInt() { int first, second; int fDigit; int sDigit; cout << "\n\nEnter your positive integer : "; cin >> first; cout << "\nEnter your positive integer : "; cin >> second; cout << "\n\nNumber 1: " << setw(10) << first; cout << "\nNumber 2: " << setw(10) << second; w...
Convert both numbers to strings with std::to\_string() Compare with the algorithm that you prefer: std::equal() or std::mismatch() Why don't you compare them directly as intergers?
5,851,569
**HTML** ``` <form action="inc/q/prof.php?pID=<?php echo $the_pID; ?>" method="post"> <select id="courseInfoDD" name="courseInfoDD" tabindex="1"><?php while($row3 = $sth3->fetch(PDO::FETCH_ASSOC)) { echo "<option>".$row3['prefix']." ".$row3['code']."</option>"; }ec...
2011/05/01
[ "https://Stackoverflow.com/questions/5851569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/700070/" ]
Like @user551841 said, you will want to limit your possibility of sql injection with his code. You are seeing that error because you're code told it to echo that error if nothing was entered, which is the case upon first page load. You shouldn't need that until submit is done. Edit: Sorry, I was assuming you are direc...
To answer to your question `what is wrong here` **you've got a huge gaping SQL-injection hole!!** Change this code ``` //Get data in local variable $course_info=$_POST['courseInfoDD']; $the_comment=$_POST['addComment']; $the_pID=$_POST['pID']; ``` To this ``` //Get data in local variable $course_info = mysql_re...
34,597
What is the difference between French and British cuts of beef? I am told they just butcher the animals dfferently. Certainly the cuts don't seem the same. For example is faux fillet really exactly the same as British sirloin and is entrecôte really the same as rib steak? Here is a picture of British beef cuts. ![e...
2013/06/09
[ "https://cooking.stackexchange.com/questions/34597", "https://cooking.stackexchange.com", "https://cooking.stackexchange.com/users/18672/" ]
The simplest way to see the difference is to compare the cut diagrams: **British** ![enter image description here](https://i.stack.imgur.com/1c2DT.png) **French** ![enter image description here](https://i.stack.imgur.com/cQioc.png) Images courtesy of [Wikipedia - Cut of Beef](https://en.wikipedia.org/wiki/Cut_of_b...
Two things 1.The French diagram seemsfar more detailed than the English one, which lacks several cuts 2. Meat cuts are regional in both countries, but I think more in the UK The obvious examples have already been mentioned, fillet steak is definitely an English cut,the eye of the loin. French paleron = feather or blad...
37,651,380
I am trying to toggle the background colour of a div element but my code doesn't work. I wrote the following code: ``` $(document).ready(function(){ var $on_off = true; $('div.hot').on('click', function($on_off){ if($on_off){ $(this).css('background-color', 'red'); } else{ $(this).css('back...
2016/06/06
[ "https://Stackoverflow.com/questions/37651380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3887531/" ]
> > Remove argument from `on` handler as first argument is `event-object` which is always evaluated as `true`(`Boolean({})===true`) > > > ```js $(document).ready(function() { var $on_off = true; $('div.hot').on('click', function() { if ($on_off) { $(this).css('background-color', 'red'); } else { ...
Event handlers receives an [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event) Object when they are invoked but you are expecting another variable (`$on_off`) which doesn't exist inside event handler. So `$on_off` variable that you have passed to event handler is in fact an object which will be automaticall...
38,785,924
we are using Postgresql 9.4 and i noticed a strange behavior when using date\_trunc. The time zone in result is shifted by 1hr: ``` select date_trunc('year','2016-08-05 04:01:58.372486-05'::timestamp with time zone); date_trunc ------------------------ 2016-01-01 00:00:00-06 ``` There is no such behavior when...
2016/08/05
[ "https://Stackoverflow.com/questions/38785924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5168941/" ]
The `date_trunc(text, timestamptz)` variant seems a bit under-documented, so here are my findings: 1) below the `day` precision (first parameter) the time zone **offset** of the result is always the same as the second parameters' offset. 2) at or above `day` precision, the time zone **offset** is recalculated, accord...
It is expected to have two variants of `date_trunc`: one for `timestamp` and one for `timestamptz`, because [the doc](https://www.postgresql.org/docs/current/static/functions-datetime.html) says: > > All the functions and operators described below that take time or > timestamp inputs actually come in two variants: o...
32,891,518
**EDIT: This question is deprecated.** Please see [How to set a variable from an $http call then use it in the rest of the application WITHOUT making the whole application asynchronous](https://stackoverflow.com/questions/33129638/how-to-set-a-variable-from-an-http-call-then-use-it-in-the-rest-of-the-applicat) instead....
2015/10/01
[ "https://Stackoverflow.com/questions/32891518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1045881/" ]
**Build a constant** Build the confguration into Angular `constant` with build system. There are [grunt-ng-constant](https://github.com/werk85/grunt-ng-constant) and [gulp-ng-constant](https://github.com/guzart/gulp-ng-constant). **Resolve the dependency** Use ng-route or ui-router `resolve` to resolve config depend...
What I've generally done is to generate the code for the constant on the server. As opposed to having the constant populated by some call back to the server. ``` using Newtonsoft.Json.Linq; public class JavascriptConstantsHelper { public static string GetConstantsJavascriptFile() { var constantsCollec...
12,830,197
I want to declare an array of arrays or multidimensional array without knowing the size. I want to do something similar to what I did in this cases with simple arrays: ``` int *array; cin >> size; array = new int[size]; ``` Maybe I can loop to initialize a pointer of pointers like this: ``` int **array; cin >> row...
2012/10/10
[ "https://Stackoverflow.com/questions/12830197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1192999/" ]
You're pretty much going to have to go with the loop version. You can make one slight improvement, which is to allocate one big block and then build your own `int*` index into it: ``` int **array; int *storage; cin >> rows >> col; array = new *int[rows]; storage = new int[rows*col]; for (int i = 0; i < rows; ++i) ...
You could use a single std::vector to contain the entire two dimensional array and wrap it in a class to hide the details. Here's an example, it uses a `data( row, col )` member function that returns a reference to the element at `row` and `col`. I included an example 2 dimensional matrix of `int` where each entry in t...
460,293
Having the hours and minutes, is there any easier or better way to set it into a Calendar object than: ``` calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), hour, minute); ```
2009/01/20
[ "https://Stackoverflow.com/questions/460293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6068/" ]
In 2018 no one should use the `Calendar` class anymore. It it long outmoded, and `java.time` the modern Java date and time API is so much nicer to work with. Instead use, depending on you exact requirements, a `ZonedDateTime` or perhaps an `OffsetDateTime` or `LocalDateTime`. In either case, set the time of day this wa...
In addition to [the great accepted answer by Xn0vv3r](https://stackoverflow.com/a/460312/2359227), don't forget to set `calendar.set(Calendar.SECOND, 0);`
53,654,728
The **following code** displays the **following window**: ``` import numpy as np import matplotlib.pylab as pl import matplotlib.gridspec as gridspec from matplotlib import pyplot as plt def plot_stuff(x,y,z): gs = gridspec.GridSpec(3, 1) plt.style.use('dark_background') pl.figure("1D Analysis") ...
2018/12/06
[ "https://Stackoverflow.com/questions/53654728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5052566/" ]
Here is another solution, using an explicit `close` statement to close then recreate the figure at each iteration ``` from matplotlib import gridspec import matplotlib.pyplot as plt import numpy as np def plot_stuff(x, y, z): gs = gridspec.GridSpec(3, 1) plt.style.use('dark_background') fig = plt.figure("...
I have tested the below solution and which is working perfectly. I have used only pylab module. ``` import numpy as np import matplotlib.pylab as pl import matplotlib.gridspec as gridspec def plot_stuff(x,y,z): pl.ion() # interactive mode on gs = gridspec.GridSpec(3, 1) pl.style.use('dark_background') ...
44,322,178
I am using Android Database Component Room I've configured everything, but when I compile, Android Studio gives me this warning: > > Schema export directory is not provided to the annotation processor so > we cannot export the schema. You can either provide > `room.schemaLocation` annotation processor argument OR ...
2017/06/02
[ "https://Stackoverflow.com/questions/44322178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3101777/" ]
I use `.kts` Gradle files (Kotlin Gradle DSL) and the `kotlin-kapt` plugin but I still get a script compilation error when I use Ivanov Maksim's answer. ``` Unresolved reference: kapt ``` For me this was the only thing which worked: ``` android { defaultConfig { javaCompileOptions { annotati...
Probably you didn't add your room class to child `RoomDatabase` child class in `@Database(entities = {your_classes})`
13,133,734
I have run this below query and it is giving error: ``` UPDATE t_o SET t_o.mlm_order_id = mt.order_id FROM temp_orders t_o, mlm_transaction mt WHERE mt.v2_order_id = t_o.order_id ``` Error is: ``` #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the ...
2012/10/30
[ "https://Stackoverflow.com/questions/13133734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1784710/" ]
One more version - ``` UPDATE temp_orders t_o, mlm_transaction mt SET t_o.mlm_order_id = mt.order_id WHERE mt.v2_order_id = t_o.order_id ```
Updates don't use the FROM clause. Use something like this: ``` UPDATE table_name SET column1=value1, column2=value2,... WHERE some_column=some_value ```
61,338,917
I have a dataframe that has x/y values every 5 seconds, with a depth value every second (time column). There is no depth where there is an x/y value. ``` x <- c("1430934", NA, NA, NA, NA, "1430939") y <- c("4943206", NA, NA, NA, NA, "4943210") time <- c(1:6) depth <- c(NA, 10, 19, 84, 65, NA) data <- data.frame(x, y, ...
2020/04/21
[ "https://Stackoverflow.com/questions/61338917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11372268/" ]
You can use `ave` and `cumsum` with `!is.na` to get the groups for ave like: ``` data$newvar <- ave(data$depth, cumsum(!is.na(data$x)), FUN= function(x) if(all(is.na(x))) NA else { c(max(x, na.rm=TRUE), rep(NA, length(x)-1))}) data # x y time depth newvar #1 1430934 4943206 1 NA 84 #2 <NA>...
Using `dplyr`, we can create groups of every 5 rows and update the first row in group as `max` value in the group ignoring `NA` values. ``` library(dplyr) df %>% group_by(grp = ceiling(time/5)) %>% mutate(depth = ifelse(row_number() == 1, max(depth, na.rm = TRUE), NA)) ``` --- In base R, we can use `tapply` :...
1,061,911
How well does Django handle the case of different timezones for each user? Ideally I would like to run the server in the UTC timezone (eg, in settings.py set TIME\_ZONE="UTC") so all datetimes were stored in the database as UTC. Stuff like [this](https://stackoverflow.com/questions/689831/changing-timezone-on-an-existi...
2009/06/30
[ "https://Stackoverflow.com/questions/1061911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/84262/" ]
**Update, January 2013**: Django 1.4 now has [time zone](https://docs.djangoproject.com/en/3.2/topics/i18n/timezones/) support!! --- Old answer for historical reasons: I'm going to be working on this problem myself for my application. My first approach to this problem would be to go with django core developer Malcom...
Django doesn't handle it at all, largely because Python doesn't either. Python (Guido?) has so far decided not to support timezones since although a reality of the world are "[more political than rational, and there is no standard suitable for every application](http://docs.python.org/library/datetime.html#module-datet...
41,837,927
I am trying to implement realm migration using version v0.81.0 When I install and run the new version of the app with an additional field in one of my data access objects, instead of calling the realm migration callback it just throws an exception (RealmMigrationNeededException) telling me I have to migrate because I ...
2017/01/24
[ "https://Stackoverflow.com/questions/41837927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1898970/" ]
Your code was throwing the same format because both **DateFormat** were constructed with the same pattern and that is not correct.. ``` SimpleDateFormat sdfuk = new SimpleDateFormat("dd/MM", Locale.UK); SimpleDateFormat sdfus = new SimpleDateFormat("dd/MM", Locale.US); ``` You will need the local if you have a Strin...
tl;dr ===== ``` MonthDay.from( LocalDate.now( ZoneId.of( "America/Montreal" ) ) ).format( DateTimeFormatter.ofPattern( "MM/dd" ) ) ``` > > 01/24 > > > `MonthDay` ========== There's a class for that: [`MonthDay`](https://docs.oracle.com/javase/8/docs/api/java/time/MonthDay.html). The `MonthDay` represent...
390,449
Hmmm. Is there a primer anywhere on memory usage in Java? I would have thought Sun or IBM would have had a good article on the subject but I can't find anything that looks really solid. I'm interested in knowing two things: 1. at runtime, figuring out how much memory the classes in my package are using at a given time...
2008/12/24
[ "https://Stackoverflow.com/questions/390449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44330/" ]
If you are using a pre 1.5 VM - You can get the approx size of objects by using serialization. Be warned though.. this can require double the amount of memory for that object.
I believe the profiler included in Netbeans can moniter memory usage also, you can try that
306,768
I'm looking for a **UPNP/DLNA Client for Windows**. The server is **MediaTomb** on a Ubuntu box. The clients are **Windows** (any, XP and up). I'm looking for a *simplistic* music player program but failed to identify any. I'm hoping for something in the *style* of Winamp or Windows Media Player. I've looked, bu...
2011/07/05
[ "https://superuser.com/questions/306768", "https://superuser.com", "https://superuser.com/users/85665/" ]
[foobar2000](http://www.foobar2000.org/) has a supported DNLA [plugin](http://www.foobar2000.org/components/view/foo_upnp). Its winamp-styled, configurable and works pretty well in general
Have you tried VLC? <http://www.videolan.org/vlc/> Upgrade it to VLC media player 2.0.1 Twoflower. UPnP was added back into the Windows build as of V2. If you still like your V1.1 for some reason you can always parallel install V2 in a different folder. Open the Playlist menu. On the left side, click on Local Network ...
2,861,139
I have a class that implements an interface. In another area of the code I check if that class instance contains that interface, but it doesn't work. The check to see if the class contains the interface always fails (false) when it should be true. Below is a simple representation of what I am trying to accomplish. ...
2010/05/18
[ "https://Stackoverflow.com/questions/2861139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/173432/" ]
Did you make sure you tested against the correct interface? By that I mean, is your "is" test using the correct version of IModel? IModel doesn't strike me as a unique type name, so you may have imported an incorrect namespace. Try explicitly qualifying your check. I.e. ``` if (model is MyNamespace.IModel) ... ...
One *very* common error here is to declare the interface in two different assemblies, for example by including the same `.cs` file in two different dlls. Since types are defined by their assembly, this gives two *conflicting* interfaces, which *happen* to have the same name. The same scenario is also common (with *dif...
4,530,069
I am trying to subtract one date value from the value of `datetime.datetime.today()` to calculate how long ago something was. But it complains: ```none TypeError: can't subtract offset-naive and offset-aware datetimes ``` The return value from `datetime.datetime.today()` doesn't seem to be "timezone aware", while my...
2010/12/25
[ "https://Stackoverflow.com/questions/4530069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/323874/" ]
Here is a solution using a readable timezone and that works with today(): ``` from pytz import timezone datetime.now(timezone('Europe/Berlin')) datetime.now(timezone('Europe/Berlin')).today() ``` You can list all timezones as follows: ``` import pytz pytz.all_timezones pytz.common_timezones # or ```
If you get current time and date in python then import date and time,pytz package in python after you will get current date and time like as.. ``` from datetime import datetime import pytz import time str(datetime.strftime(datetime.now(pytz.utc),"%Y-%m-%d %H:%M:%S%t")) ```
4,970,489
Using the development server, it works with debug=True or False. In production, everything works if debug=True, but if debug=False, I get a 500 error and the apache logs end with an import error: "ImportError: cannot import name Project". Nothing in the import does anything conditional on debug - the only code that d...
2011/02/11
[ "https://Stackoverflow.com/questions/4970489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/508724/" ]
Just to say, I ran into a similar error today and it's because Django 1.5 requires the `ALLOWED_HOSTS` parameter in the settings. You simply need to place this row to make it work ;) ``` ... ALLOWED_HOSTS = '*' ... ``` However, **be aware** that you need to set this parameter properly according to your actual host(s...
This can also happen if you do not have both a 500.html and 404.html template present. Just the 500 isn't good enough, even for URIs that won't produce a 404!
99,429
A contractor looked at our house and told me that you can't fix a house (with old wiring) that has some outlets that are not grounded. He said that you can go on YouTube and search the internet and it will tell you that you can. He says that the only way to properly fix and ground everything is to do a whole house rewi...
2016/09/17
[ "https://diy.stackexchange.com/questions/99429", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/672/" ]
It's perfectly legal to run JUST a ground wire to retrofit old work. You do not need to also pull all the conductors. This is legal as of NEC 2014, so if your region hasn't adopted it yet, just wait. People who say "might as well pull all new conductors" do not fully understand what the new rule permits. Retrofit gro...
A ground for an outlet,is not ground for the service.Ground for a 3 prong outlet must return to the ground bar or neutral bar in the sub panel.A ground rod has nothing to do with it .That is for lightning protection to the service, and there should only be one ground rod by the meter in a normal residential installatio...
309,633
One can define the fundamental concepts of probability theory (such as a probability measure, random variable, etc) in a purely axiomatic manner. However, when we teach probability, we start off with the notion of an "experiment", a concept it seems to me which is something akin to pornography: difficult to define, but...
2013/02/20
[ "https://math.stackexchange.com/questions/309633", "https://math.stackexchange.com", "https://math.stackexchange.com/users/62659/" ]
I like the way it is defined in [Mathematical Statistics](http://books.google.com/books?id=9QHcJ8WQQ5UC) By Wiebe R. Pestman: "A probability experiment is an experiment which, when repeated under the same conditions, does not necessarily give the same results" [This](http://www.futureaccountant.com/probability/study-...
While reading Grimmett & Welsh book, I found that an experiment is > > Any procedure whose consequences are not predetermined. > > > This is quite a restrictive definition in my opinion, because it excludes "deterministic" experiments where we can determine the final result 100% precision (because there is actual...
40,150,192
I have to update multiple rows in a table in a MySQL db, where the condition to find the rows to be updated are in the same table. For instance, I have a table called "cdrs". There is a column in the table called "tf", that is the one I have to update. The column that has the condition to update or not the row is "cal...
2016/10/20
[ "https://Stackoverflow.com/questions/40150192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7045849/" ]
You can do simple request : ``` UPDATE cdrs SET tf = 1 WHERE calltype = 11; ```
It is as simple as `UPDATE cdrs SET tf = 1 WHERE calltype = 11;`
5,955,421
Say there are 5 records from the query, how do I get the top 1 records? This is my current code. ``` public Application GetByUserIdAndVersion(int userId, string version) { VettingDataContext dc = new VettingDataContext(_connString); return (from a in dc.Applications where a.UserId == userId && a.ch...
2011/05/10
[ "https://Stackoverflow.com/questions/5955421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/695101/" ]
Just use `FirstOrDefault()` instead: ``` return (from a in dc.Applications where a.UserId == userId && a.chr_Version == version select a).FirstOrDefault<Application>(); ``` `SingleOrDefault()` will throw an exception if there is more than one record, `FirstOrDefault()` will just take the first one. ...
For the first record you can try: ``` return (from a in dc.Applications where a.UserId == userId && a.chr_Version == version select a).FirstOrDefault(); ``` For the first N use: ``` return (from a in dc.Applications where a.UserId == userId && a.chr_Version == version select a).Take(N); ```
37,299
When Joffrey becomes king, he seems to give equal weight to both the Lannister and Baratheon sigils. Why is this? Robb Stark doesn't consider himself a Tully. It's almost as if Joffrey himself knows he's not a Baratheon.
2013/06/24
[ "https://scifi.stackexchange.com/questions/37299", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/15454/" ]
Three people were flying the stag. Stannis changed his as well. Not sure how Renly the guy with the weakest claim wound up with the old school stag though. The lion was probably added as a PR move to remind people where the most powerful house stood.
The reason why is because Joffrey is of House Baratheon of King's Landing. Stannis flies the banner of House Baratheon of Dragonstone because Robert installed him there and made him Lord of Dragonstone, thus creating a cadet branch of House Baratheon. His banner and sigil is a stag surrounded by a heart of fire, appro...
33,563,736
I have two database tables: ``` subscribers: (ID, name, email_address etc) ``` And subscriptions: (subsc\_id, user\_id, subsc\_start, subsc\_end) My question is how can I get a result of all expired members? I wrote an SQL query: ``` SELECT * FROM subscriptions LEFT JOIN subscribers ON subscriptions.user_id = su...
2015/11/06
[ "https://Stackoverflow.com/questions/33563736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2161265/" ]
So you want to find users whose expiry date is in the past AND their start date is *before* their expiry date - so try this: ``` SELECT * FROM subscriptions LEFT JOIN subscribers ON subscriptions.user_id = subscribers.ID WHERE DATE(subscriptions.subsc_end) < DATE(NOW()) AND DATE(subscriptions.subsc_start) < DATE(su...
Probably easiest to do a LEFT OUTER JOIN of non expired subscriptions to subscribers, and check in the WHERE clause that no non expired subscription is found. Saves any aggregate functions. ``` SELECT * FROM subscribers LEFT JOIN subscriptions ON subscriptions.user_id = subscribers.ID AND DATE(subscription.subsc_end...
10,511,897
I have an click event that I want to assign to more than class. The reason for this is that I'm using this event on different places in my application, and the buttons you click have different styling in the different places. What I want is something like $('.tag' '.tag2'), which of course don't work. ``` $('.tag...
2012/05/09
[ "https://Stackoverflow.com/questions/10511897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/937624/" ]
Approach #1 ----------- ``` function doSomething(){ if ($(this).hasClass('clickedTag')){ // code here } else { // and here } } $('.tag1').click(doSomething); $('.tag2').click(doSomething); // or, simplifying further $(".tag1, .tag2").click(doSomething); ``` Approach #2 ----------- ...
Have you tried this: ``` function doSomething() { if ($(this).hasClass('clickedTag')){ // code here } else { // and here } } $('.tag1, .tag2').click(doSomething); ```
9,077,055
``` InputStream is = new URL(someUrl).openStream(); long length = is.skip(Long.MAX_VALUE); ``` When I call `is.skip(Long.MAX_VALUE)`, does it download the file before returning the value, or does it actually skip the given number of byte (assume the size is less than `MAX_VALUE`)?
2012/01/31
[ "https://Stackoverflow.com/questions/9077055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1177604/" ]
From the [docs](http://docs.oracle.com/javase/6/docs/api/java/io/FileInputStream.html#skip%28long%29): > > Skips over and discards n bytes of data from the input stream. > > > The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. If n is negative, an IOExcepti...
Looking at the implementation of the [JDK6 HTTP client](http://hg.openjdk.java.net/jdk6/jdk6/jdk/file/ef3efe6d9488/src/share/classes/sun/net/www/http/), you see no special handling of the `skip` method. That means that (by default, assuming you don't do something elaborate like configuring a range header on the request...
11,875,590
Can anybody help me in solving this error. I am getting Invalid response from paypal sandbox. My sandbox account is verified, IPN is on at my account, I have also set notify url in my sandbox account. Here is my button code ``` <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> <input type=...
2012/08/09
[ "https://Stackoverflow.com/questions/11875590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1076123/" ]
Inside your IPN, you are opening a socket to www.paypal.com instead of www.sandbox.paypal.com
<https://www.paypal-community.com/t5/Selling-on-your-website/IPN-response-problem/m-p/521312#M2445> I recently experienced this problem, going from a code base that hadn't changed and was working correctly on the Paypal sandbox. If you can provide more information was to what is occuring, i can point you more in the ...
13,363,398
I was wondering whether exists any dashlet which allows you to explore a site's document library. As far as I know doesn't exist such dashlet out of the box, there only exists the "Site Content" dashlet but it is slightly limited. I have been searching around and "googling" and I found these useful resources that coul...
2012/11/13
[ "https://Stackoverflow.com/questions/13363398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1514315/" ]
You are going to see a couple of site visualization and navigation dashlets on Alfresco Visualization Tools available on <https://github.com/bhagyas/alfresco-visualization-tools>. The project is still at it's initial phase, but you will find interesting snippets of code used to retrieve the document library content tre...
There is a document-liberary-display dashlet available in the alfresco add-on list which can be used to show all the documents from document-library on site-dashlet. <http://addons.alfresco.com/addons/document-library-display-dashlet>
6,161
I am unable to autotune on 21Mhz as the SWR is more than 1:3 which is out side the range of the radio. I would like use it only for digital TX with a max. power of 50 watts. Any solution/s?
2016/05/07
[ "https://ham.stackexchange.com/questions/6161", "https://ham.stackexchange.com", "https://ham.stackexchange.com/users/6641/" ]
The traditional "No balun" G5RV design is famous (infamous, more like) for these sorts of quirks, primarily because the claim that it behaves in various different (and universally desirable) ways at different frequencies is a crock. In reality, it has two modes, a balanced dipole when used on a frequency where SWR (and...
The usual solution to autotuner problems is to change the length of the coax. Try adding a half wavelength of coax, approx 5 m, to the antenna feed, and see if that helps. You could also try 2.5 or 7.5 m, anything about that long will have some impact. Although the VSWR won't change much if you add a bit of cable, th...
35,632,928
I need my buttons to have several pieces of text on them in a specific layout, so I'm trying to put a grid on my button to organize the info. My problem is that while I can get the unmodified button to appear, the grid never appears in or on top of it. Here's the .xaml code: ``` <!-- ...other code up above... --> <...
2016/02/25
[ "https://Stackoverflow.com/questions/35632928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4224414/" ]
You must unhide the sheet before copying it (at least to a new workbook as lturner notes) - you can then re-hide it ``` Dim shtTemplate as Worksheet, sheetWasHidden As Boolean Set shtTemplate = ThisWorkbook.Sheets(Machine) 'handle the case where the sheet to be copied is Hidden If shtTemplate.Visible = xlSheetHidden ...
When you have the worksheet object and use the `Copy` method, Excel seems to be making assumptions (or not) about where you want to put the new sheet. I pretty much always use the `After` option to define where the new sheet should go. ``` Option Explicit Sub test() Dim wsCopy As Worksheet Set wsCopy = Active...
37,219,424
I can only seem to find answers about last/first element in a list or that you can get a specific item etc. Lets say I have a list of 100 elements, and I want to return the last 40 elements. How do I do that? I tried doing this but it gave me one element.. ``` Post last40posts = posts.get(posts.size() -40); ```
2016/05/13
[ "https://Stackoverflow.com/questions/37219424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6208277/" ]
Do use the method sub list ``` List<Post> myLastPosts = posts.subList(posts.size()-40, posts.size()); ```
(To complete Ankit Malpani answer) If `40` is provided by our lovely users, then you will have to restrict it to the list size: ``` posts.subList(posts.size()-Math.min(posts.size(),40), posts.size()) ``` Another way to show it: ``` @Test public void should_extract_last_n_entries() { List<String> myList = Arrays...
49,918,511
I have a dataframe like this, ``` col1 1 2 3 2 2 3 1 1 2 3 1 1 3 3 1 1 3 ``` When I compute `print df['col1'].value_counts(bins=2)` It gives me, ``` (0.997, 2.0] 11 (2.0, 3.0] 6 Name: col1, dtype: int64 ``` Result is good. But in index it gives mixed of `(`&`]`. Why it behaves like this. Because I wan...
2018/04/19
[ "https://Stackoverflow.com/questions/49918511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4684861/" ]
Now you can find the documentation here: <https://angular.io/api/forms/FormControlName#use-with-ngmodel-is-deprecated> So you have 3 options: 1. use Reactive forms 2. use Template driven forms 3. silence warning (not recommended) ``` <!-- language: lang-ts --> imports: [ ReactiveFormsModule.withConfig({w...
add ``` [ngModelOptions]="{standalone: true}" ``` You can read more from angular website <https://angular.io/api/forms/NgModel>
29,956,610
I am using vagrant to set up my enviroment, when I use sudo npm update, I get this error. ``` npm ERR! Linux 3.13.0-49-generic npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "update" npm ERR! node v0.12.2 npm ERR! npm v2.7.4 npm ERR! path ../mime/cli.js npm ERR! code EPROTO npm ERR! errno -71 npm ERR! EPROTO, symlink ...
2015/04/29
[ "https://Stackoverflow.com/questions/29956610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4434843/" ]
There are two problems with using sudo with `npm` 1. 99 problems like this. 2. It's a [security issue](https://news.ycombinator.com/item?id=8947493). The best solution is to use a node version manager. I use [nvm](https://github.com/creationix/nvm). Another called [n](https://www.npmjs.com/package/n) exists as well. ...
You are using an older version of NPM, the current latest version is 2.8.4 you are currently on 2.7.4. The release notes for 2.7.5 mention an issue with symbolic links that was fixed. Updating NPM should fix this, run: ``` sudo npm install npm -g ```
50,086,247
So, as one of my first projects, I tried to do a little lottery draw site, but I can't display the `winPercentage` variable from the `script.js` on the site. It just stays empty. Why? The `script.js` part: ``` var winPercentage = winCount / gameCount * 100; document.getElementById("winPercentageID").innerHTML...
2018/04/29
[ "https://Stackoverflow.com/questions/50086247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Your id `winPercentageID` does not match `winPercentageId` (uppercase "ID" vs "Id")
In case if you want to do it with jQuery. ``` var winPercentage = winCount / gameCount * 100; $("#winPercentageID").html(winPercentage) ```