qid int64 10 74.7M | question stringlengths 15 26.2k | date stringlengths 10 10 | metadata list | response_j stringlengths 27 28.1k | response_k stringlengths 23 26.8k |
|---|---|---|---|---|---|
1,103,653 | So I have a spreadsheet with a bunch of little mini-charts as seen below. The numbers in blue are user entered, and they are all added together in the chart with the gray cells on the top left.
Right now, I do this by having a basic sum formula. The real spreadsheet is much much larger, but in the example C3 would be ... | 2016/07/21 | [
"https://superuser.com/questions/1103653",
"https://superuser.com",
"https://superuser.com/users/34463/"
] | When you add a new program to the path, you need to type
```
rehash
```
For it to be known to the shell. | As a fast fix you can make an alias. Add to you `~/.bashrc` file this:
```
alias main='/home/user/Downloads/program/./main'
```
then run `exec bash` in your terminal and it should work. If you're not using bash something similar would work for other shells. For example writing to the file `~/.zshrc` for the `zsh` s... |
543,130 | I have some old Java 2D code I want to reuse, but was wondering, is this the best way to get the highest quality images?
```
public static BufferedImage getScaled(BufferedImage imgSrc, Dimension dim) {
// This code ensures that all the pixels in the image are loaded.
Image scaled = imgSrc.getScaledInstan... | 2009/02/12 | [
"https://Stackoverflow.com/questions/543130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22801/"
] | Chris Campbell has an excellent and detailed write-up on scaling images - see **[this article](http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html)**.
Chet Haase and Romain Guy also have a detailed and very informative write-up of image scaling in their book, **[Filthy Rich Clients](htt... | Adding some clarifying information here.
No, that isn't the *best* way to get a good looking scaled image in Java. Use of getScaledInstance and the underlying AreaAveragingScaleFilter are deprecated by the Java2D team in favor of some more advanced methods.
If you are just trying to get a good-looking thumbnail, usin... |
47,053,727 | Say I have a UIView,
```
class CleverView: UIView
```
In the custom class, I want to do this:
```
func changeWidth() {
let c = ... find my own layout constraint, for "width"
c.constant = 70 * Gameinfo.ImportanceOfEnemyFactor
}
```
Similarly I wanna be able to "find" like that, the constraint (or I guess, a... | 2017/11/01 | [
"https://Stackoverflow.com/questions/47053727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/294884/"
] | There are really two cases:
1. Constraints regarding a view's size or relations to descendant views are saved in itself
2. Constraints between two views are saved in the views' lowest common ancestor
**To repeat. For constraints which are between two views. iOS does, in fact, always store them in the lowest common an... | [`stakri`'s answer](https://stackoverflow.com/a/47113933/2463616) is OK, but we can do better by using
[`sequence(first:next:)`](https://developer.apple.com/documentation/swift/sequence(first:next:)):
```
extension UIView {
var allConstraints: [NSLayoutConstraint] {
sequence(first: self, next: \.superview)... |
23,776,715 | I am very new to Android & now I am having weird problem in my Application. It doesn't give me any error in console but it says in emulator that the stopwatch has stopped working...
my MainActivity.java
```
import android.os.Bundle;
import android.os.SystemClock;
import android.support.v7.app.ActionBarActivity;
impor... | 2014/05/21 | [
"https://Stackoverflow.com/questions/23776715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3659612/"
] | The issue happen right after I changed the V1\_2\_\_books.sql ddl file, There should be a better way to force flyway to recognize the new changes!!!
I tried to run mvn flyway:repair but it did not work, I ended up changing the schema url in the application.properties file [datasource.flyway.url] to books2
I removed t... | There is yet another solution. You can drop your migration from **schema\_version** table. |
68,022,698 | I have a list `sample_list` like this:
```
[
{
"Meta": {
"ID": "1234567",
"XXX": "XXX"
},
"bbb": {
"color":red"
},
{
"Meta": {
"ID": "78945612",
"XXX": "XXX"
... | 2021/06/17 | [
"https://Stackoverflow.com/questions/68022698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10581944/"
] | The problem is in the second line of a for loop. What you are doing is that you are creating a dictionary in this forloop. In any other language, you would get a syntax error, because you are trying to access un-initialised variable (in this case `init_dict`) (in this case, if sample\_list is empty, you will get an err... | You need to append to your dictionary. The line `init_dict = {}` resets your dictionary. Instead you should do:
```
init_dict = {'ID':[]}
for item in sample_list:
init_dict['ID'].append(item['Meta']['ID'])
print(init_dict)
```
To satisfy the request you made in a comment, you can do this to use the value as a ke... |
92,804 | I am developing a service that will involve the direct debit of customers' accounts on a routine (weekly, monthly, etc.) basis, and so I'll need to store their information (BSB/routing number and account number) in my database. I am very concerned about security, and so my first thought was to not store this informatio... | 2015/07/01 | [
"https://security.stackexchange.com/questions/92804",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/79882/"
] | >
> The password is hashed with bcrypt, and the public and private keys
> are stored alongside the password hash in the user table.
>
>
>
Storing the private key means a compromise of the database would allow attacker to decrypt the bank information. You might as well store the bank information in plain text.
Wh... | Yes, use these functions to encrypt & decrypt the data from the DB.
```
static function encrypt($s) {
$keyHex = getenv('APP_KEY');
if (!$keyHex) {
Yii::error ("Could not retrieve environment variable APP_KEY");
return null;
}
$key = pack('H*', $keyHex);
$iv = mcrypt_create_iv(256/8);... |
7,878,420 | I created function for my blog.
Model -
```
public function get_article($nosaukums) {
$query = DB::query(Database::SELECT, 'SELECT * FROM ieraksti WHERE virsraksts = :nosaukums')
->parameters(array(':nosaukums' => $nosaukums))->execute();
return $query;
}
```
Controller -
```
public function ac... | 2011/10/24 | [
"https://Stackoverflow.com/questions/7878420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/914143/"
] | Probably the easiest way to do this is to use [`scipy.interpolate.interp2d()`](http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp2d.html):
```
# construct interpolation function
# (assuming your data is in the 2-d array "data")
x = numpy.arange(data.shape[1])
y = numpy.arange(data.shape[0])
f... | Here is a method without using scipy package(s). It should run much faster and is easy to understand. Basically, any pair of coordinates between point 1 (pt1) and point 2 (pt2) can be converted to x- and y- pixel integers, so we don't need any interpolation.
```
import numpy as np
from PIL import Image
import matplotl... |
1,316,983 | Does OpenID improve the user experience?
**Edit**
Not to detract from the other comments, but I got one really good reply below that outlined 3 advantages of OpenID in a rational bottom line kind of way. I've also heard some whisperings in other comments that you can get access to some details on the user through Op... | 2009/08/22 | [
"https://Stackoverflow.com/questions/1316983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/152580/"
] | It's great not having to make too many user accounts all around. All those passwords.... then again, I far prefer a solution like 1Password for the Mac. OpenID is better for sites I'll return to than a separate username, though | I would agree with you that ease of use for your users is something to heavily consider. Your audience is another thing to consider. As OpenID becomes more accepted this will be less and less of an issue. If you are working on a project where you know the majority of your users will not even know what OpenID is then pe... |
19,352,934 | These two function ares in my Python programming book, and I just can't quite get why they're doing what they're doing. I really wanna understand, so any explanation would be great.
```
def example(aString, index):
if index == len(aString):
return ""
else:
return aString[index] + example(aStrin... | 2013/10/14 | [
"https://Stackoverflow.com/questions/19352934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2877503/"
] | First, calculate the distance you will travel based on your current speed and your known time interval ("next time"):
```
distance = speed * time
```
Then you can use this formula to calculate your new position (lat2/lon2):
```
lat2 =asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc))
dlon=atan2(sin(tc)*sin(d)*cos(lat... | Based on the answer of @clody96 and @mike, here is an implementation in **R** using a data.frame with **velocity** and **timesteps** instead of distance:
```
points = data.frame(
lon = seq(11, 30, 1),
lat = seq(50, 59.5, 0.5),
bea = rep(270, 20),
time = rep(60,20),
vel = runif(20,1000, 3000)
)
## lat, lng i... |
47,344,571 | I am able to draw checkbox in Github README.md lists using
```
- [ ] (for unchecked checkbox)
- [x] (for checked checkbox)
```
But this is not working in table. Does anybody know how to implement checkbox or checkmark in GitHub Markdown table? | 2017/11/17 | [
"https://Stackoverflow.com/questions/47344571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8253993/"
] | ```
|checked|unchecked|crossed|
|---|---|---|
|✓|_|✗|
|☑|☐|☒|
```
| checked | unchecked | crossed |
| --- | --- | --- |
| ✓ | \_ | ✗ |
| ☑ | ☐ | ☒ |
Where
* ✓ via [HTML Entity Code](https://www.toptal.com/designers/htmlarrows/symbols/check-mark)
* ✗ via [HTML Entity Code](https://ww... | Following is how I draw a checkbox in a table!
```
| Checkbox Experiments | [ ] unchecked header | [x] checked header |
| ---------------------|:---------------------:|:-------------------:|
| checkbox | [ ] row | [x] row |
```
Displays like this:
[![enter image descriptio... |
17,745,148 | I can understand simple recursion, such as:
```
def count(n):
if n <= 0:
return
else:
print n
count(n-1)
count(3)
```
However, when faced with more complicated code, such as, an implementation of Koch snowflake:
```
def koch(order, size):
if order == 0:
t.forward(siz... | 2013/07/19 | [
"https://Stackoverflow.com/questions/17745148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1539759/"
] | Your Koch snowflake example is a good one. What does the snowflake consist of? In the first iteration (`order == 0`), it starts out as a simple line. This is the base case.
```
________
```
Now, for the next level of recursion (`order == 1`), that base case is split into four sub-lines that form an inverted `V`. To ... | The python tutor web site can help in visualising program flows
<http://www.pythontutor.com/> |
45,497,031 | If the total *content height* of the parent is 10,000px but the `overflow: auto` element is *rendered* with a height of 700px how do I force the `aside` child element to dynamically render as 10,000px *instead* of the default 700px? You can see the white background the moment you begin to scroll [the Fiddle](https://js... | 2017/08/04 | [
"https://Stackoverflow.com/questions/45497031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/606371/"
] | This is *not* the way I intended to achieve the result as I would like to set `background-image` on the `#body` in many cases though it may be acceptable subjective to how I handle things, here is the [Fiddle](https://jsfiddle.net/4m1L2tLh/2/). I'm certain that this issue will be resolved at some point in the future.
... | Actually, there's a pretty simple solution with just CSS and without touching the markup.
* `display:table-cell` for the `aside` and the `main`
* omit the display flex on the `#body`
Here's a fully functional snippet:
```html
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/... |
9,312 | Is there an existing plugin or a built-in way of adding an "add me to mailing list" button to a contact form? Not just that it gets stored in the database as a lightswitch, but so it actually subscribes them (or at least sends them a sign-up confirmation email)? | 2015/04/20 | [
"https://craftcms.stackexchange.com/questions/9312",
"https://craftcms.stackexchange.com",
"https://craftcms.stackexchange.com/users/642/"
] | If you're using a Craft Client or Craft Pro, you can save your entry as a draft and review it later.

This isn't foolproof either. If you wanted to really try to restrict yourself, you could set up another user account that doesn't have privileges to... | There's no setting to define a default master status for entries, but there's locale specific statuses that can be set to a default in the section's settings.
This requires Craft Pro and more than one locale configured though. |
26,808,657 | I have a date in YYYY.MM.DD HH:SS format (e.g. 2014.02.14 13:30). I'd like to convert it in seconds since epoch using the date command.
The command
date -d"2014.02.14 13:30" +%s
won't work, because of the dots separation.
Any Ideas? | 2014/11/07 | [
"https://Stackoverflow.com/questions/26808657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3762096/"
] | Why don't you make the date format acceptable? Just replace dots with dashes:
```
$ date --date="`echo '2014.02.14 13:30' | sed 's/\./-/g'`" +%s
1392370200
```
Here I first change the format:
```
$ echo '2014.02.14 13:30' | sed 's/\./-/g'
2014-02-14 13:30
```
and then use the result as a parameter for `date`.
No... | Perl: does not require you to munge the string
```
d="2014.02.14 13:30"
epoch_time=$(perl -MTime::Piece -E 'say Time::Piece->strptime(shift, "%Y.%m.%d %H:%M")->epoch' "$d")
echo $epoch_time
```
```
1392384600
```
Timezone: Canada/Eastern |
28,284,608 | I have a DialogFragment which I want to show in fullscreen. I do however still want a StatusBar present, and the hardware buttons at the bottom. I also want to set a background color of the StatusBar (for Lollipop).
My problem is that if I set the following flags in the DialogFragment:
```
getWindow().addFlags(Window... | 2015/02/02 | [
"https://Stackoverflow.com/questions/28284608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4066691/"
] | You have to set fitsystemwindows = true. Other way is to add a Space with 0dp and change its height to 25dp when the dialog is going to show.
To change the space size, use layout params, check this post: [How to create a RelativeLayout programmatically with two buttons one on top of the other?](https://stackoverflow.c... | ```
<style name="DialogTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowIsFloating">false</item>
</sty... |
59,265,908 | I need a little help getting to display my ngFor data in a new container div when the length gets to four. hard coding the data in several div is easier, but using ngFor displays the data in a single container div.
the code below there is supposed to be four **book-section-subGrid DIV** in a **book-section-grid DIV**
... | 2019/12/10 | [
"https://Stackoverflow.com/questions/59265908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10008455/"
] | Try like this
```
<div class="book-section-grid">
<div *ngFor="let book of books; let index = index;" class="book-section-subGrid">
<div *ngIf="index < 5; else elseBlock">
<h4>{{book?.title}}</h4>
<img height="100" width="100" src="https://images.pexels.com/photos/1226302/pexels-photo... | I think you can make use of angular [slice pipe](https://angular.io/api/common/SlicePipe).
You can find a sample implementation [here](https://angular.io/api/common/SlicePipe). |
43,455,380 | ```
class Base
rand bit b;
// constraint c1 { every 5th randomization should have b =0;}
endclass
```
I know I can make a static count variable and update that count variable and then, in constraint I can check if count%5 is zero, then make b=0, but is there a better way to do that? Thanks. | 2017/04/17 | [
"https://Stackoverflow.com/questions/43455380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7595813/"
] | There's no need to make count static, just non-random.
```
class Base;
rand bit b;
int count;
constraint c1 { count%5 -> b==0;}
function post_randomize();
count++;
endfunction
endclass
``` | If you know the upper limit of `b`, then you can write a constraint like follow.
```
constraint abc
{
b dist {0:=20, 1:=80}
}
```
This will make weight of `0` to `20` and, weight of `1` to `80`. So in this way, 0 will occur once in every 5 randomization. |
64,485,104 | Get this error on our Domino server log:
PROTON: Handshake failed with fatal error SSL\_ERROR\_SSL: error:100000f7:SSL routines:OPENSSL\_internal:WRONG\_VERSION\_NUMBER. [D:\jenkins\workspace\domino-app-dev\fed-protected\grpc\grpc\src\core\tsi\ssl\_transport\_security.cc:1233]
I am taking the 3CUG courses in google c... | 2020/10/22 | [
"https://Stackoverflow.com/questions/64485104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3470383/"
] | This ususally is a problem with the server config missing the secure flag like so, please check if you have set the flag and import the certificates correctly:
```
const serverConfig = {
hostName: config.protonHostName, // DNS (!) Host name of your server
connection: {
port: config.protonHostPort, // P... | If this problem is related to lection 404 of the course, you have to turn off SSL for the proton task.
If you're using AppDevPack 1.0.6 or higher you can do this in the `adpconfig.nsf` file.
SSL will be configured in chapter 5.
For turning off ssl for the proton task open adpconfig.nsf.
Then open the configuration d... |
8,882,104 | I have a pointer array defined declared as
```
char (*c)[20]
```
When allocating memory using malloc
```
c=malloc(sizeof(char)*20);
```
or
```
c=(char*)malloc(sizeof(char)*20);
```
I get a warning as "Suspicious pointer conversion"
Why? | 2012/01/16 | [
"https://Stackoverflow.com/questions/8882104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/553406/"
] | First of all, make sure you have `stdlib.h` included.
Secondly, try rewriting it as
```
c = malloc(sizeof *c);
```
I suspect you're getting the diagnostic on the second case because `char *` and `char (*)[20]` are not compatible types. Don't know why the first case would complain (at compile-time, anyway) unless yo... | For an array of 20 characters, counting the NUL terminator, you don't need a pointer
```
char array[20];
```
for a pointer to char, you don't need an array
```
char *pointer;
```
A pointer to char can point to an array
```
pointer = array;
```
to part of the array (assuming no 'funny' business with the NUL ter... |
10,193,978 | I'm trying to compare column a in Sheet 1 with column a in Sheet 2, then copy corresponding values in column b from sheet 1 to column b in Sheet 2 (where the column a values match). I've been trying to read up on how to do this, but I'm not sure if I should be trying to create a macro, or if there's a simpler way to do... | 2012/04/17 | [
"https://Stackoverflow.com/questions/10193978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/431060/"
] | As kmcamara discovered, this is exactly the kind of problem that VLOOKUP is intended to solve, and using vlookup is arguably the simplest of the alternative ways to get the job done.
In addition to the three parameters for lookup\_value, table\_range to be searched, and the column\_index for return values, VLOOKUP tak... | Make a truth table and use SUMPRODUCT to get the values. Copy this into cell B1 on Sheet2 and copy down as far as you need:
`=SUMPRODUCT(--($A1 = Sheet1!$A:$A), Sheet1!$B:$B)`
the part that creates the truth table is:
`--($A1 = Sheet1!$A:$A)`
This returns an array of 0's and 1's. 1 when the values match and ... |
54,999,533 | Hello im having error on browser and i don't know how to resolve this. thanks for the future help[](https://i.stack.imgur.com/UJMnF.png) | 2019/03/05 | [
"https://Stackoverflow.com/questions/54999533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10539385/"
] | The easiest, and with best browser support might actually be SVG.
You can set up approximately the same thing you did with the ::before, with the difference that the background stroked version can have a mask, which will let only the outer-line visible.
From there, you can simply append a copy of the same text ov... | Solution using SVG filters
--------------------------
To get a stroke around the text, you can use a combined SVG filter consisting of successively applied filters: `feMorphology`, `feComposite` and `feColorMatrix`.
```css
body{
background-image:url(https://picsum.photos/800/800?image=1061);
background-size:co... |
25,103 | Sometimes, people use a colloquial phrase of "it figures" or "go figure", which is kind of an acknowledgement of the correctness of a fact, or something like that. It's also sometimes abbreviated even further to just "Figures" or "Go fig", depending on the speaker.
Examples of the phrase in context:
>
> **It figure... | 2011/05/12 | [
"https://english.stackexchange.com/questions/25103",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/8566/"
] | Just spitballing here, but could 'it figures' in the sense of to draw a conclusion or "stands to reason" or "figure out" be related to the sense of "figure" in a categorical syllogism. Once you determine the figure and the mood of a syllogism you can understand it's form and can determine if it is a valid form or not.
... | As others have indicated, it means pretty much the same as "*Go figure it out*", "*Go compute it*", or "*Do the math*". This comes directly from the literal, math meaning of the verb "*figure*" as "calculate". That's the origin.
Sometimes it is used sarcastically, to indicate that there is really **nothing** difficult... |
3,687 | How do I set keyboard shortcuts for `Home`, `End`, `PageDown`, and `PageUp` on a 13" MacBook Pro? Are there default keyboard shortcuts? Or can I do it with Automator (and if so, how)?
I want them to work the same way that `Home` and `End` do on all Windows apps.
---
I also want general solution I get that [Kyle Cro... | 2010/11/04 | [
"https://apple.stackexchange.com/questions/3687",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/15/"
] | You can do page up/down and home/end on a Macbook keyboard by using the `fn` and the arrow keys:
`fn`+`↑` is `PageUp`
`fn`+`↓` is `PageDown`
`fn`+`←` is `Home`
`fn`+`→` is `End` | `⌘`+`→` works like a PC's `End` (moves the cursor to the end of the line). `⌘`+`←` works like a PC's `Home` (moves to the beginning of the line). `ctrl`+`A` and `ctrl`+`E` (Emacs-style keybindings) work in most OS X applications as well. |
66,945,035 | I have a string of words and mathematical/programmatically used symbols. For example, something like this:
```swift
let source = "a + b + 3 == c"
```
(Note: you cannot rely on spaces)
I also have an array of strings that I need to filter out of the source string:
```swift
let symbols = ["+", "-", "==", "!="]
```
... | 2021/04/04 | [
"https://Stackoverflow.com/questions/66945035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10531223/"
] | so when I experiment on my own system, this is how I see the path variable once I added the globstar pattern: `...:./path1:./**/` - which is not reading all the paths (perhaps pattern matching is not part of PATH, dont know)
* If you are not creating new subdirectories all the time and just want "all subdirectories th... | You can try something like this. Just name the file `file.txt`
```
add_path() {
declare -a new_path
local IFS=:
mapfile -t new_path < <(find /usr/local/bin/ -type f -name '*.py')
NEW_PATH=${new_path[*]%/*}
export PATH="$PATH:$NEW_PATH"
}
add_path
```
Just source that file.
```
source ./file.txt
```
The... |
13 | No.2 on <http://blog.stackoverflow.com/2010/07/the-7-essential-meta-questions-of-every-beta/> | 2010/11/12 | [
"https://security.meta.stackexchange.com/questions/13",
"https://security.meta.stackexchange.com",
"https://security.meta.stackexchange.com/users/33/"
] | With the increasing use of social media mining tools such as Maltego we should be stressing that people should think carefully about what they are asking questions on. Especially if they are asking questions about their companies security posture or configuration.
If I was going to do a profile of a company there coul... | I think we should have something in there specifically around not posting requests for ways to hack a device/app/database/OS. Haven't yet thought of appropriate wording (It is 1am and it has been a long day) but after having to close a couple of questions on this topic I think it is worth having a standard FAQ answer. |
70,251,636 | I have a dataframe where I would like to maintain all columns in my original dataset and create a new pivoted column based on existing dataset.
**Data**
```
stat1 stat2 id q122con q122av q122con q122av q222con q222av q222con q222av
50 1000 aa 40 10 900 100 50 0 1000 0 ... | 2021/12/06 | [
"https://Stackoverflow.com/questions/70251636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5942100/"
] | Lot of your issues here is dealing with duplicate column names:
```
import pandas as pd
# Duplicating input dataframe with clipboard and remove dot numbers assign for duplicate column headers
df = pd.read_clipboard()
df.columns = df.columns.str.split('.').str[0]
# Set index to move first three columns into index
df ... | It's not as pretty as the other solutions but it works:
```
out = df.set_index(['stat1','stat2','id']).stack()
idx = pd.DataFrame(out.index.tolist())
count = idx.groupby(idx.columns.tolist()).cumcount().tolist()
idx = (idx.iloc[:,:-1]
.merge(idx.iloc[:,-1].str.extract('(q\d{3})(.*)'), left_index=True, right_ind... |
22,054,679 | I have a set of items that have information on them. These items are defined by me, the programmer, and the user do not ever need to change them, they will never need to change based on configuration, and the only time they might change is in a future version of my application. I know before hand how many of these item... | 2014/02/26 | [
"https://Stackoverflow.com/questions/22054679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172272/"
] | If it's purely for description you can use the built-in `DescriptionAttribute` as stated in some of the other answers. If you need functionality that an attribute can't supply, however, you can create a lookup with some sort of metadata object.
Something like this:
```
public enum PossibleKeys
{
Key1,
Key2,
... | Another alternative can be using *Java style enums*
```
public class PossibleItems
{
public string Name { private set; get; }
public string Description { private set; get; }
public static PossibleItems Item1 = new PossibleItems() { Name = "My first item", Description = "The first of my possible items" };
... |
4,451,662 | How is this mechanism realized, I mean, having some layouts and changing them when user scrolls the screen? I need it to look like the Samsung Galaxy S main menu, or Angry Birds Seasons level menu. Thanks in advance. | 2010/12/15 | [
"https://Stackoverflow.com/questions/4451662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/543539/"
] | By the way, `Thread.Sleep` is probably never a good idea.
A basic problem with `Thread.Sleep` that people are usually not aware of, is that the internal implementation of `Thread.Sleep` *does not pump STA messages*. The best and easiest alternative, if you have to wait a given time and can't use a kernel sync object, ... | You don't provide a lot of background on why you're doing this, or what you're trying to accomplish, but if its possible, you might want to look into creating a windows service. |
264,154 | How can I fetch more than 1000 record from data store and put all in one single list to pass to django? | 2008/11/05 | [
"https://Stackoverflow.com/questions/264154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20683/"
] | Fetching though the remote api still has issues when more than 1000 records. We wrote this tiny function to iterate over a table in chunks:
```
def _iterate_table(table, chunk_size = 200):
offset = 0
while True:
results = table.all().order('__key__').fetch(chunk_size+1, offset = offset)
if not ... | JJG: your solution above is awesome, except that it causes an infinite loop if you have 0 records. (I found this out while testing some of my reports locally).
I modified the start of the while loop to look like this:
```
while count % 1000 == 0:
current_count = query.count()
if current_count == 0:
br... |
169,987 | In C/C++ it is in general possible to do `strcpy`(`argv[0]`, "new process name"). It's a hack used in malicous software to hide real process name. Is such operation possible via shell?
What I want to do is: change `$1`, `$2`, ... so that the script can make certain information easily available to user. For example, if... | 2014/11/26 | [
"https://unix.stackexchange.com/questions/169987",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/92616/"
] | With recent Linux, `printf foo > /proc/$$/comm` will change the executable name (the `ps -p` thing) provided "noclobber" isn't set (and the wind is in the right direction).
In zsh, `printf foo >! /proc/$$/comm` works regardless of clobbering state. | You could make your script recursive this way:
```
#! /bin/sh -
do-something-with "$1"
shift
[ "$#" -eq 0 ] || exec "$0" "$@"
```
Then when running `your-script a b c`, the `ps` output would show in turn:
```
your-script a b c
your-script a b
your-script a
``` |
136,670 | I have a some what strange problem (which could have an easy and obvious solution for all I know).
My problem is that when I've booted ubuntu (now 10.4 but same problem with 9.10) and turns it off it starts sending a HUGE amount of data via the ethernet cable, so much in fact that my router can't handle it and stops r... | 2010/05/01 | [
"https://superuser.com/questions/136670",
"https://superuser.com",
"https://superuser.com/users/35756/"
] | What is indicating that your Ubuntu-shutting-down computer is sending data to your router?
I mean, do you have any other things to show that there was data being sent?
(for example, you might put a hub in the path and capture data on it while the shutdown is in progress... does that show such transfers?)
A simpl... | It could be a faulty Ethernet cable that sends out noise as the signal is coming down. Try a different cable. |
57,295,193 | I want to solve the following problem. I have variable data\_json which contain json data of following structure
```
data_json =
"api": {"results": 402,
"fixtures":
[{"fixture_id": 127807,
"league_id": 297,
"round": "Clausura - Semi-finals",
"statusShort": "FT",
"elapsed": 90,
"venue": "Estadio Universitario d... | 2019/07/31 | [
"https://Stackoverflow.com/questions/57295193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11363452/"
] | `id["homeTeam"]` and `id["awayTeam"]` aren't lists (there are no square brackets around them), they're just single dictionaries. So you don't need to loop over them.
```
date_fixt = open("../forecast/endpoints/date_fixtures.txt", "r")
date_fixt_json = json.load(date_fixt)
data_json = date_fixt_json["api"]["fixtures"]
... | Your json may be formatted improperly if it is thinking that "homeTeam" is reference to a string and not a dictionary.
try:
```
import json
data_json = json.loads(data_json)
home_team_id = id["homeTeam"]["team_id"]
away_team_id = id["awayTeam"]["team_id"]
```
The second issue may be that it's failing at:
```
fixt... |
15,859 | My digital piano (Roland FP 80) can transpose the existing MIDI file at most five semitones up or at most six semitones down (does not allow to select more). Has it been done for my convenience ("too many features") or there are some fundamental reasons making transposition by arbitrary range more difficult than appear... | 2014/03/02 | [
"https://music.stackexchange.com/questions/15859",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/8737/"
] | Why would you need more than that?
Five semitones up and six down can make every possible key:
Let's say the original MIDI file was in C major. Up 5 semitones and you can get C C# D D# E and F. Down 6 semitones and you can get C B Bb A Ab G Gb. I am aware that you cannot transpose to a different octave using that but... | Look for a separate Octave Shift function.
As David has already said above, there are two different functions, transpose, which shifts by semi-tones and octave shift which does the same thing by a whole octave. If you just want to shift the pitch by a whole number of octaves you need to use that function, if you then ... |
80,643 | I'm going to be running *Curse of Strahd* for my regular group. I'm usually a player and have only DM'd once to give our usual DM a break. This is my first time with a published adventure.
I finished reading the campaign book through, and I'm now assembling notes and thinking deeper about how I want to run the game.
... | 2016/05/25 | [
"https://rpg.stackexchange.com/questions/80643",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/28283/"
] | Having studied the book, you have some idea of what each Tarokka result can entail, and you can let this "foreknowledge" inform Madam Eva's reactions to the cards as they appear. If you draw
>
> the 7 of Coins, you can hint that the location of the treasure isn't very far away; if you draw the 9 of Coins, Madam Eva ... | Strahd's a vampire -- he can peer into other realms. He sees that there is some kind of seance or party sitting around a table thinking about him in Ravenloft (your D&D group ;^>).
Here's an unorthodox suggestion. Figure out a way to associate different cards with different questions about the player's themselves. Mak... |
3,629,545 | Is it redundant to run `git add .` and then `git commit -am "commit message"`?
Can I just run `git add .` and then `git commit -m "commit message"` or, alternatively, just `git commit -am "commit message"`? | 2010/09/02 | [
"https://Stackoverflow.com/questions/3629545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/168286/"
] | `Git add` + `git commit -m` will just commit those files you've added (new and previously tracked), but `git commit -am` will commit all changes on tracked files, but it doesn't add new files. | I think some of the previous answers did not see the period after `git add` (your original question and some of the answers have since been edited to make the period more clear).
`git add .` will add all files in the current directory (and any subdirectories) to the index (except those being ignored by `.gitignore`).
... |
191,747 | I have a PDF of a Ph.D. thesis in mechanical engineering, so there are lots of equations. No PDF app that I've tried on OS X (Preview.app,Adobe Reader, Skim, PDFPen) can show the equations properly; some symbols are missing (particularly integral signs). However, when I open the file in Windows (with PDF X-Change) the ... | 2015/06/15 | [
"https://apple.stackexchange.com/questions/191747",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/132077/"
] | Try the following:
1. Open the "Keyboard" preferences pane
2. In the "Keyboard" tab, turn on the "Show Keyboard and Character Viewers in menu bar" checkbox
3. Go to the new menu (it looks like a box with a command key clover-leaf in it) and choose "Show Keyboard Viewer"
You'll now see a window shaped like your keyboa... | I happen to have run into this today though probably for an unrelated reason, but maybe this will help someone else. I had recently installed Snap Camera and bound Shift-T and Shift-O to actions in the app. What I didn't realize was that the app stayed open in the background (with a menubar icon) and was capturing thos... |
3,682,019 | I have a question -
If a player rolls $4$ dice, and the maximum result is the highest number he gets (for example he tosses and gets $1$,$2$,$4$,$6$ the maximum result is $6$). His opponent rolls a single die and if the player's result is higher than his opponent's, he wins. What is the chance of the player to to lose... | 2020/05/19 | [
"https://math.stackexchange.com/questions/3682019",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/778899/"
] | Find:$$P(D\_1,D\_2,D\_3,D\_4\leq D\_5)=\sum\_{k=1}^6P(D\_1,\dots,D\_4\leq D\_5\mid D\_5=k)P(D\_5=k)$$where the $D\_i$ denote the results of 5 independent die rolls.
Here $P(D\_1,\dots,D\_4\leq D\_5\mid D\_5=k)=P(D\_1,\dots,D\_4\leq k)$ on base of independence. | If Player 1 (P1) rolling one die rolls a 6, i'm assuming he wins and Player 2 rolling the 4 dice loses even if manages a 6 in his grouping, if so...
If P1 rolls
6 - then P1 wins 100% of time;
5 - P1 wins 48.2% of time (5x5x5x5 / 6x6x6x6 = 625/1296)
4 - P1 wins 9.87% of time (4x4x4x4 / 6x6x6x6 = 128/1296)
3 - P1 w... |
202,457 | Bones can be not quite enough sometimes, and for my secret military organization, every possible advantage is given to the soldiers. Including reinforcing bones. But...where do I put the metal?
Material specifics:
* Handwavium Material X
* Will not cause blood poisoning/other effects once in place
* No ill effects du... | 2021/05/11 | [
"https://worldbuilding.stackexchange.com/questions/202457",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/77168/"
] | ### On the outside
Of the body that is.
It's generally a bad idea to have anything in the body that the body can't repair. The metal is going to get bent and broken, it's going to need repair. It seems you have some solid medical technology going on here, but if you need to replace the bent metal in someone's leg tha... | **Drag those supersoldiers into the millenium!**
Metal, schmetal. Schmetal, I tell you! What are you, patching up Steve Austin? **Carbon fiber** is how one reinforces bones these days.
[](https://i.stack.imgur.com/fmwmO.png)
<https://www.podiatrytoday.... |
14,117,962 | My problem is I am trying to get some testimonials from the database and need to echo them in a div. The DIV has created with fix width and height values. In this case I need to display every testimonials with a link of 'read more' to full one. Here in the DIV I want to limit to only 50 words from the testimonials... c... | 2013/01/02 | [
"https://Stackoverflow.com/questions/14117962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1942155/"
] | you can do like this-
```
echo wordwrap(substr($str, 50), 20, "<br />\n");
``` | If the container has fixed height and width values, then limiting the amount of text by character is only fool-proof if you're using a monospaced typeface. Why not do it the CSS way?
```
.truncated {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
```
[Browser support](http://caniuse.co... |
1,434,166 | I've created a simple REST service that serves data as XML. I've managed to enable XML, JS and RSS format but I can not find the way to enable JSON format. Is JS == JSON? Guess not :).
How can I enable this in version 1.2/1.3?
Thx!! | 2009/09/16 | [
"https://Stackoverflow.com/questions/1434166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/132257/"
] | Router::parseExtensions('json'); | just add this line of code in your controller or AppController
```
var $components = array('RequestHandler');
function beforeFilter() {
$this->RequestHandler->setContent('json', 'text/x-json');
}
```
and run it into internet explorer. |
62,070,024 | Good afternoon.
Announced the ADX indicator function
(link Python: Average Directional Index (ADX) 2 Directional Movement System Calculation - <https://www.youtube.com/watch?v=joOWm-GcHTw>).
An error occurs during operation - "TypeError: 'builtin\_function\_or\_method' object is not subscriptable".
on this line -
... | 2020/05/28 | [
"https://Stackoverflow.com/questions/62070024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13635936/"
] | ```
output = [[item[0] for item in order] for order in orders]
display(output)
[['Fries'],
['Burger', 'Milkshake', 'Cola'],
['Cola', 'Nuggets', 'Onion Rings'],
['Fries'],
['Big Burger', 'Nuggets']]
``` | You can isolate the keys by zipping up each order and returning the first index of each zip result.
**The following gives you a list of tuples:**
```
orders2 = [list(zip(*order))[0] for order in orders]
```
**If you need a list of lists, use this:**
```
orders2 = [list(a) for a in [list(zip(*order))[0] for order... |
11,830,351 | First, here is the code:
```
<form action="FirstServlet" method="Post">
Last Name: <input type="text" name="lastName" size="20">
<br><br>
<input type="submit" value="FirstServlet">
<input type="submit"value="SecondServlet">
</form>
```
I'd like to understand how to send information in case the `First... | 2012/08/06 | [
"https://Stackoverflow.com/questions/11830351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1403516/"
] | In addition to the previous response, the best option to submit a form with different buttons without language problems is actually using a **button** tag.
```
<form>
...
<button type="submit" name="submit" value="servlet1">Go to 1st Servlet</button>
<button type="submit" name="submit" value="servlet2">Go ... | ```
function gotofirst(){
window.location = "firstServelet.java";
}
function gotosecond(){
window.location = "secondServelet.java";
}
```
```html
<form action="FirstServlet" method="Post">
Last Name: <input type="text" name="lastName" size="20">
<br><br>
<input type="submit" onclic... |
39,159,065 | This is the `JSON` Response I'm getting,I unable to parse,Please help me.
```
{
"features": [{
"attributes": {
"OBJECTID": 1,
"schcd": "29030300431",
"schnm": "UNAIDED GENITALIA LIPS DALMATIA RS"
},
"geometry": {
"x": 8449476.63052563,
"y": 1845072.4204768054
}
... | 2016/08/26 | [
"https://Stackoverflow.com/questions/39159065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3728743/"
] | You should use `IsPostBack` on Page load to prevent every time page load on button click. You can check every time on `Page_Load`.
**Sample Code**
```
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// First Time Load When User Come
}
else
{
// Every Time... | Try to Add `OnClientClick="return false;"`
```
<asp:Button ID="btnApprove" runat="server" Text="Approve" CssClass="button" OnClick="btnApprove_Click" OnClientClick="return false;"/>
``` |
54,113,724 | I am checking some code and I am wondering if this expression could ever be `false`:
```
!isset($_POST['foo']) || $_POST['foo']
```
Context:
```
$bar = (!isset($_POST['foo']) || $_POST['foo']) ? 1 : 0;
``` | 2019/01/09 | [
"https://Stackoverflow.com/questions/54113724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/248959/"
] | According to a quick test below, it is indeed possible
```
$trueVar = true; // Or 1
$falseVar = false; // Or 0
$nullVar = null;
$emptyVar = "";
$result1 = (!isset($trueVar) || $trueVar) ? 1 : 0;
$result2 = (!isset($falseVar) || $falseVar) ? 1 : 0;
$result3 = (!isset($nullVar) || $nullVar) ? 1 : 0;
$result4 = (!isset... | You could think of the following cases:
* **$\_POST['foo'] doesn't exist**
$bar = (true || null) ? 1 : 0 => 1
* **$\_POST['foo'] exists and value is anything but 0, false or empty string**
$bar = (false || true) ? 1 : 0 => 1
* **$\_POST['foo'] exists and value is 0, false, empty string**
$bar = (false || false) ?... |
16,924,120 | We're facing a formatting issue with publishing PDF output from XML content.
In table columns, text in a table cell contains some text (model numbers) for example,
AD150, OP834,
HT78J, QW09T,
OL560, **PQ**
**UW**, AG800, XN280
as highlighted, the model names mentioned are split into two lines if there is ... | 2013/06/04 | [
"https://Stackoverflow.com/questions/16924120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2452560/"
] | The sample XSL provided will work well if the input XML has separate tags for each model number. If it does not and the source XML is something like this:
<modellist>OL560, PQ UW, AG800</modellist>
Then you would write a recursive template to process through each character in the list, writing the output into a varia... | One cheap thing to try: when you render the model names, change blanks to character U+00A0, non-breaking space. Something like this:
```
<xsl:template match="model-name">
<xsl:value-of select="translate(.,' ',' ')"/>
</xsl:template>
``` |
23,314,652 | How do I solve this error?
```
Can't locate Switch.pm in @INC (you may need to install the Switch module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at external/webkit/Source/WebCo... | 2014/04/26 | [
"https://Stackoverflow.com/questions/23314652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7946951/"
] | You are getting this error because you don't have the Switch.pm perl module installed on your system. There are two ways to install it and both of them work on Ubuntu 14.04 as well.
1. Install it through the Ubuntu repositories.
2. Install the .pm through CPAN.
Installing Switch.pm using the Ubuntu repositories:
----... | You can resolve this error by installing "perl-Switch"
for **Amazon Linux** / **Redhat** / **Centos** / etc:
```
sudo yum install -y perl-Switch
```
for **Ubuntu**:
```
sudo apt-get install -y libswitch-perl
``` |
7,975,444 | I have a WCF service that needs to be called via SOAP (working) and via JSON (not working).
My C# code:
```
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebGet(ResponseFormat=WebMessageFormat.Json)]
string Foo();
}
public class Service1 : IService1
{
public string Foo()
{
... | 2011/11/02 | [
"https://Stackoverflow.com/questions/7975444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/536/"
] | Your problem is that you are calling `spaced` with a non-numeric string and then trying to convert that to an integer:
```
>>> int("Blusson Hall")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: 'Blusson Hall'
```
If you want a range based ... | You can't convert a string to an integer, and that's what you try to do when you type:
```
n = int(s)
```
spaced only takes one argument, 's', and you pass in a string, then try to convert it to an integer. I think what you want is probably
```
n = len(s)
```
But really, you don't even need that. Since strings a... |
424,736 | Im a student of class 11th and right now my schools teaching atomic structure , can anybody tell me that why do we need high voltage and low pressure in discharge tube in cathode ray experiment? | 2018/08/25 | [
"https://physics.stackexchange.com/questions/424736",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/204848/"
] | If the cathode ray experiment has a beam of electrons hitting a fluorescent screen which glows then:
* You need the low pressure in the tube so that the passage of the beam
of electrons is not impeded very much by collision with air molecules.
* You need a reasonably high accelerating voltage to give the electrons
en... | Why high voltage?
To break the molecules of the gas into atoms and to remove the electrons from the outermost orbitals.
Why low pressure?
To allow the rays to move freely from one electrode to another and the possibility of collisions between rays and moleculess are minized. |
108,796 | It seems like Azure is getting a lot of buzz lately, but it's doesn't seems to make sense for us. Here are our basic details
* Primarily .NET/Microsoft
* Primarily intranet
applications, but also have a public
company website
* Have a full time IT
staff and manage our own servers
* Offices in 4 major cities
* Internet... | 2010/02/02 | [
"https://serverfault.com/questions/108796",
"https://serverfault.com",
"https://serverfault.com/users/14121/"
] | Since you already have a bunch of servers, making them useless by moving to Azure (or EC2) will not pay. But when the time comes to replace or add hardware you should consider a hosted (i.e. "cloud") environment, or even directly hosted solutions.
Your supposition of higher TCO for Azure/EC2 is far from certain. If f... | Do you have an existing DR solution? It could be used for that. |
59,035,731 | Write an SQL query to find all those hostnames that have encountered multiple logs
“init failure” on any given day at 5 min interval. Also provide count of such log instance.
```
//Hostlogs
//date, time, hostname, logs
//may 20, 2019 8:00 abc init failure
//may 20, 2019 8:01 abc init failure
//may 20, 2019 8:02 abc... | 2019/11/25 | [
"https://Stackoverflow.com/questions/59035731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12430420/"
] | This is caused because of a broken setuptools package, you just need to reinstall it.
For most operating systems: `pip install setuptools`
Linux: `apt-get install python-setuptools` or `yum install python-setuptools` | Stumbled uppon this answer first on google when searching for this error code, so for future reference ill just leave a link to this issue that solved my problem:
<https://stackoverflow.com/a/59979390/10565375>
tldr:
```
pyinstaller --hidden-import=pkg_resources.py2_warn example.py
``` |
60,441,236 | Given the following C code:
```
#include <stdio.h>
#include <string.h>
typedef struct a {
char name[10];
} a;
typedef struct b {
char name[10];
} b;
void copy(a *source, b *destination) {
strcpy(destination->name, source->name);
}
```
This main function below runs successfully:
```
int main() {
... | 2020/02/27 | [
"https://Stackoverflow.com/questions/60441236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12100328/"
] | They don't run identically because you don't allocate memory for `first` and `second` in the second example. To do that, you can allocate them using `malloc`:
```
a *first = malloc(sizeof(*first));
b *second = malloc(sizeof(*second));
```
If you allocate using `malloc`, make sure to check if the pointers are `NULL` ... | The program are not identical because in the second program the declared pointers
```
a *first;
b *second;
```
are not initialized, have indeterminate values and do not point tfo valid objects of the types a and b.
You have to define objects of the types a and be to which the pointers will point to.
For this purpo... |
81,102 | [](https://i.stack.imgur.com/6mfUa.jpg)
I am using Illustrator CS6 and when I want to make a rectangle's corners round by using the direct selection tool and doing it manually, there is no option for that. So how to do so? | 2016/12/02 | [
"https://graphicdesign.stackexchange.com/questions/81102",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/72298/"
] | Since this functionality was not made available until later versions of illustrator, your only option is to do it through a plugin:
* [VectorScribe](http://astutegraphics.com/software/vectorscribe/), from AstuteGraphics has not only live (rounded)
corners, but TONS of functionality to edit paths. It is a must for
all ... | [](https://i.stack.imgur.com/EfbV0.png)
I am using Illustrator CS5. I always do it like this. Then if I need to adjust further I use the Direct Selection tool and adjust it. |
21,975,920 | I'm creating an API using peewee as the ORM and I need the ability to convert a peewee model object into a JSON object to send to the user. Does anyone know of a good way to do this? | 2014/02/23 | [
"https://Stackoverflow.com/questions/21975920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1438754/"
] | I had this very same problem and ended up defining my own parser extension for JSON types that could not be automatically serialized. I'm fine for now in using strings as data represented (although you could possibly use different datatypes, but beware of approximation using floating points!
In the following example, ... | I usually implement the model to dict and dict to model functions, for maximum security and understanding of the inner workings of the code. Peewee does a lot of magic and you want to be in control over it.
The most obvious argument for why you should not iterate on the fields but rather explicitly specify them is bec... |
66,672,754 | I have a generic method that takes List (extend Person) and should result a new List S(extend Student).
The teacher said I am not allowed to cast (S)t as I did in my code.
Student class extends Person class
```
// Main
List<Person> people = new ArrayList<>();
people.add(new Person());
people.add(new Student());
List<... | 2021/03/17 | [
"https://Stackoverflow.com/questions/66672754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11866427/"
] | It is unclear what exactly you assignment is or your return type `(List<Student> vs List<Person>)`. But you can do the following:
```
List<? extends Person> students = getStudent(people);
```
By making the following changes:
* return type is `List<? extends T>`
* put the Students in a `List<T>`
* remove the type de... | I think the best way, is using abstraction concept,
here the example, hope its help
```
public static <T extends Person, S extends Student> List<People> getStudent2(List<T> list) {
List<People> students = new ArrayList<>();
for (People t : list){
if (t instanceof Student){
students.add(t);... |
11,030,757 | Is it possible to change object's value not directly?
For example
```
a = {x: 5}
b = a.x
b = 100
a.x // => 5
```
I'd like to get 100, but actually, `a.x` is still 5. | 2012/06/14 | [
"https://Stackoverflow.com/questions/11030757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/792549/"
] | Just use the number as object, and not as literal:
```
a = {x: {v: 5}}
b = a.x
b.v = 100
a.x.v // => 100
``` | It's impossible to achieve this in JavaScript. 5 is of a Number type and it's a value type. There is no way to access it through reference unlike Function, Object or Array. |
19,767,826 | I am trying to limit the input of a textbox of a very simple Web Application so that the user can only input numbers. Im having trouble doing this without using 20 lines of code, any help at all is appreciated!
```
protected void Button1_Click(object sender, EventArgs e)
{
{
int input = int.Par... | 2013/11/04 | [
"https://Stackoverflow.com/questions/19767826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2929497/"
] | following is the javascript code to validate numeric value.
```
<script type="text/javascript">
function ValidateTextBox() {
var value = document.getElementById("txtprice").value;
if (!isNumber(value)) {
alert("Please Enter Numeric Value ");
return false... | Try adding the following markup to your Web Application next to your TextBox :
```
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Input must be a number!"
ValidationExpression="^[1-9]\d*$" ControlToValidate="InputBox"></asp:RegularExpressionValidator>
```
This will ... |
20,541,788 | I'm combining two C programs using a header file.
first program
```
#include<explore.h>
int main()
{
int a =10;
explore();
}
```
explore program
```
#include<stdio.h>
int explore()
{
// I want to use the value of a. Can I use it? How can sue it?
}
```
I want to use the value of `a` in `explore()`... | 2013/12/12 | [
"https://Stackoverflow.com/questions/20541788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2971609/"
] | Ok, first off. With the code as it stands now, you won't be able to use the int `a` anywhere, except in the `main` function, since it's a local variable to that function.
Either pass it as an argument, or declare it as a global (and an *extern* for that matter). Either way, I'd opt to pass it as an argument, if `a` ... | Call `explore` with `a` as parameter.
Nevertheless, you don't really seem to have two "programs". You have two source files in one program. So another way to use `a` in both parts could be to define `a` in main.c and declare it as "extern" in explore.h. Keep in mind, though, that `a` is somewhat "global" to your progr... |
13,164,218 | What is the difference between class A and class B?
What's wrong with self?
Why do I need to declare self line by line?
```
class A(dict):
def __init__(self):
self={1:"you", 2:"and me"}
print "inside of class A",self
class B(dict):
def __init__(self):
self[1]="you"
self[2]="and me"
print "ins... | 2012/10/31 | [
"https://Stackoverflow.com/questions/13164218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1789431/"
] | In class A, you are assigning to the local `self` variable. When `__init__` is called, `self` contains a reference so the constructed object. You are reassigning it to something else completely; *this does not change the instance of class A at all*.
In fact, if you define a new method on class A you will notice that t... | just adding to the other good answers. you can see the difference in the Byte-code:
**Byte-code of `A`:**
```
Disassembly of __init__:
3 0 BUILD_MAP 2
3 LOAD_CONST 1 ('you')
6 LOAD_CONST 2 (1)
9 STORE_MAP
... |
16,629,979 | In short, how do I let alert(1) run first:
```
$.post('example.php', function() {
alert(1);
})
alert(2);
alert(3);
alert(4);
```
But jquery ajax call seem like run in asynchronous method. So JavaScript will run everything below first, alert(2) to alert(4), then back to the post method, al... | 2013/05/18 | [
"https://Stackoverflow.com/questions/16629979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2292614/"
] | >
> *"Certainly I can just put the code in the ajax function, but this make no sense when I have dozens of functions, then I would have to add the code to all functions."*
>
>
>
There are many patters that can make this easier, but if you're saying that dozens of functions may need to call this post, you could jus... | The reason the `alert`s are firing in that order is because the "**A**" in AJAX stands for **Asynchronous**.
Here is how the code executes:
* The `post` method sends a request to the server, the second parameter is a callback function which will be called later once the request is returned by the server.
* It then pr... |
22,175,369 | If I want to display images in a template, the path I specify is relative to the static folder in my app directory. But if I want to load a file from a view function, then the path I specify seems to be relative to the project directory. Should these files all be in the same directory? Or is it typical to separate them... | 2014/03/04 | [
"https://Stackoverflow.com/questions/22175369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3320135/"
] | Emacs autosave files are ignored with
```
\#*#
``` | To suppress the temporary Emacs files appearing on `git status` globally, you can do the following:
1. **Configure git to use a global excludesfile**
Since this is a common problem, `git` has a [specific solution](https://git-scm.com/docs/gitignore) to that:
>
> Patterns which a user wants Git to ignore in all situ... |
27,259,858 | I don't know much about HTML, basically only what I've taught myself (so if you answer please don't speak in developer language hehe).
I need the entire below styled button to be clickable, not just the text. I've been researching all over google but can't work it out.
Also the corners only appear rounded in some brows... | 2014/12/02 | [
"https://Stackoverflow.com/questions/27259858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4317650/"
] | VBScript has 5 windows into the .NET world:
1. By doing HTTP POST/GET to a .NET handler of some kind (such as a .aspx, HTTP handler, MVC or WebAPI controller).
2. By writing data to a file or a database for a .NET process to pick up.
3. By [exposing a .NET assembly (class library) as a COM object](http://msdn.microsof... | You need to mark your assembly as COM visible by setting the COMVisibleAttribute to true (either at assembly level or at class level if you want to expose only a single type).
Next you register it with:
```
regasm /codebase MyAssembly.dll
```
and finally call it from VBScript:
```
dim myObj
Set myObj = CreateObjec... |
31,345,754 | I am working my way through "Java - A beginners guide by Herbert Schildt". I hope this question is not way too ridiculous. It is about a while loop condition, where the while loop is located inside a for loop. The code example is this one:
```
public static void main(String[] args) {
int e;
int result;
f... | 2015/07/10 | [
"https://Stackoverflow.com/questions/31345754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5103623/"
] | If you do not do `e--` you will get stuck in an endless `while loop`.
Look at it like this:
Let's go into a random iteration of the `for` loop.
Let's say `i=5`.
Then `e=i` so `e=5`.
We now jump into the `while` loop.
```
while (e >0) {
result*=2;
e--;
}
```
If we did NOT do `e--`, `e` would always stay ... | **Simple word explanation** :
>
> In while loop you need such a statement because of which the while
> condition becomes false and program control comes out of the while
> loop and it will help to avoid endless lopping problem.
>
>
>
**You have asked why decrementing e is important in this program?**
**Answer... |
13,717 | I think to learn a language including Chinese, you would need to first learn the fundamentals, such as the vocabulary, pronunciation and grammar. After that, native speakers go their own way to develop into a more proficient speaker/writer/communicator.
This process takes time and results are uncertain (maybe). Any su... | 2015/05/28 | [
"https://chinese.stackexchange.com/questions/13717",
"https://chinese.stackexchange.com",
"https://chinese.stackexchange.com/users/4640/"
] | Thanks for everyone's comments. I think I got some answer to this question.
To improve Chinese beyond intermediate level, one can "use the language in context".
Single-person activities include
* Reading Chinese in cartoon book with a topic you are interested in or familiar with
* Watch Chinese drama/movies or tran... | Many young people in China use the APP like QQ or WeChat chat on the Internet,so you can find someone to be your friend.It is a funny way to learn Chinese. |
3,283,901 | I'm working on a project that already contains the [gzip](http://www.gzip.org/) library as follows:
```
zlib\zlib.h
zlib\zlib.lib
zlib\zconf.h
```
I would like to use the gzip functions from this .lib but am getting the following [errors](http://msdn.microsoft.com/en-us/library/f6xx1b1z%28VS.71%29.aspx):
```
C... | 2010/07/19 | [
"https://Stackoverflow.com/questions/3283901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52256/"
] | you also need to add zlib.lib to your project's libraries:
Project properties->Linker->Input->Additional Dependencies. | It turned out the static library I was using had the gz() functions taken out of them. The header file still had them which was misleading. |
49,852,532 | In my Postgresql 9.3 database I have a table `stock_rotation`:
```
+----+-----------------+---------------------+------------+---------------------+
| id | quantity_change | stock_rotation_type | article_id | date |
+----+-----------------+---------------------+------------+---------------------+
| 1 |... | 2018/04/16 | [
"https://Stackoverflow.com/questions/49852532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9651587/"
] | In this case I would use a different internal query to get the max inventory per article. You are effectively using stock\_rotation twice but it should work. If it's too big of a table you can try something else:
```
SELECT sr.article_id, sum(quantity_change)
FROM stock_rotation sr
LEFT JOIN (
SELECT article_id, M... | You can use `DISTINCT ON` together with `ORDER BY` to get the latest `INVENTORY` row for each `article_id` in the `WITH` clause.
Then you can join that with the original table to get all later rows and add the values:
```
WITH latest_inventory as (
SELECT DISTINCT ON (article_id) id, article_id, date
FROM sto... |
34,466,205 | I have this snippet that counts the number rows and returns the number of rows found in a MySQL table. This is the code, in which I have used underscore.js's `_.each` to iterate.
```
var all_rows = Noder.query('SELECT count(*) as erow from crud ', function(err, the_rows) {
_.each(the_rows, function (cornd... | 2015/12/25 | [
"https://Stackoverflow.com/questions/34466205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4567032/"
] | While Jonathan and Ilya have already given practical solutions to your specific problem, let me provide a generic answer to the question in the title:
The simplest way to replace `_.each()` is to iterate over the array using a plain [`for`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/f... | Declare `trows` outside of the loop:
```
var trows = 0;
_.each(the_rows, function (corndog) {
trows += corndog.erow;
console.log("All rows",trows);
});
``` |
81,635 | We recieved the following e-mail with from one of the UI developers
>
> When we browser site with IP: <http://x.x.x.x/>, it doesn’t
> redirect to <http://www.our_website_name.com>. This could cause duplicate
> content problems if a search engine indexes site under both its IP and
> domain name.
>
>
> Can we set ... | 2015/02/14 | [
"https://security.stackexchange.com/questions/81635",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/58761/"
] | It's not a security problem, but it's a bit of a strange thing to do. It complicates your configuration, and is prone to errors if the IP address were to change, or you wanted to move to cloud based services. AFAIK this it isn't standard practice to redirect IP address lookups to a domain. | As an employee of a company that does hosting I can tell you we do the following for our hosting servers.
We have a 'base' (or catch-all) (virtual-) host configurations that refer to a quick to load page without any real content. (like a banner with our logo and a link to our corporate website).
This approach has sev... |
21,942,349 | How do I center the text horizontally and vertically for a TextView in Android?
How do I center the alignment of a TextView? | 2014/02/21 | [
"https://Stackoverflow.com/questions/21942349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In Linear Layouts use
```
android:layout_gravity="center"
```
In Relative Layouts
```
android:layout_centerInParent="true"
```
Above Code will center the textView in layout
To center the text in TextView
```
android:textAlignment="center"
android:gravity="center"
``` | It depends on how you have declared the height and width. If you used wrap\_content, then the textview is just big enough in that direction to hold the text, so the gravity attribute will not apply. android:gravity affects the location of the text Within the space allocated for the textview. layout\_xx attributes affec... |
5,749,807 | Given a Perforce changelist number, I want to find the local path of all files in that pending changelist.
* **p4 describe changelist** -- gets me the depot path for files in the changelist (method 1)
* **p4 opened -c changelist** -- gets me the depot path for files in the changelist (method 2)
* **p4 have** -- gets m... | 2011/04/21 | [
"https://Stackoverflow.com/questions/5749807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175/"
] | To output the local path of all pending adds of a changelist you can use:
```
p4 opened -c changelist | grep -w add | sed 's/#.*//' \
| p4 -x - where | awk '/^\// {print $3}'
```
This does the same without grep but is a bit more obscure:
```
p4 opened -c changelist | sed -n 's/\(.*\)#.*- add .*/\1/p' \
| p4 -x - wh... | Local path for all files in a pending changelist without any external or platform-specific tools:
```
p4 -F %clientFile% fstat -Ro -F action=add [-e CHANGE] //...
```
Remove the '-F action=add' if you want to get files opened for all actions. |
1,132,927 | Note: This is a long winded question and requires a good understanding of the MVVM "design pattern", JSON and jQuery....
So I have a theory/claim that MVVM in DHTML is **possible** and **viable** and want to know if you agree/disagree with me and why. Implementing MVVM in DHTML revolves around using ajax calls to a se... | 2009/07/15 | [
"https://Stackoverflow.com/questions/1132927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40914/"
] | This would probably be a good time to link to [knockout JS](http://knockoutjs.com/), which is a javascript mvvm framework.
You may also want to look at [backbone](http://documentcloud.github.com/backbone/), a javascript MVC framework: | Take a look at the ASP.NET data binding features in .NET 4.0 - comes out with Visual Studio 2010. This is exactly what you are looking for if you are ok with MS technology.
[Blog that details the feature](http://blogs.visoftinc.com/archive/2009/05/27/ASP.NET-4.0-AJAX-Preview-4-Data-Binding.aspx)
Community technology ... |
273,148 | I have been trying to incorporate CCD linear array into my circuit. However, I have never dealt with electric shutter functions which are necessary to operate the CCD. Here is the link to the datasheet (pg 2,6-8): http //oceanoptics.com/wp-content/uploads/Toshiba-TCD1304AP-CCD-array.pdf
Here are the parts that I'm str... | 2016/12/05 | [
"https://electronics.stackexchange.com/questions/273148",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/132139/"
] | At first - two basic considerations:
* The impulse response is a **closed-loop** test in the **TIME** domain (and can give you some rough "impression" regarding the degree of stability);
* The BODE diagram is an analysis of the **loop gain** (loop open) in the **FREQUENCY** domain (and can give you some figures for ph... | What you are referring to is more related to a root locus plot rather than phase/gain margin. It will show how the system will react to an impulse ( including oscillation ) and whether the system is underdamped or overdamped.
However this is different than gain and phase margin. The system could meet root locus stabil... |
11,141,293 | So I'm hoping somebody can just explain to my why when I run the following code, it prints ".link/output" at both the beginning and end of the line. I was trying to get it to print only at the end of the line. Any thoughts?
```
#!/usr/local/bin/perl
use warnings;
use strict;
my $logfiles = $ARGV[0]; #file containing... | 2012/06/21 | [
"https://Stackoverflow.com/questions/11141293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1440061/"
] | you have an empty element at the beginning of your list. simply `shift @logf` | I don't see what `@logf` does. Couldn't you just do this:
```
#!/usr/bin/env perl
use warnings;
use strict;
my $logfiles = $ARGV[0]; #file containing the list of all the log file names
#open(my $f2, "<", $logfiles);
# FOR TESTING, use above in your code
my $f2 = \*DATA;
# ===========
while(<$f2>){
chomp;
... |
275,797 | I have questions about security of my computer, digital or informational security, for which there is an [Information Security](https://security.stackexchange.com/) site.
The questions are also about security in a Linux Operating System, for which there is a [Stack Exchange community](https://unix.stackexchange.com/) ... | 2016/02/17 | [
"https://meta.stackexchange.com/questions/275797",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/303078/"
] | [Nathan's](https://meta.stackexchange.com/a/275807/155160) and [Robert's](https://meta.stackexchange.com/a/275800/155160) answers are on point, but also... Who do you want to hear from? Security experts or Linux experts? Tailoring your question to the right audience may get you better responses.
Posting to both sites ... | There's a good chance your question will fit well on any of the sites listed. Ask Ubuntu, if I'm not mistaken, caters a little more toward the GUI-friendly, end-user crowd than Unix & Linux, which is more goatees and CLI hacks that work across multiple distros. InfoSec handles things from a perhaps more generalized sec... |
16,810,634 | I'm working on Windows 8 and I want to try to disable the default edge gesture behaviors when my desktop app is fullscreen.
I've found this [page](http://msdn.microsoft.com/en-us/library/windows/desktop/jj553591%28v=vs.85%29.aspx) which explains how to do it in C++.
My app is a WPF/C# application and I've found the [... | 2013/05/29 | [
"https://Stackoverflow.com/questions/16810634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1520279/"
] | An easier solution would be using [Windows API Code Pack](https://www.nuget.org/packages/WindowsAPICodePack-Shell/).
The code setting **System.AppUserModel.PreventPinning** property would be as easy as:
```
public static void PreventPinning(Window window)
{
var preventPinningProperty = new PropertyKey(new Guid("9... | >
> I don't know how to pass the right parameter, which is a boolean. As you can see, the parameter has to be a string but no one works.
>
>
>
Pass the string `"1"` for `true`, or `"0"` for `false`. |
19,126,370 | I am using a cluster with [environment modules](http://modules.sourceforge.net/). This means that I must specifically load any R version other than the default (2.13) so to load R 3.0.1, I have to specify
```
module load R/3.0.1
R
```
I have added `module load R/3.0.1` to `.bashrc`, so that if I ssh into the server... | 2013/10/01 | [
"https://Stackoverflow.com/questions/19126370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/199217/"
] | **TL;DR**
1. Identify path of R module: `module show R/3.0.1`
2. add to your .emacs: `(add-to-list 'tramp-remote-path "/path/to/R-3.0.1/bin")`
---
bash called by TRAMP via ssh does execute its initialization files but which files ultimately get executed depends on several things. You can check if your `~/.bashrc` g... | When TRAMP runs a shell command on the remote host, it calls `/bin/sh -c`. There doesn't seem to be a way to tell `sh` to source any files at initialization when it is called like that. So let's instead configure TRAMP to call `/bin/bash -c`. Then `bash` will source `BASH_ENV`, which we can point at a custom file that ... |
12,480 | Suppose that I know [how an NPN transistor works](https://electronics.stackexchange.com/questions/12477/how-bjt-transistors-work-in-saturated-state).
How different is a PNP transistor? What are the operational differences between a PNP and a NPN? | 2011/04/03 | [
"https://electronics.stackexchange.com/questions/12480",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/3411/"
] | PNP transistors work the same way as NPNs do but all voltages and currents are reversed. You connect the emitter to the higher potential, source current from the base and the main current flows into the emitter and then exits through the collector.
\$V\_\rm{BE}\$ will be \$-0.7\,\rm{V}\$ but it's magnitude should be t... | NPN and PNP transistors are different. Electrons are more mobile than Holes Which means that PNP is not as good as NPN. For Si BJTs the PNP types are behind when it comes to breakdown voltage and really high power. For general purpose devices like BC337 / BC327 things for all intent and purpose are the same but if you ... |
6,666,617 | <http://dabbler.org/home/asdf/scrolling/test.html>
Does anyone see anything wrong with this code?
I can't figure out what is wrong with it, but my intentions are such that when the user hits the bottom of the page, the page scrolls to the top.
Thanks. | 2011/07/12 | [
"https://Stackoverflow.com/questions/6666617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/839160/"
] | Your question can be solved a few different ways, so let's break it down and look at the individual requirements you've laid out:
1. Writes - It sounds like the bulk of what you're doing is append only writes at a relatively low volume (80 writes/second). Just about any product on the market with a reasonable storage ... | Ok for MySQL I would advice you to use InnoDB without any indexes, expect on primary keys, even then, if you can skip them it would be good, in order to make input flow uninterrupted.
Indexes optimize reading, but descrease the writing capabilities.
You also may use PostgreSQL. Where you also need to skip indexes as ... |
5,913,177 | I have a new question for WCF gurus.
So, I have a class `User` which is close to the 'User' representation from the DB which I use for database operations. Now, I would like to have 2 different service contracts that use this class as data contract, but each in their own way... I mean,
```
public class DBLayer
{
... | 2011/05/06 | [
"https://Stackoverflow.com/questions/5913177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/208696/"
] | You could create separate DTO's for each service but your case would actually be ideal for a [Decorator pattern](http://en.wikipedia.org/wiki/Decorator_pattern):
```
[DataContract]
public class UserForService1 : User
{
private User mUser;
public UserForService1(User u)
{
mUser = u;
}
... | As suggested in the comment, you can have two classes deriving from a base User then using [Data Contract Known Types](http://msdn.microsoft.com/en-us/library/ms730167.aspx), you can accomplish your desired goal. See the following links for more examples.
<http://www.freddes.se/2010/05/19/wcf-knowntype-attribute-examp... |
21,578 | I've been working as a web developer for almost a year now. Before this I spent 3 years in university on a bachelor degree, which included mostly practical tasks instead of theoretical exams.
During the past 4 years, I've come to acknowledge that I work rather fast compared to my colleagues, but in exchange, my attent... | 2014/03/28 | [
"https://workplace.stackexchange.com/questions/21578",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/18085/"
] | I work in bursts like this as well. Not only in terms of hours per day, but also in terms of weeks. I might go a couple weeks of doing very little, and then a couple with very high productivity. Over an average 8 hour day, I may only be actually 'coding' 2-3 hours. I've just learned to understand thats just how I opera... | Following up to my own question as it's been 2 years now:
I've tried following the advice here and also switched jobs 3 times since then, and the short answer to the question is: There is *very little* chance that your workplace is going to accomodate to your own working pace. Companies work with a 8h/day schedule, an... |
19,358,419 | I would like to only have single checkbox selected at a time. My program reads from a textfile and creates checkboxes according to how many "answers" there are in the textfile.
Does anyone know what is wrong with the code?
```
public partial class Form1 : Form
{
string temp = "questions.txt";
p... | 2013/10/14 | [
"https://Stackoverflow.com/questions/19358419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2752375/"
] | It's so simple to achieve what you want, however it's also so **strange**:
```
//We need this to hold the last checked CheckBox
CheckBox lastChecked;
private void chk_Click(object sender, EventArgs e) {
CheckBox activeCheckBox = sender as CheckBox;
if(activeCheckBox != lastChecked && lastChecked!=null) lastCheck... | 1. Put the checkbox inside the groupbox control.
2. Loop the control enclosed on the groupbox
3. Find the checkbox name in the loop, if not match make the checkbox unchecked else checked the box.
See Sample code:
```
//Event CheckedChanged of checkbox:
private void checkBox6_CheckedChanged(object sender, EventArgs e)... |
26,908,220 | I want to create this layout:

```
<div class="row">
<div class="col-md-4 col-sm-4 col-xs-4 line"></div>
<div class="col-md-4 col-sm-4 col-xs-4"><img src="http://placepic.me/profiles/160-160" width="160" height="160" class="img-circle"></div>
<... | 2014/11/13 | [
"https://Stackoverflow.com/questions/26908220",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4247634/"
] | Your fiddle is not referencing bootstrap. Have a look now.
[Updated Demo](http://jsfiddle.net/y8kcsr31/6/)
and
```
.line {
height:2px;
background:#CCC;
}
```
is enough.
EDIT:
You can try something like this : - <http://jsfiddle.net/y8kcsr31/10/> | The OP has a design pattern like this:

Using the grid system to accomplish this is not the correct way to get the desired result.
Since there is no design pattern precisely like this in Bootstrap, let's find something similar:
`.panel`
Will work.... |
56,434,820 | Im trying to run a python3 application in a docker container using CentOS 7 as the base image. So if I'm just playing with it interactively, I type `scl enable rh-python36 bash`
That obviously switches my standard python2 environment to the python3.6 environment I install earlier(in the Dockerfile) Now, earlier in the... | 2019/06/03 | [
"https://Stackoverflow.com/questions/56434820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7113104/"
] | So I figured this out thanks to the answer from C.Nivs and an answer [here](https://stackoverflow.com/questions/36388465/how-to-set-bash-aliases-for-docker-containers-in-dockerfile). The alias works in an interactive shell, but not for the CMD. What I ended up doing was similar, only in my case I'm creating a new execu... | Configuring the shell environment variables by overriding them all to use scl\_source, as seen from following "Method #2" from Austin Dewey's [blog](https://austindewey.com/2019/03/26/enabling-software-collections-binaries-on-a-docker-image/) works for me.
```
FROM centos:7
SHELL ["/usr/bin/env", "bash", "-c"]
RUN \
... |
11,756,693 | >
> **Possible Duplicate:**
>
> [C++: Delete this?](https://stackoverflow.com/questions/3150942/c-delete-this)
>
> [Object-Oriented Suicide or delete this;](https://stackoverflow.com/questions/3959634/object-oriented-suicide-or-delete-this)
>
>
>
I wonder if the code below is run safely:
```
#include <iost... | 2012/08/01 | [
"https://Stackoverflow.com/questions/11756693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1433300/"
] | It's ok to `delete this` in case no one will use the object after that call. And in case the object was allocated on a heap of course
For example `cocos2d-x` game engine does so. It uses the same memory management scheme as `Objective-C` and here is a method of base object:
```
void CCObject::release(void)
{
CCAs... | Absolutelly, you just run destructor. Methods does not belongs to object, so it runs ok. In external context object (\*a) will be destroyed. |
236,968 | We can use CORS to restrict API calls to a specific host in a web app. How to do the same for native mobile app?
I want to restrict API calls from my app alone.
Is it possible to do so? | 2020/08/12 | [
"https://security.stackexchange.com/questions/236968",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/79154/"
] | CORS doesn't prevent anything, and it doesn't protect the server. It simply tells a *conforming* client (a browser) what is permitted for the protection of the browser's *user*; CORS is a way to carefully make holes in the browser's **Same-Origin Policy**. Additionally, CORS headers are advisory, in that they don't act... | This is not possible using http headers alone. CORS only applies to browsers, not to any other clients.
If you want to restrict api calls to your app, you need to implement some form of authentication. However, if your app is publicly available you have no way of keeping an api-key or something similar a secret if it ... |
27,969,891 | I have a List and I'm looping through it removing items in the List if there is a match.
I'm using i = -1 if the item in the List is removed. But it loops through from the beginning again. Is there a better way to do this?
```
private List<String> populateList(List<String> listVar) {
List<String> list = new ArrayL... | 2015/01/15 | [
"https://Stackoverflow.com/questions/27969891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1629109/"
] | Java's `List<T>` provides a better way of removing items from it by using `ListIterator<T>`:
```
ListIterator<String> iter = list.listIterator();
while (iter.hasNext()) {
String s = iter.next();
String dateNoTime = s.split(" ")[0];
if(!dateNoTime.equalsIgnoreCase("2015-01-13")) {
iter.remove();
... | Or you can use guava API to achieve it.
```
FluentIterable
.from(list)
.transform(new Function<String, String>(){
@Override
public void apply(String input){
return input.split(" ")[0];
}
}).filter(new Predicate<String>(){
@Override
... |
524,392 | I'm trying to do this, and failing. Is there any reason why it wouldn't work in Django template syntax? I'm using the latest version of Django.
```
{% ifequal entry.created_at|timesince "0 minutes" %}
``` | 2009/02/07 | [
"https://Stackoverflow.com/questions/524392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/326176/"
] | `{% ifequal %}` tag doesn't support filter expressions as arguments. It treats whole `entry.created_at|timesince` as identifier of the variable.
Quik workaround: introduce intermediate variable with expresion result using `{% with %}` like this:
```
{% with entry.created_at|timesince as delta %}
{% ifequal delta ... | See [ticket #5756](http://code.djangoproject.com/ticket/5756) and links in its comments for more information. A patch for Django in [ticket #7295](http://code.djangoproject.com/ticket/7295) implements this functionality. A broader refactoring of the template system based on [#7295](http://code.djangoproject.com/ticket/... |
11,138,788 | I have a Webview that is embedded inside a scrollview. The Webview itself has areas that are vertical scrollable.
Now if I try to scroll inside the webview, the scrollview intercepts the touchevent and scrolls the whole webview instead that only the small scrollable div is moved.
How can I make the scrollview work ... | 2012/06/21 | [
"https://Stackoverflow.com/questions/11138788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/114066/"
] | In my case, I have a webview within a scrollview container, and the scrollview and webview are full screen. I was able to fix this by overriding the onTouch event in my webView touchListener.
```
scrollView = (ScrollView)findViewById(R.id.scrollview);
webView.setOnTouchListener(new OnTouchListener() { ... | Our solution uses a Javascript callback through the [Javascript Interface](http://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface%28java.lang.Object,%20java.lang.String%29). Every time a part of the UI that is scrollable inside the WebView is touched a listener is called through java ... |
2,678,504 | How many solutions are there for $x^x=y^y$? I believe they are uncountable, but what is the proof? I have an example stating that $\frac{1}{2}^{\frac{1}{2}}=\frac{1}{4}^{\frac{1}{4}}$. What other examples and proofs of this are there? | 2018/03/05 | [
"https://math.stackexchange.com/questions/2678504",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/537797/"
] | The function $x^x$ has a single global minimum at $x = \frac{1}{e}$. You will notice that it is strictly decreasing from $x = 0$ to $x = \frac{1}{e}$ and strictly increasing from $x = \frac{1}{e}$ to infinity.
Moreover it is continuous, so you can use the Intermediate Value Theorem to deduce how many times the functio... | The example is *one* solution.
What about $x = \frac12,$ $y = \frac12$? Is that a solution too? Why or why not?
Can you come up with any other solutions? For how many values of $x$ can you find a solution? |
25,750,240 | Supposing that we have a array C with all element in C > 0
A pair of indices `(a, b)` is multiplicative if `0 ≤ a < b < N` and `C[a] * C[b] ≥ C[a] + C[b]`.
with the time-complexity is O ( n )
* expected worst-case time complexity is O(N);
I appreciate your help in supporting this case.
Thanks. | 2014/09/09 | [
"https://Stackoverflow.com/questions/25750240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3737020/"
] | As always with competition problems, you have to solve the problem before you code it. In this case you'll need some basic algebra. I'll ignore the strange formatting of numbers and operate only on `C`.
So, given a non-negative number `a`, what non-negative number `b` would yield `a * b >= a + b`?
`a * b >= a + b` ... | The following condition:
>
> A pair of indices (P, Q) is multiplicative if 0 ≤ P < Q < N and C[P] \* C[Q] ≥ C[P] + C[Q].
>
>
>
Combined with the presorted arrays:
>
> 4. real numbers created from arrays are sorted in non-decreasing order.
>
>
>
Allows a O(n) solution. Perhaps if you debug through your solut... |
106,766 | A common task in programs I've been working on lately is modifying a text file in some way. (Hey, I'm on Linux. Everything's a file. And I do large-scale system admin.)
But the file the code modifies may not exist on my desktop box. And I probably don't want to modify it if it IS on my desktop.
I've read about unit t... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19207/"
] | You're talking about testing too much at once. If you start trying to attack a testing problem by saying "Let's verify that it modifies its environment correctly", you're doomed to failure. Environments have dozens, maybe even millions of potential variations.
Instead, look at the pieces ("units") of your program. For... | You might want to setup the test so that it runs inside a chroot jail, so you have all the environment the test needs, even if paths and file locations are hardcoded in the code [not really a good practice, but sometimes one gets the file locations from other places...] and then check the results via the exit code. |
1,084,256 | Is there a way that I can see when a Bluetooth device was last connected to my Windows 10 laptop? | 2016/06/04 | [
"https://superuser.com/questions/1084256",
"https://superuser.com",
"https://superuser.com/users/495177/"
] | Try the log file `%SystemRoot%\inf\setupapi.dev.log` for connection logs. Or use tools like [BluetoothView](http://www.nirsoft.net/utils/bluetooth_viewer.html) or [BluetoothLogView](http://www.nirsoft.net/utils/bluetooth_log_view.html) for monitoring Bluetooth devices in the vicinity of your laptop.
There's timestamps... | If you go in "Devices and printers" and select a paired device, you may be able to find the last connection time there.
Go in the hardware tab, click "Properties", then "Details" and choose the property called "Bluetooth last connected time".
In my case, the time appears to be shifted in the future of two hours, but ... |
46,441,922 | I'm using
>
> php artisan storage:link to store the images to database. As expected Images are storing in database. But I've problem in retrieving the images and displaying them on the view.I tried different type of methods but not working. This is my code to get the records.
>
>
>
```html
public function show($... | 2017/09/27 | [
"https://Stackoverflow.com/questions/46441922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8119147/"
] | If you *use* the MongoClient for any operation that contacts the MongoDB server, then the MongoClient must create connections and background threads. Once this has happened it is no longer safe to use it in a forked subprocess. For example, this is unsafe:
```
client = MongoClient(connect=False)
client.admin.command('... | I had the same problem but with slightly different setup. For me it was Flask app and `MongoClient` was created via `flask_mongoengine`. Here is my [answer](https://stackoverflow.com/questions/51139089/mongoclient-opened-before-fork-create-mongoclient-only-flask/56474420#56474420) |
162,691 | I have about 1700 contacts in my google account. When I try to sync on my android it gets to 938 and then stops.
The last sync date shows for about a month ago, and there's always a black sync icon next to it.
I tried removing and re-adding the account to no avail.
I even did a complete factory reset. No luck.
What ... | 2016/11/20 | [
"https://android.stackexchange.com/questions/162691",
"https://android.stackexchange.com",
"https://android.stackexchange.com/users/145911/"
] | After short google search I found something that suppose to help: <https://play.google.com/store/apps/details?id=ru.ivary.ContactsSyncFix>
try using it .
if not, then you could do something like this :
1. Go to Google Contacts and Extract ALL contacts in CSV
2. Delete the contacts (Note that Google contacts has a recov... | in the end the solution was a combination of 2 steps:
1. i deleted all the contacts in the browser as suggested by @br0k3ngl255 , then i reran my sync function, and it was basically ok.
2. actually my sync function also had an issue, that a single contact had more then 1000 email addresses, which had kept the sync fro... |
18,468,021 | Background
----------
I am creating a video gallery using the ShadowBox jQuery plugin. To do this, I am creating rows of inline images using `display:inline-block`. The user will be able to upload a video as well as thumbnail images to accompany the video. The thumbnail's max size is 240x160 pixels.
What I want to d... | 2013/08/27 | [
"https://Stackoverflow.com/questions/18468021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2657386/"
] | Add `vertical-align:top` to your thumbnails:
```
.thumbImg {
max-width:240px;
max-height:160px;
vertical-align:top;
}
```
**[jsFiddle example](http://jsfiddle.net/j08691/HvZ5p/1/)**
The default value of [`vertical-align`](https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align) is `baseline`, bu... | Adding `vertical-align: middle;` to your image will solve that.
```
.thumbImg {
vertical-align: middle;
max-width:240px;
max-height:160px;
}
``` |
27,500,957 | I'm trying to make a simple iOS game to learn programming in swift.
The user inputs a 4 digits number in a text field (keyboard type number pad if that matters) and my program should take that 4 digits number and put each digit in an array.
basically I want something like
```
userInput = "1234"
```
to become
```
in... | 2014/12/16 | [
"https://Stackoverflow.com/questions/27500957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1667981/"
] | Here is a much simpler solution for future users
```
let text : String = "12345"
var digits = [Int]()
for element in text.characters
{
digits.append(Int(String(element))!)
}
``` | **Convert String into [Int] extension - Swift Version**
I put below extensions which allow you to convert `String` into `[Int]`.
It's long version, where you can see what happen in each line with your string.
```
extension String {
func convertToIntArray() -> [Int]? {
var ints = [Int]()
for char... |
986,590 | My laptop—a Toshiba Satellite C55-B5101—does not turn on anymore. This laptop contains many critical information.
I tried a new power supply as that was the primary suspect, but still there is no indication of power.
I have no clear idea how to connect internal hard drive to my desktop.
How do I know what size of en... | 2015/10/14 | [
"https://superuser.com/questions/986590",
"https://superuser.com",
"https://superuser.com/users/250045/"
] | RMarkwald's suggestion is a great way to go, especially if you only need a short-term hookup. You won't need to worry about getting the proper size enclosure. If you plan on leaving it attached long-term, an enclosure will provide more protection for it.
Your drive is SATA and 2.5". Your laptop specs say it shipped wi... | <https://m.wikihow.com/Recover-Data-from-the-Hard-Drive-of-a-Dead-Laptop>
This link provides plenty of information. Getting the hard drive out is generally pretty easy. Good luck! |
10,569 | It seems that some rules of writing code are in direct contradiction with the rules of human writing. For example in code it's advisable to define each piece of information in only one place and in writing for humans it's normal to repeat important points (though usually phrased differently).
**What rules of writing g... | 2010/10/08 | [
"https://softwareengineering.stackexchange.com/questions/10569",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/4422/"
] | ```
Indentation rules (most coding standards impose) really contradict
rules of good writing,
the way people perceive information,
and the grammar rules.
Making things (that group naturally, but not syntactically) inside
parenthesis also contradicts how texts are usually typed.
If (you try to type text tha... | 1. capitalizationIsUsuallyAtTheBeginning
2. underlines\_are\_usually\_under\_the\_words\_not\_the\_spaces
3. subject.verb(noun,noun) |
171,720 | I like to know it when I do or see something wrong. So I really like our flagging history (*x* moderator attention flags, *y* deemed helpful, *z* declined, etc.)
I specifically find the declined / disputed flags interesting, because one can learn from his faults. However, now you have to scroll through *all* your good... | 2013/03/13 | [
"https://meta.stackexchange.com/questions/171720",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/205264/"
] | I think it's just the great idea.
I made a script which will load all of your helpful/ declined/ disputed flags. To use, first go to your flags history (`http://{some-se-site-there}.stackexchange.com/users/flag-summary/your-id`).
Then run one of the following scripts.
To show declined:
```
javascript:var pn=parseIn... | I'm fairly certain I got two declined flags last night. However, I was only able to find one of them.
Because my flag history currently has pending flags that go back at least 15 pages (most of them have been handled, but not all), trying to find the rare exception among a huge list of helpful NAA and/or comment flags... |
13,979,371 | I want to create a ListView in c++.
My code so far:
```
InitCommonControls(); // Force the common controls DLL to be loaded.
HWND list;
// window is a handle to my window that is already created.
list = CreateWindowEx(0, (LPCSTR) WC_LISTVIEWW, NULL, WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_SHOWSELALWAYS | LVS_REPORT, ... | 2012/12/20 | [
"https://Stackoverflow.com/questions/13979371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1432545/"
] | Here is the link to original MSDN sample code of [ListView control](http://csdata.iblogger.org/programming/CodeSamples/) written in Windows API and C.
It compiles in VC++ 2010. | `WC_LISTVIEWW` (notice the extra W on the end) is a `wchar_t*`, but you are type-casting it to a `char*`. That will only compile if `UNICODE` is not defined, making the generic `CreateWindowEx()` map to `CreateWindowExA()`. Which means you are trying to create a Unicode window with the Ansi version of `CreateWindowEx()... |
67,849,986 | There are these two applications:
* WordPress-site with REST-API. Let's call this **Brandon**.
* Another system, using the REST-API. Let's call this **Jeremy**.
I know about the WordPress Stack Exchange, but this is more a PHP question than it is a WordPress question (I think).
---
The problem
-----------
Jeremy c... | 2021/06/05 | [
"https://Stackoverflow.com/questions/67849986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1766219/"
] | Would a simple set of trigger mechanisms help?
Jeremy updates an atom -> this triggers a request to be sent to Brandon to `BuildMolecule()`, sent in a curl request that doesn't need to wait for a response. That request has a `callback` parameter
```
$url = 'https://brandon.com/buildMolecule.php';
$curl = curl_init();... | It depends on how you are calling the REST APIs.
Is JavaScript involved? If so you could send the atom modification request and not call the build molecules
on completion but instead just respond ok. Upon receipt of this "ok" you can send a background ajax request to rebuild the molecules.
If this is a server to serv... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.