INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Is there a possibility to delete a string that starts with a ">" and ends with a newline in postgresql via sql update statement?
Lets say I have a database with about 50k entries in a column called `content`. This column contains strings which causes problems to my further work.
Now here is the thing I need to do it for all the rows inside of that table.
Any Ideas? Here an example:
'user wrote:
-----------------------------------------------------
> Some text
> that vary too much and I dont need it actually
> here is end of the text
The text I actually need.'
I would like to remove all of the unnecessary part so the only thing that is left is in this case :
'The text I actually need.' | This should delete all lines that start with a `>`:
regexp_replace(textcol, E'^>.*\n', '', 'gn');
The `g` flag is needed to delete _all_ such lines, and the `n` flag makes the `^` match the position right after each line break.
I use an "extended" string literal (the leading `E`) so that I can write a newline as `\n`. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -2,
"tags": "sql, postgresql, data manipulation"
} |
Copying .gif images to clipboard using UIPasteboard through code [iOS]
I want to copy .gif images to clipboard, so as user can paste that gif images from application to mails, etc...
I have tried :-
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"
UIPasteboard *pasteBoard=[UIPasteboard generalPasteboard];
[pasteBoard setImage:[UIImage imageWithData:data]];
but it copies in format of .png and not .gif. How can I copy .gif image with its animation to clipboard which can be used as paste option in other application?
Application < already does this.
Please help me.
Thanks in advance | I found solution for same :-
This is my code which helped me:-
@import MobileCoreServices;
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"
UIPasteboard *pasteBoard=[UIPasteboard generalPasteboard];
[pasteBoard setData:data forPasteboardType:(__bridge NSString *)kUTTypeGIF];
`@"com.compuserve.gif"` comes from <
Hope this helps someone... :) | stackexchange-stackoverflow | {
"answer_score": 23,
"question_score": 9,
"tags": "iphone, ios, objective c, animated gif, uipasteboard"
} |
How to find out the activity which increasing the response time of the Sql Server?
We are using SQL Server 2008 as our database server. Recently we came to know, by using a 3rd party tool, that the response time of our database server is increasing at a specific time for example at night 1AM to 4AM. That 3rd party tool provides no information about the activity which is causing this.
Some Facts:
1. We are using SQL Server 2008.
2. We have scheduled some SQL Jobs but their execution time is different; not in the range where the response time is high.
I hope my question is clear enough if not please let me know. | I highly recommend using Adam Machanic's excellent diagnostic stored procedure sp_WhoIsActive. I've got an sp_WhoIsActive tutorial on my blog. Run it during the slow time window as I describe in the video, and it'll show the active queries, what they're waiting on, and their execution plans.
Keep in mind, though, that this is more of a DBA tool than a "here's-your-problem" tool. This is where a database administrator usually has to step in and do diagnostic work. If you're confused by the output of sp_WhoIsActive, check out the book Troubleshooting SQL Server. | stackexchange-dba | {
"answer_score": 4,
"question_score": 0,
"tags": "performance, sql server 2008"
} |
Dúvida ao fazer um ranking utilizando django!
Estou fazendo um site de um jogo utilizando django e quero fazer um ranking baseado na pontuação de todos os usuários! Por enquanto está assim:
**views.py** :
def index(request):
perfis = Perfil.objects.all().order_by('-pontuacao_ultima')
return render(request, 'index.html', {'perfis' : perfis})
**index.html** :
{% for perfis in perfis %}
<tr>
<td>1</td>
<td>{{ perfis.nome }}</td>
<td>{{ perfis.pontuacao_ultima }} pontos</td>
</tr>
{% endfor %}
No caso ele já está ordenando, porém eu estou com dúvida no que fazer para o número da posição variar de acordo com a posição real do player(primeiro, segundo, etc). Por enquanto ele está mostrando apenas o 1 (coloquei manualmente no html). | Utilize a tag `forloop.counter`:
{% for perfil in perfis %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ perfil.nome }}</td>
<td>{{ perfil.pontuacao_ultima }} pontos</td>
</tr>
{% endfor %}
Existem outras tags com diferentes funções, como começar contando a partir de zero `forloop.counter0`, verificar se é o primeiro laço do loop `{% if forloop.first %}`, etc.
Mais detalhes podem ser vistas na documentação. | stackexchange-pt_stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "python, python 3.x, django, django templates"
} |
chose path fopen with variable file name in C
Let's say I have a variable "NomFichier" that receive the name of my .bin file.
For now i have :
FILE fichier = fopen(NomFichier, "wb");
So I create my .bin in "Projet AP3\Projet\Code" with my code files.
What could I write to create my file in this path : "Projet AP3\Fichiers .txt et .bin" ? (I would like to write a relative path not an absolute path). | If you use:
char const* NomFichier = "myfile.txt";
to create the file in the directory "Projet AP3\Projet\Code", then you can use:
char const* NomFichier = "..\\..\\Fichiers\myfile.txt";
to create the file in the directory "Project AP3\Fichiers". | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "c, variables, path, fopen"
} |
Typesafe effectively read only java collections?
I'm searching for a java library for collections with no methods that allow for mutations. effectively immutable read only collections.
By that I mean, NO METHODS. Not like the usual Java immutable collections that have methods like `add` or `remove` that throw an exception when called. No... I want the compiler to let me know I'm trying to do something not allowed, instead of some error at runtime.
I know it exists because I've used it, but I cannot remember the name of such library. | Eclipse Collections: <
Their own guide on immutable collections says:
> All of the basic containers in Eclipse Collections have interfaces for both mutable and immutable (unchangeable) forms. This departs somewhat from the JCF model, in which most containers are mutable.
>
> An immutable collection is just that - once created, it can never be modified, retaining the same internal references and data throughout its lifespan. An immutable collection is equal to a corresponding mutable collection with the same contents; a `MutableList` and an `ImmutableList` can be equal. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "java, immutability, readonly collection"
} |
Problem with setContentBorderThickness:forEdge: not actually setting the value
I'm trying to use `setContentBorderThickness:forEdge:` to create a bottom bar in a Cocoa application.
mipadi was on to something, but in testing it out, I think maybe this is a slightly different problem:
-(void) adjustContentBorderBasedOnArrayControllerSelection{
if(([[self.resultsArrayController selectionIndexes] count] == 0)){
[[self window] setContentBorderThickness:40.0f forEdge:CGRectMinYEdge];
NSLog(@"%f", [[self window] contentBorderThicknessForEdge:CGRectMinYEdge]);
} else {
[[self window] setContentBorderThickness:60.0f forEdge:CGRectMinYEdge];
NSLog(@"%f", [[self window] contentBorderThicknessForEdge:CGRectMinYEdge]);
}
}
Both of those `NSLog()` messages show the thickness value is 0.0 even after I explicitly set it. Anyone know what's up with that? | By any chance have you checked to make sure [self window] isn't nil? Do you have your outlet setup right? I get that behavior if the outlet to the window isn't set. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "cocoa, nswindowcontroller"
} |
How to use lerp() method in flutter and what are the use cases?
I actually came across the lerp function in many of the Flutter animations. I studied about linear interpolation. But I wonder how it's used in flutter and what are its use cases. could anyone explain it? | It linearly interpolates between two values, for example:
var color = Color.lerp(Colors.white, Colors.black, 0.5);
var value = lerpDouble(10, 20, 0.5); // 15
The `color` here would have a middle value between white and black. | stackexchange-stackoverflow | {
"answer_score": 20,
"question_score": 15,
"tags": "flutter"
} |
what is the difference between navigator "object" And Navigator "Function" in browser console
I have searched the web for an answer but all links talk about navigator object.
!Screen shot of browser console | When you type `navigator`, you're accessing the `window.navigator` property, which returns an instance of the `Navigator` object representing the current browser state.
The `Navigator` function is the constructor for that object, but it's implementation dependent, hence it being shown as native code. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "javascript, browser"
} |
Inequality of cardinals: $AB<A^B$ for $B\geq |\mathbb{N}|$
Let $A$ and $B$ be cardinal numbers. Assume $B\geq |\mathbb{N}|$. Is there an easy proof of $$ AB<A^B? $$ (Note the strict inequality!) | No, as equality can be obtained:
Let $A:= 2^\omega$ (continuum) and let $B:= \omega$.
Then $AB=\max(A, B) = A$ and $A^B= 2^{\omega\cdot\omega} = A$. | stackexchange-math | {
"answer_score": 4,
"question_score": 2,
"tags": "inequality, cardinals"
} |
"List Injection" in Unity?
I've got a project coming up that will involve connecting to one to many backend systems through the same interface; let's call it IBacksideProvider.
I'd like to use Unity to inject these providers at runtime. The problem is that since we're talking about 1...n backend systems, I'd need to register 1...n implementations of IBacksideProvider. Unity doesn't support this out of the box.
This blog post suggests that it can be done, however. I'm wondering if anybody has done this or has an idea how to go about working Unity so as to be able to do this. TIA. | Any reason why this wouldn't work? <
> To retrieve a list of object instances from the container based on named registrations, use the ResolveAll method and specify a value for the object type (the registration type). The ResolveAll method returns an IEnumerable generic List of the non-default (named) registered types that you can iterate through in code to examine each object.
IEnumerable<IMyObject> objects = myContainer.ResolveAll<IMyObject>(); | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": ".net, dependency injection, inversion of control, unity container"
} |
how to handle FATAL EXCEPTION IN SYSTEM PROCESS: ActivityManager and java.lang.OutOfMemoryError: [memory exhausted]
I have a device (samsung galaxy fit). When I turn on the device I can't go to the Homescreen and it just keeps loading. When i connect the device and see the logcat, my logcat error showed -
"FATAL EXCEPTION IN SYSTEM PROCESS: ActivityManager and java.lang.OutOfMemoryError: [memory exhausted]"
How to handle it? | there are some way to solve out of memory error
first recycling the bitmap like this
bmp.recycle();
bmp = null;
second using the garbage collector
System.runFinalization();
Runtime.getRuntime().gc();
System.gc();
but it'll be better if you post some of your code here so I and the other people can help you more :) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "android"
} |
Streamming data to Druid Server
I have ad log data and I want to send it real-time to Druid server. But, the issue is that between Tranquility and Kafka. Which is the best method to ingest data real-time. Because, when using kafka it make a bundle of error. I try to use Tranquility. Can anyone who have experiences on this issue help me ? Thanks a lot. | The best way is to use the new kafka indexing service. This service is independent from tranquility and has better guaranties. Please read this doc < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "java, streaming, real time, druid"
} |
How can I write a RegEx that only allows certain characters?
I'm writing a small script (similar to SO's tag RegEx) that only allows the following characters: `[a-z 0-9 + # - .]` But I can't figure out the right syntax:
I've come up with this:
`ReReplace(myString, "[A-Z]", "", "ALL")` which removes capital letters. I'm not sure how to include the special characters in the expression, however.
The ReReplace() I'm using is a ColdFusion function. | `[^a-z0-9+#\-.]` should work. The `^` symbol within the `[]` means "Everything that's not in this list".
I'm not 100% on ColdFusion and if you'll need to escape the `#` but if you find any issues, just escape the other special characters. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 1,
"tags": "regex, coldfusion"
} |
create <ul> & <li> dynamically from database using c# in Asp.net
I need to create dynamic menu using and submenu using
* dynamically using c# code in Asp.net and pass this to .aspx page | use the **ASP.NET Menu Control** and set the **RenderingMode to List** and bind it to any datasource that respects the IHierarchicalDataSource Interface
A nice tutorial is found here | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -3,
"tags": "asp.net"
} |
Position child div outside parent div (left/top)
I am creating a horizontal accordion timeline but am having issues with child div within them. Here is an example - without the jQuery in place:
<
The GREEN div is placed within the 3rd 'pink' vertical panel div. I want this to centre to the 3rd div - that is to have it floating out over 2nd div - outside the parent div. Using left/top will only position it to the outside of the page. I've have played around with 'position' on outer and inner divs but with no luck.
Would anyone out there have a solution? Thanks in advance. | mess around with `margin: 0px;` you can give this negative values such as `margin-left: -5px;` | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "html, css, layout, position"
} |
MySQL Update if exists else insert - On Duplicate Key confusion
I want to write a statement to insert into the database if no record is found and update the existing record if it already exists.
My table is like so:
**ID** | Value | UserID | VoteID
1 10 567 54
2 19 600 78
I want to do the following (written in semi-pseudo):
IF EXISTS (SELECT ID FROM table WHERE UserID = 600 AND VoteID = 78)
UPDATE table SET Value = 100 WHERE UserID = 600 AND VoteID = 78
ELSE
INSERT INTO table (Value, UserID, VoteID) Values(100, 600, 78)
How does one use 'On Duplicate Key' in this situation, it at all? Thanks | INSERT INTO table (Value, UserID, VoteID)
VALUES (100, 600, 78)
ON DUPLICATE KEY UPDATE Value = 100 | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 2,
"tags": "mysql"
} |
Intuitive explanation of Nakayama's Lemma
Nakayama's lemma states that given a finitely generated $A$-module $M$, and $J(A)$ the Jacobson radical of $A$, with $I\subseteq J(A)$ some ideal, then if $IM=M$, we have $M=0$.
I've read the proof, and while being relatively simple, it doesn't give much insight on why this lemma should be true, for example - is there some way to see how the fact that $J(A)$ is the intersection of all maximal ideals related to the result?
Any intuition on the conditions and the result would be of great help. | Suppose your module is of finite length. Then you can consider on it the so called _radical filtration_ , which organises the module into an onion-like thing, with elements of the maximal ideal pushing elements of the module farther in from their starting layer to one right below and, moreover, each layer obtained from the one above it in this way.
Now, the condition $\mathfrak m M=M$ tells you that the outermost layer of the module is actually empty: obviously, then, there is not much in the whole thing and $M=0$. We have just discovered Nakayama's lemma!
If your module is arbitrary, exactly the same happens. | stackexchange-math | {
"answer_score": 27,
"question_score": 35,
"tags": "abstract algebra, intuition, commutative algebra, modules"
} |
Aggregate values into list like string and then cast to true list datatype
df = pd.DataFrame([
["a", 1],
["a", 2],
["b", 5],
["b", 11]
])
df.columns=["c1","c2"]
grouped = df.groupby(["c1"])["c2"].apply(list)
grouped = grouped.reset_index()
grouped["c3"] = "[11,12]" #add list like string manually
#grouped["true_list_c2"] = grouped["c2"].apply(eval)
grouped["true_list_c3"] = grouped["c3"].apply(eval)
print(grouped)
If try to convert manually added column "c3" to true python list, it works.
But if try same for aggregated column "c2", raises error: `eval() arg 1 must be a string, bytes or code object`
What is reason? what is difference between "c2" and "c3" columns? | The aggregated column "c2" is a series of lists, eval doesn't accept that. If you cast it to str `grouped["true_list_c2"] = grouped["c2"].apply(str).apply(eval)` (just like "c3") it works just fine. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, pandas"
} |
while returing values in single line
I am using ajax and returning values by the following method
$query = mysql_query("SELECT DISTINCT * FROM symptom WHERE symptom LIKE '%$key%'")or die('couldnt select');
while(($row = mysql_fetch_array($query))!=false){
echo $row['disease'];
}
but the result received in ajax function shows the result like
streppneumonia
instead of
strep
pneumonia
What am i doing wrong?I just can't figure out the problem here. | when using ajax and returning multiple values, send it in the json format. You cannot distinguish the multiple values although you can break with break tag on the client side:
<?php
$query = mysql_query("SELECT DISTINCT * FROM symptom WHERE symptom LIKE '%$key%'")or die('couldnt select');
while(($row = mysql_fetch_array($query))!=false){
$diseases[] = $row['disease'];
}
echo json_encode($diseases);
?>
Later, decode by js on the client side | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, ajax"
} |
Quantity of active connections in SQL Server 2014
How can I monitor the quantity of active connections in SQL Server 2014 using SQL Server 2014 Management Studio? | SELECT * FROM sys.dm_exec_sessions | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "sql server"
} |
How to process array returned from pgsql?
in php i get an array from pgsql:
$res = $db
->query( "SELECT myarray FROM arrays WHERE array_name=smth" )
->fetchRow();
exit (json_encode($res));
Type in pgsql is integer[]
But in JS I get JSON with one string "{1,2,3,...,}" How to get in 'array-way' this data? | PDO does not do any kind of type translation, everything is returned as strings. So you will have to parse the string using explode() and build a PHP array yourself. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "php, arrays, json, postgresql"
} |
URL "http://.../js/myscript.js" fetches the source for myscript.js. Why doesn't it run the script?
When I enter a URL like " in my browser it returns the source for the script. I would like the server to run the script and return the result. I assume that server is using node.js. | Typing a url with the name of a file will just display the content inside the file. Imagine it like copying a path to a file on your computer, pasting that path in your browser and you will be able to read the file, but it won't be executed. It's the same thing. Actually running it, you'll have to do that in your code. | stackexchange-stackoverflow | {
"answer_score": -1,
"question_score": -2,
"tags": "javascript, node.js"
} |
Rails 3 - Routing to a user profile
Greetings all, newbie to Rails here. I'm currently having issues routing /profile to the current user's profile.
My route is as follows:
> match "profile" => "users#show"
However, this is hitting me with the "Couldn't find User without an ID" error. I know it has to do with my show method in the Users Controller. That code is simply:
> def show
> @user = User.find(params[:id])
> end
Now, I could add another method in my Users controller with "@user = current_user" and it works fine. However, it seems a bit redundant and would also require a copy of the show view page. From what I've gathered with Rails, it's all about keeping things neat and tidy.
I would appreciate it if someone could point me in the right direction. Thank you. | RailsGuides states:
_Because you might want to use the same controller for a singular route (/account) and a plural route (/accounts/45), singular resources map to plural controllers._
So I think you want to change your code to be the following
def show
@user = !params[:id].nil? ? User.find(params[:id]) : current_user
end | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 2,
"tags": "ruby on rails 3, routes"
} |
Why does to_be_bytes() and to_le_bytes() do the opposite of what I expect here?
Maybe the question should be "Why do I expect to_be_bytes() and to_le_bytes() to do the opposite here?", but anyways, here is the situation:
fn main() {
let buf: [u8; 2048] // Buffer I use to receive UDP messages
let (_, entry, _) = unsafe { buf[14..].align_to::<u16>() };
// In memory entry looks like: 00 44 16 15 21 04 03 5a 03 67 03 6a 03 64 88 91
let [first, second] = entry[0].to_be_bytes();
assert_eq!(first, 0x44);
assert_eq!(second, 0x00);
}
Shouldn't it be the opposite? Isn't big endianness like preserving the order in memory? | Big endian means the high byte is stored (or transmitted) first, meaning at the lowest address. Intel processors are little endian, meaning the low byte is stored in the low address.
There are some advantages to each, but generally big endian is preferred, which is why network protocols and portable data formats are usually big endian. Intel remains little endian for compatibility with older versions. Some CPUs have modes that can switch between the two, but Intel never did that. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "rust, endianness, bytebuffer"
} |
Automatically remove >100MB files from git commits to github
I don't want to push >100MB files to my repos as data connectivity is a constraint for me.
**Is there any way, any script that automatically removes >100MB files** (irrespective of their file format) **from my commits?**
Solution needs to be preferably with a warning along with a list of files it is removing from commits
doesn't require me to type long commands (git or otherwise)
simple and easy to use with any new repo
**P.S.**
I know there is 100MB limit to adding and pushing files and we get error while pushing to the github server.
I am not interested in pushing data through git lfs service.
I have been using data type omissions in `.gitignore` file. However, often I like to commit `*.pkl` (python pickle files) that are <100MB | This is probably what you are looking for. This is a pre-commit hook that will reject large files. The script is not so complicated so you should be able to adapt it to your own requirements if needs be. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "git, github"
} |
How to pack an arduino project in a box
I made a project with Arduino using a breadboard. Everything is working, but nothing is soldered in place. So, for example, I cannot put it outside, otherwise after the first wind, everything will break :-)
I would like to pack it in a box and actually used as a gadget. Can anyone suggest ways to do this? For example, are there any breadboard + screws that I could use, without having to solder my Arduino? | I've seen Pelican cases being popular for this kind of thing. There are some videos of people using them: < and <
Otherwise, to make a sturdy Arduino circuit without a breadboard, I'd suggest using Perfboard to solder the components in. Check out < for a great tutorial on doing this. It is more work than a breadboard, but not too much and worth it for a very solid Arduino device. | stackexchange-electronics | {
"answer_score": 8,
"question_score": 5,
"tags": "arduino"
} |
How to make a button move randomly when pressed
I've searched everywhere to try and find an answer to this, but any answers that I've found don't work for me... I want to make a button more randomly when pressed. I know this is simple, and xcode doesn't pick up any problems. When I run my code the simulater runs fine, apart from the fact that the button doesnt move. Here is the code I used;
-(IBAction)Counter {
[self moveButton];
}
-(void)moveButton {
int xCo = arc4random() %200;
int yCo = arc4random() %200;
CGRect frame = Butoon2.frame;
frame.origin.x = xCo;
frame.origin.y = yCo;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.001];
Butoon2.frame = frame;
[UIView commitAnimations];
}
Thanks very much for your input! | Try this:
-(IBAction)Counter:(id)sender {
[self moveButton];
}
-(void)moveButton {
int xCo = arc4random() %(int)(self.view.frame.size.width-Butoon2.frame.size.width);
int yCo = arc4random() %(int)(self.view.frame.size.height-Butoon2.frame.size.height);
CGRect frame = Butoon2.frame;
frame.origin.x = xCo;
frame.origin.y = yCo;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.001];
self.Button2.frame = frame;
[UIView commitAnimations];
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ios, objective c"
} |
run timer triggered azure function locally on MAC (inside docker)
I am trying to run a timer triggered nodejs azure function locally on MAC (inside docker) but getting the following error:
The listener for function 'Functions.MyTimerFunction' was unable to start. Microsoft.WindowsAzure.Storage: Connection refused. System.Net.Http: Connection refused. System.Private.CoreLib: Connection refused.
And when I am trying to trigger the function using HTTP post I get the following error:
System.Private.CoreLib: Exception while executing function: Functions.DomainVerifier. Microsoft.Azure.WebJobs.Host: Exception binding parameter 'myTimer'. Microsoft.WindowsAzure.Storage: Connection refused. System.Net.Http: Connection refused. System.Private.CoreLib: Connection refused.
this is in my `local.settings.json` file:
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsSecretStorageType": "files",
Any help is appreciated. | I can reproduce this error, I test with local windows pc. You get this error when you use `UseDevelopmentStorage=true` and `Storage Emulator` is not start.
So set the `AzureWebJobsStorage` with your storage connection or start `Storage Emulator` on your local environment. After start the Storage Emulator it will work .

