qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
9,656,867 | I was trying to create a linked list with structs. The idea is to use 2 different stucts, one which is a node, and another which is a pointer to the nodes (so, I can link the nodes together).
But I wanted to initialize the pointer to the first node as NULL, and create subsequent nodes later:
I am having an error in t... | 2012/03/11 | [
"https://Stackoverflow.com/questions/9656867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/989359/"
] | @Rikonator is on the right track there with Soundpool. It's much more suited to the kind of functionality you are after.
If you decide to go with the mediaplayer anyway, though, don't forget the prepareAsync () method to prevent it from hanging the UI thread. You can read more about playing media [here](http://develop... | ```
MediaPlayer mp = MediaPlayer.create(getApplicationContext(), R.raw.sound);
try {
if (mp.isPlaying()) {
mp.stop();
mp.release();
mp = MediaPlayer.create(getApplicationContext(), R.raw.sound);
}
mp.start();
} catch (Exception e) {
e.printStackTrace();
}
``` |
51,054 | Is there a quick way to show where a paragraph is sitting in the document structure hierarchy?
```
* Chapter 1
...
* Chapter 5
** Section 4
...
paragraph X
```
I would like to tell that `paragraph X` is sitting under `Chapter 5, Section 4` without having to navigate the cursor away from the text. | 2019/06/15 | [
"https://emacs.stackexchange.com/questions/51054",
"https://emacs.stackexchange.com",
"https://emacs.stackexchange.com/users/23726/"
] | Your function is not defined correctly. You don't need the code inside the interactive line, and you don't need the hook function. This should work fine I think:
```
(defun org-show-position-in-text () ;; display outline path of hierarchical headings
(interactive)
(message (mapconcat #'identity (org-get-outline-pa... | My half-successful attempt:
===========================
```
(defun org-show-position-in-text () ;; display outline path of hierarchical headings
(interactive (mapconcat #'identity (org-get-outline-path t) "/")))
(add-hook 'org-mode-hook 'org-show-position-in-text)
```
The above function just about does the job. O... |
74,293,324 | I'm a new C# programmer here in the early stages of creating a project in Unity where you play as a microbe that needs to eat blue food pellets to grow and survive. I've got the blue food pellets to spawn randomly across the map but I want to add a delay because too much is spawning at once. This is what I've attempted... | 2022/11/02 | [
"https://Stackoverflow.com/questions/74293324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19153501/"
] | Like the default code snippet says, Update runs every frame. Using Task.Delay to delay events would still spawn objects with the same frequency, they would only start spawning delayed.
The typical way to do this in Unity is to use a [coroutine](https://docs.unity3d.com/Manual/Coroutines.html).
```cs
using System.Coll... | I have made this prefab called “pellet”, then I have created a new gameObject called “SpawnManager” and, finally, added this script to SpawnManager:
```
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnPellet : MonoBehaviour
{
public GameObject prefab;
public b... |
28,882,520 | I'm writing a json-file inside a generated folder. After an hour I want to delete the folder with its content automatically.
I tried:
```
$dir = "../tmpDir";
$cdir = scandir($dir);
foreach ($cdir as $key => $value)
{
if (!in_array($value,array(".","..")))
{
if (is_dir($dir.'/'.$value))
... | 2015/03/05 | [
"https://Stackoverflow.com/questions/28882520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2839873/"
] | The method sizeToFit calls sizeThatFits: which returns the ‘best’ size to fit the **current** bounds and then resize label. So at first you constrain the label and it has to fit the given width. You can see description of [NSLineBreakByWordWrapping](https://developer.apple.com/library/ios/documentation/Cocoa/Reference/... | Have you tried the [`UILabel.adjustsFontSizeToWidth`](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UILabel_Class/#//apple_ref/occ/instp/UILabel/adjustsFontSizeToFitWidth) property? |
25,580,404 | I'm new to Web development and have been messing around with `BootStrap`. I've been trying to make a Web form on my new website, but I can't seem to access the username variable.
Here's my form code:
```
<form class="navbar-form navbar-left" role="search" action="username">
<div class="form-group">
... | 2014/08/30 | [
"https://Stackoverflow.com/questions/25580404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You have the following mistakes
1. You didn't set the `method` attribute in your form.So when the form is submitted the data will be posted via get method.And you need to access `$_GET` variable for getting the form data. So here when you submit the form the data will be in `$_GET` variable.But you are trying to acces... | Set your `action` attribute to `index.php` and set your `method="post"` if you access the username with `$_POST['username']`. |
25,580,404 | I'm new to Web development and have been messing around with `BootStrap`. I've been trying to make a Web form on my new website, but I can't seem to access the username variable.
Here's my form code:
```
<form class="navbar-form navbar-left" role="search" action="username">
<div class="form-group">
... | 2014/08/30 | [
"https://Stackoverflow.com/questions/25580404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | According to your description, your HTML code should look something like this:
```
<form method="post" class="navbar-form navbar-left" role="search" action="username/index.php">
<div class="form-group">
<input name="username" type="text" class="form-control" placeholder="Username">
</div>
<button t... | You have the following mistakes
1. You didn't set the `method` attribute in your form.So when the form is submitted the data will be posted via get method.And you need to access `$_GET` variable for getting the form data. So here when you submit the form the data will be in `$_GET` variable.But you are trying to acces... |
25,580,404 | I'm new to Web development and have been messing around with `BootStrap`. I've been trying to make a Web form on my new website, but I can't seem to access the username variable.
Here's my form code:
```
<form class="navbar-form navbar-left" role="search" action="username">
<div class="form-group">
... | 2014/08/30 | [
"https://Stackoverflow.com/questions/25580404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | According to your description, your HTML code should look something like this:
```
<form method="post" class="navbar-form navbar-left" role="search" action="username/index.php">
<div class="form-group">
<input name="username" type="text" class="form-control" placeholder="Username">
</div>
<button t... | Set your `action` attribute to `index.php` and set your `method="post"` if you access the username with `$_POST['username']`. |
6,554,484 | can anyone please tell me what is the error on this code? I am trying to set a cookie for the fancybox popup but it is showing on every refresh. All .js are included.
```
<script>
$(document).ready(function(){
if(!$.cookie('the_cookie1')){
$.cookie('the_cookie1', 'true', { expires: 3});
$.fancybox(
'<h2... | 2011/07/02 | [
"https://Stackoverflow.com/questions/6554484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/807325/"
] | I modified the code block to the following and it's functioning as expected both in Chrome 13 and FF5.
```
<script>
$(document).ready(function () {
var cookieName = 'the_cookie1';
var cookie = $.cookie(cookieName);
if(cookie === null) {
var cookieOptions = { expires: 3, path:... | try changing your condition to this:
```
if(! ($.cookie('the_cookie1')){...
```
this both covers null and 'undefined'. |
21,041 | I have an RN-41 bluetooth module connected to an MSP430. I want to connect the RN-41 to an Android cellphone. Just by having power to the Bluetooth module, the cellphone finds the device. However, it is not able to make pairing the only documentation that I find about pairing on the RN-41 says that the default key for ... | 2011/10/19 | [
"https://electronics.stackexchange.com/questions/21041",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/5712/"
] | The problem I was actually having with the module, was a hardware problem. I tried to connect the Bluetooth module power to the VCC pin of the target board of the MSP. It is a 3.3v source, which is appears to be compatible. But the maximum current that could pass through that pin was 15mA, which is enough to set the de... | It has been a while since I messed with my RN41 connecting to an android phone, but I will try to provide some advice for you.
The bluetooth module uses [SPP (Serial Port Profile)](http://en.wikipedia.org/wiki/Bluetooth_profile#Serial_Port_Profile_.28SPP.29) as its default profile. Essentially the way that it works is... |
46,292,300 | I have a linux server OEL 5.8 in which 8 oracle DB instances are running. 4 Db instances are running on Oracle 10.2.0.4 and other 4 on 11.2.0.3. Initially, all the DB instances were running on 10.2.0.4. I upgraded 4 of them to 11.2.0.3. Now the existing linux server is going to be migrated on new location. Server was c... | 2017/09/19 | [
"https://Stackoverflow.com/questions/46292300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7430328/"
] | There was some configuration issue in /etc/hosts. IP was mapped against some different hostname, hence the issue. After mapping IP to correct Hostname issue got resolved. | Its very simply if your Database is already started up, sqlplus will connect to the instance. If instance is not started up, sqlplus will connect to an idle instance by default. Moreover if you want to connect with a specific instance you have to specify @SID\_NAME as follows in the sqlplus command
sqlplus / as sysdba... |
3,896,524 | Question:
Prove that if $f, g: [a, b] → \mathbb{R}$ are continuous and $f (x) <g (x) $ for every $x \in [a, b]$, then there exists $δ> 0$ such that $f + δ ≤ g$.
I have tried to take the $f-g$ function and apply something like intermediate value theorem, but couldn't conclude anything. I've seen a [solution](https://ma... | 2020/11/06 | [
"https://math.stackexchange.com/questions/3896524",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/700522/"
] | let $h=g-f>0$ on $[a,b]$. Since $h$ is continuous on a closed interval, it has a global minimum (extreme value theorem).
then let $\delta=\min\_{x\in[a,b]}{h(x)}$
Then, by definition $\delta>0$ and $\forall x\in[a,b], f(x)+\delta\leq g(x) $ | Suppose not. Then for every $\delta>0$ there is a point $x\in[a,b]$ where $g(x)-f(x)<\delta$. In particular, there is a sequence $x\_n\in[a,b]$ with $g(x\_n)-f(x\_n)<1/n$.
The sequence $x\_n$ doesn't necessarily have a limit, but by Bolzano-Weierstrass there is a convergent subsequence $x\_{n\_i}\to x\in[a,b]$. Now $g... |
3,896,524 | Question:
Prove that if $f, g: [a, b] → \mathbb{R}$ are continuous and $f (x) <g (x) $ for every $x \in [a, b]$, then there exists $δ> 0$ such that $f + δ ≤ g$.
I have tried to take the $f-g$ function and apply something like intermediate value theorem, but couldn't conclude anything. I've seen a [solution](https://ma... | 2020/11/06 | [
"https://math.stackexchange.com/questions/3896524",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/700522/"
] | The idea is that you want to prove that there exists some constant $\delta$ such that $g(x)-f(x) \geqslant \delta >0$ for all $x \in [a,b]$. Your only hypothesis are the continuity of $f$ and $g$, with $g >f$, over the set $[a,b]$.
But there is a well-known property of continuous functions over closed bounded interval... | Suppose not. Then for every $\delta>0$ there is a point $x\in[a,b]$ where $g(x)-f(x)<\delta$. In particular, there is a sequence $x\_n\in[a,b]$ with $g(x\_n)-f(x\_n)<1/n$.
The sequence $x\_n$ doesn't necessarily have a limit, but by Bolzano-Weierstrass there is a convergent subsequence $x\_{n\_i}\to x\in[a,b]$. Now $g... |
12,687,239 | When scripts are loaded via [Head JS](http://headjs.com/) I am unable to force the content to refresh using the Ctrl+F5 (or equivalent) keyboard shortcut.
The scripts cache correctly and the browser obeys the cache directives sent from the server (I'm using IIS 7.5). But unlike scripts tags included directly in the ma... | 2012/10/02 | [
"https://Stackoverflow.com/questions/12687239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3362/"
] | Dynamic script loading is not a part of the page loading proper. When you force refresh, the browser reloads the page and all resources referenced in its HTML and in referenced CSS files, but the scripts you load with `head.js` are not referenced in the page content and the browser has no way to figure out that `head.j... | This is also a problem with require.js. Hopefully one of these work arounds will also apply to Head.Js
* If using Chrome, open the developer tools panel on the Network tab, right click and choose 'Clear Browser Cache'
* Do a bit of 'Cache-busting' by appending a datetime stamp to the query string for js resources
* If... |
12,687,239 | When scripts are loaded via [Head JS](http://headjs.com/) I am unable to force the content to refresh using the Ctrl+F5 (or equivalent) keyboard shortcut.
The scripts cache correctly and the browser obeys the cache directives sent from the server (I'm using IIS 7.5). But unlike scripts tags included directly in the ma... | 2012/10/02 | [
"https://Stackoverflow.com/questions/12687239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3362/"
] | Dynamic script loading is not a part of the page loading proper. When you force refresh, the browser reloads the page and all resources referenced in its HTML and in referenced CSS files, but the scripts you load with `head.js` are not referenced in the page content and the browser has no way to figure out that `head.j... | I wouldn't say its a question of dynamic or not dynamic, when you inject a script it still causes the browser to make a HTTP request and apply whatever caching logic it applies.
Like mentioned above if you don't want scripts to be cached ..dynamic or static, it doesn't matter, you will usually have to append a timesta... |
12,687,239 | When scripts are loaded via [Head JS](http://headjs.com/) I am unable to force the content to refresh using the Ctrl+F5 (or equivalent) keyboard shortcut.
The scripts cache correctly and the browser obeys the cache directives sent from the server (I'm using IIS 7.5). But unlike scripts tags included directly in the ma... | 2012/10/02 | [
"https://Stackoverflow.com/questions/12687239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3362/"
] | This is also a problem with require.js. Hopefully one of these work arounds will also apply to Head.Js
* If using Chrome, open the developer tools panel on the Network tab, right click and choose 'Clear Browser Cache'
* Do a bit of 'Cache-busting' by appending a datetime stamp to the query string for js resources
* If... | I wouldn't say its a question of dynamic or not dynamic, when you inject a script it still causes the browser to make a HTTP request and apply whatever caching logic it applies.
Like mentioned above if you don't want scripts to be cached ..dynamic or static, it doesn't matter, you will usually have to append a timesta... |
102,860 | Noobie here.
Should I open Mac terminal and cd to /Applications/Blender/ which is where my Blender app is? Doesn't seem to work for me trying to run script from Text screen in Blender. I guess there is no way to see output within Blender itself? | 2018/03/11 | [
"https://blender.stackexchange.com/questions/102860",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/53255/"
] | The only way to see the Blender console and thus the script output is to launch Blender from a terminal using the full path to the executable: `"/Applications/Blender/blender.app/Contents/MacOS/blender"`
All script output will appear in the terminal only.
Following @DickMeehan's comment and since I hate to install ye... | Without creating a new application with Applescript and all, you can just create a shell script with the '.command' extension. The extension makes it clickable, which opens a console and executes the file.
1. Open a terminal
2. `cd /Applications`
3. `nano Blender.command`
paste this and save the file
```
#!/bin/sh
... |
102,860 | Noobie here.
Should I open Mac terminal and cd to /Applications/Blender/ which is where my Blender app is? Doesn't seem to work for me trying to run script from Text screen in Blender. I guess there is no way to see output within Blender itself? | 2018/03/11 | [
"https://blender.stackexchange.com/questions/102860",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/53255/"
] | If you want to be able to launch it like any other application, the simplest way is to do this:
1. Launch **Automator** (it is in your Mac's Applications folder) and launch **Terminal** (it is in Applications/Utilities).
2. Create a new Application in Automator.

3. Type "run" ... | It seem's I cannot comment.
Small note, blender 3.x is located at:
`/Applications/Blender.app/Contents/MacOS/Blender` |
102,860 | Noobie here.
Should I open Mac terminal and cd to /Applications/Blender/ which is where my Blender app is? Doesn't seem to work for me trying to run script from Text screen in Blender. I guess there is no way to see output within Blender itself? | 2018/03/11 | [
"https://blender.stackexchange.com/questions/102860",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/53255/"
] | Right click on the Blender icon in the Applications folder and select "Show Package contents". Make an alias of `Contents/MacOS/Blender` by right clicking and selecting "Make Alias". Rename it and move it somewhere you like.
This opens the console in the background, next to the Blender application.
source:
<https://w... | The only way to see the Blender console and thus the script output is to launch Blender from a terminal using the full path to the executable: `"/Applications/Blender/blender.app/Contents/MacOS/blender"`
All script output will appear in the terminal only.
Following @DickMeehan's comment and since I hate to install ye... |
102,860 | Noobie here.
Should I open Mac terminal and cd to /Applications/Blender/ which is where my Blender app is? Doesn't seem to work for me trying to run script from Text screen in Blender. I guess there is no way to see output within Blender itself? | 2018/03/11 | [
"https://blender.stackexchange.com/questions/102860",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/53255/"
] | A really quick way for mac users to do this is to create an alias using the Terminal (It's not as scary as it looks)
open Terminal
type `nano ~/.bash_profile`
on the first line paste this `alias blender='/Applications/blender-2.80.0/blender.app/Contents/MacOS/blender'`
Exit nano by `ctrl + x` and press `y` to save ... | If you want to be able to launch it like any other application, the simplest way is to do this:
1. Launch **Automator** (it is in your Mac's Applications folder) and launch **Terminal** (it is in Applications/Utilities).
2. Create a new Application in Automator.

3. Type "run" ... |
102,860 | Noobie here.
Should I open Mac terminal and cd to /Applications/Blender/ which is where my Blender app is? Doesn't seem to work for me trying to run script from Text screen in Blender. I guess there is no way to see output within Blender itself? | 2018/03/11 | [
"https://blender.stackexchange.com/questions/102860",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/53255/"
] | Without creating a new application with Applescript and all, you can just create a shell script with the '.command' extension. The extension makes it clickable, which opens a console and executes the file.
1. Open a terminal
2. `cd /Applications`
3. `nano Blender.command`
paste this and save the file
```
#!/bin/sh
... | It seem's I cannot comment.
Small note, blender 3.x is located at:
`/Applications/Blender.app/Contents/MacOS/Blender` |
102,860 | Noobie here.
Should I open Mac terminal and cd to /Applications/Blender/ which is where my Blender app is? Doesn't seem to work for me trying to run script from Text screen in Blender. I guess there is no way to see output within Blender itself? | 2018/03/11 | [
"https://blender.stackexchange.com/questions/102860",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/53255/"
] | Right click on the Blender icon in the Applications folder and select "Show Package contents". Make an alias of `Contents/MacOS/Blender` by right clicking and selecting "Make Alias". Rename it and move it somewhere you like.
This opens the console in the background, next to the Blender application.
source:
<https://w... | A really quick way for mac users to do this is to create an alias using the Terminal (It's not as scary as it looks)
open Terminal
type `nano ~/.bash_profile`
on the first line paste this `alias blender='/Applications/blender-2.80.0/blender.app/Contents/MacOS/blender'`
Exit nano by `ctrl + x` and press `y` to save ... |
102,860 | Noobie here.
Should I open Mac terminal and cd to /Applications/Blender/ which is where my Blender app is? Doesn't seem to work for me trying to run script from Text screen in Blender. I guess there is no way to see output within Blender itself? | 2018/03/11 | [
"https://blender.stackexchange.com/questions/102860",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/53255/"
] | A really quick way for mac users to do this is to create an alias using the Terminal (It's not as scary as it looks)
open Terminal
type `nano ~/.bash_profile`
on the first line paste this `alias blender='/Applications/blender-2.80.0/blender.app/Contents/MacOS/blender'`
Exit nano by `ctrl + x` and press `y` to save ... | Without creating a new application with Applescript and all, you can just create a shell script with the '.command' extension. The extension makes it clickable, which opens a console and executes the file.
1. Open a terminal
2. `cd /Applications`
3. `nano Blender.command`
paste this and save the file
```
#!/bin/sh
... |
102,860 | Noobie here.
Should I open Mac terminal and cd to /Applications/Blender/ which is where my Blender app is? Doesn't seem to work for me trying to run script from Text screen in Blender. I guess there is no way to see output within Blender itself? | 2018/03/11 | [
"https://blender.stackexchange.com/questions/102860",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/53255/"
] | The only way to see the Blender console and thus the script output is to launch Blender from a terminal using the full path to the executable: `"/Applications/Blender/blender.app/Contents/MacOS/blender"`
All script output will appear in the terminal only.
Following @DickMeehan's comment and since I hate to install ye... | It seem's I cannot comment.
Small note, blender 3.x is located at:
`/Applications/Blender.app/Contents/MacOS/Blender` |
102,860 | Noobie here.
Should I open Mac terminal and cd to /Applications/Blender/ which is where my Blender app is? Doesn't seem to work for me trying to run script from Text screen in Blender. I guess there is no way to see output within Blender itself? | 2018/03/11 | [
"https://blender.stackexchange.com/questions/102860",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/53255/"
] | The only way to see the Blender console and thus the script output is to launch Blender from a terminal using the full path to the executable: `"/Applications/Blender/blender.app/Contents/MacOS/blender"`
All script output will appear in the terminal only.
Following @DickMeehan's comment and since I hate to install ye... | If you want to be able to launch it like any other application, the simplest way is to do this:
1. Launch **Automator** (it is in your Mac's Applications folder) and launch **Terminal** (it is in Applications/Utilities).
2. Create a new Application in Automator.

3. Type "run" ... |
102,860 | Noobie here.
Should I open Mac terminal and cd to /Applications/Blender/ which is where my Blender app is? Doesn't seem to work for me trying to run script from Text screen in Blender. I guess there is no way to see output within Blender itself? | 2018/03/11 | [
"https://blender.stackexchange.com/questions/102860",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/53255/"
] | A really quick way for mac users to do this is to create an alias using the Terminal (It's not as scary as it looks)
open Terminal
type `nano ~/.bash_profile`
on the first line paste this `alias blender='/Applications/blender-2.80.0/blender.app/Contents/MacOS/blender'`
Exit nano by `ctrl + x` and press `y` to save ... | It seem's I cannot comment.
Small note, blender 3.x is located at:
`/Applications/Blender.app/Contents/MacOS/Blender` |
10,771,653 | Why does the textfield doesn't follow the `.span1` rule? What can I do to fix it?
<http://jsfiddle.net/aurorius/aNRBn/>
```
<html>
<head>
<title></title>
</head>
<body>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<form class="form-horizontal">
<fieldset>
... | 2012/05/27 | [
"https://Stackoverflow.com/questions/10771653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/113573/"
] | It would be much more convenient to define allowed routes in routes.rb and add exception handling in application controller for routing error:
```
class ApplicationController < ActionController::Base
rescue_from ActionController::RoutingError, :with => :render_not_found
private
def render_not_found
ren... | i do catch my exception handling in my application controller but unfortunately for admin\_data, i don't explicitly set it in routes.rb. it gets configured somewhere in the gem with namespace or something (im not really sure)
but on a positive note... i finally fixed it! i changed my glob and did...
```
match '*not_... |
73,537,836 | At the moment, I am working on a project that requires me to add three videos to the homepage, but loading them all at once will reduce the load time considerably.
Also i want to use `<video/>` tag instead of using `<iframe/>` because i want that autoplay functionality.
What's the best way to do this in React? Using N... | 2022/08/30 | [
"https://Stackoverflow.com/questions/73537836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5033113/"
] | You can use [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) and do it as below. For React all you have to do is to add the below code in an `useEffect` with empty dependency.
```js
const video = document.querySelector("video");
function handleIntersection(entries) ... | i found a way to do it using '[@react-hook/intersection-observer](https://www.npmjs.com/package/@react-hook/intersection-observer)'
```
import useIntersectionObserver from '@react-hook/intersection-observer'
import { useRef } from 'react'
const LazyIframe = () => {
const containerRef = useRef()
const lockRef = us... |
51,133,540 | Is it possible to track the cost of bigquery queries using the `configuration.labels` attribute on a query request? I have specified some labels and I do find it in the job definition as you can see here:
```
{
"configuration": {
"labels": {
"label1": "tomas",
"label2": "yolo"
},
"query": {
... | 2018/07/02 | [
"https://Stackoverflow.com/questions/51133540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/280693/"
] | I have not been able to query or filter on specific labels, but can at least display them with this...
```
SELECT service.description, cost, labels
FROM `PROJECTNAME.billing_report.gcp_billing_export_v1_016D47_E84908_9F5AB5`
WHERE cost > 0
LIMIT 1000
``` | If you use `bq` command, you can do it by adding `--label` flag as below
```sh
bq query \
--nouse_legacy_sql \
--label foo:bar \
'SELECT COUNT(*) FROM `bigquery-public-data`.samples.shakespeare'
```
Then, you can issue below filter in Cloud logging
```
resource.type="bigquery_resource"
protoPayload.serviceData.jobC... |
236,743 | I'm looking into solid state relays for an application where I need to switch between two different transducers to allow two different modes of operation for an echo sounder. Basically a MUX that allows selecting either transducer #1 or transducer #2.
Short overview of how an echo sounder works: the echo sounder gener... | 2016/05/27 | [
"https://electronics.stackexchange.com/questions/236743",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/41060/"
] | The 74HC4051 has level shifters inside that allow you to use a logic supply that is GND to Vcc and another supply voltage Vee that is less than (or equal to) GND.
This is a great advantage when you want to use dual supplies such as +/-5V for the analog electronics, and the digital signals are 0 to +5 (or +/-3.3V with... | The CD4051 mux can work at +15 volts single-ended supply, or +/- 7.5 volts for bipolar supply handling bipolar signals to +/- 5 volts or so. The IC also needs a ground ref for the 3 to 5 volt logic used to select which of 8 input/outputs is selected to connect to the common I/O pin.
So for bipolar operation you need 3... |
74,776 | Do we have any standard for using ghost buttons? I know basic details on when to use ghost buttons but more detailed explanation will help
Can we use ghost button as well as solid button on same page?
If you notice, there is close icon next to close button. Do you think its very smalll and it should also be button? Th... | 2015/03/12 | [
"https://ux.stackexchange.com/questions/74776",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/52106/"
] | This question is quite broad for a single answer to cover everything, but I'll give it a go!
First of all, **motion sickness**. In actual fact it's not even motion sickness, it's the opposite - it's the brain telling you you're moving when other senses tell you you're not.
And in any case, it's not the manipulation o... | The reason why a mouse is a terrible UI for VR is because when you (inevitably) take your hand off of it (to type or itch or eat etc.), then you have to find the mouse without being able to see it! That can't happen in VR. You have to be able to see the things you're interacting with **or** the things you're interactin... |
38,007,813 | Which one should i use in an angular app and why?
```
array.filter(o => o.name === myName);
```
or
```
$filter('filter')(array, {name: myName}, true);
``` | 2016/06/24 | [
"https://Stackoverflow.com/questions/38007813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3967289/"
] | The key difference is the **shortcuts or syntactic sugar** provided by the `$filter('filter')`. For example, the following syntax can be used to get the items containing the `keyword` string in any of the item's `string` properties:
```
$filter('filter')(array, 'keyword')
```
Which can not be as simple using the sta... | You should use `Array.filter` and then assign the result. When you use `$filter`, it is re-applied at the end of every **$digest** cycle for all the bindings and that is performance intensive to watch for the values and update the results after every **$digest** cycle. Instead you should filter your result and assign i... |
38,007,813 | Which one should i use in an angular app and why?
```
array.filter(o => o.name === myName);
```
or
```
$filter('filter')(array, {name: myName}, true);
``` | 2016/06/24 | [
"https://Stackoverflow.com/questions/38007813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3967289/"
] | While using $filter('filter') can be easier and more syntactically attractive, I can think of four good reasons to use Array.filter over $filter('filter')
**Efficiency**
While it is true that $filter('filter') uses Array.filter under the hood, it also uses other code, including deep comparisons, in addition to Array.... | You should use `Array.filter` and then assign the result. When you use `$filter`, it is re-applied at the end of every **$digest** cycle for all the bindings and that is performance intensive to watch for the values and update the results after every **$digest** cycle. Instead you should filter your result and assign i... |
20,329,018 | I have used [OverScroller](http://developer.android.com/reference/android/widget/OverScroller.html) for implementing scroll of my view.
Here is some code:
```
@Override
protected void onDraw(Canvas canvas) {
if (scroller.computeScrollOffset()){
int x = scroller.getCurrX();
int y = scroller.getCur... | 2013/12/02 | [
"https://Stackoverflow.com/questions/20329018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368428/"
] | you should override computeScroll() for things like that and not onDraw() | You can override **onFinishInflate ()** method in your custom View class and you can write OverScroll related code under this method instead of **onDraw()**. For more detail [click here](http://developer.android.com/reference/android/view/View.html#onFinishInflate%28%29). |
451,983 | >
> Let $N>1$ be a positive integer. What will be the Arithmetic mean of positive integers less than $N$ and co-prime with $N$?
>
>
>
Getting no idea how to proceed! | 2013/07/25 | [
"https://math.stackexchange.com/questions/451983",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/53265/"
] | (The way the problem reads at this time is "What will be the Arithmetic mean of positive integers less than $N$ and co-prime with $N$?" (I mention this in case there was some other version of the question and it got edited.))
$n$ is coprime to $N$ if and only if $N-n$ is coprime to $N$.
The average of $n$ and $N-n$ i... | HINT:
As $(a,n)=(n-a,n),$
Let $$S=\sum\_{1\le a\le n,(a,n)=1}a,$$
then $$S=\sum\_{1\le a\le n,(a,n)=1}(n-a)$$
$$\implies2S=\phi(n)(a+n-a)=n\phi(n)$$ where $\phi(n)$ is the Euler [Totient](http://en.wikipedia.org/wiki/Euler%27s_totient_function) function, the number of positive integers $<n$ and co-prime to $n$
The... |
3,791,345 | Let $F([0,1], \mathbb{R})$ the space of functions of [0,1] in $\mathbb{R}$, together with the topology of the point convergence $\tau$.
Show that the set of continuous functions of [0,1] in $\mathbb{R}$ is dense in $(F([0,1], \mathbb{R}), \tau)$. | 2020/08/15 | [
"https://math.stackexchange.com/questions/3791345",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/651825/"
] | You can indeed use the Riesz representation theorem to solve the problem.
The hypothesis
$$ \left| \int f g \right | \leq M \| f\|\_{p}$$
shows in particular that the element $g$ defines a linear continuous functional $T\_g$ on the space $L^{p}$ via the relation
$$T\_g(f) = \int f g.$$
Now, Riesz representation theorem... | I will assume that $g$ is real valued and $p>1$. (The case $p=1$ is similar).
I will prove b) directly and a) follows from b).
Let $N$ be a positive integer and $f=(sgn \,g)|g|^{q/p}I\_{|g| \leq N}$ where $q$ is the conjugate index. Then $g$ is bounded and the given inequality becomes $\int\_{|g| \leq N} |g|^{q} \leq... |
2,202,271 | Is there a way to have an app write a into a file and then have another app read from that file?
I mean writting into the file system of the iPhone.
I want to do this without using an internet connection. So uploading the file and then downloading from the other app is not what i mean.
Thanks! | 2010/02/04 | [
"https://Stackoverflow.com/questions/2202271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/217808/"
] | It appears that there are ways you can, but it won't get approved by Apple if you do.
See <http://blogs.oreilly.com/iphone/2008/09/sandbox-think-like-apple.html> for more information. | I'm not sure exactly what circumstances you're in here, but you could register app B as a handler for a particular protocol, and have app A try to open such a link (e.g. appB://yourinfohere). It depends on how much data you want to transfer and many other things, but it might work. |
2,202,271 | Is there a way to have an app write a into a file and then have another app read from that file?
I mean writting into the file system of the iPhone.
I want to do this without using an internet connection. So uploading the file and then downloading from the other app is not what i mean.
Thanks! | 2010/02/04 | [
"https://Stackoverflow.com/questions/2202271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/217808/"
] | The current sand boxing of applications does not allow this, however it appears that this may be available in future iPhone OS versions. [Reference](http://www.techhail.com/gadgets/iphone-os-3-2-for-ipad-with-improved-text-file-document-support-xcode-tools/3088) | I'm not sure exactly what circumstances you're in here, but you could register app B as a handler for a particular protocol, and have app A try to open such a link (e.g. appB://yourinfohere). It depends on how much data you want to transfer and many other things, but it might work. |
43,035,000 | Can someone explain why the second promise returned by then function is resolved? It looks like Angular JS bug in its Promises implementation. According to the documentation [here](https://docs.angularjs.org/api/ng/service/$q) the second promise should also have been rejected.
```js
// Code goes here
var myMod = angu... | 2017/03/26 | [
"https://Stackoverflow.com/questions/43035000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1079362/"
] | So:
1. **One-to-one**: you could use a `Dense` layer as you are not processing sequences:
```py
model.add(Dense(output_size, input_shape=input_shape))
```
2. **One-to-many**: this option is not supported well as chaining models is not very easy in `Keras`, so the following version is the easiest one:
```py
model.ad... | Great Answer by @Marcin Możejko
I would **add the following to NR.5** (many to many with different in/out length):
A) as Vanilla LSTM
```
model = Sequential()
model.add(LSTM(N_BLOCKS, input_shape=(N_INPUTS, N_FEATURES)))
model.add(Dense(N_OUTPUTS))
```
B) as Encoder-Decoder LSTM
```
model.add(LSTM(N_BLOCKS, input... |
34,572,816 | First of all I'm a newbie to Python. I'm trying to combine multiple data into a single CSV. Following is the CSV format,
**file1.csv**
```
Country of Residence,2014-04,2015-04
NORTH AMERICA ,"5,514","6,160"
Canada ,"2,417","2,864"
U.S.A. ,"3,097","3,296"
LATIN AMERICA & THE CARIBBEAN ,281,293
WESTERN EUROPE ,"... | 2016/01/03 | [
"https://Stackoverflow.com/questions/34572816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5739474/"
] | There is a grate library for custom fonts in android: [custom fonts](https://github.com/chrisjenx/Calligraphy)
Here is a sample how to use it.
In gradle you need to put this line:
```
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
```
Then make a class that extends application and write this code:
```
public class A... | You can achieve this in mainly 3 ways. one way would be to create a custom TextView and refer that everywhere, ie :
```
public class TypefacedTextView extends TextView {
public TypefacedTextView(Context context, AttributeSet attrs) {
super(context, attrs);
Typeface typeface = Typeface.createF... |
13,758,536 | This question has been asked several times in various forms but I haven't found a definitive answer.
I need to be able to get dimensions and positions of descendant `Views` after the initial layout of a container (a `contentView`). The dimensions required in this case are of a View(Group) that is not predictable - mig... | 2012/12/07 | [
"https://Stackoverflow.com/questions/13758536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/429430/"
] | I've been successful using the OnGlobalLayoutListener.
It worked great on my Nexus S
```
final LinearLayout marker = (LinearLayout) findViewById(R.id.distance_marker);
OnGlobalLayoutListener listener = new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
//some code using marker.get... | My own experience with OnGlobalLayoutListener is that it does not always wait to fire until all of the child views have been laid out. So, if you're looking for the dimensions of a particular child (or child of a child, etc.) view, then if you test them within the onGlobalLayout() method, you may find that they reflect... |
59,398,255 | I have an enumerable that goes through several transformation steps and a final filter step
E.g
```
[1,2,3,4,5,6,7,8,9].map{|i| i * 2}
.map{|i| i * i}
.filter{|i| i % 3 ==0 }
.each{|i| puts how_do_i_get_initial_value_here }
.or_the_initial_va... | 2019/12/18 | [
"https://Stackoverflow.com/questions/59398255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12560599/"
] | You need to carry original value to the final step.
Object-oriented approach can help by introducing a "filter" type
```
class Filter
attr_reader :value
def initialize(value)
@value = value
end
def satisfies?
(value * 2 * value) % 3 == 0
end
end
```
Usage
```
[1,2,3,4,5,6,7,8,9].map { |i| Fil... | You could just undo the things you did. So
```
[1,2,3,4,5,6,7,8,9]
.map{ |i| i * 2 }
.map{ |i| i * i }
.filter{ |i| i % 3 ==0 }
.map{ |i| Math.sqrt(i) / 2 }
``` |
59,398,255 | I have an enumerable that goes through several transformation steps and a final filter step
E.g
```
[1,2,3,4,5,6,7,8,9].map{|i| i * 2}
.map{|i| i * i}
.filter{|i| i % 3 ==0 }
.each{|i| puts how_do_i_get_initial_value_here }
.or_the_initial_va... | 2019/12/18 | [
"https://Stackoverflow.com/questions/59398255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12560599/"
] | You need to carry original value to the final step.
Object-oriented approach can help by introducing a "filter" type
```
class Filter
attr_reader :value
def initialize(value)
@value = value
end
def satisfies?
(value * 2 * value) % 3 == 0
end
end
```
Usage
```
[1,2,3,4,5,6,7,8,9].map { |i| Fil... | You are given a method:
```
def f(n)
4 * n**2
end
```
where `f(n)` is the transformed value of an element `n` from the given array (as `(2 * n)*(2 * n) = 4 * n**2)`).
`f` is a 1-1 mapping, so it has an inverse method `g` (i.e., `g(f(n)) #=> n` for all integers `n`):
```
def g(m)
Math.sqrt(m).round/2
end
```
... |
59,398,255 | I have an enumerable that goes through several transformation steps and a final filter step
E.g
```
[1,2,3,4,5,6,7,8,9].map{|i| i * 2}
.map{|i| i * i}
.filter{|i| i % 3 ==0 }
.each{|i| puts how_do_i_get_initial_value_here }
.or_the_initial_va... | 2019/12/18 | [
"https://Stackoverflow.com/questions/59398255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12560599/"
] | You could simply apply the transformations that you do in the two `map` calls directly in `filter`:
```rb
[1,2,3,4,5,6,7,8,9]
.filter { |i| (i * 2)**2 % 3 == 0 }
```
Alternatively, you could keep the original value in a "tuple" as follows:
```rb
[1,2,3,4,5,6,7,8,9]
.map { |i| [i, i] }
.map { |a, b| [a, b * 2]... | You could just undo the things you did. So
```
[1,2,3,4,5,6,7,8,9]
.map{ |i| i * 2 }
.map{ |i| i * i }
.filter{ |i| i % 3 ==0 }
.map{ |i| Math.sqrt(i) / 2 }
``` |
59,398,255 | I have an enumerable that goes through several transformation steps and a final filter step
E.g
```
[1,2,3,4,5,6,7,8,9].map{|i| i * 2}
.map{|i| i * i}
.filter{|i| i % 3 ==0 }
.each{|i| puts how_do_i_get_initial_value_here }
.or_the_initial_va... | 2019/12/18 | [
"https://Stackoverflow.com/questions/59398255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12560599/"
] | You are given a method:
```
def f(n)
4 * n**2
end
```
where `f(n)` is the transformed value of an element `n` from the given array (as `(2 * n)*(2 * n) = 4 * n**2)`).
`f` is a 1-1 mapping, so it has an inverse method `g` (i.e., `g(f(n)) #=> n` for all integers `n`):
```
def g(m)
Math.sqrt(m).round/2
end
```
... | You could just undo the things you did. So
```
[1,2,3,4,5,6,7,8,9]
.map{ |i| i * 2 }
.map{ |i| i * i }
.filter{ |i| i % 3 ==0 }
.map{ |i| Math.sqrt(i) / 2 }
``` |
59,398,255 | I have an enumerable that goes through several transformation steps and a final filter step
E.g
```
[1,2,3,4,5,6,7,8,9].map{|i| i * 2}
.map{|i| i * i}
.filter{|i| i % 3 ==0 }
.each{|i| puts how_do_i_get_initial_value_here }
.or_the_initial_va... | 2019/12/18 | [
"https://Stackoverflow.com/questions/59398255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12560599/"
] | You could simply apply the transformations that you do in the two `map` calls directly in `filter`:
```rb
[1,2,3,4,5,6,7,8,9]
.filter { |i| (i * 2)**2 % 3 == 0 }
```
Alternatively, you could keep the original value in a "tuple" as follows:
```rb
[1,2,3,4,5,6,7,8,9]
.map { |i| [i, i] }
.map { |a, b| [a, b * 2]... | You are given a method:
```
def f(n)
4 * n**2
end
```
where `f(n)` is the transformed value of an element `n` from the given array (as `(2 * n)*(2 * n) = 4 * n**2)`).
`f` is a 1-1 mapping, so it has an inverse method `g` (i.e., `g(f(n)) #=> n` for all integers `n`):
```
def g(m)
Math.sqrt(m).round/2
end
```
... |
66,197,834 | I am getting a weird segmentation fault when accessing a structure inside of a opaque structure form it's definition file. I have just recently learned about opaque pointers, but my my guess is, I am doing something wrong with the allocation of the internal structure. However, in a first call to the structure it seems ... | 2021/02/14 | [
"https://Stackoverflow.com/questions/66197834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7473663/"
] | You're not allocating enough memory:
```
self->serv = malloc(sizeof(struct sockaddr_un *));
```
You're allocating enough space for a *pointer* to a `struct sockaddr_un`, not an instance of one. The pointer size is smaller than the struct size, so when you attempt to write to the struct you write past the end of allo... | You do not allocate `self->serv->sun_path` before copying data to it. Something must go wrong after that.
Except if `sun_path` is an array of `char`. |
66,197,834 | I am getting a weird segmentation fault when accessing a structure inside of a opaque structure form it's definition file. I have just recently learned about opaque pointers, but my my guess is, I am doing something wrong with the allocation of the internal structure. However, in a first call to the structure it seems ... | 2021/02/14 | [
"https://Stackoverflow.com/questions/66197834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7473663/"
] | You're not allocating enough memory:
```
self->serv = malloc(sizeof(struct sockaddr_un *));
```
You're allocating enough space for a *pointer* to a `struct sockaddr_un`, not an instance of one. The pointer size is smaller than the struct size, so when you attempt to write to the struct you write past the end of allo... | Compiling your code I found this:
```
connection.c:37:43: warning: format specifies type 'short *' but the argument has type 'sa_family_t' (aka 'unsigned char') [-Wformat]
printf("self->serv->sun_family = %hn\n", self->serv->sun_family);
~~~ ^~~~~~~~~~~~~~~~~~~~~~
1... |
66,197,834 | I am getting a weird segmentation fault when accessing a structure inside of a opaque structure form it's definition file. I have just recently learned about opaque pointers, but my my guess is, I am doing something wrong with the allocation of the internal structure. However, in a first call to the structure it seems ... | 2021/02/14 | [
"https://Stackoverflow.com/questions/66197834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7473663/"
] | Compiling your code I found this:
```
connection.c:37:43: warning: format specifies type 'short *' but the argument has type 'sa_family_t' (aka 'unsigned char') [-Wformat]
printf("self->serv->sun_family = %hn\n", self->serv->sun_family);
~~~ ^~~~~~~~~~~~~~~~~~~~~~
1... | You do not allocate `self->serv->sun_path` before copying data to it. Something must go wrong after that.
Except if `sun_path` is an array of `char`. |
40,527,745 | As User types in the input i am searching the table and displaying results accordingly .
But the issue i am facing is that the table header is being hidden after the search .
This is my code
```
$(document).ready(function()
{
$('#searchinputtext').keyup(function()
{
var tr = $('#vide... | 2016/11/10 | [
"https://Stackoverflow.com/questions/40527745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/784597/"
] | Use `<thead>`
```
<input type="text" id="searchinputtext" class="form-control" placeholder="Search">
<span id="errmsgnovideos"></span>
<table class="mytable1 table table-bordered table-hover" id="videosfromtagstable">
<thead>
<tr class="existingvideos">
<th width="20%">Name</th>
<th width="35%... | ```
<input type="text" id="searchinputtext" class="form-control" placeholder="Search">
<table class="mytable1 table table-bordered table-hover" id="videosfromtagstable">
<tbody class="connectedSortable ui-sortable">
<tr class="existingvideos">
<th width="20%">Name</th>
... |
5,292,379 | ```
public class AccountMembershipService : IMembershipService
{
private readonly MembershipProvider _provider;
public AccountMembershipService()
: this(null)
{
}
```
I took this bit of code from the AccountModels.cs class automatically created with the MVC3 projec... | 2011/03/13 | [
"https://Stackoverflow.com/questions/5292379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | It will call the single-argument constructor for `AccountMembershipService`, passing a `null` as the argument, before processing the body of the constructor you list.
From [MSDN](http://msdn.microsoft.com/en-us/library/ms173115.aspx):
>
> A constructor can invoke another constructor in the same object by using the t... | It calls another constructor in your class and passes `null` as a parameter.
You can also write `: base(...)` to explicitly call a constructor in your base class. |
5,292,379 | ```
public class AccountMembershipService : IMembershipService
{
private readonly MembershipProvider _provider;
public AccountMembershipService()
: this(null)
{
}
```
I took this bit of code from the AccountModels.cs class automatically created with the MVC3 projec... | 2011/03/13 | [
"https://Stackoverflow.com/questions/5292379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | It calls a different constructor with a `null` argument. | It calls another constructor in your class and passes `null` as a parameter.
You can also write `: base(...)` to explicitly call a constructor in your base class. |
5,292,379 | ```
public class AccountMembershipService : IMembershipService
{
private readonly MembershipProvider _provider;
public AccountMembershipService()
: this(null)
{
}
```
I took this bit of code from the AccountModels.cs class automatically created with the MVC3 projec... | 2011/03/13 | [
"https://Stackoverflow.com/questions/5292379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | There is most likely another constructor in your class that looks like this:
```
public AccountMembershipService(MembershipProvider provider)
{
_provider = provider;
}
```
Your code calls this constructor first and passes `null` as the argument for `provider`, then executes the original constructor. | It calls another constructor in your class and passes `null` as a parameter.
You can also write `: base(...)` to explicitly call a constructor in your base class. |
5,292,379 | ```
public class AccountMembershipService : IMembershipService
{
private readonly MembershipProvider _provider;
public AccountMembershipService()
: this(null)
{
}
```
I took this bit of code from the AccountModels.cs class automatically created with the MVC3 projec... | 2011/03/13 | [
"https://Stackoverflow.com/questions/5292379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The above answers are answering the question asked, but to go a bit further:
This is one technique we use for inversion of control and making unit testing possible.
Here are both constructors
```
public AccountMembershipService()
: this(null)
{
}
public AccountMembershipService(MembershipProvider provider)
{
... | It calls another constructor in your class and passes `null` as a parameter.
You can also write `: base(...)` to explicitly call a constructor in your base class. |
5,292,379 | ```
public class AccountMembershipService : IMembershipService
{
private readonly MembershipProvider _provider;
public AccountMembershipService()
: this(null)
{
}
```
I took this bit of code from the AccountModels.cs class automatically created with the MVC3 projec... | 2011/03/13 | [
"https://Stackoverflow.com/questions/5292379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | It will call the single-argument constructor for `AccountMembershipService`, passing a `null` as the argument, before processing the body of the constructor you list.
From [MSDN](http://msdn.microsoft.com/en-us/library/ms173115.aspx):
>
> A constructor can invoke another constructor in the same object by using the t... | It calls a different constructor with a `null` argument. |
5,292,379 | ```
public class AccountMembershipService : IMembershipService
{
private readonly MembershipProvider _provider;
public AccountMembershipService()
: this(null)
{
}
```
I took this bit of code from the AccountModels.cs class automatically created with the MVC3 projec... | 2011/03/13 | [
"https://Stackoverflow.com/questions/5292379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | It will call the single-argument constructor for `AccountMembershipService`, passing a `null` as the argument, before processing the body of the constructor you list.
From [MSDN](http://msdn.microsoft.com/en-us/library/ms173115.aspx):
>
> A constructor can invoke another constructor in the same object by using the t... | The above answers are answering the question asked, but to go a bit further:
This is one technique we use for inversion of control and making unit testing possible.
Here are both constructors
```
public AccountMembershipService()
: this(null)
{
}
public AccountMembershipService(MembershipProvider provider)
{
... |
5,292,379 | ```
public class AccountMembershipService : IMembershipService
{
private readonly MembershipProvider _provider;
public AccountMembershipService()
: this(null)
{
}
```
I took this bit of code from the AccountModels.cs class automatically created with the MVC3 projec... | 2011/03/13 | [
"https://Stackoverflow.com/questions/5292379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | There is most likely another constructor in your class that looks like this:
```
public AccountMembershipService(MembershipProvider provider)
{
_provider = provider;
}
```
Your code calls this constructor first and passes `null` as the argument for `provider`, then executes the original constructor. | It calls a different constructor with a `null` argument. |
5,292,379 | ```
public class AccountMembershipService : IMembershipService
{
private readonly MembershipProvider _provider;
public AccountMembershipService()
: this(null)
{
}
```
I took this bit of code from the AccountModels.cs class automatically created with the MVC3 projec... | 2011/03/13 | [
"https://Stackoverflow.com/questions/5292379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | There is most likely another constructor in your class that looks like this:
```
public AccountMembershipService(MembershipProvider provider)
{
_provider = provider;
}
```
Your code calls this constructor first and passes `null` as the argument for `provider`, then executes the original constructor. | The above answers are answering the question asked, but to go a bit further:
This is one technique we use for inversion of control and making unit testing possible.
Here are both constructors
```
public AccountMembershipService()
: this(null)
{
}
public AccountMembershipService(MembershipProvider provider)
{
... |
15,196 | I am creating a SaaS that will be delivered through a Vertical Information Portal (VIP).
In my research I have found that by developing a custom lean web browser and installing it on the clients platform, I can better restrict access to the portal on the web by only allowing this custom browser to access it.
I realiz... | 2012/05/21 | [
"https://security.stackexchange.com/questions/15196",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/10090/"
] | It sounds to me like you want your Web based SaaS application to be accessed only by browser/client/hosts that have some system integrity properties that are usually lacking in a typical web client host -- e.g. absence of malware, resistance to malware. If that is so, then you should consider developing a client that i... | This is [(in)security though obscurity](http://en.wikipedia.org/wiki/Security_through_obscurity), I don't see how this improves the security of any system. Probably the reason why you can't find any information on this topic is because its not a good idea. I suspect you would also implement your own HTTP protocol, and ... |
33,945 | After the one ring was destroyed and Aragorn was crowned King of Gondor and Arnor, he and Arwen were married. Though he looks older than his bride, I'm learning that Arwen is actually older than Aragorn by at least 2,600 years. She's obviously robbing the cradle, but I can't get an exact fix on exactly how old they wer... | 2013/04/07 | [
"https://scifi.stackexchange.com/questions/33945",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/13090/"
] | Both Aragorn and Arwen's births, and their marriage, are listed in the Third Age section of The Tale of Years (Appendix B, at the back of *Return of the King*). Arwen was born in the year 241. Aragorn was born on March 1 of 2931. Since they were married at the end of June in 3019, this means Aragorn was 88 years old wh... | Aragorn was 88 (having aged 45 years) and Arwen 2778 (having aged 33 years)
---------------------------------------------------------------------------
As far as I can tell, Tolkien's last known writings about Arwen's growth is the work "Elvish Ages & Númenórean" written in 1965 and published in *The Nature of Middle-... |
29,293,426 | I want to add version number and build number to my app in Titanium Studio. How to I can add these two to my apps? | 2015/03/27 | [
"https://Stackoverflow.com/questions/29293426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3534812/"
] | I too was struggling with this. Especially after testflightapp merged with iTunesConnect. The latter needs a strict build number system.
There's a nifty solution.
Let's say your app version is 1.2.3 You will set this in tiapp.xml. Now if you add another number to the end like so 1.2.3.1 then the first three will be u... | The version number of your app is set in the project's `tiapp.xml` file. A build number is usually automatically appended when you build/run the project for iOS.
You can look at the build number by opening the Xcode project file in the project's `build` directory and going to the build settings. |
45,529,342 | here I'm trying to make an inscription form an as a form validation i've chosen that the name must contain at least 2 charecters, So i've added an event listner to the input with the `id="nom"` but the problem that occurs here is that the code gets only the initial value which is empty so it doesn't really matter what ... | 2017/08/06 | [
"https://Stackoverflow.com/questions/45529342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5208122/"
] | In this line:
```
arr = (arr.OrderBy(i => i).ToArray());
```
you are creating a new array and assigning to to `arr`. The array you passed to the function is no longer accessible by that function. If you want to be able to modify the array `arr` so that other functions can use it, you need to use the [`ref` keyword]... | You can use Object.ReferenceEquals to check arr's reference has been change after call arr.OrderBy(i => i).ToArray().
```
public static void ArrayCalledWithOrderBy(string[] origin)
{
var arr = (origin.OrderBy(i => i).ToArray());
//isEqual flag is false
var isEqual = Object.ReferenceEquals(arr, ... |
45,529,342 | here I'm trying to make an inscription form an as a form validation i've chosen that the name must contain at least 2 charecters, So i've added an event listner to the input with the `id="nom"` but the problem that occurs here is that the code gets only the initial value which is empty so it doesn't really matter what ... | 2017/08/06 | [
"https://Stackoverflow.com/questions/45529342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5208122/"
] | Arrays are reference types, so when you pass an array to a method. Its *reference* is passed by *value*.
You should be aware that the `arr` in this method:
```
public static void ArrayCalledWithOrderBy(string[] arr)
{
arr = (arr.OrderBy(i => i).ToArray());
DisplayArray(arr, "After orderby inside method");
}
... | You can use Object.ReferenceEquals to check arr's reference has been change after call arr.OrderBy(i => i).ToArray().
```
public static void ArrayCalledWithOrderBy(string[] origin)
{
var arr = (origin.OrderBy(i => i).ToArray());
//isEqual flag is false
var isEqual = Object.ReferenceEquals(arr, ... |
1,099,439 | Recently, I find out that somebody uses my network traffic. I found his `MAC` address and now I wanna find full details of his device. I tried: <http://www.macvendors.com/> and such this, but the response was only the name of manufacture. Tnx from anybody who helps me( or says a better solution to find him:) )
EDIT: An... | 2016/07/11 | [
"https://superuser.com/questions/1099439",
"https://superuser.com",
"https://superuser.com/users/613671/"
] | Just searching on the MAC will only give you the vendor. It will never show you in which hardware the component with the MAC was used. (Think of it as finding the vendor name for a lightbulb, which does not tell you in which device the bulb was used).
But given that you have the MAC and almost certainly the IP, you ca... | It is not possible to get device details via MAC address as @Hennes already said as the MAC address is only specific to the network card.
Another way to obtain more information is to log into your router/firewall and look for known devices with the found MAC. There you have the association MAC <-> IP address.
You th... |
1,099,439 | Recently, I find out that somebody uses my network traffic. I found his `MAC` address and now I wanna find full details of his device. I tried: <http://www.macvendors.com/> and such this, but the response was only the name of manufacture. Tnx from anybody who helps me( or says a better solution to find him:) )
EDIT: An... | 2016/07/11 | [
"https://superuser.com/questions/1099439",
"https://superuser.com",
"https://superuser.com/users/613671/"
] | Just searching on the MAC will only give you the vendor. It will never show you in which hardware the component with the MAC was used. (Think of it as finding the vendor name for a lightbulb, which does not tell you in which device the bulb was used).
But given that you have the MAC and almost certainly the IP, you ca... | I have another idea for this purpose: what if somebody , on purpose , set own wifi without any password and the thief could connect again!
I think in that case we have more chance to discover what device is connected to our router. |
1,099,439 | Recently, I find out that somebody uses my network traffic. I found his `MAC` address and now I wanna find full details of his device. I tried: <http://www.macvendors.com/> and such this, but the response was only the name of manufacture. Tnx from anybody who helps me( or says a better solution to find him:) )
EDIT: An... | 2016/07/11 | [
"https://superuser.com/questions/1099439",
"https://superuser.com",
"https://superuser.com/users/613671/"
] | I have another idea for this purpose: what if somebody , on purpose , set own wifi without any password and the thief could connect again!
I think in that case we have more chance to discover what device is connected to our router. | It is not possible to get device details via MAC address as @Hennes already said as the MAC address is only specific to the network card.
Another way to obtain more information is to log into your router/firewall and look for known devices with the found MAC. There you have the association MAC <-> IP address.
You th... |
37,166,663 | So I've got two different classes in C++,
```
#ifndef A_H
#define A_H
class A
{
public:
...
private:
static const int MAX = 52;
int a_array[MAX];
};
#endif // A_H
```
And I'd like to use that array into another class... But I was wondering if I can't just return an array, how sh... | 2016/05/11 | [
"https://Stackoverflow.com/questions/37166663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5615653/"
] | The array is just a pointer to a piece of data. But you need to be very clear on what you want. Do you want to copy the data and have a separate copy to play with? Or do you want the second class to have full access to the original?
You can return the pointer in a function or make the member variable accessible as eit... | ```
create a method in public int Array(int index) and return the value to your desired
like:
class B
{
public:
void createNewDeck("here would be the array, or the object I'd like to input to use the array inside");
private:
static const int min = 5;
int a_array[min]
// Method to r... |
37,166,663 | So I've got two different classes in C++,
```
#ifndef A_H
#define A_H
class A
{
public:
...
private:
static const int MAX = 52;
int a_array[MAX];
};
#endif // A_H
```
And I'd like to use that array into another class... But I was wondering if I can't just return an array, how sh... | 2016/05/11 | [
"https://Stackoverflow.com/questions/37166663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5615653/"
] | The array is just a pointer to a piece of data. But you need to be very clear on what you want. Do you want to copy the data and have a separate copy to play with? Or do you want the second class to have full access to the original?
You can return the pointer in a function or make the member variable accessible as eit... | Easiest way is to make `B` a friend of `A`. That way `B` will have access to `A`'s `private` member.
```
class B; // forward declare B to make it visible in A's scope. Important
class A
{
private:
static const int MAX = 52;
int a_array[MAX];
friend class B; // !!
//friend B; // i... |
15,012,847 | I've got a curious bug (bugging me) today. There are three inheritance levels involved:
**Grandpa**:
```
abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess,
IteratorAggregate
{
protected $_data = array();
/* snip */
}
```
**Mom**:
```
nam... | 2013/02/21 | [
"https://Stackoverflow.com/questions/15012847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11995/"
] | following snippet works flawlessly on PHP 5.4.9:
```
class A
{
protected $foo = 'hello';
public function bar()
{
echo $this->foo;
}
}
class B extends A {}
class C extends B {}
$c = new C();
$c->bar();
```
Please minimise your code step by step to this to see if/when problem occurs (I wonde... | If you don't want the parent field to inherit in the child class through object then declar the parent field as "static". |
5,751,545 | I have a java code that contains a class TRADE\_HISTORY that holds a history of trades.
Class TRADE\_HISTORY has a final field named fMapDateOutputPriceRatios that is set in the constructor . fMapDateOutputPriceRatios is a map between dates and a double array (TreeMap). In the constructor, the field is assinged to the... | 2011/04/22 | [
"https://Stackoverflow.com/questions/5751545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/719924/"
] | A final reference to an object instance *does not make that instance immutable!* It only blocks changing the reference to point to a different object instance. The reference is final--not the state of the object instance it references.
Note that the set of keys returned by `keySet()` is backed by the map. If you remov... | First, important question: are you sure Dates used as keys are not modified anywhere? Date is supposed to be an immutable object, but it still contains legacy deprecated methods letting one to change the key content. That would cause unpredictable consequences to TreeMap, including the ones you described.
Also, make s... |
5,751,545 | I have a java code that contains a class TRADE\_HISTORY that holds a history of trades.
Class TRADE\_HISTORY has a final field named fMapDateOutputPriceRatios that is set in the constructor . fMapDateOutputPriceRatios is a map between dates and a double array (TreeMap). In the constructor, the field is assinged to the... | 2011/04/22 | [
"https://Stackoverflow.com/questions/5751545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/719924/"
] | A final reference to an object instance *does not make that instance immutable!* It only blocks changing the reference to point to a different object instance. The reference is final--not the state of the object instance it references.
Note that the set of keys returned by `keySet()` is backed by the map. If you remov... | Thank you for the feedback.
Moving the date/output price map to the driving function removes the possibility of a problem with date/output price maps.
However, still get unexpected errors.
A static counter was added to the constructor of TRADE\_HISTORY to keep track of the number of TRADE\_HISTORY constructed. Also, ... |
7,886,575 | I have the following array of TrackerReport Object:
```
public class TrackerReport : TrackerMilestone
{
public long Views { get; set; }
public override string ToString()
{
return "Id=" + MilestoneId + " | Name=" + Name + " | Views = " + Views;
}
```
I post also the parent class to better explain... | 2011/10/25 | [
"https://Stackoverflow.com/questions/7886575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/799758/"
] | This is the `lambda expression` for your query.
```
TrackerReport[] trackerInfoList = trackerReportList
.SelectMany(s => s)
.GroupBy(g => g.MilestoneId)
.Select(s =>
{
var trackerReportCloned = Clone<TrackerReport[]>(s.First());
trackerReportCloned.Vi... | I'd do it in the following way:
1) Let the `TrackerReports[] resultList` is the array of deep copies of the `trackerReportList[0]` items
2) As I understand, the Views property corresponds to the Counter column. If so, then
```
foreach(report in resultList)
{
report.Views = trackerReportList.Sum(reports => reports.... |
7,886,575 | I have the following array of TrackerReport Object:
```
public class TrackerReport : TrackerMilestone
{
public long Views { get; set; }
public override string ToString()
{
return "Id=" + MilestoneId + " | Name=" + Name + " | Views = " + Views;
}
```
I post also the parent class to better explain... | 2011/10/25 | [
"https://Stackoverflow.com/questions/7886575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/799758/"
] | Here's how to do it using Linq.
1. Firstly, you want to get the data in a single list rather than a `List` of `Arrays`. We can do this with a `SelectMany`.
`trackerReportList.SelectMany(c => c)` flattens `List<TrackerReport[]>()` into `IEnumerable<TrackerReport>`
2. Then you group the objects by the relevant column/c... | I'd do it in the following way:
1) Let the `TrackerReports[] resultList` is the array of deep copies of the `trackerReportList[0]` items
2) As I understand, the Views property corresponds to the Counter column. If so, then
```
foreach(report in resultList)
{
report.Views = trackerReportList.Sum(reports => reports.... |
72,325,550 | I have a data set which I can represent by this toy example of a list of dictionaries:
```
data = [{
"_id" : "001",
"Location" : "NY",
"start_date" : "2022-01-01T00:00:00Z",
"Foo" : "fruits"
},
{
"_id" : "002",
"Location" : "NY",
"start_date" : "2022-... | 2022/05/20 | [
"https://Stackoverflow.com/questions/72325550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343215/"
] | In my organization, this error was solved with this sequence:
```
# apt remove ubuntu-advantage-tools
# apt install -f
# apt update
# apt upgrade
```
A reboot after these steps should complete the updates.
The outputs are below:
```
root@host:~# **apt remove ubuntu-advantage-tools**
Reading package lists... Done
B... | When apt says dependencies have conflicting versions, you need to manually specify all dependencies in the command line. This tells apt that you want also to upgrade all dependencies. Apt doesn't by default allow downgrading packages. If any package still conflicts and it is not required by other installed packages, it... |
63,932,169 | Regex program to print words from sentences which contain 2 numbers and they are not next to each other. I made a regex program which prints them but in some cases they print out words with numbers next to each other.
```
import re
tekst = str(input("Unesi tekst: "))
pattern = re.findall(r'\b(?=\d*[^\W\d])[^\W\d]*\d[^... | 2020/09/17 | [
"https://Stackoverflow.com/questions/63932169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14212957/"
] | Use `re.findall`:
```
[i for i in tekst.split() if len(re.findall("\d+", i)) == 2]
```
Output:
```
['2test2', '2tes2t', 't2est2']
``` | You could update the pattern to repeat the middle negated character class 1+ times to prevent the 2 digits being next to each other.
```
\b(?=\d*[^\W\d])[^\W\d]*\d[^\W\d]+\d[^\W\d]*\b
```
**Explanation**
* `\b` Word boundary
* `(?=\d*[^\W\d])` Assert as least a single word char that is not a digit
* `[^\W\d]*` Matc... |
47,439,536 | I am able to extract the inner file, but it extracts the entire chain.
Suppose the following file structure
```
v a.zip
v folder1
v folder2
> inner.txt
```
and suppose I want to extract `inner.txt` to some folder `target`.
Currently what happens when I try to do this is that I end up ex... | 2017/11/22 | [
"https://Stackoverflow.com/questions/47439536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7571052/"
] | You should use the **-j** (*junk paths (do not make directories)*) modifier (old *v5.52* has it). Here's the full list: [[DIE.Linux]: unzip(1) - Linux man page](https://linux.die.net/man/1/unzip), or you could simply run *(${PATH\_TO}/)unzip* in the terminal, and it will output the argument list.
Considering that you ... | The zip doesn't have a folder structure in the same way as on the filesystem - each file has a name that is its entire path.
You'll want to use a method that allows you to read the file contents (such as zipfile.open or zipfile.read), extract the part of the filename you actually want to use, and save the file content... |
11,768,601 | With best practices in mind, what's the advisable approach to adding optional parameters to a constructor signature? Should you only ever list the core parameters and depend on initialisers for the non optional properties? Seems to me to be the most sensible approach! | 2012/08/01 | [
"https://Stackoverflow.com/questions/11768601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/477097/"
] | In particular with the ability to assign property values with object initializers, multiple overloads for constructors are far less useful than they were. They were mostly useful in the past for setting mutable properties for code compactness.
Now one can write
```
MyClass my = new MyClass() { PropA = 1, PropB = 2 };... | I believe this is a fine approach. Typically people use properties for optional parameters; but this makes the object mutable. Using optional constructor arguments/ctor overloads is a good approach to keep the object immutable. |
11,768,601 | With best practices in mind, what's the advisable approach to adding optional parameters to a constructor signature? Should you only ever list the core parameters and depend on initialisers for the non optional properties? Seems to me to be the most sensible approach! | 2012/08/01 | [
"https://Stackoverflow.com/questions/11768601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/477097/"
] | I believe this is a fine approach. Typically people use properties for optional parameters; but this makes the object mutable. Using optional constructor arguments/ctor overloads is a good approach to keep the object immutable. | Consider subclassing instead of several constructors.
Reason: Often two different different constructors indicate two different behaviors are desired. Different nehaviors should be implemented by different classes.
The subclass would then have both a name that indicates how it's a specialized version of the base cla... |
11,768,601 | With best practices in mind, what's the advisable approach to adding optional parameters to a constructor signature? Should you only ever list the core parameters and depend on initialisers for the non optional properties? Seems to me to be the most sensible approach! | 2012/08/01 | [
"https://Stackoverflow.com/questions/11768601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/477097/"
] | In particular with the ability to assign property values with object initializers, multiple overloads for constructors are far less useful than they were. They were mostly useful in the past for setting mutable properties for code compactness.
Now one can write
```
MyClass my = new MyClass() { PropA = 1, PropB = 2 };... | As a rule of thumb, I add to a constructor only the parameters that are *required* to create a valid, working object. With the advent of object initializer syntax, it is much easier for the client to configure whatever other parameters he wants.
However, I think that this rule *should* have many exceptions: many time... |
11,768,601 | With best practices in mind, what's the advisable approach to adding optional parameters to a constructor signature? Should you only ever list the core parameters and depend on initialisers for the non optional properties? Seems to me to be the most sensible approach! | 2012/08/01 | [
"https://Stackoverflow.com/questions/11768601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/477097/"
] | In particular with the ability to assign property values with object initializers, multiple overloads for constructors are far less useful than they were. They were mostly useful in the past for setting mutable properties for code compactness.
Now one can write
```
MyClass my = new MyClass() { PropA = 1, PropB = 2 };... | Consider subclassing instead of several constructors.
Reason: Often two different different constructors indicate two different behaviors are desired. Different nehaviors should be implemented by different classes.
The subclass would then have both a name that indicates how it's a specialized version of the base cla... |
11,768,601 | With best practices in mind, what's the advisable approach to adding optional parameters to a constructor signature? Should you only ever list the core parameters and depend on initialisers for the non optional properties? Seems to me to be the most sensible approach! | 2012/08/01 | [
"https://Stackoverflow.com/questions/11768601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/477097/"
] | As a rule of thumb, I add to a constructor only the parameters that are *required* to create a valid, working object. With the advent of object initializer syntax, it is much easier for the client to configure whatever other parameters he wants.
However, I think that this rule *should* have many exceptions: many time... | Consider subclassing instead of several constructors.
Reason: Often two different different constructors indicate two different behaviors are desired. Different nehaviors should be implemented by different classes.
The subclass would then have both a name that indicates how it's a specialized version of the base cla... |
22,987,874 | I want to access a Darwin iCal server which i have implemented using my Rails application. I would like to create events and access the server to get events in specific date range. When I tried to install the [Caldav gem](http://rubygems.org/gems/caldav), I am getting a dependency with the "rexml" gem.
>
> Could not... | 2014/04/10 | [
"https://Stackoverflow.com/questions/22987874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/907561/"
] | I'm not sure but i've figured out this from what i understand you want like this?
```
$('#NewCustomerDiv input[name=CompanyName]').keyup(function () {
if($(this).val().length > 0) {
if($(this).val() == "test")
$('#CustomerCompanyDiv').slideUp("slow");
else
$('#CustomerCo... | Use the PLACEHOLDER Parameter to inform users of the functionality of a form element:
```
<input type="text" name="CompanyName" placeholder="Type test to slide up"/>
``` |
22,987,874 | I want to access a Darwin iCal server which i have implemented using my Rails application. I would like to create events and access the server to get events in specific date range. When I tried to install the [Caldav gem](http://rubygems.org/gems/caldav), I am getting a dependency with the "rexml" gem.
>
> Could not... | 2014/04/10 | [
"https://Stackoverflow.com/questions/22987874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/907561/"
] | I'm not sure but i've figured out this from what i understand you want like this?
```
$('#NewCustomerDiv input[name=CompanyName]').keyup(function () {
if($(this).val().length > 0) {
if($(this).val() == "test")
$('#CustomerCompanyDiv').slideUp("slow");
else
$('#CustomerCo... | ok try this [fiddle](http://jsfiddle.net/L7Ebt/3/)
Your modified script
```
$(document).ready(function(){
$('#NewCustomerDiv input[name=CompanyName]').keyup(function(){
if($(this).val()==""){
$('#CustomerCompanyDiv').slideUp("slow");
}
else{
$('#CustomerCompanyDiv').slideDown("slow");
}
});
if($('#New... |
28,795,808 | Based on recent empirical findings, and based on various posts on the web, it seems that an application running on an iPhone with personal hotspot enabled cannot send broadcasts and/or multicasts out onto the personal hotspot's network. Can anyone shed light on the cause of this problem?
**The Application**
I have an... | 2015/03/01 | [
"https://Stackoverflow.com/questions/28795808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/562242/"
] | **I got broadcast working (on iOS 10)**
I'm posting a second answer, because I found a way to get broadcast working on iOS 10 in personal hotspot mode. the solution is a bit complex, but here is how I got it to work:
1. use `getifaddrs(if)` to loop through all interfaces (`do {} while (if = if->ifa_next)`)
2. reject ... | **Quick-and-dirty workaround**
I also ran into the same problem when developing an iPhone app that uses a UDP multicast message to discover devices on the network. Apparently the iPhone blocks multicast messages in personal hotspot mode.
However, iPhone seems to use the `172.20.10.0/28` subnet for devices on the pers... |
13,743,618 | I am attempting to get multiple String variables set with one println. Here is what I have:
```
Scanner scanner = new Scanner(System.in);
String teacher = "";
String classSelect = "";
String location = "";
System.out.println("Enter a teacher: ");
teacher = scanner.next();
System.out.println("Enter a class name: ");... | 2012/12/06 | [
"https://Stackoverflow.com/questions/13743618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414028/"
] | This might not be an ethical way but try it
```
System.out.printf("Only fill in applicable criteria, leave the rest blank and use | after every field:\n"
+ "Section://Sets section var// \n"
+ "Instructor://Sets instructor var// \n"
+ "Location://Sets location var// \n");
```
if the user enter... | Are you looking for this:
```
String message =
String.format("Only fill in applicable criteria, leave the rest blank :\n"
+ "Section: %s \n"
+ "Instructor: %s \n"
+ "Location:%s \n",
section ,instructor,location );
```
or this?
```
System.out.printf("Only fill in app... |
51,222,035 | I'm looking to achieve horizontal scroll using buttons in VueJS. I have a container which has several divs stacked horizontally and I want to scroll through them using the buttons.
[Here](https://stackoverflow.com/questions/25028040/jquery-horizontal-scroll-using-buttons) is an identical thread on SO for JQuery. [This... | 2018/07/07 | [
"https://Stackoverflow.com/questions/51222035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7489488/"
] | >
> I made a sandbox for this: [see it here](https://jz38xyr559.codesandbox.io)
>
>
>
The logic is this:
```
scroll_left() {
let content = document.querySelector(".wrapper-box");
content.scrollLeft -= 50;
},
scroll_right() {
let content = document.querySelector(".wrapper-box");
content.scrollLeft += 40;
}... | You can use JavaScript only, using the example you gave I converted it to JavaScript only and here's the Codepen for it.
<https://codepen.io/immad-hamid/pen/yEmayr>
This is the JavaScript that can replace the example that you sent.
```
const rightBtn = document.querySelector('#right-button');
const leftBtn = documen... |
51,222,035 | I'm looking to achieve horizontal scroll using buttons in VueJS. I have a container which has several divs stacked horizontally and I want to scroll through them using the buttons.
[Here](https://stackoverflow.com/questions/25028040/jquery-horizontal-scroll-using-buttons) is an identical thread on SO for JQuery. [This... | 2018/07/07 | [
"https://Stackoverflow.com/questions/51222035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7489488/"
] | You can use JavaScript only, using the example you gave I converted it to JavaScript only and here's the Codepen for it.
<https://codepen.io/immad-hamid/pen/yEmayr>
This is the JavaScript that can replace the example that you sent.
```
const rightBtn = document.querySelector('#right-button');
const leftBtn = documen... | There's also this example from codepen
`$ Here's the link`
<https://codepen.io/wa23/pen/pObyrq>
here's the important things:
HTML (pug)
```
link(href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400" rel="stylesheet")
h1 Vue Carousel
script#v-carousel(type="x/template")
.card-carousel-wrapper
... |
51,222,035 | I'm looking to achieve horizontal scroll using buttons in VueJS. I have a container which has several divs stacked horizontally and I want to scroll through them using the buttons.
[Here](https://stackoverflow.com/questions/25028040/jquery-horizontal-scroll-using-buttons) is an identical thread on SO for JQuery. [This... | 2018/07/07 | [
"https://Stackoverflow.com/questions/51222035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7489488/"
] | >
> I made a sandbox for this: [see it here](https://jz38xyr559.codesandbox.io)
>
>
>
The logic is this:
```
scroll_left() {
let content = document.querySelector(".wrapper-box");
content.scrollLeft -= 50;
},
scroll_right() {
let content = document.querySelector(".wrapper-box");
content.scrollLeft += 40;
}... | There's also this example from codepen
`$ Here's the link`
<https://codepen.io/wa23/pen/pObyrq>
here's the important things:
HTML (pug)
```
link(href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400" rel="stylesheet")
h1 Vue Carousel
script#v-carousel(type="x/template")
.card-carousel-wrapper
... |
51,222,035 | I'm looking to achieve horizontal scroll using buttons in VueJS. I have a container which has several divs stacked horizontally and I want to scroll through them using the buttons.
[Here](https://stackoverflow.com/questions/25028040/jquery-horizontal-scroll-using-buttons) is an identical thread on SO for JQuery. [This... | 2018/07/07 | [
"https://Stackoverflow.com/questions/51222035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7489488/"
] | >
> I made a sandbox for this: [see it here](https://jz38xyr559.codesandbox.io)
>
>
>
The logic is this:
```
scroll_left() {
let content = document.querySelector(".wrapper-box");
content.scrollLeft -= 50;
},
scroll_right() {
let content = document.querySelector(".wrapper-box");
content.scrollLeft += 40;
}... | If you're looking for horizontal smooth scroll animation in javascript itself without using any library.
Use `scrollTo` with `behavior: 'smooth'`
```js
Vue.config.devtools = false;
Vue.config.productionTip = false;
new Vue({
el: '#app',
data: {
scrollAmount: 0,
},
methods: {
scrollLeft: function () {
const... |
51,222,035 | I'm looking to achieve horizontal scroll using buttons in VueJS. I have a container which has several divs stacked horizontally and I want to scroll through them using the buttons.
[Here](https://stackoverflow.com/questions/25028040/jquery-horizontal-scroll-using-buttons) is an identical thread on SO for JQuery. [This... | 2018/07/07 | [
"https://Stackoverflow.com/questions/51222035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7489488/"
] | If you're looking for horizontal smooth scroll animation in javascript itself without using any library.
Use `scrollTo` with `behavior: 'smooth'`
```js
Vue.config.devtools = false;
Vue.config.productionTip = false;
new Vue({
el: '#app',
data: {
scrollAmount: 0,
},
methods: {
scrollLeft: function () {
const... | There's also this example from codepen
`$ Here's the link`
<https://codepen.io/wa23/pen/pObyrq>
here's the important things:
HTML (pug)
```
link(href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400" rel="stylesheet")
h1 Vue Carousel
script#v-carousel(type="x/template")
.card-carousel-wrapper
... |
7,345,786 | This code is not working and i do not understand the mistake.
Please help.
```
-(UIImage *)addText:(UIImage *)img text:(NSString *)text1
{
int w = img.size.width;
int h = img.size.height;
//lon = h - lon;
char* text = (char *)[text1 cStringUsingEncoding:NSASCIIStringEncodi... | 2011/09/08 | [
"https://Stackoverflow.com/questions/7345786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/889867/"
] | Unless you have a reason to avoid NSString UIKit additions, this will suffice:
```
+(UIImage*) drawText:(NSString*) text
inImage:(UIImage*) image
atPoint:(CGPoint) point
font:(UIFont*) font
color:(UIColor*) color
{
UIGraphicsBeginImageContextWithOpti... | Your code does work.
Make sure the string you are passing into it is not empty. |
226,503 | I am trying to delete first and the last vertex of each line.
I created code to delete first and last vertex but it shows me error on line 18:
>
>
> >
> > Traceback (most recent call last): File "D:\UKPN\ukpn\_CAD\tet\Delete\_first\_last.py", line 18, in
> > insert = arcpy.da.InsertCursor(outFC, "SHAPE@") Runti... | 2017/01/31 | [
"https://gis.stackexchange.com/questions/226503",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/62486/"
] | I think the problem lies in your attempt to "explode" your geometry into a list of point objects. I personally find list comprehension extremely confusing and generally unreadable. The following code does the same and is much easier to read.
```py
# Code assumes the following: all polylines are single part & that a mi... | You are asking your model's user to enter an output feature class location/name as a parameter and deleting it if it exists. The problem is arcpy.da.InsertCursor works only with existing feature classes, so you need to create one (since you want to make sure it is an empty feature class).
Try adding [Create Feature C... |
226,503 | I am trying to delete first and the last vertex of each line.
I created code to delete first and last vertex but it shows me error on line 18:
>
>
> >
> > Traceback (most recent call last): File "D:\UKPN\ukpn\_CAD\tet\Delete\_first\_last.py", line 18, in
> > insert = arcpy.da.InsertCursor(outFC, "SHAPE@") Runti... | 2017/01/31 | [
"https://gis.stackexchange.com/questions/226503",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/62486/"
] | I have had similar problems with data where we had multiple vertices "stacked" at close to the same x,y pt in polylines and polygons. If you are using ArcGIS Arcmap (32 bit) ESRI products with python 2.7, I wrote a script to identify and clean those issues. In my script, I'm always saving the beginning and ending verte... | You are asking your model's user to enter an output feature class location/name as a parameter and deleting it if it exists. The problem is arcpy.da.InsertCursor works only with existing feature classes, so you need to create one (since you want to make sure it is an empty feature class).
Try adding [Create Feature C... |
226,503 | I am trying to delete first and the last vertex of each line.
I created code to delete first and last vertex but it shows me error on line 18:
>
>
> >
> > Traceback (most recent call last): File "D:\UKPN\ukpn\_CAD\tet\Delete\_first\_last.py", line 18, in
> > insert = arcpy.da.InsertCursor(outFC, "SHAPE@") Runti... | 2017/01/31 | [
"https://gis.stackexchange.com/questions/226503",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/62486/"
] | I think the problem lies in your attempt to "explode" your geometry into a list of point objects. I personally find list comprehension extremely confusing and generally unreadable. The following code does the same and is much easier to read.
```py
# Code assumes the following: all polylines are single part & that a mi... | I have had similar problems with data where we had multiple vertices "stacked" at close to the same x,y pt in polylines and polygons. If you are using ArcGIS Arcmap (32 bit) ESRI products with python 2.7, I wrote a script to identify and clean those issues. In my script, I'm always saving the beginning and ending verte... |
44,671,730 | I did not want to do it using "shell, exec, etc"... Only with loop in php!
My understanding is in this case:
1. I have a form in page, on form submit, i will call on a PHP script which will run in Background.
2. Background process started and running ....running ....running .....running......
3. I want to got back pr... | 2017/06/21 | [
"https://Stackoverflow.com/questions/44671730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8193147/"
] | Because non-empty strings evaluate to `True` in Python. Solution for you problem could be one of the following
```
if i=="b" or i == "k" or i == "c":
```
or
```
if i in ["b", "k", "c"]:
```
Apart from that you are iterating over a wrong set of values. Replace your `for` with
```
for i in alpha:
``` | Your condition `i=="b" or "k" or "c"` probably isn't what you wanted. It always returns true, because `"k"` (and `"c"` as well) is true. What you want is:
```
if i=="b" or i=="k" or i=="c":
```
or, better:
```
if i in {"b", "c", "k"}:
``` |
44,671,730 | I did not want to do it using "shell, exec, etc"... Only with loop in php!
My understanding is in this case:
1. I have a form in page, on form submit, i will call on a PHP script which will run in Background.
2. Background process started and running ....running ....running .....running......
3. I want to got back pr... | 2017/06/21 | [
"https://Stackoverflow.com/questions/44671730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8193147/"
] | Because non-empty strings evaluate to `True` in Python. Solution for you problem could be one of the following
```
if i=="b" or i == "k" or i == "c":
```
or
```
if i in ["b", "k", "c"]:
```
Apart from that you are iterating over a wrong set of values. Replace your `for` with
```
for i in alpha:
``` | You have missed the check
```
def alphaToPhone(alpha):
for i in alpha:
if i == "b" or i == "k" or i == "c":
phone="yes"
else:
phone="no"
return phone
print(alphaToPhone("23ht"))
``` |
44,671,730 | I did not want to do it using "shell, exec, etc"... Only with loop in php!
My understanding is in this case:
1. I have a form in page, on form submit, i will call on a PHP script which will run in Background.
2. Background process started and running ....running ....running .....running......
3. I want to got back pr... | 2017/06/21 | [
"https://Stackoverflow.com/questions/44671730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8193147/"
] | Because non-empty strings evaluate to `True` in Python. Solution for you problem could be one of the following
```
if i=="b" or i == "k" or i == "c":
```
or
```
if i in ["b", "k", "c"]:
```
Apart from that you are iterating over a wrong set of values. Replace your `for` with
```
for i in alpha:
``` | You code should be like this:
```
def alphaToPhone(alpha):
for ch in alpha:
if ch == "b" or ch=="k" or ch=="c":
phone="yes"
else:
phone="no"
return phone
print(alphaToPhone("23ht"))
``` |
44,671,730 | I did not want to do it using "shell, exec, etc"... Only with loop in php!
My understanding is in this case:
1. I have a form in page, on form submit, i will call on a PHP script which will run in Background.
2. Background process started and running ....running ....running .....running......
3. I want to got back pr... | 2017/06/21 | [
"https://Stackoverflow.com/questions/44671730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8193147/"
] | Your condition `i=="b" or "k" or "c"` probably isn't what you wanted. It always returns true, because `"k"` (and `"c"` as well) is true. What you want is:
```
if i=="b" or i=="k" or i=="c":
```
or, better:
```
if i in {"b", "c", "k"}:
``` | You code should be like this:
```
def alphaToPhone(alpha):
for ch in alpha:
if ch == "b" or ch=="k" or ch=="c":
phone="yes"
else:
phone="no"
return phone
print(alphaToPhone("23ht"))
``` |
44,671,730 | I did not want to do it using "shell, exec, etc"... Only with loop in php!
My understanding is in this case:
1. I have a form in page, on form submit, i will call on a PHP script which will run in Background.
2. Background process started and running ....running ....running .....running......
3. I want to got back pr... | 2017/06/21 | [
"https://Stackoverflow.com/questions/44671730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8193147/"
] | You have missed the check
```
def alphaToPhone(alpha):
for i in alpha:
if i == "b" or i == "k" or i == "c":
phone="yes"
else:
phone="no"
return phone
print(alphaToPhone("23ht"))
``` | You code should be like this:
```
def alphaToPhone(alpha):
for ch in alpha:
if ch == "b" or ch=="k" or ch=="c":
phone="yes"
else:
phone="no"
return phone
print(alphaToPhone("23ht"))
``` |
12,242,879 | In my project I have to select multiple values and pass it to a query. i.e page1 contains checkboxes. I am storing the selected checkbox id's into an array.
I am shuffling that array and getting the values randomly. Now I need to pass these random values to a query. Using IN operator in database I can pass the values
... | 2012/09/03 | [
"https://Stackoverflow.com/questions/12242879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1455252/"
] | see how values are dynamicaly passed
```
// Getting single contact
public Contact getContact(int id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(TABLE_CONTACTS, new String[] { KEY_ID,
KEY_NAME, KEY_PH_NO }, KEY_ID + "=?",
new String[] { String.valueOf(id) }, null, nul... | Try it
```
cursor = database.query(tablename,
new String[] {"TopName"}, "id IN(?,?)", new String[]{"2","3"}, null, null, null);
```
using raw query
```
String query = "SELECT * FROM Persons WHERE person_id IN ("+parameter1+","+parameter2+")";
db.rawQuery(query);
``` |
12,242,879 | In my project I have to select multiple values and pass it to a query. i.e page1 contains checkboxes. I am storing the selected checkbox id's into an array.
I am shuffling that array and getting the values randomly. Now I need to pass these random values to a query. Using IN operator in database I can pass the values
... | 2012/09/03 | [
"https://Stackoverflow.com/questions/12242879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1455252/"
] | `String query = "SELECT * FROM Persons WHERE person_id IN (" + TextUtils.join(",", chksublist) + ")";`
But shuffling the `chksublist` before sending it to your SQL query has no impact on the result set you get from SQL. It will not randomly permute your results. Remove `Collections.shuffle(chksublist);` and use
`Stri... | see how values are dynamicaly passed
```
// Getting single contact
public Contact getContact(int id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(TABLE_CONTACTS, new String[] { KEY_ID,
KEY_NAME, KEY_PH_NO }, KEY_ID + "=?",
new String[] { String.valueOf(id) }, null, nul... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.