INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Why does Git store the file in the repository when I just add it to the staging area?
From what I understand when you `git add` a file, it merely stages the file before adding it to the repository but why can I see it added into the git repository before I've committed it?
For instance, if I create a new git repository and create a new file called `foo` and add the contents "hello world" into it, and then `git add foo`, I see a new item in the `objects` subdirectory inside the `.git` folder. I can even view the contents of the new file inside the `objects` file with the `git cat-file -p` command.
What exactly has been added to the `.git/objects` folder? What does staging a file technically do? Like what are the steps that take place after a `git add` is run on a file? Maybe I'll understand it better if I know the steps.
|
The staging area is part of the repository.
I think you are confusing the repository's object database with the history. Only commits are part of the history, but all objects Git handles are part of the object database.
Think about it: Git doesn't stay resident in memory, so where else would it record what is part of the staging area than in its object database?
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 4,
"tags": "git, git add, .git folder"
}
|
Auto keyboard by using SendMessage
int VK_F_DOWN = GetVirtualKey('F', 0);
int VK_F_UP = GetVirtualKey('F', 1);
HWND hWnd = FindWindow(NULL,L"Calculator.exe");
SendMessage(hWnd, WM_KEYDOWN, toascii('F'), VK_F_DOWN);
SendMessage(hWnd, WM_KEYUP, toascii('F'), VK_F_UP);
It doesn't work on the Calculator.exe,however it can work on my visual studio when I change `hWnd` to `HWND(0xFFFF)`. And I also already got a non-zero `hWnd`. What am I missing here? Like authority or something?
|
Sounds like User Interface Privilege Isolation. As the Wikipedia article explains, you can request the access you want in your application manifest.
That said, you should be using SendInput rather than SendMessage. See one of Raymond Chen's blog entries on that point.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "sendmessage"
}
|
Recommended book on random processes to understand new functionality in Mathematica 9?
I am interested in exploring the new functionality on random processes available in _Mathematica_ 9, but I am not familiar with all of the underlying mathematics.
Could you recommend a book that provides a foundation on these topics?
I am thinking about a book that favors intuition and breadth over proofs. I have an engineering background (and know probability and statistics decently well) and would like to rapidly take advantage of these functions. I am interested in both modeling and estimation issues.
|
Introduction to Probability Models by Ross gives good description of stochastic processes. Applied Intertemporal Optimization by Walde also has easy to follow structure on stochastic models in both discrete and continuous time and it is free to download pdf.
|
stackexchange-mathematica
|
{
"answer_score": 5,
"question_score": 8,
"tags": "probability or statistics, random, reference request"
}
|
How to configure PostgreSQL to accept specific IPV6 incoming connection
I'm trying to connect to my remote DB from inside Intellij.
So I think I need to be in pg_hba.conf
I have my IPV4 local connections:
host all all my.IP.V4.ip/32 md5
Question: beneath this is a line to configure IPV6, I have the address but I don't know what exactly to put for the IPV6 line after the "/"? Do I even need the slash?
host all all 1:2:3:4:5:6:7:8/??? md5
UPDATE: Hmm, so I have...
host all all xxxx:xxxx:xxxx:ccc:xxxx:xxxx:xxxx/128 trust
...and my db client (intellij) is still asking for a username / password.
user:postgres....pass:none....is still failing
thanks in advance
|
`pg_hba.conf` takes CIDR addresses, so yes, just like with IPv4 address you'll need the slash and the number behind it.
If you want to narrow the permissible connection down to one specific host you'll want to specify a `/128`.
host all all 1:2:3:4:5:6:7:8/128 md5
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "linux, postgresql"
}
|
Identifying processes responsible for queries with client_port==-1 in pg_stat_activity
I'm trying to trace the source of postgres queries identified by a pid. Normally you can do this by finding the client_addr and client_port fields in the pg_stat_activity table.
However, some entries have client_port -1 or NULL. What does this mean and how can one go about finding the source of these queries?
I think NULL ports indicated that this is an internal postgres operation, and I suspected that -1 meant local connections - but I couldn't work out how local connections communicated with the postgres daemon.
|
I've found a magic trick that appears to work. At least on one particular ubuntu linux machine.
Run lsof on the postgres backend and find a unix socket something like this:
postgres 6571 postgres 8u unix 0xffff81061ab3a000 205980094 /var/run/postgresql/.s.PGSQL.5432
The value 205980094 is the inode. Though the client unix socket connecting to this socket is anonymous, and you can't convince lsof on linux to tell you the end point of unix sockets it is created at amount the same time as the backends socket. So appears to have an inode number which is usually adjacent to this number.
Running lsof on the whole system, restriction to unix sockets (using grep), and then sorting by this key ( _sort -k 7 -n_ ) should hopefully tell the process responsible for the query.
|
stackexchange-serverfault
|
{
"answer_score": 1,
"question_score": 2,
"tags": "linux, postgresql"
}
|
Saving and screenshot [image] to a database
I am trying to save a image directory that a user opened into a database. But the symbol "\" is not in the path. It is turning out like **C:UsersAshleyDesktopScreenshot_1.png** and as you can see it has no `\`, which make it an invalid path.
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
if (open.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = Image.FromFile(open.FileName);
pictureBox2.Image = Image.FromFile(open.FileName);
MySQL.ExecuteNonQuery(@"UPDATE users SET profile_image_dir = '" + open.FileName + "' WHERE username = '" + User.Details.Username + "'");
MessageBox.Show(""+ open.FileName + "\r\n");
}
On the MySQL.ExecuteNonQuery i am saving it to the database and it is turning out like as i showed before
|
A parameterized query should work
string cmdText = @"UPDATE users SET profile_image_dir = @file
WHERE username = @uname";
using(MySqlConnection cn = new MySqlConnection(.....))
using(MySqlCommand cmd = new MySqlCommand(cmdText, cn))
{
cn.Open();
cmd.Parameters.AddWithValue("@file", open.FileName);
cmd.Parameters.AddWithValue("@uname", User.Details.Username);
cmd.ExecuteNonQuery();
}
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 3,
"tags": "c#, mysql"
}
|
Proving rank$(S\circ T)\le$ rank $S$ and null$(S\circ T)\ge$ null $T$
Let $T$:$V\rightarrow W$ and $S$:$W\rightarrow U$ be linear transformations. I need to prove the two statements in the title.
I don't know how to approach this problem. I am quite sure it involves the use of rank-nullity theorem, an example for the first part:
$\text{rank } S=\dim W-\text{null }S$ and $\text{rank }(S\circ T)=\dim V-\text{null}(S\circ T)$
But even when assigning values, it doesn't prove to be enough to give a direct proof. Should I take different cases?
|
I suggest that you consider the spaces rather than their dimensions. If you prove that $$ range(S \circ T) \subset range(S) $$ then the statement about rank (which is just the dimensions of the two sides) follows.
Now something is in the range of $S\circ T$ if it's $S(T(v))$ for some $v$. Calling $T(v)$ by the name $w$, that means it's $S(w)$, which makes it in the range of $S$. So I've proved that anything in the range of $S \circ T$ is in $range (S)$. So I'm done.
Can you make the parallel argument for the nullspace/nullity?
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "linear algebra, matrix rank"
}
|
How to improve the flavor of gluten free challah bread?
I am trying to improve the taste of this gluten free challah recipe. The texture seems right, but I am trying to add more flavor. I am wondering what ingredients I have the freedom to modify. For example,
* Can I increase the butter without altering the chemistry? Will this add to taste?
* Can I increase the salt? Why is there so little to begin with?
Any other suggestions are welcome!
|
Baking is chemistry. Any changes in the formula will have some consequences on the chemistry. It can be fun to experiment but do not be surprised that the end result is not the same as from the per-modified formula.
As to your question of more flavor, I do know that increasing the proofing time will help to increase the development of the dough and allow it to extract more of the flavor available in the flour. Try slow proofing your loaf in a refrigerator or a very cool room.
I do not know anything about the flour in question but I know that the better the quality the flour the better your bread will be. Avoid flour from large industrial producers that use large steel mills, these create to much heat in the milling process and deplete flavor, enzymes and proteins. Find a good stone ground miller. You may be limited in the gluten free options.
|
stackexchange-cooking
|
{
"answer_score": 1,
"question_score": 3,
"tags": "baking, bread, gluten free"
}
|
String reasonString = reason(i); gives compilation error;reason is in red colour
reason is in red colour(compilation error)
@Override
public void onFailure(int i) {
//String reasonString = reason(i);//---> reason is in red colour(compilation error)
}
|
The scope of the reason() method must be,
1. inside that class in which, onFailure() method is overriding.
2. if you are using reason() method inside anonymous class ,then define reason() outside of that anonymous class.
3. if that anonymous class is user define, then define reason() method in that anonymous class.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -2,
"tags": "android"
}
|
HTML scraping returns template
I've been trying to extract data from a website using different methods (urllib & lxml for example).
My problem:
The HTML-files I recieve are the templates for the website. For example, I recieve `{{price}}` instead of `$3,543`.
Is there some general solution to this? Please ask if you need more information (not that I have a lot of it).
Thanks!
|
If you look at the page, you'll find some JavaScript is automatically submitting a form. The response will contain the price you want, so you need to find the request that's being made, and replicate it.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "html, screen scraping, urllib"
}
|
iPhone Pull Down Refresh like Tweetie
I am trying to find an example of placing an element above the Table View outside the normal scrollable region. How would I do this? An example would be what the Tweetie 2 app for the iPhone does to refresh tweets.
Sample code would be extremely helpful.
|
I did find the answer to my own question, for anyone who is interested.
EGOTableViewPullRefresh
I tried this solution and it works great! It is almost identical to the Tweetie Pull Down refresh.
|
stackexchange-stackoverflow
|
{
"answer_score": 52,
"question_score": 44,
"tags": "iphone, uitableview, pull to refresh"
}
|
Skipping the first line of the .csv in Map reduce java
As mapper function runs for every line , can i know the way how to skip the first line. For some file it consists of column header which i want to ignore
|
In mapper while reading the file, the data is read in as key-value pair. The key is the byte offset where the next line starts. For line 1 it is always zero. So in mapper function do the following
@Override
public void map(LongWritable key, Text value, Context context) throws IOException {
try {
if (key.get() == 0 && value.toString().contains("header") /*Some condition satisfying it is header*/)
return;
else {
// For rest of data it goes here
}
} catch (Exception e) {
e.printStackTrace();
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 13,
"question_score": 7,
"tags": "java, mapreduce, bigdata"
}
|
Pattern matching in R using grepl() function
I have below pattern match -
grepl("Close_[a-zA-Z]{0,}_{0,1}ASE_[a-zA-Z]{0,}_{0,1}", "Close_ASE_RS____")
#TRUE
R returns this as affirmative match. Shouldn't it be `FALSE` since I have `"____"` which has more than `1` repetition of `"_"`, but in my pattern I put only max `1` match through `"_{0,1}"`
Any pointer why it is happening will be highly helpful.
Thanks,
|
Try indicating the string ends after your initial pattern:
grepl("Close_[a-zA-Z]{0,}_{0,1}ASE_[a-zA-Z]{0,}_{0,1}$", "Close_ASE_RS____")
# [1] FALSE
Otherwise you can put anything after the initial underscore following `RS` and it will match it.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "r"
}
|
Running an HTTP request after a few HTTP requests have completed
I am creating a jmeter test that does an HTTP request and after a certain amount needs to run a clean up HTTP request. How can I accomplish something like this is jmeter? Currently I have a HTTP request and I would like to implement something where after 10 HTTP requests of the first POST I run this cleanup request to remove a dependency that the first one has.
Steps:
1. POST request #1
2. Follow step 1 - 9 more times
3. POST request #2
I need to be able to run 100 concurrent users doing this, any help would be appreciated.
|
You can use controllers to fulfill your requirements.
1. **Simple Controller** (POST request #1)
2. **Loop Controller** (Follow up requests) define # of times you want to execute inside loop controller
3. **Simple Controller** (Post request #2)
Let me know in case you need help on this.
|
stackexchange-sqa
|
{
"answer_score": 3,
"question_score": 1,
"tags": "jmeter"
}
|
discord.py/nextcord.py Reaction role with on_raw_reaction_add not working
I´ve been a long time trying to figure out why this isn´t working, the part that doesn´t work is where I get the role, but I can´t figure out why.
Does anyone know? :c
@client.event
async def on_raw_reaction_add(payload):
message_id = 999984925216358470
if message_id == payload.message_id:
user = payload.member
guild_user = user.guild
emoji = payload.emoji.name
if emoji == "<:hi:999730650087165993>":
role = nextcord.utils.get(guild_user.guild.roles, name="the role")
print(role)
await user.add_roles(role)
else:
print("Not a reaction roles message")
|
I'm not familiar with this library, but looking at the documentation tells me that the `nextcord.utils.get`-function does the following:
> A helper that returns the first element in the iterable that meets all the traits passed in attrs
> If nothing is found that matches the attributes passed, then None is returned.
I suppose, that there is no element in the iterable that meets the trait `name="the role"`. There could be many reasons for this, maybe you can find out if you take a look at the iterable `guild_user.guild.roles` by printing that, or better yet using a debugger.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, discord, discord.py, nextcord"
}
|
Entering CNAME and CNAME value into DNS for AWS Certificate approval
I am trying to get an SSL certificate supplied by AWS and the process give me the values that I should enter into the CNAME and value fields. I'm using Wix as our domain's DNS host. I am getting the error message that the value must be a valid domain name but the value that AWS suppied ends w/ xxxx.aws. Please help since Wix support really suck and I can't get a real person to help me.
|
For anyone else coming here trying to get this to work. The . (period) at the end of the value can be left off. I've found a few dns hosts that append this value for you and they will not let you add it. I was using Wix and this was the case, I also see that Linode is doing this as well.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "amazon web services, ssl, dns, cname"
}
|
Run one of two for loops
Suppose I had 2 for loops, each contains an if and else statement, I want it to work so that if the first `for`loop is achieved then to break and not run the second for loop. Probably a very simple solution, thanks any help.
The aim of this program is to read a user input and iterate over the `int` given, if the user doesn't input a int value then to iterate over 100.
As this code is everything is working except it is doing both loops, I want it to do one or the other.
package coreprog;
...
for (...){
...
if (...) {
...
}
else
System.out.println(...);
}
for (...){
...
if (...) {
...
}
else
System.out.println(...);
|
Keep a Boolean flag inside first for loop and Make it true before break.Based on it do it whatever you want to do. For example :-
boolean firstConditionAchieved= false;
for (...){
...
if (...) {
firstConditionAchieved = true;
...
}
else
System.out.println(...);
}
**Second loop :-**
if(!firstConditionAchieved){
......
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "java, for loop"
}
|
issues in spinner Android?
Hai i developed a application in android,in my application i used a dynamically created spinner(many spinner),the width in 320
**problem**
when 1 spinner text is like`"aaaa",`2 spinner text is like `"a".`the two spinner width is varied.i need the same width in all spinner.how to do?Anybody kindly solve my problem.
Spinner spinner = new Spinner(this);
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_dropdown_item,
spinnerArray);
spinner.setAdapter(spinnerArrayAdapter);
|
Try to create the spinner in XML layout with the width value and set visibility "GONE". When you have to use it, you can retrieve it by using findviewbyid method and then you have to set the visibility at VISIBLE.
Spinner spinner = (Spinner)findViweById(R.id.spinnerInvisible);
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_dropdown_item,
spinnerArray);
spinner.setAdapter(spinnerArrayAdapter);
spinner.setVisibility(View.VISIBLE);
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "android, spinner"
}
|
During an animation, can the properties of every CALayer be read atomically in the presentationLayer tree?
I'm looking for a solution to make a video from a CoreAnimation animation.
If I recursively enumerate the sublayers of my root CALayer presentation layer, is there a risk that the values(position, transform, opacity..) keep on changing while I'm a reading the properties in the (presentation) tree ? Or is the presentation layer like a deep copy of the CALayer hierarchy ?
|
The presentation layer is a deep copy of the model layer, with all the active animations applied. It's not actually the literal presentation tree that's used to render to screen, it's just an approximation.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "core animation"
}
|
Saving large image to filesystem with emgu CV
I am trying to save a large image (2048 x 2048 pixels) from a C# software to the filesystem using the emgu cv library:
var mat = new Mat( pathToFile, ImreadModes.GrayScale );
mat.Save( "imagename.png" );
The second line of the code snippet throws an exception with the message
> System.ArgumentException: Parameter is not valid. at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, Int32 stride, PixelFormat format, IntPtr scan0)
I found out, that the size of the image can be a problem, when the `save()` function creates a bitmap.
What other possibilites do you suggest, to save the `Mat`-image onto the filesystem?
Note that I the Image is not already stored in the filesystem as my code snippet implies. I am receiving it from a camera.
|
In fact the problem was not the size of the image. Before saving the image, some strange settings were made to the camera what made all taken pictures unreadable. Now it works.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c#, image processing, emgucv"
}
|
awk: to find out of order data in a single file
For the example file contents below
00000001.00000001
00000001.00000002
00000001.00000003
00000001.00000004
00000001.00000006
00000001.00000010
00000002.00000001
00000002.00000002
00000002.00000003
00000002.00000004
0000000b.00000001
Need to find the out of order data. Out of order meaning here is after 00000001.00000004 next should come is 00000001.00000005 not 00000001.00000006 as in the above. 00000001.00000010 is also a wrong entry as after 00000001.00000006 next 00000001.00000007 should come.
Using awk can we print odd likes 00000001.00000006 and 00000001.00000010 from the above file.
Note that all are considered here as numbers which will be in hexadecimals. EG 0000001a.0000000b are hexadecimal numbers means 8digithexadecimal.8digithexadecimal.
|
Here's one way using `awk`:
awk -F. 'NR > 1 && $1==a && $2 + 0 != b + 1; { a=$1; b=$2 + 0 }' file
Results:
00000001.00000006
00000001.00000010
* * *
**_EDIT1:_**
awk -F. 'NR > 1 && strtonum("0x" $1) == a && strtonum("0x" $2) != b + 1; { a=strtonum("0x" $1); b=strtonum("0x" $2) }' file
Results:
00000001.00000006
00000001.00000010
* * *
**_EDIT2:_**
String comparison:
awk -F. '$1 != x; { x = $1 }' file
Hex comparison:
awk -F. 'strtonum("0x" $1) != x; { x = strtonum("0x" $1) }' file
Results:
00000001.00000001
00000002.00000001
0000000b.00000001
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "awk"
}
|
Why is Zend_Form's best use for "RAD and prototyping"?
Can someone explain why it's best use is for prototyping? Should it not be used in a production app?
|
Zend_Form can be and I'm sure is used in production on many sites.
The reason you likely hear that Zend_Form is best used in prototyping is because with the way the current decorator's are used it can be very difficult to get exactly the look or code many people want.
Also support for multipage forms and very complex forms can be limited or require alot of work to get right.
The trick to making Zend_Form easier is to learn the _viewScript_ decorator, it's not perfect but it does help.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, zend framework"
}
|
c# linq create a third list combining two lists with different item count
I need do combine two lists in C#, like the following:
List1
[0]A
[1]B
List2
[0]C
[1]D
[2]E
I need as a result a list like:
List3
[0] A,C
[1] A,D
[2] A,E
[3] B,C
[4] B,D
[5] B,E
Would you lend me a hand? If possible, I'd like to do this using LINQ.
Thanks.
|
var List3 = (from f in List1
from s in List2
select $"{f}, {s}").ToList();
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -2,
"tags": "c#, linq"
}
|
How to calculate percentage increase between rows in Oracle SQL?
I have data like:
YEAR_MONTH|AVG_VISITS|WAS_MEMBER
2020-09|10|True
2020-09|5|False
2019-04|2.5|True
2019-04|5|False
I'd like to make it into a table that calculates the percentage of visits membership added:
YEAR_MONTH|VISIT_PERCENT
2020-09|200
2019-04|50
What is the SQL that would let me look between rows for this sort of calculation?
|
You just need conditional aggregation as follows:
select year_month,
100 * sum(case when WAS_MEMBER = 'True' then avg_visits end) /
sum(case when WAS_MEMBER = 'False' then avg_visits end) as perc_increase
from your_table t
group by year_month
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "sql, oracle, percentage"
}
|
enable acl in VPS
How can I enable `acl` in my VPS? I have the next in `/etc/fstab`:
proc /proc proc defaults 0 0
none /dev/pts devpts rw 0 0
And executing `df` I get:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/simfs 52428800 1971916 50456884 4% /
none 104860 64 104796 1% /run
none 5120 0 5120 0% /run/lock
none 524288 0 524288 0% /run/shm
When I try to do:
setfacl -R -m u:www-data:rwx -m u:manolo:rwx app/cache
I get "operation not supported" for each file.
|
You are using OpenVZ. In this case you need to open a ticket with the service provider; the community cannot help.
|
stackexchange-serverfault
|
{
"answer_score": 2,
"question_score": 1,
"tags": "vps, access control list"
}
|
How do I match one vectors index positions to a different vectors index positions?
I have two vectors with different values. I have sorted the second vector and need to rearrange the first vector so that it matches the index positions of the second vector. For example if vector B has values 3, 5, 1, 2 rearranged to 1,2,3,5, I need to sort vector A so that the index positions are the same as the positions of vector B rearranged. I've tried:
>sort(VectorB)
>match(c[VectorA], c[sort(VectorB)]
|
You are looking for `VectorA[order(VectorB)]`. To understand this issue, try
sig <- order(VectorB)
VectorB[sig]
VectorA[sig]
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 3,
"tags": "r, sorting"
}
|
How can I speed up my maven2 build?
I'm using a local artifactory to proxy the request, but the build and test phases are still a bit slow. It's not the actual compile and tests that are slow, it's the "warmup" of the maven2 framework. Any ideas?
|
There are some possibilities to optimize some of the build tasks. For example the 'clean' task can be optimized from minutes to just milliseconds using simple trick - rename 'target' folder instead of delete.
To get details how to do it refer to Speed up Maven build.
|
stackexchange-stackoverflow
|
{
"answer_score": 24,
"question_score": 35,
"tags": "maven 2"
}
|
Python Pandas KeyError when trying to save a timestamp to MySQL
I'm trying to save a data frame to a mysql database. But it seems that it doesn't work because of the timestamp (format?).
stock_hist = pd.io.data.get_data_yahoo('company', start = datetime.datetime(2010,1,1), end = datetime.datetime(2015,01,01))
stock_hist.to_sql('table', dbCon, if_exists='replace', index=False)
When I run this script, the following Error occurs .....
in escape_item
encoder = encoders[type(val)]
KeyError: <class 'pandas.tslib.Timestamp'>
Can't figure it out and couldn't find a similar answer...
|
Updating pandas from 0.14.1 to 0.15.2 as advised by joris worked.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "python, mysql, pandas"
}
|
Rails4: Cannot send email from lib/module
I have this weird thing going on in my rails4 app:
I created `event.rb` in the `lib` folder.
In there, I call a mailer:
def whatever
puts 'here'
UserMailer.welcome(user)
puts 'there'
end
which is calling
class UserMailer < ActionMailer::Base
def welcome(user)
@user = user
mail(to: @user.mailer, subject: 'Welcome to my app').deliver
end
end
The weird thing is that the method `welcome` is never called, while `whatever` is called, without raising any error (the logs are there).
But if I call `UserMailer.welcome(User.first)` in the console, it is sent.
What am I doing wrong? Is it that it is not possible to send an email from a module? I should move this code to a model? That would be weird.
Thanks in advance
|
IMO mailer should look like this:
class UserMailer < ActionMailer::Base
def welcome(user)
@user = user
mail(to: @user.mailer, subject: 'Welcome to my app') #.deliver removed
end
end
and should be invoked with this manner:
def whatever
puts 'here'
UserMailer.welcome(user).deliver_now # and added here
puts 'there'
end
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "ruby on rails, actionmailer"
}
|
Is there a known construction for heavy topologies of all sizes?
Given a set $A$ is there a known way to find a topological space $X$ such that $|A|=|X|<w(X)$?
Here $w(X)$ is the weight of the topological space.
This is clearly impossible for finite sets $A$. We know it is possible for $A=\mathbb Z$ because of the answers to this question.
Is there a general construction for any infinite set? Is it even known if such a space exists for every infinite $A$? Has a contruction been found for $\mathbb R$ for example?
Thank you kindly.
|
Let $U$ be a (free) ultrafilter on an infinite set $X$ which contains only sets of cardinality $|X|$ (that is, it is a normal ultrafilter). Put $\tau = U \cup \\{\varnothing\\}$; this is clearly a topology.
There is no base $B$ for $\tau$ with $|B|=|X|$ as every such base must have cardinality at least $|X|^+$ by a diagonal argument.
|
stackexchange-mathoverflow_net_7z
|
{
"answer_score": 4,
"question_score": 2,
"tags": "gn.general topology, examples"
}
|
How to reload a tableviewcontroller inside scrollview with pagination?
I have several instances of Tableviewcontroller inside a Scrollview using NSMUTABLEARRAY with pagination. The basic usage of scrollview is to create instances of tableviewcontroller with different dates and display tableviews inside scrollable scrollview. Now what I am trying to achieve is to reload tableview with different data using a button at navigation? Parent-view is Scrollview for x=50, all the child-view is alloc and initialized null then updated with data. how when i do change a parameter. all the new pages created will make request according to the new parameter but those all loaded will stills how previous data.
|
I am posting the answer for future results. Finally figured out after trying it hard.
CGFloat width = scrollView.frame.size.width;
//Getting the Current Page of ChildTableController inside scrollview
NSInteger page = (scrollView.contentOffset.x + (0.5f * width)) / width;
ChildTableController *child =[[ChildTableController alloc]initWithPageNumber:page];
[child.tableView reloadData];
This is how I did it and it works.
* get the width of the scrollview that was created
* round the page int from the float
* instantiate the ChildTableController at page
* reload tableview inside instance
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "ios, scrollview, tableview, reload"
}
|
How would one go about getting the USA to brain drain Russia by giving out green cards?
It has been suggested that offering green cards to Russians with STEM degrees can be an effective sanction against Putin. What would the political process for that be? Which political body in the USA could make such a decision?
|
> What would the political process for that be?
Congress could amend the Immigration and Nationality Act, which establishes the criteria for admitting new immigrants to the US.
> Which political body in the USA could make such a decision?
Congress, through the normal procedure for enacting statutes (which means that the president must assent or that congress must override the veto). There are various decisions vested in the president or the Secretary of Homeland Security, but they do not have the authority to create new categories of immigrants, and they do not have the authority to increase the number of immigrants eligible for existing categories. The president can increase the refugee quota but cannot make refugee status contingent on educational credentials.
|
stackexchange-politics
|
{
"answer_score": 1,
"question_score": 5,
"tags": "united states, russian federation, ukraine, visa"
}
|
Need guidance starting node js / scala app
I have installed yum/apt-get installed scala, "node install" installed gulp, but cannot find how to run it for dev mode. I have started a number of node applications in the past.
I am trying to start this app for development (I want to play with the the UI) <
FTA: "You're welcome to reuse as much code as you want for your projects"
Thanks for any guidance here
|
First of all I advice you explore languages and tools that you want to learn. If it's programming language what paradigm is support what kind of problem this lang solve and so on...
## Scala
* to getting start read wiki post)
* Twitter Scala school
* Scala on Coursera
* and the same time read this **book**
_Actually before pick up Scala will good have good knowledges in the Java_
## NodeJS
Before dive in NodeJS you **must** have good experience with JavaScript
* Node API
* Node.js Tutorial – Step-by-Step Guide For Getting Started
* you mentioned about Gulp.js, this playlist will nice for learning it quickly
NodeJS platform provide opportunity create Web app on pure JavaScript this third party libraries as AngularJS, Express.js or Meteor
|
stackexchange-superuser
|
{
"answer_score": 0,
"question_score": -1,
"tags": "linux, installation, node.js, development, scala"
}
|
Fuzzy Edges on Linear Gradient
The below css does exactly what I want (creates a single stripe on a background) except that the edges are slightly fuzzy. I need a clean edge (hard) between the white and tan. Any ideas?
background: linear-gradient(to right, white 300px, rgba(175, 156, 114, 0.4) 300px, rgba(175, 156, 114, 0.4) 499px, white 500px);
Also, pretty positive it's possible because this css creates a clean edge, but then the tan continues on forever:
background: linear-gradient(to right, white 300px, rgba(175, 156, 114, 0.4) 300px);
|
You can use two simple (1 stop) linear gradients - the bottom one white and tan, and the top one transparent and white.
body {
background: linear-gradient(to right, transparent 500px, white 500px),
linear-gradient(to right, white 300px, rgba(175, 156, 114, 0.4) 300px);
}
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "css, linear gradients"
}
|
Wilson's Theorem Application to Quadratic Residues
Im a noob and trying to prove: $(m!)^2\equiv(-1)^{m+1}\textrm{(mod p)}$ using Wilson's Theorem. Although it's on Wikipedia, I want to really understand what is happening. Could someone explain how $$\begin{align*}1*2\dotsb*(p-1)=1*(p-1)*2*(p-2)\dotsb m*(p-m)\end{align*}$$ What is m? How is it possible for (p-1)! to have this expansion. Then could someone also explain the property that was used to transform this: $$(-1)^m(m!)^2\equiv-1\textrm{(mod p)}$$ into $$(m!)^2\equiv(-1)^{m+1}\textrm{(mod p)}$$ I understand that $-1^1*-1^m=-1^{m+1}$, but how did the $-1^m$ move from the left side to the right. Thanks for help! Wilson's Theorem Quadratic Residue
|
$m$ is $(p-1)/2$.
You can multiply a congruence by the same thing on both sides. Also, $(-1)^m\cdot(-1)^m=(-1)^{2m}=1$. Thus the result.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "proof explanation, factorial, quadratic residues"
}
|
How to calculate 95% CI for area under the precision recall curve in R
I calculate area under the precision recall curve using the Mleval package. The Mleval package provides 95% CI for the AUROC but not AUPRC. Is there a package that provides 95% CI for AUPRC?
|
The `precrec` library gives an AUC for precision-recall as well as ROC, as shown in this example with dummy data:
library(precrec)
set.seed(1)
## Create sample datasets with 100 positives and 100 negatives
samps <- create_sim_samples(2, 100, 100, "good_er")
## Single model & multiple test datasets
smmdat <- mmdata(samps[["scores"]], samps[["labels"]],
modnames = samps[["modnames"]],
dsids = samps[["dsids"]])
mod <- evalmod(smmdat)
auc_ci(mod)
#> modnames curvetypes mean error lower_bound upper_bound n
#> 1 good_er ROC 0.8192000 0.0007839856 0.8184160 0.819984 2
#> 2 good_er PRC 0.8603505 0.0154645417 0.8448859 0.875815 2
Created on 2022-03-06 by the reprex package (v2.0.1)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "r, logistic regression, confidence interval, precision recall"
}
|
Selenium java can't get html text
I have this HTML code:
<span id="slotTotal">
<span id="slotUsed">4</span>
/16
</span>
I want to get text /16 but when I try:
slotTot = driver.findElement(By.xpath("//*[@id='slotTotal']")).getText();
I get this Exception: org.openqa.selenium.InvalidSelectorException: invalid selector while trying to locate an element
How can I fix that? (If I get 4/16 is good too...) thanks in advance
|
**To get text of SlotUsed**
String slotUsed= driver.findElement(By.xpath("//span[@id='slotUsed']")).gettext();
System.out.println("Value of used slot"+slotUsed);
**To get SubTotal** (subtotal is part of first span element)
String total=driver.findElement(By.xpath(".//span[@id='slotTotal']")).getText();
System.out.println("Total"+total);
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java, html, selenium, gettext"
}
|
Why can I put comments in some JSON files but not others?
My IDE (WebStorm) lets me put comments in some of my JSON files (e.g., `tsconfig.json` and `.eslintrc.json`, but balks at allowing them in others (e.g., `package.json` and `app.json`).
The former are subsequently identified as "JSON with Comments" on GitHub (even if I don't actually have comments in them).
Why can I put comments in some JSON files but not others?
|
By default the IDE checks for strict standard compliance, as standard JSON doesn't allow comments.
We have a set of options to relax compliance checking in **Settings | Editor | Inspections, JSON and JSON5 | Compliance with JSON standard** , and for some files the option for checking comments is off by default (`tsconfig`, `tslint` and `eslint` configs), as corresponding tools allow comments in JSON (this is hardcoded).
If you need adding comments to certain JSON files, you can add their names to the list of patterns associated with **JSON5** file type in **Settings | Editor | File Types** \- JSON5 standard allows comments
|
stackexchange-stackoverflow
|
{
"answer_score": 17,
"question_score": 11,
"tags": "json, comments, webstorm"
}
|
Png Image support of J2ME WTK Emulator
I use a png image in my project that is not displayed in emulator but it can be displayed in phone. Then i open it with photoshop, save as png and use that image. It is displayed both emulator and phone. I couldn't figure out the difference of original and edited one. And is there any setting of emulator for image display? And how can i understand any png file is supported or not?
!original image
original image
!edited image
edited image
|
I preferred PNG files is good for MIDP. You can check following links, It will helps you.
What image types does MIDP support?
Image Formats in J2ME
|
stackexchange-stackoverflow
|
{
"answer_score": -1,
"question_score": 2,
"tags": "java, java me, png, image formats, java wireless toolkit"
}
|
Drupal: change $link->text depending on a specific node in flag.tpl.php?
I’m taking over a Drupal site where I’m currently working on changing the text (the $link_text) depending on the current, active node.
Because I’ve taken over the development of the site I haven’t been involved in the actual development and therefore can change the code to much because the site is already in production and pretty much working except some small issues, where this is one of them.
I’m working in the flag.tpl.php file where I want to say:
$nodetype = $node->type;
if($nodetype == 'image'){$link_text='recommend image';}else{$link_text='recommend post';}
But unfortunately the flag.tpl.php doesn’t support $node->type selection so I was wondering if there was a workaround for this?
Sincere
\- Mestika
|
I don't really understand exactly what you are trying to accomplish.
However, if you are talking about dynamically changing the text of hyperlinks, I don't think you can do that except by using jquery.
If I have guessed correctly, you just need to perform a check to see if a link has a class of active and use the text() function to change the text of the link.
Hope I helped you.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "drupal, drupal 6, drupal views, task parallel library"
}
|
PlaceAutoComplete over query imit
Error while autocompleting: OVER_QUERY_LIMIT
I got this error in autocomplet. error came at first request of the day. please help me to recover this
|
We have to purchase the google cloud platform for it to work.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "android, google places api"
}
|
How to update multiple dropdownlists using Ajax in Asp.net-MVC
I have multiple identical dropdownlists created by a `@html` helper. In each dropdown, there is one option which is named "Create a new one".
When I click this option, there is popup showing up and allows me to fill out infor and create a new option. I'm totally up to this part, and get it saved to database successfully.
But what I want is as soon as I close the popup, the newly created option will also show up to other dropdownlists. What should I do? examples are greatly appreciated.
|
I think you can try something like this: ASP.NET MVC Html.DropDownList populated by Ajax call to controller?
when close the popup, update the drop downs
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "jquery, ajax, asp.net mvc, html helper, html.dropdownlistfor"
}
|
React TypeScript button with loading spinner
I have a button inside a react component, the test on the button says `Join Now` when the button is clicked I call the function `submitForm` which then sets the state to true. I want the loading svg image to be displayed but instead the path to the image is shown on the button.
import React, { useState } from 'react';
import Context from './context';
import loading from '../images/loading.svg';
const ButtonSpinner: React.FC = () => {
const [state, setState] = useState({loading: false});
function submitForm() {
setState({ ...state, loading: true})
}
return (
<button className="btn-join" onClick={submitForm}>
{!state.loading && 'Join Now!'}
{state.loading && loading}
</button>
);
}
export {ButtonSpinner};
|
import React, { useState } from 'react';
import Context from './context';
import loading from '../images/loading.svg';
const ButtonSpinner: React.FC = () => {
const [state, setState] = useState({loading: false});
function submitForm() {
setState({ ...state, loading: true})
}
return (
<button className="btn-join" onClick={submitForm}>
{!state.loading ? 'Join Now!' : <img src={loading} alt="loading" />}
</button>
);
}
export {ButtonSpinner};
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "javascript, reactjs"
}
|
I have error on checkout page
I have error on checkout page (see the image) . Continue button is not working. Any luck ?  , and the way you added the values blocks the current page for proceeding. Use this for delivery country :
"delivery_country": "<?php echo $googleRatingData['delivery_country'] ?>",
For the delivery date :
"estimated_delivery_date": "<?php echo $deliveryDate=Date('Y-m-d', strtotime("+12 days")); ?>",
Update the date as you want.
If this doesnt work for you , paste the full script here (without the mercant id ) so we can debug.
|
stackexchange-magento
|
{
"answer_score": 1,
"question_score": 0,
"tags": "magento 1.9, magento 1"
}
|
Wired-or open drain with open collector outputs
I have a comparator with open collector output (LM311) and a gate with open drain output (SN74LVC1G06). I want join these two outputs to make a wired-or, with a pull-up resistor tied to +3.3V.
In a general way, is it appropriate to join an open-drain output with an open-collector output?
|
There really isn't an issue with that. Open drain and open-collector are essentially the same in this application.
Two things to watch out for:
1. Make sure you get your polarities right and that you need an OR gate and not a NOR gate because the open-collector/open-drain style often invert your signal. If the output of either opamp is high, then the output of that IC will be pulled low, and vice versa.
2. Just make sure each IC can sink (Vcc/R1)+(Vcc/R2). This will be the worst case current if one output is low, and the other is high.
Picture for reference.
!enter image description here
|
stackexchange-electronics
|
{
"answer_score": 3,
"question_score": 1,
"tags": "open collector, open drain"
}
|
How to install applet on smart card using java
Is there any way to load . **cap** (converted applet) design in java card in to java and then install applet from that .cap(converted applet) file into smart card?
I am having .cap file that is converted applet file and i want to install applet present in that .cap file.
First tell me how to load .cap file in java.
In java i am using **javax.smartcardio** package to interact with smart card and apdu commands to interact with applet installed in smart card.
I am using:
1. smart card type = contact card
2. using **JavaCard2.2.2** with **jcop** using **apdu**
|
On every programmable JavaCard there is a pre-loaded applet called "CardManager". This applet has to be used for uploading and installing new applets.
In most cases the used SDK of your JavaCard comes with libraries that encapsulate the necessary steps for selecting the CardManager (including necessary authentication), loading and installing an applet. It bases on the install and load commands defined in the GlobalPlatform standard.
The necessary steps/commands are for example explained here: Installing JavaCard Applet into real SmartCard. However the concrete authentication sequence (CardManager AID, used authentication key) for your card depends on what card type you have.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 5,
"tags": "java, applet, smartcard, javacard, apdu"
}
|
Remove trailing ]> from the page
I'm using a doctype with custom attributes to validate XHTML. Here is my Doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
[
<!ATTLIST div data-localized CDATA #IMPLIED>
]>
But the problem is that it's displaying "]>" when I load my page on the browser. The XHTML validates fine.
|
Check out the article in A list apart \-
> Unfortunately, when you display the file in a browser, the ]> shows up on the screen.
It points out a solution that involves using a separate DTD file (which will fail in W3C validator...)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "html, validation, xhtml"
}
|
How to put UIImageView on the background of the layout
Greetz,
So this is rather a simple question (maybe not a simple answer). I want the IB option called 'send to back' (On IB, go to Layout -> Send to back) to be done programmatically.
Is it possible? If not, any suggestions to simulate the same thing?
This is for an UIImageView as the title states.
|
Use `sendSubviewToBack:`
[yourSubView.superview sendSubviewToBack:yourSubView];
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 0,
"tags": "iphone, objective c, cocoa touch, layout, uiimageview"
}
|
What's the standard way of doing this sort in Python?
Imagine I have a list of tuples in this format:
(1, 2, 3)
(1, 0, 2)
(3, 9 , 11)
(0, 2, 8)
(2, 3, 4)
(2, 4, 5)
(2, 7, 8)
....
How could I sort the list by the first element of the tuples, and then by the second? I'd like to get to this list:
(0, 2, 8)
(1, 0, 2)
(1, 2, 3)
(2, 3, 4)
(2, 4, 5)
(2, 7, 8)
(3, 9 , 11)
I was thinking to do a sort for the first element, and then go through the list, and build a hash with subarrays. I will probably overcomplicate things :), and this is why I asked for other ways of doing this sort.
|
Why not simply let python sort the list for you ?
my_list = [
(1, 2, 3),
(1, 0, 2),
(3, 9 , 11),
(0, 2, 8),
(2, 3, 4),
(2, 4, 5),
(2, 7, 8),
]
print sorted(my_list)
>>>[(0, 2, 8), (1, 0, 2), (1, 2, 3), (2, 3, 4), (2, 4, 5), (2, 7, 8), (3, 9, 11)]
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 5,
"tags": "python, sorting"
}
|
Print PDF with Acrobat Pro: select printer
I can print a PDF with Acrobat (not the reader) Here is the code:
var mApp = new AcroAppClass();
var avDoc = new AcroAVDocClass();
if (avDoc.Open(filename, ""))
{
var pdDoc = (CAcroPDDoc)avDoc.GetPDDoc();
avDoc.PrintPagesSilent(0, pdDoc.GetNumPages()-1, 2, 1, 1);
pdDoc.Close();
avDoc.Close(1);
}
if (mApp != null)
{
mApp.CloseAllDocs();
mApp.Exit();
}
This will print the PDF to the default windows printer.
Is there a way to choose the printer without changing the windows default printer?
|
Here is the documentation: <
It seems this is not possible:
> PrintPages always uses the default printer setting.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c#, pdf, acrobat"
}
|
Are the Puppy Bowl puppies trained to play the game?
Instead of watching the Super Bowl this year, I decided to watch the Animal Planet Puppy Bowl, featuring puppies dragging toys around the field and scoring if they drag it to the end zone.
It made me wonder, are the puppies trained to drag toys to the end zone and play nicely with others on their team? Or are they just given free reign to do what they want and they are unaware that the goal is to get it to the end zone?
Also, are any other animals on the show trained (e.g. Half-Time show cats, cheer-leading roosters, smartphone typing parakeet)?
|
They aren't really trained since the dogs are all puppies who are available for adoption in shelters nationwide. But their handlers do have tricks:
> Peanut butter has proved useful in luring the pups apart — or getting them to do anything, really. Spread some peanut butter on the edge of a camera lens and it’s a guaranteed adorable puppy-licking-America’s-TV-screens moment.
Animal Planet has a video showing how the kittens are choreographed and other similar ones.
|
stackexchange-movies
|
{
"answer_score": 5,
"question_score": 5,
"tags": "production, puppy bowl"
}
|
Image not showing in header when added in div
I have Below code in my header.html
<div class="col-md-3">
<div class="logo">
<a href="
</div>
</div>
But it's not showing my png image in header, Is the way adding image path in div is wrong?
|
<img src="
That is how you use an image. You are placing a link to the image. Also, you are not seeing anything because your `<a></a>` tags are empty. If you write something between them, you can click on it, to see the image you linked.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": -1,
"tags": "php, html, css"
}
|
Use the path for a spreadsheet that is provided in another cell in Excel
Good day,
I have two spreadsheets and I'm trying to get values from the second spreadsheet (Sheet.xlsx) to the main spreadsheet. This works perfectly by providing the whole path manually, but I want to get the path from another cell in the main sheet, like shown below:
. What path it should produce:

