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 |
|---|---|---|---|---|---|
3,569,183 | When a user tries to access our website via a link (for instance going to www.website.com/privatepage) they are redirected to a login page. Once they login, we want to redirect them to that intended URL - how do you do this?
Also we have a use case where a user logs in from the homepage, or goes directly to the login ... | 2010/08/25 | [
"https://Stackoverflow.com/questions/3569183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364969/"
] | in your login page:
if you go to **www.example.com/private\_page**
using CodeIgniter (on private page)
```
// if user is not logged in...
$_SESSION['redirect'] = $this->uri->segment(1);
redirect('login');
```
on login page
```
// successfully logged in..
if (isset($_SESSION['redirect'])) {
redirect($_SESSION[... | I usually store the page in a PHP session before I redirect to the login page. After logging in, see if the session value is set, if it is then redirect back to that page. |
6,445,274 | How do I set watermark for a texbox in MVC3 .Also if there are multiple textboxes in a web page, how do you write different watermark text for each textbox?
```
<%:Html.TextBoxFor(mdl => mdl.inputTextSearch, Model.inputTextSearch )%>
```
Appreciate your response | 2011/06/22 | [
"https://Stackoverflow.com/questions/6445274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/811007/"
] | If I understand your question, you can just pass in:
```
new { placeholder = "my watermark" }
```
as the htmlAttributes parameter in Html.TextBoxFor.
Edit:
You can also add support for older browsers by using Javascript as outlined here:
<http://www.standardista.com/html5-placeholder-attribute-script> | Try this Jquery .You need to create an image with the watermark text.
```
$(document).ready(function () {
/*Watermark for date fields*/
if ($("#dob").val() == "") {
$("#dob").css("background", "#ebebeb url('/Content/images/DateWaterMark.png') no-repeat 1px 0px");
... |
23,078,287 | I'm trying to vectorize the following MATLAB operation:
>
> Given a column vector with indexes, I want a matrix with the
> same number of rows of the column and a fixed number of columns. The
> matrix is initialized with zeroes and contains ones in the locations
> specified by the indexes.
>
>
>
Here is an exa... | 2014/04/15 | [
"https://Stackoverflow.com/questions/23078287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/556141/"
] | Two approaches you can use here.
**Approach 1:**
```
y = [1; 3; 2; 1; 3];
yvec = zeros(numel(y),3);
yvec(sub2ind(size(yvec),1:numel(y),y'))=1
```
**Approach 2 (One-liner):**
```
yvec = bsxfun(@eq, 1:3,y)
``` | Yet another approach:
```
yvec = full(sparse(1:numel(y),y,1));
``` |
4,899,800 | So lets say I have two models:
Thingy and Status. `Thingy` has a `Status`, and Status has many Thingies. It's typical "Object and Object type relationship".
I have a view where I just want the number of thingies in each status. Or basically a list of Status.Name and Status.Thingies.Count. I could do exactly this, but ... | 2011/02/04 | [
"https://Stackoverflow.com/questions/4899800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2009/"
] | >
> Should I use a viewmodel here?
>
>
>
Is this a rhetorical question?
Your view model would look exactly as you propose and it is perfectly adapted to what you are trying to display here:
```
public class ThingiesByStatusViewModel
{
public string StatusName { get; set; }
public int StatusThingiesCount ... | I, personally, don't like to send non-trivial types to the view because then the person designing the view might feel obligated to start stuffing business logic into the view, that that's bad news.
In your scenario, I'd add a StatusName property to your view model and enjoy success. |
18,744 | "Mitzvah gedola le'heyos be'simcha..." many of us have heard this. I am wondering if there is an actual mitzvah to be be'simcha? (I am looking for sourced comments and not just idea's).
I know that simcha is not counted as a mitzvah by the Rishonim, but I think the question still stands.
I have heard that the Chasam S... | 2012/08/25 | [
"https://judaism.stackexchange.com/questions/18744",
"https://judaism.stackexchange.com",
"https://judaism.stackexchange.com/users/1769/"
] | I believe that having inner simcha (happiness) is a branch of the Mitzva to love Hashem "with all your heart, all your soul, and all your possessions [(Deuteronomy 6:5)](http://www.sefaria.org/Deuteronomy.6)" which many Rishonim consider a Mitzvah, and some consider it a constant one (Sefer HaChinuch). If you love some... | “You shall be glad with all the goodness that Hashem, your G-d, has given you and your household…” [Devarim 26:11] |
34,498,132 | Why if I write some other letter or number(not y\n) the order
```
printf("\nWould you like to play again? (y/n):");
```
run twice?
```
int ans= 0,i=1;
do
{
printf("\nWould you like to play again? (y/n):");
ans = getchar();
if (ans=='y')
{
printf("yyyyyyyyyyy");
i = i-1;
}
el... | 2015/12/28 | [
"https://Stackoverflow.com/questions/34498132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Probably because your `getchar` call is picking up the newline from your input. So if you press 'X', the first time through the loop `ans` is 'X' and the newline was buffered. The second time through the loop `ans` is '\n'.
You can put a loop around your input call like this:
```
do
ans = getchar();
while (isspac... | Another solution:
```
char c = 'x'; // Initialize to a character other than input
while( c != 'y' || c != 'n') { // You can also use strchr as @Olaf mentioned
printf ("\nPlay again (y/n): ");
c = getchar ();
}
``` |
25,510,184 | I want to check a string for a list of phrases. If those phrases exist I want to remove them and return a new string.
```
For Example:
String: Lower Dens - Propagation (Official Music Video)
Result: Lower Dens - Propagation
```
This is what I have so far, but it does not work. This would work for single words, but n... | 2014/08/26 | [
"https://Stackoverflow.com/questions/25510184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2083111/"
] | set newVideoTitle to the result of the replace operation it works. I would make a jsfiddle but am too lazy to include underscore.
[heres a fiddle](http://jsfiddle.net/uxea8vLo/1/)
```
formatVideoTitle = function(videoTitle){
var phrases = [
'(Official Music Video)',
'(Official Video)',
'(M... | `replace` returns a value, so you need to assign the replaced variable to a new variable (or the same one):
```
_.each(phrases, function(phrase) {
newVideoTitle = newVideoTitle.replace(phrase, '');
});
```
[**DEMO**](http://jsfiddle.net/6Le5spuy/2/) |
13,725,060 | I have multiple UserControl XAML files that use a similar structure. I want to remove this duplication and thought to use a Style that overrides the Template of the UserControl (and then use ContentPresenter for the custom part).
But apparently the Template of a UserControl can't be overwritten.
How do I this the cle... | 2012/12/05 | [
"https://Stackoverflow.com/questions/13725060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91002/"
] | You could define a custom control like this. (I'm not sure if you need to specify the Title separate from the content, but here it is just in case.)
```
public class MyControl : ContentControl
{
public static readonly DependencyProperty TitleProperty =
DependencyProperty.Register("Title", typeof(string), t... | Perhaps you need to use [ContentControl](http://msdn.microsoft.com/en-us/library/system.windows.controls.contentcontrol.aspx) as a base class for your controls (It should be not User Control but Custom Control).
Then you'll be able to define `ControlTemplate` and use `ContentPresenter` within it. Than you need to set ... |
39,781,420 | With the upcoming [RxJava2 release](https://github.com/ReactiveX/RxJava/tree/2.x) one of the important changes is that `null` is no longer accepted as a stream element, i.e. following code will throw an exception: `Observable.just(null)`
Honestly, I have mixed feelings about this change and part of me understands that... | 2016/09/29 | [
"https://Stackoverflow.com/questions/39781420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1277362/"
] | Well, there are several ways to represent what you want.
One option is to use `Observable<Optional<CacheItem>>`:
```
Observable<Optional<CacheItem>> getStream(final long id) {
return Observable.defer(() -> {
return Observable.just(Optional.ofNullable(findCacheItem(id)));
});
}
public static <T> Transformer<O... | You can use [`RxJava2-Nullable`](https://github.com/XDean/RxJava2-Nullable) to handle null value in RxJava2.
For your situation, you can do:
```
Observable<CacheItem> getStream(final long id) {
return RxNullable.fromCallable(() -> findCacheItem(id))
.onNullDrop()
.observa... |
17,970,410 | So here is my first question and my first C# program:
I need function that could permanently change a connection string.
My program has this structure:
Main form is `Form1`, when I click the button, `Options`, I get new from - `Form3`, where user can log in (password protects changing options) and if login is success... | 2013/07/31 | [
"https://Stackoverflow.com/questions/17970410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1967428/"
] | Did you try enabling persistence in ActiveMQ? Which version of ActiveMQ do you use? I looked in to ActiveMQ 5.8 and it uses KahaDB which is a file based DB as the default persistence configuration. The persistence approach can be changed based on you requirement.
To enable persistance;
1) Go to file [ActiveMQ\_HOME] ... | If you are using JMS Message Store, even if the server crashes, the messages which were enqueued before (and processing not yet completed) will still be there. This is because the messages are persisted in the JMS queue. If you use In Memory Message Store, upon server crash, your messages will be lost.
In JMS case, y... |
47,593,409 | I created runtime image using jlink on my Linux machine. And I see `linux` folder under the `include` folder. Does it mean that I can use this runtime image only for Linux platform? If yes, are there any ways to create runtime images on one platform for another (e.g. on Linux for Windows and vice versa) | 2017/12/01 | [
"https://Stackoverflow.com/questions/47593409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5883307/"
] | The `include` directory is for header files, such as `jni.h`, that are needed when compiling C/C++ code that uses JNI and other native interfaces. It's nothing to do with `jlink`.
The `jlink` tool can create a run-time image for another platform (cross targeting). You need to download two JDKs to do this. One for the ... | Being generally unable to add anything to Alan Bateman's answers in terms of information, I'll offer a working example. [This example](https://github.com/codetojoy/easter_eggs_for_java_9/tree/master/egg_22_JLink_Cross_Platform) illustrates using `jlink` on Mac OS and then running the binary on Ubuntu in a Docker contai... |
4,261,785 | I think I have a bug in one plugin. I would like to load only this plugin, without having to delete all the other bundles in my pathogen's bundle folder, to debug.
Is it possible? | 2010/11/23 | [
"https://Stackoverflow.com/questions/4261785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/198553/"
] | *vim --noplugin*
In this case vim will not load any plugins but your vimrc will be used.
After you can load your plugin in vim:
*:source 'your plugin path'* | Why not just:
1. rename the current bundle directory
2. create a new empty bundle directory
3. put your test plugin files into the new bundle dir?
When done put everything back the way it was. (The suggested method of loading Vim without plugins and sourcing the plugin file would work if it's a simple one-file plugin... |
4,280,970 | I did not realize that: 'have a web.config in a separate class library and' was reading the web.config app setting from different web application.
I am using VS2010 target framework 3.5
I don't know what is wrong here but I am getting `null` when I try to get `ConfigurationManager.AppSettings["StoreId"];`
```
privat... | 2010/11/25 | [
"https://Stackoverflow.com/questions/4280970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/275390/"
] | and:
```
<appSettings>
<add key="StoreId" value="123" />
</appSettings>
```
is located in the `web.config` file of your ASP.NET application and not in some `app.config` file you've added to your class library project in Visual Studio, right? You can't be possibly getting `null` if this is the case. If you've add... | I tried all of these solutions but none worked for me. I was attempting to use a 'web.config' file. Everything was named correctly and the files were in the proper location, but it refused to work. I then decided to rename my 'web.config' file to 'app.config' and just like that, it worked.
So if you are having this is... |
396,053 | I have been unable to trigger an **onselect** event handler attached to a **<div>** element. Is it possible to force a **<div>** to emit **select** events? | 2008/12/28 | [
"https://Stackoverflow.com/questions/396053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27122/"
] | You can achieve what you want by using `onMouseUp` event. See below...
```
<html>
<body>
<div id="container" style="border: 1px solid #333" contentEditable="true" onMouseUp="checkMe()">Type text here</div>
</body>
<script language="javascript">
function checkMe() {
var txt = "";
... | Use `OnClick`.
`:select` only applies to some form elements. |
16,735,454 | In my model I have this:
```
validates :name, :presence => true, :uniqueness => true
```
In my controller I have:
```
...
if @location.save
format.html { redirect_to @location, :notice => 'Location was successfully created.' }
format.json { render :json => @location, :status => :created }
...
```
which su... | 2013/05/24 | [
"https://Stackoverflow.com/questions/16735454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/478513/"
] | Add a unique index in your database. That way, if something slips through the model validations (rare, but technically possible), the query to save to the database will fail. | Your validation is correct. Just like all the other answers above, however assuming you want to validate multiple fields for example assuming you have a wishlist, that takes the `user_id` and the `item_id`, you need each item to be added only once by a user, for this kind of scenario add this type of validation to your... |
44,993,393 | I have an hidden div which will contain some HTML inputs which some are needed to be required as part of a form. the div is visible by checking the checkbox and the code looks like this:
```js
$(function() {
var checkbox = $("#checkbox01");
var hidden = $("#div01");
hidden.hide();
checkbox.change(function(... | 2017/07/09 | [
"https://Stackoverflow.com/questions/44993393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8052221/"
] | You could just toggle the type to `hidden`, that way it's no longer required
```
$("#checkbox01").on('change', function() {
$("#div01").toggle(this.checked)
.find('input').prop('type', this.checked ? 'text' : 'hidden')
.val('');
}).trigger('change');
```
```js
$(function() {
... | Try this: (**JavaScript**)
```js
$(function() {
var checkbox = $("#checkbox01");
var hidden = $("#div01");
hidden.hide();
checkbox.change(function() {
if (checkbox.is(':checked')) {
hidden.show();
document.getElementById("username").required = true;
} else {
hidden.hide();
... |
27,711,046 | apologies for the n00b question, but I have a VBScript that I generated with SAP. This script works just fine. I modified the same script by adding lines (basically just copy/paste and modify field numbers) and I am getting an the error which I will describe below.
The redacted WORKING VBScript is below:
<http://pas... | 2014/12/30 | [
"https://Stackoverflow.com/questions/27711046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4396611/"
] | char type is always padded with spaces to it's length (in your case 8000), you need to use varchar to prevent padding, you can also try to [TRIM](http://msdn.microsoft.com/en-us/library/ee634558.aspx) to get actual text
here is from <http://msdn.microsoft.com/en-us/library/ms176089.aspx>
>
> char [ ( n ) ]
>
>
>
... | There are no CHAR columns involved here. The issue is that a TEXT column always shows a length of 8000, irrespective of the actual length of the string, and no padding spaces have been stored. ANSI\_PADDING ON *allows* trailing spaces to be stored, but again, that is not the case here, as none of the rows I have inspec... |
37,758,137 | Problem Statement: I need my result set to include records that would not naturally return because they are NULL.
I'm going to put some simplified code here since my code seems to be too long.
Table `Scores` has `Company_type`, `Company`, `Score`, `Project_ID`
```
Select Score, Count(Project_ID)
FROM Scores
... | 2016/06/10 | [
"https://Stackoverflow.com/questions/37758137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6452068/"
] | You can specify the [actual column name](http://docs.sqlalchemy.org/en/latest/orm/extensions/declarative/basic_use.html#defining-attributes) (if different from the attribute name) as the first argument to `Column`:
```
emp_d = Column("employee_desgination", String)
``` | // tested on sqlalchemy1.4
if use this form define: // for others come here
```
sqlalchemy.Table('sometable', metadata,
Column('from', Intege)
)
```
alias can be define by this:
```
t1 = Table('sometable', metadata,
Column('from', Integer, key='from_')
)
```
and use column by
```
t1.c.from_
```
but, in ... |
170,706 | What is the easiest way to get the IP address from a hostname?
I was thinking about trying a [`ping`](http://en.wikipedia.org/wiki/Ping_%28networking_utility%29) and parse it from the output. However, that doesn't seem very nice and will probably not work the same way on all systems.
I searched a bit around and found... | 2010/08/14 | [
"https://serverfault.com/questions/170706",
"https://serverfault.com",
"https://serverfault.com/users/48295/"
] | This ancient post seem to have many creative solutions.
If I need to make sure also `/etc/hosts` gets accessed, I tend to use
`getent hosts somehost.com`
This works, at least if `/etc/nsswitch.conf' has been configured to use files (as it usually is). | Using `ping` is not that bad since you generally do not have any strong dependencies.
Here is the function I used on Linux systems :
```
getip () { ping -c 1 -t 1 $1 | head -1 | cut -d ' ' -f 3 | tr -d '()' ; }
``` |
30,168,779 | So I wanted to link to RealmSwift in my own framework and these are the steps I took:
1. Add `RealmSwift` as a subproject

2. Link the framework:

3. Add the dependency
![enter ima... | 2015/05/11 | [
"https://Stackoverflow.com/questions/30168779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I had the same issue, turns out that the file that showed the error was used by two different targets. When adding Realm with SPM, we can only select one target. I solved the with the following steps:
1. In the Project Navigator, select the target that lacks Realm
2. In `Build Phases > Link Binary With Libraries`, add... | Something similar happened to me when I did the pod install...
Make sure you open the appname.xcworkspace file not the appname.xcodeproj after doing the pod-install with CocoaPods.
The error No such module 'RealmSwift' will occur from any file where 'import RealmSwift' is set up if not opened from appname.xcworkspac... |
10,388,564 | How do I make the background in an image transparent? Most of my images have a white background. When I use them in my website with my body background color black it looks awkward.
I have unsuccessfully tried using [Fireworks](http://en.wikipedia.org/wiki/Adobe_Fireworks) magic wand tool to remove the white background... | 2012/04/30 | [
"https://Stackoverflow.com/questions/10388564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1366440/"
] | Use photoshop to remove the background and save it as .png
remove it like this: <http://www.addictivetips.com/windows-tips/how-to-remove-image-background-in-photoshop-tutorial/>
or using magic eraser.
good luck! | If you don't have Photoshop - the easiest way to do it is with MS Word (2010).
1. Change a background of your page to black (Page Layout --> Page Color --> Set to the color of your website)
2. Insert --> Picture
3. Once your have inserted pickture, go to **Picture Tools** and find **Background Removal** tool under **... |
48,603,244 | Technically speaking, based on posts I've read here, Hash table is indeed O(n) time lookup in the worst case. But I don't get how the internal mechanics guarantee it to be O(1) time on average.
My understanding is that given some n elements, the ideal case is there are n buckets, which result in O(1) space. This is wh... | 2018/02/03 | [
"https://Stackoverflow.com/questions/48603244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8845060/"
] | Great question!
Assume
1. We want to map `string`s to `value`s
2. `hashFunction(string) => hashedIndex : int` in O(1)
3. `valueArray : [any]` stores `value`s
4. `valueIndex : int` is the first empty index in `valueArray`
5. `lookupArray : [int]` stores each `valueIndex` at `hashedIndex`
6. array lookups are O(1).
`... | i think the word "hash" is scaring people. Behind the scene, hash tables are data structures that stores the key/value pairs in an array.
The only difference here is, we do not care about the position of the key value pair. There is no INDEX here. Look up for an array item O(1). it is independent of size of the array ... |
51,742,698 | I have designed code as:
```
import csv
import numpy as np
data = [['Diameter', 'color', 'no']]
with open('samp1.csv', 'w') as f:
writer = csv.writer(f, delimiter=',')
for row in data:
writer.writerow(row)
for i in np.arange(20,30,0.2):
writer.writerow(i)
f.close()
```
And I want to save... | 2018/08/08 | [
"https://Stackoverflow.com/questions/51742698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10174453/"
] | Don't forget to add
```
android.useAndroidX=true
android.enableJetifier=true
```
to your gradle.properties. I always forget this when I get on a new machine because gradle.properties is not in source control. Would be great if we got a sensible error in this case. | I have this problem too. When use this library in dependencies
```
implementation 'com.google.android.material:material:1.0.0'
```
Give this :
>
> Manifest merger failed : Attribute application@appComponentFactory
> value=(androidx.core.app.CoreComponentFactory) from
> [androidx.core:core:1.0.0] AndroidManifest.... |
45,081,579 | I searched for how to initialise requestPermissions and found the code below:
```
if (ActivityCompat.checkSelfPermission((Activity)mContext,
android.Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions((Activity)mContext, new String[]{
android.Ma... | 2017/07/13 | [
"https://Stackoverflow.com/questions/45081579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8302211/"
] | In CMD you'd do something like this:
```
@echo off
set "basedir=C:\some\folder"
set "outfile=C:\path\to\output.txt"
(for /r "%basedir%" %f in (*.txt) do type "%~ff") > "%outfile%"
```
For use in batch files you need to change `%f` to `%%f` and `%~ff` to `%%~ff`.
---
In PowerShell you'd do something like this:
`... | Code 3 is not bad but it won't work with spaces in a path because you use the standard `delims` as you're not providing one. Also there a several other errors about working with spaces in a path.
The following code works and combine all `txt files` in all subdirectories. It will create a new file `list.txt` in the fol... |
19,073,959 | Newbie here typesetting my question, so excuse me if this don't work.
I am trying to give a *bayesian classifier* for a multivariate classification problem where input is assumed to have *multivariate normal distribution*. I choose to use a discriminant function defined as **log(likelihood \* prior)**.
However, from... | 2013/09/29 | [
"https://Stackoverflow.com/questions/19073959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2255305/"
] | `add_resource` accepts two arguments, `resource_class_args` and `resource_class_kwargs`, used to pass arguments to the constructor. ([source](http://flask-restful-cn.readthedocs.io/en/0.3.5/intermediate-usage.html#passing-constructor-parameters-into-resources))
>
> So you could have a Resource:
>
>
>
```
from fla... | based on @Greg answer I've added an initialization check in the **init** method:
creating and calling Todo Resource class for flask-restful api:
```
todo = Todo.create(InMemoryTodoRepository())
api.add_resource(todo, '/api/todos/<todo_id>')
```
The Todo Resource class:
```
from flask_restful import reqparse, abort... |
8,364,918 | In the ARM NEON documentation, it says:
>
> [...] some pairs of instructions might have to wait until the value is written back to the register file.
>
>
>
I haven't come across a list that defines the instruction pairs that *can* use forwarded results and the instruction pairs that have to wait for write back.
... | 2011/12/03 | [
"https://Stackoverflow.com/questions/8364918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1028638/"
] | You can group adjacent items in a sequence using the [GroupAdjacent Extension Method](https://stackoverflow.com/a/8364977/76217) (see below):
```
var result = unorderedList
.OrderBy(x => x.date)
.GroupAdjacent((g, x) => x.A == g.Last().A &&
x.B == g.Last().B &&
... | If I understood you well, a simple Group By would do the trick:
```
var orderedList = unorderedList.OrderBy(o => o.date).GroupBy(s => new {s.A, s.B});
```
Just that. To print the results:
```
foreach (var o in orderedList) {
Console.WriteLine("Dates of group {0},{1}:", o.Key.A, o.... |
39,781,069 | I have an Event model with `parent_id` and `date` attributes:
Event.rb
```
has_many :children, :class_name => "Event"
belongs_to :parent, :class_name => "Event"
```
I have no issues calling `event.parent` or `event.children`. A child event never has a child itself.
I am trying to add a scope to this model so that... | 2016/09/29 | [
"https://Stackoverflow.com/questions/39781069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4621100/"
] | Ignoring Rails for a moment, what you are doing in SQL is the [greatest-n-per-group](/questions/tagged/greatest-n-per-group "show questions tagged 'greatest-n-per-group'") problem. Here are [lots of solutions](https://stackoverflow.com/questions/3800551/select-first-row-in-each-group-by-group/25534279). I would choose ... | Your own answer looks good, but I would refine it the following way:
```
scope :closest, -> {
where.not(parent_id: nil).group(:parent_id).minimum(:date)
}
```
And very important or else in production you would always get the deployment date as `Date.today` because it will only reload in development:
```
scope :fu... |
764,385 | We have seen the argument for proving the above statment using Zorn's Lemma by asserting the existence of a maximal linearly independent set which serves a basis. In finite dimensional vector space, a basis is same as a maximal linearly independent and also same as a minimal spanning set.
Does the notion of minimal sp... | 2014/04/22 | [
"https://math.stackexchange.com/questions/764385",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/138157/"
] | It doesn't work. See Keith Conrad's [note](http://www.math.uconn.edu/~kconrad/blurbs/zorn1.pdf) (namely page 16). Here is a relevant screenshot.
 | *Does the notion of minimal spanning set make sense for arbitrary vector spaces?*
Sure: why not? The notion has a sensible definition. A minimal spanning set $S$ is one for which $\langle S'\rangle \subsetneq \langle S\rangle $ whenever $S'$ is a proper subset of $S$.
If instead $S'$ were a proper subset of $S$, and ... |
11,726,678 | I want to display only `div.card1` when a user clicks on a selection menu I have made
```
<table id="flowerTheme">
<tr>
<td>
<div class="card1">
<div class="guess"><a href="#" id="flower1" class="quickFlipCta"><img src="Test Pictures/QuestionMark.gif" /></a></div>
<div class="remember"><a... | 2012/07/30 | [
"https://Stackoverflow.com/questions/11726678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1464197/"
] | ```
$('#flowerTheme').css('display', 'inline');
$('.card2').hide();
``` | You can write a javascript function to hide children...
```
function hideSpecificChildren(childClass){
var child = document.getElementByClass(childClass);
if(tab.style.display == "block") {
tab.style.display = "none";
}else {
tab.style.display = "block";
}
}
``` |
818,132 | I have thumbnails on a page, as such:
```
<div id="credits">
<a href="largeimage1.jpg" alt="credits1.php"><img src="thumb1"></a>
<a href="largeimage2.jpg" alt="credits2.php"><img src="thumb2"></a>
<a href="largeimage3.jpg" alt="credits3.php"><img src="thumb3"></a>
</div>
<div id="zoom"></div>
<div id="credits"></div... | 2009/05/03 | [
"https://Stackoverflow.com/questions/818132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/99112/"
] | Above this line:
```
return false;
```
Add this:
```
$('#credits').load($(this).attr('alt'));
```
The whole point of asynchronous requests is that you can fire as many as you want while you keep going. You might want to have some kind of loading indicator that something is happening when you use load, as well as ... | Just to make sure I'm not missing something about jquery (I'm more familiar with mootools), your first bit of code won't work unless you have an image already inside the zoom div. I don't see anything in your code that injects a new image into the div... it only targets an existing image and updates its attributes. Or ... |
14,486,101 | >
> **Possible Duplicate:**
>
> [Should you access a variable within the same class via a Property?](https://stackoverflow.com/questions/271318/should-you-access-a-variable-within-the-same-class-via-a-property)
>
>
>
I ran into this recently and was curious if there was some sort of standard for which one you ... | 2013/01/23 | [
"https://Stackoverflow.com/questions/14486101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1454813/"
] | This shouldn't be a choice you really make. Either the code in the setter is supposed to run, in which case use the property, or it's not, in which case you use the member variable. In most all situations one is right and one is wrong. Neither is always right/wrong in the general case, and it's unusual for it to "not m... | If you wrapped the field `foo` in the property `Foo`, you probably did so for a reason (conversion, events, validation, etc). So, generally speaking, the only place you should be referencing the field `foo` is in the getters and setters for the property `Foo`. The rest of the code should reference the property `Foo`.
... |
18,522 | So I did some algebraic topology at university, including homotopy theory and basic simplicial homology, as well as some differential geometry; and now I'm coming back to the subject for fun via Hatcher's textbook. A problem I had in the past and still have now is how to understand projective space RP^n - I just can't ... | 2010/03/17 | [
"https://mathoverflow.net/questions/18522",
"https://mathoverflow.net",
"https://mathoverflow.net/users/1256/"
] | You can "visualize" the cell structure on $\mathbb{R}P^n$ rather explicitly as follows. The set of tuples $(x\_0, ... x\_n) \in \mathbb{R}^{n+1}$, not all equal to zero, under the equivalence relation where we identify two tuples that differ by multiplication by a nonzero real number, can be broken up into pieces depen... | A Point in $RP^n$ corresponds to a pair of antipodal points on $S^n$ - so just practice visualizing two antipodal points on a sphere every time you say Point. Such an approach is clearly equivalent to other definitions, but I find it good for "seeing." The standard cell structure is then defined by a Point being in the... |
50,739,802 | I am trying to extend an open source automation testing framework which uses ExtJS.
I am new to ExtJS and have tried to play around around with its views.
Now I wish to use grid grouping in such a way that when I click on an icon on the group header, it should append all the data of its children in an array and fire ... | 2018/06/07 | [
"https://Stackoverflow.com/questions/50739802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8186671/"
] | ```
someOperation(me.flatMap(_.secondName))
```
See [ScalaDoc](https://www.scala-lang.org/api/2.12.6/scala/Option.html#flatMap[B](f:A=%3EOption[B]):Option[B]).
You can use `map` for non-`Option` properties: `me.map(_.age)` is `Option[Int]`. | As I understood, you need to extract person fields and pass it into the method someOperation. Right?
If so, you can use pattern matching for this:
```
someOperation(
me match {
case Some(person) => person.firstName
case None => None
}
)
``` |
45,092,274 | I'm fairly new to C, and today I was introduced to Valgrind. I installed it and ran it on my C calculator/equation parser that I'm working on to figure out why I was having a segmentation fault (core dumped), and I got this:
```
==20== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==20==... | 2017/07/13 | [
"https://Stackoverflow.com/questions/45092274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8218230/"
] | This is a stack trace from deep within the Linux loader. Valgrind creates a sandbox execution environment and loads your program into that, where its various tools can insert their own instrumentation code into your instruction stream.
This is exotic stuff: very dependent a good valgrind build and care in building you... | When I run your program I get a complaint from gdb about line 8 (my cut and paste wont work)
It seems like there is somehting serioulsy wrong with your toolchain
Can you even write and run a hello world program?
```
#include <stdio.h>
int main()
{
printf("hello world\n");
}
``` |
1,474,688 | If I have a bunch of elements like:
```
<p>A paragraph <ul><li>Item 1</li><li>Apple</li><li>Orange</li></ul></p>
```
Is there a built-in method in Nokogiri that would get me all `p` elements that contain the text "Apple"? (The example element above would match, for instance). | 2009/09/24 | [
"https://Stackoverflow.com/questions/1474688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/178779/"
] | Here is an XPath that works:
```
require 'nokogiri'
doc = Nokogiri::HTML(DATA)
p doc.xpath('//li[contains(text(), "Apple")]')
__END__
<p>A paragraph <ul><li>Item 1</li><li>Apple</li><li>Orange</li></ul></p>
``` | You can also do this very easily with [Nikkou](https://github.com/tombenner/nikkou):
```rb
doc.search('p').text_includes('bar')
``` |
34,147,508 | I want to use CSS variables in a Bootstrap theme so I can conveniently change the theme's color scheme in the future.
[This chart shows that Firefox is the only browser at the moment that supports CSS variables](http://caniuse.com/#feat=css-variables).
Question
--------
>
> **How do I use Polymer's Polyfills to shi... | 2015/12/08 | [
"https://Stackoverflow.com/questions/34147508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1640892/"
] | Try to use this (better when you link CSS via a CDN): <https://poly-style.appspot.com/demo/> or this is probably better in your case: <https://github.com/MaKleSoft/gulp-style-modules> | [I found this demo in the github repository for Polystyles](https://github.com/PolymerLabs/polystyles/blob/master/demo/elements.html).
<https://github.com/PolymerLabs/polystyles/blob/master/demo/elements.html>
It uses the following import, which suggests the `url` parameter should link to a `.css` file.
```
<link re... |
48,126,230 | I have qwebengine that i have overwritten its context menu with a custom pop up menu and i am need to add menu item that when i right click a url it gives me the option to open in new tab, how i can achieve this? I have no idea how to do it so i have no code to show and there isn't enough topics out there but in qt sim... | 2018/01/06 | [
"https://Stackoverflow.com/questions/48126230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9084265/"
] | Please modify button tag
```
<button type="submit" name="submit" id="feedbackSubmit" class="btn btn-primary btn-lg" style=" margin-top: 10px;"> Verstuur</button>
``` | Use name = submit in button tag.
```
<button type="submit" name="submit" id="feedbackSubmit" class="btn btn-primary btn-lg" style=" margin-top: 10px;"> Verstuur</button>
```
After that also check your spam folder. Sometime you don't get messages in inbox. |
58,018,923 | Write a recursive function named get\_first\_capital(word) that takes a string as a parameter and returns the first capital letter that exists in a string using recursion. This function has to be recursive; you are not allowed to use loops to solve this problem.
```
def get_first_capital(word):
if word[0].isupper(... | 2019/09/19 | [
"https://Stackoverflow.com/questions/58018923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10379890/"
] | I am not really sure what your trying to achieve here.
But i would suggest using a class that will allow you to have better control over your variables.
```
class Game:
def __init__(self):
self.hp = 100
def takeInput(self):
self.current = input()
self.computeScore()
def computeScore(self):
... | Not sure what you want to achieve. If it keeps that simple you could also go in the following direction...
```
def test1(hp):
test = input("yes no")
stop_msg = None
if test == "yes":
print("not ok")
hp -= 25
elif test == "no":
print("ok")
stop_msg = "dead end"
else:
... |
11,171,060 | I have a web application that I am trying to make more efficient by reducing the number of database queries that it runs. I am inclined to implement some type of Comet style solution but my lack of experience in this department makes me wonder if a more simple solution exists.
For the sake of brevity, let's just say t... | 2012/06/23 | [
"https://Stackoverflow.com/questions/11171060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42388/"
] | To enumerate the words in a string, you should use `-[NSString enumerateSubstringsInRange:options:usingBlock:]` with `NSStringEnumerationByWords` and `NSStringEnumerationLocalized`. All of the other methods listed use a means of identifying words which may not be locale-appropriate or correspond to the system definitio... | If you could write your criteria with regular expressions, then you could probably do a regular expression matching to fetch these words and then pass them to your `convert:` method.
You could also do a split of string into an array of words using `componentsSeparatedByString:` or `componentsSeparatedByCharactersInSet... |
1,745,570 | I recently noticed that I couldn't write files (or delete files) to any external usb storage using my PC.
Here is what happens when I try to create a new folder.


I... | 2022/10/03 | [
"https://superuser.com/questions/1745570",
"https://superuser.com",
"https://superuser.com/users/1735529/"
] | I finally found the fix for this issue! I should have done this the first time I was looking into it but it makes sense why I didn't.
---
It was a local group policy all along. Specifically this setting, Computer Configuration > Administrative Templates > System > Removable Storage Devices > Removable Disks: Deny wri... | You have done almost everything conceivable for solving the problem.
The problem is probably in Windows, not in hardware, so I suggest doing
these checks (in order of gravity):
* Check for drivers on the manufacturer's website that might be
connected: USB controller, chipset and motherboard.
Check also for a BIOS upd... |
2,603,190 | Anyone have any idea why shuffle() would only return 1 item?
when using:
```
$array2 = shuffle($array1);
```
with the following array($array1):
```
Array
(
[0] => 1
[1] => 5
[2] => 6
[3] => 7
[4] => 8
[5] => 10
[6] => 11
[7] => 12
[8] => 13
[9] => 14
)
```
The output of:
... | 2010/04/08 | [
"https://Stackoverflow.com/questions/2603190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/201255/"
] | shuffle changes the original array. So in your case the shuffled array is `$array1`.
`$array2` is simply a boolean value. The function returns true or false. | Please read a function description before use <http://php.net/shuffle>
it may work other than you expect. |
575,639 | Between German and English, there are quite equivalent words “Fahrer” / “driver” and “Passagier” / “passenger”.
But German has another word “Insasse” which is used for anyone inside a car or bus, that is driver, passengers, possibly the bus conductor if there is one.
Is there an English word for this at all? (Google ... | 2021/09/26 | [
"https://english.stackexchange.com/questions/575639",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/73713/"
] | In English, we would call those *occupants*:
>
> **occupant** *noun*
>
>
> **a person who is in a car, room, seat, place, or position:**
> *One of the occupants of the car was slightly injured.*
>
>
> Source: [Cambridge Dictionary —
> *occupy*](https://dictionary.cambridge.org/us/dictionary/english/occupant)
>... | Possibly [occupant](https://dictionary.cambridge.org/it/dizionario/inglese/occupant):
>
> a person who is in a car, room, seat, place, or position.
>
>
>
*In a terrific accident all four occupants were killed.* |
347,595 | If $z$ is an integer, the sum of the series
$$\sum\_{k=1}^\infty \left(\frac{1}{k}-\frac{1}{k+z}\right)$$ is easy since it is a telescoping series. But if $z$ is a fraction, say $z=3/2$, I don't see why the series sums to $$\frac{8}{3}-\ln 4$$
Is there a formula for $z=m/n$, where $m,n$ are positive integers and $n\ne... | 2013/03/31 | [
"https://math.stackexchange.com/questions/347595",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/3249/"
] | To complete Marvis' (and now Mhenni's) answer let's notice that your series is, up to the Euler $\gamma$ constant ($0.577215\cdots$), the [digamma $\psi$ function](http://en.wikipedia.org/wiki/Digamma_function#Recurrence_formula_and_characterization) i.e.
$$\psi(z+1)+\gamma=\sum\_{k=1}^\infty \left(\frac{1}{k}-\frac{1... | Recalling the identity of the [$\psi$ function](http://en.wikipedia.org/wiki/Digamma_function)
$$ \psi(z)=-\gamma+\sum\_{n=0}^{\infty}\left(\frac{1}{n+1}-\frac{1}{n+z}\right)\qquad z\neq0,-1,-2,-3,\ldots, $$
your series can be readily expressed in terms of the $\psi$ function
$$ \sum\_{k=1}^\infty \left(\frac{1}{k}-... |
49,109,243 | My website works perfect on `localhost` but when moved to live server which is `Ubuntu 16.04 LTS` I got this error
>
> [Mon Mar 05 11:11:28.968821 2018] [:error] [pid 19322] [client 156.212.75.255:61635] PHP Parse error: syntax error, unexpected '?', expecting variable (T\_VARIABLE) in XXXXXXXXXX/vendor/symfony/finde... | 2018/03/05 | [
"https://Stackoverflow.com/questions/49109243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2825410/"
] | If you look at the source [code](https://github.com/symfony/finder/blob/master/Comparator/NumberComparator.php#L42).
```
/**
* @param string|int $test A comparison string or an integer
*
* @throws \InvalidArgumentException If the test is not understood
*/
public function __construct(?string $test)
{
```
The `?s... | Check your php version, it's very likely that's it:
For ubuntu family:
```
> a2dismod php5.6 #current version
> a2enmod php7.1 #required version ( 7.0, 7.1, 7.2 )
> service apache2 restart
``` |
6,276 | In a previous [question](https://aviation.stackexchange.com/questions/786/is-it-even-remotely-feasible-to-turnback-a-single-engine-aircraft-with-an-engine) the case about if a turnback would be feasible, specifically for a single engine aircraft, has been analysed.
But given a *twin-engine* general aviation aircraft a... | 2014/06/11 | [
"https://aviation.stackexchange.com/questions/6276",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/1467/"
] | What you really should learn by heart is the flight speed for best climb with one engine inoperative. Try to trim that immediately and you will win more time to make a decision. The rest is really depending on circumstances: Is there a landing opportunity ahead? Are you high enough to do a 180 and land on the same runw... | You are more likely to kill yourself in a stall/spin trying to turn back than you are from a forced landing straight ahead.
Since the altitude required to make a successful 180 turn is quite considerable the chances are if you are high enough you will be too far from the runway to make it back.
I remember seeing an ... |
375,484 | I have a button which is a quick action and I am calling a LWC and the logic is handled in the invoke method. Below is the LWC structure.
```
@wire(getRecord)
.
.
@wire(getRelatedListRecords)
.
.
@api invoke(){
..
}
```
I want to call @wire(getRelatedListRecords) in the invoke method or I want to reload the LWC comp... | 2022/05/06 | [
"https://salesforce.stackexchange.com/questions/375484",
"https://salesforce.stackexchange.com",
"https://salesforce.stackexchange.com/users/82367/"
] | Data fetched from Wire Callouts are stored in browser cache. If you want to refresh the cached data please use `refreshApex()`.
```js
import { refreshApex } from '@salesforce/apex';
@wire(getRecord)
theRecord;
wiredValues;
@wire(getValues)
theValues(value) {
this.wiredValues = value;
}
handlerMethod(){
refres... | Wire methods are called automatically and cannot be called directly. Simply accessing the data in the invoke method should already have the data you want to access. |
63,786,136 | So I have been trying to locate the username input box on python using selenium. I have tried xpath, id, class name, etc.
I am also aware of explicit wait for the elements to load. However, depite all this, no luck. I checked to see if the element is in an iframe that I overlooked, but I couldn't find it.
Here is the... | 2020/09/08 | [
"https://Stackoverflow.com/questions/63786136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14238455/"
] | Try to place the modal outside the mypost map, maybe this is why the modal won't show up. You may need another state for the src path of the selected image.
```
import { Modal } from "antd";
function Profile() {
const [visible, setVisible] = useState(false);
const [selectedImgSrc, setSelectedImgSrc] = useState(""... | it seems like the problem is here in your code.
```html
<Modal
title="Basic Modal"
visible={visible}
onOk={setVisible(false)}
onCancel={setVisible(false)}
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Modal>
```
```
onOk={setVisible(false)}
onCancel={set... |
200,922 | I have a Bad-Elf Surveyor unit which claims accuracy ~1m when post-processed, but I am at a loss to find software that can differentially correct the raw NMEA/UBX logs that the unit will record. I checked the bad-elf site to see if they had a list of apps that could do it, but couldn't find anything.
Anyone know what... | 2016/07/04 | [
"https://gis.stackexchange.com/questions/200922",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/25644/"
] | If you can convert them to rinex format you can use the online Precise Point Positioning (PPP) service provided by the Canadian Geodetic Survey. You can find out more at <http://www.nrcan.gc.ca/earth-sciences/geomatics/geodetic-reference-systems/tools-applications/10925#ppp>, or google NRCAN and PPP
It's a great servi... | Once you have used the raw data logger to output a RINEX file, you can use the [RTKLib](http://www.rtklib.com/) to post-process your data using either
* a) DGPS, using RINEX data from a known base station (CACS in Canada or CORS in the
US) or
* b) [PPP](https://gis.stackexchange.com/questions/112718/how-is-precise-po... |
104,526 | I am not a dba. I have general knowledge of SQL Server and T-SQL. Our company currently has a SQL Server 2008 R2 hosting about 30 databases.
I've been asked to research adding a second server for HA/Failover. My question is, should I be considering upgrading the current server to at least 2012, and build the new serve... | 2015/06/19 | [
"https://dba.stackexchange.com/questions/104526",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/68862/"
] | Given the sample data:
```
CREATE TABLE dbo.Data
(
ID integer PRIMARY KEY,
A0 character(1) NULL,
A1 character(1) NULL,
A2 character(1) NULL,
A3 character(1) NULL,
A4 character(1) NULL
);
INSERT dbo.Data
(ID, A0, A1, A2, A3, A4)
VALUES
(14, 'A', 'B', 'A', 'C', 'A'),
(15, 'A', 'A', '... | Another example using cross apply. The idea is to transpose a0, a1, ..., to rows and then check where max and min equals:
```
select d.id
from dbo.data as d
cross apply ( values (d.a0),(d.a1),(d.a2),(d.a3),(d.a4) ) as x(a)
group by d.id
having min(a) = max(a);
``` |
12,732,664 | I have the following function:
```
function array_duplicates($array)
{
$duplicates = array();
$unique = array_unique($array);
for ($i = 0; $i < count($array); $i++) {
if (!array_key_exists($i, $unique)) {
$duplicates[] = $array[$i];
}
}
return $duplicates;
}
```
... | 2012/10/04 | [
"https://Stackoverflow.com/questions/12732664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/199712/"
] | This might be the type of thing you'd put into a service. Create a class like this:
```
class ArrayUtils
{
function array_duplicates($array)
{
...
return $duplicates;
}
}
```
And then define it as a service. If you're using YAML, you'd put something like this into your config.yml file:
... | By convention, utility classes go under the `Util` namespace.
If you use bundles, a class would go into the `YourBundle\Util` namespace. If you [don't](https://stackoverflow.com/questions/9999433/should-everything-really-be-a-bundle-in-symfony-2), it would go into the `Acme\Util` namespace — the `src/Acme/Util` folder... |
7,887 | WP 3.0.4
local installation, multisite network enabled
theme: Twentyten
plugin: [List Category Posts](http://wordpress.org/extend/plugins/list-category-posts/) v .15, network activated
I've created the folder `list-category-posts` inside my theme folder, and placed `default.php` inside it. Edited `default.php... | 2011/01/27 | [
"https://wordpress.stackexchange.com/questions/7887",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Hey you just opened the plugin's tag on WordPress Answers :D
Can you paste the code of the generated html? From what you describe, you are using it correctly, so I just want to see if the template is being loaded to detect if the problem is on the template side, or a bug on the plugin's code.
**UPDATE**: Ok, I checke... | Shortcode: [catlist template=lcp\_template\_1 id=9 orderby=date numberposts=1 date=yes author=yes excerpt=yes catlink=yes thumbnail=yes ]
In the plugin folder > list\_cat\_posts.php, these are the instances for 'thumbnail':
>
> File list\_cat\_posts.php; line 56:
> 'thumbnail' => 'no',
>
>
> File list\_cat\_posts... |
4,278,701 | Consider the polynomial $F(t)= 2021t^7+6t^6+2017t^5-2t^4-t^3+2t^2-t+5$ , this is irreducible in $\mathbb{Q}[t]$ because it's irreducible in $\mathbb{F}\_2[t]$ (it has no factors of degree 1,2 or 3) , so now we consider one of its complex roots $α$ . We obviously have $\mathbb{Q}(α^3) \subset \mathbb{Q}(α)$ , but for th... | 2021/10/16 | [
"https://math.stackexchange.com/questions/4278701",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/740138/"
] | The series *[Math Girls](https://rads.stackoverflow.com/amzn/click/com/0983951306)* by Hiroshi Yuki is both amusing and instructive. We explore together with at first two later three female students some highlights in mathematics like Fermat's last theorem or Gödel's incompleteness theorems.
Currently there are four v... | The popular mathematics book [*Dialogues on Mathematics*](https://rads.stackoverflow.com/amzn/click/com/B0006BQH6Y) (original title: *Dialoge über Mathematik*) by Alfréd Rényi is a set of fictional dialogues about the *nature* of mathematics between some historical characters (Socrates and Hippocratis in the first chap... |
25,420,191 | I’m writing an application which checks whether a (ublox) GPS module is installed in a machhine and if so it reads out the data via the serial interface. I do not know on which port, the module is working, so the program checks all COM ports for incoming signals at 4800 and 9600 baud.
The Ublox GPS module actually ada... | 2014/08/21 | [
"https://Stackoverflow.com/questions/25420191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/613155/"
] | You can use `text-right` first you have to wrap it in a `div` like this:
```
<div class="text-right">
<button class="btn-info btn">Log in</button>
</div>
```
[LIVE-DEMO](http://jsfiddle.net/8x4fmcq9/)
==========================================
Here is the full code
```
<div role="form">
<div class="form-g... | If you are inside a container with rows and columns in Bootstrap4, all the floats don't work properly.
Instead you have to add a spacer column to get things to align.
```html
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/... |
29,361 | What can you do when your child comes back from school with tears in her eyes or her heart because of an **incompetent teacher**? Three examples to illustrate:
* she told her class that humans can hear radio waves. Without a radio!
She teaches physics in high school.
* On another occasion she said that if the moon wa... | 2017/03/15 | [
"https://parenting.stackexchange.com/questions/29361",
"https://parenting.stackexchange.com",
"https://parenting.stackexchange.com/users/22362/"
] | Teach your kid on how to deal with incompetent superiors. In a manner which is acceptable to the other side, of course.
Unfortunately, this is not really easy to learn for young people - especially not if they are very intelligent. A child will be able to play the role of the attentive student who admires the teacher,... | **Many thanks to all of you**, I appreciate the time you took to answer. At the beginning, as noted A.I. Breveleri, my question did not show evidence of this teacher's incompetence. My mistake. I edited the original text to explain more about it. I first gave the impression that it was a question of physics, but it was... |
3,279,373 | In Spivak's *Calculus* (4th edition), Chapter 13, problem 15, the author asks to prove:
>
> For $a,b>1$ prove that:
> $$\int\_1^a\frac 1tdt+\int\_1^b\frac1tdt=\int\_1^{ab}\frac1tdt$$
> The result is used in some problems in the following chapter, but I can't find in it's proof why $a,b$ must greater than 1, and t... | 2019/07/01 | [
"https://math.stackexchange.com/questions/3279373",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/401653/"
] | If I recall correctly, in chapter 13, Spivak only defined $\int\_a^b f$ for $a < b$. So the upper limit is greater than the lower limit. It is only in chapter 14 that he defines the integral $\int\_a^bf$ when $b\leq a$. I think this is why he imposes the condition $a,b > 1$ in your question. After defining things appro... | This is the fact $\ln ab=\ln a+\ln b$. This is true for any $a,b\gt0$. |
35,678 | I want to hang something like <http://www.skychairs.com/> or similar in my living room. If the joists were exposed I would mount a beam between two of them and hang over or through that. However, when the joists are hidden behind drywall or sheetrock or other ceiling material this doesn't seem to be an option. Putting ... | 2013/11/12 | [
"https://diy.stackexchange.com/questions/35678",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/999/"
] | Just because you can't see the joists doesn't mean you cannot use your beam approach for exposed rafters. The structure is essentially the same, except for a thin layer of sheetrock between the two, which has little impact on the forces involved. The best thing to do is distribute any concentrated load over multiple co... | Drywall is a repairable material. When needed, be prepared to rip it open, do what you need to do, and patch it afterwards. If you are not **absolutely sure** how the ceiling is built, you can be lead astray following lines of nails/screws in drywall, if the ceiling was strapped with 1 x 3 running crossways to the jois... |
4,186,744 | Let's say a have the following code:
```
<nav id="main-navigation">
<ul>
<li><a href="#">Link 1 Level 1</a></li>
<li><a href="#">Link 1 Level 1</a></li>
<ul>
<li><a href="#">Link 1 Level 2</a>
</ul>
</ul>
</nav>
```
And now I want to to set first `ul`'s height to ... | 2010/11/15 | [
"https://Stackoverflow.com/questions/4186744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/443957/"
] | To select direct children of an element, and not any descendant, you should use the `>` syntax. In your case (after you put the second `ul` inside a `li`) you need:
```
nav > ul {
height: 100px;
}
nav > ul > li > ul {
height: 300px;
}
```
~~*Extra: It doesn't really make sense to have a 300px item inside ... | Firstly, how imporant is browser compatibility to you? All of those selectors you mentioned have issues in various versions of IE (IE8 is obviously better than IE7, but even IE8 is missing a lot of CSS selectors)
Simple nested selectors (ie just a space between the CSS names) will work for you - although as you say, s... |
45,824,504 | Trying to understand, but I am not able to get the perfect answer.
```
#include<iostream>
using namespace std;
int main(){
unsigned char ch = '150';
int count=0;//just to get a count for the loop
cout << (int)ch<<endl;
for (int i = 0; i <= ch * 2; i++){
cout << "Hello" << endl;
count+... | 2017/08/22 | [
"https://Stackoverflow.com/questions/45824504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8380523/"
] | There are some ways to declare `unsigned char` character literals:
```
unsigned char ch1 = 150;
unsigned char ch2 = 0x96;
unsigned char ch3 = '\150';
unsigned char ch4 = '\x96';
unsigned char ch5 = '\0226';
unsigned char ch6 = 0226;
unsigned char ch7 = 0b10010110;
```
Choose the one which is most readable in your ap... | There's a great difference between:
```
unsigned char ch = '150'; // wrong way
unsigned char ch = 150; // correct way (conversion from integer to char according to ASCII standard)
```
As you can see i the first line as long as ch is of type char and you assign it a string (multi-char constant). Here no conversion ... |
65,155,356 | i want to search data based nama\_kegiatan or tanggal\_kegiatan where these two name form my table field, this code from my controller :
```
public function search(Request $request){
$cari = $request->search;
$caritanggal = date($request->datekeg);
$infokeg = Infokeg::where(function ($query) use ($cari) {
$query->... | 2020/12/05 | [
"https://Stackoverflow.com/questions/65155356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10485539/"
] | Maybe you can try to get() all the result after the query? Somethings like
```
$infokeg = Infokeg::where('name_kegiatan','LIKE','%'.$cari.'%')->orWhere('tanggal_kegiatan',$caritanggal)->get();
```
IMO the get() and paginate() cannot be use at the same time if I have not get it wrong. If you need to paginate after al... | If you want to see what is run in the database use dd(DB::getQueryLog()) after query to see what queries exactly were run.
```
$infokeg = Infokeg::where('nama_kegiatan','like', "%" . $cari ."%")
->orWhere(function($query) use ($caritanggal) {
$query->where('tanggal_kegiatan', $caritanggal);
... |
1,750,671 | This is the common structure of all of my classes:
```
public class User
{
public int ID { get;set; }
public string User_name { get; set; }
public string Pass_word { get; set; }
public string UserTypeCode { get; set; }
public int SaveOrUpdate()
{
int id = -1;
if (this._ID <=0)... | 2009/11/17 | [
"https://Stackoverflow.com/questions/1750671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/159072/"
] | ObjectDataSources look for methods within the type specified that match the signature of the update/insert method name and the update/insert parameters provided.
Your `SaveOrUpdate` method is on an instantiated class, and the ObjectDataSource will not find a matching method signature.
From what you have, if you must ... | I am not quite sure, but you can try to mark this class with [DataObjectAttribute](http://msdn.microsoft.com/en-us/library/system.componentmodel.dataobjectattribute.aspx) and CRUD methods with [DataObjectMethodAttribute](http://msdn.microsoft.com/en-us/library/system.componentmodel.dataobjectmethodattribute.aspx). I di... |
8,235,852 | I am trying in an iPhone app to set the possibility for the user to choose the fonts.
I have already made progress using the UIFont class. Here is my question :
When the choice of a Font within a Font Family is made how to I know the possibilities the user has for the size? Is there a way to list them? I did not see a... | 2011/11/23 | [
"https://Stackoverflow.com/questions/8235852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/611201/"
] | These two functions do exactly the same thing.
`Keys.Contains` exists because `Keys` is an `ICollection<TKey>`, which defines a `Contains` method.
The standard `Dictionary<TKey, TValue>.KeyCollection` implementation (the class, not the interface) defines it as
```
bool ICollection<TKey>.Contains(TKey item){
r... | Although they are pretty much equivalent for `Dictionary<,>`, I find it's much safer to stick with `ContainsKey()`.
The reason is that in the future you may decide to use `ConcurrentDictionary<,>` (to make your code thread-safe), and in that implementation, `ContainsKey` is significantly faster (since accessing the `K... |
33,538,637 | I have a `Series` as following:
```
In [37]: ser
Out[37]:
Aa 0
Ab 1
Ac 2
Ba 3
Bb 4
Bc 5
Ca 6
Cb 7
Cc 8
dtype: int3
```
I want to rearrange it to a `DataFrame` as:
```
a b c
A 0 1 2
B 3 4 5
C 6 7 8
```
Here is what I had try with no luck:
```
In [38]: ser.groupby(lambda ... | 2015/11/05 | [
"https://Stackoverflow.com/questions/33538637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172677/"
] | Here you go:
```
ser.groupby(lambda i: i[0]).apply(lambda x: x.rename({i: i[1] for i in x.index})).unstack()
```
You were close! | ```
In [235]:
df = pd.DataFrame(data = { 'key' : ser.index.values , 'value' :ser.values })
df
Out[235]:
key value
0 Aa 0
1 Ab 1
2 Ac 2
3 Ba 3
4 Bb 4
5 Bc 5
6 Ca 6
7 Cb 7
8 Cc 8
In [251]:
df['key_1'] = df.key.str.extract('(^\w)')
df
Out[251]:
key value key_1
0 Aa 0 A ... |
32,530,952 | I am receiving a message using the [Go NSQ library](http://github.com/bitly/go-nsq) where a field is a slice of `map[string]string`'s. I feel like I should be able to type assert this field as `value.([]map[string]string)` but it's failing and I can't tell if this is expected or not.
This snippet replicates the behavi... | 2015/09/11 | [
"https://Stackoverflow.com/questions/32530952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/210547/"
] | The conversion referred to doesn't work as described in Jim's answer. However, if you actually have the type you claim, and the interface you state it implements is just `interface{}` then the type assertion works fine. I don't want to speculate on the details of why the other doesn't work but I believe it's because yo... | you can do it by reflect in 2022
```golang
res := `[
{
"name": "jhon",
"age": 35
},
{
"name": "wang",
"age": 30
}
]`
// res := `{
// "name": "jhon",
// "age": 35
// }`
var rst any
err := json.Unmarshal([]byte(res), &rst)
if err != nil {
pa... |
5,026,805 | I'm experiencing validation errors in the checkout and user registration workflows of my Magento (version 1.4.2) install.
Example: During checkout, I get a "Customer email is required" error even if the field is correctly filled out. In the registration process, I get the error "Field xx must be greater or equal to a ... | 2011/02/17 | [
"https://Stackoverflow.com/questions/5026805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/100382/"
] | comment out the line in the specific phtml files inside the tags that looks like:
```
var dataForm = new VarienForm('name-of-form');
```
Otherwise, comment out the line in page.xml with:
```
<action method="addJs"><script>prototype/validation.js</script></action>
```
**EDIT**
open `DOCROOT\js\prototype\validat... | If you want to disable the validation for a certain form field, you will have to remove the validation class of the input tag. The input tags are looking like this:
```
<input type="text" name="email" class="input-text validate-email required-entry" />
```
Just remove the "validate-email" part from the class attribu... |
5,542,412 | I've read a lot about openid in recent few days and found out it's not as easy on a standard web space.
I've only follow available in the web space:
* CGI Exec
* PHP 5 (cURL Similar)
* Apache 2
* IM, GD, FTP ect.
* No openid setup.
* No options to install apps.
Is it possible to setup openid or which one? | 2011/04/04 | [
"https://Stackoverflow.com/questions/5542412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/678611/"
] | The emulator on its own doesn't provide any "fake GPS" support, but there are a few emulator tricks around to allow you to fake GPS data:
e.g.
* <http://phone7.wordpress.com/2010/08/19/gps-sim-update-generic-model-and-dll/> - see <http://phone7.wordpress.com/2010/08/02/no-device-no-gps-no-matter-with-code/> for pictu... | Above codeplex link have fake.cs file that is not working at all. and other link u folks are provided are expired.
If there is any good solution to **simulate fake gps** or **find current location** on emulator then post any sample App please |
47,939,166 | I have a singleton instance defined like this:
```
public class Singleton {
private static Singleton INSTANCE = new Singleton();
private Singleton() {
}
public Singleton getInstance() {
return INSTANCE;
}
}
```
Now, due to some changes, this class has to depend on a few(3) dependencies... | 2017/12/22 | [
"https://Stackoverflow.com/questions/47939166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4405757/"
] | You could refactor your class as a dependency while keeping the same API for clients.
With Spring for example :
```
@Component
public class Singleton {
private Foo foo;
private Bar bar;
private Any any;
// inject dependencies
@Autowired
// annotation not required in recent Spring versions
public Si... | If you are using Spring you can achieve dependency injection even without a public constructor. Just mark the dependencies @Autowired. Spring will inject them via reflection. :) |
52,643,734 | I have an HTML video player that runs random videos. I have the following function that tests if the video is marked completed based on the video seen percentage. VideoCompletionPercentage is a global variable that is set by reading it from the database. I have to test for two conditions as follows:
1. verify video is... | 2018/10/04 | [
"https://Stackoverflow.com/questions/52643734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9810043/"
] | you could just use operateur "?"
```
do
{
:
:
}while (videoSeenPercentage < (skip ? VideoCompletionPercentage : 100));
``` | ```
private void VideoPecentageCompletion(bool skip)
{
double videoSeenPercentage;
double percentage;
do
{
TryGetAttributeValue("aria-valuemax", out double totalVideo);
TryGetAttributeValue("aria-valuenow", out double videoProgress);
videoSeenPercentage = Math.Floor(videoProgres... |
46,581,564 | I wanted to make a shell script that accepts a vowel and prints the number of occurrences of that vowel inside the text file "abc.txt".
The following script works perfectly (a script to print the number of occurrences of the vowel "a" inside the text file "abc.txt"):
```
#!/bin/bash
grep -o [aA] abc.txt|wc -l
```
B... | 2017/10/05 | [
"https://Stackoverflow.com/questions/46581564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7337777/"
] | Multiple issues, but the one mostly causing your problem is not using a variable in the `case` construct. Use `ch` is just a constant and does not match any of the expressions below.
```
case "$ch" in
# ^^^^^ This needs to be a variable used in read command
```
Also, to store the output of a command, you need to ... | Your problem is not the case statement, but that you're using the variable assignment in a wrong way
```
x=grep -o [aA] abc.txt|wc -l;echo $x
```
you're assigning `grep` to the variable x for running `-o [aA] abc.txt`, as `var=something command` assigns the variable just for running `command`.
This of course doesn'... |
41,161,006 | I am trying to read some logs from a Hadoop process that I run in AWS. The logs are stored in an S3 folder and have the following path.
bucketname = name
key = y/z/stderr.gz
Here Y is the cluster id and z is a folder name. Both of these act as folders(objects) in AWS. So the full path is like x/y/z/stderr.gz.
Now I w... | 2016/12/15 | [
"https://Stackoverflow.com/questions/41161006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2358427/"
] | You can use AWS S3 **SELECT Object Content** to read gzip contents
S3 Select is an Amazon S3 capability designed to pull out only the data you need from an object, which can dramatically improve the performance and reduce the cost of applications that need to access data in S3.
Amazon S3 Select works on objects store... | Just like what we do with variables, data can be kept as bytes in an in-memory buffer when we use the io module’s Byte IO operations.
Here is a sample program to demonstrate this:
```
mport io
stream_str = io.BytesIO(b"JournalDev Python: \x00\x01")
print(stream_str.getvalue())
```
The `getvalue()` function takes t... |
22,374,882 | I am new to Javascript, and i run into some big problems. I got some functions, which I can type into a text field and press enter, and the functions works. But i have created 4 buttons, which i want to connect to the actions.. i got 4 actions: "UP","DOWN","LEFT" and "RIGHT".
This is the js fiddle over my code: <http:... | 2014/03/13 | [
"https://Stackoverflow.com/questions/22374882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3414678/"
] | Instead of using inline handlers (bad practice) or multiple handlers for each button, I would use event delegation on your button wrapper, like so
```
$('#gamebuttons').on('click', 'button', function() {
/* get the id attribute of the clicked button */
var button_id = this.id;
case (button_id) {
... | Please pass the function name inside the OnClick tag
for example if you want to associate **playGame** function to DOWN button
write
```
<button id="down" onclick="playGame();">DOWN</button>
``` |
52,507,482 | I need to know how to hide the bottom label.
I've tried the following:
>
> tabBarShowLabels: 'hidden', tabbarlabelvisible: false.
>
>
>
I also removed the `tabbarlabel: 'Home'` and it still shows
Any help would be appreciated or if someone could point me to the right direction.
[![enter image description here]... | 2018/09/25 | [
"https://Stackoverflow.com/questions/52507482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10364763/"
] | You have to define `showLabel: false` as the [docs](https://reactnavigation.org/docs/bottom-tab-navigator/#showlabel) says, just as
```
const Tabs = createBottomTabNavigator ({
Home:{
screen: Home,
navigationOptions:{
tabBarIcon: ({ focused, tintcolor }) => (
<Icon name="ios-home" size={24} />... | On the new versions of React Navigation, you just need to pass `showLabel` prop as `false`
```
<Tab.Navigator tabBarOptions={{ showLabel: false }}>
``` |
3,397,873 | I would like to be able to pull back 15 or so records from a database. I've seen that using `WHERE id = rand()` can cause performance issues as my database gets larger. All solutions I've seen are geared towards selecting a single random record. I would like to get multiples.
Does anyone know of an efficient way to do... | 2010/08/03 | [
"https://Stackoverflow.com/questions/3397873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/153110/"
] | >
> **Update**: Check out the accepted answer in [this question](https://stackoverflow.com/questions/1244555/how-can-i-optimize-mysqls-order-by-rand-function). It's pure mySQL and even deals with even distribution.
>
>
>
The problem with `id = rand()` or anything comparable in PHP is that you can't be sure whether... | You could do a query with all the results or however many limited, then use mysqli\_fetch\_all followed by:
```
shuffle($a);
$a = array_slice($a, 0, 15);
``` |
2,969,003 | I am hoping this question fares a little better than the similar [Create a table without columns](https://stackoverflow.com/questions/2438321/create-a-table-without-columns). Yes, I am asking about something that will strike most as pointlessly academic.
It is easy to produce a SELECT result with 0 rows (but with colu... | 2010/06/03 | [
"https://Stackoverflow.com/questions/2969003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/200993/"
] | No it's a SQL limitation. SQL has lots of warts, contradictions and asymmetries. It's unfortunately not mathematically precise or complete unlike the relational theory and algebra it was inspired by and meant to be used to work with. | If I remember correctly, `SELECT NULL FROM table_name;` is valid syntax, but I don't remember whether this counts as having zero columns or one column (containing NULL for each row). |
5,498,937 | My question is simple. When do we need to have a default constructor?
Please refer to the code below:
```
class Shape
{
int k;
public:
Shape(int n) : k(n) {}
~Shape() {}
};
class Rect : public Shape
{
int l;
public:
Rect(int n): l(n)
{} //error C2512: 'Shape' : no appropriate default c... | 2011/03/31 | [
"https://Stackoverflow.com/questions/5498937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/683589/"
] | Compiler generates default constructor in case when you have not define any constructor. But if you have defined any constructor that takes some argument or not. The compiler will use that constructor and will not generate default constructor with zero argument. | The default constructor is generated only if you have not defined any other constructors.
Supposedly, if you need some special initialization in the class, the default constructor would not do the right thing. |
36,214,999 | I've recently started using application insights with a web api.
It will be really helpful to configure app insights to post error messages in a slack channel.
I've seen there is a slack connector but I am not sure how to use it, my guess is that this can be solved with the slack connector and a azure logic app, any ... | 2016/03/25 | [
"https://Stackoverflow.com/questions/36214999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/261363/"
] | You may have a look at this link: <https://github.com/Azure/azure-quickstart-templates/tree/master/demos/alert-to-slack-with-logic-app>. I followed the instruction and it worked for me.
The tricky part is you need to click the "Deploy to Azure" button on this link page. It would redirect you to Azure Portal, and you w... | The most easiest path that I found to integrate was using an app named Slack Email which sends email alerts to slack. Once you subscribe this email id to alerts in Application Insights it will start sending the messages on the specific channel you have linked the email to.
<https://teamesub.slack.com/apps/A0F81496D-ema... |
23,834,624 | How to remove first and last character from std::string, I am already doing the following code.
But this code only removes the last character
```
m_VirtualHostName = m_VirtualHostName.erase(m_VirtualHostName.size() - 1)
```
How to remove the first character also? | 2014/05/23 | [
"https://Stackoverflow.com/questions/23834624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2623557/"
] | Well, you could [`erase()`](http://en.cppreference.com/w/cpp/string/basic_string/erase) the first character too (note that `erase()` modifies the string):
```
m_VirtualHostName.erase(0, 1);
m_VirtualHostName.erase(m_VirtualHostName.size() - 1);
```
But in this case, a simpler way is to take a substring:
```
m_Virtu... | My BASIC interpreter chops beginning and ending quotes with
```
str->pop_back();
str->erase(str->begin());
```
Of course, I *always* expect well-formed BASIC style strings, so I will abort with failed `assert` if not:
`assert(str->front() == '"' && str->back() == '"');`
Just my two cents. |
19,436,975 | Ok so I have a question relating to the output of the following code (which is 111222223)
```
#include <iostream>
struct C {
virtual int eq(const C& other) const { return 1; }
};
struct SC : C {
virtual int eq(const C& other) const { return 2; }
virtual int eq(const SC& other) const { return 3; }
};
void go(const ... | 2013/10/17 | [
"https://Stackoverflow.com/questions/19436975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1628702/"
] | First, the declared type of `CircuitData` should be a pointer:
```
ListNodeType* CircuitData;
```
To set the address stored in `CircuitData` (inside the ReadFile function) you would write
```
*CircuitData = newPtr;
```
This sets the data at the address `CircuitData` to the address stored in `newPtr`, which is wha... | Define CircuitData as (ListNodeType \*), and in function ReadFile, pass &CircuitData |
30,054,149 | Here it is... By the way, it is misaligned in jsFiddle. In my actual webpage it's aligned, so no worries there.
<http://jsfiddle.net/j8oawqL4/>
I tried using code inspired by [http://jsbin.com/umubad/2/](http://jsbin.com/umubad/2/edit?html,js,output) but I couldn't figure out how to successfully implement it.
HTML
... | 2015/05/05 | [
"https://Stackoverflow.com/questions/30054149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4725638/"
] | ```
$(document).click(function (event) {
alert(event.target.id);
if (event.target.id != 'category') {
$('.navbar li ul').slideToggle(300);
}
```
}) | What about ?
```
$("body").on("click", function(e){
if(!$(e.target).is(".navbar *")){
$('.navbar li ul').slideUp(100);
}
});
```
<http://jsfiddle.net/j8oawqL4/7/> |
39,757,948 | Hi there trying to create my first meteor project on my desktop. When I try initialize my project after creation by entering the directory and entering meteor get and error. I am working on windows 10. I tried uninstalling/installing & deleting the .meteor folder. I am on node 5.6.0 and meteors 1.4.1.1.
```
C:\Users\... | 2016/09/28 | [
"https://Stackoverflow.com/questions/39757948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6057000/"
] | the definitive solution is:
remove folder "http-proxy" under c:\users\username\node\_modules | Try to change directory to the root of your new project, then run meteor.
```
$ cd my/directory/root
$ meteor
``` |
16,019,401 | I'm not entirely sure when it happened, but attempting to run homebrew on my OSX Mountain Lion machine now yields a strange error:
`/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- checksums (LoadError)`
This was n... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16019401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1447303/"
] | You need to read the output:
>
> RVM autolibs is now configured with mode '2' => 'check and stop if missing',
> please run `rvm autolibs enable` to let RVM do its job or run and read `rvm autolibs [help]`
>
>
>
If you were following instructions from [rvm site installation instructions](https://rvm.io/rvm/instal... | Try:
```
rvm get head && rvm reload
```
to update your rvm install |
24,669,486 | **HTML**
```
<input type="text" value="" id="ip1" class="ip1" />
<input type="button" value="Add" class="bt1" id="bt1">
</br>
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</select>
```
**JQUERY**
```
$(document).ready(function(e) {
$(".bt1").click(function(){... | 2014/07/10 | [
"https://Stackoverflow.com/questions/24669486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3820063/"
] | you can do like this:
**HTML:**
```
<select id="List">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</select>
```
**JQUERY:**
```
$(".bt1").click(function(){
var opt = $("#ip1").val();
$('#List')
.append($("<o... | ```
$(document).ready(function (e) {
$(".bt1").click(function () {
var opt = $("#ip1").val();
$('select').append(' <option value="' + opt + '">' + opt + '</option>')
});
});
```
[DEMO](http://jsfiddle.net/J2QVN/1/) |
15,626,393 | Ok
It's simple. I just want to add 1 to a number every time trought the use of `+=` operator!
So i go in prompt just like this:
```
C:\Users\fsilveira>SET teste=000007
C:\Users\fsilveira>ECHO %teste%
000007
C:\Users\fsilveira>SET /A teste+=1
8
C:\Users\fsilveira>
```
Wow nice. Seems to be working just fine.
Fro... | 2013/03/25 | [
"https://Stackoverflow.com/questions/15626393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/521864/"
] | When prefixing with 0 it is intrepeated as an octal number. And 00008 is not a valid octal number. You can see the effect of this by the following:
```
C:\Users>SET teste=000020
C:\Users>ECHO %teste%
000020
C:\Users>SET /A teste+=1
17
```
where `00020` in octal is `16` in decimal. | You can avoid this by removing leadig zeros:
```
C:\>set teste=000008
C:\>echo %teste%
000008
C:\>for /f "tokens=1*delims=0" %i in ("$0%teste%") do @set teste=%j
C:\>set /a teste+=1
9
``` |
24,745,396 | I'm trying to run an SSIS package in Visual Studio 2012. When I click the "Start" button I get this very odd error in a popup from Visual Studio:
```
Method not found: 'Boolean
Microsoft.SqlServer.Dts.Design.VisualStudio2012Utils.IsVisualStudio2012ProInstalled()'.
(Microsoft.DataTransformationServices.VsIntegration)... | 2014/07/14 | [
"https://Stackoverflow.com/questions/24745396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65070/"
] | 1. Open the Developer Command Prompt for VS212 as Administrator
2. execute the command `cd "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies"`
3. execute the command `gacutil /if Microsoft.SqlServer.Dts.Design.dll`
4. restart Visual Studio
Source msdn [Fail to start project](http://soc... | The following is the command we have to use to resolve the issue:
>
> "C:\Program Files\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\gacutil.exe" /if "C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\Microsoft.SqlServer.Dts.Design.dll"
>
>
>
Make sure that your dll file and `Gacutil... |
42,548,714 | I'm trying to put json into recyclerview but it gives me the "unable to parse dara" error!
this is my json response :
>
> {"action":"true","error":"","data":[{"\_id":"58ad8d8ca49d0e11e21c4504","store\_name":"firstStore","store\_view":0,"store\_textposition":null}]}
>
>
>
And there is where i'm getting the error"... | 2017/03/02 | [
"https://Stackoverflow.com/questions/42548714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6354359/"
] | Your root element is a json object. Parse the object first then get the json array
```
try
{
JSONObject obj = new JSONObject(jsonData);
JSONArray ja = obj.getJsonArray("data");
JSONObject jo;
shops.clear();
for(int i=0;i<ja.length();i++)
//................
``` | Use below code to parse your json Response:
```
private void parse(String jsonData)
{
try
{
JSONObject jsonObject = new JSONObject(jsonData);
String action = jsonObject.optString("action");
String error = jsonObject.optString("error");
JSONArray dat... |
927,894 | I want to practice programming code for future hardware. What are these? The two main things that come to mind is 64bits and multicore. I also note that cache is important along and GPU have their own tech but right now i am not interested in any graphics programming.
What else should i know about?
-edit- i know a l... | 2009/05/29 | [
"https://Stackoverflow.com/questions/927894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | 64 bits and multicore are the present not the future.
About the future:
Quantum computing or something like that? | I agree with Oli's answere (+1) and would add that in addition to 64-bit environments, you look at multi-core environments. The industry is getting pretty close to the end of the cycle of improvements in raw speed. But we're seeing more and more multi-core CPUs. So parallel or concurrent programming -- which is rilly r... |
17,292,783 | Where I can find GPX files that I can import into my iOS Simulator?
The iOS Simulator only contains static locations around the world and walk / bike / car drive simulations.
This is not good enough for unit testing or other specific use cases.
This is the for GPX file: <http://www.topografix.com/GPX/1/1/gpx.xsd>
Ho... | 2013/06/25 | [
"https://Stackoverflow.com/questions/17292783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1317394/"
] | You can go to <https://github.com/doronkatz/GFXLocations> which is a github repository of some cities (for Australia). You can generate new ones and contribute back to that. | The ideal and fastest solution (with accuracy), is to:
1. Create a Path via Google Earth
2. Save the path to an .kml file (on your desktop)
3. Open the .kml and copy all the geolocation points (notably the long, lat, elvations)
4. Paste it in TextMate or similar
5. Use this RegEx Find & Replace:
Find: `(.*?),(.*?),0`... |
7,329,840 | I wrote a small code of C.
```
#include<stdio.h>
int main()
{
int a = 0;
printf("Hello World %llu is here %d\n",a, 1);
return 0;
}
```
It is printing the following ouput
>
> Hello World 4294967296 is here -1216225312
>
>
>
With the following warning on compilation
>
> prog.cpp: In function ‘int... | 2011/09/07 | [
"https://Stackoverflow.com/questions/7329840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/534087/"
] | The format you passed to `printf()` leads it to expect 12 bytes on the stack, but you only push 8 bytes. So, it reads 4 bytes you didn't push, and gives you unexpected output.
Make sure you pass what `printf()` expects, and heed your compiler's warnings. | According to given format, printf reads memory region 64 bit length, which contains a and 1 together, an prints 4294967296. Then it reads some junk from the next 32 bits and prints -1216225312. |
121,220 | I am presently writing an article about a certain class of discrete probability distributions, and I want to mention that the distribution is relatively obscure compared to other common distributions. As an indicator of its relative obscurity, I would like to mention the fact that this class of distributions does not h... | 2018/12/07 | [
"https://academia.stackexchange.com/questions/121220",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/87026/"
] | >
> What is the proper way to cite this evidence? Presumably I will be citing the fact that I have performed a search of Wikipedia at a certain time, and that I found pages for various common discrete distributions, but no page for the one that is the subject of my paper.
>
>
>
You can prove that a particular page... | I think you could really just handle it in article text itself. ("I searched" or "a search was done".) I would maybe mention a few details (date of the search, English Wikipedia, what different versions of the name you searched on). I don't think you have to go crazy about the details if it is just a minor point.
You... |
22,826,067 | I have read the MSDN but, I could not understand this concept.
Correct me if I am wrong,
>
> A innerexception will be used in hand with current exception.
>
>
>
Inner exception will occur first and then the current exception will occur (if there is an exception) that is the reason why `InnerException` is checke... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22826067",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2526236/"
] | An inner exception is the exception that caused the current exception.
It is used in cases when you want to surface a different exception than the one that your code caught but you don't want to throw away the original context.
In order for a new exception to have information about a previous one, like you said, you ... | Exception objects are read only by the time you get to a `catch` block, sometimes your code can't do anything to handle the exception, but it can add more information by creating a new exception and wrapping the originally thrown exception inside of it. This makes it so you can add information but not be required to co... |
2,674,205 | >
> What does the below expression converge to and why?
> $$ \cfrac{2}{3 -\cfrac{2}{3-\cfrac{2}{3-\cfrac2\ddots}}}$$
>
>
>
Setting it equal to $ x $, you can rewrite the above as $ x = \dfrac{2}{3-x} $, which gives the quadratic equation $x^2 - 3x + 2 = 0 $, and the roots are $ 1 $ and $2 $, both positive. How do... | 2018/03/02 | [
"https://math.stackexchange.com/questions/2674205",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | You can look at the stability of the solutions. You start with some $x\_0$ close to one of your solutions, and check if $$x\_1=\frac{2}{2-x\_0}$$ is closer to that solution. So if $x\_0=1+\epsilon$, where $|\epsilon|\ll 1$, we have $$x\_1=\frac{2}{3-(1+\epsilon)}=\frac{2}{2-\epsilon}\approx\left(1+\frac{\epsilon}{2}\ri... | In fact this fraction is the limit of the following sequence$$x\_{n+1}=\dfrac{2}{3-x\_n}\\x\_0=\dfrac{2}{3}$$now if $0<x\_n<1$ we have $$2<3-x\_n<3\to\\\dfrac{2}{3}<x\_{n+1}=\dfrac{2}{3-x\_n}<1$$therefore for all $n$ we have $$0.66<x\_n<1$$ ant then the limit is $1$. |
6,969,604 | This is code from Crockford's JavaScript: The Good Parts.
```
var results = [];
var walkDOM = function (node,func) {
func(node); //What does this do?
node = node.firstChild;
while(node) {
walkDOM(node,func);
node = node.nextSibling;
}
};... | 2011/08/06 | [
"https://Stackoverflow.com/questions/6969604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/858962/"
] | The `func` that's in the
```
func(node)
```
line is what is typically known as a *callback function*. It a function that is available for use by the `walkDOM` function. It might make sense with a more verbose function name:
```js
var results = [];
var walkDOM = function (node, iCanBeCalledOnANode) {
iCanBeCall... | Crockford's code is passing a callback to walkDOM which can be used in many ways to process the arguments passed to it.
An example could be a method which returns the count of all DOM elements with the specified tagName:
```
var getTagNameCount = function(tagName) {
var count = 0;
walkDOM(document.body, func... |
13,158,226 | I have a `textbox` which needs only accept numbers (can be decimal values) and negative values.
Currently I have something like this in `KeyPress` event
```
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.')
{
e.Handled = true;
}
```
What else I should... | 2012/10/31 | [
"https://Stackoverflow.com/questions/13158226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/925222/"
] | Hook up the Validating event, like so:
```
private void myTextBox_Validating(object sender, CancelEventArgs event) {
decimal d;
if(!decimal.TryParse(myTextBox.Text, out d) {
event.Cancel = true;
//this.errorProvider1.SetError(myTextBox, "My Text Box must be a negative number."); //optional
... | Something like:
```
var regex = new Regex("^[-]?\d+(\.\d+)?$", RegexOptions.Compiled);
Match m = regex.Match(textbox.Text + e.KeyChar);
e.Handled = m.Success;
```
**Edit**: It allows any real number now |
817,044 | This screenshot in the [Chrome Developer Documentation](https://developer.chrome.com/devtools/docs/network#resource-network-timing) shows very detailed information on what takes how long to fulfill a HTTP request:

When I look that information up on ... | 2014/09/26 | [
"https://superuser.com/questions/817044",
"https://superuser.com",
"https://superuser.com/users/83407/"
] | Performance is fine for pretty much every Linux Distro.
If you want to run a server, choose one of the typical server distros.
Debian, Ubuntu LTS, CentOS maybe Open SUSE | Based on your requirements Debian or Fedora will probably be your best choices as these distributions will hang on to old hardware support where Arch or Ubuntu may not.
Almost any popular Linux distribution can be a server and will run will be performant on old CPUs and small amounts of ram. Debian, Fedora and Arch ma... |
6,915,013 | I have to use the wakelock (yes I shouldn't for the obvious reasons but I'm being paid to do it so I don't have a choice lol)
my question is very simple: when I leave the app onPause or onStop, is the wake lock of the app automatically released ?
I want to avoid the user closing his app and the wake lock is still on... | 2011/08/02 | [
"https://Stackoverflow.com/questions/6915013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/440336/"
] | Wake lock DEFINITELY affects your device even if you application is NOT in foreground !
That's actually the whole point of acquiring wake locks
So, make sure you ONLY use wake locks when you have no other option, and if you don't need wake lock when your app is in background, make sure to release wake lock in onPause... | When your application is no longer the focus the wake lock is cancelled, only when your application is the focus is the wake lock in affect. |
32,366,942 | Using the row id to call the particular row values from two columns and display in edittext.
For that I had posted the below code that I tried so far.
**ActivityList.java:**
```
public class ActivityList extends Activity {
SQLiteDatabase db = null;
EditText editId, editCheck, editCity;
Ac... | 2015/09/03 | [
"https://Stackoverflow.com/questions/32366942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3960700/"
] | I think you should use sqlquery to search the db with the id.
Ex: `"select * from CheckPoint WHERE id=2"`
```
else if (editId.getText().toString() != null) {
c1 = db.rawQuery("select * from CheckPoint WHERE id=" + editId.getText().toString(), null);
if (c1.getCount() > 0) {
if (c1.move... | **MainActivity.java:**
```
btnSearch.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (editId.getText().toString().equals("")) {
show("Enter Id Number");
} else if (editId.getText().toString() != null) {
... |
51,699 | I'm a beginning flute player. When I play, I often- but not always- have a "shh" sound along with it. I noticed that it usually starts out pretty quiet when I start practicing, but after I play for about an hour it gets totally out of control. And since I usually play for an hour or more in one setting, that is a major... | 2016/12/30 | [
"https://music.stackexchange.com/questions/51699",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/-1/"
] | Check out [this thread on fluteland.com](https://www.fluteland.com/board/viewtopic.php?t=6178). Notably, it's mentioned that this is a 'by-individual-musician' issue...
Also, this nice gentleman is beautifully demonstrating body position, fingering, etc. on a wooden flute with no hiss:
Your ultimate answer here, as y... | Have proper posture and make sure you play the correct note. |
40,492 | In what ways may I monetize a website which offers free and accurate real time Bitcoin exchange and BTC market meta data?
In this particular case the purpose and the business model the website was built for is a longer term proposition. In the meantime how can this website be enhanced to return at least some revenue w... | 2015/09/11 | [
"https://bitcoin.stackexchange.com/questions/40492",
"https://bitcoin.stackexchange.com",
"https://bitcoin.stackexchange.com/users/29340/"
] | One way in which I have seen many such websites monetize their services is to release paid APIs. There would be people willing to pay to use your APIs (for trading, news services, Apps etc) if the data is better than the ones that are freely available.
On top of this you can try the usual stuff, ads and referrals and ... | Generally, there are two sources of income available when you monetize a site; the site user pays you or, a third-party pays you. You can use either or both of them.
### The site user pays you:
You must offer something of value for the site user to pay you. Subscription services or access to something of value.
* Yo... |
34,111,807 | Currently my code iterates through each `<li>` within a `<td>` cell and applies a class to the `<li>`. I've now added `<a>` tags in between each `<li>` and am having problems accessing the `<a>`. I essentially want to add a class to each `<a>` tag rather than the `<li>`.
**HTML**
```
<td style='padding: 0;' bgcolor=... | 2015/12/05 | [
"https://Stackoverflow.com/questions/34111807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5330854/"
] | Did you try using the query selector to find those `<a>` ?
```
var li = col.querySelectorAll("#tbl_calendar li a");
for (var k = 0; k < li.length; k++) {
for (var a = 0; a < bookedAppointmentsArray.length; a++)
{
if (li[k].id == bookedAppointmentsArray[a])
{
li[k].className = "color... | You don't need to use `table` to access it. Just keep in mind `getElementsByClassName` method:
```
u = document.getElementsByClassName('doctorList');
for (i = 0; i < u.length; i++){
l = u[i].getElementsByTagName('li');
for (j = 0; j < l.length; j++){
l[j].className = 'red';
}
}
```
... |
322,057 | I described someones voice as being **shrill** but I think that relates to the voice being particularly high pitched.
If when someone speaks and it invokes an uneasy feeling in others, how would you describe it? The uneasy feeling isn't necessarily from what they are saying but rather the tone, pitch, repetitiveness, ... | 2016/04/27 | [
"https://english.stackexchange.com/questions/322057",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/63120/"
] | "Distressing": *causing anxiety, sorrow or pain; upsetting.*
"Unsettling": *causing one to feel anxious or uneasy; disturbing.*
"Agitating": *make (someone) troubled or nervous.* | ***aggravating***
>
> : arousing displeasure, impatience, or anger.
>
>
> [M-W](http://www.merriam-webster.com/dictionary/aggravating)
>
>
> |
819 | Хочу написать предложение со словом "завсегдатай" во множественном числе. Никак не соображу, как правильно написать.
"И тогда эти посетители станут завсегдата...." ???? | 2012/01/16 | [
"https://rus.stackexchange.com/questions/819",
"https://rus.stackexchange.com",
"https://rus.stackexchange.com/users/239/"
] | Завсегдатаями (полицаями, самураями и т. д.). | В случае возникновения подобных вопросов, можно обратиться к словарям, содержащим формы слов, например [к этому](http://dic.academic.ru/dic.nsf/dic_forms/18414/завсегдатай) или [к этому](http://ru.wiktionary.org/wiki/завсегдатай). |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.