qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
48,095,096 | Default `font-size` for my code is equivalent to `10px` or `0.625em`. So as per this rule, to set the font size of `<p>` as `7px` I can use `0.7em`. But in my case browser is taking the fixed font size of `9px` (checked in "computed" section of browser) even if I decrease the font size of `<p>` as `0.5em` or less.
[](https://i.stack.imgur.com/7vqRv.png)
```css
body {
font-size: 0.625em;
}
h1 {
font-size: 2.5em;
}
h2 {
font-size: 1.875em;
}
p {
font-size: 0.7em;
}
```
```html
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<p>This is a paragraph.</p>
<p>Specifying the font-size in em allows all major browsers to resize the text.
Unfortunately, there is still a problem with older versions of IE. When resizing the text, it becomes larger/smaller than it should.</p>
``` | 2018/01/04 | [
"https://Stackoverflow.com/questions/48095096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8873934/"
] | You can not set
```
body {
font-size: 0.625em;
}
```
You need to set `10px` to the body font-size. **Then the calculations will work as you expected with using `em`. Else it will take the default `font-size` set by the browser.**
```css
body {
font-size: 10px;
}
h1 {
font-size: 2.5em;
}
h2 {
font-size: 1.875em;
}
p {
font-size: 0.7em;
}
```
```html
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<p>This is a paragraph.</p>
<p>Specifying the font-size in em allows all major browsers to resize the text.
Unfortunately, there is still a problem with older versions of IE. When resizing the text, it becomes larger/smaller than it should.</p>
```
Read more about how to set [em font-sizes here](https://developer.mozilla.org/en-US/docs/Web/CSS/font-size?#Ems) | As you say ***font size of p as 7px I can use 0.7em***, which is not correct because here your default font size is 16px. if
```
10px == 0.625em then
7px = (0.625/10)*7em = 0.4375em
```
And if you are using **`10px`** as your default font, you have to set the **`body`** and **`html`** font size in **`px`** i.e. **`10px`**
```
html,
body {
font-size: 10px;
}
```
Check below snippet
```css
html{
font-size: 10px;
}
h1 {
font-size: 2.5em;
}
h2 {
font-size: 1.875em;
}
p {
font-size: 0.7em;
}
```
```html
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<p>This is a paragraph.</p>
<p>Specifying the font-size in em allows all major browsers to resize the text. Unfortunately, there is still a problem with older versions of IE. When resizing the text, it becomes larger/smaller than it should.</p>
``` |
85,572 | When you ride in a heavy rain, you can easily wear a Gore-tex jacket an to stay "mostly" dry on top and some kind of overshoes to achieve the same for the shoes/socks. However, noone talks about getting wet for the bib shorts? Is there any reasonable solution? Especially on brevets or bikepackings? | 2022/08/27 | [
"https://bicycles.stackexchange.com/questions/85572",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/66520/"
] | There are a few options. I've tried them all, they all have different pros/cons
1. Get wet but use a very heavy chamois cream that doesnt wash away easily
2. Waterproof cycling trousers exist. They work well, but are expensive and often hard to find in stock as they are a fairly low volume item
3. MTB shorts are available with various levels of water repellency
4. Bib shorts made with water repellent material exist | You have three options
1. Ride and get wet.
2. Ride, try to stay dry, get wet anyway.
3. Don't ride.
You can get wet from rain falling down, road water flying up, and sweatting on the inside
**Ambient temperature** The main reason I might try and stay dry is the temperature. Riding in the rain at 25 degrees C is pleasant, where as 0 degrees C is unpleasant and should be avoided.
**Trying to stay dry** I wear a waterproof jacket and some cheaper waterproof pants. After a spirited commute, I am frequently drenched in my own sweat and the jacket is wetter on the inside than the outside should the rain let up.
Some rains demand this outfit. When it warm rain it is nice to simply ride and use the rain as additional cooling.
**Let yourself get wet** As above, rainwater is extra cooling. Downside is that it can add weight which can stretch clothes if you get too wet.
Friction is reduced between hands and brake levers/handlebars/etc while increasing at the top of your leg/inseam and saddle. That can be annoying.
**Road water** is dirty, containing at least mud, and potentially grit and oils and anything else that is laying on the roadway.
The best defence against road water is fenders/mudguards. Ideally these would be long enough to give 190-200 degrees of coverage over the rear wheel, and 110-120 degrees of coverage on the front wheel. Short ones help less than long ones. The guard should also be close to the tyre and wide enough to catch spray off the sides.
"ass savers" are perhaps 10% as good as a full guard.
---
Personally on a hard ride/race, I'll wear bib shorts, a thermal shirt as a base layer, and a riding jersey on that.
Arm warmers, full finger gloves, as well as either tights or leg warmers if I expect to take them off later. I also wear neoprene shoe covers and carry a light folding raincoat. Remember to put the pant's cuff over the top of the shoe covers for water shedding.
I also have a cycling cap with ear flaps, and a neck buff. With cycling glasses and prescription lenses, the only thing exposed is my nose - covering that with the buff tends to fog up the glasses.
Another trick is to use silicon spray in an aerosol can to douse your waterproof items like jackets, but you can also increase the water shedding of non waterproof items by misting them with silicon. Don't soak the cloth, just a light layer on the surfaces that get wettest. Note this may upset some cloth and cause discolouration so test before you commit. |
85,572 | When you ride in a heavy rain, you can easily wear a Gore-tex jacket an to stay "mostly" dry on top and some kind of overshoes to achieve the same for the shoes/socks. However, noone talks about getting wet for the bib shorts? Is there any reasonable solution? Especially on brevets or bikepackings? | 2022/08/27 | [
"https://bicycles.stackexchange.com/questions/85572",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/66520/"
] | There are a few options. I've tried them all, they all have different pros/cons
1. Get wet but use a very heavy chamois cream that doesnt wash away easily
2. Waterproof cycling trousers exist. They work well, but are expensive and often hard to find in stock as they are a fairly low volume item
3. MTB shorts are available with various levels of water repellency
4. Bib shorts made with water repellent material exist | Take a change of clothes, in a sealed bag.
Naturally, this will only work in specific circumstances, here are a few that come to my mind:
1. It rained heavily but now cleared up fully, and on the balance of likelihoods, it seems worthwhile to get changed (perhaps keep an eye on the latest hourly forecast).
2. You're cycling on tarmac which dries up quickly.
3. You have somewhere to get changed without offending.
I'm sure there are more things to consider. And it's clearly much easier for shorts than shoes. |
85,572 | When you ride in a heavy rain, you can easily wear a Gore-tex jacket an to stay "mostly" dry on top and some kind of overshoes to achieve the same for the shoes/socks. However, noone talks about getting wet for the bib shorts? Is there any reasonable solution? Especially on brevets or bikepackings? | 2022/08/27 | [
"https://bicycles.stackexchange.com/questions/85572",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/66520/"
] | There are a few options. I've tried them all, they all have different pros/cons
1. Get wet but use a very heavy chamois cream that doesnt wash away easily
2. Waterproof cycling trousers exist. They work well, but are expensive and often hard to find in stock as they are a fairly low volume item
3. MTB shorts are available with various levels of water repellency
4. Bib shorts made with water repellent material exist | If it is raining and warm, I don't do anything to guard against the rain. If it is raining and cool, though, I don't mess around. On a very long effort, your body's ability to regulate its temperature decreases; hard rain and cool temperatures can leave you hypothermic.
In addition to a jacket and rain-resistant bibs, here's what I would pack:
* Full-finger rain-resistant gloves
* Beanie that fits under helmet
* Rain-resistant leg warmers
* Booties. There are some booties that are bulky neoprene and others that are are a thin rubbery layer.
You can probably cram all this into a medium-sized frame bag. |
85,572 | When you ride in a heavy rain, you can easily wear a Gore-tex jacket an to stay "mostly" dry on top and some kind of overshoes to achieve the same for the shoes/socks. However, noone talks about getting wet for the bib shorts? Is there any reasonable solution? Especially on brevets or bikepackings? | 2022/08/27 | [
"https://bicycles.stackexchange.com/questions/85572",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/66520/"
] | For 200 km or even 300 km brevets I just get wet legs, but I don't suffer too much from the cold. I have had plenty of rides of that length when I've been unable to dry out for the whole ride, and a couple where the rain has been incessant for the whole ride. Anything longer (and indeed most of my 300s) tends to be at drier times of year when you might get soaked once or twice but you dry out.
Multiple days out in the rain is a challenge whether trekking on foot or bikepacking/touring with a tent. There's a reason people tend to tour in seasons where respite from the rain can be expected. If I was expecting a wet tour I'd look into [Rainlegs](https://www.rainlegs.com/en/home) though wearing waterproof overtrousers as used for hiking can work at low effort (with elastic straps to keep them out of the chain). A pair of MTB-style shorts cut down from waterproof trousers might also be useful.
For multi-day stuff it's important to sleep with dry skin, and have clean dry shorts to wear the next day. This is likely to mean carrying more and/or staying in less remote places every couple of days so there are laundry facilities. Constant wetness softens skin and makes it fragile.
Lower down, shoe covers only hold serious rain off for a little while. They're better against bare skin, so under water-repellent tights or leg warmers, but if (like me) you've got big feet and skinny ankles they've got no hope of sealing completely. Waterproof socks are more effective but only in conditions where you'll be sweating very little | You have three options
1. Ride and get wet.
2. Ride, try to stay dry, get wet anyway.
3. Don't ride.
You can get wet from rain falling down, road water flying up, and sweatting on the inside
**Ambient temperature** The main reason I might try and stay dry is the temperature. Riding in the rain at 25 degrees C is pleasant, where as 0 degrees C is unpleasant and should be avoided.
**Trying to stay dry** I wear a waterproof jacket and some cheaper waterproof pants. After a spirited commute, I am frequently drenched in my own sweat and the jacket is wetter on the inside than the outside should the rain let up.
Some rains demand this outfit. When it warm rain it is nice to simply ride and use the rain as additional cooling.
**Let yourself get wet** As above, rainwater is extra cooling. Downside is that it can add weight which can stretch clothes if you get too wet.
Friction is reduced between hands and brake levers/handlebars/etc while increasing at the top of your leg/inseam and saddle. That can be annoying.
**Road water** is dirty, containing at least mud, and potentially grit and oils and anything else that is laying on the roadway.
The best defence against road water is fenders/mudguards. Ideally these would be long enough to give 190-200 degrees of coverage over the rear wheel, and 110-120 degrees of coverage on the front wheel. Short ones help less than long ones. The guard should also be close to the tyre and wide enough to catch spray off the sides.
"ass savers" are perhaps 10% as good as a full guard.
---
Personally on a hard ride/race, I'll wear bib shorts, a thermal shirt as a base layer, and a riding jersey on that.
Arm warmers, full finger gloves, as well as either tights or leg warmers if I expect to take them off later. I also wear neoprene shoe covers and carry a light folding raincoat. Remember to put the pant's cuff over the top of the shoe covers for water shedding.
I also have a cycling cap with ear flaps, and a neck buff. With cycling glasses and prescription lenses, the only thing exposed is my nose - covering that with the buff tends to fog up the glasses.
Another trick is to use silicon spray in an aerosol can to douse your waterproof items like jackets, but you can also increase the water shedding of non waterproof items by misting them with silicon. Don't soak the cloth, just a light layer on the surfaces that get wettest. Note this may upset some cloth and cause discolouration so test before you commit. |
85,572 | When you ride in a heavy rain, you can easily wear a Gore-tex jacket an to stay "mostly" dry on top and some kind of overshoes to achieve the same for the shoes/socks. However, noone talks about getting wet for the bib shorts? Is there any reasonable solution? Especially on brevets or bikepackings? | 2022/08/27 | [
"https://bicycles.stackexchange.com/questions/85572",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/66520/"
] | For 200 km or even 300 km brevets I just get wet legs, but I don't suffer too much from the cold. I have had plenty of rides of that length when I've been unable to dry out for the whole ride, and a couple where the rain has been incessant for the whole ride. Anything longer (and indeed most of my 300s) tends to be at drier times of year when you might get soaked once or twice but you dry out.
Multiple days out in the rain is a challenge whether trekking on foot or bikepacking/touring with a tent. There's a reason people tend to tour in seasons where respite from the rain can be expected. If I was expecting a wet tour I'd look into [Rainlegs](https://www.rainlegs.com/en/home) though wearing waterproof overtrousers as used for hiking can work at low effort (with elastic straps to keep them out of the chain). A pair of MTB-style shorts cut down from waterproof trousers might also be useful.
For multi-day stuff it's important to sleep with dry skin, and have clean dry shorts to wear the next day. This is likely to mean carrying more and/or staying in less remote places every couple of days so there are laundry facilities. Constant wetness softens skin and makes it fragile.
Lower down, shoe covers only hold serious rain off for a little while. They're better against bare skin, so under water-repellent tights or leg warmers, but if (like me) you've got big feet and skinny ankles they've got no hope of sealing completely. Waterproof socks are more effective but only in conditions where you'll be sweating very little | Take a change of clothes, in a sealed bag.
Naturally, this will only work in specific circumstances, here are a few that come to my mind:
1. It rained heavily but now cleared up fully, and on the balance of likelihoods, it seems worthwhile to get changed (perhaps keep an eye on the latest hourly forecast).
2. You're cycling on tarmac which dries up quickly.
3. You have somewhere to get changed without offending.
I'm sure there are more things to consider. And it's clearly much easier for shorts than shoes. |
85,572 | When you ride in a heavy rain, you can easily wear a Gore-tex jacket an to stay "mostly" dry on top and some kind of overshoes to achieve the same for the shoes/socks. However, noone talks about getting wet for the bib shorts? Is there any reasonable solution? Especially on brevets or bikepackings? | 2022/08/27 | [
"https://bicycles.stackexchange.com/questions/85572",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/66520/"
] | For 200 km or even 300 km brevets I just get wet legs, but I don't suffer too much from the cold. I have had plenty of rides of that length when I've been unable to dry out for the whole ride, and a couple where the rain has been incessant for the whole ride. Anything longer (and indeed most of my 300s) tends to be at drier times of year when you might get soaked once or twice but you dry out.
Multiple days out in the rain is a challenge whether trekking on foot or bikepacking/touring with a tent. There's a reason people tend to tour in seasons where respite from the rain can be expected. If I was expecting a wet tour I'd look into [Rainlegs](https://www.rainlegs.com/en/home) though wearing waterproof overtrousers as used for hiking can work at low effort (with elastic straps to keep them out of the chain). A pair of MTB-style shorts cut down from waterproof trousers might also be useful.
For multi-day stuff it's important to sleep with dry skin, and have clean dry shorts to wear the next day. This is likely to mean carrying more and/or staying in less remote places every couple of days so there are laundry facilities. Constant wetness softens skin and makes it fragile.
Lower down, shoe covers only hold serious rain off for a little while. They're better against bare skin, so under water-repellent tights or leg warmers, but if (like me) you've got big feet and skinny ankles they've got no hope of sealing completely. Waterproof socks are more effective but only in conditions where you'll be sweating very little | If it is raining and warm, I don't do anything to guard against the rain. If it is raining and cool, though, I don't mess around. On a very long effort, your body's ability to regulate its temperature decreases; hard rain and cool temperatures can leave you hypothermic.
In addition to a jacket and rain-resistant bibs, here's what I would pack:
* Full-finger rain-resistant gloves
* Beanie that fits under helmet
* Rain-resistant leg warmers
* Booties. There are some booties that are bulky neoprene and others that are are a thin rubbery layer.
You can probably cram all this into a medium-sized frame bag. |
64,532,965 | PS C:\Users\BM KHAN\react-guide> npm install --save radium
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: react-guide@0.1.0
npm ERR! Found: react@17.0.1
npm ERR! node\_modules/react
npm ERR! react@"^17.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from radium@0.26.1
npm ERR! node\_modules/radium
npm ERR! radium@"\*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\BM KHAN\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\BM KHAN\AppData\Local\npm-cache\_logs\2020-10-26T07\_23\_09\_921Z-debug.log
PS C:\Users\BM KHAN\react-guide> | 2020/10/26 | [
"https://Stackoverflow.com/questions/64532965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14520336/"
] | It worked for me , I was having the same problem
>
> npm install --save radium --legacy-peer-deps
>
>
> | This worked for me I also have the same problem. If we read the errors currently we can resolve them easily
[](https://i.stack.imgur.com/lHNyL.png)
```
npm install --save radium --legacy-peer-deps
``` |
64,532,965 | PS C:\Users\BM KHAN\react-guide> npm install --save radium
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: react-guide@0.1.0
npm ERR! Found: react@17.0.1
npm ERR! node\_modules/react
npm ERR! react@"^17.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from radium@0.26.1
npm ERR! node\_modules/radium
npm ERR! radium@"\*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\BM KHAN\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\BM KHAN\AppData\Local\npm-cache\_logs\2020-10-26T07\_23\_09\_921Z-debug.log
PS C:\Users\BM KHAN\react-guide> | 2020/10/26 | [
"https://Stackoverflow.com/questions/64532965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14520336/"
] | It worked for me , I was having the same problem
>
> npm install --save radium --legacy-peer-deps
>
>
> | ```
npm install --save radium --force
``` |
64,532,965 | PS C:\Users\BM KHAN\react-guide> npm install --save radium
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: react-guide@0.1.0
npm ERR! Found: react@17.0.1
npm ERR! node\_modules/react
npm ERR! react@"^17.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from radium@0.26.1
npm ERR! node\_modules/radium
npm ERR! radium@"\*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\BM KHAN\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\BM KHAN\AppData\Local\npm-cache\_logs\2020-10-26T07\_23\_09\_921Z-debug.log
PS C:\Users\BM KHAN\react-guide> | 2020/10/26 | [
"https://Stackoverflow.com/questions/64532965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14520336/"
] | This worked for me I also have the same problem. If we read the errors currently we can resolve them easily
[](https://i.stack.imgur.com/lHNyL.png)
```
npm install --save radium --legacy-peer-deps
``` | ```
npm install --save radium --force
``` |
46,548,006 | I have array in my php file:
```
$invoices_arr = [];
foreach ($invoices as $key=>$invoice){
$invoices_arr[$key]['id']=$invoice->get_id();
$invoices_arr[$key]['code_text']=$invoice->get_code_text();
$invoices_arr[$key]['invoice_name']=$invoice->get_invoice_name();
$invoices_arr[$key]['status_invoice']=$invoice->get_status_invoice();
$invoices_arr[$key]['attachments']=$invoice->get_attachments();
}
echo json_encode(['invoices'=>$invoices_arr]);
```
My ajax call:
```
$.ajax({
data:{lead_id:$("#lead_id").val()},
url: sJSUrlGetAllLeadInvoices,
success: function (data) {
var obj = jQuery.parseJSON(data);
$("#all_invoice_table tbody").empty();
$(obj.invoices).each(function(key,value){
$('#all_invoice_table').append('<tr><td>'+value.invoice_name+'</td><td class="invoice_status">'+value.status_invoice+'<td>attt</td><td><button id="'+value.id+'" class="edit_invoice_'+value.id+'">Edit invoice</button</td><td><button class="send_invoice_btn_'+value.id+'">Send invoice</button></td><td><img class="delete_invoice_'+value.id+'" src="/images/icons/delete.gif"></td><td class="invoice_hidden_column_'+value.id+'">'+value.code_text+'</td></tr>');
});
}
});
```
In field `value.attachments` there is php serialize array, for example, string "a:1:{i:0;s:36:"../../pdf\_invoices/2017-10-10015.pdf";}" .
How can I convert this string to array in js?
I try do it:
```
var mas=JSON.parse(value.attachments);
```
But I get error **SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data**
How can I solve it? Thanks for any help. | 2017/10/03 | [
"https://Stackoverflow.com/questions/46548006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8714851/"
] | I guess this is what you want. A matrix of 2 columns and 4 rows and in each "cell" of this matrix you get the histogram for a column with the categories overlapped.
```
import pandas as pd
from matplotlib import pyplot as plt
df = pd.DataFrame({'V1':[1,2,3,4,5,6],
'V2': [43,35,6,7,31,34],
'V3': [23,75,67,23,56,32],
'V4': [23,45,67,63,56,32],
'V5': [23,5,67,23,6,2],
'V6': [23,78,67,76,56,2],
'V7': [23,45,67,53,56,32],
'V8': [5,5,5,5,5,5],
'cat': ["A","B","C","A","B","B"],})
# Define your subplots matrix.
# In this example the fig has 4 rows and 2 columns
fig, axes = plt.subplots(4, 2, figsize=(12, 8))
# This approach is better than looping through df.cat.unique
for g, d in df.groupby('cat'):
d.hist(alpha = 0.5, ax=axes, label=g)
# Just outputing the legend for each column in fig
for c1, c2 in axes:
c1.legend()
c2.legend()
plt.show()
```
Here's the output:
[](https://i.stack.imgur.com/TMwYa.png) | The last code from the question should give you a warning about the axes being cleared - essentially the phenomenon you observe.
`UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared`
Now the idea could be to let pandas plot each histogram in its own axes, but to make sure that each of those is the same, namely `ax`. This can be done by passing a list of 8 times `ax`, `ax =[ax]*8`:
```
fig, ax = plt.subplots(figsize=(12,8),)
for i in df['cat'].unique():
df[df['cat']==i].hist(ax =[ax]*8, alpha = 0.5, label = i)
ax.legend()
plt.show()
```
The result will look very crowded, but this is apparently desired.
[](https://i.stack.imgur.com/SD15i.png) |
34,892,781 | I have a question about this code. It is supposed to keep score of a quiz.
```
function point() {
var questions = document.getElementsByTagName("input");
var value_list = [];
var point = 0;
for (var i = 0; i < questions.length; i++) {
value_list.push(questions[i].value);
if (questions[i].checked) {
point += Number(value_list[i])
}
}
``` | 2016/01/20 | [
"https://Stackoverflow.com/questions/34892781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5783294/"
] | ```
var questions = document.getElementsByTagName("input");
```
Get all elements that have the tag `<input>`.`questions` is an array of all those elements.
```
var value_list = [];
var point = 0;
```
Initialize an array and a variable.
```
for (var i = 0; i < questions.length; i++) {
```
For all the input elements in the `questions` array do the following.
```
value_list.push(questions[i].value);
```
1) Push the value of the input element into the value\_list array.
```
if (questions[i].checked) {
point += Number(value_list[i])
}
```
2) If the input is checked then add the point.The function `Number` will convert the value in `value_list[i]` to a number and then add it the points.we pass the value of the checked input tag as argument to the function.
The input in this case is a checkbox which has attributes checked and value.
```
<input type="checkbox" name="vehicle" value="Bike">
``` | ```
function point() {
var questions = document.getElementsByTagName("input");
//This line gets all the input tags on your page. Instead you can give all your questions a common class and do this to get count
document.getElementsByClass("className");
var value_list = []; //creates an empty array value_list.
var point = 0; //intializes a variable called point = 0 for keeping the count.
for (var i = 0; i < questions.length; i++) {
//Runs a for loop starting from 0 to number of questions on your screen less 1. So if you have 5 input tags this loop will run from 0 to 4.
value_list.push(questions[i].value); //pushes the values of the questions into the array value_list.
if (questions[i].checked) { //If questions have checked property then the point variable is trying to store a number.
point += Number(value_list[i])
}
}
``` |
34,892,781 | I have a question about this code. It is supposed to keep score of a quiz.
```
function point() {
var questions = document.getElementsByTagName("input");
var value_list = [];
var point = 0;
for (var i = 0; i < questions.length; i++) {
value_list.push(questions[i].value);
if (questions[i].checked) {
point += Number(value_list[i])
}
}
``` | 2016/01/20 | [
"https://Stackoverflow.com/questions/34892781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5783294/"
] | ```
var questions = document.getElementsByTagName("input");
```
Get all elements that have the tag `<input>`.`questions` is an array of all those elements.
```
var value_list = [];
var point = 0;
```
Initialize an array and a variable.
```
for (var i = 0; i < questions.length; i++) {
```
For all the input elements in the `questions` array do the following.
```
value_list.push(questions[i].value);
```
1) Push the value of the input element into the value\_list array.
```
if (questions[i].checked) {
point += Number(value_list[i])
}
```
2) If the input is checked then add the point.The function `Number` will convert the value in `value_list[i]` to a number and then add it the points.we pass the value of the checked input tag as argument to the function.
The input in this case is a checkbox which has attributes checked and value.
```
<input type="checkbox" name="vehicle" value="Bike">
``` | ```
function point() {
var questions = document.getElementsByTagName("input");
```
The getElementsByTagName() method accesses all elements with the specified tagname.
```
var value_list = [];
```
Above line creates the empty list having name value\_list.
```
var point = 0;
```
Set the variable point=0; Purpose of this variable is storing final result.
```
for (var i = 0; i < questions.length; i++) {
#var i = 0 => sets a variable before the loop starts (var i = 0).
#i < questions.length => defines the condition for the loop to run (i must be less than question.length). questions.length calculate total number of question.
#i++ => increases a value (i++) each time the code block in the loop has been executed.
value_list.push(questions[i].value);
```
The push() method adds new items to the end of an array.
```
if (questions[i].checked) {
point += Number(value_list[i])
#Here point = point+ Number(value_list[i]), it means adds the new score
}
}
``` |
34,892,781 | I have a question about this code. It is supposed to keep score of a quiz.
```
function point() {
var questions = document.getElementsByTagName("input");
var value_list = [];
var point = 0;
for (var i = 0; i < questions.length; i++) {
value_list.push(questions[i].value);
if (questions[i].checked) {
point += Number(value_list[i])
}
}
``` | 2016/01/20 | [
"https://Stackoverflow.com/questions/34892781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5783294/"
] | **Line1:**
```
var questions = document.getElementsByTagName("input");
```
There are be elements with tag input in your HTML file.So you are taking those elements array using `document.getElementsByTagName("input")` and assigning in to variable questions.
**So outcome of this line is you will get a variable questions which will hold all input elements of your HTML document**.
**Line2:**
```
var value_list = [];
```
**This line is being used to define an array variable `value_list` and assigning empty array to it.**
**Line3:**
```
var point = 0;
```
Initializing variable `point` with value `0`.
**Line4 till end:**
```
// for (var i = 0; i < questions.length; i++) =>for loop syntax will iterate till the length of questions(Which is array of input elements")
```
Suppose you have two input tag elements it will iterate 2 times.
```
// value_list.push(questions[i].value);=>taking value of ith input element and pushing to "**value_list**" array variable
// if (questions[i].checked) { =>
// { checking if ith element is checked}
point += Number(value_list[i])=>
//{ converting to munber and adding to point variable.
// }
//}
```
**The result of this code will be the sum of all the values input tags have.
suppose you have an html file like below:**
```
<html><input type="checkbox" value="10">
<input type="checkbox" value="20">
</html>
```
Note that only input type of checkbox has the attribute checked.After this code will successfully executed the point will be `0 + 10 + 20`.
point will hold `value` = `30`.
Best Regards,
Priyanka | ```
function point() {
var questions = document.getElementsByTagName("input");
//This line gets all the input tags on your page. Instead you can give all your questions a common class and do this to get count
document.getElementsByClass("className");
var value_list = []; //creates an empty array value_list.
var point = 0; //intializes a variable called point = 0 for keeping the count.
for (var i = 0; i < questions.length; i++) {
//Runs a for loop starting from 0 to number of questions on your screen less 1. So if you have 5 input tags this loop will run from 0 to 4.
value_list.push(questions[i].value); //pushes the values of the questions into the array value_list.
if (questions[i].checked) { //If questions have checked property then the point variable is trying to store a number.
point += Number(value_list[i])
}
}
``` |
34,892,781 | I have a question about this code. It is supposed to keep score of a quiz.
```
function point() {
var questions = document.getElementsByTagName("input");
var value_list = [];
var point = 0;
for (var i = 0; i < questions.length; i++) {
value_list.push(questions[i].value);
if (questions[i].checked) {
point += Number(value_list[i])
}
}
``` | 2016/01/20 | [
"https://Stackoverflow.com/questions/34892781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5783294/"
] | **Line1:**
```
var questions = document.getElementsByTagName("input");
```
There are be elements with tag input in your HTML file.So you are taking those elements array using `document.getElementsByTagName("input")` and assigning in to variable questions.
**So outcome of this line is you will get a variable questions which will hold all input elements of your HTML document**.
**Line2:**
```
var value_list = [];
```
**This line is being used to define an array variable `value_list` and assigning empty array to it.**
**Line3:**
```
var point = 0;
```
Initializing variable `point` with value `0`.
**Line4 till end:**
```
// for (var i = 0; i < questions.length; i++) =>for loop syntax will iterate till the length of questions(Which is array of input elements")
```
Suppose you have two input tag elements it will iterate 2 times.
```
// value_list.push(questions[i].value);=>taking value of ith input element and pushing to "**value_list**" array variable
// if (questions[i].checked) { =>
// { checking if ith element is checked}
point += Number(value_list[i])=>
//{ converting to munber and adding to point variable.
// }
//}
```
**The result of this code will be the sum of all the values input tags have.
suppose you have an html file like below:**
```
<html><input type="checkbox" value="10">
<input type="checkbox" value="20">
</html>
```
Note that only input type of checkbox has the attribute checked.After this code will successfully executed the point will be `0 + 10 + 20`.
point will hold `value` = `30`.
Best Regards,
Priyanka | ```
function point() {
var questions = document.getElementsByTagName("input");
```
The getElementsByTagName() method accesses all elements with the specified tagname.
```
var value_list = [];
```
Above line creates the empty list having name value\_list.
```
var point = 0;
```
Set the variable point=0; Purpose of this variable is storing final result.
```
for (var i = 0; i < questions.length; i++) {
#var i = 0 => sets a variable before the loop starts (var i = 0).
#i < questions.length => defines the condition for the loop to run (i must be less than question.length). questions.length calculate total number of question.
#i++ => increases a value (i++) each time the code block in the loop has been executed.
value_list.push(questions[i].value);
```
The push() method adds new items to the end of an array.
```
if (questions[i].checked) {
point += Number(value_list[i])
#Here point = point+ Number(value_list[i]), it means adds the new score
}
}
``` |
34,892,781 | I have a question about this code. It is supposed to keep score of a quiz.
```
function point() {
var questions = document.getElementsByTagName("input");
var value_list = [];
var point = 0;
for (var i = 0; i < questions.length; i++) {
value_list.push(questions[i].value);
if (questions[i].checked) {
point += Number(value_list[i])
}
}
``` | 2016/01/20 | [
"https://Stackoverflow.com/questions/34892781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5783294/"
] | ```
// We define a new function, named point. In this case, it doesn't receive any parameters.
function point() {
// We get all the input elements, and we store it in the variable 'questions'
var questions = document.getElementsByTagName("input");
// We are creating a new empty list
var value_list = [];
// We declare a variable initialized at 0
var point = 0;
// we are going to loop over the items inside questions (all the input elements)
for (var i = 0; i < questions.length; i++) {
// We get the value of the questions of the current iteration (questions[i].value) and we store it inside the empty list
value_list.push(questions[i].value);
// If the input is checked...
if (questions[i].checked) {
// we increment the value of point with the value in value_list[i], in this case it should be the same as questions[i],
// because previously we store questions[i] inside value_list
point += Number(value_list[i])
}
}
```
You are simply looping over all the input, and if the input it's checked, you increment the `point` variable with it's value. It could be simplified in this code
```
// We define a new function, named point. In this case, it doesn't receive any parameters.
function point() {
// We get all the input elements, and we store it in the variable 'questions'
var questions = document.getElementsByTagName("input");
// We declare a variable initialized at 0
var point = 0;
// we are going to loop over the items inside questions (all the input elements)
for (var i = 0; i < questions.length; i++) {
if (questions[i].checked) {
point += Number(questions[i].value)
}
}
``` | ```
function point() {
var questions = document.getElementsByTagName("input");
//This line gets all the input tags on your page. Instead you can give all your questions a common class and do this to get count
document.getElementsByClass("className");
var value_list = []; //creates an empty array value_list.
var point = 0; //intializes a variable called point = 0 for keeping the count.
for (var i = 0; i < questions.length; i++) {
//Runs a for loop starting from 0 to number of questions on your screen less 1. So if you have 5 input tags this loop will run from 0 to 4.
value_list.push(questions[i].value); //pushes the values of the questions into the array value_list.
if (questions[i].checked) { //If questions have checked property then the point variable is trying to store a number.
point += Number(value_list[i])
}
}
``` |
34,892,781 | I have a question about this code. It is supposed to keep score of a quiz.
```
function point() {
var questions = document.getElementsByTagName("input");
var value_list = [];
var point = 0;
for (var i = 0; i < questions.length; i++) {
value_list.push(questions[i].value);
if (questions[i].checked) {
point += Number(value_list[i])
}
}
``` | 2016/01/20 | [
"https://Stackoverflow.com/questions/34892781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5783294/"
] | ```
// We define a new function, named point. In this case, it doesn't receive any parameters.
function point() {
// We get all the input elements, and we store it in the variable 'questions'
var questions = document.getElementsByTagName("input");
// We are creating a new empty list
var value_list = [];
// We declare a variable initialized at 0
var point = 0;
// we are going to loop over the items inside questions (all the input elements)
for (var i = 0; i < questions.length; i++) {
// We get the value of the questions of the current iteration (questions[i].value) and we store it inside the empty list
value_list.push(questions[i].value);
// If the input is checked...
if (questions[i].checked) {
// we increment the value of point with the value in value_list[i], in this case it should be the same as questions[i],
// because previously we store questions[i] inside value_list
point += Number(value_list[i])
}
}
```
You are simply looping over all the input, and if the input it's checked, you increment the `point` variable with it's value. It could be simplified in this code
```
// We define a new function, named point. In this case, it doesn't receive any parameters.
function point() {
// We get all the input elements, and we store it in the variable 'questions'
var questions = document.getElementsByTagName("input");
// We declare a variable initialized at 0
var point = 0;
// we are going to loop over the items inside questions (all the input elements)
for (var i = 0; i < questions.length; i++) {
if (questions[i].checked) {
point += Number(questions[i].value)
}
}
``` | ```
function point() {
var questions = document.getElementsByTagName("input");
```
The getElementsByTagName() method accesses all elements with the specified tagname.
```
var value_list = [];
```
Above line creates the empty list having name value\_list.
```
var point = 0;
```
Set the variable point=0; Purpose of this variable is storing final result.
```
for (var i = 0; i < questions.length; i++) {
#var i = 0 => sets a variable before the loop starts (var i = 0).
#i < questions.length => defines the condition for the loop to run (i must be less than question.length). questions.length calculate total number of question.
#i++ => increases a value (i++) each time the code block in the loop has been executed.
value_list.push(questions[i].value);
```
The push() method adds new items to the end of an array.
```
if (questions[i].checked) {
point += Number(value_list[i])
#Here point = point+ Number(value_list[i]), it means adds the new score
}
}
``` |
60,242,762 | I want to put a CDN in front of a Google Cloud Run service in order to cache some responses.
Right now it seems Cloud CDN requires a Google Load Balancer, and they cannot point to a Google Cloud Run service (<https://github.com/ahmetb/cloud-run-faq/tree/e7a0fc43d3054456613c09e073db289ddf76dd33#how-can-i-configure-cdn-for-cloud-run-services>).
Is there another way? | 2020/02/15 | [
"https://Stackoverflow.com/questions/60242762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1685538/"
] | [updated]
You can use Cloud CDN with Cloud Run via [Google Cloud Load Balancer](https://cloud.google.com/load-balancing/docs/negs/serverless-neg-concepts) | Additionally it's possible without using the Load Balancer by serving it through a Firebase app by adding a `Cache-Control` [header](https://firebase.google.com/docs/hosting/manage-cache#set_cache-control) and via a [rewrite rule](https://firebase.google.com/docs/hosting/cloud-run#direct_requests_to_container) in `firebase.json` (via the unofficial [Cloud Run FAQ](https://github.com/ahmetb/cloud-run-faq#how-can-i-configure-cdn-for-cloud-run-services)). |
137,492 | I downloaded the desktop ISO for Ubuntu 12.04 and burned the ISO to a DVD. When it boots, it loads up to the splash screen and stops until I get impatient and hit enter then it brings uup the language selection screen after which it loads the GUI with the options where I choose install. At this point the screen goes blank with a flashing cursor on the upper left corner of the screen and that is all it does. How do I get it to install.
System Config
* Motherboard: Asus A8n-SLI Deluxe
* CPU: AMD 3500 Athalon 64
* Ram: 1 GB
* HD: 300 GB
* Operating System: Windows 8 | 2012/05/15 | [
"https://askubuntu.com/questions/137492",
"https://askubuntu.com",
"https://askubuntu.com/users/63667/"
] | As Jorge Castro has said, this should be [a bug report](https://askubuntu.com/questions/5121/how-do-i-report-a-bug).
...Unless the problem is due to bad installation media, or is a known graphics problem. You gave us some information about your computer, but you did not tell us the make and model of your graphics card. You should edit your question to include that. If you end up reporting a bug, you should make sure to include that information in the bug report as well.
You should [MD5 test](https://help.ubuntu.com/community/HowToMD5SUM) the Ubuntu `.iso` you downloaded. If that fails, it means the `.iso` file is corrupted, so you'll need to download it again and start over.
If that succeeds, then verify the installation media (whether it's a CD/DVD or USB flash drive). You can use [these instructions](http://zootlinux.blogspot.com/2010/05/check-disc-for-defects-in-ubuntu-1004.html).
If no errors are found, then try using the [`nomodeset` kernel boot option](http://ubuntuforums.org/showthread.php?t=1613132). That can work around some graphics card problems. If that does the trick, you can set `nomodeset` permanently (also using the instructions available through that link). | Same Thing. It could be that your ACPI is not supported.
[Disable the new card](http://pastebin.ubuntu.com/995187/) , [or disable ACPI.](http://www.ehow.com/how_7641485_edit-acpi-bios.html) Use the second option if you can't find "New Card Interface".
You can also add the `acpi = off` or the `nolapic` parameter to boot properly. |
137,492 | I downloaded the desktop ISO for Ubuntu 12.04 and burned the ISO to a DVD. When it boots, it loads up to the splash screen and stops until I get impatient and hit enter then it brings uup the language selection screen after which it loads the GUI with the options where I choose install. At this point the screen goes blank with a flashing cursor on the upper left corner of the screen and that is all it does. How do I get it to install.
System Config
* Motherboard: Asus A8n-SLI Deluxe
* CPU: AMD 3500 Athalon 64
* Ram: 1 GB
* HD: 300 GB
* Operating System: Windows 8 | 2012/05/15 | [
"https://askubuntu.com/questions/137492",
"https://askubuntu.com",
"https://askubuntu.com/users/63667/"
] | I've had a similar issue and it seems that it is related to the Nvidia card used. I have found the following workaround:
1. Insert the USB stick/CD disk and, as soon as you see a small icon at the bottom of the screen, press Enter.
2. Choose your language
3. Press F6 (More options).
4. Select "nomodeset" and press Enter (an "x" will appear next to this option).
5. Choose "Install Ubuntu" and follow the usual instalation process.
The install screens will appear with low quality, when once Ubuntu is fully installed, the screen will appear OK.
Good luck! | Same Thing. It could be that your ACPI is not supported.
[Disable the new card](http://pastebin.ubuntu.com/995187/) , [or disable ACPI.](http://www.ehow.com/how_7641485_edit-acpi-bios.html) Use the second option if you can't find "New Card Interface".
You can also add the `acpi = off` or the `nolapic` parameter to boot properly. |
72,821,565 | bellow is my code, its written in springboot but im having trouble trying to write it in webflux. im using mono but im not sure how i can log info in mono or how i can return a responseEntity using mono either.
```
@GetMapping("/helloWorld")
public ResponseEntity helloWorld() {
log.info("Entered hello world");
return ResponseEntity.ok("Hello World");
}
```
there is not much i did in webflux but this is how far i got
```
@GetMapping("/helloWorld")
public Mono<ResponseEntity> helloWorld() {
// log.info("Entered hello world in controller");
Mono<String> defaultMono = Mono.just("Entered hello world").log();
defaultMono.log();
// return ResponseEntity.ok("Hello World ");
}
``` | 2022/06/30 | [
"https://Stackoverflow.com/questions/72821565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18614455/"
] | Your function should return a `Mono` (single resource) or a `Flux` (collection resource).
```
@GetMapping("/helloWorld")
public Mono<String> helloWorld() {
log.info("Entered hello world");
return Mono.just("Hello World");
}
```
You should also make sure you have `spring-boot-starter-webflux` in your dependencies.
for example, maven pom:
```
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
``` | ```
@GetMapping("/helloWorld")
public Mono<ResponseEntity<String>> helloWorld() {
log.info("Entered hello world");
return Mono.just(ResponseEntity.ok("Hello World"));
}
```
May suggest reading the spring webflux [docs](https://docs.spring.io/spring-framework/docs/current/reference/html/web-reactive.html) as well Project Reactor [docs](https://projectreactor.io/).
Also if what you need is to log all the reactive stream I'd would suggest following code.
```
@GetMapping("/helloWorld")
public Mono<ResponseEntity<String>> helloWorld() {
return Mono.just("Entered hello world in controller").log().map(s -> ResponseEntity.ok(s));
}
```
Some good spring webflux example can be found on internet, such: [Building Async REST APIs with Spring WebFlux](https://howtodoinjava.com/spring-webflux/spring-webflux-tutorial/) |
31,567,002 | When launching the application a Failures manifest malformed error occurs what is the problem in my manifest file?
I've been looking around and i've already checked for:
1. I've checked for capitalization
2. The packages are set properly
3. All the libraries for Parse and facebook has been imported properly.
(or maybe i missed out on something)
I've also tried commenting out parts to see if it would compile though with no avail.
I've also ran a validate and these errors were shown
```
Error:(1, 56) schema_reference.4: Failed to read schema document 'null', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
Error:(3, 38) cvc-elt.1: Cannot find the declaration of element 'manifest'.
Error:(1, 56) s4s-elt-schema-ns: The namespace of element 'x' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'.
Error:(1, 56) s4s-elt-invalid: Element 'x' is not a valid element in a schema document.
```
I don't understand those error and what Element X is.
```
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="artisedesolution.task" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- PARSE -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<supports-screens android:xlargeScreens="true" />
<supports-screens android:largeScreens="true" />
<supports-screens android:normalScreens="true" />
<permission
android:name=".permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name=".permission.C2D_MESSAGE" />
<!-- PARSE -->
<application
android:name="Utilities.AppUtilities"
android:allowBackup="true"
android:icon="@mipmap/appicon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/app_id" />
<activity
android:name=".Activities.Login"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.NoActionBar" />
<activity android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name=".Activities.Splash"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Activities.RegistrationTemplate"
android:label="@string/title_activity_registration"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".Activities.Login" />
</activity>
<activity
android:name=".Activities.Task"
android:label="Task"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".Activities.SignUp"
android:label="@string/title_activity_sign_up"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".Activities.Login" />
</activity>
<activity
android:name=".Activities.ClaimCode"
android:label="Pocket"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".Activities.Task" />
</activity>
<activity
android:name=".Activities.Join"
android:label="@string/title_activity_join"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".Activities.Task" />
</activity>
<activity
android:name=".Activities.TaskInstantGratification"
android:label="@string/title_activity_task_instant_gratification"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".Activities.TaskRate"
android:label="@string/title_activity_task_rate"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".Activities.TaskPhoto"
android:label="@string/title_activity_task_photo"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".Activities.TaskSurprise"
android:label="@string/title_activity_task_surprise"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".Activities.TaskSurvey"
android:label="@string/title_activity_task_survey"
android:parentActivityName=".Activities.Join"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".Activities.Join" />
</activity>
<activity
android:name=".Activities.Edit"
android:label="@string/title_activity_edit"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".Activities.Join" />
</activity>
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver
android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<receiver
android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="artisedesolution.task" />
</intent-filter>
</receiver>
<activity
android:name=".Activities.About"
android:label="@string/title_activity_about"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".Activities.Task" />
</activity>
<activity
android:name=".Activities.InstructionsActivity"
android:label="@string/title_activity_instructions" >
</activity>
</application>
</manifest>
``` | 2015/07/22 | [
"https://Stackoverflow.com/questions/31567002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4875555/"
] | `(!$mod)` is true. The `if` condition is evaluated to true
You end up having:
```
if ( true || anotherCondition ) {
return;
}
```
It doesn't matter what the other condition is in this case. It evaluates to `true`
Your code is pretty close to what you need.
```
if ( (!$mod) && ($status != 'pending') && ($currentuser != $author) ) {
// if the user is not a moderator AND
// the status is not pending AND
// the user is not the owner, then
return;
}
``` | ```
if( (!$mod) && ( ($status != 'pending') && ($currentuser != $author) ) )
```
Because the user is not a mod it short circuits the second half of your if statement, by making it an and instead of or it will only return if both of the statements are true.
Another option is to do:
```
if(($mod) || ( ( ($status == 'pending') && ($current user == $author) ) ) {
// do logic here
}
else {
// user is not a mod and user is not the pending author
return;
}
``` |
27,374,156 | I am trying to find alphanumeric string including these two characters "/+" with at least 30 characters in length.
I have written this code,
```
grep "[a-zA-Z0-9\/\+]{30,}" tmp.txt
```
cat tmp.txt
```
> array('rWmyiJgKT8sFXCmMr639U4nWxcSvVFEur9hNOOvQwF/tpYRqTk9yWV2xPFBAZwAPRVs/s
ddd73ZEjfy+airfy8DtqIqKI9+dd 6hdd7soJ9iG0sGs/ld5f2GHzockoYHfh
+pAzx/t17Crf0T/2+8+reo+MU39lqCr02sAkcC1k/LzyBvSDEtu9N/9NHicr jA3SvDqg5s44DFlaNZ/8BW37fGEf2rk13S/q68OVVyzac7IT7yE7PIL9XZ/6LsmrY
KEsAmN4i/+ym8be3wwn KWGYaIB908+7W98pI6qao3iaZB
3mh7Y/nZm52hyLa37978f+PyOCqUh0Wfx2PL3vglofi0l
QVrOM1pg+mFLEIC88B706UzL4Pss7ouEo+EsrES+/qJq9Y1e/UGvwefOWSL2TJdt
```
this does not work, Mainly I wanted to have minimum length of the string to be 30 | 2014/12/09 | [
"https://Stackoverflow.com/questions/27374156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/372108/"
] | In the syntax of `grep`, the repetition braces need to be backslashed.
```
grep -o '[a-zA-Z0-9/+]\{30,\}' file
```
If you want to constrain the match to lines containing only matches to this pattern, add line-start and line-ending anchors:
```
grep '^[a-zA-Z0-9/+]\{30,\}$' file
```
The `-o` option in the first command line causes `grep` to only print the matching part, not the entire matching line. | You can use
```
grep -e "^[a-zA-Z0-9/+]\{30,\}" tmp.txt
```
---
```
grep -e "^[a-zA-Z0-9/+]\{30,\}" tmp.txt
+pAzx/t17Crf0T/2+8+reo+MU39lqCr02sAkcC1k/LzyBvSDEtu9N/9NHicr jA3SvDqg5s44DFlaNZ/8BW37fGEf2rk13S/q68OVVyzac7IT7yE7PIL9XZ/6LsmrY
3mh7Y/nZm52hyLa37978f+PyOCqUh0Wfx2PL3vglofi0l
QVrOM1pg+mFLEIC88B706UzL4Pss7ouEo+EsrES+/qJq9Y1e/UGvwefOWSL2TJdt
``` |
27,374,156 | I am trying to find alphanumeric string including these two characters "/+" with at least 30 characters in length.
I have written this code,
```
grep "[a-zA-Z0-9\/\+]{30,}" tmp.txt
```
cat tmp.txt
```
> array('rWmyiJgKT8sFXCmMr639U4nWxcSvVFEur9hNOOvQwF/tpYRqTk9yWV2xPFBAZwAPRVs/s
ddd73ZEjfy+airfy8DtqIqKI9+dd 6hdd7soJ9iG0sGs/ld5f2GHzockoYHfh
+pAzx/t17Crf0T/2+8+reo+MU39lqCr02sAkcC1k/LzyBvSDEtu9N/9NHicr jA3SvDqg5s44DFlaNZ/8BW37fGEf2rk13S/q68OVVyzac7IT7yE7PIL9XZ/6LsmrY
KEsAmN4i/+ym8be3wwn KWGYaIB908+7W98pI6qao3iaZB
3mh7Y/nZm52hyLa37978f+PyOCqUh0Wfx2PL3vglofi0l
QVrOM1pg+mFLEIC88B706UzL4Pss7ouEo+EsrES+/qJq9Y1e/UGvwefOWSL2TJdt
```
this does not work, Mainly I wanted to have minimum length of the string to be 30 | 2014/12/09 | [
"https://Stackoverflow.com/questions/27374156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/372108/"
] | In the syntax of `grep`, the repetition braces need to be backslashed.
```
grep -o '[a-zA-Z0-9/+]\{30,\}' file
```
If you want to constrain the match to lines containing only matches to this pattern, add line-start and line-ending anchors:
```
grep '^[a-zA-Z0-9/+]\{30,\}$' file
```
The `-o` option in the first command line causes `grep` to only print the matching part, not the entire matching line. | The repetition operator is not directly supported in Basic Regular Expression syntax. Use `grep -E` to enable Extended Regular Expression syntax, or backslash the braces. |
27,374,156 | I am trying to find alphanumeric string including these two characters "/+" with at least 30 characters in length.
I have written this code,
```
grep "[a-zA-Z0-9\/\+]{30,}" tmp.txt
```
cat tmp.txt
```
> array('rWmyiJgKT8sFXCmMr639U4nWxcSvVFEur9hNOOvQwF/tpYRqTk9yWV2xPFBAZwAPRVs/s
ddd73ZEjfy+airfy8DtqIqKI9+dd 6hdd7soJ9iG0sGs/ld5f2GHzockoYHfh
+pAzx/t17Crf0T/2+8+reo+MU39lqCr02sAkcC1k/LzyBvSDEtu9N/9NHicr jA3SvDqg5s44DFlaNZ/8BW37fGEf2rk13S/q68OVVyzac7IT7yE7PIL9XZ/6LsmrY
KEsAmN4i/+ym8be3wwn KWGYaIB908+7W98pI6qao3iaZB
3mh7Y/nZm52hyLa37978f+PyOCqUh0Wfx2PL3vglofi0l
QVrOM1pg+mFLEIC88B706UzL4Pss7ouEo+EsrES+/qJq9Y1e/UGvwefOWSL2TJdt
```
this does not work, Mainly I wanted to have minimum length of the string to be 30 | 2014/12/09 | [
"https://Stackoverflow.com/questions/27374156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/372108/"
] | In the syntax of `grep`, the repetition braces need to be backslashed.
```
grep -o '[a-zA-Z0-9/+]\{30,\}' file
```
If you want to constrain the match to lines containing only matches to this pattern, add line-start and line-ending anchors:
```
grep '^[a-zA-Z0-9/+]\{30,\}$' file
```
The `-o` option in the first command line causes `grep` to only print the matching part, not the entire matching line. | ```
man grep
```
Read up about the difference between between regular and extended patterns. You need the `-E` option. |
27,374,156 | I am trying to find alphanumeric string including these two characters "/+" with at least 30 characters in length.
I have written this code,
```
grep "[a-zA-Z0-9\/\+]{30,}" tmp.txt
```
cat tmp.txt
```
> array('rWmyiJgKT8sFXCmMr639U4nWxcSvVFEur9hNOOvQwF/tpYRqTk9yWV2xPFBAZwAPRVs/s
ddd73ZEjfy+airfy8DtqIqKI9+dd 6hdd7soJ9iG0sGs/ld5f2GHzockoYHfh
+pAzx/t17Crf0T/2+8+reo+MU39lqCr02sAkcC1k/LzyBvSDEtu9N/9NHicr jA3SvDqg5s44DFlaNZ/8BW37fGEf2rk13S/q68OVVyzac7IT7yE7PIL9XZ/6LsmrY
KEsAmN4i/+ym8be3wwn KWGYaIB908+7W98pI6qao3iaZB
3mh7Y/nZm52hyLa37978f+PyOCqUh0Wfx2PL3vglofi0l
QVrOM1pg+mFLEIC88B706UzL4Pss7ouEo+EsrES+/qJq9Y1e/UGvwefOWSL2TJdt
```
this does not work, Mainly I wanted to have minimum length of the string to be 30 | 2014/12/09 | [
"https://Stackoverflow.com/questions/27374156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/372108/"
] | The repetition operator is not directly supported in Basic Regular Expression syntax. Use `grep -E` to enable Extended Regular Expression syntax, or backslash the braces. | You can use
```
grep -e "^[a-zA-Z0-9/+]\{30,\}" tmp.txt
```
---
```
grep -e "^[a-zA-Z0-9/+]\{30,\}" tmp.txt
+pAzx/t17Crf0T/2+8+reo+MU39lqCr02sAkcC1k/LzyBvSDEtu9N/9NHicr jA3SvDqg5s44DFlaNZ/8BW37fGEf2rk13S/q68OVVyzac7IT7yE7PIL9XZ/6LsmrY
3mh7Y/nZm52hyLa37978f+PyOCqUh0Wfx2PL3vglofi0l
QVrOM1pg+mFLEIC88B706UzL4Pss7ouEo+EsrES+/qJq9Y1e/UGvwefOWSL2TJdt
``` |
27,374,156 | I am trying to find alphanumeric string including these two characters "/+" with at least 30 characters in length.
I have written this code,
```
grep "[a-zA-Z0-9\/\+]{30,}" tmp.txt
```
cat tmp.txt
```
> array('rWmyiJgKT8sFXCmMr639U4nWxcSvVFEur9hNOOvQwF/tpYRqTk9yWV2xPFBAZwAPRVs/s
ddd73ZEjfy+airfy8DtqIqKI9+dd 6hdd7soJ9iG0sGs/ld5f2GHzockoYHfh
+pAzx/t17Crf0T/2+8+reo+MU39lqCr02sAkcC1k/LzyBvSDEtu9N/9NHicr jA3SvDqg5s44DFlaNZ/8BW37fGEf2rk13S/q68OVVyzac7IT7yE7PIL9XZ/6LsmrY
KEsAmN4i/+ym8be3wwn KWGYaIB908+7W98pI6qao3iaZB
3mh7Y/nZm52hyLa37978f+PyOCqUh0Wfx2PL3vglofi0l
QVrOM1pg+mFLEIC88B706UzL4Pss7ouEo+EsrES+/qJq9Y1e/UGvwefOWSL2TJdt
```
this does not work, Mainly I wanted to have minimum length of the string to be 30 | 2014/12/09 | [
"https://Stackoverflow.com/questions/27374156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/372108/"
] | The repetition operator is not directly supported in Basic Regular Expression syntax. Use `grep -E` to enable Extended Regular Expression syntax, or backslash the braces. | ```
man grep
```
Read up about the difference between between regular and extended patterns. You need the `-E` option. |
154,707 | I found this Image on an obscure YouTube channel and since then I've had a hard time trying to recreate this effect . I would like it to know what's the key to achieve that lighting using photoshop , and that grunge lines texture too if possible .
thanks alot in advance :)
[](https://i.stack.imgur.com/Wd8Oi.jpg) | 2021/11/15 | [
"https://graphicdesign.stackexchange.com/questions/154707",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/170058/"
] | In simple, **rudimentary**, terms...
* A **dot** is the smallest possible spot of **ink** on paper.
* A **pixel** is the smallest possible spot of **light** on a screen.
Dots are *never* on a screen and pixels are *never* on paper.
---
This **does not** cover how pixels are *made*. Nor does it cover how ink is *made*. If you care about construction of either, then a *rudimentary* explanation is another matter, especially where pixels are concerned since they are intangible and not a *physical* object, unlike dots/ink.
Upon *output* (printing) pixels are *translated*, via mathematical formulas, to dots. Such formulas *could* mean 1 pixel = 2 dots or 2 pixel = 1 dot or 1 pixel = 15 dots... there's no *direct* correlation between pixel and dot. It's the output formula which determines how a given number of pixels *may* relate to dots. | This is more like a long comment than a answer.
The reason why you fail to get this is simply you have no need for this information. The only way you can ever understand this is if you care about the actual technical implementation details of the underlying system. In this case a printer and a screen. Since you most likely live in a all digital world you will likely never get it nor does knowing this benefit you at all.
Human language is not fixed enough that the definition of a dot is so definitive that you can not say a screen does not contain dots. The definitions of the words depend on context, audience etc. Most humans dont write academically correct language at all times. In fact they can not as the meaning of the word dot and pixel varies depending on what academic field they would follow some persons might need to cross fields. In fact monitor manufacturers sometimes call technical elemens of pixels dots.
But they are indeed different. Its just that dividing something into only two categories is a bit misleading. There are several different ways to implement screens and several ways to implement printers. Lumping them all under pixels and dots is a bit arbitrary. But as long as you talk of:
* Laser printers and offset printers
* Most generic color screens
Then it is ok to divide them in two categories. But just be aware that once you start talking about inkjets, or some exotic system like chemical or heat based printing it becomes increasingly harder to keep up the appearances that this nomlencature makes sense.
So roughly speaking saying that a dot is printed and a pixel is on screen is prudent. But i dont like that definition as it lacks predictive value. I would much rather point to the fact that we mentally treat them differently. For some reason we treat a pixel as whole all included in one even if the color channels are separate sub pixels, and may in fact be grouped in some wierd stochastic clumping. This leads to:
* A pixel has any amount of intensity in all 3 colors
* While a dot has one intensity, on or off one color.
So they do not compare very well. A pixel is more like a group of dots (called a halftone screen), so its disengenious to compare dots of a printer to pixels of a screen. Its much more honest to compare a pixel to the size of your halftone. But then that wouldn't allow so much marketting bulshit to happen. |
154,707 | I found this Image on an obscure YouTube channel and since then I've had a hard time trying to recreate this effect . I would like it to know what's the key to achieve that lighting using photoshop , and that grunge lines texture too if possible .
thanks alot in advance :)
[](https://i.stack.imgur.com/Wd8Oi.jpg) | 2021/11/15 | [
"https://graphicdesign.stackexchange.com/questions/154707",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/170058/"
] | *(It's clear now that a simple answer to this question doesn't exist. Our language simply isn't precise enough. I like the two other answers, but would still like to give an answer seen more from the viewpoint of a graphic designer.)*
A **pixel** is simply the smallest unit of an image. An image file is a collection of pixels. Nothing more than colored squares in a grid. The pixels don't have a physical size until you assign one to them and they are not necessarily the same as the pixels you see on a monitor. It depends on how you choose to display them. They are to be seen as an *abstract* idea. Pure information.
You might be making pixel art for a game. So you design your graphics by coloring a grid of pixels. But when you display the graphics, you probably scale it up several times. On the *design level*, your pixel character can still be said to consist of for example 7×12 pixels even though it might be taking up 28×48 pixels *on the screen*.
[](https://i.stack.imgur.com/FWueK.png)
So we live with different meanings of the word "pixel".
Likewise, when working with design for print, a pixel in itself have no meaning in a physical sense. In vector layout applications, you often place images at different resolutions in the same document. You can even rotate or stretch the images.
[](https://i.stack.imgur.com/UkqyL.png)
In this (very ugly) collage from InDesign, because we have defined a physical size for each image, the four images now have each their own resolution measured in *PPI* (pixels per inch). The stretched image where the pixels aren't square have a different resolution horizontally and vertically.
A **dot** is, for a graphic designer, a less ambiguous term. It's the smallest square a printing device can print. Unlike a pixel, a dot *does* have a physical size although it differs from device to device.
Most (if not all) printing devices can only print *solid* inks. Either there is color applied or there isn't. Like an old-fashioned stamp. So they need to have a rather high resolution of dots to be able to make some kind of pattern to create the *illusion* of different colors.
For example the offset machine we have at my job use printing plates that has a resolution of 2400 *DPI* (dots per inch). When a document is sent to the so-called *RIP* (raster image processor), it creates a 1-bit image of each CMYK channel. The tints of the original pixels are interpreted into different densities of *halftone screen*. These patterns are made of dots.
[](https://i.stack.imgur.com/avYNy.png)
**Note that the circles of the halftone screen are *not* what we talk about when we say "dots". The dots are the square elements which the circles consist of. Of course they are saved as pixels in an image file, but at this stage of production we still refer to them as dots.**
Below is a close-up of part of the collage from above after being interpreted by a RIP. It shows all four CMYK channels layered on top of each other. The original pixels are sort of used as masks for the halftone raster. It's one big messy soup of pixels at different PPI, normalized into halftone raster at one specific DPI.
[](https://i.stack.imgur.com/g4Czc.png)
The 1-bit images of each channel are burned onto printing plates and thereby the dots become physical. Ink is applied to the plates and then pressed onto paper. So the dots are directly transferred to paper, but the original pixels are long gone.
(I'm focusing on offset print as its my expertise. On a digital printer like an inkjet, the process is different but more or less follows the same principle.) | In simple, **rudimentary**, terms...
* A **dot** is the smallest possible spot of **ink** on paper.
* A **pixel** is the smallest possible spot of **light** on a screen.
Dots are *never* on a screen and pixels are *never* on paper.
---
This **does not** cover how pixels are *made*. Nor does it cover how ink is *made*. If you care about construction of either, then a *rudimentary* explanation is another matter, especially where pixels are concerned since they are intangible and not a *physical* object, unlike dots/ink.
Upon *output* (printing) pixels are *translated*, via mathematical formulas, to dots. Such formulas *could* mean 1 pixel = 2 dots or 2 pixel = 1 dot or 1 pixel = 15 dots... there's no *direct* correlation between pixel and dot. It's the output formula which determines how a given number of pixels *may* relate to dots. |
154,707 | I found this Image on an obscure YouTube channel and since then I've had a hard time trying to recreate this effect . I would like it to know what's the key to achieve that lighting using photoshop , and that grunge lines texture too if possible .
thanks alot in advance :)
[](https://i.stack.imgur.com/Wd8Oi.jpg) | 2021/11/15 | [
"https://graphicdesign.stackexchange.com/questions/154707",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/170058/"
] | In simple, **rudimentary**, terms...
* A **dot** is the smallest possible spot of **ink** on paper.
* A **pixel** is the smallest possible spot of **light** on a screen.
Dots are *never* on a screen and pixels are *never* on paper.
---
This **does not** cover how pixels are *made*. Nor does it cover how ink is *made*. If you care about construction of either, then a *rudimentary* explanation is another matter, especially where pixels are concerned since they are intangible and not a *physical* object, unlike dots/ink.
Upon *output* (printing) pixels are *translated*, via mathematical formulas, to dots. Such formulas *could* mean 1 pixel = 2 dots or 2 pixel = 1 dot or 1 pixel = 15 dots... there's no *direct* correlation between pixel and dot. It's the output formula which determines how a given number of pixels *may* relate to dots. | Some units are very precisely defined. Others much less. And you'll learn that some can have very different definitions depending on context or whoever you're talking to.
Supposedly, a **pixel** (**pict**ure **el**ement) is the smallest addressable unit on a **screen**. So your screen may have 1920 x 1080 pixels ("full HD"), with each pixel being able to have a different color. But RGB pixels are actually made of 3 elements (**sub-pixels**), one for each **channel**: one **red**, one **green**, one **blue** (sometimes one is doubled). And some technologies (e.g. ClearType) will actually use those subpixels individually to take advantage of the higher resolution for anti-aliasing purposes (this requires knowing how the sub-pixels are arranged, and in what order).
Some people will tell you each of those sub-pixels are dots. Others won't and tell you the pixels are dots. Some people (a minority, though) will even tell you that each of the sub-pixels are actually the pixels (this is most common coming from the actual display manufacturers).
It is worth noting that screens can vary the intensity of each sub-pixel. This is where the **bits per channel** come in. Each sub pixel is not just on (full red, green or blue) or off (black) — this would only give us a total of 8 colours: black, red, green, blue, yellow (red+green), purple (red+blue), cyan (green+blue) and white (red+green+blue).
Instead, each sub-pixel (channel) can take a number of values between the two. If you have **8 bits per channel** (so a total of 24 bits for RGB), that means **each of those sub pixels can take 256 different values** (1 bit = 2 values, 2 bits = 4 values, 3 bits = 8 values, and you continue doubling until 8 bits = 256 values). So **in total, you get 256 x 256 x 256 = 16 million colours**.
---
The **dot** is more commonly used in **print**. Initially, on black-and-white printers, where each dot can only have two states: it is white (no print/no ink) or black (print/ink).
Note that on printers (especially inkjet printers), dots can be larger than the spacing between them and overlap (usually the opposite for pixels, which if you look very very closely may have a bit of space between them), though of course older dot matrix printers usually had spaces between dots.
Contrary to screens, **printers usually don't handle anything but on or off** (printed or not, ink deposited on the paper or not). You can't get a half-printed dot. So to get grayscale, or a large variety of colours, one will use patterns (called **halftones**). To have something quite dark, you set most dots to black. To have something quite light, you'll set only a few. Likewise to get any colour you want, you'll combine multiple patterns on top of each other, one each for cyan, magenta and yellow (and usually black for best results).
If you look at large billboards e.g. in subway stations, which are produced by expanding a smaller image, you'll see those patterns quite clearly.
To achieve the same kind of results you would on a screen (in terms of number of colours), you thus need multiple dots for each individual unit you want to assign a different colour to. For instance, if you want to have the same 8 bits per channel, you need to be able to print anywhere between 0 and 255 ink dots for each unit. That requires 256 dots, or a square of 16 x 16 dots.
Note that you may think that 8 dots are enough, with each dot matching one bit, but that's not the case. In an 8-bit channel, each bit has a different weight, while all the dots have the same weight. So you need a lot more.
This means that if all those dots where arranged in a perfectly rectangular fashion, you need 16 times more dots in each direction to achieve the same result as a screen (in term of number of colours). That's one of the reasons why **professional printing usually uses resolutions of about 1200 or 2400 dots per inch**. In the end, this is not much better (for pictures) than a screen at 75 to 150 dpi (but it makes a whole lot of a difference for cases where you're printing pure black and white, like text, because you don't use halftones for those). The resolution once you take into account the pattern size is measured in... **lines per inch**.
This is the reason why, in print, in you want a specific colour but also need fine detail, you won't print in regular CMYK, but actually have a separate channel using a predefined colour with will use a specific ink. So if you want very readable purple text, you won't print it as a combination of cyan and magenta (which will give a very fine grid of dots mixing the two, and you'll end up with "fuzzy" text), but directly using purple ink. That's where Pantone colours and other palettes come in, they're actually inks (of course this is for professional offset printing, usually not on your home laser printer which can only use the standard inks).
You'll notice that I mentioned **"dots per inch" (dpi) both for printers and for screens**. Yes, "dots per inch" for screens are actually pixels per inch. Same thing for your screen's "dot pitch".
---
If that wasn't complex enough, some units also have standardised **sizes**. As for a long time computer screens had vaguely similar resolutions (in dots per inch) usually in the 70-90 dpi range, programmers often measured things in pixels rather than more absolute units like points (1/72 of an inch), mm, cm, picas, or whatnot.
The problem? When higher-resolution screens (e.g. the "Retina" screens) came along, anything that was measured in pixels would become a lot smaller if the relationship with the physical pixel was maintained, not the intended effect.
So some technologies (like CSS) **define a pixel as being something which is not a physical screen pixel! They actually define it as 1/96 of an inch**.
This gives quite interesting discussions between CSS pixels and actual physical pixels. [This page](https://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions) for instance will show you the difference between "points" used by programmers/designers (which are not actual 1/72 inch points, and in the context of CSS, are the same as CSS pixels), rendered pixels (using an integer ratio), physical pixels (after bit of downsampling the match the actual number of screen pixels) and physical size.
Welcome to the wonderful world of pixels and dots! |
154,707 | I found this Image on an obscure YouTube channel and since then I've had a hard time trying to recreate this effect . I would like it to know what's the key to achieve that lighting using photoshop , and that grunge lines texture too if possible .
thanks alot in advance :)
[](https://i.stack.imgur.com/Wd8Oi.jpg) | 2021/11/15 | [
"https://graphicdesign.stackexchange.com/questions/154707",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/170058/"
] | In simple, **rudimentary**, terms...
* A **dot** is the smallest possible spot of **ink** on paper.
* A **pixel** is the smallest possible spot of **light** on a screen.
Dots are *never* on a screen and pixels are *never* on paper.
---
This **does not** cover how pixels are *made*. Nor does it cover how ink is *made*. If you care about construction of either, then a *rudimentary* explanation is another matter, especially where pixels are concerned since they are intangible and not a *physical* object, unlike dots/ink.
Upon *output* (printing) pixels are *translated*, via mathematical formulas, to dots. Such formulas *could* mean 1 pixel = 2 dots or 2 pixel = 1 dot or 1 pixel = 15 dots... there's no *direct* correlation between pixel and dot. It's the output formula which determines how a given number of pixels *may* relate to dots. | In the beginning, there was no difference between a dot and a pixel - the two terms were interchangeable. That's why you still encounter the term DPI in contexts where they're clearly referring to PPI. Even on a CRT where it was clear that a single pixel lit up a varying amount of phosphor dots, nobody bothered to draw the distinction.
As technology progressed, clever people figured out that you could subdivide a pixel to provide variations on pixel brightness. A pixel subdivided into dots where half the dots are dark and half are light would look like it was at a 50% intensity. "Bit depth" is how you describe the number of possible variations of intensity; for example 8 bits allows for 256 different levels of intensity, because that's the number of unique values you can represent with 8 binary digits.
I think you already understand the "per inch" part of the equation. As the density of elements per inch goes up, whether they be dots or pixels, the sharper your image will appear. |
154,707 | I found this Image on an obscure YouTube channel and since then I've had a hard time trying to recreate this effect . I would like it to know what's the key to achieve that lighting using photoshop , and that grunge lines texture too if possible .
thanks alot in advance :)
[](https://i.stack.imgur.com/Wd8Oi.jpg) | 2021/11/15 | [
"https://graphicdesign.stackexchange.com/questions/154707",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/170058/"
] | *(It's clear now that a simple answer to this question doesn't exist. Our language simply isn't precise enough. I like the two other answers, but would still like to give an answer seen more from the viewpoint of a graphic designer.)*
A **pixel** is simply the smallest unit of an image. An image file is a collection of pixels. Nothing more than colored squares in a grid. The pixels don't have a physical size until you assign one to them and they are not necessarily the same as the pixels you see on a monitor. It depends on how you choose to display them. They are to be seen as an *abstract* idea. Pure information.
You might be making pixel art for a game. So you design your graphics by coloring a grid of pixels. But when you display the graphics, you probably scale it up several times. On the *design level*, your pixel character can still be said to consist of for example 7×12 pixels even though it might be taking up 28×48 pixels *on the screen*.
[](https://i.stack.imgur.com/FWueK.png)
So we live with different meanings of the word "pixel".
Likewise, when working with design for print, a pixel in itself have no meaning in a physical sense. In vector layout applications, you often place images at different resolutions in the same document. You can even rotate or stretch the images.
[](https://i.stack.imgur.com/UkqyL.png)
In this (very ugly) collage from InDesign, because we have defined a physical size for each image, the four images now have each their own resolution measured in *PPI* (pixels per inch). The stretched image where the pixels aren't square have a different resolution horizontally and vertically.
A **dot** is, for a graphic designer, a less ambiguous term. It's the smallest square a printing device can print. Unlike a pixel, a dot *does* have a physical size although it differs from device to device.
Most (if not all) printing devices can only print *solid* inks. Either there is color applied or there isn't. Like an old-fashioned stamp. So they need to have a rather high resolution of dots to be able to make some kind of pattern to create the *illusion* of different colors.
For example the offset machine we have at my job use printing plates that has a resolution of 2400 *DPI* (dots per inch). When a document is sent to the so-called *RIP* (raster image processor), it creates a 1-bit image of each CMYK channel. The tints of the original pixels are interpreted into different densities of *halftone screen*. These patterns are made of dots.
[](https://i.stack.imgur.com/avYNy.png)
**Note that the circles of the halftone screen are *not* what we talk about when we say "dots". The dots are the square elements which the circles consist of. Of course they are saved as pixels in an image file, but at this stage of production we still refer to them as dots.**
Below is a close-up of part of the collage from above after being interpreted by a RIP. It shows all four CMYK channels layered on top of each other. The original pixels are sort of used as masks for the halftone raster. It's one big messy soup of pixels at different PPI, normalized into halftone raster at one specific DPI.
[](https://i.stack.imgur.com/g4Czc.png)
The 1-bit images of each channel are burned onto printing plates and thereby the dots become physical. Ink is applied to the plates and then pressed onto paper. So the dots are directly transferred to paper, but the original pixels are long gone.
(I'm focusing on offset print as its my expertise. On a digital printer like an inkjet, the process is different but more or less follows the same principle.) | This is more like a long comment than a answer.
The reason why you fail to get this is simply you have no need for this information. The only way you can ever understand this is if you care about the actual technical implementation details of the underlying system. In this case a printer and a screen. Since you most likely live in a all digital world you will likely never get it nor does knowing this benefit you at all.
Human language is not fixed enough that the definition of a dot is so definitive that you can not say a screen does not contain dots. The definitions of the words depend on context, audience etc. Most humans dont write academically correct language at all times. In fact they can not as the meaning of the word dot and pixel varies depending on what academic field they would follow some persons might need to cross fields. In fact monitor manufacturers sometimes call technical elemens of pixels dots.
But they are indeed different. Its just that dividing something into only two categories is a bit misleading. There are several different ways to implement screens and several ways to implement printers. Lumping them all under pixels and dots is a bit arbitrary. But as long as you talk of:
* Laser printers and offset printers
* Most generic color screens
Then it is ok to divide them in two categories. But just be aware that once you start talking about inkjets, or some exotic system like chemical or heat based printing it becomes increasingly harder to keep up the appearances that this nomlencature makes sense.
So roughly speaking saying that a dot is printed and a pixel is on screen is prudent. But i dont like that definition as it lacks predictive value. I would much rather point to the fact that we mentally treat them differently. For some reason we treat a pixel as whole all included in one even if the color channels are separate sub pixels, and may in fact be grouped in some wierd stochastic clumping. This leads to:
* A pixel has any amount of intensity in all 3 colors
* While a dot has one intensity, on or off one color.
So they do not compare very well. A pixel is more like a group of dots (called a halftone screen), so its disengenious to compare dots of a printer to pixels of a screen. Its much more honest to compare a pixel to the size of your halftone. But then that wouldn't allow so much marketting bulshit to happen. |
154,707 | I found this Image on an obscure YouTube channel and since then I've had a hard time trying to recreate this effect . I would like it to know what's the key to achieve that lighting using photoshop , and that grunge lines texture too if possible .
thanks alot in advance :)
[](https://i.stack.imgur.com/Wd8Oi.jpg) | 2021/11/15 | [
"https://graphicdesign.stackexchange.com/questions/154707",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/170058/"
] | This is more like a long comment than a answer.
The reason why you fail to get this is simply you have no need for this information. The only way you can ever understand this is if you care about the actual technical implementation details of the underlying system. In this case a printer and a screen. Since you most likely live in a all digital world you will likely never get it nor does knowing this benefit you at all.
Human language is not fixed enough that the definition of a dot is so definitive that you can not say a screen does not contain dots. The definitions of the words depend on context, audience etc. Most humans dont write academically correct language at all times. In fact they can not as the meaning of the word dot and pixel varies depending on what academic field they would follow some persons might need to cross fields. In fact monitor manufacturers sometimes call technical elemens of pixels dots.
But they are indeed different. Its just that dividing something into only two categories is a bit misleading. There are several different ways to implement screens and several ways to implement printers. Lumping them all under pixels and dots is a bit arbitrary. But as long as you talk of:
* Laser printers and offset printers
* Most generic color screens
Then it is ok to divide them in two categories. But just be aware that once you start talking about inkjets, or some exotic system like chemical or heat based printing it becomes increasingly harder to keep up the appearances that this nomlencature makes sense.
So roughly speaking saying that a dot is printed and a pixel is on screen is prudent. But i dont like that definition as it lacks predictive value. I would much rather point to the fact that we mentally treat them differently. For some reason we treat a pixel as whole all included in one even if the color channels are separate sub pixels, and may in fact be grouped in some wierd stochastic clumping. This leads to:
* A pixel has any amount of intensity in all 3 colors
* While a dot has one intensity, on or off one color.
So they do not compare very well. A pixel is more like a group of dots (called a halftone screen), so its disengenious to compare dots of a printer to pixels of a screen. Its much more honest to compare a pixel to the size of your halftone. But then that wouldn't allow so much marketting bulshit to happen. | Some units are very precisely defined. Others much less. And you'll learn that some can have very different definitions depending on context or whoever you're talking to.
Supposedly, a **pixel** (**pict**ure **el**ement) is the smallest addressable unit on a **screen**. So your screen may have 1920 x 1080 pixels ("full HD"), with each pixel being able to have a different color. But RGB pixels are actually made of 3 elements (**sub-pixels**), one for each **channel**: one **red**, one **green**, one **blue** (sometimes one is doubled). And some technologies (e.g. ClearType) will actually use those subpixels individually to take advantage of the higher resolution for anti-aliasing purposes (this requires knowing how the sub-pixels are arranged, and in what order).
Some people will tell you each of those sub-pixels are dots. Others won't and tell you the pixels are dots. Some people (a minority, though) will even tell you that each of the sub-pixels are actually the pixels (this is most common coming from the actual display manufacturers).
It is worth noting that screens can vary the intensity of each sub-pixel. This is where the **bits per channel** come in. Each sub pixel is not just on (full red, green or blue) or off (black) — this would only give us a total of 8 colours: black, red, green, blue, yellow (red+green), purple (red+blue), cyan (green+blue) and white (red+green+blue).
Instead, each sub-pixel (channel) can take a number of values between the two. If you have **8 bits per channel** (so a total of 24 bits for RGB), that means **each of those sub pixels can take 256 different values** (1 bit = 2 values, 2 bits = 4 values, 3 bits = 8 values, and you continue doubling until 8 bits = 256 values). So **in total, you get 256 x 256 x 256 = 16 million colours**.
---
The **dot** is more commonly used in **print**. Initially, on black-and-white printers, where each dot can only have two states: it is white (no print/no ink) or black (print/ink).
Note that on printers (especially inkjet printers), dots can be larger than the spacing between them and overlap (usually the opposite for pixels, which if you look very very closely may have a bit of space between them), though of course older dot matrix printers usually had spaces between dots.
Contrary to screens, **printers usually don't handle anything but on or off** (printed or not, ink deposited on the paper or not). You can't get a half-printed dot. So to get grayscale, or a large variety of colours, one will use patterns (called **halftones**). To have something quite dark, you set most dots to black. To have something quite light, you'll set only a few. Likewise to get any colour you want, you'll combine multiple patterns on top of each other, one each for cyan, magenta and yellow (and usually black for best results).
If you look at large billboards e.g. in subway stations, which are produced by expanding a smaller image, you'll see those patterns quite clearly.
To achieve the same kind of results you would on a screen (in terms of number of colours), you thus need multiple dots for each individual unit you want to assign a different colour to. For instance, if you want to have the same 8 bits per channel, you need to be able to print anywhere between 0 and 255 ink dots for each unit. That requires 256 dots, or a square of 16 x 16 dots.
Note that you may think that 8 dots are enough, with each dot matching one bit, but that's not the case. In an 8-bit channel, each bit has a different weight, while all the dots have the same weight. So you need a lot more.
This means that if all those dots where arranged in a perfectly rectangular fashion, you need 16 times more dots in each direction to achieve the same result as a screen (in term of number of colours). That's one of the reasons why **professional printing usually uses resolutions of about 1200 or 2400 dots per inch**. In the end, this is not much better (for pictures) than a screen at 75 to 150 dpi (but it makes a whole lot of a difference for cases where you're printing pure black and white, like text, because you don't use halftones for those). The resolution once you take into account the pattern size is measured in... **lines per inch**.
This is the reason why, in print, in you want a specific colour but also need fine detail, you won't print in regular CMYK, but actually have a separate channel using a predefined colour with will use a specific ink. So if you want very readable purple text, you won't print it as a combination of cyan and magenta (which will give a very fine grid of dots mixing the two, and you'll end up with "fuzzy" text), but directly using purple ink. That's where Pantone colours and other palettes come in, they're actually inks (of course this is for professional offset printing, usually not on your home laser printer which can only use the standard inks).
You'll notice that I mentioned **"dots per inch" (dpi) both for printers and for screens**. Yes, "dots per inch" for screens are actually pixels per inch. Same thing for your screen's "dot pitch".
---
If that wasn't complex enough, some units also have standardised **sizes**. As for a long time computer screens had vaguely similar resolutions (in dots per inch) usually in the 70-90 dpi range, programmers often measured things in pixels rather than more absolute units like points (1/72 of an inch), mm, cm, picas, or whatnot.
The problem? When higher-resolution screens (e.g. the "Retina" screens) came along, anything that was measured in pixels would become a lot smaller if the relationship with the physical pixel was maintained, not the intended effect.
So some technologies (like CSS) **define a pixel as being something which is not a physical screen pixel! They actually define it as 1/96 of an inch**.
This gives quite interesting discussions between CSS pixels and actual physical pixels. [This page](https://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions) for instance will show you the difference between "points" used by programmers/designers (which are not actual 1/72 inch points, and in the context of CSS, are the same as CSS pixels), rendered pixels (using an integer ratio), physical pixels (after bit of downsampling the match the actual number of screen pixels) and physical size.
Welcome to the wonderful world of pixels and dots! |
154,707 | I found this Image on an obscure YouTube channel and since then I've had a hard time trying to recreate this effect . I would like it to know what's the key to achieve that lighting using photoshop , and that grunge lines texture too if possible .
thanks alot in advance :)
[](https://i.stack.imgur.com/Wd8Oi.jpg) | 2021/11/15 | [
"https://graphicdesign.stackexchange.com/questions/154707",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/170058/"
] | This is more like a long comment than a answer.
The reason why you fail to get this is simply you have no need for this information. The only way you can ever understand this is if you care about the actual technical implementation details of the underlying system. In this case a printer and a screen. Since you most likely live in a all digital world you will likely never get it nor does knowing this benefit you at all.
Human language is not fixed enough that the definition of a dot is so definitive that you can not say a screen does not contain dots. The definitions of the words depend on context, audience etc. Most humans dont write academically correct language at all times. In fact they can not as the meaning of the word dot and pixel varies depending on what academic field they would follow some persons might need to cross fields. In fact monitor manufacturers sometimes call technical elemens of pixels dots.
But they are indeed different. Its just that dividing something into only two categories is a bit misleading. There are several different ways to implement screens and several ways to implement printers. Lumping them all under pixels and dots is a bit arbitrary. But as long as you talk of:
* Laser printers and offset printers
* Most generic color screens
Then it is ok to divide them in two categories. But just be aware that once you start talking about inkjets, or some exotic system like chemical or heat based printing it becomes increasingly harder to keep up the appearances that this nomlencature makes sense.
So roughly speaking saying that a dot is printed and a pixel is on screen is prudent. But i dont like that definition as it lacks predictive value. I would much rather point to the fact that we mentally treat them differently. For some reason we treat a pixel as whole all included in one even if the color channels are separate sub pixels, and may in fact be grouped in some wierd stochastic clumping. This leads to:
* A pixel has any amount of intensity in all 3 colors
* While a dot has one intensity, on or off one color.
So they do not compare very well. A pixel is more like a group of dots (called a halftone screen), so its disengenious to compare dots of a printer to pixels of a screen. Its much more honest to compare a pixel to the size of your halftone. But then that wouldn't allow so much marketting bulshit to happen. | In the beginning, there was no difference between a dot and a pixel - the two terms were interchangeable. That's why you still encounter the term DPI in contexts where they're clearly referring to PPI. Even on a CRT where it was clear that a single pixel lit up a varying amount of phosphor dots, nobody bothered to draw the distinction.
As technology progressed, clever people figured out that you could subdivide a pixel to provide variations on pixel brightness. A pixel subdivided into dots where half the dots are dark and half are light would look like it was at a 50% intensity. "Bit depth" is how you describe the number of possible variations of intensity; for example 8 bits allows for 256 different levels of intensity, because that's the number of unique values you can represent with 8 binary digits.
I think you already understand the "per inch" part of the equation. As the density of elements per inch goes up, whether they be dots or pixels, the sharper your image will appear. |
154,707 | I found this Image on an obscure YouTube channel and since then I've had a hard time trying to recreate this effect . I would like it to know what's the key to achieve that lighting using photoshop , and that grunge lines texture too if possible .
thanks alot in advance :)
[](https://i.stack.imgur.com/Wd8Oi.jpg) | 2021/11/15 | [
"https://graphicdesign.stackexchange.com/questions/154707",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/170058/"
] | *(It's clear now that a simple answer to this question doesn't exist. Our language simply isn't precise enough. I like the two other answers, but would still like to give an answer seen more from the viewpoint of a graphic designer.)*
A **pixel** is simply the smallest unit of an image. An image file is a collection of pixels. Nothing more than colored squares in a grid. The pixels don't have a physical size until you assign one to them and they are not necessarily the same as the pixels you see on a monitor. It depends on how you choose to display them. They are to be seen as an *abstract* idea. Pure information.
You might be making pixel art for a game. So you design your graphics by coloring a grid of pixels. But when you display the graphics, you probably scale it up several times. On the *design level*, your pixel character can still be said to consist of for example 7×12 pixels even though it might be taking up 28×48 pixels *on the screen*.
[](https://i.stack.imgur.com/FWueK.png)
So we live with different meanings of the word "pixel".
Likewise, when working with design for print, a pixel in itself have no meaning in a physical sense. In vector layout applications, you often place images at different resolutions in the same document. You can even rotate or stretch the images.
[](https://i.stack.imgur.com/UkqyL.png)
In this (very ugly) collage from InDesign, because we have defined a physical size for each image, the four images now have each their own resolution measured in *PPI* (pixels per inch). The stretched image where the pixels aren't square have a different resolution horizontally and vertically.
A **dot** is, for a graphic designer, a less ambiguous term. It's the smallest square a printing device can print. Unlike a pixel, a dot *does* have a physical size although it differs from device to device.
Most (if not all) printing devices can only print *solid* inks. Either there is color applied or there isn't. Like an old-fashioned stamp. So they need to have a rather high resolution of dots to be able to make some kind of pattern to create the *illusion* of different colors.
For example the offset machine we have at my job use printing plates that has a resolution of 2400 *DPI* (dots per inch). When a document is sent to the so-called *RIP* (raster image processor), it creates a 1-bit image of each CMYK channel. The tints of the original pixels are interpreted into different densities of *halftone screen*. These patterns are made of dots.
[](https://i.stack.imgur.com/avYNy.png)
**Note that the circles of the halftone screen are *not* what we talk about when we say "dots". The dots are the square elements which the circles consist of. Of course they are saved as pixels in an image file, but at this stage of production we still refer to them as dots.**
Below is a close-up of part of the collage from above after being interpreted by a RIP. It shows all four CMYK channels layered on top of each other. The original pixels are sort of used as masks for the halftone raster. It's one big messy soup of pixels at different PPI, normalized into halftone raster at one specific DPI.
[](https://i.stack.imgur.com/g4Czc.png)
The 1-bit images of each channel are burned onto printing plates and thereby the dots become physical. Ink is applied to the plates and then pressed onto paper. So the dots are directly transferred to paper, but the original pixels are long gone.
(I'm focusing on offset print as its my expertise. On a digital printer like an inkjet, the process is different but more or less follows the same principle.) | Some units are very precisely defined. Others much less. And you'll learn that some can have very different definitions depending on context or whoever you're talking to.
Supposedly, a **pixel** (**pict**ure **el**ement) is the smallest addressable unit on a **screen**. So your screen may have 1920 x 1080 pixels ("full HD"), with each pixel being able to have a different color. But RGB pixels are actually made of 3 elements (**sub-pixels**), one for each **channel**: one **red**, one **green**, one **blue** (sometimes one is doubled). And some technologies (e.g. ClearType) will actually use those subpixels individually to take advantage of the higher resolution for anti-aliasing purposes (this requires knowing how the sub-pixels are arranged, and in what order).
Some people will tell you each of those sub-pixels are dots. Others won't and tell you the pixels are dots. Some people (a minority, though) will even tell you that each of the sub-pixels are actually the pixels (this is most common coming from the actual display manufacturers).
It is worth noting that screens can vary the intensity of each sub-pixel. This is where the **bits per channel** come in. Each sub pixel is not just on (full red, green or blue) or off (black) — this would only give us a total of 8 colours: black, red, green, blue, yellow (red+green), purple (red+blue), cyan (green+blue) and white (red+green+blue).
Instead, each sub-pixel (channel) can take a number of values between the two. If you have **8 bits per channel** (so a total of 24 bits for RGB), that means **each of those sub pixels can take 256 different values** (1 bit = 2 values, 2 bits = 4 values, 3 bits = 8 values, and you continue doubling until 8 bits = 256 values). So **in total, you get 256 x 256 x 256 = 16 million colours**.
---
The **dot** is more commonly used in **print**. Initially, on black-and-white printers, where each dot can only have two states: it is white (no print/no ink) or black (print/ink).
Note that on printers (especially inkjet printers), dots can be larger than the spacing between them and overlap (usually the opposite for pixels, which if you look very very closely may have a bit of space between them), though of course older dot matrix printers usually had spaces between dots.
Contrary to screens, **printers usually don't handle anything but on or off** (printed or not, ink deposited on the paper or not). You can't get a half-printed dot. So to get grayscale, or a large variety of colours, one will use patterns (called **halftones**). To have something quite dark, you set most dots to black. To have something quite light, you'll set only a few. Likewise to get any colour you want, you'll combine multiple patterns on top of each other, one each for cyan, magenta and yellow (and usually black for best results).
If you look at large billboards e.g. in subway stations, which are produced by expanding a smaller image, you'll see those patterns quite clearly.
To achieve the same kind of results you would on a screen (in terms of number of colours), you thus need multiple dots for each individual unit you want to assign a different colour to. For instance, if you want to have the same 8 bits per channel, you need to be able to print anywhere between 0 and 255 ink dots for each unit. That requires 256 dots, or a square of 16 x 16 dots.
Note that you may think that 8 dots are enough, with each dot matching one bit, but that's not the case. In an 8-bit channel, each bit has a different weight, while all the dots have the same weight. So you need a lot more.
This means that if all those dots where arranged in a perfectly rectangular fashion, you need 16 times more dots in each direction to achieve the same result as a screen (in term of number of colours). That's one of the reasons why **professional printing usually uses resolutions of about 1200 or 2400 dots per inch**. In the end, this is not much better (for pictures) than a screen at 75 to 150 dpi (but it makes a whole lot of a difference for cases where you're printing pure black and white, like text, because you don't use halftones for those). The resolution once you take into account the pattern size is measured in... **lines per inch**.
This is the reason why, in print, in you want a specific colour but also need fine detail, you won't print in regular CMYK, but actually have a separate channel using a predefined colour with will use a specific ink. So if you want very readable purple text, you won't print it as a combination of cyan and magenta (which will give a very fine grid of dots mixing the two, and you'll end up with "fuzzy" text), but directly using purple ink. That's where Pantone colours and other palettes come in, they're actually inks (of course this is for professional offset printing, usually not on your home laser printer which can only use the standard inks).
You'll notice that I mentioned **"dots per inch" (dpi) both for printers and for screens**. Yes, "dots per inch" for screens are actually pixels per inch. Same thing for your screen's "dot pitch".
---
If that wasn't complex enough, some units also have standardised **sizes**. As for a long time computer screens had vaguely similar resolutions (in dots per inch) usually in the 70-90 dpi range, programmers often measured things in pixels rather than more absolute units like points (1/72 of an inch), mm, cm, picas, or whatnot.
The problem? When higher-resolution screens (e.g. the "Retina" screens) came along, anything that was measured in pixels would become a lot smaller if the relationship with the physical pixel was maintained, not the intended effect.
So some technologies (like CSS) **define a pixel as being something which is not a physical screen pixel! They actually define it as 1/96 of an inch**.
This gives quite interesting discussions between CSS pixels and actual physical pixels. [This page](https://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions) for instance will show you the difference between "points" used by programmers/designers (which are not actual 1/72 inch points, and in the context of CSS, are the same as CSS pixels), rendered pixels (using an integer ratio), physical pixels (after bit of downsampling the match the actual number of screen pixels) and physical size.
Welcome to the wonderful world of pixels and dots! |
154,707 | I found this Image on an obscure YouTube channel and since then I've had a hard time trying to recreate this effect . I would like it to know what's the key to achieve that lighting using photoshop , and that grunge lines texture too if possible .
thanks alot in advance :)
[](https://i.stack.imgur.com/Wd8Oi.jpg) | 2021/11/15 | [
"https://graphicdesign.stackexchange.com/questions/154707",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/170058/"
] | *(It's clear now that a simple answer to this question doesn't exist. Our language simply isn't precise enough. I like the two other answers, but would still like to give an answer seen more from the viewpoint of a graphic designer.)*
A **pixel** is simply the smallest unit of an image. An image file is a collection of pixels. Nothing more than colored squares in a grid. The pixels don't have a physical size until you assign one to them and they are not necessarily the same as the pixels you see on a monitor. It depends on how you choose to display them. They are to be seen as an *abstract* idea. Pure information.
You might be making pixel art for a game. So you design your graphics by coloring a grid of pixels. But when you display the graphics, you probably scale it up several times. On the *design level*, your pixel character can still be said to consist of for example 7×12 pixels even though it might be taking up 28×48 pixels *on the screen*.
[](https://i.stack.imgur.com/FWueK.png)
So we live with different meanings of the word "pixel".
Likewise, when working with design for print, a pixel in itself have no meaning in a physical sense. In vector layout applications, you often place images at different resolutions in the same document. You can even rotate or stretch the images.
[](https://i.stack.imgur.com/UkqyL.png)
In this (very ugly) collage from InDesign, because we have defined a physical size for each image, the four images now have each their own resolution measured in *PPI* (pixels per inch). The stretched image where the pixels aren't square have a different resolution horizontally and vertically.
A **dot** is, for a graphic designer, a less ambiguous term. It's the smallest square a printing device can print. Unlike a pixel, a dot *does* have a physical size although it differs from device to device.
Most (if not all) printing devices can only print *solid* inks. Either there is color applied or there isn't. Like an old-fashioned stamp. So they need to have a rather high resolution of dots to be able to make some kind of pattern to create the *illusion* of different colors.
For example the offset machine we have at my job use printing plates that has a resolution of 2400 *DPI* (dots per inch). When a document is sent to the so-called *RIP* (raster image processor), it creates a 1-bit image of each CMYK channel. The tints of the original pixels are interpreted into different densities of *halftone screen*. These patterns are made of dots.
[](https://i.stack.imgur.com/avYNy.png)
**Note that the circles of the halftone screen are *not* what we talk about when we say "dots". The dots are the square elements which the circles consist of. Of course they are saved as pixels in an image file, but at this stage of production we still refer to them as dots.**
Below is a close-up of part of the collage from above after being interpreted by a RIP. It shows all four CMYK channels layered on top of each other. The original pixels are sort of used as masks for the halftone raster. It's one big messy soup of pixels at different PPI, normalized into halftone raster at one specific DPI.
[](https://i.stack.imgur.com/g4Czc.png)
The 1-bit images of each channel are burned onto printing plates and thereby the dots become physical. Ink is applied to the plates and then pressed onto paper. So the dots are directly transferred to paper, but the original pixels are long gone.
(I'm focusing on offset print as its my expertise. On a digital printer like an inkjet, the process is different but more or less follows the same principle.) | In the beginning, there was no difference between a dot and a pixel - the two terms were interchangeable. That's why you still encounter the term DPI in contexts where they're clearly referring to PPI. Even on a CRT where it was clear that a single pixel lit up a varying amount of phosphor dots, nobody bothered to draw the distinction.
As technology progressed, clever people figured out that you could subdivide a pixel to provide variations on pixel brightness. A pixel subdivided into dots where half the dots are dark and half are light would look like it was at a 50% intensity. "Bit depth" is how you describe the number of possible variations of intensity; for example 8 bits allows for 256 different levels of intensity, because that's the number of unique values you can represent with 8 binary digits.
I think you already understand the "per inch" part of the equation. As the density of elements per inch goes up, whether they be dots or pixels, the sharper your image will appear. |
154,707 | I found this Image on an obscure YouTube channel and since then I've had a hard time trying to recreate this effect . I would like it to know what's the key to achieve that lighting using photoshop , and that grunge lines texture too if possible .
thanks alot in advance :)
[](https://i.stack.imgur.com/Wd8Oi.jpg) | 2021/11/15 | [
"https://graphicdesign.stackexchange.com/questions/154707",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/170058/"
] | In the beginning, there was no difference between a dot and a pixel - the two terms were interchangeable. That's why you still encounter the term DPI in contexts where they're clearly referring to PPI. Even on a CRT where it was clear that a single pixel lit up a varying amount of phosphor dots, nobody bothered to draw the distinction.
As technology progressed, clever people figured out that you could subdivide a pixel to provide variations on pixel brightness. A pixel subdivided into dots where half the dots are dark and half are light would look like it was at a 50% intensity. "Bit depth" is how you describe the number of possible variations of intensity; for example 8 bits allows for 256 different levels of intensity, because that's the number of unique values you can represent with 8 binary digits.
I think you already understand the "per inch" part of the equation. As the density of elements per inch goes up, whether they be dots or pixels, the sharper your image will appear. | Some units are very precisely defined. Others much less. And you'll learn that some can have very different definitions depending on context or whoever you're talking to.
Supposedly, a **pixel** (**pict**ure **el**ement) is the smallest addressable unit on a **screen**. So your screen may have 1920 x 1080 pixels ("full HD"), with each pixel being able to have a different color. But RGB pixels are actually made of 3 elements (**sub-pixels**), one for each **channel**: one **red**, one **green**, one **blue** (sometimes one is doubled). And some technologies (e.g. ClearType) will actually use those subpixels individually to take advantage of the higher resolution for anti-aliasing purposes (this requires knowing how the sub-pixels are arranged, and in what order).
Some people will tell you each of those sub-pixels are dots. Others won't and tell you the pixels are dots. Some people (a minority, though) will even tell you that each of the sub-pixels are actually the pixels (this is most common coming from the actual display manufacturers).
It is worth noting that screens can vary the intensity of each sub-pixel. This is where the **bits per channel** come in. Each sub pixel is not just on (full red, green or blue) or off (black) — this would only give us a total of 8 colours: black, red, green, blue, yellow (red+green), purple (red+blue), cyan (green+blue) and white (red+green+blue).
Instead, each sub-pixel (channel) can take a number of values between the two. If you have **8 bits per channel** (so a total of 24 bits for RGB), that means **each of those sub pixels can take 256 different values** (1 bit = 2 values, 2 bits = 4 values, 3 bits = 8 values, and you continue doubling until 8 bits = 256 values). So **in total, you get 256 x 256 x 256 = 16 million colours**.
---
The **dot** is more commonly used in **print**. Initially, on black-and-white printers, where each dot can only have two states: it is white (no print/no ink) or black (print/ink).
Note that on printers (especially inkjet printers), dots can be larger than the spacing between them and overlap (usually the opposite for pixels, which if you look very very closely may have a bit of space between them), though of course older dot matrix printers usually had spaces between dots.
Contrary to screens, **printers usually don't handle anything but on or off** (printed or not, ink deposited on the paper or not). You can't get a half-printed dot. So to get grayscale, or a large variety of colours, one will use patterns (called **halftones**). To have something quite dark, you set most dots to black. To have something quite light, you'll set only a few. Likewise to get any colour you want, you'll combine multiple patterns on top of each other, one each for cyan, magenta and yellow (and usually black for best results).
If you look at large billboards e.g. in subway stations, which are produced by expanding a smaller image, you'll see those patterns quite clearly.
To achieve the same kind of results you would on a screen (in terms of number of colours), you thus need multiple dots for each individual unit you want to assign a different colour to. For instance, if you want to have the same 8 bits per channel, you need to be able to print anywhere between 0 and 255 ink dots for each unit. That requires 256 dots, or a square of 16 x 16 dots.
Note that you may think that 8 dots are enough, with each dot matching one bit, but that's not the case. In an 8-bit channel, each bit has a different weight, while all the dots have the same weight. So you need a lot more.
This means that if all those dots where arranged in a perfectly rectangular fashion, you need 16 times more dots in each direction to achieve the same result as a screen (in term of number of colours). That's one of the reasons why **professional printing usually uses resolutions of about 1200 or 2400 dots per inch**. In the end, this is not much better (for pictures) than a screen at 75 to 150 dpi (but it makes a whole lot of a difference for cases where you're printing pure black and white, like text, because you don't use halftones for those). The resolution once you take into account the pattern size is measured in... **lines per inch**.
This is the reason why, in print, in you want a specific colour but also need fine detail, you won't print in regular CMYK, but actually have a separate channel using a predefined colour with will use a specific ink. So if you want very readable purple text, you won't print it as a combination of cyan and magenta (which will give a very fine grid of dots mixing the two, and you'll end up with "fuzzy" text), but directly using purple ink. That's where Pantone colours and other palettes come in, they're actually inks (of course this is for professional offset printing, usually not on your home laser printer which can only use the standard inks).
You'll notice that I mentioned **"dots per inch" (dpi) both for printers and for screens**. Yes, "dots per inch" for screens are actually pixels per inch. Same thing for your screen's "dot pitch".
---
If that wasn't complex enough, some units also have standardised **sizes**. As for a long time computer screens had vaguely similar resolutions (in dots per inch) usually in the 70-90 dpi range, programmers often measured things in pixels rather than more absolute units like points (1/72 of an inch), mm, cm, picas, or whatnot.
The problem? When higher-resolution screens (e.g. the "Retina" screens) came along, anything that was measured in pixels would become a lot smaller if the relationship with the physical pixel was maintained, not the intended effect.
So some technologies (like CSS) **define a pixel as being something which is not a physical screen pixel! They actually define it as 1/96 of an inch**.
This gives quite interesting discussions between CSS pixels and actual physical pixels. [This page](https://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions) for instance will show you the difference between "points" used by programmers/designers (which are not actual 1/72 inch points, and in the context of CSS, are the same as CSS pixels), rendered pixels (using an integer ratio), physical pixels (after bit of downsampling the match the actual number of screen pixels) and physical size.
Welcome to the wonderful world of pixels and dots! |
69,419,273 | I have two custom classes called `OrthogonalPoint` and `PolarPoint`.
```
public class OrthogonalPoint extends AbstractPoint<OrthogonalPoint> {
private double x;
private double y;
// constructor, getters, ...
}
```
```
public class PolarPoint extends AbstractPoint<PolarPoint> {
private double rho;
private double theta;
// constructor, getters, ...
}
```
Both extend an abstract class `AbstractPoint`.
```
public abstract class AbstractPoint<PointType extends AbstractPoint<PointType>> {
public abstract double getX();
public abstract double getY();
public final double distance(PointType other) {
// calculate distance between current point and other point
}
}
```
Next, I have a class `Route`.
```
public class Route<T extends AbstractPoint<T>> {
private final List<T> points = new ArrayList<>();
public void appendPoint(T point) {
this.points.add(point);
}
public double routeDistance() {
// calculate total distance
}
}
```
A route is an ordered number of points whose length is defined as the sum of the distances of the points in the sequence. So, if a route consists of three points (p1, p2, and p3) the distance of the route is `p1.distance(p2) + p2.distance(p3)`.
In the `routeDistance` function, I want to calculate this distance. I have tried something like
```
public double routeDistance() {
return this.points.stream().reduce(0d, (point, point2) -> point.distance(point2));
}
```
But the body part of the lambda function is underlined red:
```
Bad return type in lambda expression: double cannot be converted to T
```
What would be the correct way to calculate the distance? I would like to use the reduce, but any solution is appreciated. | 2021/10/02 | [
"https://Stackoverflow.com/questions/69419273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11107128/"
] | In Spring Security version `5.6`, which is in `5.6.0.M3` as of now, you can create an `AuthorizationManager` bean and define place your rules anywhere you want, like so:
```java
@Autowired
private MyCustomAuthorizationManager access;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().access(access);
}
```
Or even better, you can define a `SecurityFilterChain` bean and make use of method parameter injection, instead of extending `WebSecurityConfigurerAdapter`:
```java
@Bean
SecurityFilterChain app(HttpSecurity http, MyCustomAuthorizationManager access) throws Exception {
...
http.authorizeRequests().access(access);
...
return http.build();
}
```
There is a [great presentation](https://youtu.be/5tlU_Vjv8Ns?t=1992) showing how to do this. | I ended up with this [solution](https://www.baeldung.com/java-restart-spring-boot-app). The solution is to close the current context and run the new one. Of course, it has the disadvantage because it causes downtime but I use a load balancer and several nodes so it's was ok for me. |
11,116,162 | I'm navigating from:
* `Main activity` to `Activity 2`
* `Activity 2` to `Activity 3`
* `Activity 3` to `Activity 4`
through `Intent`.
I've also created the menu so that user can directly navigate from `Activity 4` to `Main activity`.
But after navigating from `Activity 4` to `Main activity` by using menu, when I press back, it takes me to `Activity 3` rather than **exiting the application**.
I tried:
```
@Override
public void onBackPressed() {
super.onBackPressed();
MainActivity.this.finish();
}
```
But no gain. Any suggestions? | 2012/06/20 | [
"https://Stackoverflow.com/questions/11116162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1061728/"
] | You need to consider your "[back stack](http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html)" more closely.
What is happening exactly is, your back stack gets populated as follows:
```
Main activity -> Activity 2 -> Activity 3 -> Activity 4
```
Then from `Activity 4` you launch your `Main Activity`. So your stack becomes:
```
Main activity -> Activity 2 -> Activity 3 -> Main Activity
```
Hence, when you press back, you land up in `Activity 3`.
Solution:
Either call `finish()` on every `Activity` when you navigate away from them. Or use `Intent.FLAG_ACTIVITY_CLEAR_TOP` to clear all intermediate `Activities`.
More about [Intent.FLAG\_ACTIVITY\_CLEAR\_TOP](http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP). | In activity 2 and 3, after calling `startActivity(intent)`, call `this.finish()`. This will also be one solution. |
11,116,162 | I'm navigating from:
* `Main activity` to `Activity 2`
* `Activity 2` to `Activity 3`
* `Activity 3` to `Activity 4`
through `Intent`.
I've also created the menu so that user can directly navigate from `Activity 4` to `Main activity`.
But after navigating from `Activity 4` to `Main activity` by using menu, when I press back, it takes me to `Activity 3` rather than **exiting the application**.
I tried:
```
@Override
public void onBackPressed() {
super.onBackPressed();
MainActivity.this.finish();
}
```
But no gain. Any suggestions? | 2012/06/20 | [
"https://Stackoverflow.com/questions/11116162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1061728/"
] | Just try this code when you navigate from 4th Activity to Main Activity.
```
Intent inMain=new Intent(Activity4.this, MainActivity.class);
inMain.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(inMain);
```
Note:
This code in your case, clears the previous activities and launches the main activity with no activity in the backstack. | use the flag Intent.FLAG\_ACTIVITY\_CLEAR\_TOP with your intent. For more detail -
[FLAG\_ACTIVITY\_CLEAR\_TOP](http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP) |
11,116,162 | I'm navigating from:
* `Main activity` to `Activity 2`
* `Activity 2` to `Activity 3`
* `Activity 3` to `Activity 4`
through `Intent`.
I've also created the menu so that user can directly navigate from `Activity 4` to `Main activity`.
But after navigating from `Activity 4` to `Main activity` by using menu, when I press back, it takes me to `Activity 3` rather than **exiting the application**.
I tried:
```
@Override
public void onBackPressed() {
super.onBackPressed();
MainActivity.this.finish();
}
```
But no gain. Any suggestions? | 2012/06/20 | [
"https://Stackoverflow.com/questions/11116162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1061728/"
] | You can set flag `Intent.FLAG_ACTIVITY_CLEAR_TOP` to finish all the intermediate activities and your called activity will come to top of the activity stack. | In activity 2 and 3, after calling `startActivity(intent)`, call `this.finish()`. This will also be one solution. |
11,116,162 | I'm navigating from:
* `Main activity` to `Activity 2`
* `Activity 2` to `Activity 3`
* `Activity 3` to `Activity 4`
through `Intent`.
I've also created the menu so that user can directly navigate from `Activity 4` to `Main activity`.
But after navigating from `Activity 4` to `Main activity` by using menu, when I press back, it takes me to `Activity 3` rather than **exiting the application**.
I tried:
```
@Override
public void onBackPressed() {
super.onBackPressed();
MainActivity.this.finish();
}
```
But no gain. Any suggestions? | 2012/06/20 | [
"https://Stackoverflow.com/questions/11116162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1061728/"
] | use the flag Intent.FLAG\_ACTIVITY\_CLEAR\_TOP with your intent. For more detail -
[FLAG\_ACTIVITY\_CLEAR\_TOP](http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP) | When you go back to the `MainActivity` you need to use the `Intent.FLAG_ACTIVITY_CLEAR_TOP` on your `Intent`. This is an example of a `goHome` method that you can used in your `Activity`:
```
public void goHome ()
{
Intent homeIntent = new Intent();
homeIntent.setClass(this, MainActivity.class);
homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(homeIntent);
}
``` |
11,116,162 | I'm navigating from:
* `Main activity` to `Activity 2`
* `Activity 2` to `Activity 3`
* `Activity 3` to `Activity 4`
through `Intent`.
I've also created the menu so that user can directly navigate from `Activity 4` to `Main activity`.
But after navigating from `Activity 4` to `Main activity` by using menu, when I press back, it takes me to `Activity 3` rather than **exiting the application**.
I tried:
```
@Override
public void onBackPressed() {
super.onBackPressed();
MainActivity.this.finish();
}
```
But no gain. Any suggestions? | 2012/06/20 | [
"https://Stackoverflow.com/questions/11116162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1061728/"
] | use the flag Intent.FLAG\_ACTIVITY\_CLEAR\_TOP with your intent. For more detail -
[FLAG\_ACTIVITY\_CLEAR\_TOP](http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP) | You need to consider your "[back stack](http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html)" more closely.
What is happening exactly is, your back stack gets populated as follows:
```
Main activity -> Activity 2 -> Activity 3 -> Activity 4
```
Then from `Activity 4` you launch your `Main Activity`. So your stack becomes:
```
Main activity -> Activity 2 -> Activity 3 -> Main Activity
```
Hence, when you press back, you land up in `Activity 3`.
Solution:
Either call `finish()` on every `Activity` when you navigate away from them. Or use `Intent.FLAG_ACTIVITY_CLEAR_TOP` to clear all intermediate `Activities`.
More about [Intent.FLAG\_ACTIVITY\_CLEAR\_TOP](http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP). |
11,116,162 | I'm navigating from:
* `Main activity` to `Activity 2`
* `Activity 2` to `Activity 3`
* `Activity 3` to `Activity 4`
through `Intent`.
I've also created the menu so that user can directly navigate from `Activity 4` to `Main activity`.
But after navigating from `Activity 4` to `Main activity` by using menu, when I press back, it takes me to `Activity 3` rather than **exiting the application**.
I tried:
```
@Override
public void onBackPressed() {
super.onBackPressed();
MainActivity.this.finish();
}
```
But no gain. Any suggestions? | 2012/06/20 | [
"https://Stackoverflow.com/questions/11116162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1061728/"
] | call startActivity Method using clear top flag
```
startActivity(new Intent(this, UI.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
``` | In activity 2 and 3, after calling `startActivity(intent)`, call `this.finish()`. This will also be one solution. |
11,116,162 | I'm navigating from:
* `Main activity` to `Activity 2`
* `Activity 2` to `Activity 3`
* `Activity 3` to `Activity 4`
through `Intent`.
I've also created the menu so that user can directly navigate from `Activity 4` to `Main activity`.
But after navigating from `Activity 4` to `Main activity` by using menu, when I press back, it takes me to `Activity 3` rather than **exiting the application**.
I tried:
```
@Override
public void onBackPressed() {
super.onBackPressed();
MainActivity.this.finish();
}
```
But no gain. Any suggestions? | 2012/06/20 | [
"https://Stackoverflow.com/questions/11116162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1061728/"
] | You can set flag `Intent.FLAG_ACTIVITY_CLEAR_TOP` to finish all the intermediate activities and your called activity will come to top of the activity stack. | When you go back to the `MainActivity` you need to use the `Intent.FLAG_ACTIVITY_CLEAR_TOP` on your `Intent`. This is an example of a `goHome` method that you can used in your `Activity`:
```
public void goHome ()
{
Intent homeIntent = new Intent();
homeIntent.setClass(this, MainActivity.class);
homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(homeIntent);
}
``` |
11,116,162 | I'm navigating from:
* `Main activity` to `Activity 2`
* `Activity 2` to `Activity 3`
* `Activity 3` to `Activity 4`
through `Intent`.
I've also created the menu so that user can directly navigate from `Activity 4` to `Main activity`.
But after navigating from `Activity 4` to `Main activity` by using menu, when I press back, it takes me to `Activity 3` rather than **exiting the application**.
I tried:
```
@Override
public void onBackPressed() {
super.onBackPressed();
MainActivity.this.finish();
}
```
But no gain. Any suggestions? | 2012/06/20 | [
"https://Stackoverflow.com/questions/11116162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1061728/"
] | Just try this code when you navigate from 4th Activity to Main Activity.
```
Intent inMain=new Intent(Activity4.this, MainActivity.class);
inMain.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(inMain);
```
Note:
This code in your case, clears the previous activities and launches the main activity with no activity in the backstack. | You need to consider your "[back stack](http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html)" more closely.
What is happening exactly is, your back stack gets populated as follows:
```
Main activity -> Activity 2 -> Activity 3 -> Activity 4
```
Then from `Activity 4` you launch your `Main Activity`. So your stack becomes:
```
Main activity -> Activity 2 -> Activity 3 -> Main Activity
```
Hence, when you press back, you land up in `Activity 3`.
Solution:
Either call `finish()` on every `Activity` when you navigate away from them. Or use `Intent.FLAG_ACTIVITY_CLEAR_TOP` to clear all intermediate `Activities`.
More about [Intent.FLAG\_ACTIVITY\_CLEAR\_TOP](http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP). |
11,116,162 | I'm navigating from:
* `Main activity` to `Activity 2`
* `Activity 2` to `Activity 3`
* `Activity 3` to `Activity 4`
through `Intent`.
I've also created the menu so that user can directly navigate from `Activity 4` to `Main activity`.
But after navigating from `Activity 4` to `Main activity` by using menu, when I press back, it takes me to `Activity 3` rather than **exiting the application**.
I tried:
```
@Override
public void onBackPressed() {
super.onBackPressed();
MainActivity.this.finish();
}
```
But no gain. Any suggestions? | 2012/06/20 | [
"https://Stackoverflow.com/questions/11116162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1061728/"
] | When you go back to the `MainActivity` you need to use the `Intent.FLAG_ACTIVITY_CLEAR_TOP` on your `Intent`. This is an example of a `goHome` method that you can used in your `Activity`:
```
public void goHome ()
{
Intent homeIntent = new Intent();
homeIntent.setClass(this, MainActivity.class);
homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(homeIntent);
}
``` | In activity 2 and 3, after calling `startActivity(intent)`, call `this.finish()`. This will also be one solution. |
11,116,162 | I'm navigating from:
* `Main activity` to `Activity 2`
* `Activity 2` to `Activity 3`
* `Activity 3` to `Activity 4`
through `Intent`.
I've also created the menu so that user can directly navigate from `Activity 4` to `Main activity`.
But after navigating from `Activity 4` to `Main activity` by using menu, when I press back, it takes me to `Activity 3` rather than **exiting the application**.
I tried:
```
@Override
public void onBackPressed() {
super.onBackPressed();
MainActivity.this.finish();
}
```
But no gain. Any suggestions? | 2012/06/20 | [
"https://Stackoverflow.com/questions/11116162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1061728/"
] | use the flag Intent.FLAG\_ACTIVITY\_CLEAR\_TOP with your intent. For more detail -
[FLAG\_ACTIVITY\_CLEAR\_TOP](http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP) | call startActivity Method using clear top flag
```
startActivity(new Intent(this, UI.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
``` |
12,298,481 | I've tried [this sketch](http://arduino.cc/playground/Main/MPU-6050#sketch) provided by arduino.cc. (I've an [MPU6050 GY-521 breakout board](https://rads.stackoverflow.com/amzn/click/com/B008BOPN40).)
I think it works fine. It gives a weird set of numbers I can't get any meaning out. It says that those are raw values.
How can I convert them into meaningful values?
The output is as follows. Even when the whole thing is kept stationary, it gives changing values! Is this meaningful? Then how is it to be understood?
*(What I only know is that the temperature value is meaningful :D)*
```
June 2012
WHO_AM_I : 68, error = 0
PWR_MGMT_2 : 0, error = 0
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 260, 120, 15572
temperature: 31.047 degrees Celsius
gyro x,y,z : -24, -234, -240,
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 304, 12, 15608
temperature: 31.000 degrees Celsius
gyro x,y,z : -7, -234, -232,
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 160, 100, 15716
temperature: 31.000 degrees Celsius
gyro x,y,z : -8, -241, -248,
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 192, 56, 15712
temperature: 31.000 degrees Celsius
gyro x,y,z : -36, -212, -222,
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 212, 100, 15440
temperature: 30.906 degrees Celsius
gyro x,y,z : -32, -253, -240,
``` | 2012/09/06 | [
"https://Stackoverflow.com/questions/12298481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1547699/"
] | You need to look at the [datasheet](http://www.invensense.com/mems/gyro/documents/PS-MPU-6000A.pdf) to translate the raw values to meaningful ones. Look for tables like this one for the gyroscope:

If you used the default values, `FS_SEL` will be `0`. That's the sensitivity setting. So to translate your raw gyroscope values to degrees per second, you divide them by 131. You can see your numbers come out under 2 degrees per second or so, which is a reasonable margin of error.
For the default accelerometer sensitivity, you divide by `16,384` to get the value in *g* (the force exerted by the earth). You're getting on the order of 0.01g for the x and y axes and 0.95g for the z axis, which is within a reasonable margin of error for the chip staying still with the z-axis pointed toward the earth. | ```
mpu.setFullScaleGyroRange(0); //0 = +/- 250 degrees/sec | 1 = +/- 500 degrees/sec | 2 = +/- 1000 degrees/sec | 3 = +/- 2000 degrees/sec
mpu.setFullScaleAccelRange(0); //0 = +/- 2g | 1 = +/- 4g | 2 = +/- 8g | 3 = +/- 16g
``` |
42,836,750 | ```
float kernel[kernel_size][kernel_size] = {
0.000036, 0.000363, 0.001446, 0.002291, 0.001446, 0.000363, 0.000036,
0.000363, 0.003676, 0.014662, 0.023226, 0.014662, 0.003676, 0.000363,
0.001446, 0.014662, 0.058488, 0.092651, 0.058488, 0.014662, 0.001446,
0.002291, 0.023226, 0.092651, 0.146768, 0.092651, 0.023226, 0.002291,
0.001446, 0.014662, 0.058488, 0.092651, 0.058488, 0.014662, 0.001446,
0.000363, 0.003676, 0.014662, 0.023226, 0.014662, 0.003676, 0.000363,
0.000036, 0.000363, 0.001446, 0.002291, 0.001446, 0.000363, 0.000036
};
float kernel[kernel_size][kernel_size] = {
{0.000036, 0.000363, 0.001446, 0.002291, 0.001446, 0.000363, 0.000036},
{0.000363, 0.003676, 0.014662, 0.023226, 0.014662, 0.003676, 0.000363},
{0.001446, 0.014662, 0.058488, 0.092651, 0.058488, 0.014662, 0.001446},
{0.002291, 0.023226, 0.092651, 0.146768, 0.092651, 0.023226, 0.002291},
{0.001446, 0.014662, 0.058488, 0.092651, 0.058488, 0.014662, 0.001446},
{ 0.000363, 0.003676, 0.014662, 0.023226, 0.014662, 0.003676, 0.000363},
{0.000036, 0.000363, 0.001446, 0.002291, 0.001446, 0.000363, 0.000036}
};
```
As you can see, the second array has additional {} for every row.
Are these two equivalent or would the program behave differently if i substituted one of them with the other? | 2017/03/16 | [
"https://Stackoverflow.com/questions/42836750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6244285/"
] | If `kernel_size` is 7, there's no difference. Otherwise, they are different.
The first version will use the initializers sequentially to initialize full rows in row-by-row fashion (and zero-initialize the remainder of the array, if any)
The second version will skip to the next `float [kernel_size]` subarray (row) at each of the inner `{` (it will zero-initialize the remainder of each row, if any).
If `kernel_size` is greater then 7, this will obviously result in different initialization layout that in the second version. | First one is a 1 dia array with 49 entries and second one is 2 dia array with 7x7 entries |
1,049,183 | I just bought a recent ASUS laptop.
The seller clearly stated on its website that this laptop USB type-C connector was "thunderbolt 3" compatible.
Since, my USB connector doesn't have the usual little lightning logo, I'm having doubt that's this connector is really "Thunderbolt 3"...
It's clear however that the connector is USB 3.1 Gen2
I'm still confused with the different types of USB type-C connector so I would like to check if my laptop has the hardware required to be "thunderbolt 3" enabled,
According to this [article](https://thunderbolttechnology.net/blog/thunderbolt%E2%84%A2-3-controllers-launch-6th-gen-intel%C2%AE-core%E2%84%A2-processors-ifa-show), my laptop should have a dedicated controller for thunderbolt, but how to be sure?
Any help appreciated.. | 2016/03/05 | [
"https://superuser.com/questions/1049183",
"https://superuser.com",
"https://superuser.com/users/204988/"
] | I know this is a fairly old thread, but I have been looking for a definitive answer myself, as the specs for my HP 850 G5 just say Thunderbolt - ditto for all the details I could find in Device Manager.
Eventually I came across the freeware HWiNFO64 at hwinfo.com, and found the information I wanted ("Thunderbolt 3 Bridge") under the Bus heading. It will also tell you whether you have 2 or 4 PCI-E lanes (I only have two it seems, ho hum!). | I'm not sure if this is definitive, but my Dell Latitude 5401 which has Thunderbolt has this shown in the Device Manager. Maybe that might help someone:
[Screen shot of device manager showing "Thunderbolt HSA Component"](https://i.stack.imgur.com/zXwCj.png) |
1,049,183 | I just bought a recent ASUS laptop.
The seller clearly stated on its website that this laptop USB type-C connector was "thunderbolt 3" compatible.
Since, my USB connector doesn't have the usual little lightning logo, I'm having doubt that's this connector is really "Thunderbolt 3"...
It's clear however that the connector is USB 3.1 Gen2
I'm still confused with the different types of USB type-C connector so I would like to check if my laptop has the hardware required to be "thunderbolt 3" enabled,
According to this [article](https://thunderbolttechnology.net/blog/thunderbolt%E2%84%A2-3-controllers-launch-6th-gen-intel%C2%AE-core%E2%84%A2-processors-ifa-show), my laptop should have a dedicated controller for thunderbolt, but how to be sure?
Any help appreciated.. | 2016/03/05 | [
"https://superuser.com/questions/1049183",
"https://superuser.com",
"https://superuser.com/users/204988/"
] | On windows machine you can run dxdiag.exe. From there you can save a text file with all you installed HW/drivers,...
Then look for thunderbold in the text.
Something like:
```
Name: Thunderbolt(TM) Controller - 15EB
Device ID: PCI\VEN_8086&DEV_15EB&SUBSYS_08311028&REV_06\C4520491CDB7D00000
Driver: C:\WINDOWS\system32\DRIVERS\tbt100x.sys, 17.04.0079.0011 (English), 12/30/2018 08:38:22, 137680 bytes
Driver: C:\Intel\Thunderbolt\setup.msi, 1/7/2019 14:28:28, 8798208 bytes
Driver: C:\WINDOWS\system32\tbtcoinx_17_4_79_11.dll, 17.04.0079.0011 (English), 12/30/2018 08:38:24, 411600 bytes
``` | I'm not sure if this is definitive, but my Dell Latitude 5401 which has Thunderbolt has this shown in the Device Manager. Maybe that might help someone:
[Screen shot of device manager showing "Thunderbolt HSA Component"](https://i.stack.imgur.com/zXwCj.png) |
1,049,183 | I just bought a recent ASUS laptop.
The seller clearly stated on its website that this laptop USB type-C connector was "thunderbolt 3" compatible.
Since, my USB connector doesn't have the usual little lightning logo, I'm having doubt that's this connector is really "Thunderbolt 3"...
It's clear however that the connector is USB 3.1 Gen2
I'm still confused with the different types of USB type-C connector so I would like to check if my laptop has the hardware required to be "thunderbolt 3" enabled,
According to this [article](https://thunderbolttechnology.net/blog/thunderbolt%E2%84%A2-3-controllers-launch-6th-gen-intel%C2%AE-core%E2%84%A2-processors-ifa-show), my laptop should have a dedicated controller for thunderbolt, but how to be sure?
Any help appreciated.. | 2016/03/05 | [
"https://superuser.com/questions/1049183",
"https://superuser.com",
"https://superuser.com/users/204988/"
] | I finally found a way to verify the thunderbolt compatibility of a computer:
* If the laptop is really Thunderbolt enabled, there should be a line in the different *"BIOS setup options"* mentioning "Thunderbolt" somewhere (*or maybe "Alpine Ridge" for the host controller codename*)
* If there is no mention of Thunderbolt in the BIOS, then it's likely that your
computer is not Thunderbolt enabled.. | My system came with a thunderbolt software or installed.
It's called Thunderbolt Software and it lists the ports available. |
1,049,183 | I just bought a recent ASUS laptop.
The seller clearly stated on its website that this laptop USB type-C connector was "thunderbolt 3" compatible.
Since, my USB connector doesn't have the usual little lightning logo, I'm having doubt that's this connector is really "Thunderbolt 3"...
It's clear however that the connector is USB 3.1 Gen2
I'm still confused with the different types of USB type-C connector so I would like to check if my laptop has the hardware required to be "thunderbolt 3" enabled,
According to this [article](https://thunderbolttechnology.net/blog/thunderbolt%E2%84%A2-3-controllers-launch-6th-gen-intel%C2%AE-core%E2%84%A2-processors-ifa-show), my laptop should have a dedicated controller for thunderbolt, but how to be sure?
Any help appreciated.. | 2016/03/05 | [
"https://superuser.com/questions/1049183",
"https://superuser.com",
"https://superuser.com/users/204988/"
] | Hunt down your laptop specifications online for detailed specifications. For instance a [Google search](https://www.google.com/search?q=hp%2015-eg0073cl%20specs) on "HP 15-eg0073cl specs" leads to a page that says:
**External Ports**
* SuperSpeed USB Type-C® 10Gbps signaling rate (USB Power Delivery, DisplayPort™ 1.4)
* 2 SuperSpeed USB Type-A 5Gbps signaling rate
* 1 HDMI 2.0
Lack of Thunderbolt port is confirmed, however USB-C to DisplayPort 1.4 monitor should work. | I'm not sure if this is definitive, but my Dell Latitude 5401 which has Thunderbolt has this shown in the Device Manager. Maybe that might help someone:
[Screen shot of device manager showing "Thunderbolt HSA Component"](https://i.stack.imgur.com/zXwCj.png) |
1,049,183 | I just bought a recent ASUS laptop.
The seller clearly stated on its website that this laptop USB type-C connector was "thunderbolt 3" compatible.
Since, my USB connector doesn't have the usual little lightning logo, I'm having doubt that's this connector is really "Thunderbolt 3"...
It's clear however that the connector is USB 3.1 Gen2
I'm still confused with the different types of USB type-C connector so I would like to check if my laptop has the hardware required to be "thunderbolt 3" enabled,
According to this [article](https://thunderbolttechnology.net/blog/thunderbolt%E2%84%A2-3-controllers-launch-6th-gen-intel%C2%AE-core%E2%84%A2-processors-ifa-show), my laptop should have a dedicated controller for thunderbolt, but how to be sure?
Any help appreciated.. | 2016/03/05 | [
"https://superuser.com/questions/1049183",
"https://superuser.com",
"https://superuser.com/users/204988/"
] | I finally found a way to verify the thunderbolt compatibility of a computer:
* If the laptop is really Thunderbolt enabled, there should be a line in the different *"BIOS setup options"* mentioning "Thunderbolt" somewhere (*or maybe "Alpine Ridge" for the host controller codename*)
* If there is no mention of Thunderbolt in the BIOS, then it's likely that your
computer is not Thunderbolt enabled.. | I'm not sure if this is definitive, but my Dell Latitude 5401 which has Thunderbolt has this shown in the Device Manager. Maybe that might help someone:
[Screen shot of device manager showing "Thunderbolt HSA Component"](https://i.stack.imgur.com/zXwCj.png) |
1,049,183 | I just bought a recent ASUS laptop.
The seller clearly stated on its website that this laptop USB type-C connector was "thunderbolt 3" compatible.
Since, my USB connector doesn't have the usual little lightning logo, I'm having doubt that's this connector is really "Thunderbolt 3"...
It's clear however that the connector is USB 3.1 Gen2
I'm still confused with the different types of USB type-C connector so I would like to check if my laptop has the hardware required to be "thunderbolt 3" enabled,
According to this [article](https://thunderbolttechnology.net/blog/thunderbolt%E2%84%A2-3-controllers-launch-6th-gen-intel%C2%AE-core%E2%84%A2-processors-ifa-show), my laptop should have a dedicated controller for thunderbolt, but how to be sure?
Any help appreciated.. | 2016/03/05 | [
"https://superuser.com/questions/1049183",
"https://superuser.com",
"https://superuser.com/users/204988/"
] | I know this is a fairly old thread, but I have been looking for a definitive answer myself, as the specs for my HP 850 G5 just say Thunderbolt - ditto for all the details I could find in Device Manager.
Eventually I came across the freeware HWiNFO64 at hwinfo.com, and found the information I wanted ("Thunderbolt 3 Bridge") under the Bus heading. It will also tell you whether you have 2 or 4 PCI-E lanes (I only have two it seems, ho hum!). | My system came with a thunderbolt software or installed.
It's called Thunderbolt Software and it lists the ports available. |
1,049,183 | I just bought a recent ASUS laptop.
The seller clearly stated on its website that this laptop USB type-C connector was "thunderbolt 3" compatible.
Since, my USB connector doesn't have the usual little lightning logo, I'm having doubt that's this connector is really "Thunderbolt 3"...
It's clear however that the connector is USB 3.1 Gen2
I'm still confused with the different types of USB type-C connector so I would like to check if my laptop has the hardware required to be "thunderbolt 3" enabled,
According to this [article](https://thunderbolttechnology.net/blog/thunderbolt%E2%84%A2-3-controllers-launch-6th-gen-intel%C2%AE-core%E2%84%A2-processors-ifa-show), my laptop should have a dedicated controller for thunderbolt, but how to be sure?
Any help appreciated.. | 2016/03/05 | [
"https://superuser.com/questions/1049183",
"https://superuser.com",
"https://superuser.com/users/204988/"
] | I finally found a way to verify the thunderbolt compatibility of a computer:
* If the laptop is really Thunderbolt enabled, there should be a line in the different *"BIOS setup options"* mentioning "Thunderbolt" somewhere (*or maybe "Alpine Ridge" for the host controller codename*)
* If there is no mention of Thunderbolt in the BIOS, then it's likely that your
computer is not Thunderbolt enabled.. | Hunt down your laptop specifications online for detailed specifications. For instance a [Google search](https://www.google.com/search?q=hp%2015-eg0073cl%20specs) on "HP 15-eg0073cl specs" leads to a page that says:
**External Ports**
* SuperSpeed USB Type-C® 10Gbps signaling rate (USB Power Delivery, DisplayPort™ 1.4)
* 2 SuperSpeed USB Type-A 5Gbps signaling rate
* 1 HDMI 2.0
Lack of Thunderbolt port is confirmed, however USB-C to DisplayPort 1.4 monitor should work. |
1,049,183 | I just bought a recent ASUS laptop.
The seller clearly stated on its website that this laptop USB type-C connector was "thunderbolt 3" compatible.
Since, my USB connector doesn't have the usual little lightning logo, I'm having doubt that's this connector is really "Thunderbolt 3"...
It's clear however that the connector is USB 3.1 Gen2
I'm still confused with the different types of USB type-C connector so I would like to check if my laptop has the hardware required to be "thunderbolt 3" enabled,
According to this [article](https://thunderbolttechnology.net/blog/thunderbolt%E2%84%A2-3-controllers-launch-6th-gen-intel%C2%AE-core%E2%84%A2-processors-ifa-show), my laptop should have a dedicated controller for thunderbolt, but how to be sure?
Any help appreciated.. | 2016/03/05 | [
"https://superuser.com/questions/1049183",
"https://superuser.com",
"https://superuser.com/users/204988/"
] | I finally found a way to verify the thunderbolt compatibility of a computer:
* If the laptop is really Thunderbolt enabled, there should be a line in the different *"BIOS setup options"* mentioning "Thunderbolt" somewhere (*or maybe "Alpine Ridge" for the host controller codename*)
* If there is no mention of Thunderbolt in the BIOS, then it's likely that your
computer is not Thunderbolt enabled.. | I know this is a fairly old thread, but I have been looking for a definitive answer myself, as the specs for my HP 850 G5 just say Thunderbolt - ditto for all the details I could find in Device Manager.
Eventually I came across the freeware HWiNFO64 at hwinfo.com, and found the information I wanted ("Thunderbolt 3 Bridge") under the Bus heading. It will also tell you whether you have 2 or 4 PCI-E lanes (I only have two it seems, ho hum!). |
1,049,183 | I just bought a recent ASUS laptop.
The seller clearly stated on its website that this laptop USB type-C connector was "thunderbolt 3" compatible.
Since, my USB connector doesn't have the usual little lightning logo, I'm having doubt that's this connector is really "Thunderbolt 3"...
It's clear however that the connector is USB 3.1 Gen2
I'm still confused with the different types of USB type-C connector so I would like to check if my laptop has the hardware required to be "thunderbolt 3" enabled,
According to this [article](https://thunderbolttechnology.net/blog/thunderbolt%E2%84%A2-3-controllers-launch-6th-gen-intel%C2%AE-core%E2%84%A2-processors-ifa-show), my laptop should have a dedicated controller for thunderbolt, but how to be sure?
Any help appreciated.. | 2016/03/05 | [
"https://superuser.com/questions/1049183",
"https://superuser.com",
"https://superuser.com/users/204988/"
] | On windows machine you can run dxdiag.exe. From there you can save a text file with all you installed HW/drivers,...
Then look for thunderbold in the text.
Something like:
```
Name: Thunderbolt(TM) Controller - 15EB
Device ID: PCI\VEN_8086&DEV_15EB&SUBSYS_08311028&REV_06\C4520491CDB7D00000
Driver: C:\WINDOWS\system32\DRIVERS\tbt100x.sys, 17.04.0079.0011 (English), 12/30/2018 08:38:22, 137680 bytes
Driver: C:\Intel\Thunderbolt\setup.msi, 1/7/2019 14:28:28, 8798208 bytes
Driver: C:\WINDOWS\system32\tbtcoinx_17_4_79_11.dll, 17.04.0079.0011 (English), 12/30/2018 08:38:24, 411600 bytes
``` | My system came with a thunderbolt software or installed.
It's called Thunderbolt Software and it lists the ports available. |
1,049,183 | I just bought a recent ASUS laptop.
The seller clearly stated on its website that this laptop USB type-C connector was "thunderbolt 3" compatible.
Since, my USB connector doesn't have the usual little lightning logo, I'm having doubt that's this connector is really "Thunderbolt 3"...
It's clear however that the connector is USB 3.1 Gen2
I'm still confused with the different types of USB type-C connector so I would like to check if my laptop has the hardware required to be "thunderbolt 3" enabled,
According to this [article](https://thunderbolttechnology.net/blog/thunderbolt%E2%84%A2-3-controllers-launch-6th-gen-intel%C2%AE-core%E2%84%A2-processors-ifa-show), my laptop should have a dedicated controller for thunderbolt, but how to be sure?
Any help appreciated.. | 2016/03/05 | [
"https://superuser.com/questions/1049183",
"https://superuser.com",
"https://superuser.com/users/204988/"
] | Hunt down your laptop specifications online for detailed specifications. For instance a [Google search](https://www.google.com/search?q=hp%2015-eg0073cl%20specs) on "HP 15-eg0073cl specs" leads to a page that says:
**External Ports**
* SuperSpeed USB Type-C® 10Gbps signaling rate (USB Power Delivery, DisplayPort™ 1.4)
* 2 SuperSpeed USB Type-A 5Gbps signaling rate
* 1 HDMI 2.0
Lack of Thunderbolt port is confirmed, however USB-C to DisplayPort 1.4 monitor should work. | My system came with a thunderbolt software or installed.
It's called Thunderbolt Software and it lists the ports available. |
139,923 | I have a sequence of bytes:
<https://drive.google.com/file/d/17sfchPgsySi2ilIxLuBb1q-UUqq5lO87>
What the data is, is unknown (see NOTE below).
I'm pretty sure this data is compressed in some way, due to the ent analysis results:
```
$ ent first-chunk
Entropy = 7.997831 bits per byte.
Optimum compression would reduce the size
of this 949674 byte file by 0 percent.
Chi square distribution for 949674 samples is 2962.74, and randomly
would exceed this value less than 0.01 percent of the times.
Arithmetic mean value of data bytes is 127.3922 (127.5 = random).
Monte Carlo value for Pi is 3.157487727 (error 0.51 percent).
Serial correlation coefficient is 0.001738 (totally uncorrelated = 0.0).
```
According to the Chi square distribution the data is definitely not random.
And compression is at an optimum. This leads me to believe the data is compressed and not encrypted. Is this a correct inference?
I've tried to decompress this data assuming the compression method to be zip, gz, xz, lz4, deflate, lzma, bzip, using tools like unlzma, gunzip, unzip, unlz4, zlib-flate etc. and none of them have worked. I always end up with a "file format not recognized" or a "invalid header check" error.
How do I find what compression method was used on the data? Could it be that the compression headers are missing?
---
NOTE:
This data is part of a slightly larger data file that is (possibly) the firmware and additional memory of a bluetooth speaker Flash memory.
The whole file is:
<https://drive.google.com/file/d/1e9yG8xMkZ331C2TOTOzo9Y93L4abxX9F> | 2021/05/05 | [
"https://cs.stackexchange.com/questions/139923",
"https://cs.stackexchange.com",
"https://cs.stackexchange.com/users/136249/"
] | This file contains some repeated long byte sequences. In particular, the 66(decimal)-byte sequence beginning `49 97 CE...` occurs many times, and always at an offset that's a multiple of 66.
If you decrypt the file as a bitwise [Vigenère cipher](https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher) with that as the key, the result has a lot of structure. It appears to be divided into 66-byte records with 64 bytes of payload followed by a 2-byte checksum. (I assume it's a checksum because it's a deterministic function of the first 64 bytes, and the first 64 bytes sometimes have simple patterns like `01 01 01...` but the last two bytes always look like garbage.)
Beyond that, I can't figure anything out. Notably, while some records consist entirely of recognizable patterns (except the checksum), and some begin with recognizable patterns and end as garbage, none begin as garbage and end recognizably, which makes me think that there may be more to the encryption than a simple xor. | It's a reasonable hypothesis, but definitely not guaranteed, that it was compressed. There is general no way to know for sure which compression method was used. You've already tried some reasonable things to try. |
32,488,313 | In PHP, how do variable scope rules apply to Try/Catch blocks? Do variables declared within the `try` block go out of scope when the block has finished? Or are they in scope until the end of the function/method?
For example:
```
try
{
// This may throw an exception when created!
$o = new Pronk();
}
catch (Exception $ex)
{
// Handle & exit somehow; not important here
return false;
}
$o->doPronk();
```
Is this valid? Or should `$o = NULL;` be set before the try/catch to keep `$o` in scope?
(I know that the sample code *does* work, however I also know PHP can get a little stupid when it comes to scoping. My question is, ideally, how *should* it work? What is the correct and proper way to do this?) | 2015/09/09 | [
"https://Stackoverflow.com/questions/32488313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192831/"
] | Your code is valid. Variable scope in PHP is by function, not block. So you can assign a variable inside the `try` block, and access it outside, so long as they're in the same function. | I believe this is opinion based mostly. The code is correct and it will work as expected as long as the `catch` block always has the `return` statement. if the `catch` block does not return, the flow will continue and the code outside the try/catch block will be executed, and it will fail, because `$o` won't be initialized. You will be able to access `$o` because of the lack of block scope in php, but the method won't exist because the object construction failed. |
32,488,313 | In PHP, how do variable scope rules apply to Try/Catch blocks? Do variables declared within the `try` block go out of scope when the block has finished? Or are they in scope until the end of the function/method?
For example:
```
try
{
// This may throw an exception when created!
$o = new Pronk();
}
catch (Exception $ex)
{
// Handle & exit somehow; not important here
return false;
}
$o->doPronk();
```
Is this valid? Or should `$o = NULL;` be set before the try/catch to keep `$o` in scope?
(I know that the sample code *does* work, however I also know PHP can get a little stupid when it comes to scoping. My question is, ideally, how *should* it work? What is the correct and proper way to do this?) | 2015/09/09 | [
"https://Stackoverflow.com/questions/32488313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192831/"
] | I believe this is opinion based mostly. The code is correct and it will work as expected as long as the `catch` block always has the `return` statement. if the `catch` block does not return, the flow will continue and the code outside the try/catch block will be executed, and it will fail, because `$o` won't be initialized. You will be able to access `$o` because of the lack of block scope in php, but the method won't exist because the object construction failed. | the main concept for the exception handling is that if anything goes wrong inside the "try" block the code will enter into the "catch" block. so if
```
$o = new Pronk();
```
does not raise any error it will be in scope. we don't have to declare it before try/catch block.
your code is perfectly valid. |
32,488,313 | In PHP, how do variable scope rules apply to Try/Catch blocks? Do variables declared within the `try` block go out of scope when the block has finished? Or are they in scope until the end of the function/method?
For example:
```
try
{
// This may throw an exception when created!
$o = new Pronk();
}
catch (Exception $ex)
{
// Handle & exit somehow; not important here
return false;
}
$o->doPronk();
```
Is this valid? Or should `$o = NULL;` be set before the try/catch to keep `$o` in scope?
(I know that the sample code *does* work, however I also know PHP can get a little stupid when it comes to scoping. My question is, ideally, how *should* it work? What is the correct and proper way to do this?) | 2015/09/09 | [
"https://Stackoverflow.com/questions/32488313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192831/"
] | I believe this is opinion based mostly. The code is correct and it will work as expected as long as the `catch` block always has the `return` statement. if the `catch` block does not return, the flow will continue and the code outside the try/catch block will be executed, and it will fail, because `$o` won't be initialized. You will be able to access `$o` because of the lack of block scope in php, but the method won't exist because the object construction failed. | As long as your obj is correctly constructed
you can expect to use `obj` outside of try/catch block
However, suppose that there was an exception during construction.
Then your `obj` wouldn't be even constructed inside try block.
Therefore, you wouldn't be able to call the functions on `obj` because `obj` was not even created. |
32,488,313 | In PHP, how do variable scope rules apply to Try/Catch blocks? Do variables declared within the `try` block go out of scope when the block has finished? Or are they in scope until the end of the function/method?
For example:
```
try
{
// This may throw an exception when created!
$o = new Pronk();
}
catch (Exception $ex)
{
// Handle & exit somehow; not important here
return false;
}
$o->doPronk();
```
Is this valid? Or should `$o = NULL;` be set before the try/catch to keep `$o` in scope?
(I know that the sample code *does* work, however I also know PHP can get a little stupid when it comes to scoping. My question is, ideally, how *should* it work? What is the correct and proper way to do this?) | 2015/09/09 | [
"https://Stackoverflow.com/questions/32488313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192831/"
] | Your code is valid. Variable scope in PHP is by function, not block. So you can assign a variable inside the `try` block, and access it outside, so long as they're in the same function. | the main concept for the exception handling is that if anything goes wrong inside the "try" block the code will enter into the "catch" block. so if
```
$o = new Pronk();
```
does not raise any error it will be in scope. we don't have to declare it before try/catch block.
your code is perfectly valid. |
32,488,313 | In PHP, how do variable scope rules apply to Try/Catch blocks? Do variables declared within the `try` block go out of scope when the block has finished? Or are they in scope until the end of the function/method?
For example:
```
try
{
// This may throw an exception when created!
$o = new Pronk();
}
catch (Exception $ex)
{
// Handle & exit somehow; not important here
return false;
}
$o->doPronk();
```
Is this valid? Or should `$o = NULL;` be set before the try/catch to keep `$o` in scope?
(I know that the sample code *does* work, however I also know PHP can get a little stupid when it comes to scoping. My question is, ideally, how *should* it work? What is the correct and proper way to do this?) | 2015/09/09 | [
"https://Stackoverflow.com/questions/32488313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192831/"
] | Your code is valid. Variable scope in PHP is by function, not block. So you can assign a variable inside the `try` block, and access it outside, so long as they're in the same function. | As long as your obj is correctly constructed
you can expect to use `obj` outside of try/catch block
However, suppose that there was an exception during construction.
Then your `obj` wouldn't be even constructed inside try block.
Therefore, you wouldn't be able to call the functions on `obj` because `obj` was not even created. |
32,488,313 | In PHP, how do variable scope rules apply to Try/Catch blocks? Do variables declared within the `try` block go out of scope when the block has finished? Or are they in scope until the end of the function/method?
For example:
```
try
{
// This may throw an exception when created!
$o = new Pronk();
}
catch (Exception $ex)
{
// Handle & exit somehow; not important here
return false;
}
$o->doPronk();
```
Is this valid? Or should `$o = NULL;` be set before the try/catch to keep `$o` in scope?
(I know that the sample code *does* work, however I also know PHP can get a little stupid when it comes to scoping. My question is, ideally, how *should* it work? What is the correct and proper way to do this?) | 2015/09/09 | [
"https://Stackoverflow.com/questions/32488313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192831/"
] | the main concept for the exception handling is that if anything goes wrong inside the "try" block the code will enter into the "catch" block. so if
```
$o = new Pronk();
```
does not raise any error it will be in scope. we don't have to declare it before try/catch block.
your code is perfectly valid. | As long as your obj is correctly constructed
you can expect to use `obj` outside of try/catch block
However, suppose that there was an exception during construction.
Then your `obj` wouldn't be even constructed inside try block.
Therefore, you wouldn't be able to call the functions on `obj` because `obj` was not even created. |
43,160 | A word used when patients say they feel better when they have been lied to. Not necessarily lied to, but told they have been given a drug or undergone an operation which would supposedly make them healed, which was not actually done. | 2011/09/24 | [
"https://english.stackexchange.com/questions/43160",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/13345/"
] | I believe you are referring to the placebo effect. A placebo given as medicine is a pill that has no medical effect (it's made of sugar, has no taste, no nutritional value -- it just 'feels' like you're taking a pill.)
It has been scientifically proven that placebos help people recover from illness. This is a counter intuitive result because placebos should have no medical effect. However, they do. | I think you are referring to the [placebo effect](http://en.wikipedia.org/wiki/Placebo). |
47,806,500 | So I am trying to use TinyMCE for an editor within an application. and I have correctly installed the npm module, copied the skin into my assets folder and correctly added the scripts to my angular-cli.json. Here is what I have done with my `EditorComponent`:
```
import { Component, OnInit, AfterViewInit, EventEmitter, Input, Output } from '@angular/core';
import 'tinymce';
declare var tinymce: any;
@Component({
selector: 'app-editor',
templateUrl: './editor.component.html',
styleUrls: ['./editor.component.scss']
})
export class EditorComponent implements OnInit, AfterViewInit {
@Input() elementId: string;
@Output() onEditorKeyup = new EventEmitter<any>();
editor: any;
constructor() { }
ngOnInit() {
}
ngAfterViewInit() {
tinymce.init({
selector: '#' + this.elementId,
plugins: ['link', 'paste', 'table'],
skin_url: 'assets/skins/lightgray',
setup: editor => {
this.editor = editor;
editor.on('keyup', () => {
const content = editor.getContent();
this.onEditorKeyup.emit(content);
});
}
});
}
ngOnDestroy() {
tinymce.remove(this.editor);
}
}
```
and here is the markup for the `EditorComponent`:
```
<textarea id="{{elementId}}"></textarea>
```
and now being used in a parent component:
```
<app-editor [elementId]="'editor'" (onEditorKeyup)="keyupHandlerFunction($event)"></app-editor>
```
I have followed this link from their website: <https://www.tinymce.com/docs/integrations/angular2/>
in addition to a few other posts showing how to declare `tinymce` in the component.
Here is the angular-cli.json app[0].scripts as well:
```
"scripts": [
"../node_modules/tinymce/tinymce.js",
"../node_modules/tinymce/themes/modern/theme.js",
"../node_modules/tinymce/plugins/link/plugin.js",
"../node_modules/tinymce/plugins/paste/plugin.js",
"../node_modules/tinymce/plugins/table/plugin.js"
]
```
I seem to be getting this error in my console which is thrown by tinymce.js:
[](https://i.stack.imgur.com/Rb4vw.png)
But I cannot find a replicated issue anywhere out there, and the console log gives no clue to where in my code this issue is arising. My editor component also just shows up completely blank in the parent component. I appreciate any and all help. Thanks in advance. | 2017/12/14 | [
"https://Stackoverflow.com/questions/47806500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1148618/"
] | I had the same error and got it working in Angular 5:
Copy the 3 Folders "plugins", "skins", "themes" from the "node\_modules/tinymce" folder into your apps "assets" folder.
Also set the baseURL for tinymce to your assets folder afterwards
```
ngAfterViewInit() {
tinymce.baseURL = 'assets';
tinymce.init({
selector: '#' + this.elementId,
plugins: ['link', 'paste', 'table'],
skin_url: 'assets/skins/lightgray',
setup: editor => {
this.editor = editor;
editor.on('keyup', () => {
const content = editor.getContent();
this.onEditorKeyup.emit(content);
});
},
});
}
``` | Sorry for being late. Here I found the issue on GitHub:
>
> <https://github.com/tinymce/tinymce/issues/4164>
>
>
>
The temporary solution is to import your scripts like this:
```
"../node_modules/tinymce/tinymce.min.js",
"../node_modules/tinymce/themes/modern/theme.min.js"
```
Or wait to the next version.
Sorry for my bad english, have a good day. |
47,806,500 | So I am trying to use TinyMCE for an editor within an application. and I have correctly installed the npm module, copied the skin into my assets folder and correctly added the scripts to my angular-cli.json. Here is what I have done with my `EditorComponent`:
```
import { Component, OnInit, AfterViewInit, EventEmitter, Input, Output } from '@angular/core';
import 'tinymce';
declare var tinymce: any;
@Component({
selector: 'app-editor',
templateUrl: './editor.component.html',
styleUrls: ['./editor.component.scss']
})
export class EditorComponent implements OnInit, AfterViewInit {
@Input() elementId: string;
@Output() onEditorKeyup = new EventEmitter<any>();
editor: any;
constructor() { }
ngOnInit() {
}
ngAfterViewInit() {
tinymce.init({
selector: '#' + this.elementId,
plugins: ['link', 'paste', 'table'],
skin_url: 'assets/skins/lightgray',
setup: editor => {
this.editor = editor;
editor.on('keyup', () => {
const content = editor.getContent();
this.onEditorKeyup.emit(content);
});
}
});
}
ngOnDestroy() {
tinymce.remove(this.editor);
}
}
```
and here is the markup for the `EditorComponent`:
```
<textarea id="{{elementId}}"></textarea>
```
and now being used in a parent component:
```
<app-editor [elementId]="'editor'" (onEditorKeyup)="keyupHandlerFunction($event)"></app-editor>
```
I have followed this link from their website: <https://www.tinymce.com/docs/integrations/angular2/>
in addition to a few other posts showing how to declare `tinymce` in the component.
Here is the angular-cli.json app[0].scripts as well:
```
"scripts": [
"../node_modules/tinymce/tinymce.js",
"../node_modules/tinymce/themes/modern/theme.js",
"../node_modules/tinymce/plugins/link/plugin.js",
"../node_modules/tinymce/plugins/paste/plugin.js",
"../node_modules/tinymce/plugins/table/plugin.js"
]
```
I seem to be getting this error in my console which is thrown by tinymce.js:
[](https://i.stack.imgur.com/Rb4vw.png)
But I cannot find a replicated issue anywhere out there, and the console log gives no clue to where in my code this issue is arising. My editor component also just shows up completely blank in the parent component. I appreciate any and all help. Thanks in advance. | 2017/12/14 | [
"https://Stackoverflow.com/questions/47806500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1148618/"
] | I had the same error and got it working in Angular 5:
Copy the 3 Folders "plugins", "skins", "themes" from the "node\_modules/tinymce" folder into your apps "assets" folder.
Also set the baseURL for tinymce to your assets folder afterwards
```
ngAfterViewInit() {
tinymce.baseURL = 'assets';
tinymce.init({
selector: '#' + this.elementId,
plugins: ['link', 'paste', 'table'],
skin_url: 'assets/skins/lightgray',
setup: editor => {
this.editor = editor;
editor.on('keyup', () => {
const content = editor.getContent();
this.onEditorKeyup.emit(content);
});
},
});
}
``` | You might lost the theme folder bundled with the `tinymce` directory. Now look into the `theme` folder if there is no `modern` folder then got to: <https://www.tiny.cloud/get-tiny/self-hosted/>, download the version you prefer and configure to your project manually.
Hope this will help! :) |
47,806,500 | So I am trying to use TinyMCE for an editor within an application. and I have correctly installed the npm module, copied the skin into my assets folder and correctly added the scripts to my angular-cli.json. Here is what I have done with my `EditorComponent`:
```
import { Component, OnInit, AfterViewInit, EventEmitter, Input, Output } from '@angular/core';
import 'tinymce';
declare var tinymce: any;
@Component({
selector: 'app-editor',
templateUrl: './editor.component.html',
styleUrls: ['./editor.component.scss']
})
export class EditorComponent implements OnInit, AfterViewInit {
@Input() elementId: string;
@Output() onEditorKeyup = new EventEmitter<any>();
editor: any;
constructor() { }
ngOnInit() {
}
ngAfterViewInit() {
tinymce.init({
selector: '#' + this.elementId,
plugins: ['link', 'paste', 'table'],
skin_url: 'assets/skins/lightgray',
setup: editor => {
this.editor = editor;
editor.on('keyup', () => {
const content = editor.getContent();
this.onEditorKeyup.emit(content);
});
}
});
}
ngOnDestroy() {
tinymce.remove(this.editor);
}
}
```
and here is the markup for the `EditorComponent`:
```
<textarea id="{{elementId}}"></textarea>
```
and now being used in a parent component:
```
<app-editor [elementId]="'editor'" (onEditorKeyup)="keyupHandlerFunction($event)"></app-editor>
```
I have followed this link from their website: <https://www.tinymce.com/docs/integrations/angular2/>
in addition to a few other posts showing how to declare `tinymce` in the component.
Here is the angular-cli.json app[0].scripts as well:
```
"scripts": [
"../node_modules/tinymce/tinymce.js",
"../node_modules/tinymce/themes/modern/theme.js",
"../node_modules/tinymce/plugins/link/plugin.js",
"../node_modules/tinymce/plugins/paste/plugin.js",
"../node_modules/tinymce/plugins/table/plugin.js"
]
```
I seem to be getting this error in my console which is thrown by tinymce.js:
[](https://i.stack.imgur.com/Rb4vw.png)
But I cannot find a replicated issue anywhere out there, and the console log gives no clue to where in my code this issue is arising. My editor component also just shows up completely blank in the parent component. I appreciate any and all help. Thanks in advance. | 2017/12/14 | [
"https://Stackoverflow.com/questions/47806500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1148618/"
] | I had the same error and got it working in Angular 5:
Copy the 3 Folders "plugins", "skins", "themes" from the "node\_modules/tinymce" folder into your apps "assets" folder.
Also set the baseURL for tinymce to your assets folder afterwards
```
ngAfterViewInit() {
tinymce.baseURL = 'assets';
tinymce.init({
selector: '#' + this.elementId,
plugins: ['link', 'paste', 'table'],
skin_url: 'assets/skins/lightgray',
setup: editor => {
this.editor = editor;
editor.on('keyup', () => {
const content = editor.getContent();
this.onEditorKeyup.emit(content);
});
},
});
}
``` | Well actually I had the same problem but in my Syfomny 4 project with webpack. I've searched in many places and ended up with my own idea which works - at least at this moment.
First of all in **js file** that's gonna have tinymce logic add:
```
import tinymce from 'tinymce/tinymce';
import 'tinymce/themes/silver';
```
Now this article: <https://medium.freecodecamp.org/how-to-setup-tinymce-in-your-rails-app-using-webpack-edf030915332> says that You can use this:
```
import ‘tinymce/skins/lightgray/skin.min.css’;
```
but it will not work, since there is no such file as **skin.min.css**.
The solution is to import every single file like:
```
import 'tinymce/skins/content/default/content.css';
import 'tinymce/skins/content/document/content.css';
import 'tinymce/skins/content/writer/content.css';
import 'tinymce/skins/ui/oxide-dark/content.css';
```
but then this destroys the page theme...
So the final solution is adding wrapper for form which will have the tiny-mce:
```
<section id="tiny-mce-wrapper">
<form>
<textarea class="tiny-mce"></textarea>
</form>
</section>
```
then:
* **move all csses from node/modules/tinymce/skin** into place where You store Your css.
* change extension of all files from css to scss
* in each file add changes so that the styles will apply **only** for Your tinmce textarea when it's inside **#tiny-mce** |
47,806,500 | So I am trying to use TinyMCE for an editor within an application. and I have correctly installed the npm module, copied the skin into my assets folder and correctly added the scripts to my angular-cli.json. Here is what I have done with my `EditorComponent`:
```
import { Component, OnInit, AfterViewInit, EventEmitter, Input, Output } from '@angular/core';
import 'tinymce';
declare var tinymce: any;
@Component({
selector: 'app-editor',
templateUrl: './editor.component.html',
styleUrls: ['./editor.component.scss']
})
export class EditorComponent implements OnInit, AfterViewInit {
@Input() elementId: string;
@Output() onEditorKeyup = new EventEmitter<any>();
editor: any;
constructor() { }
ngOnInit() {
}
ngAfterViewInit() {
tinymce.init({
selector: '#' + this.elementId,
plugins: ['link', 'paste', 'table'],
skin_url: 'assets/skins/lightgray',
setup: editor => {
this.editor = editor;
editor.on('keyup', () => {
const content = editor.getContent();
this.onEditorKeyup.emit(content);
});
}
});
}
ngOnDestroy() {
tinymce.remove(this.editor);
}
}
```
and here is the markup for the `EditorComponent`:
```
<textarea id="{{elementId}}"></textarea>
```
and now being used in a parent component:
```
<app-editor [elementId]="'editor'" (onEditorKeyup)="keyupHandlerFunction($event)"></app-editor>
```
I have followed this link from their website: <https://www.tinymce.com/docs/integrations/angular2/>
in addition to a few other posts showing how to declare `tinymce` in the component.
Here is the angular-cli.json app[0].scripts as well:
```
"scripts": [
"../node_modules/tinymce/tinymce.js",
"../node_modules/tinymce/themes/modern/theme.js",
"../node_modules/tinymce/plugins/link/plugin.js",
"../node_modules/tinymce/plugins/paste/plugin.js",
"../node_modules/tinymce/plugins/table/plugin.js"
]
```
I seem to be getting this error in my console which is thrown by tinymce.js:
[](https://i.stack.imgur.com/Rb4vw.png)
But I cannot find a replicated issue anywhere out there, and the console log gives no clue to where in my code this issue is arising. My editor component also just shows up completely blank in the parent component. I appreciate any and all help. Thanks in advance. | 2017/12/14 | [
"https://Stackoverflow.com/questions/47806500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1148618/"
] | Well actually I had the same problem but in my Syfomny 4 project with webpack. I've searched in many places and ended up with my own idea which works - at least at this moment.
First of all in **js file** that's gonna have tinymce logic add:
```
import tinymce from 'tinymce/tinymce';
import 'tinymce/themes/silver';
```
Now this article: <https://medium.freecodecamp.org/how-to-setup-tinymce-in-your-rails-app-using-webpack-edf030915332> says that You can use this:
```
import ‘tinymce/skins/lightgray/skin.min.css’;
```
but it will not work, since there is no such file as **skin.min.css**.
The solution is to import every single file like:
```
import 'tinymce/skins/content/default/content.css';
import 'tinymce/skins/content/document/content.css';
import 'tinymce/skins/content/writer/content.css';
import 'tinymce/skins/ui/oxide-dark/content.css';
```
but then this destroys the page theme...
So the final solution is adding wrapper for form which will have the tiny-mce:
```
<section id="tiny-mce-wrapper">
<form>
<textarea class="tiny-mce"></textarea>
</form>
</section>
```
then:
* **move all csses from node/modules/tinymce/skin** into place where You store Your css.
* change extension of all files from css to scss
* in each file add changes so that the styles will apply **only** for Your tinmce textarea when it's inside **#tiny-mce** | Sorry for being late. Here I found the issue on GitHub:
>
> <https://github.com/tinymce/tinymce/issues/4164>
>
>
>
The temporary solution is to import your scripts like this:
```
"../node_modules/tinymce/tinymce.min.js",
"../node_modules/tinymce/themes/modern/theme.min.js"
```
Or wait to the next version.
Sorry for my bad english, have a good day. |
47,806,500 | So I am trying to use TinyMCE for an editor within an application. and I have correctly installed the npm module, copied the skin into my assets folder and correctly added the scripts to my angular-cli.json. Here is what I have done with my `EditorComponent`:
```
import { Component, OnInit, AfterViewInit, EventEmitter, Input, Output } from '@angular/core';
import 'tinymce';
declare var tinymce: any;
@Component({
selector: 'app-editor',
templateUrl: './editor.component.html',
styleUrls: ['./editor.component.scss']
})
export class EditorComponent implements OnInit, AfterViewInit {
@Input() elementId: string;
@Output() onEditorKeyup = new EventEmitter<any>();
editor: any;
constructor() { }
ngOnInit() {
}
ngAfterViewInit() {
tinymce.init({
selector: '#' + this.elementId,
plugins: ['link', 'paste', 'table'],
skin_url: 'assets/skins/lightgray',
setup: editor => {
this.editor = editor;
editor.on('keyup', () => {
const content = editor.getContent();
this.onEditorKeyup.emit(content);
});
}
});
}
ngOnDestroy() {
tinymce.remove(this.editor);
}
}
```
and here is the markup for the `EditorComponent`:
```
<textarea id="{{elementId}}"></textarea>
```
and now being used in a parent component:
```
<app-editor [elementId]="'editor'" (onEditorKeyup)="keyupHandlerFunction($event)"></app-editor>
```
I have followed this link from their website: <https://www.tinymce.com/docs/integrations/angular2/>
in addition to a few other posts showing how to declare `tinymce` in the component.
Here is the angular-cli.json app[0].scripts as well:
```
"scripts": [
"../node_modules/tinymce/tinymce.js",
"../node_modules/tinymce/themes/modern/theme.js",
"../node_modules/tinymce/plugins/link/plugin.js",
"../node_modules/tinymce/plugins/paste/plugin.js",
"../node_modules/tinymce/plugins/table/plugin.js"
]
```
I seem to be getting this error in my console which is thrown by tinymce.js:
[](https://i.stack.imgur.com/Rb4vw.png)
But I cannot find a replicated issue anywhere out there, and the console log gives no clue to where in my code this issue is arising. My editor component also just shows up completely blank in the parent component. I appreciate any and all help. Thanks in advance. | 2017/12/14 | [
"https://Stackoverflow.com/questions/47806500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1148618/"
] | I had a very similar issue, and I discovered that somehow TinyMCE changed the location of where it was seeking the asset archives from
```
"/tinymce/skins/",
"/tinymce/themes/",
"/tinymce/plugins/",
```
to
```
"/skins/",
"/themes/",
"/plugins/",
```
Because of this the output in the assets config in the Angular.json file was wrong and I had to fix it from:
```
{ "glob": "**/*", "input": "node_modules/tinymce/skins", "output": "/tinymce/skins/" },
{ "glob": "**/*", "input": "node_modules/tinymce/themes", "output": "/tinymce/themes/" },
{ "glob": "**/*", "input": "node_modules/tinymce/plugins", "output": "/tinymce/plugins/" }
```
To:
```
{ "glob": "**/*", "input": "node_modules/tinymce/skins", "output": "/skins/" },
{ "glob": "**/*", "input": "node_modules/tinymce/themes", "output": "/themes/" },
{ "glob": "**/*", "input": "node_modules/tinymce/plugins", "output": "/plugins/" }
```
Unfortunately, I have not found out what caused the change in behaviour but I do believe this is a better answer than manually importing the scripts or copying them inside your application folder. | Sorry for being late. Here I found the issue on GitHub:
>
> <https://github.com/tinymce/tinymce/issues/4164>
>
>
>
The temporary solution is to import your scripts like this:
```
"../node_modules/tinymce/tinymce.min.js",
"../node_modules/tinymce/themes/modern/theme.min.js"
```
Or wait to the next version.
Sorry for my bad english, have a good day. |
47,806,500 | So I am trying to use TinyMCE for an editor within an application. and I have correctly installed the npm module, copied the skin into my assets folder and correctly added the scripts to my angular-cli.json. Here is what I have done with my `EditorComponent`:
```
import { Component, OnInit, AfterViewInit, EventEmitter, Input, Output } from '@angular/core';
import 'tinymce';
declare var tinymce: any;
@Component({
selector: 'app-editor',
templateUrl: './editor.component.html',
styleUrls: ['./editor.component.scss']
})
export class EditorComponent implements OnInit, AfterViewInit {
@Input() elementId: string;
@Output() onEditorKeyup = new EventEmitter<any>();
editor: any;
constructor() { }
ngOnInit() {
}
ngAfterViewInit() {
tinymce.init({
selector: '#' + this.elementId,
plugins: ['link', 'paste', 'table'],
skin_url: 'assets/skins/lightgray',
setup: editor => {
this.editor = editor;
editor.on('keyup', () => {
const content = editor.getContent();
this.onEditorKeyup.emit(content);
});
}
});
}
ngOnDestroy() {
tinymce.remove(this.editor);
}
}
```
and here is the markup for the `EditorComponent`:
```
<textarea id="{{elementId}}"></textarea>
```
and now being used in a parent component:
```
<app-editor [elementId]="'editor'" (onEditorKeyup)="keyupHandlerFunction($event)"></app-editor>
```
I have followed this link from their website: <https://www.tinymce.com/docs/integrations/angular2/>
in addition to a few other posts showing how to declare `tinymce` in the component.
Here is the angular-cli.json app[0].scripts as well:
```
"scripts": [
"../node_modules/tinymce/tinymce.js",
"../node_modules/tinymce/themes/modern/theme.js",
"../node_modules/tinymce/plugins/link/plugin.js",
"../node_modules/tinymce/plugins/paste/plugin.js",
"../node_modules/tinymce/plugins/table/plugin.js"
]
```
I seem to be getting this error in my console which is thrown by tinymce.js:
[](https://i.stack.imgur.com/Rb4vw.png)
But I cannot find a replicated issue anywhere out there, and the console log gives no clue to where in my code this issue is arising. My editor component also just shows up completely blank in the parent component. I appreciate any and all help. Thanks in advance. | 2017/12/14 | [
"https://Stackoverflow.com/questions/47806500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1148618/"
] | Well actually I had the same problem but in my Syfomny 4 project with webpack. I've searched in many places and ended up with my own idea which works - at least at this moment.
First of all in **js file** that's gonna have tinymce logic add:
```
import tinymce from 'tinymce/tinymce';
import 'tinymce/themes/silver';
```
Now this article: <https://medium.freecodecamp.org/how-to-setup-tinymce-in-your-rails-app-using-webpack-edf030915332> says that You can use this:
```
import ‘tinymce/skins/lightgray/skin.min.css’;
```
but it will not work, since there is no such file as **skin.min.css**.
The solution is to import every single file like:
```
import 'tinymce/skins/content/default/content.css';
import 'tinymce/skins/content/document/content.css';
import 'tinymce/skins/content/writer/content.css';
import 'tinymce/skins/ui/oxide-dark/content.css';
```
but then this destroys the page theme...
So the final solution is adding wrapper for form which will have the tiny-mce:
```
<section id="tiny-mce-wrapper">
<form>
<textarea class="tiny-mce"></textarea>
</form>
</section>
```
then:
* **move all csses from node/modules/tinymce/skin** into place where You store Your css.
* change extension of all files from css to scss
* in each file add changes so that the styles will apply **only** for Your tinmce textarea when it's inside **#tiny-mce** | You might lost the theme folder bundled with the `tinymce` directory. Now look into the `theme` folder if there is no `modern` folder then got to: <https://www.tiny.cloud/get-tiny/self-hosted/>, download the version you prefer and configure to your project manually.
Hope this will help! :) |
47,806,500 | So I am trying to use TinyMCE for an editor within an application. and I have correctly installed the npm module, copied the skin into my assets folder and correctly added the scripts to my angular-cli.json. Here is what I have done with my `EditorComponent`:
```
import { Component, OnInit, AfterViewInit, EventEmitter, Input, Output } from '@angular/core';
import 'tinymce';
declare var tinymce: any;
@Component({
selector: 'app-editor',
templateUrl: './editor.component.html',
styleUrls: ['./editor.component.scss']
})
export class EditorComponent implements OnInit, AfterViewInit {
@Input() elementId: string;
@Output() onEditorKeyup = new EventEmitter<any>();
editor: any;
constructor() { }
ngOnInit() {
}
ngAfterViewInit() {
tinymce.init({
selector: '#' + this.elementId,
plugins: ['link', 'paste', 'table'],
skin_url: 'assets/skins/lightgray',
setup: editor => {
this.editor = editor;
editor.on('keyup', () => {
const content = editor.getContent();
this.onEditorKeyup.emit(content);
});
}
});
}
ngOnDestroy() {
tinymce.remove(this.editor);
}
}
```
and here is the markup for the `EditorComponent`:
```
<textarea id="{{elementId}}"></textarea>
```
and now being used in a parent component:
```
<app-editor [elementId]="'editor'" (onEditorKeyup)="keyupHandlerFunction($event)"></app-editor>
```
I have followed this link from their website: <https://www.tinymce.com/docs/integrations/angular2/>
in addition to a few other posts showing how to declare `tinymce` in the component.
Here is the angular-cli.json app[0].scripts as well:
```
"scripts": [
"../node_modules/tinymce/tinymce.js",
"../node_modules/tinymce/themes/modern/theme.js",
"../node_modules/tinymce/plugins/link/plugin.js",
"../node_modules/tinymce/plugins/paste/plugin.js",
"../node_modules/tinymce/plugins/table/plugin.js"
]
```
I seem to be getting this error in my console which is thrown by tinymce.js:
[](https://i.stack.imgur.com/Rb4vw.png)
But I cannot find a replicated issue anywhere out there, and the console log gives no clue to where in my code this issue is arising. My editor component also just shows up completely blank in the parent component. I appreciate any and all help. Thanks in advance. | 2017/12/14 | [
"https://Stackoverflow.com/questions/47806500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1148618/"
] | I had a very similar issue, and I discovered that somehow TinyMCE changed the location of where it was seeking the asset archives from
```
"/tinymce/skins/",
"/tinymce/themes/",
"/tinymce/plugins/",
```
to
```
"/skins/",
"/themes/",
"/plugins/",
```
Because of this the output in the assets config in the Angular.json file was wrong and I had to fix it from:
```
{ "glob": "**/*", "input": "node_modules/tinymce/skins", "output": "/tinymce/skins/" },
{ "glob": "**/*", "input": "node_modules/tinymce/themes", "output": "/tinymce/themes/" },
{ "glob": "**/*", "input": "node_modules/tinymce/plugins", "output": "/tinymce/plugins/" }
```
To:
```
{ "glob": "**/*", "input": "node_modules/tinymce/skins", "output": "/skins/" },
{ "glob": "**/*", "input": "node_modules/tinymce/themes", "output": "/themes/" },
{ "glob": "**/*", "input": "node_modules/tinymce/plugins", "output": "/plugins/" }
```
Unfortunately, I have not found out what caused the change in behaviour but I do believe this is a better answer than manually importing the scripts or copying them inside your application folder. | You might lost the theme folder bundled with the `tinymce` directory. Now look into the `theme` folder if there is no `modern` folder then got to: <https://www.tiny.cloud/get-tiny/self-hosted/>, download the version you prefer and configure to your project manually.
Hope this will help! :) |
47,806,500 | So I am trying to use TinyMCE for an editor within an application. and I have correctly installed the npm module, copied the skin into my assets folder and correctly added the scripts to my angular-cli.json. Here is what I have done with my `EditorComponent`:
```
import { Component, OnInit, AfterViewInit, EventEmitter, Input, Output } from '@angular/core';
import 'tinymce';
declare var tinymce: any;
@Component({
selector: 'app-editor',
templateUrl: './editor.component.html',
styleUrls: ['./editor.component.scss']
})
export class EditorComponent implements OnInit, AfterViewInit {
@Input() elementId: string;
@Output() onEditorKeyup = new EventEmitter<any>();
editor: any;
constructor() { }
ngOnInit() {
}
ngAfterViewInit() {
tinymce.init({
selector: '#' + this.elementId,
plugins: ['link', 'paste', 'table'],
skin_url: 'assets/skins/lightgray',
setup: editor => {
this.editor = editor;
editor.on('keyup', () => {
const content = editor.getContent();
this.onEditorKeyup.emit(content);
});
}
});
}
ngOnDestroy() {
tinymce.remove(this.editor);
}
}
```
and here is the markup for the `EditorComponent`:
```
<textarea id="{{elementId}}"></textarea>
```
and now being used in a parent component:
```
<app-editor [elementId]="'editor'" (onEditorKeyup)="keyupHandlerFunction($event)"></app-editor>
```
I have followed this link from their website: <https://www.tinymce.com/docs/integrations/angular2/>
in addition to a few other posts showing how to declare `tinymce` in the component.
Here is the angular-cli.json app[0].scripts as well:
```
"scripts": [
"../node_modules/tinymce/tinymce.js",
"../node_modules/tinymce/themes/modern/theme.js",
"../node_modules/tinymce/plugins/link/plugin.js",
"../node_modules/tinymce/plugins/paste/plugin.js",
"../node_modules/tinymce/plugins/table/plugin.js"
]
```
I seem to be getting this error in my console which is thrown by tinymce.js:
[](https://i.stack.imgur.com/Rb4vw.png)
But I cannot find a replicated issue anywhere out there, and the console log gives no clue to where in my code this issue is arising. My editor component also just shows up completely blank in the parent component. I appreciate any and all help. Thanks in advance. | 2017/12/14 | [
"https://Stackoverflow.com/questions/47806500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1148618/"
] | I had a very similar issue, and I discovered that somehow TinyMCE changed the location of where it was seeking the asset archives from
```
"/tinymce/skins/",
"/tinymce/themes/",
"/tinymce/plugins/",
```
to
```
"/skins/",
"/themes/",
"/plugins/",
```
Because of this the output in the assets config in the Angular.json file was wrong and I had to fix it from:
```
{ "glob": "**/*", "input": "node_modules/tinymce/skins", "output": "/tinymce/skins/" },
{ "glob": "**/*", "input": "node_modules/tinymce/themes", "output": "/tinymce/themes/" },
{ "glob": "**/*", "input": "node_modules/tinymce/plugins", "output": "/tinymce/plugins/" }
```
To:
```
{ "glob": "**/*", "input": "node_modules/tinymce/skins", "output": "/skins/" },
{ "glob": "**/*", "input": "node_modules/tinymce/themes", "output": "/themes/" },
{ "glob": "**/*", "input": "node_modules/tinymce/plugins", "output": "/plugins/" }
```
Unfortunately, I have not found out what caused the change in behaviour but I do believe this is a better answer than manually importing the scripts or copying them inside your application folder. | Well actually I had the same problem but in my Syfomny 4 project with webpack. I've searched in many places and ended up with my own idea which works - at least at this moment.
First of all in **js file** that's gonna have tinymce logic add:
```
import tinymce from 'tinymce/tinymce';
import 'tinymce/themes/silver';
```
Now this article: <https://medium.freecodecamp.org/how-to-setup-tinymce-in-your-rails-app-using-webpack-edf030915332> says that You can use this:
```
import ‘tinymce/skins/lightgray/skin.min.css’;
```
but it will not work, since there is no such file as **skin.min.css**.
The solution is to import every single file like:
```
import 'tinymce/skins/content/default/content.css';
import 'tinymce/skins/content/document/content.css';
import 'tinymce/skins/content/writer/content.css';
import 'tinymce/skins/ui/oxide-dark/content.css';
```
but then this destroys the page theme...
So the final solution is adding wrapper for form which will have the tiny-mce:
```
<section id="tiny-mce-wrapper">
<form>
<textarea class="tiny-mce"></textarea>
</form>
</section>
```
then:
* **move all csses from node/modules/tinymce/skin** into place where You store Your css.
* change extension of all files from css to scss
* in each file add changes so that the styles will apply **only** for Your tinmce textarea when it's inside **#tiny-mce** |
13,546,654 | I found this function on stackoverflow which concates two strings together. Here is the function:
```
char* concatstring(char *s1,char *s2)
{
char *result = malloc(strlen(s1)+strlen(s2)+1);
strcpy(result,s1);
strcat(result,s2);
return result;
}
```
My question is, why do we add 1 to the malloc call? | 2012/11/24 | [
"https://Stackoverflow.com/questions/13546654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/135605/"
] | It's because in C "strings" are stored as arrays of chars followed by a null byte. This is by convention. Consequently, null bytes may not appear inside any C string.
However, the actual string itself does not contain the null byte (which is just part of the *representation* of the string), and so `strlen` reports the number of *non-null* bytes in the string. To create a C string that is the result of concatenating two strings, you thus need to leave room for the null terminator.
In fact, *every* string operation one way or another needs to deal with the null terminator. Unfortunately, the details vary from function to function (e.g. `snprintf` does it right, but `strncpy` is dangerously different), and you should read each function's manual very carefully to understand who takes care of the null terminator and how. | You need to allocate space for the '\0' (NULL character) which is used to terminate strings in C.
i.e. the string "cat" is actually "cat\0". |
13,546,654 | I found this function on stackoverflow which concates two strings together. Here is the function:
```
char* concatstring(char *s1,char *s2)
{
char *result = malloc(strlen(s1)+strlen(s2)+1);
strcpy(result,s1);
strcat(result,s2);
return result;
}
```
My question is, why do we add 1 to the malloc call? | 2012/11/24 | [
"https://Stackoverflow.com/questions/13546654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/135605/"
] | You need to allocate space for the '\0' (NULL character) which is used to terminate strings in C.
i.e. the string "cat" is actually "cat\0". | If the string is "cat":
```
char * mystring = "cat";
```
Then strlen(mystring), would return 3.
But in reality it takes 4 bytes to store mystring, with one byte to store null character.
So if you have two strings, "dog" and "cat", their length will be 3 and 3 , although the number of bytes required to store them would be 4 each. The memory required to store their concatenation would be 3+3 +1 = 7.
So the 1 in malloc is to allocate extra byte to store the null character. |
13,546,654 | I found this function on stackoverflow which concates two strings together. Here is the function:
```
char* concatstring(char *s1,char *s2)
{
char *result = malloc(strlen(s1)+strlen(s2)+1);
strcpy(result,s1);
strcat(result,s2);
return result;
}
```
My question is, why do we add 1 to the malloc call? | 2012/11/24 | [
"https://Stackoverflow.com/questions/13546654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/135605/"
] | It's because in C "strings" are stored as arrays of chars followed by a null byte. This is by convention. Consequently, null bytes may not appear inside any C string.
However, the actual string itself does not contain the null byte (which is just part of the *representation* of the string), and so `strlen` reports the number of *non-null* bytes in the string. To create a C string that is the result of concatenating two strings, you thus need to leave room for the null terminator.
In fact, *every* string operation one way or another needs to deal with the null terminator. Unfortunately, the details vary from function to function (e.g. `snprintf` does it right, but `strncpy` is dangerously different), and you should read each function's manual very carefully to understand who takes care of the null terminator and how. | If the string is "cat":
```
char * mystring = "cat";
```
Then strlen(mystring), would return 3.
But in reality it takes 4 bytes to store mystring, with one byte to store null character.
So if you have two strings, "dog" and "cat", their length will be 3 and 3 , although the number of bytes required to store them would be 4 each. The memory required to store their concatenation would be 3+3 +1 = 7.
So the 1 in malloc is to allocate extra byte to store the null character. |
24,119,557 | I'm trying to work with build flavors. In my build.gradle I've defined 2 flavors, a normal flavor and an admin flavor.
Basicly, the admin flavor has an extra button on the main activity.
I understand that I can define different packages/classes for different flavors. But is there a way to make a sort of if case to add/remove a piece of code depending on the flavor?
Basicly, I would need two versions of an Activity. But I don't want two entire different versions of the activity and maintain them.
So in my activity I would like to do
=> gradle check if flavor is 'admin'
=> if yes, add this code of the button
Is this possible? Or would you need two different physical activities and thus maintain both of them when you add functionality afterwards. | 2014/06/09 | [
"https://Stackoverflow.com/questions/24119557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/916705/"
] | `BuildConfig.FLAVOR` gives you combined product flavor.
So if you have only one flavor dimension:
```
productFlavors {
normal {
}
admin {
}
}
```
Then you can just check it:
```
if (BuildConfig.FLAVOR.equals("admin")) {
...
}
```
But if you have multiple flavor dimensions:
```
flavorDimensions "access", "color"
productFlavors {
normal {
dimension "access"
}
admin {
dimension "access"
}
red {
dimension "color"
}
blue {
dimension "color"
}
}
```
there are also `BuildConfig.FLAVOR_access` and `BuildConfig.FLAVOR_color` fields so you should check it like this:
```
if (BuildConfig.FLAVOR_access.equals("admin")) {
...
}
```
And `BuildConfig.FLAVOR` contains full flavor name. For example, `adminBlue`. | To avoid plain string in the condition, you can define a boolean property:
```
productFlavors {
normal {
flavorDimension "access"
buildConfigField 'boolean', 'IS_ADMIN', 'false'
}
admin {
flavorDimension "access"
buildConfigField 'boolean', 'IS_ADMIN', 'true'
}
}
```
Then you can use it like this:
```
if (BuildConfig.IS_ADMIN) {
...
}
``` |
24,119,557 | I'm trying to work with build flavors. In my build.gradle I've defined 2 flavors, a normal flavor and an admin flavor.
Basicly, the admin flavor has an extra button on the main activity.
I understand that I can define different packages/classes for different flavors. But is there a way to make a sort of if case to add/remove a piece of code depending on the flavor?
Basicly, I would need two versions of an Activity. But I don't want two entire different versions of the activity and maintain them.
So in my activity I would like to do
=> gradle check if flavor is 'admin'
=> if yes, add this code of the button
Is this possible? Or would you need two different physical activities and thus maintain both of them when you add functionality afterwards. | 2014/06/09 | [
"https://Stackoverflow.com/questions/24119557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/916705/"
] | `BuildConfig.FLAVOR` gives you combined product flavor.
So if you have only one flavor dimension:
```
productFlavors {
normal {
}
admin {
}
}
```
Then you can just check it:
```
if (BuildConfig.FLAVOR.equals("admin")) {
...
}
```
But if you have multiple flavor dimensions:
```
flavorDimensions "access", "color"
productFlavors {
normal {
dimension "access"
}
admin {
dimension "access"
}
red {
dimension "color"
}
blue {
dimension "color"
}
}
```
there are also `BuildConfig.FLAVOR_access` and `BuildConfig.FLAVOR_color` fields so you should check it like this:
```
if (BuildConfig.FLAVOR_access.equals("admin")) {
...
}
```
And `BuildConfig.FLAVOR` contains full flavor name. For example, `adminBlue`. | You can define either different build configuration fields or different resource values (like string values) per flavor, e.g. (as per [Google's gradle tips and recipes](https://developer.android.com/studio/build/gradle-tips)), e.g.,
```
android {
...
buildTypes {
release {
// These values are defined only for the release build, which
// is typically used for full builds and continuous builds.
buildConfigField("String", "BUILD_TIME", "\"${minutesSinceEpoch}\"")
resValue("string", "build_time", "${minutesSinceEpoch}")
...
}
debug {
// Use static values for incremental builds to ensure that
// resource files and BuildConfig aren't rebuilt with each run.
// If they were dynamic, they would prevent certain benefits of
// Instant Run as well as Gradle UP-TO-DATE checks.
buildConfigField("String", "BUILD_TIME", "\"0\"")
resValue("string", "build_time", "0")
}
}
}
```
So in this case, something like
```
productFlavors {
normal {
dimension "access"
buildConfigField("boolean", "IS_ADMIN", "false")
}
admin {
dimension "access"
buildConfigField("boolean", "IS_ADMIN", "true")
}
}
```
and then use it like
```
if (BuildConfig.IS_ADMIN) {
...
} else {
...
}
```
or if it is just to have different string values for different flavors, it can be done with different `resValues` and then you don't even need the `if/then` |
24,119,557 | I'm trying to work with build flavors. In my build.gradle I've defined 2 flavors, a normal flavor and an admin flavor.
Basicly, the admin flavor has an extra button on the main activity.
I understand that I can define different packages/classes for different flavors. But is there a way to make a sort of if case to add/remove a piece of code depending on the flavor?
Basicly, I would need two versions of an Activity. But I don't want two entire different versions of the activity and maintain them.
So in my activity I would like to do
=> gradle check if flavor is 'admin'
=> if yes, add this code of the button
Is this possible? Or would you need two different physical activities and thus maintain both of them when you add functionality afterwards. | 2014/06/09 | [
"https://Stackoverflow.com/questions/24119557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/916705/"
] | `BuildConfig.FLAVOR` gives you combined product flavor.
So if you have only one flavor dimension:
```
productFlavors {
normal {
}
admin {
}
}
```
Then you can just check it:
```
if (BuildConfig.FLAVOR.equals("admin")) {
...
}
```
But if you have multiple flavor dimensions:
```
flavorDimensions "access", "color"
productFlavors {
normal {
dimension "access"
}
admin {
dimension "access"
}
red {
dimension "color"
}
blue {
dimension "color"
}
}
```
there are also `BuildConfig.FLAVOR_access` and `BuildConfig.FLAVOR_color` fields so you should check it like this:
```
if (BuildConfig.FLAVOR_access.equals("admin")) {
...
}
```
And `BuildConfig.FLAVOR` contains full flavor name. For example, `adminBlue`. | You can try this way
```
productFlavors {
def app_name = "you app name"
development {
versionCode 1
versionName "1.0.1"
buildConfigField 'String', 'varibalename', ""
}
release {
versionCode 1
versionName "1.0.1"
buildConfigField 'String', 'varibalename', ""
}
}
```
if(BuildConfig.varibalename){} |
24,119,557 | I'm trying to work with build flavors. In my build.gradle I've defined 2 flavors, a normal flavor and an admin flavor.
Basicly, the admin flavor has an extra button on the main activity.
I understand that I can define different packages/classes for different flavors. But is there a way to make a sort of if case to add/remove a piece of code depending on the flavor?
Basicly, I would need two versions of an Activity. But I don't want two entire different versions of the activity and maintain them.
So in my activity I would like to do
=> gradle check if flavor is 'admin'
=> if yes, add this code of the button
Is this possible? Or would you need two different physical activities and thus maintain both of them when you add functionality afterwards. | 2014/06/09 | [
"https://Stackoverflow.com/questions/24119557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/916705/"
] | To avoid plain string in the condition, you can define a boolean property:
```
productFlavors {
normal {
flavorDimension "access"
buildConfigField 'boolean', 'IS_ADMIN', 'false'
}
admin {
flavorDimension "access"
buildConfigField 'boolean', 'IS_ADMIN', 'true'
}
}
```
Then you can use it like this:
```
if (BuildConfig.IS_ADMIN) {
...
}
``` | You can define either different build configuration fields or different resource values (like string values) per flavor, e.g. (as per [Google's gradle tips and recipes](https://developer.android.com/studio/build/gradle-tips)), e.g.,
```
android {
...
buildTypes {
release {
// These values are defined only for the release build, which
// is typically used for full builds and continuous builds.
buildConfigField("String", "BUILD_TIME", "\"${minutesSinceEpoch}\"")
resValue("string", "build_time", "${minutesSinceEpoch}")
...
}
debug {
// Use static values for incremental builds to ensure that
// resource files and BuildConfig aren't rebuilt with each run.
// If they were dynamic, they would prevent certain benefits of
// Instant Run as well as Gradle UP-TO-DATE checks.
buildConfigField("String", "BUILD_TIME", "\"0\"")
resValue("string", "build_time", "0")
}
}
}
```
So in this case, something like
```
productFlavors {
normal {
dimension "access"
buildConfigField("boolean", "IS_ADMIN", "false")
}
admin {
dimension "access"
buildConfigField("boolean", "IS_ADMIN", "true")
}
}
```
and then use it like
```
if (BuildConfig.IS_ADMIN) {
...
} else {
...
}
```
or if it is just to have different string values for different flavors, it can be done with different `resValues` and then you don't even need the `if/then` |
24,119,557 | I'm trying to work with build flavors. In my build.gradle I've defined 2 flavors, a normal flavor and an admin flavor.
Basicly, the admin flavor has an extra button on the main activity.
I understand that I can define different packages/classes for different flavors. But is there a way to make a sort of if case to add/remove a piece of code depending on the flavor?
Basicly, I would need two versions of an Activity. But I don't want two entire different versions of the activity and maintain them.
So in my activity I would like to do
=> gradle check if flavor is 'admin'
=> if yes, add this code of the button
Is this possible? Or would you need two different physical activities and thus maintain both of them when you add functionality afterwards. | 2014/06/09 | [
"https://Stackoverflow.com/questions/24119557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/916705/"
] | To avoid plain string in the condition, you can define a boolean property:
```
productFlavors {
normal {
flavorDimension "access"
buildConfigField 'boolean', 'IS_ADMIN', 'false'
}
admin {
flavorDimension "access"
buildConfigField 'boolean', 'IS_ADMIN', 'true'
}
}
```
Then you can use it like this:
```
if (BuildConfig.IS_ADMIN) {
...
}
``` | You can try this way
```
productFlavors {
def app_name = "you app name"
development {
versionCode 1
versionName "1.0.1"
buildConfigField 'String', 'varibalename', ""
}
release {
versionCode 1
versionName "1.0.1"
buildConfigField 'String', 'varibalename', ""
}
}
```
if(BuildConfig.varibalename){} |
18,480,032 | I hopefully have a very simple question but if I have the code
```
console.log("my args", args);
```
and the result that comes back is
```
Object { pageList1=null}
```
how do i get the name pageList1
it doesnt matter that this is null i just need the name pageList1..
this is what i have tried
```
parse: function (result, args) {
var myKey = Object.keys(args);
return result.data.myKey;
}
```
ok so using on of the answers i updated the code to be
```
parse: function (result, args) {
for (variable in args) {
return result.data.variable;
}
}
```
but that doesnt like just the name variable as thats not in the JSON structure..
OK so the answer was
```
parse: function (result, args) {
var pageListVariable = Object.keys(args)[0];
return result.data[pageListVariable];
}
```
when needing to change the call of the json the . needs to be replaced with [] | 2013/08/28 | [
"https://Stackoverflow.com/questions/18480032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1658861/"
] | you should use [for in](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in).
```
for (variable in object) {
console.log(variable)
}
``` | Hope this will help:
```
var keys = [];
for (x in args) {
console.log("Key=>" + x +", val="+args[x]);
keys.push (x); //where x is the key
}
alert(keys);
``` |
18,480,032 | I hopefully have a very simple question but if I have the code
```
console.log("my args", args);
```
and the result that comes back is
```
Object { pageList1=null}
```
how do i get the name pageList1
it doesnt matter that this is null i just need the name pageList1..
this is what i have tried
```
parse: function (result, args) {
var myKey = Object.keys(args);
return result.data.myKey;
}
```
ok so using on of the answers i updated the code to be
```
parse: function (result, args) {
for (variable in args) {
return result.data.variable;
}
}
```
but that doesnt like just the name variable as thats not in the JSON structure..
OK so the answer was
```
parse: function (result, args) {
var pageListVariable = Object.keys(args)[0];
return result.data[pageListVariable];
}
```
when needing to change the call of the json the . needs to be replaced with [] | 2013/08/28 | [
"https://Stackoverflow.com/questions/18480032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1658861/"
] | `Object.keys` is a fine way to access the keys of an object, but it does give you *all* keys, in an array of strings. Incidentally, your object happens to have only one key, but the function still yields an array, albeit of one string. (In fact, it would be terribly inconvenient if it treated single-key objects as a special case and yielded only a string; you would always have to type-check before iterating over the result).
If, in your specific scenario, you *know* there will always be only one key, it's perfectly fine to go ahead and access that by index immediately `Object.keys(args)[0]`. | you should use [for in](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in).
```
for (variable in object) {
console.log(variable)
}
``` |
18,480,032 | I hopefully have a very simple question but if I have the code
```
console.log("my args", args);
```
and the result that comes back is
```
Object { pageList1=null}
```
how do i get the name pageList1
it doesnt matter that this is null i just need the name pageList1..
this is what i have tried
```
parse: function (result, args) {
var myKey = Object.keys(args);
return result.data.myKey;
}
```
ok so using on of the answers i updated the code to be
```
parse: function (result, args) {
for (variable in args) {
return result.data.variable;
}
}
```
but that doesnt like just the name variable as thats not in the JSON structure..
OK so the answer was
```
parse: function (result, args) {
var pageListVariable = Object.keys(args)[0];
return result.data[pageListVariable];
}
```
when needing to change the call of the json the . needs to be replaced with [] | 2013/08/28 | [
"https://Stackoverflow.com/questions/18480032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1658861/"
] | `Object.keys` is a fine way to access the keys of an object, but it does give you *all* keys, in an array of strings. Incidentally, your object happens to have only one key, but the function still yields an array, albeit of one string. (In fact, it would be terribly inconvenient if it treated single-key objects as a special case and yielded only a string; you would always have to type-check before iterating over the result).
If, in your specific scenario, you *know* there will always be only one key, it's perfectly fine to go ahead and access that by index immediately `Object.keys(args)[0]`. | Hope this will help:
```
var keys = [];
for (x in args) {
console.log("Key=>" + x +", val="+args[x]);
keys.push (x); //where x is the key
}
alert(keys);
``` |
23,673,216 | I am getting this error when I run my first "sqlite" app on iPhone simulator. xcode says no issue but when i am clicking on my app it throws error in debug window. i have placed all necessary code here please help me to connect "sqlite" and remove these errors.
The error is as follows:
```
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x8a45930> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key departmentbox.'
*** First throw call stack:
(0x2091012 0x119ee7e 0x2119fb1 0xc4b711 0xbccec8 0xbcc9b7 0xbf7428 0x3030cc 0x11b2663 0x208c45a 0x301bcf 0x1c6e37 0x1c7418 0x1c7648 0x1c7882 0x116a25 0x116dbf 0x116f55 0x11ff67 0xe3fcc 0xe4fab 0xf6315 0xf724b 0xe8cf8 0x1fecdf9 0x1fecad0 0x2006bf5 0x2006962 0x2037bb6 0x2036f44 0x2036e1b 0xe47da 0xe665c 0x233d 0x2265)
libc++abi.dylib: terminate called throwing an exception
(lldb)
```
DBManager.m:
```
//
// DBManager.m
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import "DBManager.h"
#import <sqlite3.h>
static DBManager *sharedInstance = nil;
static sqlite3 *database = nil;
static sqlite3_stmt *statement = nil;
@implementation DBManager
+(DBManager*)getSharedInstance{
if(!sharedInstance){
sharedInstance = [[super allocWithZone:NULL]init];
[sharedInstance createDB];
}
return sharedInstance;
}
-(BOOL)createDB{
NSString *docsDir;
NSArray *dirPaths;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
docsDir = dirPaths[0];
databasePath = [[NSString alloc] initWithString:[docsDir stringByAppendingPathComponent:@"student.db"]];
BOOL isSuccess = YES;
NSFileManager *filemgr = [NSFileManager defaultManager];
if([filemgr fileExistsAtPath:databasePath]== NO)
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK )
{
char *errMsg;
const char *sql_stmt = "create table if not exists studentsDetail (regno integer primary key, name text, department text, year text)";
if(sqlite3_exec(database,sql_stmt,NULL,NULL,&errMsg)!= SQLITE_OK)
{
isSuccess = NO;
NSLog(@"failed to open create table");
}
sqlite3_close(database);
return isSuccess;
}
else{
isSuccess = NO;
NSLog(@"Failed to open/create database");
}
}return isSuccess;
}
-(BOOL)saveData:(NSString*)registerNumber name:(NSString*)name
department:(NSString *)department year:(NSString *)year;
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK )
{
NSString *insertSQL = [NSString stringWithFormat:@"insert into studentDetail(regno,name,department,year)values(\"%d\",\"%@\",\"%@\",\"%@\")",[registerNumber integerValue],name,department,year];
const char *insert_stmt = [insertSQL UTF8String]; sqlite3_prepare_v2(database, insert_stmt,-1,&statement,NULL);
if(sqlite3_step(statement) == SQLITE_DONE)
{
return YES;
}
else{
return NO;
}
sqlite3_reset(statement);
}
return NO;
}
-(NSArray*) findByRegisterNumber:(NSString *)registerNumber
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK)
{
NSString *querySQL = [NSString stringWithFormat:@"select name, department,year from studentDetail where regno=\"%@\"",registerNumber];
const char *query_stmt = [querySQL UTF8String];
NSMutableArray *resultArray = [[NSMutableArray alloc]init];
if(sqlite3_prepare_v2(database,query_stmt,-1,&statement,NULL)== SQLITE_OK)
{
if(sqlite3_step(statement) == SQLITE_ROW)
{
NSString *name = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 0)];
[resultArray addObject:name];
NSString *department = [[NSString alloc]initWithUTF8String:(const char*) sqlite3_column_text(statement,1)];
[resultArray addObject:department];
return resultArray;
NSString *year = [[NSString alloc]initWithUTF8String:(const char*) sqlite3_column_text(statement,2)];
[resultArray addObject:year];
return resultArray;
}
else{
NSLog(@"Not Found");
return nil;
}
sqlite3_reset(statement);
}
}
return nil;
}
@end
```
ViewController.h:
```
//
// ViewController.h
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "DBManager.h"
@interface ViewController : UIViewController<UITextFieldDelegate>
{
IBOutlet UITextField *regNoTextField;
IBOutlet UITextField *nameTextField;
IBOutlet UITextField *departmentTextField;
IBOutlet UITextField *yearTextField;
IBOutlet UITextField *findByRegisterNumberTextField;
IBOutlet UIScrollView *myScrollView;
}
-(IBAction)saveData:(id)sender;
-(IBAction)findData:(id)sender;
/*
- (IBAction)find:(id)sender;
- (IBAction)save:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *findbox;
@property (weak, nonatomic) IBOutlet UITextField *regnobox;
@property (weak, nonatomic) IBOutlet UITextField *namebox;
@property (weak, nonatomic) IBOutlet UITextField *departmentbox;
@property (weak, nonatomic) IBOutlet UITextField *year;
*/
@end
```
ViewController.m:
```
//
// ViewController.m
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self)
{
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
- (IBAction)find:(id)sender {
}
- (IBAction)save:(id)sender {
}
*/
-(IBAction)saveData:(id)sender{
BOOL success = NO;
NSString *alertString = @"Data Insertion falied";
if(regNoTextField.text.length>0 && yearTextField.text.length>0 && departmentTextField.text.length>0 && yearTextField.text.length>0)
{
success = [[DBManager getSharedInstance]saveData:regNoTextField.text name:nameTextField.text department:departmentTextField.text year:yearTextField.text];
}
else
{
alertString = @"Enter all fields";
}
if(success == NO)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:alertString message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}
-(IBAction)findData:(id)sender{
NSArray *data = [[DBManager getSharedInstance]findByRegisterNumber:findByRegisterNumberTextField.text];
if(data == nil)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:
@"Data Not Found" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
regNoTextField.text = @"";
nameTextField.text = @"";
departmentTextField.text = @"";
yearTextField.text = @"";
}
else{
regNoTextField.text = findByRegisterNumberTextField.text;
nameTextField.text = [data objectAtIndex:0];
departmentTextField.text = [data objectAtIndex:1];
yearTextField.text = [data objectAtIndex:2];
}
}
#pragma mark - Text field delegate
-(void)textFieldDidBeginEditing:(UITextField *)textField{
[myScrollView setFrame:CGRectMake(10,50,300,200)];
}
-(BOOL) textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
@end
``` | 2014/05/15 | [
"https://Stackoverflow.com/questions/23673216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3522901/"
] | you unused the property `departmentbox` into `departmentTextField` on your `ViewController` but you didn't to remove the `departmentbox` from storyboard,
go to your connection inspector and remove the unused key `department box`, and then build your app

here the `department box` is shown in the `Reference Outlet` just removed the `department box` and build your app | that's because you renamed you property `departmentbox` into `departmentTextField` on `ViewController` but apparently forgot to update storyboard
Besides, there is no need to use ivars, declare private properties if you don't need to expose your outlets in `.h` file:
in your `.m` declare
```
@interface UIViewController ()
@property (nonatomic, weak) IBOutlet UITextField *regNoTextField;
// etc
@end
``` |
23,673,216 | I am getting this error when I run my first "sqlite" app on iPhone simulator. xcode says no issue but when i am clicking on my app it throws error in debug window. i have placed all necessary code here please help me to connect "sqlite" and remove these errors.
The error is as follows:
```
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x8a45930> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key departmentbox.'
*** First throw call stack:
(0x2091012 0x119ee7e 0x2119fb1 0xc4b711 0xbccec8 0xbcc9b7 0xbf7428 0x3030cc 0x11b2663 0x208c45a 0x301bcf 0x1c6e37 0x1c7418 0x1c7648 0x1c7882 0x116a25 0x116dbf 0x116f55 0x11ff67 0xe3fcc 0xe4fab 0xf6315 0xf724b 0xe8cf8 0x1fecdf9 0x1fecad0 0x2006bf5 0x2006962 0x2037bb6 0x2036f44 0x2036e1b 0xe47da 0xe665c 0x233d 0x2265)
libc++abi.dylib: terminate called throwing an exception
(lldb)
```
DBManager.m:
```
//
// DBManager.m
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import "DBManager.h"
#import <sqlite3.h>
static DBManager *sharedInstance = nil;
static sqlite3 *database = nil;
static sqlite3_stmt *statement = nil;
@implementation DBManager
+(DBManager*)getSharedInstance{
if(!sharedInstance){
sharedInstance = [[super allocWithZone:NULL]init];
[sharedInstance createDB];
}
return sharedInstance;
}
-(BOOL)createDB{
NSString *docsDir;
NSArray *dirPaths;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
docsDir = dirPaths[0];
databasePath = [[NSString alloc] initWithString:[docsDir stringByAppendingPathComponent:@"student.db"]];
BOOL isSuccess = YES;
NSFileManager *filemgr = [NSFileManager defaultManager];
if([filemgr fileExistsAtPath:databasePath]== NO)
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK )
{
char *errMsg;
const char *sql_stmt = "create table if not exists studentsDetail (regno integer primary key, name text, department text, year text)";
if(sqlite3_exec(database,sql_stmt,NULL,NULL,&errMsg)!= SQLITE_OK)
{
isSuccess = NO;
NSLog(@"failed to open create table");
}
sqlite3_close(database);
return isSuccess;
}
else{
isSuccess = NO;
NSLog(@"Failed to open/create database");
}
}return isSuccess;
}
-(BOOL)saveData:(NSString*)registerNumber name:(NSString*)name
department:(NSString *)department year:(NSString *)year;
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK )
{
NSString *insertSQL = [NSString stringWithFormat:@"insert into studentDetail(regno,name,department,year)values(\"%d\",\"%@\",\"%@\",\"%@\")",[registerNumber integerValue],name,department,year];
const char *insert_stmt = [insertSQL UTF8String]; sqlite3_prepare_v2(database, insert_stmt,-1,&statement,NULL);
if(sqlite3_step(statement) == SQLITE_DONE)
{
return YES;
}
else{
return NO;
}
sqlite3_reset(statement);
}
return NO;
}
-(NSArray*) findByRegisterNumber:(NSString *)registerNumber
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK)
{
NSString *querySQL = [NSString stringWithFormat:@"select name, department,year from studentDetail where regno=\"%@\"",registerNumber];
const char *query_stmt = [querySQL UTF8String];
NSMutableArray *resultArray = [[NSMutableArray alloc]init];
if(sqlite3_prepare_v2(database,query_stmt,-1,&statement,NULL)== SQLITE_OK)
{
if(sqlite3_step(statement) == SQLITE_ROW)
{
NSString *name = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 0)];
[resultArray addObject:name];
NSString *department = [[NSString alloc]initWithUTF8String:(const char*) sqlite3_column_text(statement,1)];
[resultArray addObject:department];
return resultArray;
NSString *year = [[NSString alloc]initWithUTF8String:(const char*) sqlite3_column_text(statement,2)];
[resultArray addObject:year];
return resultArray;
}
else{
NSLog(@"Not Found");
return nil;
}
sqlite3_reset(statement);
}
}
return nil;
}
@end
```
ViewController.h:
```
//
// ViewController.h
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "DBManager.h"
@interface ViewController : UIViewController<UITextFieldDelegate>
{
IBOutlet UITextField *regNoTextField;
IBOutlet UITextField *nameTextField;
IBOutlet UITextField *departmentTextField;
IBOutlet UITextField *yearTextField;
IBOutlet UITextField *findByRegisterNumberTextField;
IBOutlet UIScrollView *myScrollView;
}
-(IBAction)saveData:(id)sender;
-(IBAction)findData:(id)sender;
/*
- (IBAction)find:(id)sender;
- (IBAction)save:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *findbox;
@property (weak, nonatomic) IBOutlet UITextField *regnobox;
@property (weak, nonatomic) IBOutlet UITextField *namebox;
@property (weak, nonatomic) IBOutlet UITextField *departmentbox;
@property (weak, nonatomic) IBOutlet UITextField *year;
*/
@end
```
ViewController.m:
```
//
// ViewController.m
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self)
{
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
- (IBAction)find:(id)sender {
}
- (IBAction)save:(id)sender {
}
*/
-(IBAction)saveData:(id)sender{
BOOL success = NO;
NSString *alertString = @"Data Insertion falied";
if(regNoTextField.text.length>0 && yearTextField.text.length>0 && departmentTextField.text.length>0 && yearTextField.text.length>0)
{
success = [[DBManager getSharedInstance]saveData:regNoTextField.text name:nameTextField.text department:departmentTextField.text year:yearTextField.text];
}
else
{
alertString = @"Enter all fields";
}
if(success == NO)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:alertString message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}
-(IBAction)findData:(id)sender{
NSArray *data = [[DBManager getSharedInstance]findByRegisterNumber:findByRegisterNumberTextField.text];
if(data == nil)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:
@"Data Not Found" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
regNoTextField.text = @"";
nameTextField.text = @"";
departmentTextField.text = @"";
yearTextField.text = @"";
}
else{
regNoTextField.text = findByRegisterNumberTextField.text;
nameTextField.text = [data objectAtIndex:0];
departmentTextField.text = [data objectAtIndex:1];
yearTextField.text = [data objectAtIndex:2];
}
}
#pragma mark - Text field delegate
-(void)textFieldDidBeginEditing:(UITextField *)textField{
[myScrollView setFrame:CGRectMake(10,50,300,200)];
}
-(BOOL) textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
@end
``` | 2014/05/15 | [
"https://Stackoverflow.com/questions/23673216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3522901/"
] | You have connected the UITextField in IB with "departmentbox".
```
@property (weak, nonatomic) IBOutlet UITextField *departmentbox;
```
But later you have commented the above lines in your view controller.
When you try to run the app,IB is looking for the "departmentbox" in viewcontroller. That causes the crash.
disconnect the "departmentbox" in IB will resolve the issue. | that's because you renamed you property `departmentbox` into `departmentTextField` on `ViewController` but apparently forgot to update storyboard
Besides, there is no need to use ivars, declare private properties if you don't need to expose your outlets in `.h` file:
in your `.m` declare
```
@interface UIViewController ()
@property (nonatomic, weak) IBOutlet UITextField *regNoTextField;
// etc
@end
``` |
23,673,216 | I am getting this error when I run my first "sqlite" app on iPhone simulator. xcode says no issue but when i am clicking on my app it throws error in debug window. i have placed all necessary code here please help me to connect "sqlite" and remove these errors.
The error is as follows:
```
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x8a45930> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key departmentbox.'
*** First throw call stack:
(0x2091012 0x119ee7e 0x2119fb1 0xc4b711 0xbccec8 0xbcc9b7 0xbf7428 0x3030cc 0x11b2663 0x208c45a 0x301bcf 0x1c6e37 0x1c7418 0x1c7648 0x1c7882 0x116a25 0x116dbf 0x116f55 0x11ff67 0xe3fcc 0xe4fab 0xf6315 0xf724b 0xe8cf8 0x1fecdf9 0x1fecad0 0x2006bf5 0x2006962 0x2037bb6 0x2036f44 0x2036e1b 0xe47da 0xe665c 0x233d 0x2265)
libc++abi.dylib: terminate called throwing an exception
(lldb)
```
DBManager.m:
```
//
// DBManager.m
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import "DBManager.h"
#import <sqlite3.h>
static DBManager *sharedInstance = nil;
static sqlite3 *database = nil;
static sqlite3_stmt *statement = nil;
@implementation DBManager
+(DBManager*)getSharedInstance{
if(!sharedInstance){
sharedInstance = [[super allocWithZone:NULL]init];
[sharedInstance createDB];
}
return sharedInstance;
}
-(BOOL)createDB{
NSString *docsDir;
NSArray *dirPaths;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
docsDir = dirPaths[0];
databasePath = [[NSString alloc] initWithString:[docsDir stringByAppendingPathComponent:@"student.db"]];
BOOL isSuccess = YES;
NSFileManager *filemgr = [NSFileManager defaultManager];
if([filemgr fileExistsAtPath:databasePath]== NO)
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK )
{
char *errMsg;
const char *sql_stmt = "create table if not exists studentsDetail (regno integer primary key, name text, department text, year text)";
if(sqlite3_exec(database,sql_stmt,NULL,NULL,&errMsg)!= SQLITE_OK)
{
isSuccess = NO;
NSLog(@"failed to open create table");
}
sqlite3_close(database);
return isSuccess;
}
else{
isSuccess = NO;
NSLog(@"Failed to open/create database");
}
}return isSuccess;
}
-(BOOL)saveData:(NSString*)registerNumber name:(NSString*)name
department:(NSString *)department year:(NSString *)year;
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK )
{
NSString *insertSQL = [NSString stringWithFormat:@"insert into studentDetail(regno,name,department,year)values(\"%d\",\"%@\",\"%@\",\"%@\")",[registerNumber integerValue],name,department,year];
const char *insert_stmt = [insertSQL UTF8String]; sqlite3_prepare_v2(database, insert_stmt,-1,&statement,NULL);
if(sqlite3_step(statement) == SQLITE_DONE)
{
return YES;
}
else{
return NO;
}
sqlite3_reset(statement);
}
return NO;
}
-(NSArray*) findByRegisterNumber:(NSString *)registerNumber
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK)
{
NSString *querySQL = [NSString stringWithFormat:@"select name, department,year from studentDetail where regno=\"%@\"",registerNumber];
const char *query_stmt = [querySQL UTF8String];
NSMutableArray *resultArray = [[NSMutableArray alloc]init];
if(sqlite3_prepare_v2(database,query_stmt,-1,&statement,NULL)== SQLITE_OK)
{
if(sqlite3_step(statement) == SQLITE_ROW)
{
NSString *name = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 0)];
[resultArray addObject:name];
NSString *department = [[NSString alloc]initWithUTF8String:(const char*) sqlite3_column_text(statement,1)];
[resultArray addObject:department];
return resultArray;
NSString *year = [[NSString alloc]initWithUTF8String:(const char*) sqlite3_column_text(statement,2)];
[resultArray addObject:year];
return resultArray;
}
else{
NSLog(@"Not Found");
return nil;
}
sqlite3_reset(statement);
}
}
return nil;
}
@end
```
ViewController.h:
```
//
// ViewController.h
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "DBManager.h"
@interface ViewController : UIViewController<UITextFieldDelegate>
{
IBOutlet UITextField *regNoTextField;
IBOutlet UITextField *nameTextField;
IBOutlet UITextField *departmentTextField;
IBOutlet UITextField *yearTextField;
IBOutlet UITextField *findByRegisterNumberTextField;
IBOutlet UIScrollView *myScrollView;
}
-(IBAction)saveData:(id)sender;
-(IBAction)findData:(id)sender;
/*
- (IBAction)find:(id)sender;
- (IBAction)save:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *findbox;
@property (weak, nonatomic) IBOutlet UITextField *regnobox;
@property (weak, nonatomic) IBOutlet UITextField *namebox;
@property (weak, nonatomic) IBOutlet UITextField *departmentbox;
@property (weak, nonatomic) IBOutlet UITextField *year;
*/
@end
```
ViewController.m:
```
//
// ViewController.m
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self)
{
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
- (IBAction)find:(id)sender {
}
- (IBAction)save:(id)sender {
}
*/
-(IBAction)saveData:(id)sender{
BOOL success = NO;
NSString *alertString = @"Data Insertion falied";
if(regNoTextField.text.length>0 && yearTextField.text.length>0 && departmentTextField.text.length>0 && yearTextField.text.length>0)
{
success = [[DBManager getSharedInstance]saveData:regNoTextField.text name:nameTextField.text department:departmentTextField.text year:yearTextField.text];
}
else
{
alertString = @"Enter all fields";
}
if(success == NO)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:alertString message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}
-(IBAction)findData:(id)sender{
NSArray *data = [[DBManager getSharedInstance]findByRegisterNumber:findByRegisterNumberTextField.text];
if(data == nil)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:
@"Data Not Found" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
regNoTextField.text = @"";
nameTextField.text = @"";
departmentTextField.text = @"";
yearTextField.text = @"";
}
else{
regNoTextField.text = findByRegisterNumberTextField.text;
nameTextField.text = [data objectAtIndex:0];
departmentTextField.text = [data objectAtIndex:1];
yearTextField.text = [data objectAtIndex:2];
}
}
#pragma mark - Text field delegate
-(void)textFieldDidBeginEditing:(UITextField *)textField{
[myScrollView setFrame:CGRectMake(10,50,300,200)];
}
-(BOOL) textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
@end
``` | 2014/05/15 | [
"https://Stackoverflow.com/questions/23673216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3522901/"
] | you unused the property `departmentbox` into `departmentTextField` on your `ViewController` but you didn't to remove the `departmentbox` from storyboard,
go to your connection inspector and remove the unused key `department box`, and then build your app

here the `department box` is shown in the `Reference Outlet` just removed the `department box` and build your app | This error often comes when an unknown property is associated in your xib file.
It may happen if you rename a property after the xib association.
Here, the associated property was **departmentbox**, but renamed as **departmentTextField** |
23,673,216 | I am getting this error when I run my first "sqlite" app on iPhone simulator. xcode says no issue but when i am clicking on my app it throws error in debug window. i have placed all necessary code here please help me to connect "sqlite" and remove these errors.
The error is as follows:
```
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x8a45930> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key departmentbox.'
*** First throw call stack:
(0x2091012 0x119ee7e 0x2119fb1 0xc4b711 0xbccec8 0xbcc9b7 0xbf7428 0x3030cc 0x11b2663 0x208c45a 0x301bcf 0x1c6e37 0x1c7418 0x1c7648 0x1c7882 0x116a25 0x116dbf 0x116f55 0x11ff67 0xe3fcc 0xe4fab 0xf6315 0xf724b 0xe8cf8 0x1fecdf9 0x1fecad0 0x2006bf5 0x2006962 0x2037bb6 0x2036f44 0x2036e1b 0xe47da 0xe665c 0x233d 0x2265)
libc++abi.dylib: terminate called throwing an exception
(lldb)
```
DBManager.m:
```
//
// DBManager.m
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import "DBManager.h"
#import <sqlite3.h>
static DBManager *sharedInstance = nil;
static sqlite3 *database = nil;
static sqlite3_stmt *statement = nil;
@implementation DBManager
+(DBManager*)getSharedInstance{
if(!sharedInstance){
sharedInstance = [[super allocWithZone:NULL]init];
[sharedInstance createDB];
}
return sharedInstance;
}
-(BOOL)createDB{
NSString *docsDir;
NSArray *dirPaths;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
docsDir = dirPaths[0];
databasePath = [[NSString alloc] initWithString:[docsDir stringByAppendingPathComponent:@"student.db"]];
BOOL isSuccess = YES;
NSFileManager *filemgr = [NSFileManager defaultManager];
if([filemgr fileExistsAtPath:databasePath]== NO)
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK )
{
char *errMsg;
const char *sql_stmt = "create table if not exists studentsDetail (regno integer primary key, name text, department text, year text)";
if(sqlite3_exec(database,sql_stmt,NULL,NULL,&errMsg)!= SQLITE_OK)
{
isSuccess = NO;
NSLog(@"failed to open create table");
}
sqlite3_close(database);
return isSuccess;
}
else{
isSuccess = NO;
NSLog(@"Failed to open/create database");
}
}return isSuccess;
}
-(BOOL)saveData:(NSString*)registerNumber name:(NSString*)name
department:(NSString *)department year:(NSString *)year;
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK )
{
NSString *insertSQL = [NSString stringWithFormat:@"insert into studentDetail(regno,name,department,year)values(\"%d\",\"%@\",\"%@\",\"%@\")",[registerNumber integerValue],name,department,year];
const char *insert_stmt = [insertSQL UTF8String]; sqlite3_prepare_v2(database, insert_stmt,-1,&statement,NULL);
if(sqlite3_step(statement) == SQLITE_DONE)
{
return YES;
}
else{
return NO;
}
sqlite3_reset(statement);
}
return NO;
}
-(NSArray*) findByRegisterNumber:(NSString *)registerNumber
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK)
{
NSString *querySQL = [NSString stringWithFormat:@"select name, department,year from studentDetail where regno=\"%@\"",registerNumber];
const char *query_stmt = [querySQL UTF8String];
NSMutableArray *resultArray = [[NSMutableArray alloc]init];
if(sqlite3_prepare_v2(database,query_stmt,-1,&statement,NULL)== SQLITE_OK)
{
if(sqlite3_step(statement) == SQLITE_ROW)
{
NSString *name = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 0)];
[resultArray addObject:name];
NSString *department = [[NSString alloc]initWithUTF8String:(const char*) sqlite3_column_text(statement,1)];
[resultArray addObject:department];
return resultArray;
NSString *year = [[NSString alloc]initWithUTF8String:(const char*) sqlite3_column_text(statement,2)];
[resultArray addObject:year];
return resultArray;
}
else{
NSLog(@"Not Found");
return nil;
}
sqlite3_reset(statement);
}
}
return nil;
}
@end
```
ViewController.h:
```
//
// ViewController.h
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "DBManager.h"
@interface ViewController : UIViewController<UITextFieldDelegate>
{
IBOutlet UITextField *regNoTextField;
IBOutlet UITextField *nameTextField;
IBOutlet UITextField *departmentTextField;
IBOutlet UITextField *yearTextField;
IBOutlet UITextField *findByRegisterNumberTextField;
IBOutlet UIScrollView *myScrollView;
}
-(IBAction)saveData:(id)sender;
-(IBAction)findData:(id)sender;
/*
- (IBAction)find:(id)sender;
- (IBAction)save:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *findbox;
@property (weak, nonatomic) IBOutlet UITextField *regnobox;
@property (weak, nonatomic) IBOutlet UITextField *namebox;
@property (weak, nonatomic) IBOutlet UITextField *departmentbox;
@property (weak, nonatomic) IBOutlet UITextField *year;
*/
@end
```
ViewController.m:
```
//
// ViewController.m
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self)
{
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
- (IBAction)find:(id)sender {
}
- (IBAction)save:(id)sender {
}
*/
-(IBAction)saveData:(id)sender{
BOOL success = NO;
NSString *alertString = @"Data Insertion falied";
if(regNoTextField.text.length>0 && yearTextField.text.length>0 && departmentTextField.text.length>0 && yearTextField.text.length>0)
{
success = [[DBManager getSharedInstance]saveData:regNoTextField.text name:nameTextField.text department:departmentTextField.text year:yearTextField.text];
}
else
{
alertString = @"Enter all fields";
}
if(success == NO)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:alertString message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}
-(IBAction)findData:(id)sender{
NSArray *data = [[DBManager getSharedInstance]findByRegisterNumber:findByRegisterNumberTextField.text];
if(data == nil)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:
@"Data Not Found" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
regNoTextField.text = @"";
nameTextField.text = @"";
departmentTextField.text = @"";
yearTextField.text = @"";
}
else{
regNoTextField.text = findByRegisterNumberTextField.text;
nameTextField.text = [data objectAtIndex:0];
departmentTextField.text = [data objectAtIndex:1];
yearTextField.text = [data objectAtIndex:2];
}
}
#pragma mark - Text field delegate
-(void)textFieldDidBeginEditing:(UITextField *)textField{
[myScrollView setFrame:CGRectMake(10,50,300,200)];
}
-(BOOL) textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
@end
``` | 2014/05/15 | [
"https://Stackoverflow.com/questions/23673216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3522901/"
] | You have connected the UITextField in IB with "departmentbox".
```
@property (weak, nonatomic) IBOutlet UITextField *departmentbox;
```
But later you have commented the above lines in your view controller.
When you try to run the app,IB is looking for the "departmentbox" in viewcontroller. That causes the crash.
disconnect the "departmentbox" in IB will resolve the issue. | This error often comes when an unknown property is associated in your xib file.
It may happen if you rename a property after the xib association.
Here, the associated property was **departmentbox**, but renamed as **departmentTextField** |
23,673,216 | I am getting this error when I run my first "sqlite" app on iPhone simulator. xcode says no issue but when i am clicking on my app it throws error in debug window. i have placed all necessary code here please help me to connect "sqlite" and remove these errors.
The error is as follows:
```
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x8a45930> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key departmentbox.'
*** First throw call stack:
(0x2091012 0x119ee7e 0x2119fb1 0xc4b711 0xbccec8 0xbcc9b7 0xbf7428 0x3030cc 0x11b2663 0x208c45a 0x301bcf 0x1c6e37 0x1c7418 0x1c7648 0x1c7882 0x116a25 0x116dbf 0x116f55 0x11ff67 0xe3fcc 0xe4fab 0xf6315 0xf724b 0xe8cf8 0x1fecdf9 0x1fecad0 0x2006bf5 0x2006962 0x2037bb6 0x2036f44 0x2036e1b 0xe47da 0xe665c 0x233d 0x2265)
libc++abi.dylib: terminate called throwing an exception
(lldb)
```
DBManager.m:
```
//
// DBManager.m
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import "DBManager.h"
#import <sqlite3.h>
static DBManager *sharedInstance = nil;
static sqlite3 *database = nil;
static sqlite3_stmt *statement = nil;
@implementation DBManager
+(DBManager*)getSharedInstance{
if(!sharedInstance){
sharedInstance = [[super allocWithZone:NULL]init];
[sharedInstance createDB];
}
return sharedInstance;
}
-(BOOL)createDB{
NSString *docsDir;
NSArray *dirPaths;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
docsDir = dirPaths[0];
databasePath = [[NSString alloc] initWithString:[docsDir stringByAppendingPathComponent:@"student.db"]];
BOOL isSuccess = YES;
NSFileManager *filemgr = [NSFileManager defaultManager];
if([filemgr fileExistsAtPath:databasePath]== NO)
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK )
{
char *errMsg;
const char *sql_stmt = "create table if not exists studentsDetail (regno integer primary key, name text, department text, year text)";
if(sqlite3_exec(database,sql_stmt,NULL,NULL,&errMsg)!= SQLITE_OK)
{
isSuccess = NO;
NSLog(@"failed to open create table");
}
sqlite3_close(database);
return isSuccess;
}
else{
isSuccess = NO;
NSLog(@"Failed to open/create database");
}
}return isSuccess;
}
-(BOOL)saveData:(NSString*)registerNumber name:(NSString*)name
department:(NSString *)department year:(NSString *)year;
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK )
{
NSString *insertSQL = [NSString stringWithFormat:@"insert into studentDetail(regno,name,department,year)values(\"%d\",\"%@\",\"%@\",\"%@\")",[registerNumber integerValue],name,department,year];
const char *insert_stmt = [insertSQL UTF8String]; sqlite3_prepare_v2(database, insert_stmt,-1,&statement,NULL);
if(sqlite3_step(statement) == SQLITE_DONE)
{
return YES;
}
else{
return NO;
}
sqlite3_reset(statement);
}
return NO;
}
-(NSArray*) findByRegisterNumber:(NSString *)registerNumber
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK)
{
NSString *querySQL = [NSString stringWithFormat:@"select name, department,year from studentDetail where regno=\"%@\"",registerNumber];
const char *query_stmt = [querySQL UTF8String];
NSMutableArray *resultArray = [[NSMutableArray alloc]init];
if(sqlite3_prepare_v2(database,query_stmt,-1,&statement,NULL)== SQLITE_OK)
{
if(sqlite3_step(statement) == SQLITE_ROW)
{
NSString *name = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 0)];
[resultArray addObject:name];
NSString *department = [[NSString alloc]initWithUTF8String:(const char*) sqlite3_column_text(statement,1)];
[resultArray addObject:department];
return resultArray;
NSString *year = [[NSString alloc]initWithUTF8String:(const char*) sqlite3_column_text(statement,2)];
[resultArray addObject:year];
return resultArray;
}
else{
NSLog(@"Not Found");
return nil;
}
sqlite3_reset(statement);
}
}
return nil;
}
@end
```
ViewController.h:
```
//
// ViewController.h
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "DBManager.h"
@interface ViewController : UIViewController<UITextFieldDelegate>
{
IBOutlet UITextField *regNoTextField;
IBOutlet UITextField *nameTextField;
IBOutlet UITextField *departmentTextField;
IBOutlet UITextField *yearTextField;
IBOutlet UITextField *findByRegisterNumberTextField;
IBOutlet UIScrollView *myScrollView;
}
-(IBAction)saveData:(id)sender;
-(IBAction)findData:(id)sender;
/*
- (IBAction)find:(id)sender;
- (IBAction)save:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *findbox;
@property (weak, nonatomic) IBOutlet UITextField *regnobox;
@property (weak, nonatomic) IBOutlet UITextField *namebox;
@property (weak, nonatomic) IBOutlet UITextField *departmentbox;
@property (weak, nonatomic) IBOutlet UITextField *year;
*/
@end
```
ViewController.m:
```
//
// ViewController.m
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self)
{
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
- (IBAction)find:(id)sender {
}
- (IBAction)save:(id)sender {
}
*/
-(IBAction)saveData:(id)sender{
BOOL success = NO;
NSString *alertString = @"Data Insertion falied";
if(regNoTextField.text.length>0 && yearTextField.text.length>0 && departmentTextField.text.length>0 && yearTextField.text.length>0)
{
success = [[DBManager getSharedInstance]saveData:regNoTextField.text name:nameTextField.text department:departmentTextField.text year:yearTextField.text];
}
else
{
alertString = @"Enter all fields";
}
if(success == NO)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:alertString message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}
-(IBAction)findData:(id)sender{
NSArray *data = [[DBManager getSharedInstance]findByRegisterNumber:findByRegisterNumberTextField.text];
if(data == nil)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:
@"Data Not Found" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
regNoTextField.text = @"";
nameTextField.text = @"";
departmentTextField.text = @"";
yearTextField.text = @"";
}
else{
regNoTextField.text = findByRegisterNumberTextField.text;
nameTextField.text = [data objectAtIndex:0];
departmentTextField.text = [data objectAtIndex:1];
yearTextField.text = [data objectAtIndex:2];
}
}
#pragma mark - Text field delegate
-(void)textFieldDidBeginEditing:(UITextField *)textField{
[myScrollView setFrame:CGRectMake(10,50,300,200)];
}
-(BOOL) textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
@end
``` | 2014/05/15 | [
"https://Stackoverflow.com/questions/23673216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3522901/"
] | you unused the property `departmentbox` into `departmentTextField` on your `ViewController` but you didn't to remove the `departmentbox` from storyboard,
go to your connection inspector and remove the unused key `department box`, and then build your app

here the `department box` is shown in the `Reference Outlet` just removed the `department box` and build your app | Perhaps you had declared an iVar named "departmentbox" in your view controller, created a connection in xib file to that iVar and later on you deleted/renamed this iVar but forgot to delete the connection created in xib file. Can you check the xib file of your view controller class and see if there is any connection to departmentBox. If you see that (with a little warning icon showing on the right of outlet connection in xib), just remove that connection and it should be fine. |
23,673,216 | I am getting this error when I run my first "sqlite" app on iPhone simulator. xcode says no issue but when i am clicking on my app it throws error in debug window. i have placed all necessary code here please help me to connect "sqlite" and remove these errors.
The error is as follows:
```
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x8a45930> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key departmentbox.'
*** First throw call stack:
(0x2091012 0x119ee7e 0x2119fb1 0xc4b711 0xbccec8 0xbcc9b7 0xbf7428 0x3030cc 0x11b2663 0x208c45a 0x301bcf 0x1c6e37 0x1c7418 0x1c7648 0x1c7882 0x116a25 0x116dbf 0x116f55 0x11ff67 0xe3fcc 0xe4fab 0xf6315 0xf724b 0xe8cf8 0x1fecdf9 0x1fecad0 0x2006bf5 0x2006962 0x2037bb6 0x2036f44 0x2036e1b 0xe47da 0xe665c 0x233d 0x2265)
libc++abi.dylib: terminate called throwing an exception
(lldb)
```
DBManager.m:
```
//
// DBManager.m
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import "DBManager.h"
#import <sqlite3.h>
static DBManager *sharedInstance = nil;
static sqlite3 *database = nil;
static sqlite3_stmt *statement = nil;
@implementation DBManager
+(DBManager*)getSharedInstance{
if(!sharedInstance){
sharedInstance = [[super allocWithZone:NULL]init];
[sharedInstance createDB];
}
return sharedInstance;
}
-(BOOL)createDB{
NSString *docsDir;
NSArray *dirPaths;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
docsDir = dirPaths[0];
databasePath = [[NSString alloc] initWithString:[docsDir stringByAppendingPathComponent:@"student.db"]];
BOOL isSuccess = YES;
NSFileManager *filemgr = [NSFileManager defaultManager];
if([filemgr fileExistsAtPath:databasePath]== NO)
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK )
{
char *errMsg;
const char *sql_stmt = "create table if not exists studentsDetail (regno integer primary key, name text, department text, year text)";
if(sqlite3_exec(database,sql_stmt,NULL,NULL,&errMsg)!= SQLITE_OK)
{
isSuccess = NO;
NSLog(@"failed to open create table");
}
sqlite3_close(database);
return isSuccess;
}
else{
isSuccess = NO;
NSLog(@"Failed to open/create database");
}
}return isSuccess;
}
-(BOOL)saveData:(NSString*)registerNumber name:(NSString*)name
department:(NSString *)department year:(NSString *)year;
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK )
{
NSString *insertSQL = [NSString stringWithFormat:@"insert into studentDetail(regno,name,department,year)values(\"%d\",\"%@\",\"%@\",\"%@\")",[registerNumber integerValue],name,department,year];
const char *insert_stmt = [insertSQL UTF8String]; sqlite3_prepare_v2(database, insert_stmt,-1,&statement,NULL);
if(sqlite3_step(statement) == SQLITE_DONE)
{
return YES;
}
else{
return NO;
}
sqlite3_reset(statement);
}
return NO;
}
-(NSArray*) findByRegisterNumber:(NSString *)registerNumber
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK)
{
NSString *querySQL = [NSString stringWithFormat:@"select name, department,year from studentDetail where regno=\"%@\"",registerNumber];
const char *query_stmt = [querySQL UTF8String];
NSMutableArray *resultArray = [[NSMutableArray alloc]init];
if(sqlite3_prepare_v2(database,query_stmt,-1,&statement,NULL)== SQLITE_OK)
{
if(sqlite3_step(statement) == SQLITE_ROW)
{
NSString *name = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 0)];
[resultArray addObject:name];
NSString *department = [[NSString alloc]initWithUTF8String:(const char*) sqlite3_column_text(statement,1)];
[resultArray addObject:department];
return resultArray;
NSString *year = [[NSString alloc]initWithUTF8String:(const char*) sqlite3_column_text(statement,2)];
[resultArray addObject:year];
return resultArray;
}
else{
NSLog(@"Not Found");
return nil;
}
sqlite3_reset(statement);
}
}
return nil;
}
@end
```
ViewController.h:
```
//
// ViewController.h
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "DBManager.h"
@interface ViewController : UIViewController<UITextFieldDelegate>
{
IBOutlet UITextField *regNoTextField;
IBOutlet UITextField *nameTextField;
IBOutlet UITextField *departmentTextField;
IBOutlet UITextField *yearTextField;
IBOutlet UITextField *findByRegisterNumberTextField;
IBOutlet UIScrollView *myScrollView;
}
-(IBAction)saveData:(id)sender;
-(IBAction)findData:(id)sender;
/*
- (IBAction)find:(id)sender;
- (IBAction)save:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *findbox;
@property (weak, nonatomic) IBOutlet UITextField *regnobox;
@property (weak, nonatomic) IBOutlet UITextField *namebox;
@property (weak, nonatomic) IBOutlet UITextField *departmentbox;
@property (weak, nonatomic) IBOutlet UITextField *year;
*/
@end
```
ViewController.m:
```
//
// ViewController.m
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self)
{
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
- (IBAction)find:(id)sender {
}
- (IBAction)save:(id)sender {
}
*/
-(IBAction)saveData:(id)sender{
BOOL success = NO;
NSString *alertString = @"Data Insertion falied";
if(regNoTextField.text.length>0 && yearTextField.text.length>0 && departmentTextField.text.length>0 && yearTextField.text.length>0)
{
success = [[DBManager getSharedInstance]saveData:regNoTextField.text name:nameTextField.text department:departmentTextField.text year:yearTextField.text];
}
else
{
alertString = @"Enter all fields";
}
if(success == NO)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:alertString message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}
-(IBAction)findData:(id)sender{
NSArray *data = [[DBManager getSharedInstance]findByRegisterNumber:findByRegisterNumberTextField.text];
if(data == nil)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:
@"Data Not Found" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
regNoTextField.text = @"";
nameTextField.text = @"";
departmentTextField.text = @"";
yearTextField.text = @"";
}
else{
regNoTextField.text = findByRegisterNumberTextField.text;
nameTextField.text = [data objectAtIndex:0];
departmentTextField.text = [data objectAtIndex:1];
yearTextField.text = [data objectAtIndex:2];
}
}
#pragma mark - Text field delegate
-(void)textFieldDidBeginEditing:(UITextField *)textField{
[myScrollView setFrame:CGRectMake(10,50,300,200)];
}
-(BOOL) textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
@end
``` | 2014/05/15 | [
"https://Stackoverflow.com/questions/23673216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3522901/"
] | you unused the property `departmentbox` into `departmentTextField` on your `ViewController` but you didn't to remove the `departmentbox` from storyboard,
go to your connection inspector and remove the unused key `department box`, and then build your app

here the `department box` is shown in the `Reference Outlet` just removed the `department box` and build your app | You have connected the UITextField in IB with "departmentbox".
```
@property (weak, nonatomic) IBOutlet UITextField *departmentbox;
```
But later you have commented the above lines in your view controller.
When you try to run the app,IB is looking for the "departmentbox" in viewcontroller. That causes the crash.
disconnect the "departmentbox" in IB will resolve the issue. |
23,673,216 | I am getting this error when I run my first "sqlite" app on iPhone simulator. xcode says no issue but when i am clicking on my app it throws error in debug window. i have placed all necessary code here please help me to connect "sqlite" and remove these errors.
The error is as follows:
```
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x8a45930> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key departmentbox.'
*** First throw call stack:
(0x2091012 0x119ee7e 0x2119fb1 0xc4b711 0xbccec8 0xbcc9b7 0xbf7428 0x3030cc 0x11b2663 0x208c45a 0x301bcf 0x1c6e37 0x1c7418 0x1c7648 0x1c7882 0x116a25 0x116dbf 0x116f55 0x11ff67 0xe3fcc 0xe4fab 0xf6315 0xf724b 0xe8cf8 0x1fecdf9 0x1fecad0 0x2006bf5 0x2006962 0x2037bb6 0x2036f44 0x2036e1b 0xe47da 0xe665c 0x233d 0x2265)
libc++abi.dylib: terminate called throwing an exception
(lldb)
```
DBManager.m:
```
//
// DBManager.m
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import "DBManager.h"
#import <sqlite3.h>
static DBManager *sharedInstance = nil;
static sqlite3 *database = nil;
static sqlite3_stmt *statement = nil;
@implementation DBManager
+(DBManager*)getSharedInstance{
if(!sharedInstance){
sharedInstance = [[super allocWithZone:NULL]init];
[sharedInstance createDB];
}
return sharedInstance;
}
-(BOOL)createDB{
NSString *docsDir;
NSArray *dirPaths;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
docsDir = dirPaths[0];
databasePath = [[NSString alloc] initWithString:[docsDir stringByAppendingPathComponent:@"student.db"]];
BOOL isSuccess = YES;
NSFileManager *filemgr = [NSFileManager defaultManager];
if([filemgr fileExistsAtPath:databasePath]== NO)
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK )
{
char *errMsg;
const char *sql_stmt = "create table if not exists studentsDetail (regno integer primary key, name text, department text, year text)";
if(sqlite3_exec(database,sql_stmt,NULL,NULL,&errMsg)!= SQLITE_OK)
{
isSuccess = NO;
NSLog(@"failed to open create table");
}
sqlite3_close(database);
return isSuccess;
}
else{
isSuccess = NO;
NSLog(@"Failed to open/create database");
}
}return isSuccess;
}
-(BOOL)saveData:(NSString*)registerNumber name:(NSString*)name
department:(NSString *)department year:(NSString *)year;
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK )
{
NSString *insertSQL = [NSString stringWithFormat:@"insert into studentDetail(regno,name,department,year)values(\"%d\",\"%@\",\"%@\",\"%@\")",[registerNumber integerValue],name,department,year];
const char *insert_stmt = [insertSQL UTF8String]; sqlite3_prepare_v2(database, insert_stmt,-1,&statement,NULL);
if(sqlite3_step(statement) == SQLITE_DONE)
{
return YES;
}
else{
return NO;
}
sqlite3_reset(statement);
}
return NO;
}
-(NSArray*) findByRegisterNumber:(NSString *)registerNumber
{
const char *dbpath = [databasePath UTF8String];
if(sqlite3_open(dbpath,&database)== SQLITE_OK)
{
NSString *querySQL = [NSString stringWithFormat:@"select name, department,year from studentDetail where regno=\"%@\"",registerNumber];
const char *query_stmt = [querySQL UTF8String];
NSMutableArray *resultArray = [[NSMutableArray alloc]init];
if(sqlite3_prepare_v2(database,query_stmt,-1,&statement,NULL)== SQLITE_OK)
{
if(sqlite3_step(statement) == SQLITE_ROW)
{
NSString *name = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 0)];
[resultArray addObject:name];
NSString *department = [[NSString alloc]initWithUTF8String:(const char*) sqlite3_column_text(statement,1)];
[resultArray addObject:department];
return resultArray;
NSString *year = [[NSString alloc]initWithUTF8String:(const char*) sqlite3_column_text(statement,2)];
[resultArray addObject:year];
return resultArray;
}
else{
NSLog(@"Not Found");
return nil;
}
sqlite3_reset(statement);
}
}
return nil;
}
@end
```
ViewController.h:
```
//
// ViewController.h
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "DBManager.h"
@interface ViewController : UIViewController<UITextFieldDelegate>
{
IBOutlet UITextField *regNoTextField;
IBOutlet UITextField *nameTextField;
IBOutlet UITextField *departmentTextField;
IBOutlet UITextField *yearTextField;
IBOutlet UITextField *findByRegisterNumberTextField;
IBOutlet UIScrollView *myScrollView;
}
-(IBAction)saveData:(id)sender;
-(IBAction)findData:(id)sender;
/*
- (IBAction)find:(id)sender;
- (IBAction)save:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *findbox;
@property (weak, nonatomic) IBOutlet UITextField *regnobox;
@property (weak, nonatomic) IBOutlet UITextField *namebox;
@property (weak, nonatomic) IBOutlet UITextField *departmentbox;
@property (weak, nonatomic) IBOutlet UITextField *year;
*/
@end
```
ViewController.m:
```
//
// ViewController.m
// sqlite
//
// Created by Techinfiniti on 14/05/14.
// Copyright (c) 2014 Techinfiniti. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self)
{
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
- (IBAction)find:(id)sender {
}
- (IBAction)save:(id)sender {
}
*/
-(IBAction)saveData:(id)sender{
BOOL success = NO;
NSString *alertString = @"Data Insertion falied";
if(regNoTextField.text.length>0 && yearTextField.text.length>0 && departmentTextField.text.length>0 && yearTextField.text.length>0)
{
success = [[DBManager getSharedInstance]saveData:regNoTextField.text name:nameTextField.text department:departmentTextField.text year:yearTextField.text];
}
else
{
alertString = @"Enter all fields";
}
if(success == NO)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:alertString message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}
-(IBAction)findData:(id)sender{
NSArray *data = [[DBManager getSharedInstance]findByRegisterNumber:findByRegisterNumberTextField.text];
if(data == nil)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:
@"Data Not Found" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
regNoTextField.text = @"";
nameTextField.text = @"";
departmentTextField.text = @"";
yearTextField.text = @"";
}
else{
regNoTextField.text = findByRegisterNumberTextField.text;
nameTextField.text = [data objectAtIndex:0];
departmentTextField.text = [data objectAtIndex:1];
yearTextField.text = [data objectAtIndex:2];
}
}
#pragma mark - Text field delegate
-(void)textFieldDidBeginEditing:(UITextField *)textField{
[myScrollView setFrame:CGRectMake(10,50,300,200)];
}
-(BOOL) textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
@end
``` | 2014/05/15 | [
"https://Stackoverflow.com/questions/23673216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3522901/"
] | You have connected the UITextField in IB with "departmentbox".
```
@property (weak, nonatomic) IBOutlet UITextField *departmentbox;
```
But later you have commented the above lines in your view controller.
When you try to run the app,IB is looking for the "departmentbox" in viewcontroller. That causes the crash.
disconnect the "departmentbox" in IB will resolve the issue. | Perhaps you had declared an iVar named "departmentbox" in your view controller, created a connection in xib file to that iVar and later on you deleted/renamed this iVar but forgot to delete the connection created in xib file. Can you check the xib file of your view controller class and see if there is any connection to departmentBox. If you see that (with a little warning icon showing on the right of outlet connection in xib), just remove that connection and it should be fine. |
282,784 | I'm using Sybase ASE version 16.0.0.1915, (follows t-sql syntax) and trying to create a new trigger. This new trigger emulates another existing trigger, however is slightly modified. It would be a whole lot harder to modify the existing trigger to address both "workflows", so copying into a new trigger with modified details and an order of "2" would be my preferred solution.
I'm reading in the docs, that in order to create a new trigger based on the same action, I need to set the order for the triggers to fire off. If no order is specified, it is assigned order of 0 (first).
[Docs](http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc32300.1600/doc/html/ate1372183515788.html)
So here is my trigger, the existing similar trigger does not have an order set. When I place "ORDER 2" into the create statement (after the name, before "on" in row 1), I keep getting syntax error -131.
I've also tried placing the "ORDER 2" after the table name, before "for", and after "insert", before "as". All producing the same error -131.
So what am I doing wrong? Is there some other problem with this trigger preventing me to use the ORDER clause?
```
create trigger "DBA"."WKM_autoFillCL143" on
"DBA"."case_checklist" for insert
as
if((select top 1 "inserted"."code" from "inserted") in( '143' ) )
begin
declare @parentRef integer,@desc varchar(255),@desc1 varchar(255),@checkID integer
set @parentRef = (select top 1 "parent_ref" from "inserted")
if(@parentRef <> '0')
begin
set @desc = (select "description" from "case_checklist" where "checklist_id" = @parentRef)
if(@desc is not null)
begin
set @checkID = (select top 1 "checklist_id" from "inserted")
update "WKM_RecordChecklistMapping" set "c143" = @checkID where "c142" = @parentRef
declare @tabid integer
set @tabid = (select top 1 "tab_id" from "WKM_recordChecklistMapping" where "c142" = @parentRef)
set @tabid = (select top 1 "tab_id" from "user_tab2_data" where "tab_id" = @tabid)
if(@tabid is not null)
begin
declare @recProvider varchar(255),@recsRequested varchar(255),@dateFrom "datetime",@dateTo "datetime"
set @recProvider = (select top 1 "Provider_Name" from "user_tab2_data" where "tab_id" = @tabid)
set @recsRequested = (select top 1 "Records_Requested" from "user_tab2_data" where "tab_id" = @tabid)
set @dateFrom = (select top 1 "For_Dates_From" from "user_tab2_data" where "tab_id" = @tabid)
set @dateTo = (select top 1 "Through" from "user_tab2_data" where "tab_id" = @tabid)
set @desc1 = 'Receipt '+@recProvider+' Records? '+@recsRequested+', dates '+"coalesce"(convert(varchar(255),@dateFrom,1),'00/00/00')+' to '+"coalesce"(convert(varchar(255),@dateTo,1),'00/00/00')
set @checkID = (select top 1 "checklist_id" from "inserted")
update "case_checklist" set "description" = @desc1,"staff_assigned" = 'ZKS',"due_date" = ("today"()+7) where "checklist_id" = @checkID
end
end
end
end
``` | 2021/01/07 | [
"https://dba.stackexchange.com/questions/282784",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/198464/"
] | There are 4x different RDBMS products under the `Sybase` name ... `Adaptiver Server Enterprise (ASE)`, `SQLAnywhere`, `IQ` and `Advantage`. The 4x products do **not** share a common SQL language/syntax.
The question references a link for the `create trigger` syntax in `ASE`.
The sample code in the question appears to also be for `ASE`.
However, from the comments we've discovered the OP is actually using the `SQLAnywhere` product (version `16.0.0.1915`). And while `SQLAnywhere` does provide some half-workable support for `ASE's` `T-SQL` dialect, it does not include a common syntax for the `create trigger` command.
From the comments: OP has located the documentation for `SQLAnyhere's` [create trigger](http://dcx.sap.com/sa160/en/dbreference/create-trigger-statement.html) command.
Using one of the examples from that link (scroll down to find `CREATE TRIGGER myTrig`), and modifying OP's current trigger code to match the documentation, I'm thinking OP's looking for something like:
```
create trigger "DBA"."WKM_autoFillCL143"
after insert order 4 on "DBA"."case_checklist"
REFERENCING NEW AS inserted
FOR EACH STATEMENT
BEGIN
....
```
**NOTES**:
* I work primarily on `ASE`, and my `SQLAnywhere` experience is rather limited, so OP may need to tweak the above to work correctly in `SQLAnywhere`; also ...
* OP should review the various options available via `SQLAnywhere's` `create trigger` command (eg, should the trigger fire before or after the insert?)
* OP will need to review the rest of the current (`ASE/T-SQL`) trigger code to see which parts can be used 'as is' in `SQLAnywhere` and which parts will need to be rewritten to match `SQLAnywhere's` syntax
* OP will also want to verify `SQLAnywhere's` support for quoted identifiers (ie, does the current use of double-quoted identifiers meet `SQLAnywhere's` syntax?) | @mustaccio has already answered your question in the comments: place it just before `AS` at the top of the trigger.
You have a **much bigger** problem though. Your trigger does not deal with multi-row inserts. It needs a full rewrite. I hope I've got these joins right, as I don't have your full relational model:
```
create trigger "DBA"."WKM_autoFillCL143" on
"DBA"."case_checklist" for insert
as
if(not exists(select 1
from inserted i
inner join case_checklist c where c.checklist_id = i.parent_ref
where i.code = '143' and i.parent_ref <> '0' and c.description is not null))
return
update w
set c143 = i.checklist_id
from inserted i
join WKM_RecordChecklistMapping w on w.c142 = i.parent_ref
where i.code = '143' and i.parent_ref <> '0' and c.description is not null
update c
set description =
'Receipt ' + ut.Provider_Name + ' Records? ' + ut.Records_Requested +
', dates ' + coalesce(convert(varchar(255), ut.For_Dates_From, 1), '00/00/00') +
' to ' + coalesce(convert(varchar(255), ut.Through, 1), '00/00/00'),
staff_assigned = 'ZKS',
due_date = (today()+7)
from inserted i
inner join WKM_RecordChecklistMapping w on w.c142 = i.parent_ref
inner join user_tab2_data ut on ut.tab_id = w.tab_id
inner join case_checklist c on c.checklist_id = i.checklist_id
where i.code = '143' and i.parent_ref <> '0' and c.description is not null
```
Is `parent_ref <> '0'` correct? It looks like you actually wanted to write `parent_ref is not null`. Either way, I hope this is not an int column that you are comparing to text. |
27,550,376 | I want to use custom JSON deserializer for some classes(**Role** here) but I can't get it working. The custom deserializer just isn't called.
I use Spring Boot 1.2.
Deserializer:
```
public class ModelDeserializer extends JsonDeserializer<Role> {
@Override
public Role deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
return null; // this is what should be called but it isn't
}
}
```
Controller:
```
@RestController
public class RoleController {
@RequestMapping(value = "/role", method = RequestMethod.POST)
public Object createRole(Role role) {
// ... this is called
}
}
```
1. `@JsonDeserialize` on Role
```
@JsonDeserialize(using = ModelDeserializer.class)
public class Role extends Model {
}
```
2. `Jackson2ObjectMapperBuilder` bean in Java Config
```
@Bean
public Jackson2ObjectMapperBuilder jacksonBuilder() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.deserializerByType(Role.class, new ModelDeserializer());
return builder;
}
```
What am I doing wrong?
**EDIT** It is probably caused by `@RestController` because it works with `@Controller`... | 2014/12/18 | [
"https://Stackoverflow.com/questions/27550376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1712934/"
] | First of all you don't need to override `Jackson2ObjectMapperBuilder` to add custom deserializer. This approach should be used when you can't add `@JsonDeserialize` annotation. You should use `@JsonDeserialize` or override `Jackson2ObjectMapperBuilder`.
What is missed is the `@RequestBody` annotation:
```
@RestController
public class JacksonCustomDesRestEndpoint {
@RequestMapping(value = "/role", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Object createRole(@RequestBody Role role) {
return role;
}
}
@JsonDeserialize(using = RoleDeserializer.class)
public class Role {
// ......
}
public class RoleDeserializer extends JsonDeserializer<Role> {
@Override
public Role deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
// .................
return something;
}
}
``` | There is also another pretty interesting solution which can be helpful in case when you want to modify your JSON body before calling default deserializer. And let's imagine that you need to use some additional bean for that (use `@Autowire` mechanism)
Let's image situation, that you have the following controller:
```
@RequestMapping(value = "/order/product", method = POST)
public <T extends OrderProductInterface> RestGenericResponse orderProduct(@RequestBody @Valid T data) {
orderService.orderProduct(data);
return generateResponse();
}
```
Where `OrderProductInterface` is:
```
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include = NON_EMPTY)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, visible = true, property = "providerType")
@JsonSubTypes({
@JsonSubTypes.Type(value = OrderProductForARequestData.class, name = "A")
})
public interface OrderProductInterface{}
```
The code above will provide dynamic deserialization base on filed `providerType` and validation according to concrete implementation. For better grasp, consider that `OrderProductForARequestData` can be something like that:
```
public class OrderProductForARequestData implements OrderProductInterface {
@NotBlank(message = "is mandatory field.")
@Getter @Setter
private String providerId;
@NotBlank(message = "is mandatory field.")
@Getter @Setter
private String providerType;
@NotBlank(message = "is mandatory field.")
@Getter @Setter
private String productToOrder;
}
```
And let's image now that we want to init somehow `providerType` (enrich input) **before default deserialization will be executed.** so the object will be deserialized properly according to the rule in `OrderProductInterface`.
To do that you can just modify your `@Configuration` class in the following way:
```
//here can be any annotation which will enable MVC/Boot
@Configuration
public class YourConfiguration{
@Autowired
private ObjectMapper mapper;
@Autowired
private ProviderService providerService;
@Override
public void setup() {
super.setup();
SimpleModule module = new SimpleModule();
module.setDeserializerModifier(new BeanDeserializerModifier() {
@Override
public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
if (beanDesc.getBeanClass() == OrderProductInterface.class) {
return new OrderProductInterfaceDeserializer(providerService, beanDesc);
}
return deserializer;
}
});
mapper.registerModule(module);
}
public static class OrderProductInterfaceDeserializer extends AbstractDeserializer {
private static final long serialVersionUID = 7923585097068641765L;
private final ProviderService providerService;
OrderProductInterfaceDeserializer(roviderService providerService, BeanDescription beanDescription) {
super(beanDescription);
this.providerService = providerService;
}
@Override
public Object deserializeWithType(JsonParser p, DeserializationContext context, TypeDeserializer typeDeserializer) throws IOException {
ObjectCodec oc = p.getCodec();
JsonNode node = oc.readTree(p);
//Let's image that we have some identifier for provider type and we want to detect it
JsonNode tmp = node.get("providerId");
Assert.notNull(tmp, "'providerId' is mandatory field");
String providerId = tmp.textValue();
Assert.hasText(providerId, "'providerId' can't be empty");
// Modify node
((ObjectNode) node).put("providerType",providerService.getProvider(providerId));
JsonFactory jsonFactory = new JsonFactory();
JsonParser newParser = jsonFactory.createParser(node.toString());
newParser.nextToken();
return super.deserializeWithType(newParser, context, typeDeserializer);
}
}
}
``` |
5,428,199 | Height of a div
I'm trying to set the size of a div according to its content.
See the complete code [here](http://jsfiddle.net/Ridermansb/nqSxC/6/).
Basically my problem is in the div: content
In the HTML code look for the comment: wrongly
There had to add a tag p, I'm giving it a clear that the div align to the end.
Without this clear, the div will cut the image.
Actually I wonder just a better way to do this task.
There seemed a good a place p with nothing in it only with a clear class so that this problem does not happen.
What do you recommend me? There is a better way to do this task?
The goal is not to let the rope div content:
**Html**
```
<div id="header">
<div class="headerLeft" />
</div>
<div id="waycontact">
<div class="contactPaula">
<p>paulaMACHADO</p>
<p>crea 11111/D-MG</p>
<p>(00) 0000 0000</p>
</div>
<div class="contactBeatriz">
<p>beatrizDAMAS</p>
<p>crea 22222/D-MG</p>
<p>(00) 0000 0000</p>
</div>
<div class="address">
<p>av. xxxxxxxl, yyy, sl. zzz, centro - belo horizonte - mg</p>
<p>cep: 00000-000 - telefax: (00) 0000 0000</p>
<p><a href="mailto:xxxxx@yyyy.com.br">xxxxx@yyyy.com.br</a></p>
</div>
</div>
<div id="content">
<img class="left" alt="Arquitetura" src="http://cdn.archdaily.net/wp-content/uploads/2009/05/1265154380_107-silos-090511-west-view-a4-allard-architecture-528x304.jpg" />
<h2>Sobre a empresa</h2>
<p>A AMSD é focada em qualidade..</p>
<p class="clear" /> <!--Wrongly!! -->
</div>
<div id="footer">
<a class="current" href="#">home</a>
|
<a href="#">quem somos</a>
|
<a href="#">blog</a>
|
<a href="#">na mídia</a>
|
<a href="#">fale conosco</a>
</div>
```
**CSS**
```
body
{
font-size: 0.87em;
font-family: Calibri, Arial, Georgia, Verdana, Tahoma, Microsoft Sans Serif;
margin: 0;
padding: 0;
color: #666666;
}
a:link
{
color: rgb(124,71,111);
text-decoration: underline;
}
a:visited
{
color: rgb(41, 12, 36);
}
a:hover
{
color: rgb(91,25,79);
text-decoration: none;
}
a:active
{
color: #AB6D9C;
}
p
{
margin:2px;
}
ul
{
list-style-type: square;
}
li
{
line-height: 165%;
}
div#header
{
width:1024px;
margin:5px auto;
height:150px;
background-color: rgb(91,25,79);
}
div.headerLeft
{
height:100%;
width:900px;
border-right:10px solid rgb(169, 171, 174);
background-color: rgb(124,71,111);
}
div#footer
{
margin-top:10px;
text-align:center;
position:relative;
font-size: 1.27em;
}
div#content
{
margin:auto 40px;
width:200;
border:2px solid red;
}
/* Others
-----------------------------------------------------------*/
div.contactPaula p, div.contactBeatriz p
{
padding:0px;
margin:0px;
}
div.contact, div.contactPaula, div.contactBeatriz
{
margin-bottom:15px;
margin-top:0px;
}
div.contactBeatriz
{
float:right;
text-align:right;
}
div.contactPaula
{
float:left;
text-align:left;
}
div.address
{
text-align:center;
margin-bottom:30px;
}
div#waycontact
{
width:340px;
margin:20px 40px;
}
.clear, div.address, div#footer, div#waycontact
{
clear:both;
}
.left
{
float:left;
}
a.current
{
font-weight:bold;
}
``` | 2011/03/25 | [
"https://Stackoverflow.com/questions/5428199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/491181/"
] | To make a container expand to fill floated elements, give it an overflow property:
```
div.wrapper {
overflow: auto;
}
``` | A better method than using an empty `<div class="clear">` is to use the 'cearfix' method.
This is an example borrowed straight from [HTML5Bolierplate](http://html5boilerplate.com/), just apply it to the div that is giving you trouble.
In your case `#content` will become `#content.clearfix`
```
/* The Magnificent Clearfix: Updated to prevent margin-collapsing on child elements.
j.mp/bestclearfix */
.clearfix:before, .clearfix:after { content: "\0020"; display: block; height: 0; overflow: hidden; }
.clearfix:after { clear: both; }
/* Fix clearfix: blueprintcss.lighthouseapp.com/projects/15318/tickets/5-extra-margin-padding-bottom-of-page */
.clearfix { zoom: 1;
``` |
5,428,199 | Height of a div
I'm trying to set the size of a div according to its content.
See the complete code [here](http://jsfiddle.net/Ridermansb/nqSxC/6/).
Basically my problem is in the div: content
In the HTML code look for the comment: wrongly
There had to add a tag p, I'm giving it a clear that the div align to the end.
Without this clear, the div will cut the image.
Actually I wonder just a better way to do this task.
There seemed a good a place p with nothing in it only with a clear class so that this problem does not happen.
What do you recommend me? There is a better way to do this task?
The goal is not to let the rope div content:
**Html**
```
<div id="header">
<div class="headerLeft" />
</div>
<div id="waycontact">
<div class="contactPaula">
<p>paulaMACHADO</p>
<p>crea 11111/D-MG</p>
<p>(00) 0000 0000</p>
</div>
<div class="contactBeatriz">
<p>beatrizDAMAS</p>
<p>crea 22222/D-MG</p>
<p>(00) 0000 0000</p>
</div>
<div class="address">
<p>av. xxxxxxxl, yyy, sl. zzz, centro - belo horizonte - mg</p>
<p>cep: 00000-000 - telefax: (00) 0000 0000</p>
<p><a href="mailto:xxxxx@yyyy.com.br">xxxxx@yyyy.com.br</a></p>
</div>
</div>
<div id="content">
<img class="left" alt="Arquitetura" src="http://cdn.archdaily.net/wp-content/uploads/2009/05/1265154380_107-silos-090511-west-view-a4-allard-architecture-528x304.jpg" />
<h2>Sobre a empresa</h2>
<p>A AMSD é focada em qualidade..</p>
<p class="clear" /> <!--Wrongly!! -->
</div>
<div id="footer">
<a class="current" href="#">home</a>
|
<a href="#">quem somos</a>
|
<a href="#">blog</a>
|
<a href="#">na mídia</a>
|
<a href="#">fale conosco</a>
</div>
```
**CSS**
```
body
{
font-size: 0.87em;
font-family: Calibri, Arial, Georgia, Verdana, Tahoma, Microsoft Sans Serif;
margin: 0;
padding: 0;
color: #666666;
}
a:link
{
color: rgb(124,71,111);
text-decoration: underline;
}
a:visited
{
color: rgb(41, 12, 36);
}
a:hover
{
color: rgb(91,25,79);
text-decoration: none;
}
a:active
{
color: #AB6D9C;
}
p
{
margin:2px;
}
ul
{
list-style-type: square;
}
li
{
line-height: 165%;
}
div#header
{
width:1024px;
margin:5px auto;
height:150px;
background-color: rgb(91,25,79);
}
div.headerLeft
{
height:100%;
width:900px;
border-right:10px solid rgb(169, 171, 174);
background-color: rgb(124,71,111);
}
div#footer
{
margin-top:10px;
text-align:center;
position:relative;
font-size: 1.27em;
}
div#content
{
margin:auto 40px;
width:200;
border:2px solid red;
}
/* Others
-----------------------------------------------------------*/
div.contactPaula p, div.contactBeatriz p
{
padding:0px;
margin:0px;
}
div.contact, div.contactPaula, div.contactBeatriz
{
margin-bottom:15px;
margin-top:0px;
}
div.contactBeatriz
{
float:right;
text-align:right;
}
div.contactPaula
{
float:left;
text-align:left;
}
div.address
{
text-align:center;
margin-bottom:30px;
}
div#waycontact
{
width:340px;
margin:20px 40px;
}
.clear, div.address, div#footer, div#waycontact
{
clear:both;
}
.left
{
float:left;
}
a.current
{
font-weight:bold;
}
``` | 2011/03/25 | [
"https://Stackoverflow.com/questions/5428199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/491181/"
] | Add a "overflow:hidden;" to the div#content so it will look like the following. You won't need a separate clear property and a p tag. Good luck :)
```
div#content
{
margin:auto 40px;
width:200;
border:2px solid red;
overflow:hidden;
}
``` | To make a container expand to fill floated elements, give it an overflow property:
```
div.wrapper {
overflow: auto;
}
``` |
5,428,199 | Height of a div
I'm trying to set the size of a div according to its content.
See the complete code [here](http://jsfiddle.net/Ridermansb/nqSxC/6/).
Basically my problem is in the div: content
In the HTML code look for the comment: wrongly
There had to add a tag p, I'm giving it a clear that the div align to the end.
Without this clear, the div will cut the image.
Actually I wonder just a better way to do this task.
There seemed a good a place p with nothing in it only with a clear class so that this problem does not happen.
What do you recommend me? There is a better way to do this task?
The goal is not to let the rope div content:
**Html**
```
<div id="header">
<div class="headerLeft" />
</div>
<div id="waycontact">
<div class="contactPaula">
<p>paulaMACHADO</p>
<p>crea 11111/D-MG</p>
<p>(00) 0000 0000</p>
</div>
<div class="contactBeatriz">
<p>beatrizDAMAS</p>
<p>crea 22222/D-MG</p>
<p>(00) 0000 0000</p>
</div>
<div class="address">
<p>av. xxxxxxxl, yyy, sl. zzz, centro - belo horizonte - mg</p>
<p>cep: 00000-000 - telefax: (00) 0000 0000</p>
<p><a href="mailto:xxxxx@yyyy.com.br">xxxxx@yyyy.com.br</a></p>
</div>
</div>
<div id="content">
<img class="left" alt="Arquitetura" src="http://cdn.archdaily.net/wp-content/uploads/2009/05/1265154380_107-silos-090511-west-view-a4-allard-architecture-528x304.jpg" />
<h2>Sobre a empresa</h2>
<p>A AMSD é focada em qualidade..</p>
<p class="clear" /> <!--Wrongly!! -->
</div>
<div id="footer">
<a class="current" href="#">home</a>
|
<a href="#">quem somos</a>
|
<a href="#">blog</a>
|
<a href="#">na mídia</a>
|
<a href="#">fale conosco</a>
</div>
```
**CSS**
```
body
{
font-size: 0.87em;
font-family: Calibri, Arial, Georgia, Verdana, Tahoma, Microsoft Sans Serif;
margin: 0;
padding: 0;
color: #666666;
}
a:link
{
color: rgb(124,71,111);
text-decoration: underline;
}
a:visited
{
color: rgb(41, 12, 36);
}
a:hover
{
color: rgb(91,25,79);
text-decoration: none;
}
a:active
{
color: #AB6D9C;
}
p
{
margin:2px;
}
ul
{
list-style-type: square;
}
li
{
line-height: 165%;
}
div#header
{
width:1024px;
margin:5px auto;
height:150px;
background-color: rgb(91,25,79);
}
div.headerLeft
{
height:100%;
width:900px;
border-right:10px solid rgb(169, 171, 174);
background-color: rgb(124,71,111);
}
div#footer
{
margin-top:10px;
text-align:center;
position:relative;
font-size: 1.27em;
}
div#content
{
margin:auto 40px;
width:200;
border:2px solid red;
}
/* Others
-----------------------------------------------------------*/
div.contactPaula p, div.contactBeatriz p
{
padding:0px;
margin:0px;
}
div.contact, div.contactPaula, div.contactBeatriz
{
margin-bottom:15px;
margin-top:0px;
}
div.contactBeatriz
{
float:right;
text-align:right;
}
div.contactPaula
{
float:left;
text-align:left;
}
div.address
{
text-align:center;
margin-bottom:30px;
}
div#waycontact
{
width:340px;
margin:20px 40px;
}
.clear, div.address, div#footer, div#waycontact
{
clear:both;
}
.left
{
float:left;
}
a.current
{
font-weight:bold;
}
``` | 2011/03/25 | [
"https://Stackoverflow.com/questions/5428199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/491181/"
] | Add a "overflow:hidden;" to the div#content so it will look like the following. You won't need a separate clear property and a p tag. Good luck :)
```
div#content
{
margin:auto 40px;
width:200;
border:2px solid red;
overflow:hidden;
}
``` | A better method than using an empty `<div class="clear">` is to use the 'cearfix' method.
This is an example borrowed straight from [HTML5Bolierplate](http://html5boilerplate.com/), just apply it to the div that is giving you trouble.
In your case `#content` will become `#content.clearfix`
```
/* The Magnificent Clearfix: Updated to prevent margin-collapsing on child elements.
j.mp/bestclearfix */
.clearfix:before, .clearfix:after { content: "\0020"; display: block; height: 0; overflow: hidden; }
.clearfix:after { clear: both; }
/* Fix clearfix: blueprintcss.lighthouseapp.com/projects/15318/tickets/5-extra-margin-padding-bottom-of-page */
.clearfix { zoom: 1;
``` |
101,061 | Consider a random variable $\tau$:
$$\tau := \inf \left\{ {k = \sigma , \ldots ,T:S\_k \ge u} \right\}\wedge T,$$
where $\sigma$ is a stopping time, $S\_k$ - stochastic process, $T, u$ are constants and $a\wedge b=\min(a,b)$. I would like to prove that $\tau$ is a stopping time, i.e. I need to show that $\{ \tau\le k\} \in {F\_k}$, where ${F\_k}$ is natural filtration.
I tried to present $\tau$ as $\{ \tau \le k\} = \mathop \bigcup \limits\_{j = \sigma }^k \{ \tau = j\} $ and to show that $\{ \tau = j\}\in F\_j, {F\_j} \subset {F\_k}$, so I can conclude that $\{ \tau\le k\} \in {F\_k}$. But can I really use a stopping time $\sigma$ in union operator as starting index? If not, what is the correct way to prove that $\tau$ is a stopping time? | 2012/01/21 | [
"https://math.stackexchange.com/questions/101061",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/15871/"
] | Let $\mathcal F$ denote the filtration $(\mathcal F\_n)\_{n\geqslant0}$ and $S$ the process $(S\_n)\_{n\geqslant0}$. The result follows from the fact that, for every $0\leqslant k\leqslant T-1$,
$$
[\tau\leqslant k]=\bigcup\_{i=0}^kA\_i^k$$
with
$$A\_i^k=[\sigma=i]\cup\bigcup\_{j=i}^k[S\_j\geqslant u]
$$
Fix $0\leqslant k\leqslant T-1$. Then, for every $0\leqslant i\leqslant k$, $[\sigma=i]\in\mathcal F\_i$ because $\sigma$ is an $\mathcal F$-stopping time, and $\mathcal F\_i\subseteq\mathcal F\_k$, hence $[\sigma=i]\in \mathcal F\_k$. For every $i\leqslant j\leqslant k$, $[S\_j\geqslant u]\in \mathcal F\_j$ because $S$ is $\mathcal F$-adapted, and $\mathcal F\_j\subseteq\mathcal F\_k$, hence $[S\_j\geqslant u]\in\mathcal F\_k$.
Thus, $A\_i^k\in\mathcal F\_k$ for every $0\leqslant i\leqslant k$, which proves that $[\tau\leqslant k]\in\mathcal F\_k$.
Finally, for every $k\geqslant T$, $[\tau\leqslant k]=\Omega\in\mathcal F\_k$, hence $\tau$ is an $\mathcal F$-stopping time. | Is it also correct if we replace $S\_k$ by a right-continuous stochastic process $X\_t$,
a right-continuous filtration $\mathcal{F}\_t$, an open set $B$ and a stopping time $S$
with values in $[0,\infty[$? Or to be more precise i formulate it as a Theorem:
Theorem: Assume we have a right-continuous stochastic process $X\_t$,
a right-continuous filtration $\mathcal{F}\_t$, an open set $B$ and a stopping time $S$
with values in $[0,\infty[$. Then
$ \tau\_B^S:=\inf \left\{t\geq S\ : \ X\_t\in B\right\}$
is a stopping time.
I tried to proof it, but failed. I have shown, that for a fixed number $r\in[0,\infty[$ the random variable $\tau\_B^r$ is a stopping time. Indeed by $X$ right-continuous and $B$ open we have
$\left\{\tau\_B^S<t\right\}=\bigcup\limits\_{s\ :\ s\ \in\ [u,t[\cap \mathbb{Q}} \left\{X\_s\in B\right\}
\in \mathcal{F}\_t$
and therefore by the right-continuity of the filtration the claim follows.
Now you can write
$\left\{\tau\_B^S<t\right\}=\bigcup\limits\_{r\ :\ r \ \in\ [0,t[} \left\{S = r\right\}\cap
\left\{\tau\_B^r<t\right\}$.
and by the first part the intersection of the two sets is an element of $\mathcal{F}\_t$.
But now we got to my problem. I don't know how to get a countable union, i.e. something like that
$\left\{\tau\_B^S<t\right\} ?=? \bigcup\limits\_{r\ :\ r \ \in\ [0,t[\cap \mathbb{Q}} \left\{S = r\right\}\cap
\left\{\tau\_B^r<t\right\}$.
Is this possible or is there another more simple solution to the problem? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.