, name='article_detail'),
...
]
I want to get this `pk` in the view class:
class ArticleDetailView(generic.DetailView):
model = Article
def get_context_data(self, **kwargs):
pk = kwargs['pk']
However, this raises a KeyError:
KeyError at /article/2/
'pk'
|
You can get `pk` in `DetailView` from `self.kwargs`. So it should be
class ArticleDetailView(generic.DetailView):
model = Article
def get_context_data(self, **kwargs):
pk = self.kwargs['pk']
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "django"
}
|
Size/Location of Winforms MDI Client Area
Inside an MDI form is a client area that hosts the mdi child forms. How do I find out how big that area is? The best I can come up with so far is finding the total size of the parent's potential client area (mdiparent.ClientRectangle) and then subtracting off the sizes of components like toolbars, etc that take away from the client area. Is there a better way?
|
There is no property on a form that gives you access to the MDI client window. But you can find it back like this:
public MdiClient GetMdiClientWindow() {
foreach (Control ctl in this.Controls) {
if (ctl is MdiClient) return ctl as MdiClient;
}
return null;
}
From there, just use its Size property.
|
stackexchange-stackoverflow
|
{
"answer_score": 23,
"question_score": 12,
"tags": "winforms, mdi, mdichild, mdiparent"
}
|
PHP's preg_match
I am trying to get ONLY the numbers between the two brackets ([ ]) out of the string.
Here is my code:
$str = "[#123456] Some text";
preg_match('/^[#(?P<number>\w+)]/', $string, $matches);
// Returns 123456
echo $matches['number'];
Anyone able to help me out with this?
EDIT: I cleared up my question. I need to get ONLY the numbers between the brackets. The responses so far will give me numbers in the whole string.
|
If you need the numbers as well as the braces around them, you can use this regex:
preg_match('/\[#\d+\]/U', $str, $matches);
echo $matches[0];
Otherwise, use
preg_match('/\[#(\d+)\]/U', $str, $matches);
echo $matches[1];
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "php, preg match"
}
|
How do I remove old ZFS snapshots
After running updates on Ubuntu I receive a warning about my ZFS filesystem. Is there a utility or script I can use to remove old snapshots? Below is the message:
ERROR couldn't save system state: Minimum free space to take a snapshot and preserve ZFS performance is 20%.
Free space on pool "rpool" is 10%.
Please remove some states manually to free up space.
|
Use zfs-prune-snapshots, described as:
> Remove snapshots from one or more zpools that match given criteria
An example from the docs:
> Remove snapshots older than a week across all zpools
>
>
> zfs-prune-snapshots 1w
>
>
> Same as above, but with increased verbosity and without actually deleting any snapshots (dry-run)
>
>
> zfs-prune-snapshots -vn 1w
>
You may find more methods in the post [How to delete all but last [n] ZFS snapshots?](
|
stackexchange-superuser
|
{
"answer_score": 0,
"question_score": 1,
"tags": "zfs"
}
|
In Excel how to get the left 5 characters of each cell in a specified column and put them into a new column
I want to take the left 5 characters of each cell in column E and put them into the adjoining cell in column F:
A...B....C...D......E..................F
123.bb...cc..dd.....90210ABCE13........90210
555.bb...cc..dd.....10056Z19s..........10056
Using Left(x, 5) function, how does Excel say "do this to every cell in the specified column"?
|
1) Put `=Left(E1,5)` in `F1`
2) Copy `F1`, then select entire `F` column and paste.
|
stackexchange-stackoverflow
|
{
"answer_score": 28,
"question_score": 11,
"tags": "excel, excel formula"
}
|
Verification on finding the radius of convergence of a Laurent series, "the largest R".
> **Question:**
Determine the largest number $R$ such that the Laurent series of
$$f(z)= \dfrac{2}{z^2-1} + \dfrac{3}{2z-i}$$
about $z=1$ converges for $0<|z-1|<R$?
> **Attempt:**
>
> The radius of convergence of the Laurent series about one of its poles is equal to the distance to the nearest neighboring pole.
>
> In the case of interest, $f(z)= \dfrac{2}{z^2-1} + \dfrac{3}{2z-i}$, and there are three poles; $z=1$, $z=\dfrac{i}{2}$, and $z=-1$.
>
> The distances between the original pole at $z=1$ and the other poles are $|1-(-1)|=2$, and $|1-\biggr(\dfrac{i}{2}\biggl)|=\sqrt{\dfrac{5}{4}}<2$.
Therefore, the Laurent series of $f(z)$ around $z=1$ has a radius of convergence $R=\sqrt{\dfrac{5}{4}}<2$. Is this correct, or, since the question asked for the largest number $R$, would R not be $=2$?
|
The function has poles at $\;z=\pm1\,,\,\,\frac i2\;$ , so the maximal convergence radius of convergence around $\;z=1\;$ cannot be greater than
$$\left|1-\frac12i\right|=\sqrt{1+\frac14}=\frac{\sqrt5}2$$
Together with my comment I think this explains why $\;R=2\;$ cannot be.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": -1,
"tags": "calculus, complex analysis, laurent series"
}
|
Distinct Eigenvalues of a matrix
In one of the competitive exams, they asked the below question.
Q). The number of distinct eigenvalues of the matrix A is equal to ___
and The matrix A is given below,
2 2 3 3
0 1 1 1
0 0 3 3
0 0 0 2
Since it is upper triangular matrix, the Eigenvalues are its diagonal elements. That is (1,3,2,2)
My answer: There are 4 Eigenvalues among which two are distinct (1,3) & two are same (2,2). So I answered 2 for that question.
Now the key answer came out from examination board & the answer is 3(distinct Eigenvalues are 1,3,2). That is there are 3 distinct Eigenvalues.
Is my way of understanding distinct correct or not? What is the correct answer?
|
In mathematical English, the word "distinct" means that we count every object that occurs at least once, but we count each such object only once. For example, the number of distinct letters in the word "distinct" is $6$, since d, i, s, t, n, and c each occur in the word (and no other letters do); the number of distinct eigenvalues of $A$ is $3$, since $1$, $2$, and $3$ are the eigenvalues. This is the same as counting the number of elements in the sets {d,i,s,t,i,n,c,t} = {d,i,s,t,n,c} and $\\{2,1,3,2\\}=\\{1,2,3\\}$, respectively.
If we wanted to describe your interpretation, we could use "unrepeated" or "that appear exactly once" or "that appear with multiplicity $1$". For example, the number of letters that appear exactly once in the word "distinct" is $4$ (they are d, s, n, and c); the number of unrepeated eigenvalues of $A$ (the number of eigenvalues of $A$ that appear with multiplicity $1$) is $2$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "linear algebra, matrices, eigenvalues eigenvectors"
}
|
Gravar Varios Numeros Em Um Campo No Banco De Dados
Galera eu tenho uma coluna numa tabela no banco de dados que se chama "sincroniza" dentro dela eu quero salvar varios numeros separados por virgula, e depois fazer uma verificação em uma pagina da seguinte forma, que se existir entre aquelas virgulas um numero que seja igual ao numero passado na URL ele faça uma função pra mim, de qual forma eu consigo incrementar um numero novo com a virgula nessa campo "sincroniza" e como eu faço para verificar entre as virgulas se esse numero é igual ao passado na URL?? Obrigado des de já
|
Utilize campo formato JSON.
MySQL da suporte para formato JSON, que é perfeito para seu intuito.
Basicamente:
Você irá capturar os números, colocar em um array e converter para JSON, após isso irá salvar no banco.
$numbers = [1,2,3];
$json = json_encode($numbers);
// save to db
Basicamente. MySQL da suporte nativo para field json, como você pode consultar na documentação:
<
Após salvar, basta executar as querys com `JSON_CONTAINS` para verificar se o número informado esta presente no campo.
 inside one folder (A) into another folder (B) without copying over (B)'s current contents?