filenames_Aqua.sort()
Now i have a list of 10 files. Following the introduction from Satpy:
global_scene = Scene(reader="modis_l1b", filenames=filenames_Aqua)
The following error message happen:
ValueError: Could not load data from file /MODIS_Aqua/Calibrated_Radiances_5-Min_L1B_1km/MYD021KM.A2017131.1320.061.2018032101913.hdf: SD (15): File is supported, must be either hdf, cdf, netcdf
Any ideas?
Thanks. | I'll repeat my comment here so this question can be considered resolved (you'll need to select this as the accepted answer).
The error message you are getting is coming from the underlying pyhdf library and not Satpy. This suggests your HDF4 file is corrupt in some way or maybe not actually an HDF4 file. You could try running `ncdump -h your_file.hdf` on the command line and if it succeeds then that suggests the file is NOT corrupt.
As you commented, it seems the files from Earthdata are corrupt in some way. The same files from LAADS are fine. If you're up for it, I would recommend contacting the Earthdata group about the issues you've discovered. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "python, hdf, satpy"
} |
How to get permalink to a specific WooCommerce endpoint?
Hi I am looking how to get a permalink to a woocommerce my account page endpoint. For example edit-address or orders.
I tried this which I know can't possibly be right, it also appends a 0 onto the end of the link.
get_permalink( get_option('woocommerce_myaccount_page_id') )+"orders"; | Replace your code with this
get_permalink( get_option('woocommerce_myaccount_page_id') ) . "orders";
PHP concatenation is dot symbol not plus symbol. < Your code seems right only | stackexchange-stackoverflow | {
"answer_score": -2,
"question_score": 1,
"tags": "wordpress, woocommerce, permalinks"
} |
Threads associated with the same process
Hi guys im having trouble finding the answer to this question. I think the answer is C but wanted to double check if i was correct. Thanks.
Which ONE of the following statements is FALSE. Threads associated with the same process are able to ... 2 (a) control their associated process. (b) run in parallel. (c) block themselves. (d) access data in other processes. | I'd guess the answer they're after is (d). The other answers are clearly true. Since each process has its own address space, threads in one process can't directly access data in another process. To do such communication, you typically start by moving the data _out_ of one process, such as putting it into a pipe or FIFO. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "multithreading, process"
} |
Java Opensource E-Commerce solution
I believe there are a lot of similar questions even on stackoverflow. But most of them are dated 1-2 years ago. Sorry about same question again.
Could you suggest easy to run and tweak java based opensource E-Commerce solution. Before i used Magento, but it was really hard to change code at start. I spend almost 2 week to realize how Magento works. Performance was not good enough too.
Now i'm looking for simple java solution, which can be customized or rewritten easy. | I'm on the hunt for more or less the same.
Up until now, KonaKart has been my prime candidate. But their entire stack isn't opensource, this is limited to (snippet from <
> The parts of KonaKart that customers are most likely to want to customize are all open >source. These include the Struts action classes and forms, the JSPs, the velocity templates, >the BIRT reports, the payment modules, order total modules, shipping modules and the GWT One >Page Checkout code. They are shipped under the GNU Lesser General Public License
An alternative is < which offer the entire codebase under the LGPL license.
Since I'm purely in the very early stages of spotting a suitable system, I can't say much about performance of either system. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "java, open source, e commerce"
} |
How can I express the rules of this game clearly?
This is the information:
There are many mixed couples playing in this game. One of the couple must award _vote 1_ , _2_ or _3_ to the opposite sex e.g., a male _votes 1_ to a female.
* A couple is a male and a female
* Winning Couple: The male in that couple has to _vote 1_ to his female partner.
For example; **Couple A** is male A and female A , **Couple B** is male B and female B etc.
The winning couple A is the one in which male A _voted 1_ to female A and female A _voted 1_ to her male partner.
* So does the sentence below express correctly the above information?
> the winning couple is the one that has both male and female voted 1 to each other | > The winner is the couple **_whose_** partners have "voted" for each other.
The expression _the winning couple_ is ambiguous; it could mean a couple is currently in the lead or a particular couple is endearing, charming, delightful etc. as well as meaning _victorious_.
I placed _voted_ in inverted commas because it's unclear to _me_ how the **_points_** (?) are awarded in this game. If the game really has a voting system, then leave out the inverted commas. | stackexchange-english | {
"answer_score": 0,
"question_score": -1,
"tags": "word choice, expression choice"
} |
Why does the negated character class doesn't work as expected?
xyz mnl pqt aaaa ccc
yz mn ats aa cbc ddd eee ggg
I want to match the first two columns with:
[^\s]*\s[^\s]*\s
But this pattern matches up to all columns but the last one. That is:
xyz mnl pqt aaaa
yz mn ats aa cbc ddd eee
I don't understand this in VIM. | Two things:
1. `\s` doesn't work in a character class. Use `\S` instead.
2. Prefix the regex with `^` to make it start from the beginning of each line.
^\S*\s\S*\s
Which matches:
xyz mnl pqt aaaa ccc
^^^^^^^^
yz mn ats aa cbc ddd eee ggg
^^^^^^ | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "vim"
} |
What are the legal implications of Jailbreaking an iOS device?
I am forced to Jailbreak an iPad so that I can deploy a custom application for a client. This is an application that no one can have but him, so basically jailbreaking is the only choice I have?
I can't even install the app as a demo through the provisioning profile because that expires I think in 1 year?
What legal implications, in various jurisdictions, are there for jailbreaking an iOS device? | You can use a provisioning profile as long as he gets a new provisioning profile before the current one expires.
Apple also has a business store (basically a corporate App Store) but I think that is way over the top for what you are trying to do.
The most legitimate/safe option is to deploy a provisioning file and update it each year… | stackexchange-apple | {
"answer_score": 1,
"question_score": 2,
"tags": "iphone, ipad, ios, jailbreak"
} |
Updated Netflix list of TV shows
is it possible to have an always updated list of TV series on air on `Netflix`?
I'd like to get a public URL that I can access to receive something like a `JSON` o `XML` object with the list?
I don't know much about Netflix so I don't know whether all TV shows are available for all countries at the same moment, but I'm particularly interested in the list of TV shows available for italian users.
Thanks | Netflix has shut down its public API a year ago: <
There's no (legal) way to do this. | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 3,
"tags": "json, xml, netflix"
} |
C - how to get fscanf() to determine whether what it read is only digits, and no characters
Imagine I have a csv with and each value is an integer. so the first value is the INTEGER `100`.
I want fscanf() to read this line, and either tell me it's an integer ONLY, or not. So, it would pass `100` but fail on `100t`. What i've been trying to get work is "%d," where the comma is the delimiter of my CSV. so the whole function is
fscanf(fp, "%d,", &count)
Unfortunately, this fails to fail on '100t,' works on '100' and works on 't'. so it just isn't distinguishing between `100` and `100t` (all of these numbers are followed by commas, of course | Use `strtol` instead. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 1,
"tags": "c, scanf"
} |
Change Favicon on Tab Change
I'd like to change my favicon and browser tab text when a user navigates away to another browser tab. Does anyone know of a simple way to do this? | Use the `window.onblur` event to change `document.title` and the favicon. Changing favicons in some browsers can be tricky. See stackoverflow.com/questions/260857/changing-website-favicon-dynamically/260876#260876 for more info.
window.onblur=function(){
//change favicon
document.title="bye";
}
window.onfocus=function(){
document.title="hello";
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "html, favicon"
} |
C++ switch regex cases
I would like to use `switch case` to determine my value with `regex`, but it seems that I can't do this way. I can use `regex` successfully with `if else`, like below:
if (regex_search(dic_char, lowercase)) {
cout << dic_char << endl;
} else if (regex_search(dic_char, uppercase)) {
// do something
} else {
cout << "Not characters." << endl;
}
but I want to do in this way:
switch (dic_char) {
case regex_search(dic_char, lowercase):
cout << dic_char << endl;
break;
case regex_search(dic_char, uppercase):
// do something
break;
default:
cout << "Not characters." << endl;
break;
}
Does anyone know how I do in this way ? Thanks in advance. | Here is one way to do it (although most likely not feasible in your case):
Rewrite function `regex_search` as a macro (consider this as an example).
A `switch` statement in C and C++ can only take constant values as cases. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c++, regex, switch statement"
} |
Which one probability is more likely?
!enter image description here
* A. The quantity in Column A is greater
* B. The quantity in Column B is greater
* C. The two quantities are equal
* D. The relationship cannot be determined from the information given Which will be the answer?
> Because the fair coin is equal probably so I thought Quantity B is greater. But the answer is given $C$. | The crux of the problem is determining the probability that, given two heads and given two tails, that the fifth coin then flipped will land "heads": as we know, that probability is $\frac 12$, so C is indeed the correct answer.
That's also the probability of getting more tails than heads. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "probability"
} |
Select random record from mnesia
I have an mnesia table `t` that contains records with a single field `x`. How can I select a random value `x` from `t`?
To avoid the entire of process of mathematical pedantry: I don't care about the details of the random number generation, I just want my result to generally not be the same every time.
Thanks,
-tjw | By using the `mnesia:all_keys/1` (or dirty equivalent) function and the `random` module.
random_value(Table) ->
Keys = mnesia:dirty_all_keys(Table),
Key = lists:nth(random:uniform(length(Keys)), Keys),
[#record{x = X}] = mnesia:dirty_read({Table, Key}),
X.
Don't forget to initialize your seed using `random:seed/3`. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "database, erlang, mnesia"
} |
Is there any way to get uid from user name in Drupal?
Is there any core function to get uid from username in Drupal? Or I should perform a db query? my field is a textfield with '#autocomplete_path' equal to 'user/autocomplete' | You can use the `user_load` function. See <
In particular see <
So you would do something like this:
// $name is the user name
$account = user_load(array('name' => check_plain($name)));
// uid is now available as $account->uid | stackexchange-stackoverflow | {
"answer_score": 11,
"question_score": 9,
"tags": "drupal, drupal 6, drupal fapi"
} |
How c++ includes all functions in specific file without any inclusion of that file?
I just feel weird about how does that work ? That my first time that I've ever seen that , two c++ files located in the same directory "Test1.cpp,Test2.cpp"
Test1.cpp :
#include <iostream>
void magic();
int main(){
magic();
return 0;
}
Test2.cpp :
#include <iostream>
using namespace std;
void magic(){
cout << "That's not a magic , it's a logical thing.." << endl;
}
As I mentioned above , they are in the same directory , with prototype of 'magic' function. Now my question is , how does magic work without any inclusion of Test2.cpp ? Does C++ include it by default ? if that's true , then why do we need to include our classes ? why do we need header file while cpp file can does its purpose ? | In order to obtain an executable from a C++ source code two main phases are required:
* compilation phase;
* linking phase.
The first one searches only for the signature of the functions and check if the function call is compatible with the found declarations.
The second one searches the implementation of the function among the libraries or objects linked through the options specified through command line of the linker (some compilers can automatically run the linker adding some command line options).
So you need to understand the compiler and linker options in order to understand this process. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "c++"
} |
pickle error - integer required
with open('data', 'w') as f:
pickle.dumps({'foo':111},f)
results in
an integer is required (got type _io.TextIOWrapper)
How can I fix this?
I am pretty sure An integer is required? open() was not called beforehand. Python version is `3.6.2` | `pickle.dumps` dumps `obj` into a string which it returns. In order to write into a file, you probably want to use `pickle.dump` (without the s).
with open('data', 'wb') as f:
pickle.dump({'foo':111}, f)
Additionally you should also open the file in binary mode, because `pickle.dump` will write binary data. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "python 3.x, pickle"
} |
could not start the sphinx search service on local computer?
i am getting this
> Windows could not start the SphinxSearch service on Local Computer.
>
> Error 1067: The process terminated unexpectedly.
i got installation instruction from this .
<
build process is complete but when i start the sphinx search service i got errors . | Try running searchd manually from Command Prompt. Maybe it will give you a useful error message.
Try also looking in searchd.log | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "windows services, sphinx"
} |
Group by for XML Path ibn SQL
I am trying to concatenate some values from a column into a single field.
So far I have the below code.
SELECT DISTINCT [customer id]
,[customer name]
,STUFF( (SELECT ',' + [description]
FROM [Invoicing].[dbo].[CurrentBillMaster]
ORDER BY [description]
FOR XML PATH('')),
1, 1, '')
,[id]
,[Section]
,[customerpo]
FROM [Invoicing].[dbo].[CurrentBillMaster]
GROUP BY [customer id], [customer name], [description],[qty],
[identifier],[FromDate],[ToDate],[id],[Section],[customerpo]
The code largely works, however I want the concatenated description, just to show descriptions for that unique [customer id]
Any help greatly appreciated | You need to correlate subquery:
SELECT [customer id]
,[customer name]
,STUFF( (SELECT ',' + [description]
FROM [Invoicing].[dbo].[CurrentBillMaster] t
WHERE t.Customer_id = c.customer_id -- here
ORDER BY [description]
FOR XML PATH('')),
1, 1, '')
,[id]
,[Section]
,[customerpo]
FROM [Invoicing].[dbo].[CurrentBillMaster] c
GROUP BY [customer id], [customer name], [description],[qty],
[identifier],[FromDate],[ToDate],[id],[Section],[customerpo] | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 2,
"tags": "sql, tsql, for xml path"
} |
Pass Hash as Parameter to Rake Task
I've got a rake task
task :post_hit, [:host, :title, :description, :model, :num_assignments, :reward, :lifetime, :qualifications, :p, :opts] => :environment do |t, args|
`:p` needs to be a hash, but if I try:
rake turkee:post_hit[" Info","Fill In Player First Name","MechanicalTurk",100,0.01,2,{},{id: 5},{}]
It errors out saying that `id:` could not be parsed (the space seemed to do something).
If I tried:
rake turkee:post_hit[" Info","Fill In Player First Name","MechanicalTurk",100,0.01,2,{},{"id: 5"},{}]
the who string `"id: 5"` was being interpreted as a single string.
Are we not allowed to pass hashes to rake tasks? | When you issue a rake task via the terminal, you are in the UNIX or Bash environment, so you need to obey the rules of that language, which as far as I can tell doesn't include hashes. I could be wrong though.
<
This doesn't mean that whoever wrote the rake task didn't do something clever to parse a string into a hash. If I were you and trying to figure it out I would have a look at the source code and see how that rake task parses it's variables.
PS. If it's a gem you are using and you are using bundler as well, you can issue `bundle open gem_name` to open up the source, rake tasks generally end in a .rake... | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 10,
"tags": "ruby on rails, hash, rake"
} |
PHP and Cron jobs
I have some scripts which need to be run only through the CLI interface. So, when I execute them through Cron jobs, will they run through the CLI interface or some other daemon(if thats the right word to use). | The cron job (and/or shebang) will allow you to specify which program to use. Typically, it will use the same program you use as a CLI. PHP does not have a service (though it can use other services, like Apache). | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, cron"
} |
Javascript Array: what is a Big O of performing sort and then map right after on it?
arr.sort((a, b) => a - b).map(num => num ** 2);
What would be a Big O of the following operation?
As I understand Big O of imbedded `sort` function in JS is `O(Nlog(N))` and Big O of `map` is `O(N)`, therefore Big O is `O(Nlog(N))`? | The complexity of your function `f`, for `arr` of size `n`. We'll assume:
arr.sort ∈ O(nlogn)
arr.map ∈ O(n),
We can just sum these terms, since these operations are done serially (one after the other. Thus,
f(n) ∈ O(nlogn + n)
Note that the `nlogn` term will grow slowly, but eventually:
as n -> infinity, nlogn >> n
thus, as n -> infinity, nlogn + n -> nlogn
So we can simplify to just `O(nlogn)` for sufficiently large `n`.
All of this is to say, yep, you got it. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 2,
"tags": "javascript, performance, sorting, time complexity, big o"
} |
Writing data flow to postgresql
I know that by doing:
COPY test FROM '/path/to/csv/example.txt' DELIMITER ',' CSV;
I can import csv data to postgresql.
However, I do not have a static csv file. My csv file gets downloaded several times a day and it includes data which has previously been imported to the database. So, to get a consistent database I would have to `leave out` this old data.
My bestcase idea to realize this would be something like above. However, worstcase would be a java program manually checks each entry of the db with the csv file. Any recommendations for the implementation?
I really appreciate your answer! | You can dump latest data to the temp table using COPY command and MERGE temp table with the live table.
If you are using JAVA program for execute COPY command, then try CopyManager API. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "sql, postgresql, csv"
} |
Entity Framework 4 Hiding Underlying Resolver Tables when model is generated from database
When creating an entity framework model from scratch it is possible to specify a Many to Many relationship in the model.
e.g Entity1 * ----- * Entity2
When a database is then generated from this, a resolver table is then created automatically between the two entities, this is hidden in the code model, allowing direct access to each of the entities via properties.
e.g. Entity1 ----* ResolverEntity *----- Entity2
My question is, when a model is generated from an existing database, which contains resolver tables, is it possible to create the same effect so the resolver tables do not appear in the generated object model?
When I have attempted this, the entity framework appears to create entities in the model for the resolver tables with no obvious way of hiding them in the object model.
Thanks. | Yes, provided that what you're calling the "resolver table" contains only two columns, FKs to Entity1 and Entity2, and that those two columns form a compound PK. In this case, the EF GUI designer will recognize the pattern and generate a many to many relationship. If your DB schema doesn't fit these constraints, you'd have to edit the EDMX by hand. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": ".net 4.0, entity framework 4, table relationships"
} |
Why isn't my JavaScript countdown function doing anything?
I found this script:
<script language="Javascript" TYPE="text/javascript">
var container = document.getElementById('dl');
var seconds = 10;
var timer;
function countdown() {
seconds--;
if(seconds > 0) {
container.innerHTML = 'Please wait <b>'+seconds+'</b> seconds..';
} else {
container.innerHTML = '<a href="download.php">Download</a>';
clearInterval(timer);
}
}
timer = setInterval(countdown, 1000);
</script>
and I'm trying to call it with:
<input type="button" onclick="countdown()" id="dl" value="Download" />
but nothing happens. What am I doing wrong? I have JavasScript enabled but nothing happens after I click the button. | The script is starting itself with the setInterval function call, and is assigning the countdown to the element with the innerHTML property.
If you want to show that in the button, you should use the value property of the element and change the behaviour (i.e.: the link will not work there) or use a span or div element instead the button. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "javascript"
} |
How to convert a string UTC date to NSDate in Swift
I'm getting UTC string dates that look like this "2015-10-17T00:00:00.000Z" and want to convert them to an NSDate in this format "October 12th 2015 11:19:12 am"
This is the route that I'm trying but I can't seem to get the right dateFormat.
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = //can't seem to get this right
dateFormatter.timeZone = NSTimeZone(name: "UTC")
let date = dateFormatter.dateFromString("2015-10-17T00:00:00.000Z") | I think this should work
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
let localDate = formatter.date(from: date) | stackexchange-stackoverflow | {
"answer_score": 22,
"question_score": 10,
"tags": "swift, nsdate, nsdateformatter"
} |
Googlebot substitutes the links of Rails app with subdomain
I have this Rails app, with domain name `abc.com`. I am also having a separate subdomain for Piwik stats, in this subdomain `stats.abc.com`.
Googlebot somehow listed some of the links with my subdomain too.
The ones with `stats` will reference to the same page in the app, but are treated entirely different website.
I have put in `robots.txt` in `stats` after this matter, but wondering if there is any appropriate way to block this because I may have new subdomains in future. Here's my content in `robots.txt`
User-agent: *
Disallow: /
Thanks. | Robots.txt will block it just fine. It's just important to remember BEFORE you publish a site - Google is pretty fast. Some search engines ignore robots.txt. Best thing to do is not have subdomains that don't really fit you situation. I recommend reading the true purpose of subdomains. You should not be serving the same site on different domains. You should use a 301 direct or have different contents on different (sub)domains... Unless stats.abc.com contains different material, it shouldn't be a subdomain. What exactly do you need so many subdomains for?
You _could_ detect the user-agent, and if it's a bot, return a 404 too | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "ruby on rails, robots.txt, googlebot"
} |
AbstractScheduledService: shutdown underlying executor
I'm trying to use `AbstractScheduledService` from google guava lib. In the docs for this class I see the following:
> The executor will not be shutdown when this service stops.
Why do we want to leave executor thread alive after we have stopped the service? This seems a very strange architectural decision to me. What am I missing? | you could use the executor for multiple services (since it only provides it's threads for executing your code without any domain knowledge). Thats why it does make sense to not stop the executor when stopping the ScheduledService | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 1,
"tags": "java, multithreading, guava"
} |
How to access Joomla custom component administration without full admin rights
I need to realize a protected area for my components admin tools; i would like to use admin login and let the connected users see my admin tools without letting them access Joomla administrator stuff. How can i do it? | As Elin has stated Joomla's ACL will take care off this for you. The groups and Access Levels are found in Users config area. Once you have set that up, you will need to set the appropriate security access settings in the Global Configuration > Permissions settings. This will allow them in to the Admin area and then for each of the individual components/sections/areas that you DON'T want them to have access to, you will need to make appropriate selections(look for 'Options' in each area). Permissions are inherited and you have given them access to the Admin area in the Permissions settings above, so everything is open until you close them down.
Obvious warnings of testing thoroughly and backing up as you're potentially opening up your system. The ACL can become very confusing very quickly. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "joomla, joomla2.5"
} |
Can a jQuery UI datepicker be matched to a click event's target?
I've written a simple jQuery (1.4.2) UI (1.8) widget that embeds a jQuery UI datepicker. I'd like to detect when a user clicks outside my widget, in which case it should automatically hide itself. My code looks roughly like this:
var self = this;
$(document).bind("click.mywidget": function(event) {
var target = event.target;
if (!self.container.has(target).length && target != self.container.get(0)) {
self.hide();
}
});
The problem comes when clicking on a date or month prev/next button in the datepicker. For some reason, even though Firebug shows those elements as being descendants of my container, the has() check fails for them.
What is happening, and how might I fix this? | After digging through the datepicker source a bit, I realized what was going on. Apparently whenever you click on a date, or cycle through months, it empties the entire div and re-creates it.
Since the picker is further down in the DOM, it handles the click event first. By the time the document handler gets called, the target element is no longer in the DOM, and is therefore no longer a descendant of the container.
My hasty hack was to check the target's more direct parents, to see whether any of them is a datepicker table or header. Since this widget is thus far my only use of datepicker, I can assume that a click on such an element should not count as a click outside the container.
I'll update this answer once I come up with a real solution. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "jquery, jquery ui, jquery ui datepicker"
} |
Adding author to the table of contents
I'm currently trying to insert an author name in table of contents. My ad-hoc solution to the problem would be the following code snippet:
\documentclass{article}
\begin{document}
\tableofcontents
\section{Test}
\addtocontents{toc}{\textit{Author's name}}
\section{Test}
\addtocontents{toc}{\textit{Author's name}}
\end{document}
Unfortunately, I always get the following error message:
! LaTeX Error: Something's wrong--perhaps a missing \item.
I guess, the compiler cannot move to the next line in the toc file somehow. Does anyone know how to fix it? I'm very grateful for any help. | You need to add `\par` after the author name.
\documentclass{article}
\begin{document}
\tableofcontents
\section{Test}
\addtocontents{toc}{\textit{Author's name}\par}
\section{Test}
\addtocontents{toc}{\textit{Author's name}\par}
\end{document}
You can refer to the following question for more detailed explanation: missing \item with \addtocontents before \section | stackexchange-tex | {
"answer_score": 1,
"question_score": 1,
"tags": "table of contents"
} |
How can I update where a given select condition returns a true value?
I want to perform an SQL update
UPDATE incCustomer SET etaxCode = 'HST' WHERE
only on records where this is true.
select etaxCode
from incCustomer
left join incAddress on incCustomer.iAddressId = incAddress.iId
left join incProvince on incAddress.iProvinceStateId = incProvince.iId
where incAddress.iProvinceStateId in ( 2 , 3 , 4 , 6 , 9 )
I don't think that this is possible with ANSI SQL, but can it be done in MySQL? | MySQL UPDATE syntax supports joins in both ANSI-89 and ANSI-92 syntax.
Use:
UPDATE INCCUSTOMER c
LEFT JOIN INCADDRESS a ON a.iid = c.iaddressid
LEFT JOIN INCPROVINCE p ON p.iid = a.iprovincestateid
SET c.etaxcode = 'HST'
WHERE a.iProvinceStateId IN (2,3,4,6,9)
I don't see the point of LEFT JOINing to the province table - I think your UPDATE could be written as:
UPDATE INCCUSTOMER
SET c.etaxcode = 'HST'
WHERE EXISTS(SELECT NULL
FROM INCADDRESS a
WHERE a.iid = INCCUSTOMER.iaddressid
AND a.iProvinceStateId IN (2,3,4,6,9)) | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "mysql, sql, sql update"
} |
How does mysql decide if concurrent insert is possible for a MyISAM table?
For "concurrent inserts", MySQL reference manual has the following explanation:
> The MyISAM storage engine supports concurrent inserts to reduce contention between readers and writers for a given table: If a MyISAM table has no holes in the data file (deleted rows in the middle), an INSERT statement can be executed to add rows to the end of the table at the same time that SELECT statements are reading rows from the table.
<
Let's say our database "concurrent insert" parameter is set to "Auto" (1).
And we have a MyISAM table with a gap. When we insert new rows and fill those gaps, does the table "immediately" get ready to accept "concurrent inserts" for future insert queries?
Or do we need to run "OPTIMIZE" before the table knows there are no gaps? | While you can do what Rolando suggests and set `concurrent_insert=2` to always enable concurrent inserts, to answer your question about filling holes:
> we have a MyISAM table with a gap. When we insert new rows and fill those gaps, does the table "immediately" get ready to accept "concurrent inserts" for future insert queries?
Yes (emphasis mine):
> If there are holes, concurrent inserts are disabled **but are enabled again automatically when all holes have been filled with new data**. [[src]](
Disclaimer: I haven't actually tested it. It seems unless you inserted the exact same data-length in the holes, you will still have holes somewhere.
You can see if there are holes from a query such as this (data_free=0 would mean no holes):
SELECT table_name, data_free FROM information_schema.tables WHERE table_schema='FOO' AND engine='myisam' | stackexchange-dba | {
"answer_score": 6,
"question_score": 3,
"tags": "mysql, insert, myisam"
} |
Background css image won't show in firefox
<
I purchased this template online and I added separate background images css images to and . The idea is that I want two background images that overlap.
The page displays fine in chrome and Safari, but in firefox the background image that is attached to doesn't display and the image attached to displays, but ignores the y position.
Can anyone help me understand what is happening?
Thanks! | First of all `background-position-y` not works in firefox as it suppsoed to be
So it should be
background-position: center 35px;
body{
background: url('../../images/eraser.svg') no-repeat scroll center;
background-size: auto 350px;
background-position: center 35px;
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "html, css, firefox, background image"
} |
Java splitting strings regex: Leading whitespace
I know that the question has been asked before on how to split strings with leading white space, for example:
String str = " I want to be split \t!"
String[] sarr = str.split("\\s+");
for(String s : sarr) System.out.println("'" + s + "'");
produces the results:
'' //leading white space
'I'
'want'
'to'
'be'
'split'
'!'
The way to fix this is to use str.trim() before splitting.
What I'm wondering though is _why_ split() cannot skip over leading white space but can do so in the middle/end of the string. | I think this should answer your question.
Taken from String docs
> Splits this string around matches of the given regular expression.
>
> This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "java, regex, string"
} |
Checking File Checksum In Alpine
I got this curious problem with Alpine. I want to check the checksum of a file inside a bash console. It works under CentOS but not under Alpine. Where is the error?
Under CentOS
$ sha1sum /bin/tini
fa23d1e20732501c3bb8eeeca423c89ac80ed452 /bin/tini
$ echo "fa23d1e20732501c3bb8eeeca423c89ac80ed452 /bin/tini" | sha1sum -c -
/bin/tini: OK
Under Alpine
$ sha1sum /bin/tini
fa23d1e20732501c3bb8eeeca423c89ac80ed452 /bin/tini
$ echo "fa23d1e20732501c3bb8eeeca423c89ac80ed452 /bin/tini" | sha1sum -c -
sha1sum: WARNING: 1 of 1 computed checksums did NOT match | Could you try adding 1 space (total 2) between the checksum and the path:
$ echo "fa23d1e20732501c3bb8eeeca423c89ac80ed452 /bin/tini" | sha1sum -c -
I've tried with `/bin/busybox`:
# sha1sum /bin/busybox
71bdaf6e52759f7f277c89b694c494f472ca2dfb /bin/busybox
# echo '71bdaf6e52759f7f277c89b694c494f472ca2dfb /bin/busybox' | sha1sum -c -
sha1sum: WARNING: 1 of 1 computed checksums did NOT match
# echo '71bdaf6e52759f7f277c89b694c494f472ca2dfb /bin/busybox' | sha1sum -c -
/bin/busybox: OK
The error is because `sha1sum` expects its own output as input when called with `-c` and its output uses 2 spaces. | stackexchange-stackoverflow | {
"answer_score": 21,
"question_score": 10,
"tags": "bash, docker, alpine linux"
} |
Making menu item in TYPO3 Bootstrap non-clickable
I am using TYPO3 8.7.9 with the Bootstrap Extension 9.1.0 (from Benjamin Kott).
For the pages I am using the bootstrap root and extension templates.
I have a simple tree of pages like
root
sub1 <-- no content, want it to be non-clickable
subsub1
subsub2
sub2
sub3
sub4 <-- no content, want it to be non-clickable
subsub3
subsub4
sub5
The menu is built automatically from the tree (responsive, may collapse to hamburger icon).
I would like to make menu entries non-clickable - in the example above sub1 and sub4. (The pages sub1 and sub4 are empty.)
Also in the breadcrump the pages sub1 and sub4 should not be clickable.
Did I miss a configuration option? Is there a simple way with some TypoScript? And where do I have to place it? root/ext template setup, page TSConfig?
Thanks for looking into it,
Zweikeks | For this you need to change the Boostrap `Navigation` template file.
You can find this file below paths. Here you can change the menu layout and menu functionality.
typo3conf/ext/bootstrap_package/Resources/Private/Partials/Page/Navigation/ | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "twitter bootstrap, menu, typo3, typoscript"
} |
Ffmpeg Webm Encoding Error
I am trying to convert various video file formats into .webm using ffmpeg v. 0.6.1 but am having a few troubles. It creates the file but is zero kb in size. I also get the following error:
Encoder (codec id 146) not found for output stream #0.0
I have tried loads of fixes but none seem to work. I have used --enable-libvorbis on ./confure and downloaded the latest version of libvpx and all the other dependencies listed here: <
Are there any patches I need to apply from webm? Or is this version of ffmpeg meant to support it?
Anyone have any ideas? Thanks,
Chris. | I've solved it. The error was caused by a dodgy install of ffmpeg. Reinstalled and it works fine. | stackexchange-superuser | {
"answer_score": 1,
"question_score": 5,
"tags": "ffmpeg"
} |
WSO2 Identity Server Cannot see options in userstore, policyadministration etc
Hey i have just installed the WSO2 Idenity Server on my windows 7 system (localhost) to test the XACML features.
But is see nothing in the userstore, policyadministration and other features on the dashboard... any suggestions ?
< < | Fixxed.... i used JDK 1.8 instead of 1.6/1.7.
Sorry with 1.6 it works fine. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "wso2, xacml, wso2 identity server"
} |
Sign of a degree-three polynomial in arbitrary ordered fields
Let $\mathbb F$ be an ordered field, and let $a,b,q,r\in{\mathbb F}$ with $a \lt b$. Let $f(x)=x^3+qx+r$.
Is it true that if $f(a)>0,f(b)>0$, and the discriminant $\Delta=-4p^3 - 27q^2$ of $f$ is negative, then $f(x)>0$ for any $x\in [a,b]$ ?
This property is true whenever $\mathbb F$ is a subfield of $\mathbb R$, because then we have IVT and the sign of $f'$ gives us the variations of $f$. | This holds in any ordered field. To prove it, you can pass to the real closure $K$ of $\mathbb{F}$. Since the discriminant is negative, $f(x)$ has at most one root in any ordered field extending $\mathbb{F}$, and in particular has only one root in $K$. Moreover, $f(x)\to\pm\infty$ as $x\to\pm\infty$. Real-closed fields satisfy the intermediate value theorem for polynomials, and so it follows that $f(x)$ must be positive for every $c\in K$ between $a$ and $b$. (Alternatively, to use a sledgehammer, real-closed fields are elementarily equivalent to $\mathbb{R}$ and your question is first-order, so since it holds for $\mathbb{R}$ it holds for any real-closed field.) | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "polynomials, ordered fields"
} |
Regenerate user_privileges files
I'm on a vtiger 7.3, and I was wondering if the sharing_privileges_* and user_privileges_* files can be regenerated from the database.
I've read that if you re-assign a role to a user the files will be regenerated. But I tried deleting both sharing_privileges_* and user_privileges_* and then the users don't even show up on the crm, so in that case it's not possible to assign it a role.
Don't worry, my backups are fine! It's just curiosity. | check if your users are present in the `vtiger_users` table in the database. If they're not there, you will have to create them again.
To regenerate the sharing_privileges_* and user_privileges_* files, put this code in a file in the root directory of vtiger and run it from your browser or via command line:
<?php
require_once 'vtlib/Vtiger/Module.php';
require_once 'include/utils/VtlibUtils.php';
require_once 'config.inc.php';
require_once 'includes/Loader.php';
require_once 'modules/Users/CreateUserPrivilegeFile.php';
vimport ('includes.runtime.EntryPoint');
$current_user = Users::getActiveAdminUser();
vtlib_RecreateUserPrivilegeFiles();
Settings_SharingAccess_Module_Model::recalculateSharingRules(); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "vtiger, vtigercrm"
} |
Compare the previous N rows to the current row in a pandas column
I am trying to populate a new column in my pandas dataframe by considering the values of the previous n rows. If the current value is not equal to any of the past n values in that column, it should populate "N", else "Y".
Please let me know what would be a good way to achieve this.
Here's my input data :
testdata = {'col1' :['car','car','car','bus','bus','bus','car']}
df = pd.DataFrame.from_dict(testdata)
Input DF:
col1
0 car
1 car
2 car
3 bus
4 bus
5 car
6 car
Output DF (with n=2):
col1 Result
0 car
1 car
2 car Y
3 bus N
4 bus Y
5 bus Y
6 car N | Here is my way
n=2
l=[False]*n+[df.iloc[x,0] in df.iloc[x-n:x,0].tolist() for x in np.arange(n,len(df))]
df['New']=l
df
col1 New
0 car False
1 car False
2 car True
3 bus False
4 bus True
5 bus True
6 car False | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 7,
"tags": "python, pandas, dataframe"
} |
Does collections in CQL3 have certain limits?
As there are two ways to support wide rows in CQL3..One is to use composite keys and another is to use collections like Map, List and Set. The composite keys method can have millions of columns (transposed to rows).. This is solving some of our use cases.
However, if we use collections, I want to know if there is a limit that the collections can store a certain number/amount of data (Like earlier with Thrift C* supports up-to 2 billion columns in a row) | Apart from the performance issue, there is a protocol issue which limits the number of items you can access to 65536.
< | stackexchange-stackoverflow | {
"answer_score": 15,
"question_score": 12,
"tags": "cassandra, cql3"
} |
Windows service Debug Issue
I have created windows service i have try to debug for that i use Under debug Tab click on attach to process select Myservice.exe it wont go through the break point.
In service on start event i was write following code
protected override void OnStart(string[] args)
{
Console.WriteLine("Press Enter to terminate ...");
}
Please help me how resolve this issue.... | Use following method.On your code. This is by far the easiest method to set a breakpoint on service library.
**`Debugger.Break();`**
protected override void OnStart(string[] args)
{
Debugger.Break();
Console.WriteLine("Press Enter to terminate ...");
} | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "c#, windows services"
} |
Clojure- filter complex vector
I have been trying to filter complex vector like that
(def mySymbolT [[:name "salary" :type "string" :kind "static" :index 0]
[:name "money" :type "string" :kind "static" :index 1]
[:name "count" :type "int" :kind "field" :index 0]])
My goal is to return the quantity of elements that has the same kind: For example, for kind "static" I expect 2 as an answer. So far I got to write this:
(defn countKind [symbolTable kind]
(count(map first(filter #(= (:kind %) kind) symbolTable))))
Its not working. I must say that I'm new to Clojure and I dont understand well how filter goes with map, so I will be glad to hear explanations. (Yes, I have read the documentation about map and filter, still explanations missing for me, especially when I try to apply to large vectors.) | Your data would be better expressed as an array of _maps_ than of _vectors_ :
(def your-table [{:name "salary", :type "string", :kind "static", :index 0}
{:name "money", :type "string", :kind "static", :index 1}
{:name "count", :type "int", :kind "field", :index 0}])
You can get there from here by ...
(def your-table
(mapv (partial apply array-map) mySymbolT))
Now we can
* use the keyword `:kind` as a function to extract those values, and
* the core function `frequencies` to return what you ask.
For example ...
(frequencies (map :kind your-table))
;{"static" 2, "field" 1}
* * *
By the way, the Clojure idiom is to hyphenate words in a symbol: `my-symbol-t` instead of `mySymbolT`. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "dictionary, vector, filter, clojure"
} |
Intuition behind generating discrete random variables from a uniform random number generator
The following is an exercise from Rice's _Mathematical Statistics and Data Analysis_ :
> This problem shows one way to generate discrete random variables from a uniform random number generator. Suppose that F is the cdf of an integer-valued random variable; let U be uniform on [0, 1]. Define a random variable Y = k if F(k − 1) < U ≤ F(k). Show that Y has cdf F.
I know how to prove this (by writing F's cdf as a sum of cdf of uniform distribution, which then eventually cancels / simplifies nicely to give F_Y(x) = F(x)) but I'm having trouble developing an intuition as to what this method means and how it works. I am **not** looking for a solution to the exercise / a proof. I want to understand why this method works at a conceptual level.
I'm not sure what this method is called so I couldn't search for other resources on this. | I'll try to give a working example. Let's say you want to create a RV from the following discrete distribution: $$p_X(x)=\begin{cases} 0.3, &x=1\\\0.2, &x=2\\\0.1,&x=3\\\0.4,&x=4 \end{cases}$$
One simple way to simulate this distribution is the following intuitive if-else block:
u = rand() // uniform 0-1 RV
if u < 0.3
x = 1 // we'll be here with 0.3 probability
else if u < 0.5
x = 2 // we'll be here with 0.5 - 0.3 = 0.2 probability
else if u < 0.6
x = 3 // we'll be here with 0.6 - 0.5 = 0.1 probability
else
x = 4 // we'll be here with 1 - 0.6 = 0.4 probability
end
which is the same procedure described analytically. | stackexchange-stats | {
"answer_score": 2,
"question_score": 2,
"tags": "sampling, uniform distribution, random generation"
} |
How to avoid having to run "setup:upgrade" and "static deploy" each time a change is made?
Whenever i make changes in knockout.js files and html file inside web folder. I have to run "setup:upgrade" and "static deploy" again. Is there any solution to avoid doing this? | Delete the Specific File Which you are modifying from Pub/Static Folder which is generated during the Initial deployment .
Once Deleted reload the site so the new static file will be created with new contents | stackexchange-magento | {
"answer_score": 2,
"question_score": 0,
"tags": "magento2, magento 2.1"
} |
What type of exception it raises when database doesn't exist in rails?
I want to handle the exception when database doesn't exist. I'm not able to find to find out what type of exception ActiveRecord raises when database not found.
Any help would be highly appreciated. | I got the answer myself, it raises `ActiveRecord::NoDatabaseError` exception.
Thanks. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "ruby on rails 4, activerecord"
} |
Identify cells with characters other than numbers in dataframe
I have dataframe with two columns named A and B. How can I fill column B so that a cell will display "text" if A contains something other than a number or the number itself comma separated, and "number" when it is just a number? (See the example below)

def checkType(x):
try:
#Trying to convert the value into a float type
float(x)
return 'number'
except:
#If there's an error, it's a text
return 'text'
df['B'] = df.A.apply(lambda x : checkType(x))
**Output**
| A | B |
|:-------|:-------|
| 4 tons | text |
| 2.0* | text |
| 4.1 | number |
| 4.2 | number |
| 4,2 | text |
| 6,3 | text | | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python 3.x, dataframe"
} |
Operations on online files via public URL access
I need _Mathematica_ to access an online public directory via some URL (fake in this case)
<
and perform operations similar to those _Mathematica_ can do on OS directories and files. Examples:
1. Get all files names - like: {image1.png, image2.png, ...}
2. Import files into _Mathematica_
3. Get various files info
What is an efficient way to do it if it's possible at all? | Here's one approach, though it's hard to say without knowing the site and what additional information you want for the files.
Import[" {"HTML", "Images"}]
!enter image description here
There are several other items you can ask for (including what elements you can ask for!)
In[53]:= Import[" {"HTML", "Elements"}]
Out[53]= {"Data", "FullData", "Hyperlinks", "ImageLinks", "Images",
"Plaintext", "Source", "Title", "XMLObject"}
In[54]:= Import[" {"HTML", "ImageLinks"}]
Out[54]= {"
...
" | stackexchange-mathematica | {
"answer_score": 7,
"question_score": 7,
"tags": "import, networking, remote access"
} |
Get the URI of an image stored in drawable
I am adding a couple of sample items in my application so it doesn't look so empty when the user look at it the first time. The list with the sample items should have an image and the image I am going to use is already stored in the /res/drawable-folder of the application.
Since I already have a method that load the items images from a URI i'd like to get the URI to the /res/drawable/myImage.jpg but I don't seem to be able to get it right.
The flow is as follows: Create item with string that represents the URI of the image. Send list of items to an List The list loads the image in a background task by converting the string to URL and then run url.openStream();
I have tried a few options for the URI without any success. "android.resource://....." says unknow protocoll "file://" file not found
So right now I'm a little bit lost about how to fix this.. | You should use `ContentResolver` to open resource URIs:
Uri uri = Uri.parse("android.resource://your.package.here/drawable/image_name");
InputStream stream = getContentResolver().openInputStream(uri);
Also you can open file and content URIs using this method. | stackexchange-stackoverflow | {
"answer_score": 113,
"question_score": 87,
"tags": "android, url, drawable"
} |
Missing Android Studio git/linecount toolbar
Android Studio stopped displaying line count and current branch information in the bottom right portion of my program frame.
By default, Android Studio should show this information in the area I've circled in the screenshot below:
{
char arr[n];
unordered_map<char,int> exists;
int index = 0;
for(int i=0;i<n;i++){
if(exists[s[i]]==0)
{
arr[index++] = s[i];
exists[s[i]]++;
}
}
return arr;
}
//driver code
int main(){
string str;
cin >> str;
cout<<removeDuplicates(str,str.length())<<endl;
return 0;
}
The code produces no output at all, however, it works fine if I use `char arr[]` instead of string class. | So, after doing a bit of reading on the Internet I realized that I was trying to return a pointer to the local array in the `removeDuplicates()` function.
This is what works fine
#include <bits/stdc++.h>
using namespace std;
void removeDuplicates(string &s,int n){
vector<char> vec;
unordered_map<char,int> exists;
int index = 0;
for(int i=0;i<n;i++){
if(exists[s[i]]==0)
{
vec.push_back(s[i]);
exists[s[i]]++;
}
}
for(auto x: vec)
cout << x;
}
//driver code
int main(){
string str;
cin >> str;
removeDuplicates(str,str.length());
return 0;
}
PS: We can make the return type of function to vector as well. | stackexchange-stackoverflow | {
"answer_score": -1,
"question_score": 1,
"tags": "c++, string, algorithm, stl"
} |
Python script to automate search form a website?
I was able to use this below to automate opening a website for example here if I use youtube, is there a way I can put it
I'm trying to find a way to automate search "fishing" into this code but struggling to find the best way to do it.
Any recommendations would greatly appreciated
import webbrowser
new=2;
url="
webbrowser.open(url,new=new);
or way to go about it ? | Just make a get request, passing the search query parameters to this link.
_< | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -1,
"tags": "python"
} |
How to find the path of a specific application (Google Chrome)?
I have Google Chrome downloaded on my laptop and I want to find where it is compared to a Windows path use it, basically for a text to speech project.
On Windows it is located here :
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
How can I get the path on Linux? I tried:
(MoodBotEnv) mike@mike-thinks:~/Programing/Rasa/moodbot$ which chrome
(MoodBotEnv) mike@mike-thinks:~/Programing/Rasa/moodbot$ which google*
(MoodBotEnv) mike@mike-thinks:~/Programing/Rasa/moodbot$ where google*
No command 'where' found, did you mean:
Command 'gwhere' from package 'gwhere' (universe)
where: command not found
And the "Search your computer" top left button doesn't provide the path as well. | If you have installed the stable version of Google Chrome, run the following commands to find its location
whereis google-chrome-stable
or
which google-chrome-stable | stackexchange-askubuntu | {
"answer_score": 14,
"question_score": 4,
"tags": "google chrome, executable, paths"
} |
PHP submitted checkbox value is a string or a boolean?
Do you guys know when you submit a form via PHP, is the form checkbox value being treated as the string "true" or boolean true? Assuming my checkbox value attribute was set to "true". | When you submit a checkbox, the value will be whatever you set the value attribute as, and will be a string when PHP parses the form data and populates `$_REQUEST` and friends.
If you don't specify a value in the form, then browsers default to `"on"`, not `"true"` (this is being made standard behaviour in HTML 5). | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "php, forms, checkbox"
} |
Do Donald and Goofy still gain experience when you have an extra character in their place?
If you replace Donald or Goofy for someone like Tarzan, do they still gain experience points for enemies you kill? If not, do you think it is even worth it to use the extra characters at all? | Yes, Donald and Goofy continue to level normally if you swap them out with the world-specific character. I remember this from playing it, but trying to find an authoritative reference I didn't turn up much. It is, however, listed as an example of the "leaked experience" trope:
> Kingdom Hearts also uses the "one experience progression" idea. [...] Characters who are knocked out in combat don't gain experience in the first game. Oddly, this meant that on the hard difficulty, it was actually easier for a good portion of the game to level Glass Cannon Donald up by leaving him out of the party. | stackexchange-gaming | {
"answer_score": 4,
"question_score": 4,
"tags": "kingdom hearts"
} |
Make a Custom view that has a UIImage with a UILabel inside (at bottom of image)
!An custom view with UIImage that have UILabel inside
I try to make a cool news app like BBC news. I think each **_news item (see picture) must have a UIImage and UILabel (title of news) inside it_** \--> We must create custom view.
I adready have read how to create custom view in Apple Developer website but it only introduces, not has some samples.
My question is: \+ How can I create that customview (a UIImage with a UILabel inside) \+ How can I put that view in tableview in my main screen app.
Thank in advance. Sorry for poor English. | Try this..
UIButton *objBtn;
objBtn = [[UIButton alloc] init];
objBtn.frame = CGRectMake(x, y, W, H);
[objBtn setBackgroundImage:[UIImage imageNamed:@"defalt_person_01.png"] forState:UIControlStateNormal];
[objBtn addTarget:self action:@selector(SelectLanguageBtn:) forControlEvents:UIControlEventTouchUpInside];
objBtn.tag = 101;
[self.view addSubview:objBtn];
//Your News On Imagebtn
UILabel *newsLab=[[UILabel alloc]initWithFrame:CGRectMake(BtnX, BtnY, W, H)];
newsLab.textAlignment=UITextAlignmentCenter;
newsLab.textColor=[UIColor orangeColor];
newsLab.backgroundColor=[UIColor clearColor];
newsLab.text = @"My News";
newsLab.font=[UIFont fontWithName:@"TimesNewRomanPS-BoldMT" size:30];
[objBtn addSubview:newsLab]; | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "iphone, xcode, uiimageview, custom controls, uilabel"
} |
Missing commits when using 'git subtree split'
I had a task which is about extracting a folder from a repo and create a repo with the history of the folder extracted. I've searched the internet and I found people talking about `git subtree` and I used it as follows : `git subtree split -P <PATH_TO_FOLDER> -b BRANCH_NAME`
After finishing the process, I found that the commits in the branch created less than the commits when I `git log PATH_TO_FOLDER` and I don't know why this happens.
Is there any way to do this without missing any commits? | I knew what was wrong.
There was a branch that's not merged into the master branch -which causes some commits to be missing after executing `git subtree`-, and after many trials I found that `git subtree` is working on a single branch not the whole repository so I merged the last branch to the master branch and executing it again and it worked. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "git, git subtree"
} |
How to access AngularJS variable from template script
My controller:
$scope.totals = totals;
My template (works as expected for html injection):
{{totals}}
But what I need is to access the variable `totals` in a script in the template, like so:
<script>
var totals = ????;
// do stuff with totals
</script>
I've tried `$scope.totals`, `$totals`, `{{totals}}`, etc, with no avail. I would appreciate any insight, thanks!
EDIT:
The following is a jsfiddle of my controller and template. Inside of the template I'm wanting to insert a script that uses the `$scope.totals` variable.
< | OP Answer:
I ended up having to use a directive to find the value I wanted. In the controller that set the value I wanted to use I added a directive so that it looked like this:
'use strict';
angular.module('AdminApp')
.controller('AdminEventsCtrl', function ($scope, collection) {
$scope.totals = collection;
}).directive('foo', function(){
return {
restrict: 'A',
link: function(scope, elem, attrs){
//Use scope.totals here
}
}
});
In my template I had the declaration:
<div foo></div>
This gave me the ability to do what I needed with the variable totals.
Special thanks to @jvandemo for helping me arrive at this answer. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 15,
"tags": "javascript, html, angularjs, angularjs scope"
} |
Practical value of the Resurrection Stone
After seeing this question it occurred to me to ask a similar question of the Resurrection Stone. What exactly is the practical use of an object that
> creates images of the dead that only you can see? Is it purely for emotional value?
Or did I miss something important here?
**EDIT:** As a sidebar, the impression I got very strongly was that
> the Stone is really only reacting to what is inside yourself. So it's not like you can get information from an actual ghost that you didn't already know. Of course, I could be mistaken. | The book described the spirits as more than ghosts but less than living. There seemed to be no indication that it was in his head, and since the cloak and elder wand were exceptionally remarkable magical items, I would assume the resurrection stone too can do what no other magical item can do.
I suppose he could have kept using it, but the book seemed to indicate that this would only cause suffering to himself and others in the long run and didn't delve into further details. | stackexchange-scifi | {
"answer_score": 7,
"question_score": 7,
"tags": "harry potter, magic, magical items"
} |
Show video capturing duration with AVCam
I'm using Apple's AVCam source code to create a custom camera, I want still image and video capture both from custom camera, so for video capturing I'll also need video capture duration, not sure how it'll work? Any idea? I'll manage to add a `UILabel` and a `NSTimer` for this but don't know how I'll get exact video duration from this? | I sorted it out with a `NSTimer`, when I start capturing I schedule a timer, and on stop capturing, I reset timer. In timer action, incrementing a duration ivar and showing it as capturing duration in a `UILabel`. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ios, video capture, avcam"
} |
F-SW22 vs F-SW33 flux. What to these figures mean?
I was thinking of purchasing a no-clean flux pen from my supplier, but there are two options, F-SW22 and F-SW33. What do these codes mean and what types of job is each suitable for? | F-SW-22 is weakly corrosive and contains inorganic salts.
F-SW-33 is non-corrosive and is rosin free w/o halides.
You'd use F-SW-22 if there was solder-ability issues, but you must clean the board after wards.
You'd use F-SW-33 for a normal (cleaner) situation, and is advertised as no-clean . I'd recommend you clean it anyways. | stackexchange-electronics | {
"answer_score": 3,
"question_score": 2,
"tags": "soldering, flux"
} |
How to keep old highlights when calling window.find() again
If I use the below code I am able to highlight the found text in Window.
window.find(str);
But if I search for another string with `window.find()` the previous highlight will be removed. But how can I change that to not remove old highlights.. | You can use `document.execCommand()` to add styling to the current selection after calling `window.find()`. See my answer here, for example:
< | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "javascript, firefox"
} |
Rails shorthand if/else output html
Right now when I use
<%= @inbox.automatic_reconciliation ? "<i class='fi-play-circle'></i>" : "<i class='fi-pause'></i>" %>
My view spits out the actual code on the page instead of the icon. I've tried using a few methods like .to_html and such to no avail - what am I missing? | Try using the `html_safe` method.
<%= @inbox.automatic_reconciliation ? "<i class='fi-play-circle'></i>".html_safe : "<i class='fi-pause'></i>".html_safe %>
documentation | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "ruby on rails, ruby on rails 4, if statement"
} |
How do I get vs2008's intellisense member list to show full signatures?
I saw a blog post the other day that had a screen shot of intellisense's member list that looked like this:
DateTime. -> [Compare(DateTime, DateTime) int]
[DaysInMonth(int, int) int]
...
Instead of mine which looks like:
DateTime. -> [Compare ]
[DaysInMonth]
...
How do I setup my vs2008 IDE so that my member list looks like the first example? | Could it be that they were using ReSharper? ReSharper's Intellisense is definitely nicer than Visual Studio's - apart from anything else, when it's showing overloads, it shows several at a time - I can never stand the way Visual Studio does that...
I've just checked, and I don't believe ReSharper does this _by default_ but there's an option under ReSharper / Options / Environment / Intellisense / Completion Appearance: "Show member signatures". Turning that on gives the parameter types as desired.
I don't _think_ vanilla Visual Studio has an equivalent option. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 4,
"tags": "c#, visual studio 2008, settings, intellisense"
} |
How do I bind a ListView to an ObservableCollection in C++/CLI?
I've got a small app which will allow the user to select a number of files and then perform some processing. I was thinking I'd collect the files in an `ObservableCollection` of `String^` (and probably expand this to a full class at a later date).
The problem is I can't work out how to bind the `ListView` to the `ObservableCollection`. I've added a property to the main form:
protected:
ObservableCollection<String^>^ m_sourceFiles;
public:
property ObservableCollection<String^>^ SourceFileList
{
ObservableCollection<String^>^ get() {return m_sourceFiles;}
}
All the examples I've seen for C# / VB implementations switch to using XAML at this point, but I can't see how to do that in C++? Where do I go from here? | There's a `DataSource` property on `DataGridView`, `ListBox`, and `ComboBox`. Can you use one of those? `System.Windows.Forms.ListView` doesn't have support for data-binding. However, you can use virtual mode and handle the RetrieveVirtualItem event. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": ".net, data binding, c++ cli"
} |
How to make text disappear when HTML5 Video has finished loading?
The title pretty much says it all. I'm trying to have some text that says "Video Loading" and a 75% opaque background over the HTML5 video, and once it has completely loaded I want the text and background to disappear. How can I do that?
Thanks for you time and effort! The page I'm trying to do this on is jeffarries.com/videos. Can provide code if needed.
* * *
The dup link is to a post trying to get the duration of the HTML5 video, I'm trying to have JavaScript change css properties when the HTML5 video is completely FINISHED loading into the browser. | I ended up using this JavaScript code to hide my HTML element with id "video_cover" by changing CSS `display: block;` to `display: none;` when the HTML5 video element "myVideo" fires `canplaythrough`:
<script>
var vid = document.getElementById("myVideo");
vid.oncanplaythrough = function() {
var e = document.getElementById("video_cover");
e.style.display = 'none'
};
</script>
Resources: W3Schools canplaythrough JavaScript event.
Sorry if my JavaScript terminology is bad, I'm just learning it!
* * *
Thanks again @Quantastical and @Offbeatmammal for all your help! | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "javascript, css, html, video"
} |
Does the US ban high-gas-mileage cars?
A recent YouTube video features a claim that the VW Passat TDI 1.6 and similar cars have been banned by the US government, specifically because their gas mileage is too high. The purported reasoning is that if many people bought these cars, the government would lose revenue on gas taxes.
Could Volkswagen sell the Passat TDI 1.6 in the US if it wanted to? If not, what laws prohibit it? Does the US systematically ban high-gas-mileage cars?
(I find myself completely uninformed about the US auto market and vehicle regulations, but I'm also psychologically biased against the claim and so don't trust my own research very strongly.) | **There is no law in the US that bans high gas mileage cars**. In fact under Corporate Average Fuel Economy (CAFE) regulations manufacturers are fined for producing low gas mileage cars.
There are however regulations that place strict limits on the emissions produced by cars (note - Californian regulations but also used by many other states).
!LEV II Exhaust Mass Emission Standards
The emissions for the VW Passat 1.6 TDI sold in the UK are as follows (source):
!VOLKSWAGEN Passat Saloon 1.6 CR TDI
Converting the above data from mg/km to g/mi gives CO Emissions of 0.267 g/mi and NOx Emissions of 0.166 g/mi. **So the VW Passat 1.6 TDI can not be sold in any state using the Californian regulations as it emits too much NOx**. | stackexchange-skeptics | {
"answer_score": 16,
"question_score": 22,
"tags": "united states, road vehicles, politics"
} |
Is there a way to make the game announce whenever I advance in an achievement?
There are games that announce to the player once they advance in an achievement. Is there a way to do the same with Diablo. So that every time I open another chest/kill a new unique enemy the game will announce to me that I've advanced toward getting the challenge and how much I have left? | Currently, no announcements for advancing in an achievement exist besides the completion announcement. However, to track your progress you can still open the achievement menu and have a look on the progress bars there. | stackexchange-gaming | {
"answer_score": 4,
"question_score": 3,
"tags": "diablo 3"
} |
Edit grass block
Using add-ons, how do I edit the texture of a grass block? Do I use `grass.png`? Do I use `grass_carried.png`? Are either of those the answer? I see that in the default textures, `grass.png` is gray and `grass_carried.png` is green. | `grass.tga` is the block used for when it is placed.
`grass_carried.png` is used for certain textures that don't define a biome type, like in menus (i.e. the application of addons in the behavior/resource pack menu or inventory).
Whenever there is a texture that has a `_carried.png` variant, the carried one is for non-placement uses. | stackexchange-gaming | {
"answer_score": 1,
"question_score": 0,
"tags": "minecraft bedrock edition, minecraft resource packs, minecraft addons"
} |
Having Google's multiple sign-in log in to the same accounts
Since Google Apps accounts and Google Accounts have combined, I can now sign into both accounts but their relationship only lives until the end of the session or I logout.
I log back in I have to sign into the first account and into the second account again since they don't maintain that relationship beyond the session. Is there anyway to permanently associate the accounts so that when I log into one account, it automatically logs into both? | I think you can not because: Although Google Apps and Google Accounts allow you to access several of the same Google products, they're different types of accounts. A Google Account is a unified sign-in system that provides access to a variety of free Google consumer products -- such as Gmail, Google Groups, Google Shopping List, Picasa, Web History, iGoogle, and Google Checkout -- administered by Google. Google Apps provides access to products powered by Google but administered by a your organization.
What you can access directly from a google account are things such as Documents, Google Reader, Google calendar, etc. (all that appears near the upper left side of your screen when you log into google, including the utilities in the drop down menu. | stackexchange-webapps | {
"answer_score": 1,
"question_score": 1,
"tags": "google workspace, google account, google multi login"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.