INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Are card reader/writers supposed to poll all the time?
I am looking at _top_ and noticed that after I managed to get my USB2.0-CRW (Realtek chip and it's built into my laptop), its kernel module keeps on showing up. _top_ says it's using 0.0 memory but 1% CPU, and priority is 20.
Is there some way to get this to stop polling and use, probably interrupts? I remember I read that this used to be a problem with optical drives on Linux. It would keep on polling after every few seconds. Just wondering if this is as simple as a command or a file to modify, perhaps a recompile of the driver/module, but if it needs rewriting the code, then I think there is not much that can be done.
Thanks.
*oh BTW: 2.6.38-13-generic kernel on Natty Narwhal, RTS5139 | The problem is in the design of the rts5139 driver, which is in the 'staging' portion in the kernel hierarchy, meaning it's not yet up to the quality standards of some of the other drivers.
It seems, though, that the problem has been acknowledged on Linux driver development mailing list in May. However so far I'm not seeing changes after that in the kernel tree that would affect the actual problem. I can confirm that I'm seeing the polling on my machine in Ubuntu 12.10, and I'm doing the cumbersome 'rmmod rts5139' in /etc/rc.local to not used the card reader by default (I only use it rarely). | stackexchange-askubuntu | {
"answer_score": 3,
"question_score": 2,
"tags": "drivers"
} |
How to free agents from a wait block based on same value of a integer parameter
I have agents (of type `Segment`) with parameter `ring` (of type `int`). I want to release my agents when three rings with equal `ring` parameter have entered the `wait` block. For example the entries in `wait` block are as follows 13, 25, 7, 25, 13, 25, 13, 7, 1, 1, 7, 1...
As soon as 3 agents with the same `ring` parameter are present in the block, they should be released. I am struggling to compare the parameters in a queue, if anybody can help that would be great. | While this article does not directly answer your question, it has enough information to help you do what you need to do:
<
The idea is that on each arrival, you will need to loop through the content of the queue or wait block. To do so, On Enter, you write something similar to the following:
List <Segment> segments = findAll(wait,s->s.ring == agent.ring );
if( segments.size() == 3 ) {
for( Segment s : segments ) {
self.free( s );
}
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "anylogic"
} |
Check image is loaded when source set by js?
How could i check that image is loaded when i am set image source from jquery. i want change image on mouse over and due large image size its taking time to loading so want to show loading image until it loads.
Here is my code snippet:
timer = setInterval(function() {
selector.attr('src', 'localhost/product/image1.jpg');
image1 is 436x436 and its taking time to load i want to show loading image before loading this image
Please help me... | use below code
selector.attr('src', 'localhost/product/image1.jpg');
//show loader code here
var loadImage = new Image();
loadImage.src = selector.attr('src');
loadImage.onload = function(){
// hide loader code here
} | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "javascript, jquery, image loading, image load"
} |
How does string builder replace work?
StringBuilder sbt = new StringBuilder(2);//
System.out.print(sbt+"G");
sbt.replace(0,2,"Mano");
System.out.println(sbt+"Length is:"+sbt.capacity());
I expect it should print `GManoLength is:4`.
But it returns `GManoLength is:6`
How does this allocation work?
I read this) | You are not showing the _length_ of the contents of the `StringBuilder`. You are showing the _capacity_. The StringBuilder can allocate however much space it wants to even if you never use that space. Usually it's a smart thing to assume StringBuilder will be used to add more data into it, otherwise you'd be using a String or other constant size construct.
If you want to show the _length_ of the data, use `length()` method. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "java, stringbuilder"
} |
Python == many statements instead of if/elif
I am trying this below.
my_list = []
for row in reader:
a = row[0]
b = row[1]
c = row[2]
s=("{0:<5s} {1:<5s} {2:<8s} ".format(a,b,c))
lst = my_list.append(s)
if b == ("Home"):
n_lst = new_lst.appen(s)
I want if row b in my output equals "home" "gone" etc to put that line in a new list. I tried
if b == ("home", "gone"):
but that doesn't work, is there a way to keep adding things to my if == statement instead of doing a bunch of elif statements? | Use the `in` keyword instead:
if b in ['home', 'gone']:
This checks to see if `b` is an element of that list.
Also, you seem to have a spelling mistake here:
n_lst = new_lst.appen(s)
^ | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 0,
"tags": "python"
} |
Excel DB connection: insert, update & delete?
I used the `DATA`-`From Other Sources`-`From SQL Server` controls to import a database table into my Excel workbook. It looks perfect, and refreshing data works like a charm.
However, whenever I make any changes to the table (editing, inserting or deleting rows), I cannot seem to find a way to push these changes to the database. This makes me wonder whether this is actually possible.
Can anybody tell me how to do this, or confirm that this is not supported? | When you make a 'live' table in Excel by linking to an external data source like you have described in this question, Excel manages this by using a QueryTable object behind the scenes.
QueryTable objects have the ability to be refreshed on demand, and to refresh on a periodic schedule defined by the user.
QuertyTable objects are NOT bi-directional. They can be used to import data into Excel, but not to write changes back to the data source.
QueryTable objects can be manipulated from VBA.
Custom VBA code can be written to automatically write to a data source any changes made by a user to a table. But this absolutely requires writing code... it is not a simple option that you can select from the Excel user interface for your table.
> Can anybody tell me how to do this, or confirm that this is not supported?
**Insert, update, and delete are not supported from the Excel user interface.** | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": -2,
"tags": "database, excel"
} |
Extracting curved line features
I have a curved line in a matrix and i need to calculate below cases :
1. Radius of curvature top
2. Curve is upside or downside
3. Length of line
For example in below image i need to know above cases about green line(i have green line data, no need to image processing) :
.
For example, you can build polynomial approximation over points at the line border (seems you lines have thickness) with least squares method (use rather low polynom power).
Having polynom, you can estimate if it is convex upward or downward through the second derivative - note that high-power polynoms might have different convexity sign at distinct segments.
Having two polynoms for "low" and "upper" borders, you can calculate their difference and get area between them with integration.
To get length, you need to integrate along the curve. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "algorithm, math"
} |
webapp2 post operation not updating datastore
I am developing a web application using google appengine.
I am trying to update an existing entry in the table but my post operation does not seem to be working.
post script:
r = requests.post(" data={'type': 'user', 'id':
'11111', 'name': 'test'})
When running the script there are no errors in the console and when prining r.text I can see the updated name but the page on localhost does not show the updated name and the datastore user still has its previous name.
My model for the main page is:
class Page(webapp2.RequestHandler):
def get(self):
...
def post(self):
user = User().get_user(self.request.get('id')) // query user from data store
user.name = self.request.get('name')
user.put()
// update jinja template | `self.request.get('id')` is a `string`. You want to use an `integer` for the id, or build a key (I am assuming you are using `ndb`):
user = ndb.Key('User', int(self.request.get('id'))).get() | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "google app engine, post, webapp2"
} |
Drag and drop no longer working on my drupal 7 site after workbench acess install
When I enable the workbench access module, all drag and drop reordering is broken. It doesn't work under blocks or under the menus. This doesn't happen on my local computer.
The working bench acess module I have is 7.x-1.2 under drupal 7.28 | It got fixed by installing the speedy module which compreses all the js. | stackexchange-drupal | {
"answer_score": 0,
"question_score": 0,
"tags": "workbench"
} |
How to loop this array?
I'm trying to display the values of this array using map method. The data should be displayed in JSX like "local - event - age ". What is the best practice in terms of performance? I would like to avoid nested map.
const data = [
{
cambridge: {
event: "birthday",
age: "free"
},
boston: {
event: "beer tasting",
age: "only adults"
},
watertown: {
event: "porch music festival",
age: "free"
}
}
];
I tried something like that but it's not the format "local - event - age". Thank you!
function App() {
return (
<div className="App">
{data.map(obj => (
<div>
<div>{Object.keys(obj).map(key => console.log(key))}</div>
<div>{Object.values(obj).map(key => console.log(key.event, key.age))}</div>
</div>
))}
</div>
);
} | You could use `index` from the first map to find the right array item and use the `keys` to access the values. Something like this:
const childrenElements = data.map((obj, idx) =>
Object.keys(obj).map((key) => {
return (
<p>
{key} - {data[idx][key].event} - {data[idx][key].age}
</p>
);
})
);
return (
<div className="App">
<div>{childrenElements}</div>
</div>
);
Here is a working example: < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "reactjs, loops, nested loops"
} |
How to access an object attribute with a dot in its name
I am using a bunch class to transform a dict to an object.
class Bunch(object):
""" Transform a dict to an object """
def __init__(self, kwargs):
self.__dict__.update(kwargs)
The problem is , i have a key with a dot in its name({'test.this':True}).
So when i call:
spam = Bunch({'test.this':True})
dir(spam)
I have the attibute:
['__class__',
'__delattr__',
...
'__weakref__',
'test.this']
But i can't access it:
print(spam.test.this)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-7-ea63f60f74ca> in <module>()
----> 1 print(spam.test.this)
AttributeError: 'Bunch' object has no attribute 'test'
i got an AttributeError.
How can i access this attribute? | You can use `getattr`:
>>> getattr(spam, 'test.this')
True
Alternatively, you can get the value from the object's `__dict__`. Use `vars` to get `spam`'s dict:
>>> vars(spam)['test.this']
True | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 5,
"tags": "python"
} |
sql geography to dbgeography?
Maybe I'm missing something. I have a sql server column of the "Geography" datatype.
I want to use the DbGeography type in my c# code. Any way to cast or convert from sql's geography to dbgeography? | Sorry for the late response - but saw this whilst searching for something else.
Simply do the following:
SqlGeography theGeography;
int srid = 4326; // or alternative
DbGeography newGeography = DbGeography.FromText(theGeography.ToString(), srid);
To reverse it:
DbGeography theGeography;
SqlGeography newGeography = SqlGeography.Parse(theGeography.AsText()).MakeValid();
Hope that helps! | stackexchange-stackoverflow | {
"answer_score": 29,
"question_score": 18,
"tags": "sql server, c# 4.0, gis, geospatial, spatial"
} |
T-SQL - create partition function and scheme - SQL Server 2008
I am creating partition function and schemes.
In SQL Server 2008, it only defines range partitioning and not list partitions.
Dont we have list partitioning in SQL Server?
I am using SQL Server 2008 Enterprise edition. | There is no List Partitioning in SQL Server 2008. But you can fake it into creating one using the LEFT clause.
Read up here:
< | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "sql, sql server, tsql, sql server 2008, partitioning"
} |
Zend Framework URL Without mod_rewrite
In a scenario where I don't have mod_rewrite installed, is there any easy way to make URLs like from same regex router
>
and Zend Framework should be able to dispatch controller by reading the same format. | Rob Allen had a blog post about `Zend Framework URLs without mod_rewrite`
to be honest i didn't try it , but it worth mentioning
< | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "php, zend framework, mod rewrite"
} |
Ionic function works for the first few times and stops working from later shows it is not a function even when nothing is changed
I am new in ionic and trying out simple switching between pages using button
I placed the below code in home.html
<button ion-button (click)="callnew()">Click me</button>
I place the following code in home.ts
callnew() {
this.navCtrl.push(Page2Page);
}
In home.ts I have placed the import above
import { Page2Page } from'../page2/page2';
I have included necessary lines in app.module.ts :
import { Page2Page } from '../pages/page2/page2';
@NgModule({declarations: [
MyApp,
HomePage,
ListPage,
Page2Page
],
entryComponents: [
MyApp,
HomePage,
ListPage,
Page2Page
],
The function works for some 4-5 times then stops later even when nothing is changed. Please let me know where I am going wrong. | Everything seems fine from the code sample you provided, if you're using live reload then it might be the problem as it has a weird behavior that some newer changes are not detected. if you're using live reload, just go to the home.ts and save it again without editing anything just to force the live reload to be updated and detect the current code used inside this file, if the problem still occurs try to stop the live reload and run again. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "typescript, ionic framework"
} |
Learn Ancient Greek or Latin first?
I am in the beginning stages of thinking about learning both Ancient Greek and Latin. During my initial research, I have encountered some people saying that learning Latin first is what is commonly done, and that it is helpful when learning Ancient Greek. I have also read some people say that it makes no difference.
What are the benefits of learning Latin first as opposed to Ancient Greek, and vice versa? Are there any at all? | Learning Latin is (generally speaking*) easier than Greek; you don't need to learn a new alphabet, and if you know a little bit of Italian, French or Spanish, you might recognize some of the words. Even English has, because of the large influence of French, many words whose roots can be traced back to Latin.
Since it's easier, you're more likely to make significant progress and actually _enjoy_ learning a new language, which is important. (Personally speaking, learning new languages quickly becomes addictive.) And in the meantime you'll be prepared for most of the peculiarities that classical languages have, so you'll have a head start when learning Greek.
Conversely, learning Greek first is harder, and you have a higher chance of developing a dislike for it.
*: of course, if your native language is Modern Greek, things are different | stackexchange-latin | {
"answer_score": 22,
"question_score": 15,
"tags": "classical latin, ancient greek, study strategies, pedagogy"
} |
Why a complete graph has $\frac{n(n-1)}{2}$ edges?
I'm studying graphs in algorithm and complexity, (but I'm not very good at math) as in title:
> Why a complete graph has $\frac{n(n-1)}{2}$ edges?
And how this is related with combinatorics? | A simpler answer without binomials: A complete graph means that every vertex is connected with every other vertex. If you take one vertex of your graph, you therefore have $n-1$ outgoing edges from that particular vertex.
Now, you have $n$ vertices in total, so you might be tempted to say that there are $n(n-1)$ edges in total, $n-1$ for every vertex in your graph. But this method counts every edge twice, because every edge going out from one vertex is an edge going into another vertex. Hence, you have to divide your result by 2. This leaves you with $n(n-1)/2$. | stackexchange-math | {
"answer_score": 88,
"question_score": 58,
"tags": "combinatorics, discrete mathematics, graph theory"
} |
How to setup CLIENT_MULTI_RESULTS flag in perl dbi for mysql connection
How to set CLIENT_MULTI_RESULTS flag in perl dbi for mysql connection? I have to use a stored procedure with a select query at the end. I learned that to use this kind of procedure, I have to set CLIENT_MULTI_RESULTS flag. Thanks in advance. | Since version 3.0002_5, the driver (DBD::mysql) supports multiple result sets and thus sets the option automatically. (The latest version is 4.022, so one would assume it's a stable feature.)
See the relevant documentation for an example that shows how to fetch all the result sets. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "mysql, perl, stored procedures"
} |
Broadcast receiver for GPS state?
Is there a way to be notified when the GPS is switched on/off?
I noticed that when the device is switched off an then on again, getLastKnownLocation(provider) is null. So I want to save the location when the GPS is switched off to a database. | Register a BroadcastReceiver to listen for the LocationManager's PROVIDERS_CHANGED_ACTION Intent. This will be broadcast when the GPS provider (and other providers) is enabled / disabled. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "android, gps, broadcastreceiver"
} |
defer many tasks simultaneously on google-app-engine
I am developping a python app on google app engine. I have a CRON job which imports everyday a list of 20 fresh files from a S3 bucket to a GS bucket.
Here is my code:
import webapp2
import yaml
from google.appengine.ext import deferred
class CronTask(webapp2.RequestHandler):
def get(self):
with open('/my/config/file') as file:
config_dict = yaml.load(file_config_file)
for file_to_load in config_dict:
deferred.defer(my_import_function, file_to_load)
app = webapp2.WSGIApplication([
('/', CronTask)
], debug=True)
Note that `my_import_function` is part of another package and takes some time to be done.
My question: is it a good idea to use the function `deferred.defer` for this task or should I proceed diferently to launch `my_import_function` for all my arguments? | You should use the taskqueue, but depending on how many tasks you have you may not want to use `deferred.defer()`.
With `deferred.defer()` you can only enqueue one task per call. If you are enqueueing a lot of tasks, that is really inefficient. This is really slow:
for x in some_list:
deferred.defer(my_task, x)
With a lot of tasks, it is much more efficient to do something like this:
task_list = []
for x in some_list:
task_list.append(taskqueue.Task(url="/task-url",params=dict(x=x)))
taskqueue.Queue().add(task_list)
About a year ago, I did a timing comparison, and the latter was at least an order of magnitude faster than the former. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "python, google app engine, queue, deferred"
} |
me.com is coded with javascript+css+html only?
I wonder if me.com is coded with javascript+css+html only?
No RIA language like Flash, Java right? | me.com is clearly not using Flash , right click anywhere in the browser and you will quickly find out. furthermore, it wouldn't make sense for Apple to get anywhere near Flash.
This article should give you a few answers about Apple's RIA perspective <
You may also want to have a look at the SproutCore & Capuccino frameworks in order to have an idea of where Apple is likely heading. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "java, javascript, html, css, flash"
} |
Why are some iTunes Store songs marked as CLEAN when no EXPLICIT version exists?
I have downloaded a number of items from the iTunes store which are marked as CLEAN. I understand this is common in tracks (I'm looking at you, rappers!) where an EXPLICIT song has has the swear words removed or bleeped or reversed etc. However, the tracks I have are the original recordings, and are not clean versions of tracks that were originally explicit:
!enter image description here
What makes iTunes decide to add these flags to certain songs, and what is the point of a CLEAN tag?
In the example given every track is marked as clean, but I have seen it on individual songs also. | I just had a look at differently tagged files.
The responsible ID3-tag is `rtng` (short for `rating`). If set to `1` the song will be marked as `EXPLICIT`, while `2` shows up as `CLEAN`. Every other value leads to no label.
I recommend Kid3 as a tag editor.
EDIT: According to this and this, the values should be `2` (CLEAN) and `4` (EXPLICIT). I can't reproduce those, maybe someone copied it wrong... | stackexchange-apple | {
"answer_score": 2,
"question_score": 3,
"tags": "itunes, id3 tag"
} |
get sql server 2005 to NOT use unicode in its TDS protocol?
This may be a really stupid question, but...
The TDS protocol used by sql server appears to use unicode or UTF-16 character encoding. A query like `select foo from bar` appears like `s.e.l.e.c.t. .f.o.o. .f.r.o.m. .b.a.r` in the tcp stream in wireshark.
If you have an application connecting to SQL server over a network, that absolutely does not and probably never will use unicode text fields, is there a way to tell the sql client to encode the queries in ascii to cut network traffic? | The tabular data stream (TDS) protocol documentation specifically states that SQL statements in the protocol will be encoded in Unicode (section 2.2). Unless you're running over a heavily bandwidth-constrained network you're probably just gold-plating to worry about this. (If you are bandwidth-constrained to the point that this is a problem you might want to consider tunneling the traffic over something with compression.) | stackexchange-serverfault | {
"answer_score": 2,
"question_score": 0,
"tags": "sql server 2005"
} |
Packing problem regarding a disc
Suppose that there is a packing of 1000 unit discs in the rectangle R. It means that these 1000 discs lie inside of R and any two of them do not share a common interior point (but they could touch each other). Prove that there is a packing of 4000 discs of diameter 1 in R. The mentioned problem is related to the packing problem. I am very new to this idea. I am trying to find some relevant material but I am unable to find any proper notes or website. I found this < but I guess it's different from what I am trying to solve. If anyone can suggest some good websites it will be really helpful also. | A rectangle $R$ with width $w$ and height $h$ can be divided into $4$ rectangles of width $\frac w2$ and height $\frac h2$. | stackexchange-math | {
"answer_score": 1,
"question_score": 2,
"tags": "convex geometry, discrete geometry, packing problem"
} |
Empty RELIES_ON for RESULT_CACHE
I have a query inside the function with RESULT_CACHE.
So when the table is changed - my cache is invalidated and function is executed again.
What I want is to implement the function that depends **only** on input parameters, and doesn't depend on any implicit dependencies (like tables, etc).
Is it possible (without dynamic sql)? | a function that depends only on its parameters can be declared DETERMINISTIC. The results of this function will be cached in some cases. This thread on the OTN forums shows how deterministic function results get cached inside SQL statements.
As of 10gR2, the function results don't get cached across SQL statements nor do they get cached in PL/SQL. Still, this cache feature can be useful if you call a function in a SELECT where it might get called lots of time.
I don't have a 11gR2 instance available right now, so I can't test the RESULT_CACHE feature, but have you considered delaring your function relying on a fixed dummy table (a table that never gets updated for instance)? | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 5,
"tags": "oracle, oracle11g, oracle11gr2"
} |
Linq syntax for OrderBy with custom Comparer<T>
There are two formats for any given Linq expression with a custom sort comparer:
Format 1
var query =
source
.Select(x => new { x.someProperty, x.otherProperty } )
.OrderBy(x => x, new myComparer());
Format 2
var query =
from x in source
orderby x // comparer expression goes here?
select new { x.someProperty, x.otherProperty };
**Question:**
What is the syntax for the order-by expression in the second format?
**Not the question:**
How to use a custom comparer as shown in the first format.
**Bonus credit:**
Are there actual, formal names for the two Linq formats listed above? | > What is the syntax for the order-by expression in the second format?
It doesn't exist. From the orderby clause documentation:
> You can also specify a custom comparer. However, it is only available by using method-based syntax.
* * *
> How to use a custom comparer in the first format.
You wrote it correctly. You can pass the `IComparer<T>` as you wrote.
* * *
> Are there actual, formal names for the two Linq formats listed above?
Format 1 is called "Method-Based Syntax" (from previous link), and Format 2 is "Query Expression Syntax" (from here). | stackexchange-stackoverflow | {
"answer_score": 24,
"question_score": 23,
"tags": "c#, linq"
} |
Relational Database: Variable Fields
I am making this hotel reservation program and i'm in a dilemma.
I have the users table that is basically
id
identifier
password
realName
cellphone
email
The rooms table
id
type
price
And the reservations table
id
checkin
checkout
room_id
nights
total_cost
The problem is that a single user in a single reservation can ask for multiple rooms with multiple check ins and outs.
What would be the best approach to achieve this? I was thinking of splitting the various rooms with different reservation ids and then make some kind of workaround to relation them. | I think your data structure is fine as far as it goes. You have two choices.
The first is to relax your language. Don't say that "a single user in a single reservation can ask for multiple rooms with multiple check ins and outs". Instead say, "a single user can make multiple reservations at the same time". Just changing this language fixes your conundrum.
If you really have to tie things together, I might suggest having an column that groups reservations made by a single user together. This could be a full-blown entity, which would have a foreign key reference to another table. Or, it could simply be an identifier, such as the first reservation in the series or the user id with a date/time stamp. I'm not sure that a full blown entity is needed, but you might find it useful. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "mysql, sql, database, laravel, relational"
} |
Date Sort not working on datatables.net
I'm trying to sort a datatables.net table by `date` but it is not sorting correctly.
How can I sort by dates? | Just use the aoColumns option
e.g.
"aoColumns": [{ "sType": "date" }] | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "datatables"
} |
VS Code Ionic 3 - Intellisense works inside constructor but not anywhere else
VS Code Ionic 3 - Intellisense works inside constructor but not anywhere else.
 => {
this.navCtrl.push(CaseDetailsPage);
}
Since you are using Ionic 3, the class function will be:
test(){
this.navCtrl.push(CaseDetailsPage);
}
Since `this` was different the VSCode Intellisense did not detect `navCtrl` type . | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "visual studio code, ionic3"
} |
Show {{ value }} except special one in AngularJS 1.6
After SPAN click my DIV get this category title , but in one case , when category.title is 'Favorite' (or category.id = '1',its the same) i need ignore it in DIV and don't change the value on it.
How can i realize that ? Thanks in advance
My HTML :
<div> {{ selections.category.title }} </div>
<span ng-repeat="category in categories track by category.id" ng-click="selectCategory(category)">
...
</span>
My controller :
$scope.selectCategory = function selectCategory(category) {
$scope.selections.category = category;
...
}
EDIT.
I need only ignore it in DIV's text , not ignore click on this element . | <div> {{ selectedTitle }} </div>
$scope.selectCategory = function selectCategory(category) {
if(category.title !== 'Favorite' && category.id !== '1') {
$scope.selectedTitle = category.title;
}
$scope.selections.category = category;
...
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "angularjs, ng bind"
} |
Declaring tuple without initializing in C#
I want to use `Tuple`s in my code dynamically and have to assign the values to tuple _according_ to the `if` statement. I have the following code:
if(check != null)
var scoreTmpTuple = new Tuple<Guid, string, double>(
(Guid)row["sampleGuid"],
Convert.ToString(row["sampleName"]),
Convert.ToDouble(row["sampleScore"]));
else
var scoreTmpTuple = new Tuple<Guid, string, double>(
(Guid)row["exampleGuid"],
Convert.ToString(row["exampleName"]),
Convert.ToDouble(row["exampleScore"]));
In the code, the tuple is declared _inside_ the `if` and `else` statements. I want to declare that _outside_ and initialize the tuple accordingly. | You can try _ternary operator_ and push ramification within tuple creation:
var scoreTmpTuple = Tuple.Create(
(Guid)row[check != null ? "sampleGuid" : "exampleGuid"],
Convert.ToString(row[check != null ? "sampleName" : "exampleName"]),
Convert.ToDouble(row[check != null ? "sampleScore" : "exampleScore"])
);
Or even (if we actually should switch between `"sample"` and `"example"` prefixes):
string prefix = check != null
? "sample"
: "example";
var scoreTmpTuple = Tuple.Create(
(Guid)row[$"{prefix}Guid"],
Convert.ToString(row[$"{prefix}Name"]),
Convert.ToDouble(row[$"{prefix}Score"])
); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "c#, tuples"
} |
DB2 bulk update take long time
We have 3 million record in our database. We need to update postalcode column with same postalcode column by removing first letter 0.
identifyno,addresstypecode is composite primary column in addresss table.
We used below query 300 times(300*10000=3000000)
**UPDATE db2inst1.address SET postalcode = SUBSTR(postalcode,2) WHERE (identifyno,addresstypecode) IN (SELECT identifyno,addresstypecode FROM db2inst1.address WHERE countrycode='IN' AND SUBSTR(postalcode,1,1)='0' FETCH FIRST 10000 rows only ); commit;**
It is taking long time ( almost 1 day) to execute.
Please help me to improve the performance of the query. | I think the problem is that your query touches the same table twice. You can simplify it to:
UPDATE db2inst1.address
SET postalcode = SUBSTR(postalcode,2)
WHERE countrycode='IN' AND SUBSTR(postalcode,1,1)='0'
I don't understand why you are only updating the first 1000 records, especially since you do not have an ORDER BY clause, so the order is arbitrarily assigned by the database engine. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "database, performance, db2, database performance"
} |
How can I insert in database values from dropdown list based on a relationship between 2 tables? I am using ASP.NET c# Entity framework, Code first
I am not talking about the id of the element in the list, but the id of it from a table if the value is in another table. E.g I have a FullName and an ID in one table and I have the same ID and some other stuff in another table(one to zero or one relationship). I have bound the FullName to a dropdown list control,but when saving,I need to refer to it's ID from the table, not the string value. | If you place something in a drop down list, you can place the ID in the value field and something else as a text, for example :
ddlCategorie.DataTextField = "Texte";
ddlCategorie.DataValueField = "ID_GLOBAL";
ddlCategorie.DataSource = db.GLOBAL.Where(t => t.DATE_FIN > dt).OrderByDescending(t => t.ID_GLOBAL).ToList();
ddlCategorie.DataBind();
As you see, I already placed the reel database value "ID" of the object inside the value field of the drop down list. So I can immediately retrieve is ID by doing :
int i = Convert.ToInt32(ddlCategorie.SelectedValue); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "c#, asp.net, entity framework"
} |
24-hours time with 12-hour notation
I've received an paper e-mail copy with header saying, that the e-mail was sent **15:10 PM**. So I am wondering, if the mail is fake one, or is it possible due to some setting changes?
My questions:
1. Is it possible to have such a time setting in any mail client? (MS Outloook, web-based etc.)
2. Is it even possible to program such time type in any programming language?
EDIT: The header is similiar like this one, just the time is as stated above 15:10 PM. | Yes, it is possible.
To achieve such a thing, you just need to customize date format in **Regional Settings** control panel. Most applications then use the setting, including the Outlook.
So the explanation can be that person who printed the e-mail had set unusual time format on their PC.
See the following screenshot with similar example and its impact on clock in notification area:
 | stackexchange-superuser | {
"answer_score": 1,
"question_score": 1,
"tags": "email, date time, timestamp"
} |
Get id of field input in sonata using Javascript
I use symfony and sonataAdminBundle, in my ProductAdmin Class I have a form with many input type : And i like to get the Id of one of this input called 'prixAchat' : with inspect element I see that sonata generate an auto prefix value before the id like this : **s5988300197635_prixAchat** so
So I tried to use this code :
prixAchat = document.getElementById('form [id$="_prixAchat"]').value
But always the result is null
Someone can help me please ? | You only want to get input? I think the code should be `prixAchat = $('input [id$="_prixAchat"]').val()` | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "javascript, jquery, ajax, symfony, symfony sonata"
} |
How to use a python library from github
I have little experience in Python and want to use this Python library to interface with an API: Python cPanel API library
However, it does not give me any instructions on how to install. I tried `pip3 install -e git+ gives me the error:
`FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/bin/src/cpanelapi/setup.py'`
The repo contains a `__init__.py`, `client.py` and `exceptions.py` file.
How do I use and install this library? | 1. Download the repository.
2. Move it to the base of your directory (along with your scripts)
3. Import it with `import cpanelapi` | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "python, git, api, cpanel"
} |
targeting iPhoneOS 2.2.1
I don't believe that I am using any 3.0 specific APIs, but somehow whenever I compile I get a warning "This project uses features only available in iPhone SDK 3.0 and later", and then a bunch of errors. If I change the Base SDK to 3.0, the warning & errors go away, but then of course I cannot target OS 2.2.1
I see that this is coming from the project_Prefix.pch file, which I assume was created when the XCode initially created the project. I don't see how this file gets included, but I believe this is the source of the problem. I tried removing it, but then the build won't compile at all.
Do I need to regenerate this file somehow? | Silly me- I was in fact using a 3.0 API. I had the following:
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
Removing this line fixed the problem. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "iphone, iphone sdk 3.0, precompiled headers"
} |
I couldn't use my credit card to book tickets with Iranian Mahan Air
I've tried to book a single ticket from Shiraz to Tehran with Mahan Air. But they never accepted my (Belgian) credit card.
I wonder if there are any alternative ways I can book it. | As far as I know, for Iranian airlines (Mahan, Iran Air,..) you should always book via an agency as they still don't have international payment systems (mainly due to sanctions); as an alternative you can look for an agency that works with them in the city/country of your residence and give them a call!
Generally these sale points work like this: receive your request, look for a ticket in your preferred date, inform you of the exact available date and the corresponding price, along with an IBAN and a deadline to pay.
In the links below you can find list of their official sale offices:
Mahan Air
Iran Air
If you can't find an official sale office nearby, there might be some other local agencies that sell their tickets. You can find out about them by contacting them. | stackexchange-travel | {
"answer_score": 2,
"question_score": 2,
"tags": "air travel, iran"
} |
parsing rST to HTML on the fly using Docutils
I want to parse .rst files to .html files on the fly to display as a webpage. I'm using pyramid, and I haven't found any quick help on how to use docutils inside python code and make it write to a buffer.
Anyone have any links to a simple tutorial or any other suggestions on how to do that? | One way is to do something like:
>>> a = """=====\nhello\n=====\n\n - one\n - two\n"""
>>> import docutils
>>> docutils.core.publish_parts(a, writer_name='html')['html_body']
u'<div class="document" id="hello">\n<h1 class="title">hello</h1>\n<blockquote>\n<ul class="simple">\n<li>one</li>\n<li>two</li>\n</ul>\n</blockquote>\n</div>\n' | stackexchange-stackoverflow | {
"answer_score": 12,
"question_score": 6,
"tags": "python, pyramid, docutils"
} |
How to embed Javascript in CSS?
I have a CSS file, which contain the style information of my web. Some height & width is based on the screen size, so I can calculate the size using the Javascript, can I embedded the javascript in the CSS file to do so? | In IE, and only IE, you can use CSS expressions:
width: expression(blah + "px");
Then `width` becomes whatever's inside the brackets.
This only works in IE, though - so **don't use it**. Use a JS function to assign the elements the style with `element.style.width` or similar.
For example:
<script type="text/javascript">
document.getElementById('header').style.width = (100 * 2) + 'px';
</script> | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 2,
"tags": "javascript, css"
} |
Choosing points around a circle as vertices of an isosceles triangle
Suppose we have the points $a_1,a_2,\dots, a_{42}$ equally spaced around a circle. In how many ways can we choose exactly three points so that they form the vertices of an isosceles (or equilateral) triangle? (Of course, this implies permutations of triples are counted as the same)
I have tried counting the number of possibilities by fixing one vertex, then finding the other two based on the fixed point. In this manner, we may find the probability, then multiply by the number of events. I found the probability, by fixing one vertex, to be 3/166. Then, multiplying by 42*41*40, I have received an answer of $2520$ in this manner which I am sure is an over counting. what is a way to solve this problem then?
Thank you! | Putting vertices of triangle aside, let's call $a$ the number of points on the circle near by each of the equal sides and $b$ the number of points beside the other side. We have $2a+b=42-3=39$. This equation has 20 non-negative integer answers, and one of them $a=13,b=13$ is an equilateral triangle. (all sides equal). We can rotate the non-equilateral ones around the circle each 42 times, and the equilateral one $42/3$ times so at last we get $42*19+14=812$ | stackexchange-math | {
"answer_score": 1,
"question_score": 2,
"tags": "probability, combinatorics"
} |
High Chart line single data set but multiple color, not gradient color
Using latest High Chart, I want to have a single line with red color when the line is below some y-value and green otherwise (See picture < Currently this is achieved by concatenating green and red lines (ie. 2 data sets) like this:
series: [{
color: 'red',
data: [{x:1,y:3}
, {x:2, y:2}]
},
{
color: 'green',
data: [{x:2, y:2}, {x:3, y:1}]
}]
However, this introduces issues and I have to use 1 data set (ie. single series). Can someone show me how to achieve this? Thank you. | You have two options:
* use `threshold` option
* use multicolor series plugin | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "javascript, colors, highcharts"
} |
Change UITabBarView tabs order programmatically
I have an app I want to run with the option of 2 languages - First one you read from right to let, the other from left to right.
I want to be able to change tabs order in `UITabBarController` according to the selected language, programmatically.
How can this be done? | You should be able to set the items in reverse manually by calling tabView's `setItems()` method and array's `reversed()` method in the delegate method `viewWillAppear(_:)`, but first you'd want to somehow check if the language is left to right or right to left.
self.tabBar.setItems(self.tabBar.items?.reversed(), animated: false) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "swift, uitabbarcontroller"
} |
ElasticSearch Date Range query returning all values
I have created an index using below mapping.
**Index Mapping:**
{
"mappings": {
"document": {
"properties": {
"doc_date": {
"type": "date" ,
"format": "yyyy/MM/dd"
}
}
}
}
}
I indexed two records. Like below.
**Records:**
{
"doc_date": "2017/06/10",
"Record":"A"
}
{
"doc_date": "2017/05/10",
"Record":"D"
}
I wanted to select documents which are greater than or equal to date 2017/06/10.
**Query:**
{
"query": {
"range" : {
"doc_date" : {
"lte": "2017/06/10",
"format": "yyyy/MM/dd"
}
}
}
}
But the above query returned all the document in the index.
**ElasticSearch version** :5.0.2 | `lte` means lessthan or equal to the date. So you get all dates before 2017/06/10 and the date itself. You have to use `gte` which means greater-than or equal. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "elasticsearch"
} |
amp element/result does not loading on submit, but on shaking the browser window
I am working on a project where i am using the POLL widgets. It is currently working with combination of api and data is loading inside amp-list tag. When I submit the result via selecting any option the result does not show up, but when i zoom-in/zoom out the browser window, the result loads.
Does anyone experience the same problem with amp or have any solution and suggestions?
Thanks in advance. widget-screenshot widget-result-loads-on-browser-zoom-in | This sounds like your amp-list hasn't got enough space available if the viewport is too small. Have you defined an overflow button? What also helps is using a fixed-height layout (if the result always has the same height) and placing the amp-list as far as possible to the bottom of the page.
"If amp-list needs more space after loading it requests the AMP runtime to update its height using the normal AMP flow. If AMP Runtime cannot satisfy the request for new height, it will display overflow element when available. Notice however, the typical placement of amp-list elements at the bottom of the document almost always guarantees that AMP Runtime can resize it."
< | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "amp html"
} |
Using Recursion, how do I get my code to reiterate?
My assignment is to find out how many times it takes for num1 to be divided by num2 before its a whole number, using recursion. My current code is
def fraction_count(num1, num2):
times = int(0)
result = num1/num2
num1 = int(result)
if result%2 == 0:
return times
if (num1/num2)%2 != 0:
return times + 1
print(fraction_count(32,3))
Expected is:
fraction_count(32, 3) → 2 # 32 → 10.667 → 3.333 → 1; 1 is whole → 2
So I have the output of 1 right now because its just running through once. What am I missing here? | Riffing off of Nin17's answer but fulfilling the assignment's requirement to make it recursive yields:
def fraction_count(num1, num2):
num1 = int(num1)
num2 = int(num2)
if num1 % num2 == 0:
return 0
return 1 + fraction_count(num1 // num2, num2)
You can make it a tad faster by eliminating the type conversions if `num1` and `num2` are guaranteed to be integers. With type hinting (added in python 3.5), the code becomes:
def fraction_count(num1: int, num2: int) -> int:
if num1 % num2 == 0:
return 0
return 1 + fraction_count(num1 // num2, num2)
Short and sweet. Recursion may be less efficient than looping, but it often delivers concise code. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -1,
"tags": "python, if statement, recursion"
} |
C++ standard library implementations in different compilers
I was wondering which C++ standard libraries are in use in different C++ compilers. I tried searching for it, but couldn't find a comprehensive list.
I know Dinkumware's implementation is used by msvc and icc, libstdc++ is used by gcc, and libc++ is used in clang. But what about Digital Mars C++, or Embarcadero's bcc, or IBM's xlC++? | A shortlist:
* GCC: uses its own libstdc++.
* MSVC: uses its own msvcrp, which is bought from Dinkumware, then dismembered to work around MSVC's bad C++ language support (so it's not really Dinkumware anymore).
* Clang: uses LLVM's libc++ if passed the `-stdlib=libc++` option. It can also use GCC's libstdc++ and in also MSVC's library (it generates binary compatible code in all cases).
* ICC: uses GCC libstdc++ on Linux and MSVC's library on Windows. It also tries to mimick both compilers on these platforms.
Note there are other compilers and (independent) C++ standard library implementations I have not covered here. | stackexchange-stackoverflow | {
"answer_score": 9,
"question_score": 9,
"tags": "c++, stl, c++ standard library"
} |
In Moose, how do I modify an attribute any time it is set?
If you have an attribute that needs to be modified any time it is set, is there a slick way of doing this short of writing the accessor yourself and mucking around directly with the content of `$self`, as done in this example?
package Foo;
use Moose;
has 'bar' => (
isa => 'Str',
reader => 'get_bar',
);
sub set_bar {
my ($self, $bar) = @_;
$self->{bar} = "modified: $bar";
}
I considered `trigger`, but it seemed to require the same approach.
Is working directly with the hash reference in `$self` considered bad practice in Moose, or am I worrying about a non-issue? | I'm not sure what kind of modification you need, but you might be able to achieve what you need by using type coercion:
package Foo;
use Moose;
use Moose::Util::TypeConstraints;
subtype 'ModStr'
=> as 'Str'
=> where { /^modified: /};
coerce 'ModStr'
=> from 'Str'
=> via { "modified: $_" };
has 'bar' => (
isa => 'ModStr',
is => 'rw',
coerce => 1,
);
If you use this approach, not all values will be modified. Anything that passes validation as a ModStr will be used directly:
my $f = Foo->new();
$f->bar('modified: bar'); # Set without modification
This weakness could be OK or it could make this approach unusable. In the right circumstances, it might even be an advantage. | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 20,
"tags": "perl, moose"
} |
How prevent HG Workbench to ask for user name by using subrepositories?
I use HG Workbench and subrepositories over a ssh connection. I use also ssh-rsa to avoid typing my **password** every time. This works great for the main repository. But if I push or pull HG Workbench (or command shell) promt's with a dialog to typing my **login name** for **every** subreposititory. Can I prevent this?
Update:
I use windows. Also I have a `[ui]` section with `username` in my global `mercurial.ini` and in `hgrc` of every subrepositories. | On windows edit the global `mercurial.ini` settings file and add `ssh` key to the `ui` section:
[ui]
ssh = tortoiseplink.exe -l <username> | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ssh, mercurial, tortoisehg, mercurial subrepos, subrepos"
} |
Finding errors of Reactive Form subgroup
I cannot find a way to retrieve errors of subgroup of my reactive form.
private setupFormValidation() {
this.progressForm = new FormGroup({
'preImplementationGroup': new FormGroup({
'otherProgramName': new FormControl(null, [Validators.required]),
'programType': new FormControl(null, [Validators.required]),
...
}),
'testingReviewGroup': new FormGroup({
...
})
});
What would be the best way to find all errors only for 'preImplementationGroup' Form Group? | I have found a way, in case someone would be looking for the similar:
sign() {
var preImplementationGroup = <FormGroup>this.progressService.progressForm.get('preImplementationGroup');
this.getFormValidationErrors(preImplementationGroup);
}
getFormValidationErrors(fg: FormGroup) {
Object.keys(fg.controls).forEach(key => {
const controlErrors: ValidationErrors = fg.get(key).errors;
if (controlErrors != null) {
Object.keys(controlErrors).forEach(keyError => {
console.log('Key control: ' + key + ', keyError: ' + keyError + ', err value: ', controlErrors[keyError]);
});
}
});
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "angular, angular2 forms"
} |
Migrating from table without primary key to one with
I currently have a self-referencing join table without a primary key. If you're familiar with Rails, I have a has_many_and_belongs_to relationship defined.
The join table is called users_users. One FK is friend_id and the other is user_id.
I want to change the relationship of this table to has_many and belongs_to (again, if you're familiar with Rails). This means I need to a add a PK column.
What is the best way to do this? | Add a surrogate key
ALTER TABLE users_users ADD id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
Should be all you have to do in MySQL, I don't know about anything different pertaining to your model setup in Rails. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "mysql, sql, ruby on rails, join"
} |
How do i solve this recurrence relation using De Moivres Theorem
Given that $a(0) = 1, a(1) = -1$, $a(n)= -4a(n-2)$ for all n>= 2, Solve the recurrence relation.
I know that the characteristic polynomial is $x^2+4=0$, using the quadratic equation we get the two roots as +- $\sqrt{-16}/2$ which i simplified to $+-2i$
The solution to the recurrence relation will be in the form
$a(n) = A(0+-2i)^n+B(0+-2i)^n$
how can I solve this recurrence? My prof used De Moivres Theorem to solve something similar but I do not understand the theorem | For a general method of solution, you can see Theorem 4.2, part(3) and Example 4.4(c)
The characteristic equation is $r^2 + 4 = 0$ with solutions
$r = \pm ~i~2$
which means
$\rho = 2$ and $\theta = \frac{\pi}{2}$
Hence the general solution is
$a_n = 2^n \left( A \cos {\frac{n \pi}{2}} + B \sin {\frac{n \pi}{2}}\right)$
Putting $n = 0$ in the above solution we have
$a_0 = A = 1$
Putting $n = 1$ in the above solution we have
$a_1 = 2^1 \left( A \cos {\frac{1 \pi}{2}} + B \sin {\frac{1 \pi}{2}}\right) = -1$
Notice that $\cos {\frac{\pi}{2}} = 0$
or, $a_1 = 2B = -1 \implies B = -\frac{1}{2}$
Finally
$a_n = 2^n \left( \cos {\frac{n \pi}{2}} -\frac{1}{2} \sin {\frac{n \pi}{2}}\right)$
Please let me know if you could follow all the steps. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "combinatorics, recurrence relations"
} |
Question regarding construction of a linear nonzero bounded operator $T$ such that $T^2=0$
I am supposed to construct a nonzero bounded linear operator on a a separable Hilbert space of dimension at least 2 such that $T^2=0$. I have seen a question related to this (I don't know how to reference it) but for that question I saw that someone proposed the following operator $Te_1=e_2$ and $Te_n=0$ for $n\geq 2$ where $\\{e_n\\}$ is an orthonormal basis for the Hilbert space. I can clearly see that this satisfies $T^2=0$ and that it's bounded, but I can't quite see whether it is linear? Can someone help me see whether it is or not?
Also if the Hilbert space is separable, is there another way of constructing such an operator? I would think one would have to use something with orthogonal complements.
Thanks in advance! | Let $M=\text{span}(e_{n})$, then $M$ is a vector subspace of the Hilbert space with Hamel basis $(e_{n})$, a linear operator on $M$ is uniquely determined by assigning the values to those $e_{n}$. The $T$ that created is clearly bounded on $M$, since $\overline{M}$ is the Hilbert space, now you can use bounded extension theorem to obtain a uniquely defined $T$ on the whole Hilbert space. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "real analysis, functional analysis"
} |
How to add a list of values to a pandas column
I have a pandas dataframe.
d = {'col1': [1, 2], 'col2': [3, 4]}
df = pd.DataFrame(data=d)
col1 col2
0 1 3
1 2 4
I want to add the list lst=[10, 20] element-wise to 'col1' to have the following dataframe.
col1 col2
0 11 3
1 22 4
How to do that? | If you want to edit the column in-place you could do,
df['col1'] += lst
after which `df` will be,
col1 col2
0 11 3
1 22 4
Similarly, other types of mathematical operations are possible, such as,
df['col1'] *= lst
df['col1'] /= lst
If you want to create a new dataframe after addition,
df1 = df.copy()
df1['col1'] = df['col1'].add(lst, axis=0) # df['col1'].add(lst) outputs a series, df['col1']+lst also works
Now `df1` is;
col1 col2
0 11 3
1 22 4 | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "python, pandas, dataframe"
} |
Требования к системе для Win Phone 8 SDK
Вопрос прост: действительно ли для Windows Phone 8 можно разрабатывать только из под Win 8?
* * *
_Это просто epic fail какой-то! Везде установлена Windows 7 и я не могу писать под Windows Phone 8???? Android - наше все!_ | Минимальные требования для работы эмулятора и Windows Phone SDK 8, увы не порадовали: Win 8 Pro х64 и поддержка процессором технологии виртуализации, ибо эмулятор использует Hyper-V. У меня лично процессор не новый(Dual Core), но эмулятор так и не запустился.
Вообщем, одно разочарование:( | stackexchange-ru_stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "windows, windows phone 8"
} |
Insert image in Excel using xlwt in GAE
I tried:
> sheetLoopParam.insert_bitmap(os.path.abspath("static/PLL_diagram2_small.bmp"), 12, 0)
but it says:
> IOError: [Errno 13] file not accessible: 'C:\Users\rest_of_path\static\PLL_diagram2_small.bmp'
The path it displays _is_ correct, I don't understand why it says it can't access it. Thank you. | I figured it out, more or less. I put the image in the app's root directory instead of inside the static directory, seems to like that ok.
Like this:
> sheetLoopParam.insert_bitmap(os.path.abspath(" **PLL_diagram2_small.bmp** "), 12, 0)
instead of like this:
> sheetLoopParam.insert_bitmap(os.path.abspath(" **static/PLL_diagram2_small.bmp** "), 12, 0)
I just need to insert the one image so that works ok. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "google app engine, python 2.7, xlwt"
} |
Upload S3 Object with Object Permissions
I a using the .Net AWSSDK. I am trying to upload an object with permissions. In the console you can set permissions on an object by object basis and I can't for the life of me work out how to do it in C#.
I want an uploaded object to have Oped/Download permissions for everybody. So far I have the following:
try
{
var fileTransferUtility = new TransferUtility(new AmazonS3Client(REGION));
var fileName = Path.GetFileName(filePath);
var key = path "/" + fileName;
fileTransferUtility.Upload(filePath, existingBucketName, key);
// Set open permissions for file with key
}
catch (AmazonS3Exception s3Exception)
{
Console.WriteLine(s3Exception.Message, s3Exception.InnerException);
} | Use this form of the `Upload` function:
public virtual void Upload(
TransferUtilityUploadRequest request
)
The `TransferUtilityUploadRequest` contains a `CannedACL` property that can specify various different values such as:
* Private
* PublicRead
* PublicReadWrite
* AuthenticatedRead | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c#, amazon s3, permissions, aws sdk, .net 4.6"
} |
SQL: order by how many rows there are (using COUNT?)
For SMF, I'm making a roster for the members of my clan (please don't come with "You should ask SMF", because that is completely irrelevant; this is just contextual information).
I need it to select all members (from **smf_members** ) and order it by how many permissions they have in **smf_permissions** (so the script can determine who is higher in rank). You can retrieve how many permissions there are by using: `COUNT(permission) FROM smf_permissions.`
I am now using this SQL:
SELECT DISTINCT(m.id_member), m.real_name, m.date_registered
FROM smf_members AS m, smf_permissions AS p
WHERE m.id_group=p.id_group
ORDER BY COUNT(p.permission)
However, this only returns **one** row! How to return **several** rows?
Cheers, Aart | You need a `GROUP BY`. I've also rewritten with explicit `JOIN` syntax. You might need to change to `LEFT JOIN` if you want to include members with zero permissions.
SELECT m.id_member,
m.real_name,
m.date_registered,
COUNT(p.permission) AS N
FROM smf_members AS m
JOIN smf_permissions AS p
ON m.id_group = p.id_group
GROUP BY m.id_member,
m.real_name,
m.date_registered
ORDER BY COUNT(p.permission) | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 1,
"tags": "sql, count, sql order by, selected"
} |
How to javascript regex match the following?
I only want to match ones that say:
Given I string, I want something that is able to detect words that match anything with the following pattern of "TERMINATE:" + any number of random letters or numbers:
"VIRUS:XPA"
"VIRUS:IDI"
Then the function should return "true" to indicate there is only a virus.
But if the string is the following:
"ANM|SDO|FSD:SOS|VIRUS:XPA"
"ANM:SOS|SDO|FSD:SOS|VIRUS:XLS"
"VIRUS:XLS|ANM:SOS|SDO|FSD:SOS|VIRUS:XPL"
"VIRUS:XLS|ANM:SOS"
Then the function should return "false" to indicate there is no virus, or the virus is masked.
Can this be done with a single regular expression in javacsript? | You mean something like this ?
var isVirus = /^VIRUS\:\w*$/.test(str) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "javascript, regex"
} |
Biopython for Loop IndexError
I get "IndexError: list is out of range" when I input this code. Also, the retmax is set at 614 because that's the total number of results when I make the request. Is there a way to make the retmode equal to the number of results using a variable that changes depending on the search results?
#!/usr/bin/env python
from Bio import Entrez
Entrez.email = "[email protected]"
handle1 = Entrez.esearch(db = "nucleotide", term = "dengue full genome", retmax = 614)
record = Entrez.read(handle1)
IdNums = [int(i) for i in record['IdList']]
while i >= 0 and i <= len(IdNums):
handle2 = Entrez.esearch(db = "nucleotide", id = IdNums[i], type = "gb", retmode = "text")
record = Entrez.read(handle2)
print(record)
i += 1 | Rather than using a while loop, you can use a for loop...
from Bio import Entrez
Entrez.email = 'youremailaddress'
handle1 = Entrez.esearch(db = 'nucleotide', term = 'dengue full genome', retmax = 614)
record = Entrez.read(handle1)
IdNums = [int(i) for i in record['IdList']]
for i in IdNums:
print(i)
handle2 = Entrez.esearch(db = 'nucleotide', term = 'dengue full genome', id = i, rettype = 'gb', retmode = 'text')
record = Entrez.read(handle2)
print(record)
I ran it on my computer and it seems to work. The for loop solved the out of bounds, and adding the term to handle2 solved the calling error. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "loops, for loop, biopython"
} |
Why does `df` indicate no available space when used is much less than total size, on my VPS?
My VPS display this with `df -h`
Filesystem Size Used Avail Use% Mounted on
/dev/simfs 100G 46G 0 100% /
Does anyone have a idea to fix this ? | Yes, contact your provider and tell him he has overcommitted his storage and he needs to fix it ASAP.
Explanation: With some type of VPS servers, you don't have a disk image with a fixed and guaranteed size. Instead, your file system is really just a subdirectory of a larger file system with a certain quota which is reported in your VPS as the disk size.
Problem is that if the provider overcommits storage and the real disk gets full, you end up with the problem you are facing now: The disk is reported as full even if you only used 50% of what the VPS reports as its size. | stackexchange-serverfault | {
"answer_score": 16,
"question_score": 16,
"tags": "hard drive, vps, df"
} |
Is an Ooze a living creature?
Is an Ooze or something with Ooze traits a living creature for the purposes of things like Vampiric Touch? | If we look at the entry in the SRD we see:
> An ooze is an amorphous or mutable creature, usually mindless.
So it is, unequivocally, _a creature_.
As for _living_ , the entry doesn't say that they aren't, unlike construct:
> Since it was never alive, a construct cannot be raised or resurrected.
or undead:
> Undead are once-living creatures
And an Ooze does fulfill the major requirements of most definitions of life:
> Oozes eat and breathe
(I'll assume they reproduce, it just doesn't often come up in game except for the varieties that split when you deal them enough damage) | stackexchange-rpg | {
"answer_score": 27,
"question_score": 24,
"tags": "dnd 3.5e, monsters"
} |
Associations' traversal direction
I'm reading the book on **Domain Driven Design** of **Eric Evans** \- **Chapter 5** , concerning **associations**. One of his advices to reduce complexity of a model is to impose a traversal direction for the associations.
I quote:
> It is important to constrain relationships as much as possible. A bidirectional association means that both objects can be understood only together. When application requirements do not call for traversal in both directions, adding a traversal direction reduces interdependence and simplifies the design. Understanding the domain may reveal a natural directional bias.
How to chose a traversal direction for an association? Generally, when there is an association between two elements, it may be read and understood in the two directions. What may cause us to chose one direction over the other?
Thanks | When there's an association between entity A and entity B, you'll often find yourself using only A.B and never B.A. This may be because A is an aggregate root and is always your starting point, because you already have a reference to its A wherever you manipulate a B, etc.
I guess Evans simply suggests that you should add a traversal direction only when you need it and will use it in the code just after, as opposed to prematurely adding a traversal direction "in case we need it later". | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 7,
"tags": "domain driven design, uml"
} |
UTF-8 -> ASCII in C language
I have a simple question that I can't find anywhere over the internet, how can I convert UTF-8 to ASCII (mostly accented characters to the same character without accent) in C using only the standard lib? I found solutions to most of the languages out there, but not for C particularly.
Thanks!
EDIT: Some of the kind guys that commented made me double check what I needed and I exaggerated. I only need an idea on how to make a function that does: char with accent -> char without accent. :) | There's no built in way of doing that. There's really little difference between UTF-8 and ASCII unless you're talking about high level characters, which cannot be represented in ASCII anyway.
If you have a specific mapping you want (such as a with accent -> a) then you should just probably handle that as a string replace operation. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 6,
"tags": "c, utf 8, ascii"
} |
How can I use PHP to work with another application in the server?
I am taking some input from a form. I have a c++ program that processes the input and produces a hash value from it. How can I transfer data between the PHP script that handles the form and the c++ program that processes the input? | What you want to do is come up with a data interface between C++ and PHP. I recommend using JSON since PHP has the simple `json_decode` function.
You'll need to investigate a bit into how to save to JSON from C++, consider looking here.
Have your C++ program save what you want to use in PHP to a .json file then load the .json file in PHP with `file_get_contents` and `json_decode`. For example if you want your C++ program to generate a message you could save an object with something like `{ message : "Hello World" }` and save it to message.json.
Then in PHP do:
$file_data = json_decode(file_get_contents("message.json"));
echo $file_data["message"];
EDIT: You could also have C++ save your data to a database and read from the database with PHP. That's simple(ish). | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "php, c++, linux, server"
} |
Juniper Switching - Cheap Lab
A little bit new to Juniper here. I am working on scripting few of our switch ports. All switches are Juniper, Ex, FX, QFX, ...etc.
I have no access to a lab to test my scripts, and was looking for one. Of course Olive was suggested but really don't have the time to maintain it. Saw few ads about SSG-20, at low prices. I see it has several swich ports, and did my best to find out more, but do not see this anywhere. Can that be used as a managed switch? In other words, same Juniper switch commands (nothing crazy, basic port configuration, adding/changing description, and enable/disable) work on it? | Smallest switch would be an EX-2200c. I bought one for my home lab. It has 12 ports and most of the important features. You can even use virtual chassis functionality (with up to 2 or 4 devices).
Junosphere might also be worth a look. And I guess you already know about the Junos Fasttrack program where you can get the training materials for the "lower" certifications including switching. | stackexchange-networkengineering | {
"answer_score": 8,
"question_score": 5,
"tags": "juniper, switching"
} |
Export-SPWeb permissions
When using Export-SPWeb to export a site does it copy permissions with it? When the export is running can it still be used by others? Once the export is complete will it be usable as before? | Yes, you can continue to use the site while executing Export-SPWeb. And, if you want to include the user security settings in the site use the IncludeUserSecurity parameter | stackexchange-sharepoint | {
"answer_score": 3,
"question_score": 0,
"tags": "powershell"
} |
Trying to make an SMS Reminder Application
I am working on a web-application to make an SMS Reminder service, which takes various inputs from the user, like the user's name, his number, and the time he wants the reminder. The reminder is then sent through an SMS. I have the SMS Gateway part figured out for which I am using Zeep Mobile's API. I wanted to know how I can send an SMS on the time input by the user.
The database would have the user-id and the time, and I need to get my application to send an sms at the time. Any tutorials on similar lines would be great help.
Thanks in advance | Let's say your reminder interval is 1 minute and you are deploying on Linux.
1) Set up a cron-job to check your database every minute for possible reminders
2) If there are reminders to be sent, execute your sending script.
3) Mark sent reminders with a status (or similar) so you don't send them again. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "php, web applications, sms"
} |
htaccess 301 redirects to wrong url
So I did a 301 redirect with htaccess but dont understand why the final link is wrong?
This is what I end up with <
Rather than a clean intended <
This is my htaccess code
Redirect 301 /about-us/ /about
To me this looks fine... What have I done wrong?
I need to redirect from <
I've also tried
Redirect 301 /about-us/ | You can try using apache `mod_rewrite` instead of using `Redirect`:
RewriteEngine on
RewriteBase /
RewriteRule ^about-us/?$ /about [L,R=301] | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "apache, .htaccess, redirect, mod rewrite"
} |
How do I call pyspark code with .whl file?
I have used poetry to create a wheel file. I am running following spark-submit command , but it is not working. I think I am missing something
spark-submit --py-files /path/to/wheel
Please note that I have referred to below as well, but did not get much details as I am new to Python. how to pass python package to spark job and invoke main file from package with arguments | Wheel file can be executed as a part of below spark-submit command
spark-submit --deploy-mode cluster --py-files /path/to/wheel main_file.py | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 5,
"tags": "python, apache spark, pyspark, python packaging, python wheel"
} |
Enable external access to local website with www binding
I'm developing a website using ASP.NET & IIS. On my dev machine I've set the site's binding to be accessible using www.mysite.com address instead of < (by changing also the hosts file of the machine).
How can I enable access to this site from other PCs on the network using the same address?
Thanks! | Not sure if you want to do this but you can make an entry in your dns or just add the entry to the host file of the other PCs too. | stackexchange-serverfault | {
"answer_score": 0,
"question_score": 0,
"tags": "asp.net, iis"
} |
Connecting to Macbook from local network fails
I want to set up a web server on my macbook (192.168.0.10) accessible from my iPhone (192.168.0.11). Both device are on the same network.
* The apache server is running on the macbook and accessible locally via <
* The iPhone cannot access this page
* The macbook can ping the iPhone and the router
* The iPhone can ping the router but not the macbook
* The firewall on the macbook is off
I don't understand why all connection are not working to the mac. Is there something else than the firewall blocking these connections?
EDIT: I test on another local network to connect with another PC and it didn't work neither.
EDIT2: I'm using SecureClient on this machine to connect to my company VPN. | The SecureClient VPN tool was blocking external adress to my mac. I just disable by clicking the SecureClient icon > _Tools > Disable Security Policy_ | stackexchange-superuser | {
"answer_score": 0,
"question_score": 0,
"tags": "macos, connection, webserver, ping"
} |
Get PID from ShellExecute
I am launching a process from ShellExecuteEx, and I really need to get the ProcessID (It's part of the requirement of this class).
Somehow all the important `SHELLEXECUTEINFO` returns null. So for example if I use this code:
exInfo.lpVerb = "open";
exInfo.lpFile = "C:\\Windows\\system32\\cmd.exe";
exInfo.nShow = 5;
ShellExecuteExA(exInfo);
It launched CMD.exe. But now I need to get it's PID. `exInfo.hwnd` is returning `0`, and `exInfo.hProcess` is returning `null`. Is this normal behaviour?
I don't really want to resort to using CreateProcess(), because my function should also be able to launch documents like "C:\doc1.docx". This is just a method, in which I cannot predict what is going to be launched (So I cannot know the window title/classname from beforehand, get the hWnd from there and then get the PID).
Could somebody kindly point out my mistake? Thanks. | You need to set a flag (SEE_MASK_NOCLOSEPROCESS) in exInfo.fMask | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 4,
"tags": "c++, windows, winapi, java native interface, jna"
} |
Code signed MSI name issue, WiX
I coded my MSI installer using WiX. The MSI is also signed with my code signing certificate. When I begin its installation I get the following security warning on Windows 7:
!Enter image description here
But for some reason the _Program Name_ is nothing but the name of my MSI or anything I added to it.
Is there a way to give it some user-friendly name to display in that warning? | With SignTool.exe it is enough to set a description text from what I remember, this being used as application name in the UAC prompt. Have you tried that? (don't know if this is supported from WiX) | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 4,
"tags": "wix, windows installer, code signing, digital signature"
} |
iPhone - Detect the end of the animation
How can I detect the end of the animation of a modal view (when I do a dismiss)? (I'm talking about MFMailComposeViewController which is not created by myself...)
Thanks | Your modal view controller has a `-viewDidDisappear:` method that is automatically invoked whenever the view is removed from the screen. You can override this method in your modal view controller to do whatever you like.
Also, you may want to consider implementing the `-viewDidAppear:` method in the view controller whose view gets revealed by your modal view disappearing. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 3,
"tags": "iphone, objective c, animation, modal view"
} |
Nodejs send variable to ejs page
I have a question, is it possible to define a variable in nodejs and then use it in the ejs page? So for example var newOne = "Yes" in nodejs. And then i want to use this variable in the ejs page to check if that variable is equal to yes, in its script tag. I tried this but it always ends up as undefined variable.
How does one do this? | Yes you can do that. Suppose you have a variable in node
var newOne = "Yes";
you can use the variable in ejs, like the following.
1. You need to send the variable into the view during the rendering like below
res.render('/nameOfTheRoute', {
newOneInView : newOne
});
2. Then you can check conditions in ejs by accessing newOneInView like below
<%if (newOneInView == "Yes") { %>
// Do something
<% } %> | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "node.js, variables, ejs"
} |
how to edit left column when left.phtml is missing in magento?
I am trying to display the sub-categories from a certain category in magento in the left side bar. I found a few solutions saying I have to change the code in app\design\frontend\base\default\template\catalog\navigation\left.phtm but I only have top.phtml and verticalcollapse.phtml. However the code that displays the left column is this getChildHtml('left') ?>. This is in app/design/frontend/default/forest_classyshop/template/page/2collumn-left.phtml.
My question is where can I find the code "left" that should be in the left.phtml that's missing? | it's probably located at app\design\frontend\default\default\template\catalog\navigation\left.phtml.
Magento will look in Your Template for a file. if not there it will then look in Default for that file. If not there it will look at Base. Sounds like someone has deleted that file in Base.. I would look in app\design\frontend\YOUR_PACKAGE\YOUR_TEMPLATE\template\catalog\navigation\left.phtml Then app\design\frontend\Default\Default\template\catalog\navigation\left.phtml | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "php, html, magento, magento 1.7"
} |
How to disable Google Search?
Recently my phone started to lose charge faster. It just occurred to me to check Battery in Settings, and I saw that Google Search is responsible for 29%, Screen coming in second with 23%.
I set up Google Now a few weeks back, is it the same thing?
If not, what exactly _is_ Google Search? Is it something I actually use, and Google Search is just a collective name for them? Can I turn it off? | Google Search is the package that contains both Google Search and Google Now. I think you can disable Google Now while keeping the search part by going into `Now->Settings->Switch Google Now (first item)`.
If it doesn't solves your problem, then you can disable Google Search in `Settings->Applications->Google Search->Disable`. | stackexchange-android | {
"answer_score": 4,
"question_score": 3,
"tags": "battery life, nexus 4"
} |
Sorting and replace object key value - Javascript
I have a payload looking like this:
{ key: 1 }
How can I actually replace this payload to something like below?
{ "key.something": { anotherKey: "abc" } }
My old code to replace the payload looks something like this.
let a = { ...payload };
if (lodash.isEqual(a, { key: 1 })) {
a = {
"key.something": { anotherKey: "abc" }
};
return a;
But I think the current method I'm using is just not effective enough because there's just too many ifs later on. So how can I actually get the key value and then sort it based on the key value and then replace it just like above?
Thanks for the help | If you want to return the values based on the payload, just make a 2d array containing the value you want to replace and the replace value and loop over it
let a = {... payload};
let combinations = [
[{key: 1}, { "key.something": { anotherKey: "abc" } }],
// some more combinations
];
combinations.forEach(e => {
if (lodash.isEqual(a, e[0])) {
a = e[1];
break;
}
})
return a; | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, node.js, json"
} |
Javascript XML parsing or alternative
I'm building a Javascript preview function for a blog back-end (much like the one used on this website), and I'd like to be able to parse some custom tags that normally get parsed by PHP. I am wondering if it's possible to use the JS XML parser to parse content from a textarea that would look like:
<img=1>
Use for
<url=
purposes only!
I read on another question here once that using regex to parse things like this is a bad idea because of the many many exceptions there could be. What do you think? | Use this: <
It parses xml from a string and uses the fast native XML parsing engine from the browser.
Explanation and discussion:
< | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "javascript, html, xml, parsing"
} |
touchesbegan/moved/ended not working with xcode 6.3
I'm having the same problem as listed with the beta 6.3 here: Overriding method with selector 'touchesBegan:withEvent:' has incompatible type '(NSSet, UIEvent) -> ()'
but the fixes listed there are not working for me. I've changed this line:
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
to this:
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
The error I'm getting is: "Method does not override any method from its superclass"
Does anyone know if the fixes listed above for the 6.3 beta are really working with the final 6.3? | So I found the answer to my own question ... this was caused by a class I had already defined in my project called "Set". (that was from a tutorial from Ray W about making a candy crush game). Anyway, in Swift 1.2 they introduced their own class called "Set" and it was causing name collision problems. So I just renamed the old Set class and it all started working. UGH! | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "xcode, swift"
} |
If I scale my google cloud sql instance up, can I use the same database which exists on cloud sql instance previously
I have a question for google cloud sql. I used the mySQL instance of google cloud sql, this instance type is f1-micro.
If my service grows up, I should need more performance. In this case, can I use the same database which exists on previous cloud sql instance, if I scale my sql instance up? I'm just wondering if I can continue to use the same database(containing original data) just by shutting down the instance and rebooting to the new server specification. | Yes, changing the size of the instance does not affect the data though you will see a brief downtime while the instance is resized. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "google cloud sql, google cloud platform"
} |
Notation for collection of elements that may contain duplicates
I want to represent document `D` as a collection of words. I was inclined to do this with: `D = {w_1, w_2, ... }`. However, the curly brackets are often interpreted as sets that cannot have duplicates, while documents may contain duplicates.
Are there other brackets that I can use to represent this? | While a "multi-set" best answers the question in your title, people usually care about the order of the words in a document, in which case it's probably best to go with a sequence, and the notation for that is "$(w_i)$", or "$(w_i)_{i=1}^n$" if you want to fully decorate it.
To check if you want to go with multi-sets or sequences, ask yourself if you would consider "eat, cat, eat" and "eat, eat, cat" to be the same document or not. If the answer is "no", then go with sequences and the above notation. If the answer is "yes", then you're thinking of them as multi-sets, which sadly I don't believe have a standard notation. | stackexchange-math | {
"answer_score": 3,
"question_score": 2,
"tags": "notation, multisets"
} |
How will Ontario's HST apply to books / textbooks, which were PST exempt before?
Students (university/college) have been hit hard enough recently with tuition hikes. How will this latest cost increase affect the cost of education materials? | Books stay exempt, see this No Change list.
_Basic_ groceries also stay exempt; so your Kraft Dinner will remain the same price also. :-) | stackexchange-money | {
"answer_score": 4,
"question_score": 3,
"tags": "canada, ontario, hst, education"
} |
unable to get scim 2.0 wso2 is api for get Roles under secondary user store
I have a secondary userstore (JDBC) created in wso2 IS 5.11.0. 2 roles are added under the userstore. I am using the below SCIM 2.0 api to get the roles. but only the roles created under primary user store is listed in the response.
Under the claims list -> < -> Role -> Mapped attributes, I have added the secondary user store to the list. still not getting the response.
Is there any other configuration to be done to get it via scim api? | Since WSO2 IS-5.11.0 Groups and Roles are considered separately. Refer [[1]](
` endpoint lists out the userstore groups (both primary and secondary user stores' groups)
` endpoint lists out the Roles (Roles are basically Internal and Application Roles. You won't see any prefix for Internal roles in the list)
In your case, since you have added a userstore group, it need to be managed via ` | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "wso2, scim, wso2 identity server"
} |
Bat file directory listing, remove text enries
i have a simple bat file that list directory files only.
if exist "output.txt" del "output.txt"
dir /a /b /-p /O:N >>output.txt
when text file is created it also adds the bat file and the output.txt entries in the text file. I would like to remove those 2 entries to make the final list clean.
Thanks and hope i explained it correctly | Assuming that the batch file is named `list.bat`, with the help of `findstr` you can exclude the two files from the `dir` output.
Replace the second line with
dir /a /b /-p /O:N |findstr /vi output.txt|findstr /vi list.bat >>output.txt
BTW, the `if exist...` line is useless as the file `output.txt` is re-created by the `dir` command redirection before it starts to list the files. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "batch file"
} |
How to add a new user profile field to Dnn?
I want to add a new profile field in the DNN portal to be displayed in the registration form. I could not find it inside the DNN portal menu. | in dnn7 go to this address : Admin -> Site Settings -> User Account Settings -> Profile Settings -> Add New Profile Property
in dnn9 go to this address : Settings -> Site Settings -> Site Behavior -> User Profile -> Add Field | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "dotnetnuke, dotnetnuke 7, dnn9"
} |
How to automatically exit browser after youtube video has finished playing
Is it possible to exit the browser ( firefox) automatically after a video has finished playing ? Through some extensions / scripts ?
I need this because I want to automate measuring of bandwidth used while a youtube video played in firefox. | Here is the javascript API of youtube:
<
player.getPlayerState():Number
Returns the state of the player. Possible values are unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5).
You can handle it by javascript and close page after finished. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "javascript, flash, firefox, youtube, bandwidth"
} |
"ssh example.com" hangs but "ssh example.com bash -i" does not
everyday I encounter a very strange phenomenon.
From my university internet connection, sshing to my machine ("ssh example.com") works without any problems.
From my home adsl, "ssh example.com" my console gets stuck with this message:
debug1: Server accepts key: pkalg ssh-rsa blen 533
debug1: Enabling compression at level 6.
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
Sometimes it might let me in but in most of the cases not. The funny thing is that if I execute "ssh example.com bash -i" I get logged in immediately. | I finally found the source of the problem. It has to do with SSH type of service (ToS) TCP packets.
When you ask for a regular ssh teminal, ssh sets the TCP packet type of service (ToS) to "interactive". My router in my residence blocks those packet types!
Using netcat, the tunneled TCP packets get no type of service directives. Thus, if you tunnel all your ssh traffic through netcat, you reset the ToS of the TCP packets to the default ones.
In .ssh/config, you have to set:
Host *.example.com
ProxyCommand nc %h %p
So, each time you try to ssh to example.com, netcat will be called and will tunnel the packets. | stackexchange-stackoverflow | {
"answer_score": 12,
"question_score": 6,
"tags": "authentication, ssh, netcat"
} |
Various random website cannot be reached (cannot allocate memory)
With process of elimination and testing the problems on 2 different Macs, 4 different networks, and many different browsers, I have isolated the cause of my network issue to be the actual Mac.
Certain sites, even though they are up, are completely unreachable by one of my Mac. Visiting on Chrome says:
Error code: ERR_OUT_OF_MEMORY
Safari says:
The operation couldn't be completed. Cannot allocate memory
`ping` says:
ping: sendto: Cannot allocate memory
I have no idea what to do next. I check my Network setting and no proxies are on. Is there any way to reset my network settings? Or any commands to provide more information to allow more diagnostic?
Thanks. | What fixes it for me for wireless connection is this:
1. Go to network preferences
2. Open the connection data
3. Open "Advanced..." properties
4. Go to "TCP/IP" tab
5. Set "Configure IPv4" to off (remember the previous setting)
6. Click "OK" and then Apply
7. Wait for the connection to be reset
8. Go back to TCP/IP and re-enable IPv4 to the previous setting
9. Click "OK" and then "Apply" again
After the connection restores, the memory errors are gone. Still no idea why it happens or why this fixes it, but seems to work for me and is much faster than rebooting. | stackexchange-apple | {
"answer_score": 3,
"question_score": 2,
"tags": "network, macos, internet"
} |
A relation between quadratic Weyl tensors
When I deal with the variation of Lagrangian with quadratic Weyl tensors, I met some interesting terms $$-\frac{1}{4}g_{ef}C^{abcd}C_{abcd}+C_{eabc}C_{f}^{\ \ abc},$$ It is obviously traceless, but is it equal to $0$? I used Maple to calculate the results of some metrics and the answer is $0$. So I try to use the definition of Weyl tensor to prove it and I obtain that it is equal to $$R_{eabc}R_{f}^{\ \ abc}-\frac{1}{4}g_{ef}R^{abcd}R_{abcd}+2R^{ab}R_{eabf}+g_{ef}R_{ab}R^{ab}-2R_{ea}R_{f}^{a}+RR_{ef}-\frac{1}{4}g_{ef}R^{2}$$ but I can't prove it is $0$. So I wonder if it is a general result. | This combination of Weyl tensors vanishes only in $d=4$, and it follows from what is known as the Lanczos identity, which relates the double-dual of any traceless tensor with the symmetries of the Weyl tensor in $d=4$ to the original tensor: $$ \frac14 \epsilon_{abmn}\epsilon^{cdpq} {C^{mn}}_{pq} = -{C_{ab}}^{cd} $$ This is discussed, for example, around equation (A.15) and (52) of < | stackexchange-physics | {
"answer_score": 2,
"question_score": 0,
"tags": "homework and exercises, general relativity, differential geometry, tensor calculus"
} |
What is Atmel's 2x5 ICSP connector called?
I'm looking for a male connector that fits in the left female connector shown in the image. My goal is to break each lead out to holes on a breadboard. What is that kind of 2x5 connector called?
!enter image description here
Searching for ICSP connectors doesn't help me. | Those are 0.100", or 2.54mm pitch headers. They are sold in long strips of single or double rows and you can break off however many pins you need. There are also versions with shrouds and various keying mechanisms to prevent backwards connection.
Here's the basic type:
!male header
Shrouded types (like starblue mentions in comment) look like this:
!shrouded male header | stackexchange-electronics | {
"answer_score": 2,
"question_score": 0,
"tags": "cables, terminology, icsp"
} |
"une plus vieille femme" or "une femme plus vieille"
"She applied for the job, but they decided to hire an older woman with more experience."
> Elle a appliqué pour le poste, mais on a décidé d'embaucher une plus vieille femme avec plus d'expérience.
Normally _vieille_ precedes the noun, but when it comes with the comparative _plus_ , should it be placed after the noun instead?
> ... on a décidé d'embaucher une femme plus vieille ...
I tried to find a reference on this but failed. Maybe I didn't look for the right term. | First, use " _plus âgé/âgée_ ", like Simon Déchamps said it's often rude to say " _vieux/vieille_ ".
Second, while " _plus vieille femme_ " can be correct sometimes, here you would have had to go with " _une femme plus vieille_ ".
But there is no problem with " _âgé_ " because you can't say " _plus âgée femme_ ". So you answer is :
> On a décidé d'embaucher une femme plus âgée avec plus d'expérience. | stackexchange-french | {
"answer_score": 2,
"question_score": 0,
"tags": "grammaire, ordre des mots, comparatifs"
} |
How to disable registration new users in Laravel
I'm using Laravel. I want to disable registration for new users but I need the login to work.
How can I disable registration form/routes/controllers? | Laravel 5.7 introduced the following functionality:
Auth::routes(['register' => false]);
The currently possible options here are:
Auth::routes([
'register' => false, // Registration Routes...
'reset' => false, // Password Reset Routes...
'verify' => false, // Email Verification Routes...
]);
For older Laravel versions just override `showRegistrationForm()` and `register()` methods in
* `AuthController` for Laravel 5.0 - 5.4
* `Auth/RegisterController.php` for Laravel 5.5
public function showRegistrationForm()
{
return redirect('login');
}
public function register()
{
} | stackexchange-stackoverflow | {
"answer_score": 323,
"question_score": 176,
"tags": "php, laravel"
} |
Masculine country or feminine country
How do you know if a country is feminine or masculine? If you say "in a (feminine) country", you would use en, but how would you know if the country is feminine or not? Is there a rule of thumb? | This map may be helpful for remembering the genders of countries. Here's another one which includes information on the use of articles. | stackexchange-french | {
"answer_score": 1,
"question_score": 3,
"tags": "genre, noms propres, toponymes"
} |
How do I subscribe to an Outlook.com calendar from my Google calendar?
All the help I find is for the opposite direction. I need my Outlook.com calendar to show up in my Google calendar, as the events I create in my windows phone don't sync to my main Google calendar.
I am not using the Outlook windows application.
I attempted to share the calendar from Outlook.com to my gmail address, but get an error:
> Sharing error
> Sorry, this invitation isn't valid anymore. The sender may have taken away your permission, or you may have already declined this invitation. If you'd like to see this calendar, ask its owner to share it with you again.
If there is an alternative solution that accomplishes the result I want (my Outlook.com events showing up in Google calendar) that would be OK. | From Marco_Mi. replied on May 6, 2013
1. Sign in to Calendar _(Outlook.com)_
2. On the toolbar, click Share
3. Select the calendar that you want to export/embed.
4. Click Get a link.
5. Under Show event details (click Create) Note: If step number 5 is already performed, just skip it and click Link to event details
6. Copy the link that you needed and paste it on the desired program/website. | stackexchange-webapps | {
"answer_score": 0,
"question_score": 3,
"tags": "calendar, google calendar, outlook.com"
} |
AngularJS: How to load json feed before app load?
I'm just learning angularJS (using angular-seed) and I need to load my site config from a JSON feed before the rest of the site loads.
Unfortunately, using $http or $resource doesn't return the feed in time for the rest of the app to load.
What is the correct way to force the app to load this data before the rest of the app? | You have to use the Controller.resolve method. Check out Misko's (one of the core Angular developer) answer < | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 9,
"tags": "json, angularjs"
} |
In $\mathbb R^p$:Every open subset is the union of a countable collection of closed sets & every open set is the countable union of disjoint open sets
Prove/Disprove that :
$(i)$ Every open Set in $\mathbb R^p$ can be written as the union of countable number of disjoint open Sets.
$(ii)$ Every open subset of $\mathbb R^p$ is the union of a countable collection of closed sets.
I was able to look at some similar posts asking this problem; but one seemed to be using the other and vice versa and seem convoluted.
Unfortunately, I have no idea on how to move forward. Can anyone please help me in preparing a proof for both of these problems?
Thank you for your help. | Show:
1. Every open set is union of balls with rational radius and rational center.
2. Every open ball is a countable union of closed balls.
This gives _(ii)_. For _(i)_ , given two points in your open set, say that they are equivalent iff there is a continuous path between them, completely contained in the open set. Argue that this is indeed an equivalence relation, and that its components (equivalence classes) are open. Now use that $\mathbb Q^n$ is dense in $\mathbb R^n$, so there can be no more than countably many equivalence classes. | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "real analysis, general topology"
} |
KeyError: 'user_id'
I wanna put dictionary data to the model(User) .I wrote like
for row_number, row_data in dict_data.items():
user1 = User.objects.filter(corporation_id=row_data['corporation_id'])
if user1:
user1.update(user_id=dict_data['user_id'])
`dict_data` is dictionary type like
{'00010': OrderedDict([('corporation_id', '00001aB3D4'), ('user_id', '11111'), ('name', 'Tom'), ('age', '20')])}
I wanna put `dict_data` data's `user_id` to `user_id` column of `User`model. Definitely, `dict_data` has `'user_id'`, but I really cannot understand why this error happens.How can I fix this? | Instead of:
dict_data["user_id"]
You need to use the unpacked element:
row_data["user_id"]
Or, in case you really want to use `dict_data` you have to first access the corresponding dictionary value:
dict_data[row_number]["user_id"] | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "python, django"
} |
How to check for a necessary input of raw_input?
I've started to learn python only a day ago, seems to be easy, but still have some questions :)
how to write a script which have to check necessary input of raw_input?
I mean, the script must stop if a user have not entered any case and just hit enter on raw_input... | ans = raw_input('Enter: ')
if not ans:
print "You entered nothing!"
else:
print "You entered something!"
If the user hits enter, `ans` will be `''`. and `''` is considered `False`, thus as the condition is `True` (`not False`), the if block will run.
If you wish to continually ask the user for an input, you can use a while-loop:
ans = ''
while not ans: # While the input given is an empty string
ans = raw_input('Enter: ') | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "python, input"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.