Folder A
- file 1
- file 2
- file 3
Folder B
- file 4
- file 5
- file 6
I'd like the end result to be:
Folder A
- empty
Folder B
- file 1
- file 2
- file 3
- file 4
- file 5
- file 6
|
svn move foldera/file*.ext folderb
svn commit -m "move all files in foldera to folderb" .
<
If you have files with the same filename in the target directory they will be overwritten. You'll have to inspect and issue the correct svn move command (or multiples of it) for your situation. This works in your local directory so you can inspect the results before you check in. If you use the svn url instead of paths in your working copy it'll be committed immediately.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 3,
"tags": "svn, copy, move"
}
|
Remember sudo password until screen lock possible?
I usually use Linux as my standard working system and I learned a lot from actually using it. For this particular question I found no answer yet.
The `sudo` command usually remembers me typing in my password for a given time (usually 15 minutes I guess). Is it possible to extend this time to an undefined length but instead ask for the password again after locking my screen?
I always lock my screen when I leave my computer alone (even for seconds) and would like to not always retype my password when doing something.
I dont want to disable the password check in general. If I let anyone doing anything on my computer they still shouldnt be able to use the `sudo` command without me typing it once first.
|
If you can make your screen-lock mechanism run an extra command on locking, then you can edit `/etc/sudoers` to add a line for your user id, eg `myname`, which says
Defaults:myname timestamp_timeout=-1
This makes the timeout infinite. To revoke your sudo rights explicitly, run `sudo -k` from your screen-lock.
As usual when editing this file take precautions, eg use `sudo visudo` and ensure you have a root shell ready in some other terminal.
|
stackexchange-superuser
|
{
"answer_score": 3,
"question_score": 3,
"tags": "linux, ubuntu, sudo, lock"
}
|
Prove $[a]_n$ has a unique representative $r$ where $0\leq r<n$
Prove each congruence class $[a]_n$ in $\mathbb{Z_n}$ has a unique representative $r$ such that $0\leq r<n$.
My proof. Assume to the contrary that $[a]_n$ does not have a unique $r$. That is let $r'$ be the other representative such that $r\neq r'$ and $0\leq r,r'< n$. By the division algorithm and our assumption it follows that $a=nq+r$ and $a=nq'+r'$ where $q, q'\in\mathbb{Z}$.But it follows that $nq+r=nq'+r'\implies nq-nq'=r'-r\implies n|(r'-r)\implies r'\equiv r \pmod{n} $. But since we assumed $0\leq r,r'< n$ it follows that $r=r'$ a contradiction. Would this be correct?
|
Just divide any integer number by n and the existence of such a representative is straightforward from Euclid's division theorem. Your prove about uniqueness is good and acceptable intuitively, but it's not completely rigorous I think. You can go one step further in your argument and say $n|(r-r')$ gives $n \leq |r-r'|$. but $0 \leq r<n$ and $0 \leq r'<n$ gives $0 \leq|r-r'|<n$ .But if $|r-r'| \neq 0$ we'll have $|r-r'| < |r-r'|$ which is absurd. Therefore $|r-r'| =0$ and because both $r$ and $r'$ are positive we must have $r= r'$
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "elementary number theory"
}
|
Does wireless n offer better range than g with obstructions?
I have a wireless g router and a wireless USB dongle. I have just recently moved my pc into another room thus putting a brick wall between me and the router. I am now exxoerience drop outs and poor speeds. The router is fine on wireless devices within the room. Which makes me believe it's a range and obstruction issue.
I'm looking at some wireless n routers as they say they have better range and speed than g. My router currently has 1 antenna and the one I'm looking at appears to have 1 antenna.
Will the n router provide better connectivity and speed than my g router? Are there certain things to look for? I'm looking at a d-link router.
|
Not an answer to your question, but still a possible solution to your problem: Use an aluminum can as a WiFi extender. Only takes a few minutes to try it out and see if it solves your problem, before buying a new router.
|
stackexchange-superuser
|
{
"answer_score": 1,
"question_score": 1,
"tags": "networking, wireless networking, router, wireless router"
}
|
Locking in rates during yield curve inversion
While reading multiple articles about yield curve inversion, a common theme is that investors seeing an economic slowdown in the future which generally means lower interest rates so they want to lock in today's rate.
I'm confused as to why they wouldn’t just buy shorter dated maturities because the coupons from the longer term bonds will still have to be reinvested at current market rates so how can the investor “lock in” today's rate?
|
> the coupons from the longer term bonds will still have to be reinvested at current market rates
The interest earned from reinvestment of the original bond's interest is a _second-order_ effect. It is dwarfed by the first-order effect of reinvestment of the _principal_ after maturity of a short-term bond; that means the _entire_ investment will likely be earning a lower return in the future. The long-term bond locks in the higher return on the bulk of the investment.
Note, "interest on interest" can _eventually_ grow greatly through compounding, but the terms and rates of bonds are typically not sufficient to reach the many-fold growth regime.
|
stackexchange-money
|
{
"answer_score": 1,
"question_score": 1,
"tags": "bonds, government bonds, yield, fixed income, yield curve"
}
|
Re-enabling secure boot after Ubuntu install and disk erase
I used to have Windows 10 on my laptop, which ran very slowly. I decided to install Ubuntu 18.04 on it, so I disabled secure boot. Now, the laptop takes a long time to boot up. Is it safe to re-enable secure boot? If the model is neccessary, it's an ASUS X551MA.
|
To answer your exact question, yes, it's safe to re-enable secure boot.
> All current Ubuntu 64bit (not 32bit) versions now support this feature.
> Sources:
> Ubuntu Secure Boot
> How UEFI Secure Boot works on Ubuntu
As for the slow booting, I doubt secure boot is affecting this. How long does it take to boot? Windows 10 uses a hibernation method called "fast startup" to rapidly load your system from a saved image, though it's not a true "from zero" boot. Maybe you're comparing Ubuntu's load time to this, and it just seems slow by contrast. Anywhere in the 1 minute ballpark shouldn't be worrisome.
|
stackexchange-askubuntu
|
{
"answer_score": 1,
"question_score": 2,
"tags": "secure boot"
}
|
Why is my XML file not rendered properly in Firefox?
I am using Firefox to read XML files, but it is not rendering the XML file properly. What could be the problem? I’m posting the XML sample below:
<?xml version="1.0" encoding="utf-8"?>
<ExtPostTransaction>
<TransactionInfo>
<UserID>us</UserID>
<Password>pwd</Password>
<ServiceCode>1010</ServiceCode>
<TransactionID>T20120518091833</TransactionID>
</TransactionInfo>
</ExtPostTransaction>
My Firefox shows it as:
uspwd1010T20120518091833
I am expecting this:
<ExtPostTransaction>
<TransactionInfo>
<UserID>us</UserID>
<Password>pwd</Password>
<ServiceCode>1010</ServiceCode>
<TransactionID>T20120518091833</TransactionID>
</TransactionInfo>
</ExtPostTransaction>
|
Finally found the solution for me. When Firebug is enabled it seems Firefox renders the XML file wrongly. When it is off, XML files are rendered properly.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 35,
"tags": "xml, firefox"
}
|
Does the tangle store any node-specific information?
1. When a node broadcasts a transaction/bundle, is the node IP or hostname only revealed to the node's immediate neighbors, or does this information accompany the broadcast in some way?
2. Does a transaction on the tangle store anything related to the node that created it?
|
1. Broadcast of transactions just contains the transaction trytes, no other metadata (e.g. originator information). Therefore, IP addresses are only visible to immediate neighbors (and they can tell neither whether the transaction was injected at that node or just relayed)
2. The local transaction database stores some metadata about transactions that are not part of the transaction trytes (like whether the transaction is solid or confirmed); this includes the timestamp when the transaction first appeared at that node and the sender's (neighbor that first sent the transaction) IP address (or `local` if the transaction was injected via API). So if you have access to all node databases, you could eventually find the node that has stored "local" here... There is no programmatic way (via API or other calls) to retrieve this sender information, yet (except looking directly into the backend database).
|
stackexchange-iota
|
{
"answer_score": 2,
"question_score": 5,
"tags": "tangle, neighbors"
}
|
Ghost .mdb File
So today I try, of all things, to create an mdb file with VB.NET (2012) and DAO. Please see following:
Dim myEngine As New DAO.DBEngine
Sub CreateMDBFile()
myEngine.CreateDatabase("C:\Windows\Test.mdb", ";LANGID=0x0409;CP=1252;COUNTRY=0", 64)
End Sub
It seems to work great. Code executes, and I have other subroutines that create and populate tables. I can retrieve data from recordsets, the whole 9 yards. There's just one weird issue:
When I open Explorer, I can't find the mdb file. It's not there. I mean, my program can find it, open it, populate it and query it -- But as far as Windows Explorer is concerned, there's nothing there.
Is this a Win 8 bug? Why won't my mdb file show up in Windows Explorer?
Thanks in Advance,
Jason
|
When an application not "Run As Administrator" (UAC) attempts to write to a system folder (including Program Files subdirectories), Windows no longer returns an error. Instead, the file is saved in `%LOCALAPPDATA%\VirtualStore`. This behavior started in Windows Vista.
<
**TIP:** Don't save user files to system folders.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "database, vb.net, windows 8.1"
}
|
Error processing persistent unit when deploying ear in weblogic using eclipselink
I'm work on a multi module maven project and for the persistence I use eclipselink. When I deploy the ear file in weblogic I always get this error message: Failed to load webapp /yyy. Error processing persistent unit xxx of module /yyy. Error instantiating the Persistence Provider class org.apache.openjpa.persistence.PersistenceProviderImpl of the PersistentUnit xxx. java.lang.ClassNotFoundException org.apache.openjpa.persistence.PersistenceProviderImpl. I guess it tries to use the default openjpa provider, but I have configured it to use eclipselink in the persistence.xml. Any ideas?
|
Use the prefer-web-inf-classes element in your `weblogic.xml` application descriptor.
According to the documentation,
> Setting this element to True subverts the classloader delegation model so that class definitions from the Web application are loaded in preference to class definitions in higher-level classloaders. This allows a Web application to use its own version of a third-party class, which might also be part of WebLogic Server.
This is a related question which might help you as well.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "persistence, weblogic, eclipselink"
}
|
How to print a grouped_df grouped by two variables on two tables with dplyr in R
I want to group by two variables, compute a mean for the groups, then print the result on distinct tables. Unlike the below where I get all my means in a single table, I would like one output table for x==1 and another one for x==2
data = tibble(x=factor(sample(1:2,10,rep=TRUE)),
y=factor(sample(letters[1:2],10,rep=TRUE)),
z=1:10)
data %>% group_by(x) %>% summarize(Mean_z=mean(z))
res = data %>% group_by(x,y) %>% summarize(Mean_z=mean(z))
print(res)
res %>% knitr::kable() %>% kableExtra::kable_styling()```
|
You want separate outputs for when x==1 and x==2. A simple way with `dplyr` would be to `filter`:
library(dplyr)
data = tibble(x=factor(sample(1:2,10,rep=TRUE)),
y=factor(sample(letters[1:2],10,rep=TRUE)),
z=1:10)
res = data %>% group_by(x,y) %>% summarize(Mean_z=mean(z))
x1= res%>%
filter(x ==1)
x2= res%>%
filter(x ==2)
x1 %>% knitr::kable() %>% kableExtra::kable_styling()
x2 %>% knitr::kable() %>% kableExtra::kable_styling()
I'm not sure why you have this line of code:
data %>% group_by(x) %>% summarize(Mean_z=mean(z))
It doesn't create a new object and so it's output won't be available to be used in subsequent lines of code. If you did use it, it would give you the means for z for each x value, without splitting into each y value.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "r, dplyr"
}
|
How can I duplicate my existing software packages on a new system?
I installed 12.04 in a separate partition. Right now, I would like to install the software that I have installed on my 10.04 in my 12.04 too. I was hoping there would be a workaround for this using aptonCD. But I figured out 'restoring' using apt on cd only copies the .debs into the cache file and that might mess things up for me considerably.
The rough idea that I have is :
1. Run an 'apt' command on 10.04 that will give me all the package names that I have currently installed on my 10.04.
2. Bring those names to 12.04 and tell apt to fetch the same softwares, but the versions of them that belong to 12.04.
3. Install them.
Is there anyway to do the above steps or is there a totally different way in which I can achieve this?
|
this is one common way to duplicate a package set. On the old machine:
sudo dpkg --get-selections "*" > packages
Copy the file `packages` to the new machine (a pen drive is a good option. Then run this:
sudo apt-get update
sudo dpkg --set-selections < packages
sudo apt-get -u dselect-upgrade
This doesn't get you only the packages you installed. It also gets their dependencies, etc.
SOURCE
|
stackexchange-askubuntu
|
{
"answer_score": 8,
"question_score": 7,
"tags": "apt"
}
|
plot 2 variables on Y axis, using ggvis in R
I have a dataset that looks like this
"YEAR","A","B"
2001,100,177
2002,154,419
2003,334,190
2012,301,90
.. and a lot more rows.
"YEAR" columns range from 2001 to 2013. I have the dataset loaded in data.table "DT"
I want to plot a graph with YEAR on X axis, and line graphs for A and B on Y axis.
In other words, i have to combine these two graphs in one.
DT %>% ggvis(~YEAR, ~A) %>% layer_lines()
DT %>% ggvis(~YEAR, ~B) %>% layer_lines()
I know the way to do it with ggplot2 but couldn't find a way for ggvis. It shall be great even if i could do it in shiny. Your help is highly appreciated.
|
You can do it this way:
library(ggvis)
DT %>% ggvis(x= ~YEAR) %>%
layer_lines(y= ~A, stroke:='blue') %>%
layer_lines(y= ~B, stroke:='orange')
I assume that you need different colors for each line as well to be able to distinguish the groups so I added the `stroke` argument.
Output:
!enter image description here
It would probably be even better if you melt the data.frame first and then plot with the stroke argument which would return a legend as well. Like this:
library(reshape2)
DT2 <- melt(DT, 'YEAR', c('A','B'))
DT2 %>% ggvis(~YEAR, ~value, stroke=~variable) %>% layer_lines()
!enter image description here
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 3,
"tags": "r, shiny, ggvis"
}
|
Kubernetes - read arguments "args" properties from .INI file or configMap
I have kubernetes file with arguments that I am propagating through the `args`. Everything works OK! Instead of the `args` can I read the configuration from some `.ini` or properties file or configMap ? I cannot find example for using the values from properties file or configMap instead of the `args` properties. Or what will be the proposed best approach how these values should be read and how I should modify my `deployment YAML`. Thanks!
apiVersion: apps/v1
kind: Deployment
metadata:
name: ads
spec:
replicas: 1
template:
metadata:
name: ads
spec:
containers:
- name: ads
image: repo/ads:test1
#args:
args: ["-web_server", "10.1.1.1",
"-web_name", "WEB_Test1",
"-server_name", "ads"]
selector:
matchLabels:
app: ads
|
Sure you can, here's the official K8s example how to store properties in ConfigMap and how to access them in your container. If this document doesn't meet your requirement, do update your question with the reason and your exact expectation.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "kubernetes"
}
|
How do I retrieve the SharePoint Modern site's (Team sites and Communication sites) classification property via Graph API?
How do I retrieve the SharePoint Modern site's (Team sites and Communication sites) classification property via Graph API ?
I've tried /groups endpoint but it only returns the team sites properties, Communications sites are not listed in groups so how do I get those properties in Graph API?
|
For communication sites, they do not have Microsoft 365 group connected. So /groups endpoint is only available for team sites.
Using Graph API, I don't think it's possible to get the classification property for Communication sites. You could use SharePoint Rest API to get the property. Use the below endpoint: `/_api/site/Classification`
<
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "sharepoint, microsoft graph api, office365, sharepoint online, azure ad graph api"
}
|
XFS Folder Dates
I have a server running Centos 7, kernel 3.10.0-514.16.1.el7.x86_64, Samba 4.5.2, and XFS. We archive documents in a bunch of small .tif files, so XFS works great for us. The folder is mounted in fstab with the "defaults" parameter. Nothing added like "noatime" or anything. We have, however, just noticed an oddity.
Let's say a folder has 10 files in it, numbered 0001.tif - 0010.tif You re-scan those 10 files with the same names. The "Date Modified" on the folder does not change, even though the modification date on the files does.. Now if you create a new sub folder, or scan a file 0011.tif into the folder, then the folder modification date changes. I have verified that this behavior is actually happening on the server and not just on the Windows workstations accessing by Samba share.
Is this expected behavior of XFS, or do I have something wrong with my server?
|
The directory inode itself only changes when the number of contents in the directory does. Modifying files that already exist does not change the directory. Which is consistent with the behavior you observed.
If you wish to track if any files in a tree were modified at a given time, you will need to loop through them all with something like the `find` command.
|
stackexchange-serverfault
|
{
"answer_score": 2,
"question_score": 1,
"tags": "directory, xfs, last modified"
}
|
How to select table view in javafx from controller?
When I select a row in tableview, I need take the value of a given column. I'm doing this way, but is returning a ObjectList value and not the Column value
tableviewgetSelectionModel().getSelectedItem()
|
If you like to get the exact value of the column then you need to first cast the Object to the specific Generic Class then get the value of them.
See the link
<
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "javafx"
}
|
How can I display an image whose path is outside my Ruby on Rails project directory
how to display the image, which is stored in outside from the project directory.
|
You can do two things: Either you symlink to the file from within your public folder and serve the image as a static asset, or you read the image with File.read(/path/to/file) and send the binary data with send_file or send_data from within your controller.
The first option can also be slightly modified: you could catch the request for the image with a rails controller action and serve it to the browser. Additionally you could add the symlink and have the file served statically from then on.
I hope, this helps.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 3,
"tags": "ruby on rails, ruby, image, ruby on rails 3"
}
|
Google Links taking to wrong screen in asp.net, how to redirect to main page?
Google search Links are taking to admin screen instead of the main screen for the public. How can I check in my code in ASP.Net Web forms to redirect from Admin login screen < to main site < Admin Login screen is for only admins. Whoever searches are being taken to Admin site which is misleading. I use ASP.NET Webforms with C#. Thanks for the help.
|
add a meta tag in your admin login page's head
<meta name="robots" content="noindex">
This will tell google not to index your admin login page and ultimately removing this page from search result. (might take couple days to take effect depending on the crawling cycle)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c#, asp.net, webforms"
}
|
Issues with metadata converting mp3->ogg
I'm trying to convert mp3 files to ogg, but I found a problem: most or all of the metadata is disappearing after the conversion. Is there a way to keep it?
|
The userfriendly program _soundconverter_ (Gnome Sound Converter) retains at least artist, title, album, comment and year(*) when converting to ogg.
The command line program _sox_ retains at least artist, title, album and year(*), but apparently not comment.
sox xxx.mp3 xxx.ogg
(*) some programs may disagree if year is release time tag or recording time tag.
|
stackexchange-askubuntu
|
{
"answer_score": 3,
"question_score": 6,
"tags": "mp3, ogg vorbis"
}
|
Comment traduire "schon heute" / "bereits heute" ?
Dans la phrase
> Wir sichern Ihnen schon heute eine professionelle und gewissenhafte Bearbeitung des Projektes zu.
comment puis-je traduire "schon heute" / "bereits heute" (already today in English).
Voici mes efforts:
> Nous vous promettons un traitement professionnel et consciencieux du projet aujourd'hui déjà.
Si j'utilise _à partir d'aujourd'hui_ , ça serait mieux ? Je pense que si j'utilise ça, la phrase n'aurait plus le même sens, n'est-ce pas ?
|
Je pense que l'expression la plus courante pour exprimer cela en français est _dès aujourd'hui_.
> Nous vous promettons un traitement professionnel et soigné du projet dès aujourd'hui.
De la même façon « _schon jetzt_ » deviendrait « dès maintenant ». L'idée qui se cache derrière ces expressions françaises c'est : « pas besoin d'attendre ! »
« À partir d'aujourd'hui » signifierait que le service est nouveau et qu'aujourd'hui est la première date où il est disponible ( _ab heute_ ). Ni « *aujourd'hui déjà » ni « *déjà aujourd'hui » ne sont employés en français.
|
stackexchange-french
|
{
"answer_score": 6,
"question_score": 4,
"tags": "traduction, indications de temps, allemand"
}
|
concatenate .doc files with cat
I'm trying to concatenate several .doc files none of them bigger than 15 KB, I'm trying the usual
cat file1.doc file2.doc file3.doc > new_file.doc
But despite the result is an almost 200 KB new .doc file this only shows the first of the original .doc files content.
Any ideas? What I'm doing wrong? It's not possible to concatenate .doc files with cat?
Any help is appreciated.
Thanks in advance.
|
You can convert files like `*.doc` to `*.html` with the writer from LibreOffice:
lowriter --convert-to html $doc_filename
Then you can `cat` them in any order including formatting and images (if they are in the same directory or if their full path is specified).
Finally, you can use the same command to convert them back to the Word format:
lowriter --convert-to doc $html_filename
|
stackexchange-unix
|
{
"answer_score": 4,
"question_score": 0,
"tags": "cat"
}
|
Let $G$ be a group of order $30$ and $A, B$ be two normal subgroups of $G$ of order $2$ and $5$ respectively. Show that $G/AB$ contains $3$ elements.
The actual question is
> Let $G$ be a group of order $30$ and $A, B$ be two normal subgroups of $G$ of order $2$ and $5$ respectively. Show that $G/AB$ contains $3$ elements.
In my approach:
Firstly I know that $AB$ is a normal subgroup in $G$. And, since order of $B$ is $5$, a prime that implies it is a cyclic subgroup of $G$.
And, since order of $A$ is $2$, it contains the identity element and the elements of $G$ which are self inverse.
And I also know, $$ G/AB = \\{ gAB : g \in G\\} $$
Now from this much information how can I conclude that $G/AB$ has only 3 elements? I know One element must be the identity. I am lost when trying to find the other 2 elements.
It would be great to know a hint for the proof!
|
Another approach:
Alternatively, you want to show that $|AB|=10$, then it will follow that $|G/AB|=|G|/|AB|=3$.
You may use the product formula $$|AB|=\frac{|A||B|}{|A\cap B|}.$$ Try to use Lagrange's Theorem and properties of $\gcd$ to show that $|A\cap B|=1$.
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 3,
"tags": "group theory, finite groups, cyclic groups, quotient group"
}
|
Isogeny between elliptic curves is always bijective?
Isogeny is morphism between elliptic curves which keeps base point.
Then, is every isogeny between elliptic curves bijective?
Let $E1$ and $E2$ be isogenous elliptic curves defined over Fq. Then #E1(Fq) = #E2(Fq) holds, but the isogeny is not always bijective?
Thank you in advance.
|
No, isogenies need not be bijective. For example $[2]$ is an isogeny from any elliptic curve $E$ to itself. Its kernel is the 2-torsion $E[2]$. Therefore it is not bijective whenever $E(\Bbb{F}_q)$ has non-trivial 2-torsion.
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": -1,
"tags": "elliptic curves, isogeny"
}
|
how to use gss_import_name correctly?
I am using gss_import_name on the client side using GSS_C_NT_HOSTBASED_SERVICE to get a principal like service/server-host@realm.
I am calling like this,
> gss_import_name(status, "SERVICE", GSS_C_HOSTBASED_SERVICE, output_name);
But i get the principal like, service/local-machine@realm. From the man page I have learned it internally uses krb5_sname_to_principal to get the hostname, if NULL it takes the localhost name. Now my question is how do pass the correct host name (server-host) to gss-api to create the principal?
|
I overlooked into it. To get the principal in the form 'service/server-host@realm' I should call
> gss_import_name(status, "service@server-host", GSS_C_HOSTBASED_SERVICE, output_name);
instead of
> gss_import_name(status, "service", GSS_C_HOSTBASED_SERVICE, output_name);
If the host name is missing then it assumes to be the local host name.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "c, kerberos, gssapi"
}
|
Which is the best module to import/export automatically with cron
I am looking for a module which can permit me import & export by creating or updating if exist already :
- product
- customer
- stock
- attributes of product (import only)
- categories (import only)
Using a cron for importation and exportation.
Can you advice me for the best module import/export update and create with cron compatible with Magento 1.9 and version 2
Thanks
|
Check it out. <
You can configure it to run from cron.
|
stackexchange-magento
|
{
"answer_score": 0,
"question_score": 0,
"tags": "product, customer, import, cron, export"
}
|
I have problem with adding my object to array
So after creating an object,I want to add it to an array but seem it doesn't working Only the last one was added and it looped.
I expect the output of `mang[0]` would be `('Samsung S8','s0','$200')` but it doesn't.
It only show the last one `('Samsung A60','s2','$400')`. It's the same to `mang[1]`.
var mang=[];
var Phone = {
Name:'',
Img:'',
Price:'',
them :function(name,img,price){
this.Name=name;
this.Img=img;
this.Price=price;
mang.push(Phone);
}
};
Phone.them('Samsung S8','s0','$200');
Phone.them('Samsung S10','s1','$300');
Phone.them('Samsung A60','s2','$400');
|
Hi please try this solution
var PhoneList = [];
function Phone(Name,Img,Price){
this.Name = Name;
this.Img = Img;
this.Price = Price ;
}
Phone.prototype.addToArray = function(){
PhoneList.push(this);
}
let phone1 = new Phone('Samsung S8','s0','$200');
phone1.addToArray();
let phone2 = new Phone('Samsung S10','s1','$300');
phone2.addToArray();
let phone3 = new Phone('Samsung A60','s2','$400');
phone3.addToArray();
console.log(PhoneList);
I hope it helps.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -2,
"tags": "javascript, arrays"
}
|
is there a way to use a gradle variable in Java class
I am part of a team that works on an Android app that uses a RESTful api(using retrofit 1.9), and we are looking for ways to set up a config file, so that we wouldn't have to change the connection string(API URL) from the live server to our own dev environment, any time that we want to add or change something in the app.
Is there a way to use Gradle for this? in other words, is there a way for us to create a gradle config, in which we declare a variable and use that variable in the project(the API URL)?
what other options do we have?
Just as a side note, This is the first Android project that we are doing, So I apologize upfront if this is not a very good question(any hints on improvement would be appreciated). Thanks in advance.
|
Sure, you can use the `build types` for that to add a `buildConfigField`, which will then be available in `BuildConfig.[variableName]`.
buildTypes {
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "String", "API_URL", "[apiURL]"
buildConfigField "Boolean", "DEBUG_MODE", "true"
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "String", "API_URL", "[apiURL]"
buildConfigField "Boolean", "DEBUG_MODE", "false"
signingConfig signingConfigs.config
}
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "java, android, android gradle plugin"
}
|
Why is website at domain.com not working while www.domain.com does?
Here is the working page: game on glove dot com
The non-working page is the same URL minus the "www.".
Now try clicking on the items in the gallery at the top left of the page to the left of the youtube video. They pop a lightbox window in one version but not the other.
Also try clicking the "click here to order" button. A popup appears in both versions of the webpage, but once you make your selection and then click the button on that lightboxed window, you will see an error on the domain.com version, but not on the www.domain.com version.
Am I missing something ridiculous?
|
The problem is because the domain.com backend script that processes the requests sends a 302 Moved Temporarily if it's requested without the www.
I'm not sure if the jQuery ajax implementation tries to follow the 302 or not, but even if it did, it wouldn't be able to fetch the content because it's on a different domain and so is subject to the same origin policy
The easiest solution would be to update the backend processing script to remove the 302 redirect. Alternatively, forcefully redirect all traffic from < to <
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "jquery, ajax, dns, lightbox"
}
|
Use printf to format floats without decimal places if only trailing 0s
Is it possible to format a float in C to only show up to 2 decimal places if different from 0s using printf?
Ex:
12 => 12
12.1 => 12.1
12.12 => 12.12
I tried using:
float f = 12;
printf("%.2f", f)
but I get
12 => 12.00
12.1 => 12.10
12.12 => 12.12
|
You can use the `%g` format specifier:
#include <stdio.h>
int main() {
float f1 = 12;
float f2 = 12.1;
float f3 = 12.12;
float f4 = 12.1234;
printf("%g\n", f1);
printf("%g\n", f2);
printf("%g\n", f3);
printf("%g\n", f4);
return 0;
}
Result:
12
12.1
12.12
12.1234
Note that, unlike the `f` format specifier, if you specify a number before the `g` it refers to **the length of the entire number** (not the number of decimal places as with `f`).
|
stackexchange-stackoverflow
|
{
"answer_score": 62,
"question_score": 46,
"tags": "c, printf"
}
|
Override admin.TabularInline fields
> **Possible Duplicate:**
> Override django-admin edit form field values for encrypted data
The inline model has encrypted data and I need to override the method that renders each field in admin.TabularInline to decrypt the data.
|
You can add functions to your `TabularInline` and then show them as fields:
class MyTabularInline(admin.TabularInline):
model = MyModel
readonly_fields = ['decrypt_first_field', 'decrypt_second_field']
def decrypt_first_field(self, obj):
if obj.first_field:
return decrypt(obj.first_field)
else:
return 'Nothing here ...'
def decrypt_first_field(self, obj):
...
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": -1,
"tags": "python, django, django admin"
}
|
What are the major difference between a regular sleeping bag and one designed for women?
I see more and more sleeping bags designed for women. I was wondering what were the major differences with the regular sleeping bag?
Does it have to do more with the shape or insulation?
|
We did some research on this once and the results were kind of sad.
For major backpacking brands of sleeping bags (say, Marmot or Big Agnes) the major differences between sleeping bags for the two genders were these:
1. Women's sleeping bags were slightly smaller.
2. A bag that is listed as a '20-degree bag' for woman would listed as a '10-degree' bag for men.
3. Women's bags came in more garish colors and frequently had pictures of flowers on them.
**Number (1)** above seems fine.
**Number (2)** seems highly dubious. Are we saying that women "just can't take the cold" as well as men? Is there (I really, really hope) evidence showing that women actually need more insulation for safety? I happen to know a few doctors, and they can't support this idea.
And **number (3)** is the same for all women's outdoors gear. You know it's a woman's model helmet because it's pink and has flowers on it.
|
stackexchange-outdoors
|
{
"answer_score": 11,
"question_score": 10,
"tags": "gear, sleeping bags, women"
}
|
Text-shadow for position: static
Is there any way to do text shadow for Position static with somewhat decent crossbrowser support?
The CSS3 text-shadow is ultimately what I'm after, but of course only Safari/Opera/(not yet released FF3.1) out of the major browsers support it.
All javascript/css techniques I've seen forces the text into position:absolute, which will not work for my mid paragraph shadows.
Are there any that I haven't seen, or is there some other option I should explore? Forcing font downloads on the viewer? Ugh. :(
Thanks.
|
In short no, stick to the premise of graceful degradation - at least for paragraph text. If the browser can't handle it natively then it doesn't get the styling and will display in the default manner. You have to explain to your client or whoever the site is for that it's not going to have an impact on whether or not people can read the text and absorb the site's message - it's purely decorative.
IMO It's one of those things you can live without: <
If you still have to do it consider using image replacement on the paragraphs: <
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "css, shadow"
}
|
Is the CRT applicable here?
Find the `x` that satisfies the following system:
$$x = 3 \mod 2$$
$$x = 3 \mod 5$$
$$x = 3 \mod 7$$
CRT:
$$ M = 2 * 5 * 7 = 70 $$
$$ M1 = 5 * 7 = 35$$
$$ M2 = 2 * 7 = 14$$
$$ M3 = 2 * 5 = 10$$
$$N1 = 1$$
$$N2 = 4$$
$$N3 = 5$$
$$ 3 * 35 * 1 + 3 * 14 * 4 + 3 * 10 * 5 = 423$$
$$ 423 = 3 \mod 70$$
So $ x = 3 $ but this is not true because $3 = 1 \mod 2$ and not $3 = 3 \mod 2$
I am unable to see my mistake, could it be that CRT is not applicable here?
|
CRT is trivially applicable here. $3\equiv 1 \mod 2$ and $3\equiv 3 \mod 2$ are both true. You are confusing equivalence modulo $n$ with taking a residue modulo $n$.
As a side note, you don't need CRT for things like that. If you have equations $x\equiv n\mod m_i$ for some $m_i$, then trivially $x=n$ satisfies the congruences, even if the assumptions of the CRT are not satisfied.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "chinese remainder theorem"
}
|
Call a method, renaming the variables as new one
I'm working on a small project, I want to make code a lot shorted, and easier, rather than writing it out multiple times. I have a method shown below, I want to use this method multiple times - but every String that is stored in the Text Field has to be kept - and not replaced. Eg.
* The variable tf1 = "item1"
* I Then call the method again, the variable tf1 is than changed to tf1 = "item2"
* I want tf1 to keep both "item1" and "item2"
Method:
public static void text(){
TextField tf1 = new TextField();
}
text();
|
You should probably use a list of String type. A list would enable you to hold infinite data of the same type while keeping it under the same name since a list dynamically grows in size. you can then use an iterator or a for-each loop to access the data stored in the list.
The general syntax would be: `List<String> textFieldList=new ArrayList<String>();`
P.S. Remember to use the List of java.util package.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "java, variables, methods"
}
|
Getting the index of multiple selected items in a listbox using Silverlight
I have a ListBox which is made up of Grid Items in Multiple SelectionMode in Silverlight 3.0.
When I use ListBox.SelectedIndex it only returns the first item which is selected.
I would like to be able see all of the selected items such that it would return all of the selected item indexes' such as; 2, 5, and 7, etc.
Any help?
Cheers,
Turtlepower.
|
You can find the selected indexes by iterating through `SelectedItems` and finding the objects in the `Items` property, like this:
List<int> selectedItemIndexes = new List<int>();
foreach (object o in listBox.SelectedItems)
selectedItemIndexes.Add(listBox.Items.IndexOf(o));
Or if you prefer linq:
List<int> selectedItemIndexes = (from object o in listBox.SelectedItems select listBox.Items.IndexOf(o)).ToList();
|
stackexchange-stackoverflow
|
{
"answer_score": 9,
"question_score": 5,
"tags": "c#, silverlight, listbox, listboxitem"
}
|
Latitude and longitude can find zip code?
I am using Google geocoder for lat and lon and my question is, is there a way you can find out zipcode with latitude and longitude?
|
I think what you are looking for is the `address_components[]` in the `results` array. Maybe something like this would work, just typing the below so it might have errors in it but I think you will get the idea.
<
function (request, response) {
geocoder.geocode({ 'address': request.term, 'latLng': centLatLng, 'region': 'US' }, function (results, status) {
response($.map(results, function (item) {
return {
item.address_components.postal_code;//This is what you want to look at
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 9,
"question_score": 18,
"tags": "google maps, geolocation"
}
|
Cornerstone 6.0.0 eslint update
My team is upgrading our cornerstone from 5.7.1 to 6.0.0 and we noticed on Github after creating the pull request that there are a lot of eslint errors being thrown- all related to our stylesheets. We looked at the code changed from the new release and we noticed there is eslint style added, is there a way we can disable/revert that? It is helpful and my team would like to eventually clean up our stylesheets, but we are not looking to undertake that at this moment. From my understanding the eslint errors aren't going to throw off our sites, but we were curious to see if there was a way to disable this anyways.
|
I'd recommend raising this as an issue on the Cornerstone GitHub Repo, as I do not believe there is a way to revert it. However in case this is effecting others, a github issue would be helpful for our product teams' awareness.
You can create a new issue on the repository here, <
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "eslint, bigcommerce, cornerstone"
}
|
Getting SQS queue attribute via MassTransit
I'm currently learning SQS/MassTransit and would like to know if there's a way to get queue attributes via MassTransit(such as `ApproximateNumberOfMessages`). I know I can do this with `AmazonSQSClient`'s `GetQueueAttributesRequest`, just wondering if the same can be done with MassTransit.So far googling yielded no results.
|
MassTransit doesn't expose any of these attributes, you'd need to use the transport-specific client libraries.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, .net core, amazon sqs, masstransit"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.