qid
int64 1
74.7M
| question
stringlengths 0
58.3k
| date
stringlengths 10
10
| metadata
list | response_j
stringlengths 2
48.3k
| response_k
stringlengths 2
40.5k
|
---|---|---|---|---|---|
18,081,917 | ```
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href = "Jquery.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
var amount = new Array();
var x;
amount[0] = 1;
function jobID(form){
x = document.forms["JobIdForm"]["jobid"].value;
return false;
}
$(document).ready(function(){
jQuery('<div/>', {
id: 'box',
click: function(){
jQuery('<div/>', {
id: 'bob'+amount.length
}).appendTo('#scroller');
jQuery('<div/>', {
id: 'bobb'+amount.length
}).appendTo('#scroller');
jQuery('<div/>', {
id: 'bobbb'+amount.length
}).appendTo('#scroller');
$('#bob'+amount.length).css('width', '200px');
$('#bob'+amount.length).css('height', '80px');
$('#bob'+amount.length).css('background-color', '#F2F2F2');
$('#bob'+amount.length).css('border', '3px solid black');
$('#bob'+amount.length).css('margin-top', '10px');
$('#bobb'+amount.length).append(x);
$('#bobb'+amount.length).css('width', '130px');
$('#bobb'+amount.length).css('height', '80px');
$('#bobb'+amount.length).css('background-color', '#F2F2F2');
$('#bobb'+amount.length).css('border', '3px solid black');
$('#bobb'+amount.length).css('margin-top', '-86px');
$('#bobb'+amount.length).css('margin-left', '220px');
$('#bobb'+amount.length).append('hello');
$('#bobbb'+amount.length).css('width', '300px');
$('#bobbb'+amount.length).css('height', '80px');
$('#bobbb'+amount.length).css('background-color', '#F2F2F2');
$('#bobbb'+amount.length).css('border', '3px solid black');
$('#bobbb'+amount.length).css('margin-top', '-86px');
$('#bobbb'+amount.length).css('margin-left', '370px');
$('#bobbb'+amount.length).append('hello');
amount[amount.length] = 1;
}
}).appendTo('body');
$('#box').append("Submit All");
});
</script>
</head>
<body>
<header>
<h1>Fill out Forms</h1>
</header>
<section>
<div id="keys">
<div id ="job">
<p>Job ID</p>
</div>
<div id="date">
<p>Date</p>
</div>
<div id="desc">
<p>Description</p>
</div>
</div>
<div id = "scroller" style="width: 700px; height: 400px; overflow-y: scroll;">
</div>
<form name="JobIdForm" action="" onsubmit="return jobID(this)" method="post">
Job ID <input type="text" name="jobid">
<input type="submit" value="Submit">
</form>
</section>
</body>
</html>
``` | 2013/08/06 | [
"https://Stackoverflow.com/questions/18081917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1449637/"
]
| Your scope of `x` is the issue. `x` is local to jobID. Declare `x` outside of the function.
```
var x;
function jobID(form){
x = document.forms["JobIdForm"]["jobid"].value;
return false;
}
``` | try something like this:
js
==
```
$(function(){ //equivalent to $(document).read(function(){});
//you are running "joID(form)" on submit now, but have it written/called right in the html. i try to avoid that.
$("form[name='JobIdForm']").submit(function(event){
//i did not see an actual form[action] value, so I preventDefault() to call that out
event.preventDefault();
//we want the value in bob, so I have jQuery create a <div> and throw the input value between the element tags
$("#bob").append($("<div>"+$(this).find("input[name='jobid']").val()+"</div>");
});
});
```
html needed to make the above work:
===================================
```
<form name="JobIdForm" action="" method="post">
<label>Job ID <input type="text" name="jobid"></label>
<input type="submit" value="Submit">
</form>
``` |
5,651,956 | So I saw [this question](https://stackoverflow.com/q/3573554/186643) here on SO, but it hasn't really solved this problem for me.
I have an ASP.NET MVC 3 + Razor app running on IIS5 on my dev pc, and then IIS6 for my dev web server. Everything worked great until I deployed it. I am bin deploying everything, with no problems on that front (that I can tell).
Now I am getting this **Child actions are not allowed to perform redirect actions** error on my page. I am not sure how to pinpoint where it is failing.
I'm using @Html.Action to pull in some drop down boxes with data:
```
public ActionResult Hierarchy()
{
List<Store> storeList = DBService.getStores();
if (DBService.Error != null)
return RedirectToError(DBService.Error);
List<Department> deptList = DBService.getDepts();
if (DBService.Error != null)
return RedirectToError(DBService.Error);
VM_Hierarchy hierarchy = new VM_Hierarchy(storeList, deptList);
return View(hierarchy);
}
```
If I remove the @Html.Action line, the page will render. It will then break if I do an AJAX request to a controller action such as this:
```
[HttpPost]
public ActionResult InventoryList(string fromDate, string toDate)
{
List<Inventory> inventories = DBService.getInventories(fromDate, toDate);
if (DBService.Error != null)
return RedirectToAction("Error");
return View(inventories);
}
```
If this isn't correct, how am I supposed to redirect to an error page or dictate what view gets returned on a post? Any help is appreciated. Thanks. | 2011/04/13 | [
"https://Stackoverflow.com/questions/5651956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/186643/"
]
| It's probably because you're getting errors from your DB service when it's deployed, which you aren't getting locally. This is causing it to try and redirect from a child action, which you can't do.
You might want to try getting the drop-down data in your main action, and put it all in a ViewModel, so you aren't using child actions. If this fails, you can redirect to your heart's content. For the AJAX, you'll need to handle the errors on the client and do something sensible, you can't just return a redirection from an AJAX call.
This question has some further info:
[Why are Redirect Results not allowed in Child Actions in Asp.net MVC 2](https://stackoverflow.com/questions/2056421/why-are-redirect-results-not-allowed-in-child-actions-in-asp-net-mvc-2) | I had a similar problem but for the life of me, I couldn't figure out where the redirection was coming from. Once I figured it out, I thought I'd post an answer in case it happens to anyone else.
If the source of the redirection is not apparent from the imperative code, e.g.:
```
[AuthoriseThis]
public ActionResult Details(SomethingModel something)
{
return PartialView(something);
}
```
Look at the declarative code!
In my case, it was an authorisation problem, so the attribute was causing the redirection, and my eyes were filtering out the existence of the attribute. |
5,651,956 | So I saw [this question](https://stackoverflow.com/q/3573554/186643) here on SO, but it hasn't really solved this problem for me.
I have an ASP.NET MVC 3 + Razor app running on IIS5 on my dev pc, and then IIS6 for my dev web server. Everything worked great until I deployed it. I am bin deploying everything, with no problems on that front (that I can tell).
Now I am getting this **Child actions are not allowed to perform redirect actions** error on my page. I am not sure how to pinpoint where it is failing.
I'm using @Html.Action to pull in some drop down boxes with data:
```
public ActionResult Hierarchy()
{
List<Store> storeList = DBService.getStores();
if (DBService.Error != null)
return RedirectToError(DBService.Error);
List<Department> deptList = DBService.getDepts();
if (DBService.Error != null)
return RedirectToError(DBService.Error);
VM_Hierarchy hierarchy = new VM_Hierarchy(storeList, deptList);
return View(hierarchy);
}
```
If I remove the @Html.Action line, the page will render. It will then break if I do an AJAX request to a controller action such as this:
```
[HttpPost]
public ActionResult InventoryList(string fromDate, string toDate)
{
List<Inventory> inventories = DBService.getInventories(fromDate, toDate);
if (DBService.Error != null)
return RedirectToAction("Error");
return View(inventories);
}
```
If this isn't correct, how am I supposed to redirect to an error page or dictate what view gets returned on a post? Any help is appreciated. Thanks. | 2011/04/13 | [
"https://Stackoverflow.com/questions/5651956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/186643/"
]
| It's probably because you're getting errors from your DB service when it's deployed, which you aren't getting locally. This is causing it to try and redirect from a child action, which you can't do.
You might want to try getting the drop-down data in your main action, and put it all in a ViewModel, so you aren't using child actions. If this fails, you can redirect to your heart's content. For the AJAX, you'll need to handle the errors on the client and do something sensible, you can't just return a redirection from an AJAX call.
This question has some further info:
[Why are Redirect Results not allowed in Child Actions in Asp.net MVC 2](https://stackoverflow.com/questions/2056421/why-are-redirect-results-not-allowed-in-child-actions-in-asp-net-mvc-2) | if you put in the child action
`(ControllerContext.ParentActionViewContext.Controller as System.Web.Mvc.Controller).Response.Redirect(Url.Action("Action", "Controller"));` it will redirect from the childaction. |
5,651,956 | So I saw [this question](https://stackoverflow.com/q/3573554/186643) here on SO, but it hasn't really solved this problem for me.
I have an ASP.NET MVC 3 + Razor app running on IIS5 on my dev pc, and then IIS6 for my dev web server. Everything worked great until I deployed it. I am bin deploying everything, with no problems on that front (that I can tell).
Now I am getting this **Child actions are not allowed to perform redirect actions** error on my page. I am not sure how to pinpoint where it is failing.
I'm using @Html.Action to pull in some drop down boxes with data:
```
public ActionResult Hierarchy()
{
List<Store> storeList = DBService.getStores();
if (DBService.Error != null)
return RedirectToError(DBService.Error);
List<Department> deptList = DBService.getDepts();
if (DBService.Error != null)
return RedirectToError(DBService.Error);
VM_Hierarchy hierarchy = new VM_Hierarchy(storeList, deptList);
return View(hierarchy);
}
```
If I remove the @Html.Action line, the page will render. It will then break if I do an AJAX request to a controller action such as this:
```
[HttpPost]
public ActionResult InventoryList(string fromDate, string toDate)
{
List<Inventory> inventories = DBService.getInventories(fromDate, toDate);
if (DBService.Error != null)
return RedirectToAction("Error");
return View(inventories);
}
```
If this isn't correct, how am I supposed to redirect to an error page or dictate what view gets returned on a post? Any help is appreciated. Thanks. | 2011/04/13 | [
"https://Stackoverflow.com/questions/5651956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/186643/"
]
| if you put in the child action
`(ControllerContext.ParentActionViewContext.Controller as System.Web.Mvc.Controller).Response.Redirect(Url.Action("Action", "Controller"));` it will redirect from the childaction. | I had a similar problem but for the life of me, I couldn't figure out where the redirection was coming from. Once I figured it out, I thought I'd post an answer in case it happens to anyone else.
If the source of the redirection is not apparent from the imperative code, e.g.:
```
[AuthoriseThis]
public ActionResult Details(SomethingModel something)
{
return PartialView(something);
}
```
Look at the declarative code!
In my case, it was an authorisation problem, so the attribute was causing the redirection, and my eyes were filtering out the existence of the attribute. |
55,371,468 | I am building a landing page with fixed left and right image and content in the middle. in desktop view its working fine but in mobile view the images overlapping the contents. how do I fix this?
```
<div class="container">
<div class="row">
<div class="col-sm col-lg mt-5 mb-5">
<div class="text-center">
<img src="images/me.svg" class="img-fluid" style="width: 200px">
</div>
<div class="text-center" style=" font-family: 'CustomFont',SceneStd-Light; color: #969595;">
UAE’s largest online plant store launching soon in
</div>
</div>
</div>
<div class="row pb-5">
<div class="col-sm text-center">
<img src="images/bahrain.svg" style="height: 150px">
<div class="text-center pb-2 pt-2"><span>Bahrain</span></div>
</div>
<div class="col-sm text-center">
<img src="images/saudi.svg" style="height: 150px">
<div class="text-center pb-2 pt-2"><span>Bahrain</span></div>
</div>
<div class="col-sm text-center">
<img src="images/kuwait.svg" style="height: 150px">
<div class="text-center pb-2 pt-2"><span>Bahrain</span></div>
</div>
</div>
<div class="row">
<div class="col-sm col-lg mt-5 mb-5">
<div class="text-center">
<a href="#"><img src="images/ae.svg" class="img-fluid" style="width: 200px"></a>
</div>
<div class="text-center">
<a href="#"><img src="images/uae.svg" style="height: 150px"></a>
</div>
<div class="text-center pb-2 pt-2"><span>Visit our UAE store</span></div>
</div>
</div>
</div>
<div class="right">
<a href="#"> <img src="images/right.png" class="img-responsive layout-image" ></a>
</div>
```
```
.left{
left: 0;
width: 150px;
height: 100%;
position: absolute;}
.right{
top: 0px;
right: 0;
/*width: 150px;*/
height: 100%;
position: absolute;}
.layout-image{height: 100%}
```
In Desktop view

In mobile view

How do I fix this in mobile and tablet view. | 2019/03/27 | [
"https://Stackoverflow.com/questions/55371468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10110626/"
]
| ```css
.dashed-box {
position: relative;
z-index: 1;
border: dashed;
height: 8em;
margin-bottom: 1em;
margin-top: 2em;
}
.gold-box {
position: absolute;
z-index: 3; /* put .gold-box above .green-box and .dashed-box */
background: gold;
width: 80%;
left: 60px;
top: 3em;
}
.green-box {
position: absolute;
z-index: 2; /* put .green-box above .dashed-box */
background: lightgreen;
width: 20%;
left: 65%;
top: -25px;
height: 7em;
opacity: 0.9;
}
```
```html
<!-- Learn about this code on MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/z-index -->
<div class="dashed-box">Dashed box
<span class="gold-box">Gold box</span>
<span class="green-box">Green box</span>
</div>
```
There are multiple ways to do this, are mentioned my @bpolar you can use the z-index. Another way of doing it is with media selectors which would allow you to have different css properties for different screen sizes
Example:
```
@media (min-width:1281) {
image {
width:200px;
}
}
@media (max-width:1280) {
image {
width:100px;
}
}
```
This code will display images in different sizes for different display-widths, you could see them as if-statements.
The benefit of this approach is that you have finer control over how it appears on different display configurations. That being said I think the best option is a combination of the two.
If you need more info about the z-index that can be found [here](https://developer.mozilla.org/en-US/docs/Web/CSS/z-index)
I hope this is what you're looking for.
Good luck. | Set the Z-index on those images. The trick is that the content needs higher position than the images.
Example:
.img\_class {z-index: -1} |
55,371,468 | I am building a landing page with fixed left and right image and content in the middle. in desktop view its working fine but in mobile view the images overlapping the contents. how do I fix this?
```
<div class="container">
<div class="row">
<div class="col-sm col-lg mt-5 mb-5">
<div class="text-center">
<img src="images/me.svg" class="img-fluid" style="width: 200px">
</div>
<div class="text-center" style=" font-family: 'CustomFont',SceneStd-Light; color: #969595;">
UAE’s largest online plant store launching soon in
</div>
</div>
</div>
<div class="row pb-5">
<div class="col-sm text-center">
<img src="images/bahrain.svg" style="height: 150px">
<div class="text-center pb-2 pt-2"><span>Bahrain</span></div>
</div>
<div class="col-sm text-center">
<img src="images/saudi.svg" style="height: 150px">
<div class="text-center pb-2 pt-2"><span>Bahrain</span></div>
</div>
<div class="col-sm text-center">
<img src="images/kuwait.svg" style="height: 150px">
<div class="text-center pb-2 pt-2"><span>Bahrain</span></div>
</div>
</div>
<div class="row">
<div class="col-sm col-lg mt-5 mb-5">
<div class="text-center">
<a href="#"><img src="images/ae.svg" class="img-fluid" style="width: 200px"></a>
</div>
<div class="text-center">
<a href="#"><img src="images/uae.svg" style="height: 150px"></a>
</div>
<div class="text-center pb-2 pt-2"><span>Visit our UAE store</span></div>
</div>
</div>
</div>
<div class="right">
<a href="#"> <img src="images/right.png" class="img-responsive layout-image" ></a>
</div>
```
```
.left{
left: 0;
width: 150px;
height: 100%;
position: absolute;}
.right{
top: 0px;
right: 0;
/*width: 150px;*/
height: 100%;
position: absolute;}
.layout-image{height: 100%}
```
In Desktop view

In mobile view

How do I fix this in mobile and tablet view. | 2019/03/27 | [
"https://Stackoverflow.com/questions/55371468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10110626/"
]
| ```css
.dashed-box {
position: relative;
z-index: 1;
border: dashed;
height: 8em;
margin-bottom: 1em;
margin-top: 2em;
}
.gold-box {
position: absolute;
z-index: 3; /* put .gold-box above .green-box and .dashed-box */
background: gold;
width: 80%;
left: 60px;
top: 3em;
}
.green-box {
position: absolute;
z-index: 2; /* put .green-box above .dashed-box */
background: lightgreen;
width: 20%;
left: 65%;
top: -25px;
height: 7em;
opacity: 0.9;
}
```
```html
<!-- Learn about this code on MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/z-index -->
<div class="dashed-box">Dashed box
<span class="gold-box">Gold box</span>
<span class="green-box">Green box</span>
</div>
```
There are multiple ways to do this, are mentioned my @bpolar you can use the z-index. Another way of doing it is with media selectors which would allow you to have different css properties for different screen sizes
Example:
```
@media (min-width:1281) {
image {
width:200px;
}
}
@media (max-width:1280) {
image {
width:100px;
}
}
```
This code will display images in different sizes for different display-widths, you could see them as if-statements.
The benefit of this approach is that you have finer control over how it appears on different display configurations. That being said I think the best option is a combination of the two.
If you need more info about the z-index that can be found [here](https://developer.mozilla.org/en-US/docs/Web/CSS/z-index)
I hope this is what you're looking for.
Good luck. | If you assign the `!important` keyword after the z-index for `.left` and `.right` classes and then explicitly set a higher z-index on `.container` class it appears to work ok.
```
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>plantshop.me</title>
<link href="//stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous" />
<style>
.left{
z-index: -1!important;
left: 0;
width: 150px;
height: 100%;
position: fixed;
}
.right{
z-index: -1!important;
top: 0px;
right: 0;
/*width: 150px;*/
height: 100%;
position: fixed;
}
.layout-image{
height: 100%
}
.container{
z-index:2!important;
}
</style>
</head>
<body>
<div class="left"><img src="images/left.png" class="img-responsive layout-image" ></div>
<div class='container'>
<div class='row'>
<div class='col-sm col-lg mt-5 mb-5'>
<div class='text-center'>
<img src='images/me.svg' class='img-fluid' style='width: 200px'>
</div>
<div class='text-center' style='font-family:'CustomFont',SceneStd-Light; color: #969595;'>
UAE’s largest online plant store launching soon in
</div>
</div>
</div>
<div class='row pb-5'>
<div class='col-sm text-center'>
<img src='images/bahrain.svg' style='height: 150px'>
<div class='text-center pb-2 pt-2'><span>Bahrain</span></div>
</div>
<div class='col-sm text-center'>
<img src='images/saudi.svg' style='height: 150px'>
<div class='text-center pb-2 pt-2'><span>Bahrain</span></div>
</div>
<div class='col-sm text-center'>
<img src='images/kuwait.svg' style='height: 150px'>
<div class='text-center pb-2 pt-2'><span>Bahrain</span></div>
</div>
</div>
<div class='row'>
<div class='col-sm col-lg mt-5 mb-5'>
<div class='text-center'>
<a href='#'><img src='images/ae.svg' class='img-fluid' style='width: 200px'></a>
</div>
<div class='text-center'>
<a href='#'><img src='images/uae.svg' style='height: 150px'></a>
</div>
<div class='text-center pb-2 pt-2'><span>Visit our UAE store</span></div>
</div>
</div>
</div>
<div class='right'><a href="https://plantshop.ae/"> <img src="images/right.png" class="img-responsive layout-image" /></a></div>
</body>
</html>
``` |
55,371,468 | I am building a landing page with fixed left and right image and content in the middle. in desktop view its working fine but in mobile view the images overlapping the contents. how do I fix this?
```
<div class="container">
<div class="row">
<div class="col-sm col-lg mt-5 mb-5">
<div class="text-center">
<img src="images/me.svg" class="img-fluid" style="width: 200px">
</div>
<div class="text-center" style=" font-family: 'CustomFont',SceneStd-Light; color: #969595;">
UAE’s largest online plant store launching soon in
</div>
</div>
</div>
<div class="row pb-5">
<div class="col-sm text-center">
<img src="images/bahrain.svg" style="height: 150px">
<div class="text-center pb-2 pt-2"><span>Bahrain</span></div>
</div>
<div class="col-sm text-center">
<img src="images/saudi.svg" style="height: 150px">
<div class="text-center pb-2 pt-2"><span>Bahrain</span></div>
</div>
<div class="col-sm text-center">
<img src="images/kuwait.svg" style="height: 150px">
<div class="text-center pb-2 pt-2"><span>Bahrain</span></div>
</div>
</div>
<div class="row">
<div class="col-sm col-lg mt-5 mb-5">
<div class="text-center">
<a href="#"><img src="images/ae.svg" class="img-fluid" style="width: 200px"></a>
</div>
<div class="text-center">
<a href="#"><img src="images/uae.svg" style="height: 150px"></a>
</div>
<div class="text-center pb-2 pt-2"><span>Visit our UAE store</span></div>
</div>
</div>
</div>
<div class="right">
<a href="#"> <img src="images/right.png" class="img-responsive layout-image" ></a>
</div>
```
```
.left{
left: 0;
width: 150px;
height: 100%;
position: absolute;}
.right{
top: 0px;
right: 0;
/*width: 150px;*/
height: 100%;
position: absolute;}
.layout-image{height: 100%}
```
In Desktop view

In mobile view

How do I fix this in mobile and tablet view. | 2019/03/27 | [
"https://Stackoverflow.com/questions/55371468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10110626/"
]
| ```css
.dashed-box {
position: relative;
z-index: 1;
border: dashed;
height: 8em;
margin-bottom: 1em;
margin-top: 2em;
}
.gold-box {
position: absolute;
z-index: 3; /* put .gold-box above .green-box and .dashed-box */
background: gold;
width: 80%;
left: 60px;
top: 3em;
}
.green-box {
position: absolute;
z-index: 2; /* put .green-box above .dashed-box */
background: lightgreen;
width: 20%;
left: 65%;
top: -25px;
height: 7em;
opacity: 0.9;
}
```
```html
<!-- Learn about this code on MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/z-index -->
<div class="dashed-box">Dashed box
<span class="gold-box">Gold box</span>
<span class="green-box">Green box</span>
</div>
```
There are multiple ways to do this, are mentioned my @bpolar you can use the z-index. Another way of doing it is with media selectors which would allow you to have different css properties for different screen sizes
Example:
```
@media (min-width:1281) {
image {
width:200px;
}
}
@media (max-width:1280) {
image {
width:100px;
}
}
```
This code will display images in different sizes for different display-widths, you could see them as if-statements.
The benefit of this approach is that you have finer control over how it appears on different display configurations. That being said I think the best option is a combination of the two.
If you need more info about the z-index that can be found [here](https://developer.mozilla.org/en-US/docs/Web/CSS/z-index)
I hope this is what you're looking for.
Good luck. | try to increase the z-index like z-index:9999 of behrain image and leaf z-index to 9 in mobile view. |
27,636,547 | I'm making a math library because 0.1 + 0.2 DOES NOT = 0.30000000000004. But I ran into a really weird problem
I have an array:
```
var array = [1,2,3,".",4,5,6];
```
I want to split it into two parts so I...
```
var part1 = array;
var part2 = array;
```
And then...
```
for (var i = 4; i < 7; i++) {
part1[i] = 0;
};
```
So now part1 =
```
[1,2,3,".",0,0,0]
```
As it should but then I arrive at this problem. After I...
```
for (i = 2; i > -1; i--) {
part2[i] = 0;
};
```
Part1, part2 and array now =
```
[0,0,0,".",0,0,0]
```
This shouldn't happen, part2 should =
```
[0,0,0,".",4,5,6]
```
But it doesn't
??? | 2014/12/24 | [
"https://Stackoverflow.com/questions/27636547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4093378/"
]
| This happens because both `part1` and `part2` (and obviously `array` too) variables are pointing to the same memory address, which stores the same information, therefore if you edit any of the three arrays the changes will be visible in all of them, because you're modifying the same value represented by three different variables.
To avoid this you should "copy" the array using `slice()` or something else, like a for loop, but `slice` is my favourite method, and also the fastest to type, so your code will become:
```
var part1 = array.slice();
var part2 = array.slice();
```
Now you can do whatever you want and the arrays will be treated as different variables.
Quick example:
```
a = [1,2]
> [1, 2]
b = a.slice()
> [1, 2]
b[0] = 2
2
b
> [2, 2]
a
> [1, 2]
```
**Fastest method to copy an array:**
If you're looking for the fastet method (since that there are several different methods to copy an array) then you should check **[this benchmark test](http://jsperf.com/new-array-vs-splice-vs-slice/63)**, and run a test. The best solution isn't always the same one, so in the future it may change, depending on the JS implementation and your current browser version, although `slice()`, `slice(0)` and `concat()` are usually way faster than other methods. | You have to copy the array:
```
var part1 = array.concat();// it is possible to use array.slice() too.
var part2 = array.concat();
```
If not, you are always modifying the same object, since part1 and part2 will have a reference to the array variable.
On the other hand, I would not recomend you to build your own math library just to resolve floating point issues in JS. [Have you read similar questions?](https://stackoverflow.com/questions/588004/is-floating-point-math-broken) |
27,636,547 | I'm making a math library because 0.1 + 0.2 DOES NOT = 0.30000000000004. But I ran into a really weird problem
I have an array:
```
var array = [1,2,3,".",4,5,6];
```
I want to split it into two parts so I...
```
var part1 = array;
var part2 = array;
```
And then...
```
for (var i = 4; i < 7; i++) {
part1[i] = 0;
};
```
So now part1 =
```
[1,2,3,".",0,0,0]
```
As it should but then I arrive at this problem. After I...
```
for (i = 2; i > -1; i--) {
part2[i] = 0;
};
```
Part1, part2 and array now =
```
[0,0,0,".",0,0,0]
```
This shouldn't happen, part2 should =
```
[0,0,0,".",4,5,6]
```
But it doesn't
??? | 2014/12/24 | [
"https://Stackoverflow.com/questions/27636547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4093378/"
]
| You have to copy the array:
```
var part1 = array.concat();// it is possible to use array.slice() too.
var part2 = array.concat();
```
If not, you are always modifying the same object, since part1 and part2 will have a reference to the array variable.
On the other hand, I would not recomend you to build your own math library just to resolve floating point issues in JS. [Have you read similar questions?](https://stackoverflow.com/questions/588004/is-floating-point-math-broken) | What is going wrong in your code is that you don't create a clone of the array: `array`, `part1`, and `part2` all point to the very same array. You can create a copy like `part1 = array.slice(0)`.
Instead of writing your own math library to solve floating point round-off errors, you can use for example BigNumbers in [math.js](http://mathjs.org):
```
// configure math.js to use BigNumbers by default
math.config({
number: 'bignumber', // Default type of number: 'number' (default) or 'bignumber'
precision: 64 // Number of significant digits for BigNumbers
});
// evaluate an expression
math.eval('0.1 + 0.2'); // BigNumber, 0.3
```
See docs on BigNumbers: <http://mathjs.org/docs/datatypes/bignumbers.html> |
27,636,547 | I'm making a math library because 0.1 + 0.2 DOES NOT = 0.30000000000004. But I ran into a really weird problem
I have an array:
```
var array = [1,2,3,".",4,5,6];
```
I want to split it into two parts so I...
```
var part1 = array;
var part2 = array;
```
And then...
```
for (var i = 4; i < 7; i++) {
part1[i] = 0;
};
```
So now part1 =
```
[1,2,3,".",0,0,0]
```
As it should but then I arrive at this problem. After I...
```
for (i = 2; i > -1; i--) {
part2[i] = 0;
};
```
Part1, part2 and array now =
```
[0,0,0,".",0,0,0]
```
This shouldn't happen, part2 should =
```
[0,0,0,".",4,5,6]
```
But it doesn't
??? | 2014/12/24 | [
"https://Stackoverflow.com/questions/27636547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4093378/"
]
| This happens because both `part1` and `part2` (and obviously `array` too) variables are pointing to the same memory address, which stores the same information, therefore if you edit any of the three arrays the changes will be visible in all of them, because you're modifying the same value represented by three different variables.
To avoid this you should "copy" the array using `slice()` or something else, like a for loop, but `slice` is my favourite method, and also the fastest to type, so your code will become:
```
var part1 = array.slice();
var part2 = array.slice();
```
Now you can do whatever you want and the arrays will be treated as different variables.
Quick example:
```
a = [1,2]
> [1, 2]
b = a.slice()
> [1, 2]
b[0] = 2
2
b
> [2, 2]
a
> [1, 2]
```
**Fastest method to copy an array:**
If you're looking for the fastet method (since that there are several different methods to copy an array) then you should check **[this benchmark test](http://jsperf.com/new-array-vs-splice-vs-slice/63)**, and run a test. The best solution isn't always the same one, so in the future it may change, depending on the JS implementation and your current browser version, although `slice()`, `slice(0)` and `concat()` are usually way faster than other methods. | What is going wrong in your code is that you don't create a clone of the array: `array`, `part1`, and `part2` all point to the very same array. You can create a copy like `part1 = array.slice(0)`.
Instead of writing your own math library to solve floating point round-off errors, you can use for example BigNumbers in [math.js](http://mathjs.org):
```
// configure math.js to use BigNumbers by default
math.config({
number: 'bignumber', // Default type of number: 'number' (default) or 'bignumber'
precision: 64 // Number of significant digits for BigNumbers
});
// evaluate an expression
math.eval('0.1 + 0.2'); // BigNumber, 0.3
```
See docs on BigNumbers: <http://mathjs.org/docs/datatypes/bignumbers.html> |
58,292,264 | I'm uploading multiple files with form field
```
<input type="file" accept="image/jpeg, image/png" multiple
```
a loop sends all files to upload function
```
// Upload photo function
var upload = function (photo, callback) {
var formData = new FormData();
formData.append('photo', photo);
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (request.readyState === 4) {
callback(request.response);
}
}
request.open('POST', 'upload.php');
request.responseType = 'json';
request.send(formData);
};
for (var i = 0; i < files.length; i++) {
upload(resizedFile, function (response) { });
}
```
if all files are successfully uploaded, want to redirect ..
```
//all files finished, go to ...
if(response !== null && typeof response !== 'object') var response = JSON.parse(response);
window.location.href = "my-new-url.php?id="+response.id;
```
my problem, the redirect is done before all uploads are finished. how can I make the script wait for all xmlhttprequests to finish?
---
EDIT
----
I changed the upload function like this, to upload with jQuery. The fuction is called several times from the for loop, so how can I wait for all loops/jquery calls are finished, then redirect?
```
function upload (photo, callback) {
var fd = new FormData();
fd.append('photo',photo);
return $.ajax({
url: 'upload.php',
type: 'post',
data: fd,
contentType: false,
processData: false,
success: function(response){
},
});
};
``` | 2019/10/08 | [
"https://Stackoverflow.com/questions/58292264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10815299/"
]
| You can modify your Action method like
```
[HttpPost]
public ActionResult CalculatePurePrice([FromBody]string TotalPrice)
{
return Json(TotalPrice, JsonRequestBehavior.AllowGet);
}
``` | For your issue, it is caused by `dataType: 'json'` which is telling jQuery what kind of response to expect. For plain test without `""`, it will fail to convert to json. If you enter `"test"` in the input, it will work, but if you enter `test` directly, it will fail since there is no extra `""`.
For a workaround, you could remove `dataType: 'json'` like
```
$.ajax({
url: '/api/movie/CalculatePurePrice',
type: 'POST',
data: JSON.stringify(requestData),
//dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function (response) {
$('#test1').text(response);
},
error: function (response) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
``` |
58,292,264 | I'm uploading multiple files with form field
```
<input type="file" accept="image/jpeg, image/png" multiple
```
a loop sends all files to upload function
```
// Upload photo function
var upload = function (photo, callback) {
var formData = new FormData();
formData.append('photo', photo);
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (request.readyState === 4) {
callback(request.response);
}
}
request.open('POST', 'upload.php');
request.responseType = 'json';
request.send(formData);
};
for (var i = 0; i < files.length; i++) {
upload(resizedFile, function (response) { });
}
```
if all files are successfully uploaded, want to redirect ..
```
//all files finished, go to ...
if(response !== null && typeof response !== 'object') var response = JSON.parse(response);
window.location.href = "my-new-url.php?id="+response.id;
```
my problem, the redirect is done before all uploads are finished. how can I make the script wait for all xmlhttprequests to finish?
---
EDIT
----
I changed the upload function like this, to upload with jQuery. The fuction is called several times from the for loop, so how can I wait for all loops/jquery calls are finished, then redirect?
```
function upload (photo, callback) {
var fd = new FormData();
fd.append('photo',photo);
return $.ajax({
url: 'upload.php',
type: 'post',
data: fd,
contentType: false,
processData: false,
success: function(response){
},
});
};
``` | 2019/10/08 | [
"https://Stackoverflow.com/questions/58292264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10815299/"
]
| You need to add `Accept` header in your ajax request. Then your backend will give proper json or it will return plain text.
$('.calculateField').on('input', function (e) {
```
var requestData = $('.calculateField').val();
$.ajax({
url: '/InsurancePolicyContract/CalculatePurePrice',
type: 'POST',
data: JSON.stringify(requestData),
headers: {
"Accept": "application/json"
},
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function (response) {
$('#test1').text(response);
},
error: function (response) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
```
}); | For your issue, it is caused by `dataType: 'json'` which is telling jQuery what kind of response to expect. For plain test without `""`, it will fail to convert to json. If you enter `"test"` in the input, it will work, but if you enter `test` directly, it will fail since there is no extra `""`.
For a workaround, you could remove `dataType: 'json'` like
```
$.ajax({
url: '/api/movie/CalculatePurePrice',
type: 'POST',
data: JSON.stringify(requestData),
//dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function (response) {
$('#test1').text(response);
},
error: function (response) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
``` |
15,220,585 | I have fields that different people should see in different names.
For example, suppose I have the following user types:
```
public enum UserType {Expert, Normal, Guest}
```
I implemented an `IMetadataAware` attribute:
```
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class DisplayForUserTypeAttribute : Attribute, IMetadataAware
{
private readonly UserType _userType;
public DisplayForUserTypeAttribute(UserType userType)
{
_userType = userType;
}
public string Name { get; set; }
public void OnMetadataCreated(ModelMetadata metadata)
{
if (CurrentContext.UserType != _userType)
return;
metadata.DisplayName = Name;
}
}
```
The idea is that I can override other values as needed, but fall back on default values when I don't. For example:
```
public class Model
{
[Display(Name = "Age")]
[DisplayForUserType(UserType.Guest, Name = "Age (in years, round down)")]
public string Age { get; set; }
[Display(Name = "Address")]
[DisplayForUserType(UserType.Expert, Name = "ADR")]
[DisplayForUserType(UserType.Normal, Name = "The Address")]
[DisplayForUserType(UserType.Guest, Name = "This is an Address")]
public string Address { get; set; }
}
```
The problem is that when I have multiple attributes of the same type, `DataAnnotationsModelMetadataProvider` only runs `OnMetadataCreated` for the first one.
In the example above, `Address` can only be shown as "Address" or "ADR" - the other attributes are never executed.
If I try to use different attributes - `DisplayForUserType`, `DisplayForUserType2`, `DisplayForUserType3`, everything is working as expected.
Am I doing anything wrong here? | 2013/03/05 | [
"https://Stackoverflow.com/questions/15220585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7586/"
]
| I know I am bit late to this party but I was looking to the answer to same question and couldn't find it anywhere on the web. In the end I worked it out myself.
The short answer is yes you can have multiple attributes of the same type that implement IMetadataAware interface on the same field / property. You just have to remember to override the TypeId of the Attribute class when extending it and replace it with something that will give you a unique object per **instance** of each derived attribute.
If you don't override the TypeId property of derived attribute then all the attributes of that type are treated the same since the default implementation returns the run time type of the attribute as the id.
So the following should now work as desired:
```
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class DisplayForUserTypeAttribute : Attribute, IMetadataAware
{
private readonly UserType _userType;
public DisplayForUserType(UserType userType)
{
_userType = userType;
}
public override object TypeId
{
get
{
return this;
}
}
public string Name { get; set; }
public void OnMetadataCreated(ModelMetadata metadata)
{
if (CurrentContext.UserType != _userType)
return;
metadata.DisplayName = Name;
}
}
``` | You implementation is not wrong, but any attribute that implements `IMetadataAware` is applied by the [AssociatedMetadataProvider](http://msdn.microsoft.com/en-us/library/system.web.mvc.associatedmetadataprovider%28v=vs.98%29.aspx) (and any derived type) after the Metadata creation.
To override the default behavior, you may implement custom `ModelMetadataProvider`.
Here is another alternate quick solution:
Remove the interface `IMetadataAware` from the `DisplayForUserType` class.
```
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class DisplayForUserTypeAttribute : Attribute//, IMetadataAware
{
//your existing code...
}
```
Define a new `IMetadataAware` attribute that will apply the display logic by UserType, as below:
```
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class ApplyDisplayForUserTypeAttribute : Attribute, IMetadataAware
{
private readonly string _property;
public ApplyDisplayForUserTypeAttribute(string property)
{
this._property = property;
}
public void OnMetadataCreated(ModelMetadata metadata)
{
var attribues = GetCustomAttributes(metadata.ContainerType
.GetProperty(this._property), typeof(DisplayForUserTypeAttribute))
.OfType<DisplayForUserTypeAttribute>().ToArray();
foreach (var displayForUserTypeAttribute in attribues)
{
displayForUserTypeAttribute.OnMetadataCreated(metadata);
}
}
}
```
And model will be:
```
public class Model
{
[Display(Name = "Age")]
[DisplayForUserType(UserType.Guest, Name = "Age (in years, round down)")]
[ApplyDisplayForUserType("Age")]
public string Age { get; set; }
[Display(Name = "Address")]
[DisplayForUserType(UserType.Expert, Name = "ADR Expert")]
[DisplayForUserType(UserType.Normal, Name = "The Address Normal")]
[DisplayForUserType(UserType.Guest, Name = "This is an Address (Guest)")]
[ApplyDisplayForUserType("Address")]
public string Address { get; set; }
}
``` |
15,012,057 | I am just coding a small website with an admin panel.
Since I am going to be the only one who will access that panel I was thinking instead of making traditional username - password matching just make simple .htaccess file to admin folder as
```
<Limit GET POST>
order deny,allow
deny from all
allow from myip
allow from 127.0.01
</Limit>
```
So the question is since my ip is static.
This kind of protection will be secure or do I have to do it with username - password matching ?
Also if the idea is logical but .htaccess needs more additions what would they be ? | 2013/02/21 | [
"https://Stackoverflow.com/questions/15012057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1408868/"
]
| Restricting by IP is a perfectly valid alternative to protecting with a password, but less flexible for access.
If you use SSL then you could implement [SSLRequire](http://httpd.apache.org/docs/2.2/mod/mod_ssl.html#sslrequire) to make things more flexible whilst still "password-less" (note issue with threaded MPM).
However, for the small amount of effort that it would take to implement password protection using [HTTP authentication](http://httpd.apache.org/docs/2.2/howto/auth.html) I would argue that you should be as secure as possible. Even if it is a personal website, it can still be hijacked and used to send SPAM, etc. | Syntax is like this:
```
<Limit GET POST>
order deny,allow
deny from all
allow from 1.2.3.4
allow from 127.0.01
</Limit>
```
It should be secure but keep in mind that if some one from the same server tries to access you web pages then with 127.0.0.1 IP it is no longer protects your pages. |
15,012,057 | I am just coding a small website with an admin panel.
Since I am going to be the only one who will access that panel I was thinking instead of making traditional username - password matching just make simple .htaccess file to admin folder as
```
<Limit GET POST>
order deny,allow
deny from all
allow from myip
allow from 127.0.01
</Limit>
```
So the question is since my ip is static.
This kind of protection will be secure or do I have to do it with username - password matching ?
Also if the idea is logical but .htaccess needs more additions what would they be ? | 2013/02/21 | [
"https://Stackoverflow.com/questions/15012057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1408868/"
]
| Restricting by IP is a perfectly valid alternative to protecting with a password, but less flexible for access.
If you use SSL then you could implement [SSLRequire](http://httpd.apache.org/docs/2.2/mod/mod_ssl.html#sslrequire) to make things more flexible whilst still "password-less" (note issue with threaded MPM).
However, for the small amount of effort that it would take to implement password protection using [HTTP authentication](http://httpd.apache.org/docs/2.2/howto/auth.html) I would argue that you should be as secure as possible. Even if it is a personal website, it can still be hijacked and used to send SPAM, etc. | What about order?
```
order deny,allow
deny from all
allow from 127.0.0.1
``` |
35,765 | I have started to develop a simple 3D engine. I use OpenGL for rendering, and it is developed for Windows. It is all written in C.
How do I write an interface for the keyboard and mouse input? I would like to keep it as simple as possible - in contrast to the native Win32 input system. | 2012/09/09 | [
"https://gamedev.stackexchange.com/questions/35765",
"https://gamedev.stackexchange.com",
"https://gamedev.stackexchange.com/users/19693/"
]
| There is more than one one way to skin the cat. If I understand correctly, you want to be able to take input from keyboard and mouse and use that to control stuff in your engine. But to write such interface from scratch, by yourself, would not only be a classic case of reinventing the wheel, but also, a very tedious task (think about it... you want to be able to support PS/2 and USB mice, as well as keyboards and you must admit, testing whether there's something present in a particular port, polling through USB hubs and ports... it's too much hassle when there's already available software to do that for you, right?)
So you will save much time using an already developed interface/framework of that kind. Such a component is a part of already mentioned FreeGLUT, but there is also SDL, which handles not only that, but also window manipulation, threading and more. [Check it out](http://wiki.libsdl.org/moin.cgi/APIByCategory#Input_Events). Pay attention to [SDL\_event](http://wiki.libsdl.org/moin.cgi/SDL_Event?highlight=%28%5CbCategoryStruct%5Cb%29%7C%28CategoryEvents%29%7C%28SGStructures%29) struct and [SDL\_PollEvent](http://wiki.libsdl.org/moin.cgi/SDL_PollEvent?highlight=%28%5CbCategoryEvents%5Cb%29%7C%28SGFunctions%29%7C%28CategoryStruct%29%7C%28CategoryEnum%29) function. | There are frameworks like [FreeGLUT](http://freeglut.sourceforge.net/) that give a basic input/output abilities with keyboard and mouse, but if you want more there are the [Visual C++ APIs](http://msdn.microsoft.com/en-us/library/windows/desktop/ms645530%28v=vs.85%29.aspx) for Windows. |
5,108,069 | How do i use the flash context in spring without having to install webflow? | 2011/02/24 | [
"https://Stackoverflow.com/questions/5108069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26188/"
]
| In [mvc-showcase](https://anonsvn.springframework.org/svn/spring-samples/mvc-showcase/) example you can find special filter which emulates flash scope behaviour, so probably you can use it right now and don't waiting 3.1 with official support.
See for details: [web.xml](https://anonsvn.springframework.org/svn/spring-samples/mvc-showcase/src/main/webapp/WEB-INF/web.xml), [FlashMapFilter](https://anonsvn.springframework.org/svn/spring-samples/mvc-showcase/src/main/java/org/springframework/samples/mvc/flash/FlashMapFilter.java), [FlashMap](https://anonsvn.springframework.org/svn/spring-samples/mvc-showcase/src/main/java/org/springframework/samples/mvc/flash/FlashMap.java)
(I know that mvc-showcase is for Spring 3.0 and you asked about 2.5, but when I look into FlashMapFilter source I see than there no 3.0 specific things.)
HTH | `@SessionAttributes` can be used like a flash context, since you can clear them using `SessionStatus` |
146,223 | At the first I should add that different cultures have different attitudes and believes, so with that in mind I would like to ask my question that may seem weird to almost all European, American, Australian countries. :)
As women colleagues shake hands with men in company, how should I prevent shaking hands (maybe by saying a proper sentence too) with women colleagues?
I certainly know that first day impression is so much important, so I don't want to miss that opportunity!
Do you have any idea about this? Do you have similar colleagues at work that not shake hands with women? How do they behave? What is the best way to say hello with all respect? | 2019/10/09 | [
"https://workplace.stackexchange.com/questions/146223",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/97397/"
]
| If you are based in any of the countries you mentioned in your question the only way you can avoid shaking hands with women is to avoid shaking hands with everyone regardless of gender.
Treating people differently based on gender is discrimination and whilst small hand shaking could be perceived this way. I’m not sure how your culture handles trans or any of the other non binary definitions but that could also be a factor to consider.
In short, I’d consider either shaking everyone’s hand or no ones hand. | At work, in many cultures including the regions you mentioned in your question, you should treat men and women the same. Specifically, if you don't shake hands with women, do not shake hands with men, but it extends to all interactions.
Pick some non-contact greeting gesture. One person I know who does not shake hands puts her palms together, fingers up, and gives something between a nod and a slight bow. Practice the gesture, and start using it outside work, before your first day on the job, so you are used to it. Use the gesture you choose for everyone. |
146,223 | At the first I should add that different cultures have different attitudes and believes, so with that in mind I would like to ask my question that may seem weird to almost all European, American, Australian countries. :)
As women colleagues shake hands with men in company, how should I prevent shaking hands (maybe by saying a proper sentence too) with women colleagues?
I certainly know that first day impression is so much important, so I don't want to miss that opportunity!
Do you have any idea about this? Do you have similar colleagues at work that not shake hands with women? How do they behave? What is the best way to say hello with all respect? | 2019/10/09 | [
"https://workplace.stackexchange.com/questions/146223",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/97397/"
]
| If you are based in any of the countries you mentioned in your question the only way you can avoid shaking hands with women is to avoid shaking hands with everyone regardless of gender.
Treating people differently based on gender is discrimination and whilst small hand shaking could be perceived this way. I’m not sure how your culture handles trans or any of the other non binary definitions but that could also be a factor to consider.
In short, I’d consider either shaking everyone’s hand or no ones hand. | >
> What is the best way to say hello with all respect?
>
>
>
Bow, it's a respectful greeting, better than nothing.
Refusing to shake hands with women would be found distasteful to any in the Western World, so don't expect it to go unnoticed, however bowing is acceptable. When I say bow I mean whatever goes in the locale. Tipping your hat in some places, anything from a nod to a bow in others. |
146,223 | At the first I should add that different cultures have different attitudes and believes, so with that in mind I would like to ask my question that may seem weird to almost all European, American, Australian countries. :)
As women colleagues shake hands with men in company, how should I prevent shaking hands (maybe by saying a proper sentence too) with women colleagues?
I certainly know that first day impression is so much important, so I don't want to miss that opportunity!
Do you have any idea about this? Do you have similar colleagues at work that not shake hands with women? How do they behave? What is the best way to say hello with all respect? | 2019/10/09 | [
"https://workplace.stackexchange.com/questions/146223",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/97397/"
]
| At work, in many cultures including the regions you mentioned in your question, you should treat men and women the same. Specifically, if you don't shake hands with women, do not shake hands with men, but it extends to all interactions.
Pick some non-contact greeting gesture. One person I know who does not shake hands puts her palms together, fingers up, and gives something between a nod and a slight bow. Practice the gesture, and start using it outside work, before your first day on the job, so you are used to it. Use the gesture you choose for everyone. | >
> What is the best way to say hello with all respect?
>
>
>
Bow, it's a respectful greeting, better than nothing.
Refusing to shake hands with women would be found distasteful to any in the Western World, so don't expect it to go unnoticed, however bowing is acceptable. When I say bow I mean whatever goes in the locale. Tipping your hat in some places, anything from a nod to a bow in others. |
27,314 | Background: I have a whole mess of systems running the 2.6.20 and 2.6.22 kernel in what started as a Fedora Core 2 install several years ago. These systems have 8 cpus, as reported by `cat /proc/cpuinfo`.
My question is, when a process is running that uses multi-threading, does 99.99% CPU usage as reported by `top` mean 99.99% of every CPU or 99.99% total if you add the usage on each CPU together? In other words, should the maximum percentage be 800% or 100%?
It seems that when one of these processes is at 99.99%, if you look at each cpu individually, they will say 25% utilization (instead of 100%).
Any help is appreciated. If I was unclear or confusing, let me know and I will try to clarify.
**UPDATE**
It seems as though we may have been seeing the low utilization because of a problem with the threading model used by the programmers. They're using user threads as opposed to kernel threads and are seeing limitations in what user threads are allowed to do. | 2009/06/17 | [
"https://serverfault.com/questions/27314",
"https://serverfault.com",
"https://serverfault.com/users/769/"
]
| 99% cpu usage means almost total utilization of single core.
if your system is totally loaded [ couple threads each hogging one cpu ] - you'll see 400% usage on quad core or 800% usage on two quad cores.
processes/threads are re-assigned between cpus - that's why you see 25% of utilisation on each of cores. but you can [set affinity](http://www.cyberciti.biz/tips/setting-processor-affinity-certain-task-or-process.html) for them.. then they'll stick to selected processors/cores. | It shows load per core. Don't forget about a great "top" replacement called htop. It will draw you load of individual cpus/cores. |
42,933,170 | I have created a jQuery change event handler which works ok on a normal drop down (choice) field, but as soon as I change that filed property to "Require that this column contains information" = Yes then the event handler will no longer trigger. Any idea how to overcome this?
This is the original code. Could you recommend how to fix it?
```
$("select[title='Unit']").change(function() {
var UnitField = SPUtility.GetSPField('Unit').GetValue();
if ( ITCUnitField.indexOf("Unit 1") >= 0)
{
alert("Are you sure you belong to Unit 1");
}
});
``` | 2017/03/21 | [
"https://Stackoverflow.com/questions/42933170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7746884/"
]
| Original Answer
---------------
The version 4 of the React Router has **a lot of breaking changes**. You can't use nested routes this way anymore. Check out this example of nested routes using the new version of the React Router.
```
const Header = () => (
<nav>
<ul>
<li>Home</li>
<li>About</li>
</ul>
</nav>
)
const Footer = () => (
<footer>
Copyrights
</footer>
)
const Layout = props => (
<div className="layout">
<div className="layout__container">
<Header />{ props.children }
<Footer />
</div>
</div>
)
const Home = () => <Layout>This is the home page.</Layout>
const About = () => <Layout>This is the about page.</Layout>
<Router>
<div>
<Route path="/" component={Home} />
<Route path="/about" component={About} />
</div>
</Router>
```
Hope it helps.
Updated Answer (November, 16th)
-------------------------------
This is what I'm doing actually.
```
import { BrowserRouter, Route, Switch } from 'react-router-dom'
import React from 'react'
import About from './components/views/About'
import Home from './components/views/Home'
import Layout from './components/views/Layout'
const Routes = () => (
<BrowserRouter>
<Layout>
<Switch>
<Route exact path='/' component={Home} />
<Route exact path='/about' component={About} />
</Switch>
</Layout>
</BrowserRouter>
)
export default Routes
``` | I think you are misunderstanding the way React-router works.
Nested routes are rendered "Nested", that means that parent routes will renders itself and then all childs, usually used for common routes.
Here you have a working example I am using right now:
```js
<Router history={browserHistory}>
<Route path='/' component={Root}>
<Route path='/examples/react-redux-websocket' component={App} />
<Route path='/examples/react-redux-websocket/chat/:chatid/participant/:participantid' component={Chat} />
<Route path='/examples/react-redux-websocket/chat/:chatid' component={Chat} />
<Route path='/*' component={NoMatch} />
</Route>
</Router>
class Root extends Component {
render () {
return (
<div>
{this.props.children}
<Footer />
</div>
)
}
}
```
As you can see, Root route render a common Footer and then all nested childs. All routes inside the Root one will render the same footer as well.
I think what you need is something like that:
```js
<Router>
<Route path='/' component={App} />
<Route path='/active-items' component={ActiveItems} />
</Router>
```
Check out www.facundolarocca.com to see it working, you will find the repo too.
Let me know if it works. |
67,260,615 | I've run into a problem with trying to isolate a Country name in a Column.
The country name contains the name of the country followed by its coordinates
like this :
```
1
CBD, Sydney.mw-parser-output .geo-default,.mw-parser-output .geo-dms,.mw-parser-output .geo-dec{display:inline}.mw-parser-output .geo-nondefault,.mw-parser-output .geo-multi-punct{display:none}.mw-parser-output .longitude,.mw-parser-output .latitude{white-space:nowrap}30°50′30″N 29°39′50″E / 30.84167°N 29.66389°E / 30.84167; 29.66389 (Abu Mena)
```
I would like to remove everything but the Country part but I don't know how.
I only have the base R package, Dyplr, Rvest, Regex and Textreadr at my disposal.
I'd like to use Regex for it as I have very little experience with it and would like to learn how
Thanks! | 2021/04/26 | [
"https://Stackoverflow.com/questions/67260615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15413212/"
]
| A few more examples to generalize the regex pattern would be helpful. This works for one example that you have shared.
```
x <- "Sydney, Australia, 65(degrees),20',30'N,78(degrees),45',87\"E"
sub('.*?, (.*?), \\d+\\(degrees\\).*', '\\1', x)
#[1] "Australia"
```
Or maybe even just to get text after first comma.
```
sub('.*?, (.*?),.*', '\\1', x)
#[1] "Australia"
```
---
For the updated example this seems to work :
```
sub('.*?,\\s+(.*?)(\\d+|\\.).*', '\\1', df$country)
#[1] "Egypt" "Niger" "Syria" "Syria" "Syria" "Venezuela" "Peru"
```
**data**
It is easier to help if you share data in a reproducible way (like below using `dput`) which is easier to copy.
```
df <- structure(list(country = c("EgyAbusir, Egypt.mw-parser-output .geo-default,.mw-parser-output .geo-dms,.mw-parser-output .geo-dec{display:inline}.mw-parser-output .geo-nondefault,.mw-parser-output .geo-multi-punct{display:none}.mw-parser-output .longitude,.mw-parser-output .latitude{white-space:nowrap}30°50′30″N 29°39′50″E / 30.84167°N 29.66389°E / 30.84167; 29.66389 (Abu Mena)",
"Niger1Arlit Department, Niger18°17′N 8°0′E / 18.283°N 8.000°E / 18.283; 8.000 (Air and Ténéré Natural Reserves)",
"Aleppo Governorate, Syria36°14′N 37°10′E / 36.233°N 37.167°E / 36.233; 37.167 (Ancient City of Aleppo)",
"Daraa Governorate, Syria32°31′5″N 36°28′54″E / 32.51806°N 36.48167°E / 32.51806; 36.48167 (Ancient City of Bosra)",
"Damascus Governorate, Syria33°30′41″N 36°18′23″E / 33.51139°N 36.30639°E / 33.51139; 36.30639 (Ancient City of Damascus)",
"VenFalcón, Venezuela11°25′N 69°40′W / 11.417°N 69.667°W / 11.417; -69.667 (Coro and its Port)",
"PerLa Libertad, Peru8°6′40″S 79°4′30″W / 8.11111°S 79.07500°W / -8.11111; -79.07500 (Chan Chan Archaeological Zone)"
)), class = "data.frame", row.names = c(NA, -7L))
``` | If the country is always after the first comma, this works:
```
library(stringr)
str_extract(df$country, "(?<=,\\s{1,10})[A-Za-z]+(?=[^A-Za-z])")
[1] "Egypt" "Niger" "Syria" "Syria" "Syria" "Venezuela" "Peru"
```
@Ronak's data:
```
df <- structure(list(country = c("EgyAbusir, Egypt.mw-parser-output .geo-default,.mw-parser-output .geo-dms,.mw-parser-output .geo-dec{display:inline}.mw-parser-output .geo-nondefault,.mw-parser-output .geo-multi-punct{display:none}.mw-parser-output .longitude,.mw-parser-output .latitude{white-space:nowrap}30°50′30″N 29°39′50″E / 30.84167°N 29.66389°E / 30.84167; 29.66389 (Abu Mena)",
"Niger1Arlit Department, Niger18°17′N 8°0′E / 18.283°N 8.000°E / 18.283; 8.000 (Air and Ténéré Natural Reserves)",
"Aleppo Governorate, Syria36°14′N 37°10′E / 36.233°N 37.167°E / 36.233; 37.167 (Ancient City of Aleppo)",
"Daraa Governorate, Syria32°31′5″N 36°28′54″E / 32.51806°N 36.48167°E / 32.51806; 36.48167 (Ancient City of Bosra)",
"Damascus Governorate, Syria33°30′41″N 36°18′23″E / 33.51139°N 36.30639°E / 33.51139; 36.30639 (Ancient City of Damascus)",
"VenFalcón, Venezuela11°25′N 69°40′W / 11.417°N 69.667°W / 11.417; -69.667 (Coro and its Port)",
"PerLa Libertad, Peru8°6′40″S 79°4′30″W / 8.11111°S 79.07500°W / -8.11111; -79.07500 (Chan Chan Archaeological Zone)"
)), class = "data.frame", row.names = c(NA, -7L))
``` |
47,851,421 | I am trying to build my first project using an existing sqlite database in Android Studio. All of the instructions I have referenced say to create an assets folder and copy the database into that folder. A call from the database helper will move the file for me for run time testing. The problem is that when the database is in the assets folder and I click on the plus sign next to the folder, Android studio immediately halts, closing all windows and displays no error. I am running studio 3.01 build #AI-171.4443003 dated 11/9/2017. I have applied all updates and the results are the same. I have tried using different extension for the DB with no luck. | 2017/12/17 | [
"https://Stackoverflow.com/questions/47851421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9108569/"
]
| Because `spam` isn't a function, it's the result of calling the function `print` with the argument `'Hello!'`, which is `None`, of type `NoneType`.
If you want to assign that expression to a variable, then you can use a lambda:
```
l = lambda: print('Hello!') # Doesn't actually call print
l() # 1. Prints 'Hello!'
l() # 2. Prints 'Hello!'
l() # 3. Prints 'Hello!'
``` | ```
spam = print('Hello!')
```
evaluates the expression on the right hand side and binds its value to `spam`. The return value of the (Python 3) `print()` function is `None`, so `spam` refers to `None`:
```
>>> spam = print('Hello!')
Hello!
>>> spam is None
True
```
One way to handle this is to create a partial function with `functools.partial()`:
```
>>> from functools import partial
>>> spam = partial(print, 'Hello!')
>>> spam
functools.partial(<built-in function print>, 'Hello!')
>>> spam()
Hello!
```
Or a `lambda` expression:
```
>>> spam = lambda : print('Hello!')
>>> spam
<function <lambda> at 0x7f619cabf9d8>
>>> spam()
Hello!
```
Essentially both of the above use a closure around a function like this:
```
def printer(s):
def f():
print(s)
return f
>>> spam = printer('Hello!')
>>> spam
<function printer.<locals>.f at 0x7f619cabfb70>
>>> spam()
Hello!
``` |
47,851,421 | I am trying to build my first project using an existing sqlite database in Android Studio. All of the instructions I have referenced say to create an assets folder and copy the database into that folder. A call from the database helper will move the file for me for run time testing. The problem is that when the database is in the assets folder and I click on the plus sign next to the folder, Android studio immediately halts, closing all windows and displays no error. I am running studio 3.01 build #AI-171.4443003 dated 11/9/2017. I have applied all updates and the results are the same. I have tried using different extension for the DB with no luck. | 2017/12/17 | [
"https://Stackoverflow.com/questions/47851421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9108569/"
]
| Because `spam` isn't a function, it's the result of calling the function `print` with the argument `'Hello!'`, which is `None`, of type `NoneType`.
If you want to assign that expression to a variable, then you can use a lambda:
```
l = lambda: print('Hello!') # Doesn't actually call print
l() # 1. Prints 'Hello!'
l() # 2. Prints 'Hello!'
l() # 3. Prints 'Hello!'
``` | A function, depending on how that function is written, may or may not have an explicit return value. It's up to the author of the function to decide how he wants to implement his function. A function with an explicit return value must have a `return` statement in it. The `return` statement causes the function to end and for the value following the `return` statement to be "returned" to the calling code. When a function reaches the end of its code without an actual `return` statement, it's like there's an implicit `return None` at the end. So...
```
def is_5(num):
if num is 5:
return True
```
What happens above? If num is 5, the function returns the boolean value of True. But if num is not 5, there is no final `return` statement, so the implicit `None` is returned.
As to your question, there is also a difference between the "name" of a function and invoking the function. In our example above, the "name" of the function is `is_5`, and we invoke it by following the name of the function with parentheses. If there are no parentheses following the function name, then the function name is just like any other variable, only it happens to hold a reference to a function. When you follow it with parentheses, that causes the function to be invoked. This is why we can call
```
is_5(2+3)
```
but we can also say:
```
myfunc = is_5
myfunc(2+3)
```
and get the same exact result. As for `lambda` and `functools.partial`, both are used to create what are known as "nameless" functions -- they return a reference to a function, but that function has no name. You can capture the return from either of those and store it in a variable. Then, you can invoke the function by following the name of the variable with parentheses, just like above. Keep in mind that the function does not get run till it's invoked using parentheses. So, for example:
```
mylambda = lambda x: True if x is 5 else None
mylambda(1+4)
```
Having said all this, regarding your question, the variable `spam` gets whatever the return value, if any, of the `print()` function returns. `print()` has no return value, so `spam` gets assigned the value `None`. If you wanted to assign a reference to the print function to `spam`, you could say:
```
spam = print
```
And then later you could say
```
spam("Hello!")
```
and you would get your "Hello!" string printed to the screen at that time.
Also, having a return value and printing strings to the screen or terminal are two different things. A function could do both or neither of those things and still be a useful function. It all depends on what the coder was trying to accomplish. |
47,851,421 | I am trying to build my first project using an existing sqlite database in Android Studio. All of the instructions I have referenced say to create an assets folder and copy the database into that folder. A call from the database helper will move the file for me for run time testing. The problem is that when the database is in the assets folder and I click on the plus sign next to the folder, Android studio immediately halts, closing all windows and displays no error. I am running studio 3.01 build #AI-171.4443003 dated 11/9/2017. I have applied all updates and the results are the same. I have tried using different extension for the DB with no luck. | 2017/12/17 | [
"https://Stackoverflow.com/questions/47851421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9108569/"
]
| ```
spam = print('Hello!')
```
evaluates the expression on the right hand side and binds its value to `spam`. The return value of the (Python 3) `print()` function is `None`, so `spam` refers to `None`:
```
>>> spam = print('Hello!')
Hello!
>>> spam is None
True
```
One way to handle this is to create a partial function with `functools.partial()`:
```
>>> from functools import partial
>>> spam = partial(print, 'Hello!')
>>> spam
functools.partial(<built-in function print>, 'Hello!')
>>> spam()
Hello!
```
Or a `lambda` expression:
```
>>> spam = lambda : print('Hello!')
>>> spam
<function <lambda> at 0x7f619cabf9d8>
>>> spam()
Hello!
```
Essentially both of the above use a closure around a function like this:
```
def printer(s):
def f():
print(s)
return f
>>> spam = printer('Hello!')
>>> spam
<function printer.<locals>.f at 0x7f619cabfb70>
>>> spam()
Hello!
``` | A function, depending on how that function is written, may or may not have an explicit return value. It's up to the author of the function to decide how he wants to implement his function. A function with an explicit return value must have a `return` statement in it. The `return` statement causes the function to end and for the value following the `return` statement to be "returned" to the calling code. When a function reaches the end of its code without an actual `return` statement, it's like there's an implicit `return None` at the end. So...
```
def is_5(num):
if num is 5:
return True
```
What happens above? If num is 5, the function returns the boolean value of True. But if num is not 5, there is no final `return` statement, so the implicit `None` is returned.
As to your question, there is also a difference between the "name" of a function and invoking the function. In our example above, the "name" of the function is `is_5`, and we invoke it by following the name of the function with parentheses. If there are no parentheses following the function name, then the function name is just like any other variable, only it happens to hold a reference to a function. When you follow it with parentheses, that causes the function to be invoked. This is why we can call
```
is_5(2+3)
```
but we can also say:
```
myfunc = is_5
myfunc(2+3)
```
and get the same exact result. As for `lambda` and `functools.partial`, both are used to create what are known as "nameless" functions -- they return a reference to a function, but that function has no name. You can capture the return from either of those and store it in a variable. Then, you can invoke the function by following the name of the variable with parentheses, just like above. Keep in mind that the function does not get run till it's invoked using parentheses. So, for example:
```
mylambda = lambda x: True if x is 5 else None
mylambda(1+4)
```
Having said all this, regarding your question, the variable `spam` gets whatever the return value, if any, of the `print()` function returns. `print()` has no return value, so `spam` gets assigned the value `None`. If you wanted to assign a reference to the print function to `spam`, you could say:
```
spam = print
```
And then later you could say
```
spam("Hello!")
```
and you would get your "Hello!" string printed to the screen at that time.
Also, having a return value and printing strings to the screen or terminal are two different things. A function could do both or neither of those things and still be a useful function. It all depends on what the coder was trying to accomplish. |
27,878,132 | I understand that the compiler uses the target type to determine the type argument that makes the generic method invocation applicable. For instance, in the following statement:
```
List<String> listOne = Collections.emptyList();
```
where the `Collections.emptyList` has a type parameter `T` in its signature
```
public static final <T> List<T> emptyList() {
```
In this case, the inferred type argument for `T` is `String`.
Now consider the following:
```
List<?> listTwo = Collections.emptyList();
```
What is the inferred type in this case? Is it `Object`? Or it doesn't really matter due to the wildcard telling the compiler any type is possible? | 2015/01/10 | [
"https://Stackoverflow.com/questions/27878132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1064245/"
]
| Each usage of a wildcard has a distinct type associated with it. (Usually the JLS refers to this as being a "fresh type".) This is how for example a compiler error like this works:
```
List<?> list0 = ... ;
List<?> list1 = ... ;
list0.add(list1.get(0)); // error
```
Because it's the case that `list0` and `list1` are given separate types by the compiler such that for the most part
```
reference_type_of(List<?>) != reference_type_of(List<?>)
```
You can begin to see how this fits in to type inference if you try something like
```
{
List<?> list0 = ... ;
List<?> list1 = ... ;
test(list0, list1);
}
static <T> void test(List<T> list0, List<T> list1) {}
```
Where the compiler emits an error that actually tells us a little bit about the types that it has generated for `list0` and `list1`.
```
error: method test in class Ideone cannot be applied to given types;
test(list0, list1);
^
required: List<T>,List<T>
**found: List<CAP#1>,List<CAP#2>**
reason: no instance(s) of type variable(s) T exist so that
argument type List<CAP#2> conforms to formal parameter type List<T>
where T is a type-variable:
T extends Object declared in method <T>test(List<T>,List<T>)
**where CAP#1,CAP#2 are fresh type-variables:
CAP#1 extends Object from capture of ?
CAP#2 extends Object from capture of ?**
```
(My emphasis in bold.) These `CAP#...` types were generated during [capture conversion](http://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.1.10). What it's showing us is that when the method invocation expression was examined, `list0` and `list1` were given distinct types from each other. (And for those that need an explanation for the error: it's because the declaration of `test` asserts that both Lists must have the same `T`.)
So since we now know that a wildcard gets associated a reference type, we can see that in a case like
```
List<?> empty = Collections.emptyList();
```
The invocation will be inferred as something like "a fresh type where the upper bound is Object". Or symbolically we could say the compiler might see something like
```
// target type --> inferred invocation type
// v v
List<CAP#1> empty = Collections.<CAP#1>emptyList();
```
Although: of course we are always guessing a little bit because it's up to the compiler how it implements this. In theory, for a case like the above trivial assignment of `emptyList()`, it would not have to do work to generate the correct bytecode.
Also, I am sorry, I don't feel like spec scouring today. Essentially the type inference here works by generating a set of constraints to demonstrate that the method invocation should or should not compile. The algorithm described in [18.5.2](http://docs.oracle.com/javase/specs/jls/se8/html/jls-18.html#jls-18.5.2) incorporates a wildcard in this way. | >
> What is the inferred type in this case? Is it Object? Or it doesn't
> really matter due to the wildcard telling the compiler any type is
> possible?
>
>
>
On one level, it's kind of a philosophical question, because the type argument does not have any effect on the compiled bytecode, so it doesn't really matter what it is specifically. The only thing that matters is whether or not it's impossible to satisfy the bounds and context. As long as the compiler can prove that there *exists* some type that could work, then in my opinion, it should be able to go ahead and compile it without needing to come up with an actual type. |
15,699,301 | I'm trying to get my MySQL data to Excel file, but I'm having problems with Excel cells. All my text goes to one cell, I would like to have each row value in separate Excel cell. Here is my code:
```
$queryexport = ("
SELECT username,password,fullname FROM ecustomer_users
WHERE fk_customer='".$fk_customer."'
");
$row = mysql_fetch_assoc($queryexport);
$result = mysql_query($queryexport);
$header = '';
for ($i = 0; $i < $count; $i++){
$header .= mysql_field_name($result, $i)."\t";
}
while($row = mysql_fetch_row($result)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
$data = str_replace("\r", "", $data);
if ($data == "") {
$data = "\nno matching records found\n";
}
}
header("Content-type: application/vnd.ms-excel; name='excel'");
header("Content-Disposition: attachment; filename=exportfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
// output data
echo $header."\n".$data;
mysql_close($conn);`
``` | 2013/03/29 | [
"https://Stackoverflow.com/questions/15699301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1988417/"
]
| This is new version of php code
```
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "your_dbname";
//mysql and db connection
$con = new mysqli($servername, $username, $password, $dbname);
if ($con->connect_error) { //error check
die("Connection failed: " . $con->connect_error);
}
else
{
}
$DB_TBLName = "your_table_name";
$filename = "excelfilename"; //your_file_name
$file_ending = "xls"; //file_extention
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=$filename.'.'.$file_ending");
header("Pragma: no-cache");
header("Expires: 0");
$sep = "\t";
$sql="SELECT * FROM $DB_TBLName";
$resultt = $con->query($sql);
while ($property = mysqli_fetch_field($resultt)) { //fetch table field name
echo $property->name."\t";
}
print("\n");
while($row = mysqli_fetch_row($resultt)) //fetch_table_data
{
$schema_insert = "";
for($j=0; $j< mysqli_num_fields($resultt);$j++)
{
if(!isset($row[$j]))
$schema_insert .= "NULL".$sep;
elseif ($row[$j] != "")
$schema_insert .= "$row[$j]".$sep;
else
$schema_insert .= "".$sep;
}
$schema_insert = str_replace($sep."$", "", $schema_insert);
$schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert);
$schema_insert .= "\t";
print(trim($schema_insert));
print "\n";
}
``` | try this code
data.php
```
<table border="1">
<tr>
<th>NO.</th>
<th>NAME</th>
<th>Major</th>
</tr>
<?php
//connection to mysql
mysql_connect("localhost", "root", ""); //server , username , password
mysql_select_db("codelution");
//query get data
$sql = mysql_query("SELECT * FROM student ORDER BY id ASC");
$no = 1;
while($data = mysql_fetch_assoc($sql)){
echo '
<tr>
<td>'.$no.'</td>
<td>'.$data['name'].'</td>
<td>'.$data['major'].'</td>
</tr>
';
$no++;
}
?>
```
code for excel file
export.php
```
<?php
// The function header by sending raw excel
header("Content-type: application/vnd-ms-excel");
// Defines the name of the export file "codelution-export.xls"
header("Content-Disposition: attachment; filename=codelution-export.xls");
// Add data table
include 'data.php';
?>
```
if mysqli version
```
$sql="SELECT * FROM user_details";
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result) > 0)
{
$no = 1;
while($data = mysqli_fetch_assoc($result))
{echo '
<tr>
<<td>'.$no.'</td>
<td>'.$data['name'].'</td>
<td>'.$data['major'].'</td>
</tr>
';
$no++;
```
<http://codelution.com/development/web/easy-ways-to-export-data-from-mysql-to-excel-with-php/> |
15,699,301 | I'm trying to get my MySQL data to Excel file, but I'm having problems with Excel cells. All my text goes to one cell, I would like to have each row value in separate Excel cell. Here is my code:
```
$queryexport = ("
SELECT username,password,fullname FROM ecustomer_users
WHERE fk_customer='".$fk_customer."'
");
$row = mysql_fetch_assoc($queryexport);
$result = mysql_query($queryexport);
$header = '';
for ($i = 0; $i < $count; $i++){
$header .= mysql_field_name($result, $i)."\t";
}
while($row = mysql_fetch_row($result)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
$data = str_replace("\r", "", $data);
if ($data == "") {
$data = "\nno matching records found\n";
}
}
header("Content-type: application/vnd.ms-excel; name='excel'");
header("Content-Disposition: attachment; filename=exportfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
// output data
echo $header."\n".$data;
mysql_close($conn);`
``` | 2013/03/29 | [
"https://Stackoverflow.com/questions/15699301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1988417/"
]
| You can export the data from MySQL to Excel by using this simple code.
```
<?php
include('db_con.php');
$stmt=$db_con->prepare('select * from books');
$stmt->execute();
$columnHeader ='';
$columnHeader = "Sr NO"."\t"."Book Name"."\t"."Book Author"."\t"."Book
ISBN"."\t";
$setData='';
while($rec =$stmt->FETCH(PDO::FETCH_ASSOC))
{
$rowData = '';
foreach($rec as $value)
{
$value = '"' . $value . '"' . "\t";
$rowData .= $value;
}
$setData .= trim($rowData)."\n";
}
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=Book record
sheet.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo ucwords($columnHeader)."\n".$setData."\n";
?>
```
complete code here [php export to excel](http://www.phpcodify.com/export-data-to-excel-in-php-mysql/) | Posts by John Peter and Dileep kurahe helped me to develop what I consider as being a simpler and cleaner solution, just in case anyone else is still looking. (I am not showing any database code because I actually used a $\_SESSION variable.)
The above solutions invariably caused an error upon loading in Excel, about the extension not matching the formatting type. And some of these solutions create a spreadsheet with the data across the page in columns where it would be more traditional to have column headings and list the data down the rows. So here is my simple solution:
```
$filename = "webreport.csv";
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=$filename");
header("Pragma: no-cache");
header("Expires: 0");
foreach($results as $x => $x_value){
echo '"'.$x.'",' . '"'.$x_value.'"' . "\r\n";
}
```
1. Change to .csv (which Excel instantly updates to .xls and there is no error upon loading.)
2. Use the comma as delimiter.
3. Double quote the Key and Value to escape any commas in the data.
4. I also prepended column headers to `$results` so the spreadsheet looked even nicer. |
15,699,301 | I'm trying to get my MySQL data to Excel file, but I'm having problems with Excel cells. All my text goes to one cell, I would like to have each row value in separate Excel cell. Here is my code:
```
$queryexport = ("
SELECT username,password,fullname FROM ecustomer_users
WHERE fk_customer='".$fk_customer."'
");
$row = mysql_fetch_assoc($queryexport);
$result = mysql_query($queryexport);
$header = '';
for ($i = 0; $i < $count; $i++){
$header .= mysql_field_name($result, $i)."\t";
}
while($row = mysql_fetch_row($result)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
$data = str_replace("\r", "", $data);
if ($data == "") {
$data = "\nno matching records found\n";
}
}
header("Content-type: application/vnd.ms-excel; name='excel'");
header("Content-Disposition: attachment; filename=exportfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
// output data
echo $header."\n".$data;
mysql_close($conn);`
``` | 2013/03/29 | [
"https://Stackoverflow.com/questions/15699301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1988417/"
]
| ***Just Try With The Following :***
**PHP Part :**
```
<?php
/*******EDIT LINES 3-8*******/
$DB_Server = "localhost"; //MySQL Server
$DB_Username = "username"; //MySQL Username
$DB_Password = "password"; //MySQL Password
$DB_DBName = "databasename"; //MySQL Database Name
$DB_TBLName = "tablename"; //MySQL Table Name
$filename = "excelfilename"; //File Name
/*******YOU DO NOT NEED TO EDIT ANYTHING BELOW THIS LINE*******/
//create MySQL connection
$sql = "Select * from $DB_TBLName";
$Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password) or die("Couldn't connect to MySQL:<br>" . mysql_error() . "<br>" . mysql_errno());
//select database
$Db = @mysql_select_db($DB_DBName, $Connect) or die("Couldn't select database:<br>" . mysql_error(). "<br>" . mysql_errno());
//execute query
$result = @mysql_query($sql,$Connect) or die("Couldn't execute query:<br>" . mysql_error(). "<br>" . mysql_errno());
$file_ending = "xls";
//header info for browser
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=$filename.xls");
header("Pragma: no-cache");
header("Expires: 0");
/*******Start of Formatting for Excel*******/
//define separator (defines columns in excel & tabs in word)
$sep = "\t"; //tabbed character
//start of printing column names as names of MySQL fields
for ($i = 0; $i < mysql_num_fields($result); $i++) {
echo mysql_field_name($result,$i) . "\t";
}
print("\n");
//end of printing column names
//start while loop to get data
while($row = mysql_fetch_row($result))
{
$schema_insert = "";
for($j=0; $j<mysql_num_fields($result);$j++)
{
if(!isset($row[$j]))
$schema_insert .= "NULL".$sep;
elseif ($row[$j] != "")
$schema_insert .= "$row[$j]".$sep;
else
$schema_insert .= "".$sep;
}
$schema_insert = str_replace($sep."$", "", $schema_insert);
$schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert);
$schema_insert .= "\t";
print(trim($schema_insert));
print "\n";
}
?>
```
I think this may help you to resolve your problem. | If you just want your query data dumped into excel I have to do this frequently and using an html table is a very simple method. I use mysqli for db queries and the following code for exports to excel:
```
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=filename.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo '<table border="1">';
//make the column headers what you want in whatever order you want
echo '<tr><th>Field Name 1</th><th>Field Name 2</th><th>Field Name 3</th></tr>';
//loop the query data to the table in same order as the headers
while ($row = mysqli_fetch_assoc($result)){
echo "<tr><td>".$row['field1']."</td><td>".$row['field2']."</td><td>".$row['field3']."</td></tr>";
}
echo '</table>';
``` |
15,699,301 | I'm trying to get my MySQL data to Excel file, but I'm having problems with Excel cells. All my text goes to one cell, I would like to have each row value in separate Excel cell. Here is my code:
```
$queryexport = ("
SELECT username,password,fullname FROM ecustomer_users
WHERE fk_customer='".$fk_customer."'
");
$row = mysql_fetch_assoc($queryexport);
$result = mysql_query($queryexport);
$header = '';
for ($i = 0; $i < $count; $i++){
$header .= mysql_field_name($result, $i)."\t";
}
while($row = mysql_fetch_row($result)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
$data = str_replace("\r", "", $data);
if ($data == "") {
$data = "\nno matching records found\n";
}
}
header("Content-type: application/vnd.ms-excel; name='excel'");
header("Content-Disposition: attachment; filename=exportfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
// output data
echo $header."\n".$data;
mysql_close($conn);`
``` | 2013/03/29 | [
"https://Stackoverflow.com/questions/15699301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1988417/"
]
| If you just want your query data dumped into excel I have to do this frequently and using an html table is a very simple method. I use mysqli for db queries and the following code for exports to excel:
```
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=filename.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo '<table border="1">';
//make the column headers what you want in whatever order you want
echo '<tr><th>Field Name 1</th><th>Field Name 2</th><th>Field Name 3</th></tr>';
//loop the query data to the table in same order as the headers
while ($row = mysqli_fetch_assoc($result)){
echo "<tr><td>".$row['field1']."</td><td>".$row['field2']."</td><td>".$row['field3']."</td></tr>";
}
echo '</table>';
``` | PHPExcel is your friend. Very easy to use and works like a charm.
<https://github.com/PHPOffice/PHPExcel> |
15,699,301 | I'm trying to get my MySQL data to Excel file, but I'm having problems with Excel cells. All my text goes to one cell, I would like to have each row value in separate Excel cell. Here is my code:
```
$queryexport = ("
SELECT username,password,fullname FROM ecustomer_users
WHERE fk_customer='".$fk_customer."'
");
$row = mysql_fetch_assoc($queryexport);
$result = mysql_query($queryexport);
$header = '';
for ($i = 0; $i < $count; $i++){
$header .= mysql_field_name($result, $i)."\t";
}
while($row = mysql_fetch_row($result)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
$data = str_replace("\r", "", $data);
if ($data == "") {
$data = "\nno matching records found\n";
}
}
header("Content-type: application/vnd.ms-excel; name='excel'");
header("Content-Disposition: attachment; filename=exportfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
// output data
echo $header."\n".$data;
mysql_close($conn);`
``` | 2013/03/29 | [
"https://Stackoverflow.com/questions/15699301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1988417/"
]
| PHPExcel is your friend. Very easy to use and works like a charm.
<https://github.com/PHPOffice/PHPExcel> | Posts by John Peter and Dileep kurahe helped me to develop what I consider as being a simpler and cleaner solution, just in case anyone else is still looking. (I am not showing any database code because I actually used a $\_SESSION variable.)
The above solutions invariably caused an error upon loading in Excel, about the extension not matching the formatting type. And some of these solutions create a spreadsheet with the data across the page in columns where it would be more traditional to have column headings and list the data down the rows. So here is my simple solution:
```
$filename = "webreport.csv";
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=$filename");
header("Pragma: no-cache");
header("Expires: 0");
foreach($results as $x => $x_value){
echo '"'.$x.'",' . '"'.$x_value.'"' . "\r\n";
}
```
1. Change to .csv (which Excel instantly updates to .xls and there is no error upon loading.)
2. Use the comma as delimiter.
3. Double quote the Key and Value to escape any commas in the data.
4. I also prepended column headers to `$results` so the spreadsheet looked even nicer. |
15,699,301 | I'm trying to get my MySQL data to Excel file, but I'm having problems with Excel cells. All my text goes to one cell, I would like to have each row value in separate Excel cell. Here is my code:
```
$queryexport = ("
SELECT username,password,fullname FROM ecustomer_users
WHERE fk_customer='".$fk_customer."'
");
$row = mysql_fetch_assoc($queryexport);
$result = mysql_query($queryexport);
$header = '';
for ($i = 0; $i < $count; $i++){
$header .= mysql_field_name($result, $i)."\t";
}
while($row = mysql_fetch_row($result)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
$data = str_replace("\r", "", $data);
if ($data == "") {
$data = "\nno matching records found\n";
}
}
header("Content-type: application/vnd.ms-excel; name='excel'");
header("Content-Disposition: attachment; filename=exportfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
// output data
echo $header."\n".$data;
mysql_close($conn);`
``` | 2013/03/29 | [
"https://Stackoverflow.com/questions/15699301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1988417/"
]
| Try the Following Code Please.
just only update two values.
1.your\_database\_name
2.table\_name
```
<?php
$host="localhost";
$username="root";
$password="";
$dbname="your_database_name";
$con = new mysqli($host, $username, $password,$dbname);
$sql_data="select * from table_name";
$result_data=$con->query($sql_data);
$results=array();
filename = "Webinfopen.xls"; // File Name
// Download file
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
$flag = false;
while ($row = mysqli_fetch_assoc($result_data)) {
if (!$flag) {
// display field/column names as first row
echo implode("\t", array_keys($row)) . "\r\n";
$flag = true;
}
echo implode("\t", array_values($row)) . "\r\n";
}
?>
``` | This is baes on John Peter's answer above. The code is working perfectly but I needed it for WordPress. So, I did something like this:
```
<?php
require '../../../wp-load.php';
$file_name = "registered-users";
$args = array( 'role' => 'client',
'meta_query' => array( array(
'key' => '_dt_transaction_archived',
'compare' => 'NOT EXISTS'
) ),
'order' => 'DESC',
'orderby' => 'ID'
);
$users = get_users( $args );
$file_ending = "xls";
// Header info for browser
header( "Content-Type: application/xls" );
header( "Content-Disposition: attachment; filename=$file_name.$file_ending" );
header( "Pragma: no-cache" );
header( "Expires: 0" );
/*******Start of Formatting for Excel*******/
// define separator (defines columns in excel & tabs in word)
$sep = "\t"; //tabbed character
// start of printing column names as names of MySQL fields
print( "First Name" . $sep );
print( "Last Name" . $sep );
print( "E-Mail" . $sep );
print( "\n" );
// end of printing column names
// start foreach loop to get data
$schema_insert = "";
foreach ($users as $user) {
if ( $user ) {
$schema_insert = "$user->first_name" . $sep;
$schema_insert .= "$user->last_name" . $sep;
$schema_insert .= "$user->user_email" . $sep;
print "\n";
$schema_insert = str_replace( $sep . "$", "", $schema_insert );
$schema_insert = preg_replace( "/\r\n|\n\r|\n|\r/", " ", $schema_insert );
$schema_insert .= "\t";
print( trim( $schema_insert ) );
}
}
``` |
15,699,301 | I'm trying to get my MySQL data to Excel file, but I'm having problems with Excel cells. All my text goes to one cell, I would like to have each row value in separate Excel cell. Here is my code:
```
$queryexport = ("
SELECT username,password,fullname FROM ecustomer_users
WHERE fk_customer='".$fk_customer."'
");
$row = mysql_fetch_assoc($queryexport);
$result = mysql_query($queryexport);
$header = '';
for ($i = 0; $i < $count; $i++){
$header .= mysql_field_name($result, $i)."\t";
}
while($row = mysql_fetch_row($result)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
$data = str_replace("\r", "", $data);
if ($data == "") {
$data = "\nno matching records found\n";
}
}
header("Content-type: application/vnd.ms-excel; name='excel'");
header("Content-Disposition: attachment; filename=exportfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
// output data
echo $header."\n".$data;
mysql_close($conn);`
``` | 2013/03/29 | [
"https://Stackoverflow.com/questions/15699301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1988417/"
]
| This is new version of php code
```
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "your_dbname";
//mysql and db connection
$con = new mysqli($servername, $username, $password, $dbname);
if ($con->connect_error) { //error check
die("Connection failed: " . $con->connect_error);
}
else
{
}
$DB_TBLName = "your_table_name";
$filename = "excelfilename"; //your_file_name
$file_ending = "xls"; //file_extention
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=$filename.'.'.$file_ending");
header("Pragma: no-cache");
header("Expires: 0");
$sep = "\t";
$sql="SELECT * FROM $DB_TBLName";
$resultt = $con->query($sql);
while ($property = mysqli_fetch_field($resultt)) { //fetch table field name
echo $property->name."\t";
}
print("\n");
while($row = mysqli_fetch_row($resultt)) //fetch_table_data
{
$schema_insert = "";
for($j=0; $j< mysqli_num_fields($resultt);$j++)
{
if(!isset($row[$j]))
$schema_insert .= "NULL".$sep;
elseif ($row[$j] != "")
$schema_insert .= "$row[$j]".$sep;
else
$schema_insert .= "".$sep;
}
$schema_insert = str_replace($sep."$", "", $schema_insert);
$schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert);
$schema_insert .= "\t";
print(trim($schema_insert));
print "\n";
}
``` | Try this code:
```
<?php
header("Content-type: application/vnd-ms-excel");
header("Content-Disposition: attachment; filename=hasil-export.xls");
include 'view-lap.php';
?>
``` |
15,699,301 | I'm trying to get my MySQL data to Excel file, but I'm having problems with Excel cells. All my text goes to one cell, I would like to have each row value in separate Excel cell. Here is my code:
```
$queryexport = ("
SELECT username,password,fullname FROM ecustomer_users
WHERE fk_customer='".$fk_customer."'
");
$row = mysql_fetch_assoc($queryexport);
$result = mysql_query($queryexport);
$header = '';
for ($i = 0; $i < $count; $i++){
$header .= mysql_field_name($result, $i)."\t";
}
while($row = mysql_fetch_row($result)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
$data = str_replace("\r", "", $data);
if ($data == "") {
$data = "\nno matching records found\n";
}
}
header("Content-type: application/vnd.ms-excel; name='excel'");
header("Content-Disposition: attachment; filename=exportfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
// output data
echo $header."\n".$data;
mysql_close($conn);`
``` | 2013/03/29 | [
"https://Stackoverflow.com/questions/15699301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1988417/"
]
| PHPExcel is your friend. Very easy to use and works like a charm.
<https://github.com/PHPOffice/PHPExcel> | You can export the data from MySQL to Excel by using this simple code.
```
<?php
include('db_con.php');
$stmt=$db_con->prepare('select * from books');
$stmt->execute();
$columnHeader ='';
$columnHeader = "Sr NO"."\t"."Book Name"."\t"."Book Author"."\t"."Book
ISBN"."\t";
$setData='';
while($rec =$stmt->FETCH(PDO::FETCH_ASSOC))
{
$rowData = '';
foreach($rec as $value)
{
$value = '"' . $value . '"' . "\t";
$rowData .= $value;
}
$setData .= trim($rowData)."\n";
}
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=Book record
sheet.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo ucwords($columnHeader)."\n".$setData."\n";
?>
```
complete code here [php export to excel](http://www.phpcodify.com/export-data-to-excel-in-php-mysql/) |
15,699,301 | I'm trying to get my MySQL data to Excel file, but I'm having problems with Excel cells. All my text goes to one cell, I would like to have each row value in separate Excel cell. Here is my code:
```
$queryexport = ("
SELECT username,password,fullname FROM ecustomer_users
WHERE fk_customer='".$fk_customer."'
");
$row = mysql_fetch_assoc($queryexport);
$result = mysql_query($queryexport);
$header = '';
for ($i = 0; $i < $count; $i++){
$header .= mysql_field_name($result, $i)."\t";
}
while($row = mysql_fetch_row($result)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
$data = str_replace("\r", "", $data);
if ($data == "") {
$data = "\nno matching records found\n";
}
}
header("Content-type: application/vnd.ms-excel; name='excel'");
header("Content-Disposition: attachment; filename=exportfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
// output data
echo $header."\n".$data;
mysql_close($conn);`
``` | 2013/03/29 | [
"https://Stackoverflow.com/questions/15699301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1988417/"
]
| This is new version of php code
```
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "your_dbname";
//mysql and db connection
$con = new mysqli($servername, $username, $password, $dbname);
if ($con->connect_error) { //error check
die("Connection failed: " . $con->connect_error);
}
else
{
}
$DB_TBLName = "your_table_name";
$filename = "excelfilename"; //your_file_name
$file_ending = "xls"; //file_extention
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=$filename.'.'.$file_ending");
header("Pragma: no-cache");
header("Expires: 0");
$sep = "\t";
$sql="SELECT * FROM $DB_TBLName";
$resultt = $con->query($sql);
while ($property = mysqli_fetch_field($resultt)) { //fetch table field name
echo $property->name."\t";
}
print("\n");
while($row = mysqli_fetch_row($resultt)) //fetch_table_data
{
$schema_insert = "";
for($j=0; $j< mysqli_num_fields($resultt);$j++)
{
if(!isset($row[$j]))
$schema_insert .= "NULL".$sep;
elseif ($row[$j] != "")
$schema_insert .= "$row[$j]".$sep;
else
$schema_insert .= "".$sep;
}
$schema_insert = str_replace($sep."$", "", $schema_insert);
$schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert);
$schema_insert .= "\t";
print(trim($schema_insert));
print "\n";
}
``` | Try the Following Code Please.
just only update two values.
1.your\_database\_name
2.table\_name
```
<?php
$host="localhost";
$username="root";
$password="";
$dbname="your_database_name";
$con = new mysqli($host, $username, $password,$dbname);
$sql_data="select * from table_name";
$result_data=$con->query($sql_data);
$results=array();
filename = "Webinfopen.xls"; // File Name
// Download file
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
$flag = false;
while ($row = mysqli_fetch_assoc($result_data)) {
if (!$flag) {
// display field/column names as first row
echo implode("\t", array_keys($row)) . "\r\n";
$flag = true;
}
echo implode("\t", array_values($row)) . "\r\n";
}
?>
``` |
15,699,301 | I'm trying to get my MySQL data to Excel file, but I'm having problems with Excel cells. All my text goes to one cell, I would like to have each row value in separate Excel cell. Here is my code:
```
$queryexport = ("
SELECT username,password,fullname FROM ecustomer_users
WHERE fk_customer='".$fk_customer."'
");
$row = mysql_fetch_assoc($queryexport);
$result = mysql_query($queryexport);
$header = '';
for ($i = 0; $i < $count; $i++){
$header .= mysql_field_name($result, $i)."\t";
}
while($row = mysql_fetch_row($result)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
$data = str_replace("\r", "", $data);
if ($data == "") {
$data = "\nno matching records found\n";
}
}
header("Content-type: application/vnd.ms-excel; name='excel'");
header("Content-Disposition: attachment; filename=exportfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
// output data
echo $header."\n".$data;
mysql_close($conn);`
``` | 2013/03/29 | [
"https://Stackoverflow.com/questions/15699301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1988417/"
]
| ***Just Try With The Following :***
**PHP Part :**
```
<?php
/*******EDIT LINES 3-8*******/
$DB_Server = "localhost"; //MySQL Server
$DB_Username = "username"; //MySQL Username
$DB_Password = "password"; //MySQL Password
$DB_DBName = "databasename"; //MySQL Database Name
$DB_TBLName = "tablename"; //MySQL Table Name
$filename = "excelfilename"; //File Name
/*******YOU DO NOT NEED TO EDIT ANYTHING BELOW THIS LINE*******/
//create MySQL connection
$sql = "Select * from $DB_TBLName";
$Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password) or die("Couldn't connect to MySQL:<br>" . mysql_error() . "<br>" . mysql_errno());
//select database
$Db = @mysql_select_db($DB_DBName, $Connect) or die("Couldn't select database:<br>" . mysql_error(). "<br>" . mysql_errno());
//execute query
$result = @mysql_query($sql,$Connect) or die("Couldn't execute query:<br>" . mysql_error(). "<br>" . mysql_errno());
$file_ending = "xls";
//header info for browser
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=$filename.xls");
header("Pragma: no-cache");
header("Expires: 0");
/*******Start of Formatting for Excel*******/
//define separator (defines columns in excel & tabs in word)
$sep = "\t"; //tabbed character
//start of printing column names as names of MySQL fields
for ($i = 0; $i < mysql_num_fields($result); $i++) {
echo mysql_field_name($result,$i) . "\t";
}
print("\n");
//end of printing column names
//start while loop to get data
while($row = mysql_fetch_row($result))
{
$schema_insert = "";
for($j=0; $j<mysql_num_fields($result);$j++)
{
if(!isset($row[$j]))
$schema_insert .= "NULL".$sep;
elseif ($row[$j] != "")
$schema_insert .= "$row[$j]".$sep;
else
$schema_insert .= "".$sep;
}
$schema_insert = str_replace($sep."$", "", $schema_insert);
$schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert);
$schema_insert .= "\t";
print(trim($schema_insert));
print "\n";
}
?>
```
I think this may help you to resolve your problem. | I think you should try with this API
<http://code.google.com/p/php-excel/source/browse/trunk/php-excel.class.php>
With This
```
Create a quick export from a database table into Excel
Compile some statistical records with a few calculations and deliver
the result in an Excel worksheet
Gather the items off your (web-based) todo list, put them in a
worksheet and use it as a foundation for some more statistics
magic.**
``` |
14,466 | I want to open a service for people to print portrait images of people they are inspired by. Musicians, scientists, people such as Einstein, Mozart, etc.
What are the legal concerns of using images of **Google Images** and how can I find images which can be legally used for this purpose? | 2016/10/07 | [
"https://law.stackexchange.com/questions/14466",
"https://law.stackexchange.com",
"https://law.stackexchange.com/users/5614/"
]
| There is no country in the world that has *absolute* freedom of speech. There are many that have extreme limits on it.
The country with the greatest freedom is probably the United States of America but even there there are limits.
For example, it is illegal to defame someone. That is, make a factual statement about a person or organization that is not true and that could damage their reputation.
For your case, as a student of the school you are subject to the rules of the school. If your statement breaks those rules you can be sanctioned. If the school is public, it would generally be as restricted as the government is in limiting free speech but, as stated above, such restrictions depend on where you are. | If you had said it to their faces in the hallway, would you have gotten in trouble? If so, then the answer is yes, you can get in trouble with your school. Probably not with the law, unless you made some credible threat of imminent violence. |
29,069,259 | I am trying to process an array of objects (representing game players) to assign each object a group number based on their current group value.
The catch is that each group should have as close to four players as possible and some players want to be in specific groups which must not be broken (but can be renamed or merged).
Some players have unassigned/null groups (they don't want to play with anyone specific) and others want to play with specific people so they have a custom group value.
```
var players = [
{name: "A", group: null},
{name: "B", group: null},
{name: "C", group: null},
{name: "D", group: null},
{name: "E", group: null},
{name: "cA", group: "custom1"},
{name: "cB", group: "custom1"},
{name: "cC", group: "custom2"},
{name: "cD", group: "custom2"},
{name: "cE", group: "custom3"},
{name: "cF", group: "custom3"}];
```
I need a way to resolve this array so that it returns something like this:
```
var resolvedGroup = [
{name: "A", group: 1},
{name: "B", group: 1},
{name: "C", group: 1},
{name: "D", group: 1},
{name: "cA", group: "customMerged1"},
{name: "cB", group: "customMerged1"},
{name: "cC", group: "customMerged1"},
{name: "cD", group: "customMerged1"},
{name: "cE", group: 2},
{name: "cF", group: 2},
{name: "E", group: 2}
]
```
You can see that the first four players should get assigned to group 1 and the players who initially had custom groups, get merged into groups of four, if possible - otherwise, they should get some of the "null" group players to form as close to four players in a group as possible. The names of the groups don't matter, only that each player who specified a custom group should be able to stay with the initial group members even if they get merged with another custom group. | 2015/03/16 | [
"https://Stackoverflow.com/questions/29069259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2629166/"
]
| You're misunderstanding what the ID is. It's not a property of the variable, it's a property of the object that is assigned to the variable. If you change the object, for example from one number to another, you also change the ID. It is *impossible* to change to a different object without also changing the ID.
You can't even ensure that two identical numbers get the same ID:
```
>>> x = 1234567890
>>> id(x)
37359104
>>> x = 1234567890
>>> id(x)
37344544
``` | The only sure way to do so is to use a mutable object and then mutate it. Since it will be the same object, it will have the same ID.
For immutable objects such as integers and strings, this is all but impossible. |
29,069,259 | I am trying to process an array of objects (representing game players) to assign each object a group number based on their current group value.
The catch is that each group should have as close to four players as possible and some players want to be in specific groups which must not be broken (but can be renamed or merged).
Some players have unassigned/null groups (they don't want to play with anyone specific) and others want to play with specific people so they have a custom group value.
```
var players = [
{name: "A", group: null},
{name: "B", group: null},
{name: "C", group: null},
{name: "D", group: null},
{name: "E", group: null},
{name: "cA", group: "custom1"},
{name: "cB", group: "custom1"},
{name: "cC", group: "custom2"},
{name: "cD", group: "custom2"},
{name: "cE", group: "custom3"},
{name: "cF", group: "custom3"}];
```
I need a way to resolve this array so that it returns something like this:
```
var resolvedGroup = [
{name: "A", group: 1},
{name: "B", group: 1},
{name: "C", group: 1},
{name: "D", group: 1},
{name: "cA", group: "customMerged1"},
{name: "cB", group: "customMerged1"},
{name: "cC", group: "customMerged1"},
{name: "cD", group: "customMerged1"},
{name: "cE", group: 2},
{name: "cF", group: 2},
{name: "E", group: 2}
]
```
You can see that the first four players should get assigned to group 1 and the players who initially had custom groups, get merged into groups of four, if possible - otherwise, they should get some of the "null" group players to form as close to four players in a group as possible. The names of the groups don't matter, only that each player who specified a custom group should be able to stay with the initial group members even if they get merged with another custom group. | 2015/03/16 | [
"https://Stackoverflow.com/questions/29069259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2629166/"
]
| The only sure way to do so is to use a mutable object and then mutate it. Since it will be the same object, it will have the same ID.
For immutable objects such as integers and strings, this is all but impossible. | You can do that with a list and it will not change the objects identity.
```py
def _increaseParam(param):
param_list = []
print id(param_list) # -> 3072758732
pitch = 50
param_list.append(param)
param_list[0] += pitch
print id(param_list) # -> 3072758732<br><br>_increaseParam(10)
_increaseParam(10)
```
output:
```
3072758732
3072758732
``` |
29,069,259 | I am trying to process an array of objects (representing game players) to assign each object a group number based on their current group value.
The catch is that each group should have as close to four players as possible and some players want to be in specific groups which must not be broken (but can be renamed or merged).
Some players have unassigned/null groups (they don't want to play with anyone specific) and others want to play with specific people so they have a custom group value.
```
var players = [
{name: "A", group: null},
{name: "B", group: null},
{name: "C", group: null},
{name: "D", group: null},
{name: "E", group: null},
{name: "cA", group: "custom1"},
{name: "cB", group: "custom1"},
{name: "cC", group: "custom2"},
{name: "cD", group: "custom2"},
{name: "cE", group: "custom3"},
{name: "cF", group: "custom3"}];
```
I need a way to resolve this array so that it returns something like this:
```
var resolvedGroup = [
{name: "A", group: 1},
{name: "B", group: 1},
{name: "C", group: 1},
{name: "D", group: 1},
{name: "cA", group: "customMerged1"},
{name: "cB", group: "customMerged1"},
{name: "cC", group: "customMerged1"},
{name: "cD", group: "customMerged1"},
{name: "cE", group: 2},
{name: "cF", group: 2},
{name: "E", group: 2}
]
```
You can see that the first four players should get assigned to group 1 and the players who initially had custom groups, get merged into groups of four, if possible - otherwise, they should get some of the "null" group players to form as close to four players in a group as possible. The names of the groups don't matter, only that each player who specified a custom group should be able to stay with the initial group members even if they get merged with another custom group. | 2015/03/16 | [
"https://Stackoverflow.com/questions/29069259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2629166/"
]
| You're misunderstanding what the ID is. It's not a property of the variable, it's a property of the object that is assigned to the variable. If you change the object, for example from one number to another, you also change the ID. It is *impossible* to change to a different object without also changing the ID.
You can't even ensure that two identical numbers get the same ID:
```
>>> x = 1234567890
>>> id(x)
37359104
>>> x = 1234567890
>>> id(x)
37344544
``` | You can do that with a list and it will not change the objects identity.
```py
def _increaseParam(param):
param_list = []
print id(param_list) # -> 3072758732
pitch = 50
param_list.append(param)
param_list[0] += pitch
print id(param_list) # -> 3072758732<br><br>_increaseParam(10)
_increaseParam(10)
```
output:
```
3072758732
3072758732
``` |
35,735 | I am looking for a way to create a Photo Post type. Basically a post that is a title and a single image. Where I am getting stuck is the actual attaching an image to a post. I would like to have an image upload field in a metabox. I followed this [guide](http://austinpassy.com/2010/03/creating-custom-metaboxes-and-the-built-in-uploader/). I am able to see the WP upload box and I upload an image from my machine and click "Insert into Post". Then I publish the post. I don't know if the image is actually attached to that post though. I see the post in the database as well as the image as an "attachment" post\_type.
Is this a good direction to go in if all I want is a simple attach a single image to a post along with a title?
Also, is there any way to simplify the media upload lightbox just for a certain post type? (Making it so the user doesn't need to know to click "Insert into Post" instead of "Save All Changes"? | 2011/12/07 | [
"https://wordpress.stackexchange.com/questions/35735",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10909/"
]
| Your above function tests whether a page *is* a child page of some other page, not whether it has children.
You can test for children of the current page like so:
```
function has_children() {
global $post;
$children = get_pages( array( 'child_of' => $post->ID ) );
if( count( $children ) == 0 ) {
return false;
} else {
return true;
}
}
```
Further reading:
* [wp codex: get\_pages](http://codex.wordpress.org/Function_Reference/get_pages)
* [php manual: count](http://php.net/manual/en/function.count.php) | Here is version for any post type, in case if you are using custom post type
```
function has_children($post_ID = null) {
if ($post_ID === null) {
global $post;
$post_ID = $post->ID;
}
$query = new WP_Query(array('post_parent' => $post_ID, 'post_type' => 'any'));
return $query->have_posts();
}
``` |
59,672 | Can the Yongnuo YN622C TX be used with the YN622C controlling the B800 like the Radio Poppers and Pocket Wizards? | 2015/01/25 | [
"https://photo.stackexchange.com/questions/59672",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/37282/"
]
| Depends on what you mean by "controlling."
If by "controlling" you mean firing in sync, as manual triggers, no sweat. The YN-622C has a PC sync port that you can use to hook it up to an AB800 as a radio receiver, and the Bee will fire in sync.
If by "controlling" you mean firing in sync and letting you remotely set the power level on the AB800, then no. The YN-622C/662C-TX combination only controls the power on Canon eTTL-compatible flashes and requires that the flash have all the pins on a Canon flash foot. The AB800 is a manual studio strobe that doesn't do eTTL and has no flash foot, let alone one that's compatible with the Canon signaling protocol. A PC sync connection is always manual-only.
The PocketWizard AC9 adapter and the RadioPopper capability for controlling an AB power level is doing something different. I think (could be wrong) that they're taking advantage of the built-in power control that the AlienBees have for the Buff [CyberCommander](http://www.paulcbuff.com/cc.php) triggers. | I'm trying to use Yongnuo YN622C II on Alien Bees with a Pocket Wizard AC9 to set the power... It seems to work... :-) even if it's just a short house test and the Alien Bee makes some strange sounds... |
59,672 | Can the Yongnuo YN622C TX be used with the YN622C controlling the B800 like the Radio Poppers and Pocket Wizards? | 2015/01/25 | [
"https://photo.stackexchange.com/questions/59672",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/37282/"
]
| Depends on what you mean by "controlling."
If by "controlling" you mean firing in sync, as manual triggers, no sweat. The YN-622C has a PC sync port that you can use to hook it up to an AB800 as a radio receiver, and the Bee will fire in sync.
If by "controlling" you mean firing in sync and letting you remotely set the power level on the AB800, then no. The YN-622C/662C-TX combination only controls the power on Canon eTTL-compatible flashes and requires that the flash have all the pins on a Canon flash foot. The AB800 is a manual studio strobe that doesn't do eTTL and has no flash foot, let alone one that's compatible with the Canon signaling protocol. A PC sync connection is always manual-only.
The PocketWizard AC9 adapter and the RadioPopper capability for controlling an AB power level is doing something different. I think (could be wrong) that they're taking advantage of the built-in power control that the AlienBees have for the Buff [CyberCommander](http://www.paulcbuff.com/cc.php) triggers. | Well 1st off yes you can use the YN622C 11 with the Alien Bees but you have to manually change power setting not able to do it by way of remote |
59,672 | Can the Yongnuo YN622C TX be used with the YN622C controlling the B800 like the Radio Poppers and Pocket Wizards? | 2015/01/25 | [
"https://photo.stackexchange.com/questions/59672",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/37282/"
]
| Depends on what you mean by "controlling."
If by "controlling" you mean firing in sync, as manual triggers, no sweat. The YN-622C has a PC sync port that you can use to hook it up to an AB800 as a radio receiver, and the Bee will fire in sync.
If by "controlling" you mean firing in sync and letting you remotely set the power level on the AB800, then no. The YN-622C/662C-TX combination only controls the power on Canon eTTL-compatible flashes and requires that the flash have all the pins on a Canon flash foot. The AB800 is a manual studio strobe that doesn't do eTTL and has no flash foot, let alone one that's compatible with the Canon signaling protocol. A PC sync connection is always manual-only.
The PocketWizard AC9 adapter and the RadioPopper capability for controlling an AB power level is doing something different. I think (could be wrong) that they're taking advantage of the built-in power control that the AlienBees have for the Buff [CyberCommander](http://www.paulcbuff.com/cc.php) triggers. | Ok, if you use the YN622C TX on camera and the YN622C on the YN flash you can control the flash with the TX, but when you use the YN622C with the b800 and the YN622C TX, you have to manually change the power output by hand not the TX |
2,305,569 | e.g.
```
public interface CacheClient
{
List<?> getKeysWithExpiryCheck();
}
```
Or should I return
```
List<Object>
``` | 2010/02/21 | [
"https://Stackoverflow.com/questions/2305569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27328/"
]
| [Here](http://java.sun.com/docs/books/tutorial/extra/generics/index.html) is a good intro to Java Generics. [A] and [B] explain the difference between ? and Object. Basically, ? indicates that the type is unknown which is a problem if you need to add items to the list. However, if you only read from the list it is OK to treat the result as an Object. Although, I suggest to use some thing like
```
public interface CacheClient {
List<? extends Key> getKeysWithExpiryCheck();
}
```
[A] <http://java.sun.com/docs/books/tutorial/extra/generics/subtype.html>
[B] <http://java.sun.com/docs/books/tutorial/extra/generics/wildcards.html> | Could it be to ensure type safety? Returning a List of object means that the list could hold anything. |
2,305,569 | e.g.
```
public interface CacheClient
{
List<?> getKeysWithExpiryCheck();
}
```
Or should I return
```
List<Object>
``` | 2010/02/21 | [
"https://Stackoverflow.com/questions/2305569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27328/"
]
| [Here](http://java.sun.com/docs/books/tutorial/extra/generics/index.html) is a good intro to Java Generics. [A] and [B] explain the difference between ? and Object. Basically, ? indicates that the type is unknown which is a problem if you need to add items to the list. However, if you only read from the list it is OK to treat the result as an Object. Although, I suggest to use some thing like
```
public interface CacheClient {
List<? extends Key> getKeysWithExpiryCheck();
}
```
[A] <http://java.sun.com/docs/books/tutorial/extra/generics/subtype.html>
[B] <http://java.sun.com/docs/books/tutorial/extra/generics/wildcards.html> | If you declare your method as
```
List<Object> getKeysWithExpiryCheck();
```
You can only return `List<Object>` instances from it, and nothing else. If you e.g. try to return `List<String>`, you get a compilation error. This is because although `Object` is a supertype of `String`, `List<Object>` is not a supertype of `List<String>`. |
2,305,569 | e.g.
```
public interface CacheClient
{
List<?> getKeysWithExpiryCheck();
}
```
Or should I return
```
List<Object>
``` | 2010/02/21 | [
"https://Stackoverflow.com/questions/2305569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27328/"
]
| [Here](http://java.sun.com/docs/books/tutorial/extra/generics/index.html) is a good intro to Java Generics. [A] and [B] explain the difference between ? and Object. Basically, ? indicates that the type is unknown which is a problem if you need to add items to the list. However, if you only read from the list it is OK to treat the result as an Object. Although, I suggest to use some thing like
```
public interface CacheClient {
List<? extends Key> getKeysWithExpiryCheck();
}
```
[A] <http://java.sun.com/docs/books/tutorial/extra/generics/subtype.html>
[B] <http://java.sun.com/docs/books/tutorial/extra/generics/wildcards.html> | Basically it means that the collection can hold any type.
However when using it's impossible to modify the collection.
```
public void doSomething(Collection<?> col) {
for (Object o : col) {
System.out.println(o);
}
col.add("string"); //Compile Error here !
}
``` |
2,305,569 | e.g.
```
public interface CacheClient
{
List<?> getKeysWithExpiryCheck();
}
```
Or should I return
```
List<Object>
``` | 2010/02/21 | [
"https://Stackoverflow.com/questions/2305569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27328/"
]
| If you declare your method as
```
List<Object> getKeysWithExpiryCheck();
```
You can only return `List<Object>` instances from it, and nothing else. If you e.g. try to return `List<String>`, you get a compilation error. This is because although `Object` is a supertype of `String`, `List<Object>` is not a supertype of `List<String>`. | Could it be to ensure type safety? Returning a List of object means that the list could hold anything. |
2,305,569 | e.g.
```
public interface CacheClient
{
List<?> getKeysWithExpiryCheck();
}
```
Or should I return
```
List<Object>
``` | 2010/02/21 | [
"https://Stackoverflow.com/questions/2305569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27328/"
]
| If you declare your method as
```
List<Object> getKeysWithExpiryCheck();
```
You can only return `List<Object>` instances from it, and nothing else. If you e.g. try to return `List<String>`, you get a compilation error. This is because although `Object` is a supertype of `String`, `List<Object>` is not a supertype of `List<String>`. | Basically it means that the collection can hold any type.
However when using it's impossible to modify the collection.
```
public void doSomething(Collection<?> col) {
for (Object o : col) {
System.out.println(o);
}
col.add("string"); //Compile Error here !
}
``` |
18,896,455 | First, let's review my code:
HTML:
```
<div class="button_container">
<div class="inner_button">
<a href="#" class="button_text">Button</a>
</div>
<div class="button_side">
<i class="play" />
</div>
</div>
```
CSS:
```
.inner_button:hover {
background: red;
}
.button_container:hover > .button_side {
background-color: red !important;
}
```
The above code will let `.button_side` hover if `.button_container` is hovered. But now I also want to do the reverse, so that if `.button_side` is hovered it will hover `.button_container`. I believe with CSS it will be difficult but I would prefer it but I am open to something in JQuery. How can I do this? | 2013/09/19 | [
"https://Stackoverflow.com/questions/18896455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1339464/"
]
| >
> *"I also want to do the reverse, so that if `.button_side` is hovered it will hover `.button_container`"*
>
>
>
I believe you are correct about needing to use JS for this (easy with some jQuery), because CSS tends to work from parents to children, not the other way around. First define a class to add with the desired setting(s):
```
.hover {
background : red;
}
```
And then:
```
$(".button_side").mouseenter(function() {
$(this).closest(".button_container").addClass("hover");
}).mouseleave(function() {
$(this).closest(".button_container").removeClass("hover");
});
```
Demo: <http://jsfiddle.net/PxQCT/>
Within a jQuery event handler, `this` (usually) refers to the element that the event applied to, so `$(this)` gives you a jQuery wrapper to the hovered item and lets you use jQuery's `.closest()` method to find the nearest ancestor with the `.button_container` class.
Note that the JS code that I've shown would need to be included in a script element that appears after the elements in question, and/or in a document ready handler.
EDIT / P.S.: Note that in your markup as shown in the question the `.button_side` element doesn't actually have any hoverable content, just an empty (self-closing) `<i>` element (so in my demo I added some content there so that you could have something to hover over and see it working). | **I think you can do something like this (with jQuery):**
```
$(document).ready(function(){
$('.button_side').hover(function(){
$('.button_container').addClass('hover');
}, function(){
$('.button_container').removeClass('hover');
});
});
```
If you need some help, try to see this [jsfiddle](http://jsfiddle.net/59YqL/). |
18,896,455 | First, let's review my code:
HTML:
```
<div class="button_container">
<div class="inner_button">
<a href="#" class="button_text">Button</a>
</div>
<div class="button_side">
<i class="play" />
</div>
</div>
```
CSS:
```
.inner_button:hover {
background: red;
}
.button_container:hover > .button_side {
background-color: red !important;
}
```
The above code will let `.button_side` hover if `.button_container` is hovered. But now I also want to do the reverse, so that if `.button_side` is hovered it will hover `.button_container`. I believe with CSS it will be difficult but I would prefer it but I am open to something in JQuery. How can I do this? | 2013/09/19 | [
"https://Stackoverflow.com/questions/18896455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1339464/"
]
| >
> *"I also want to do the reverse, so that if `.button_side` is hovered it will hover `.button_container`"*
>
>
>
I believe you are correct about needing to use JS for this (easy with some jQuery), because CSS tends to work from parents to children, not the other way around. First define a class to add with the desired setting(s):
```
.hover {
background : red;
}
```
And then:
```
$(".button_side").mouseenter(function() {
$(this).closest(".button_container").addClass("hover");
}).mouseleave(function() {
$(this).closest(".button_container").removeClass("hover");
});
```
Demo: <http://jsfiddle.net/PxQCT/>
Within a jQuery event handler, `this` (usually) refers to the element that the event applied to, so `$(this)` gives you a jQuery wrapper to the hovered item and lets you use jQuery's `.closest()` method to find the nearest ancestor with the `.button_container` class.
Note that the JS code that I've shown would need to be included in a script element that appears after the elements in question, and/or in a document ready handler.
EDIT / P.S.: Note that in your markup as shown in the question the `.button_side` element doesn't actually have any hoverable content, just an empty (self-closing) `<i>` element (so in my demo I added some content there so that you could have something to hover over and see it working). | This is not exactly what you are asking but probably helpful.
Sometimes is a suitable solution if you don't want to mess around with js to much.
On the other side it makes your `html` and `css` code messy. I rarely use this in some special situations (e.g. for having a hover effect for column views where the column can have a height of 100% because it should expand the row).
It does not work for older IE versions so if it is used it should be used with caution.
**HTML**
```
<div class="button_container">
<div class="inner_button">
<a href="#" class="button_text">Button</a>
</div>
<div class="button_side">
<i class="play">play</i>
<div class="hover-fake"><div>
</div>
</div>
```
**CSS**
```
.hover-fake {
position: absolute;
left: 0px;
top: 0px;
z-index: -1;
width: 100%;
height: 100%;
background: green;
display: none;
}
.button_container {
position: relative;
left: 0xp;
top: 0px;
}
.inner_button:hover {
background: red;
}
.button_container:hover > .button_side {
background-color: red !important;
}
.button_side:hover > .hover-fake {
display: block;
}
```
**[JSFiddle](http://jsfiddle.net/65yuA/)** |
18,896,455 | First, let's review my code:
HTML:
```
<div class="button_container">
<div class="inner_button">
<a href="#" class="button_text">Button</a>
</div>
<div class="button_side">
<i class="play" />
</div>
</div>
```
CSS:
```
.inner_button:hover {
background: red;
}
.button_container:hover > .button_side {
background-color: red !important;
}
```
The above code will let `.button_side` hover if `.button_container` is hovered. But now I also want to do the reverse, so that if `.button_side` is hovered it will hover `.button_container`. I believe with CSS it will be difficult but I would prefer it but I am open to something in JQuery. How can I do this? | 2013/09/19 | [
"https://Stackoverflow.com/questions/18896455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1339464/"
]
| This is not exactly what you are asking but probably helpful.
Sometimes is a suitable solution if you don't want to mess around with js to much.
On the other side it makes your `html` and `css` code messy. I rarely use this in some special situations (e.g. for having a hover effect for column views where the column can have a height of 100% because it should expand the row).
It does not work for older IE versions so if it is used it should be used with caution.
**HTML**
```
<div class="button_container">
<div class="inner_button">
<a href="#" class="button_text">Button</a>
</div>
<div class="button_side">
<i class="play">play</i>
<div class="hover-fake"><div>
</div>
</div>
```
**CSS**
```
.hover-fake {
position: absolute;
left: 0px;
top: 0px;
z-index: -1;
width: 100%;
height: 100%;
background: green;
display: none;
}
.button_container {
position: relative;
left: 0xp;
top: 0px;
}
.inner_button:hover {
background: red;
}
.button_container:hover > .button_side {
background-color: red !important;
}
.button_side:hover > .hover-fake {
display: block;
}
```
**[JSFiddle](http://jsfiddle.net/65yuA/)** | **I think you can do something like this (with jQuery):**
```
$(document).ready(function(){
$('.button_side').hover(function(){
$('.button_container').addClass('hover');
}, function(){
$('.button_container').removeClass('hover');
});
});
```
If you need some help, try to see this [jsfiddle](http://jsfiddle.net/59YqL/). |
27,273,911 | An app extension is causing a code signing issue. This app is already on the Appstore (with this extension) yet overnight for some reason when I have come back to this app im getting
A strange error as its contradicting itself by showing two exact identical certificates in said error message.
Ive tried
clean and restart, deleting derived data, regenerating provisioning profiles, deleting and creating new profiles. using both xcode 6.1 and xcode beta and [This](http://aplus.rs/2014/embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app/)
I have also searched SO [Xcode6:Embedded binary is not signed with the same certificate as the parent app](https://stackoverflow.com/questions/25927604/xcode6embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app) and no solutions offered worked
(Deleting the app extension removes the error) | 2014/12/03 | [
"https://Stackoverflow.com/questions/27273911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1238867/"
]
| When I had this issue I went to the Apple Member Center and realized that the Provisioning Profile (for the extension) that I had created was marked as 'Invalid'. I just re-created the Provisioning Profile with the same certificate that the app is signed with and then downloaded it via Xcode > Preferences > Account > refresh.
Once I had the new provisioning profiles I selected them in the build settings. I selected the provisioning profile that was just created and also selected the corresponding certificate in the Code signing entity in the build settings and that fixed the issue.
Note that the extension has its own app id and hence its own provisioning profile. | I had the same issue. This started on the day when my Certificate got expired after a year. Following steps worked for me:
1. Delete the old expired certificate from Keychain(You will be able to see a red cross on the certificate icon)
2. Restarting your mac |
27,273,911 | An app extension is causing a code signing issue. This app is already on the Appstore (with this extension) yet overnight for some reason when I have come back to this app im getting
A strange error as its contradicting itself by showing two exact identical certificates in said error message.
Ive tried
clean and restart, deleting derived data, regenerating provisioning profiles, deleting and creating new profiles. using both xcode 6.1 and xcode beta and [This](http://aplus.rs/2014/embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app/)
I have also searched SO [Xcode6:Embedded binary is not signed with the same certificate as the parent app](https://stackoverflow.com/questions/25927604/xcode6embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app) and no solutions offered worked
(Deleting the app extension removes the error) | 2014/12/03 | [
"https://Stackoverflow.com/questions/27273911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1238867/"
]
| My problem was that I had a Copy Files post-build step that was causing the issue (somehow).
Once I removed that Copy Files phase, this error went away.. | I had the same issue. This started on the day when my Certificate got expired after a year. Following steps worked for me:
1. Delete the old expired certificate from Keychain(You will be able to see a red cross on the certificate icon)
2. Restarting your mac |
27,273,911 | An app extension is causing a code signing issue. This app is already on the Appstore (with this extension) yet overnight for some reason when I have come back to this app im getting
A strange error as its contradicting itself by showing two exact identical certificates in said error message.
Ive tried
clean and restart, deleting derived data, regenerating provisioning profiles, deleting and creating new profiles. using both xcode 6.1 and xcode beta and [This](http://aplus.rs/2014/embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app/)
I have also searched SO [Xcode6:Embedded binary is not signed with the same certificate as the parent app](https://stackoverflow.com/questions/25927604/xcode6embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app) and no solutions offered worked
(Deleting the app extension removes the error) | 2014/12/03 | [
"https://Stackoverflow.com/questions/27273911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1238867/"
]
| I have tried the following solution is working this morning! Please try it!
>
> The only solution here was that I went to Developer Portal, removed
> all profiles, then removed all downloaded profiles through Finder, did
> Clean project and Clean Build folder, closed and re-opened Xcode.
>
>
> Then I opened my project, went to both app and extension targets - at which
> point Xcode realized no profiles are present and thus goes to
> Developer Portal to get them. Since there’s nothing to download, it
> goes through each App ID you have on your account and creates
> development profile for each one.
>
>
>
<http://aplus.rs/2014/embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app/> | I had the same issue. This started on the day when my Certificate got expired after a year. Following steps worked for me:
1. Delete the old expired certificate from Keychain(You will be able to see a red cross on the certificate icon)
2. Restarting your mac |
27,273,911 | An app extension is causing a code signing issue. This app is already on the Appstore (with this extension) yet overnight for some reason when I have come back to this app im getting
A strange error as its contradicting itself by showing two exact identical certificates in said error message.
Ive tried
clean and restart, deleting derived data, regenerating provisioning profiles, deleting and creating new profiles. using both xcode 6.1 and xcode beta and [This](http://aplus.rs/2014/embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app/)
I have also searched SO [Xcode6:Embedded binary is not signed with the same certificate as the parent app](https://stackoverflow.com/questions/25927604/xcode6embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app) and no solutions offered worked
(Deleting the app extension removes the error) | 2014/12/03 | [
"https://Stackoverflow.com/questions/27273911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1238867/"
]
| So if anyone comes across this cryptic message the "App Group" switch in Capabilities of the app extension was off for some reason. Turned it back on and all good. Fix any "issues" if it requires you to when you do this | When I had this issue I went to the Apple Member Center and realized that the Provisioning Profile (for the extension) that I had created was marked as 'Invalid'. I just re-created the Provisioning Profile with the same certificate that the app is signed with and then downloaded it via Xcode > Preferences > Account > refresh.
Once I had the new provisioning profiles I selected them in the build settings. I selected the provisioning profile that was just created and also selected the corresponding certificate in the Code signing entity in the build settings and that fixed the issue.
Note that the extension has its own app id and hence its own provisioning profile. |
27,273,911 | An app extension is causing a code signing issue. This app is already on the Appstore (with this extension) yet overnight for some reason when I have come back to this app im getting
A strange error as its contradicting itself by showing two exact identical certificates in said error message.
Ive tried
clean and restart, deleting derived data, regenerating provisioning profiles, deleting and creating new profiles. using both xcode 6.1 and xcode beta and [This](http://aplus.rs/2014/embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app/)
I have also searched SO [Xcode6:Embedded binary is not signed with the same certificate as the parent app](https://stackoverflow.com/questions/25927604/xcode6embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app) and no solutions offered worked
(Deleting the app extension removes the error) | 2014/12/03 | [
"https://Stackoverflow.com/questions/27273911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1238867/"
]
| So if anyone comes across this cryptic message the "App Group" switch in Capabilities of the app extension was off for some reason. Turned it back on and all good. Fix any "issues" if it requires you to when you do this | I had the same issue. This started on the day when my Certificate got expired after a year. Following steps worked for me:
1. Delete the old expired certificate from Keychain(You will be able to see a red cross on the certificate icon)
2. Restarting your mac |
27,273,911 | An app extension is causing a code signing issue. This app is already on the Appstore (with this extension) yet overnight for some reason when I have come back to this app im getting
A strange error as its contradicting itself by showing two exact identical certificates in said error message.
Ive tried
clean and restart, deleting derived data, regenerating provisioning profiles, deleting and creating new profiles. using both xcode 6.1 and xcode beta and [This](http://aplus.rs/2014/embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app/)
I have also searched SO [Xcode6:Embedded binary is not signed with the same certificate as the parent app](https://stackoverflow.com/questions/25927604/xcode6embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app) and no solutions offered worked
(Deleting the app extension removes the error) | 2014/12/03 | [
"https://Stackoverflow.com/questions/27273911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1238867/"
]
| My problem was that I had a Copy Files post-build step that was causing the issue (somehow).
Once I removed that Copy Files phase, this error went away.. | For me it was not having the App Groups set up correctly on all my App IDs on the Developer Portal. Therefor the App Groups in the app didn't work correctly, causing this problem. |
27,273,911 | An app extension is causing a code signing issue. This app is already on the Appstore (with this extension) yet overnight for some reason when I have come back to this app im getting
A strange error as its contradicting itself by showing two exact identical certificates in said error message.
Ive tried
clean and restart, deleting derived data, regenerating provisioning profiles, deleting and creating new profiles. using both xcode 6.1 and xcode beta and [This](http://aplus.rs/2014/embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app/)
I have also searched SO [Xcode6:Embedded binary is not signed with the same certificate as the parent app](https://stackoverflow.com/questions/25927604/xcode6embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app) and no solutions offered worked
(Deleting the app extension removes the error) | 2014/12/03 | [
"https://Stackoverflow.com/questions/27273911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1238867/"
]
| I have tried the following solution is working this morning! Please try it!
>
> The only solution here was that I went to Developer Portal, removed
> all profiles, then removed all downloaded profiles through Finder, did
> Clean project and Clean Build folder, closed and re-opened Xcode.
>
>
> Then I opened my project, went to both app and extension targets - at which
> point Xcode realized no profiles are present and thus goes to
> Developer Portal to get them. Since there’s nothing to download, it
> goes through each App ID you have on your account and creates
> development profile for each one.
>
>
>
<http://aplus.rs/2014/embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app/> | When I had this issue I went to the Apple Member Center and realized that the Provisioning Profile (for the extension) that I had created was marked as 'Invalid'. I just re-created the Provisioning Profile with the same certificate that the app is signed with and then downloaded it via Xcode > Preferences > Account > refresh.
Once I had the new provisioning profiles I selected them in the build settings. I selected the provisioning profile that was just created and also selected the corresponding certificate in the Code signing entity in the build settings and that fixed the issue.
Note that the extension has its own app id and hence its own provisioning profile. |
27,273,911 | An app extension is causing a code signing issue. This app is already on the Appstore (with this extension) yet overnight for some reason when I have come back to this app im getting
A strange error as its contradicting itself by showing two exact identical certificates in said error message.
Ive tried
clean and restart, deleting derived data, regenerating provisioning profiles, deleting and creating new profiles. using both xcode 6.1 and xcode beta and [This](http://aplus.rs/2014/embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app/)
I have also searched SO [Xcode6:Embedded binary is not signed with the same certificate as the parent app](https://stackoverflow.com/questions/25927604/xcode6embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app) and no solutions offered worked
(Deleting the app extension removes the error) | 2014/12/03 | [
"https://Stackoverflow.com/questions/27273911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1238867/"
]
| My problem was that I had a Copy Files post-build step that was causing the issue (somehow).
Once I removed that Copy Files phase, this error went away.. | What fixed this for me was:
1. Re-Logging to my accounts in Preferences -> Accounts.
2. Turning App Groups OFF in both (main app + keyboard extension) Targets (under Target -> Capabilities), then turning them back ON and re-selecting/re-checking the app groups. |
27,273,911 | An app extension is causing a code signing issue. This app is already on the Appstore (with this extension) yet overnight for some reason when I have come back to this app im getting
A strange error as its contradicting itself by showing two exact identical certificates in said error message.
Ive tried
clean and restart, deleting derived data, regenerating provisioning profiles, deleting and creating new profiles. using both xcode 6.1 and xcode beta and [This](http://aplus.rs/2014/embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app/)
I have also searched SO [Xcode6:Embedded binary is not signed with the same certificate as the parent app](https://stackoverflow.com/questions/25927604/xcode6embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app) and no solutions offered worked
(Deleting the app extension removes the error) | 2014/12/03 | [
"https://Stackoverflow.com/questions/27273911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1238867/"
]
| When I had this issue I went to the Apple Member Center and realized that the Provisioning Profile (for the extension) that I had created was marked as 'Invalid'. I just re-created the Provisioning Profile with the same certificate that the app is signed with and then downloaded it via Xcode > Preferences > Account > refresh.
Once I had the new provisioning profiles I selected them in the build settings. I selected the provisioning profile that was just created and also selected the corresponding certificate in the Code signing entity in the build settings and that fixed the issue.
Note that the extension has its own app id and hence its own provisioning profile. | For me it was not having the App Groups set up correctly on all my App IDs on the Developer Portal. Therefor the App Groups in the app didn't work correctly, causing this problem. |
27,273,911 | An app extension is causing a code signing issue. This app is already on the Appstore (with this extension) yet overnight for some reason when I have come back to this app im getting
A strange error as its contradicting itself by showing two exact identical certificates in said error message.
Ive tried
clean and restart, deleting derived data, regenerating provisioning profiles, deleting and creating new profiles. using both xcode 6.1 and xcode beta and [This](http://aplus.rs/2014/embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app/)
I have also searched SO [Xcode6:Embedded binary is not signed with the same certificate as the parent app](https://stackoverflow.com/questions/25927604/xcode6embedded-binary-is-not-signed-with-the-same-certificate-as-the-parent-app) and no solutions offered worked
(Deleting the app extension removes the error) | 2014/12/03 | [
"https://Stackoverflow.com/questions/27273911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1238867/"
]
| My problem was that I had a Copy Files post-build step that was causing the issue (somehow).
Once I removed that Copy Files phase, this error went away.. | When I had this issue I went to the Apple Member Center and realized that the Provisioning Profile (for the extension) that I had created was marked as 'Invalid'. I just re-created the Provisioning Profile with the same certificate that the app is signed with and then downloaded it via Xcode > Preferences > Account > refresh.
Once I had the new provisioning profiles I selected them in the build settings. I selected the provisioning profile that was just created and also selected the corresponding certificate in the Code signing entity in the build settings and that fixed the issue.
Note that the extension has its own app id and hence its own provisioning profile. |
125,301 | We use Apache 2.2 to host SVN repository on a Windows 2003 machine.
Works fine except that over a couple of weeks the `httpd` process inflates and starts consuming something like 1.5 gigabytes of virtual memory. All operations with the repository become very slow.
What to tweak to prevent `httpd` from cosuming so many resources? | 2010/03/23 | [
"https://serverfault.com/questions/125301",
"https://serverfault.com",
"https://serverfault.com/users/101/"
]
| APR can [slowly leak memory](http://old.nabble.com/apr-pools---memory-leaks-td19766375.html) because of the way APR pools fragment available RAM over time. If you can configure the max requests per child limit in Apache lower so the tasks will restart sooner that should mitigate the problem to an extent. The [MaxMemFree](http://httpd.apache.org/docs/current/mod/mpm_common.html#maxmemfree) directive may also be helpful, but be warned that the mailing list post suggests it doesn't work as advertised. | I use VisualSVN Server, which is a packaged Apache+SVN system and it doesn't use anywhere near this amount of RAM. I've got 12Mb virtual use right now.
However - when committing you will see the memory use rise, when the files have been committed it should drop right down again.
I'd check the access use - make sure there's no extra processes running wild in there. use ProcessExplorer from sysinternals site to see what's happening inside it. Basically, high memory use for SVN+Apache is not a normal problem. |
243,595 | Let $G$ be a group with center $Z(G)$ and let $\sim$ denote the conjugancy equivalence relation on $G$ (that is, $a \sim b$ iff $\exists g \in G$ s.t. $a = gbg^{-1}$). Finally let $[a]$ denote the conjugacy class which contains $a \in G$.
Now if $a \in Z(G)$ it is clear that $[a] = \{a\}$, for if $b = gag^{-1}$, then $b = a$ so that $[a] = \{a\}$ as desired.
Yet it is not clear to me why the converse is true (that is if $[a] = \{a\}$ that we necessarily have $a \in Z(G)$). If we assume that $[a] = \{a\}$, then clearly there exists a $g \in G$ s.t. $a = gag^{-1}$ (since $\sim$ is an equivalence relation which means $a \sim a$ $\forall a \in G$). But we cannot know that $a \in Z(G)$ until all such elements $g \in G$ satisfy this property, not merely a single one of them. How do I show this? | 2012/11/24 | [
"https://math.stackexchange.com/questions/243595",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/46072/"
]
| Note that $a=gbg^{-1}$ if and only if $b=(g^{-1})a(g^{-1})^{-1}$. Hence, if $b\in[a]$, then $b\in\{hah^{-1}:h\in G\},$ and the converse holds, as well. In other words, $[a]=\{hah^{-1}:h\in G\}$. If $[a]=\{a\}$, then $hah^{-1}=a$ for all $h\in G$, so $a\in Z(G)$. | The conjugacy class of an element is its orbit under conjugation by the whole group. In other words, the conjugacy class of $x$ is the set $\{g^{-1}xg : g \in G\}$. If this set only consists of $x$, then necessarily $g^{-1}xg =x$ for every $g\in G$. So $x\in Z(G)$. |
1,766,638 | A friend of mine gave me external hard drive and he deleted some personal files (using his computer) before he gave it to me. Few days after I plugged the HD in my PC, I saw several deleted files in my recycle bin (my PC) which originate from the HD. Thinking I accidentally deleted the files, I restored the files from my recycle bin. Can files deleted using other PC show in recycle bin of another PC? And yes, the restored files are actually timestamped at the time I restored from my PC. I am using Windows 10.
Thank you,
Amanuel | 2023/02/03 | [
"https://superuser.com/questions/1766638",
"https://superuser.com",
"https://superuser.com/users/1770021/"
]
| You might check out [QPDF](https://qpdf.readthedocs.io/en/stable/index.html) which is an open source tool to manipulate PDF files. With it you can split the file into pages, isolate particular pages, and then recombine those pages before sending the separate files to a specific printer. Or you can isolate pages based on particular properties (for example if they contain images), or by file or page length etc. It can also generate a JSON representation of the file characteristics so that you could build an algorithm to split the file based upon those characteristics using another program.
The tool can run on windows or linux machines.
In response to the comment from @MrUpsidown to my suggestion, I provide here an example shell script that takes an inputfile, and splits it up temporarily only to assess the size in bytes of each page. The split up pages are then used to create page lists of "special pages" that are big, and "regular pages" that are small, and then to create the cups lpr commands to send those pages to a printer. The script could be modified to examine each page for a text string (using e.g. pdftotext), or some other unique attribute. Anyway, one list is sent to tray Upper and the other to tray Lower. Then it cleans up after itself. The script will need tweaking to satisfy your needs, and be hardened for production use, but I think it should outline the basic method I was suggesting.
After installing qpdf on a linux machine (or mac) You run the script by creating a file (lets call it "splitpages"), then make it executable via `chmod 755`, then executing the script by invoking `splitpages filename.pdf`. It will currently just print out the commands that could be activated by replacing the "echo" with "eval" in the script. An example of executing the script like this
`splitpages samplefile.pdf`
where samplefile.pdf has 4 pages (3 normal, and the fourth special) would be for it to print out these strings
```
lpr -o media=Upper -o page-ranges=1,2,3, samplefile.pdf
lpr -o media=Lower -o page-ranges=4, samplefile.pdf
```
Of course other things need to be tweaked to suite your needs
```
#!/bin/bash
# print pages based on page size
# greater than minimumsize goes to tray1
# else goes to tray2
minimumsize=500000
infile=$1
if [ ! -f "$infile" ]; then
echo "no input file"
exit
fi
# location of temporary files used to identify page characteristics
outfile=/tmp/test
rm -f ${outfile}*
# split the file so we can assess lengths
qpdf $infile --split-pages $outfile
pnum=0
bigpage=
smallpage=
for page in ${outfile}*
do
((pnum++))
actualsize=$(wc -c <"$page")
if [ $actualsize -ge $minimumsize ]; then
#echo size is over $minimumsize bytes
bigpage="${bigpage}${pnum},"
else
#echo size is under $minimumsize bytes
smallpage="${smallpage}${pnum},"
fi
done
# replace the echo command with the eval command to actually execute the strings
lprc1="lpr -o media=Upper -o page-ranges=$bigpage $infile"
echo $lprc1
lprc2="lpr -o media=Lower -o page-ranges=$smallpage $infile"
echo $lprc2
rm -f ${outfile}*
``` | Adobe Acrobat Pro along with the
[AutoSplit Pro plug-in](https://evermap.com/AutoSplit.asp)
($149)
can do it. More information to be found in the article
[Extract Pages from a PDF Document Using a Text Search](https://evermap.com/Tutorial_ASP_ExtractPagesByTextSearch.asp).
[](https://i.stack.imgur.com/KoE8U.png)
You could also automate this yourself using document-level JavaScript
installed in one of Acrobat’s JavaScript folders and
creating an Action that executes the JavaScript.
For an example, see the article
[Extract PDF Pages Based on Content](http://khkonsulting.com/2014/04/extract-pdf-pages-based-content/). |
240,403 | My setting is what I would call "post-post-apocalyptic", meaning that our civilization doesn't exist anymore, but the collapse has happened in a past distant enough that people aren't really dealing with the direct fallouts of it anymore, or at least those aren't the story's focus. I need this setting to :
* Be technologically medieval, save for a few things like firearms – there are story-specific exceptions, but the general population in most of the world doesn't have even the notion of electricity generation ;
* Have very little to no collective memory of the old world and its history, and a very blurry/distorted memory of the collapse.
My issue is that both of those require a radical, virtually permanent knowledge loss, one that is complicated to make happen in our modern, interconnected world. For this reason, my question isn't about what exact type of collapse I should go for, but whether my focus should be "as few people left as possible without Humanity being doomed to extinction."
The idea is that going below certain figures would lead to a statistical lack of specialized individuals to operate/fix/produce modern technological items and act as teachers ; not enough people to spare from essential survival tasks and educate efficiently, let alone send to collect the knowledge still lying around ; large portions of that knowledge would gradually be lost to time as every electronic storage becomes permanently nonfunctional and books are left on their unprotected shelves to endure whatever comes their way for God knows how long. One can also assume that literacy rates would spiral down to abysmal levels, further hindering future generations' ability to retrieve any knowledge from those books on their own.
Until population recovery happens in any significant way (which I'm able to make as long as it needs to be), all those problems would only worsen until common and even "higher" knowledge stabilize around levels that we left eons ago.
So, to summarize :
* Preservation
* Transmission
* Recovery
Do you consider this a plausible way to reach the outcome that I described, or am I underestimating the resilience of our civilization when it comes to either of those three points? | 2023/01/08 | [
"https://worldbuilding.stackexchange.com/questions/240403",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/97222/"
]
| **"Can my modern society be reduced to medieval technology?" has been asked before, and the answer is always "no."**
The examples given by other authors are not from the perspective of modern society. They describe ancient peoples having had complex interdependencies — but compared to today, that simply isn't true. It's only easy to lose knowledge when:
1. Almost no one knows it, and...
2. There's almost no record of it.
**What most people don't realize is that 99% of all human technology was invented over the last 150 years**
And that's a groundswell of what I'll call "knowledge inertia" that's whomping hard to overcome if your goal is to justify a substantial reduction (pre-industrial-revolution) of general knowledge. While some of the most specialized knowledge might (might) be lost (like how to make nuclear reactors) due to lack of people to maintain the study, the vast majority of knowledge (e.g. electricity) would be very, very quickly re-established.
And then you're on a f(150\_years)(population\_growth\_to\_1.5B) or less clock to re-establish all of it.
Remember, knowledge (even advanced knowledge) is located in...
* Universities, colleges, and high school libraries
* Business and industrial centers
* Government repositories and scientific centers
* Even individual homes
And even today, a ton of it is in printed books. Rationalizing the loss of all those books for such a long time is very hard. People live in deserts. Worse, your idea about loss of specialized knowledge isn't practical. You'd be surprised how many PhDs there are in the world (some of whom are working as janitors because there aren't enough jobs for that many PhDs). Knowledge is *everywhere.*
**There isn't a realistic reason for the loss you're looking for, but that doesn't mean you can't reasonably *rationalize* why it doesn't exist**
And this is important. Many authors get caught up in trying to be "realistic." Realism in the central aspects of your story is important. Realism (or too much realism) in the back story is actually counter-productive. What you need is the proverbial one-sentence "reason" to set the story in the circumstances that you want. That "reason" should be based on some basic assumptions:
* Whatever the apocalypse, it drove people away from population centers 5,000 and above. The higher the population, the greater the taboo. This causes the vast majority of knowledge repositories to become unavailable.
* Whatever the apocalypse, it didn't result in a dry climate (perfect for preserving paper!) but a ***wet*** climate (paper rots, gets eaten by pestiferous critters). You also want a warm climate, not a cold climate. The colder it is, the easier it is to preserve the paper. This is also useful for rationalizing the destruction of vast amounts of machinery and technology. Rust is your friend when it comes to loss of knowledge. What you want if for things to *not work.*
* Whatever the apocalypse, the survivors are young. This isn't hard to rationalize. Children and young adults are remarkably resilient. As we age, we become more susceptible to disease, damage, etc. But it's us old folks that have the greater amount of *practical knowledge* in our heads. Don't get me wrong, I've spoken with 13-year-olds who have a breathtaking amount of data in their heads. But what good is it? Answer: not much. That's because they've yet to learn how to use the data (through education or life experience, doesn't matter which). They're also the most likely to forget that data because it hasn't been deeply associated with practical uses.1
* Whatever the apocalypse, the next 2-5 generations need to work like dogs to survive. Maybe this is toxic soil or toxic rain or prolific super-hyenas or whatever the reason that people have a constant and long-term struggle just to survive. The goal here is to rationalize a lack of time to pass knowledge along.
*Keep in mind that none of this would definitively explain a shift from modern tech to medieval tech. That's simply impossible. What it does is allow the reader to suspend their disbelief so they can move on to the story you're actually trying to tell.*
---
1 *While we can always find that one child who is remarkably capable, that isn't a reflection of all children. Children are amazing, but they're not small adults. That's why they can be used to rationalize loss of knowledge.* | Limited numbers is not enough
=============================
Limiting numbers can be very effective in restricting knowledge. If only a few thousand around the world are left, too few are available to maintain the technologies and knowledge. However, there is a big flaw. The time after which it takes place.
Imagine that for whatever reason all people died, except children without even having seen electricity. No knowledge remains! The problem is that the technology does. There is plenty of simple electronics surviving that people are bound to come across it and start to use it. As simple as dynamo lamps or certain batteries. With enough time to forget the history of why the apocalypse happened, it seems doubtful that any remaining technology or (written) knowledge isn't found and eventually used. Unless you're able to destroy or otherwise make unavailable any piece of technology or knowledge of electricity or similar it is highly unlikely.
Lastly, even if everything is gone, it can be found again. We discovered electricity early on and used it in time.
Does that mean it is impossible? Not at all! There are many factors that can contribute to an electricity free society that has guns. Cultural, genetic or physical are all candidates!
Cultural
--------
The post apocalyptic society could have an aversion for electricity, blaming it for the collapse of society. It can be as simple as that social media is to blame, but as social media doesn't survive they can blame any electronic device. The problem is that such things are difficult to last for generations. We vowed we would never let it come to war after WW2. A generation or two later and it seems forgotten, ignored or even celebrated in the children.
Electricity can also not be understood because of culture and it's knowledge. Electricity was known about thousands of years in varying degrees, but it took very long before it was implemented as more than a curiosity. It is unlikely in your case with their technological progress, it can simply be overlooked.
Genetics
--------
Intelligence is a complex thing. Even between humans we see huge differences in their cognitive abilities with little differences in the brain structures. From hardly able to speak to flawless twelve languages, from understanding complex math to not being able to count.
The apocalypse could've affected the genetics, hampering certain understanding. The technology can be present and guns understood, but electricity or it's potential is lost on them.
Physics
-------
The apocalypse can also have different reasons than humans. If for whatever reason the magnetosphere of the Earth is changed, or the activity and strength of the solar winds, it can cause world wide destruction of any electrical apparatus. Electricity isn't impossible, but many electronics are difficult to use on long term. If every week or year most electronics are subject to a strong EMP of the solar storms it is hard to develop them. |
240,403 | My setting is what I would call "post-post-apocalyptic", meaning that our civilization doesn't exist anymore, but the collapse has happened in a past distant enough that people aren't really dealing with the direct fallouts of it anymore, or at least those aren't the story's focus. I need this setting to :
* Be technologically medieval, save for a few things like firearms – there are story-specific exceptions, but the general population in most of the world doesn't have even the notion of electricity generation ;
* Have very little to no collective memory of the old world and its history, and a very blurry/distorted memory of the collapse.
My issue is that both of those require a radical, virtually permanent knowledge loss, one that is complicated to make happen in our modern, interconnected world. For this reason, my question isn't about what exact type of collapse I should go for, but whether my focus should be "as few people left as possible without Humanity being doomed to extinction."
The idea is that going below certain figures would lead to a statistical lack of specialized individuals to operate/fix/produce modern technological items and act as teachers ; not enough people to spare from essential survival tasks and educate efficiently, let alone send to collect the knowledge still lying around ; large portions of that knowledge would gradually be lost to time as every electronic storage becomes permanently nonfunctional and books are left on their unprotected shelves to endure whatever comes their way for God knows how long. One can also assume that literacy rates would spiral down to abysmal levels, further hindering future generations' ability to retrieve any knowledge from those books on their own.
Until population recovery happens in any significant way (which I'm able to make as long as it needs to be), all those problems would only worsen until common and even "higher" knowledge stabilize around levels that we left eons ago.
So, to summarize :
* Preservation
* Transmission
* Recovery
Do you consider this a plausible way to reach the outcome that I described, or am I underestimating the resilience of our civilization when it comes to either of those three points? | 2023/01/08 | [
"https://worldbuilding.stackexchange.com/questions/240403",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/97222/"
]
| **The answer is undoubtedly yes, because you didn't specify how small the population could be.** Obviously, if you had a population of 2, then it's simply not possible for 2 people to know 99%+ of all modern knowledge.
But I'm guessing that what you really want is a self-sustaining civilization. In other words, you don't want the population to be so small that it goes extinct. If that's the case, then you want to learn about the concept of [Minimum Viable Population](https://en.wikipedia.org/wiki/Minimum_viable_population): the smallest a population can be without a species going extinct over time.
One of the major factors is that you have to have enough DNA in the gene pool to not have inbreeding factors, over time, cause the population to become infertile. That bumps the number up to at least around 100, give or take.
But there are many other factors. The population has to be resilient to a disease or famine or natural disaster (etc) wiping out a chunk of them. There's debate as to what homo sapiens' true MVP is, but [a good guess](https://www.nbcnews.com/mach/science/how-many-humans-would-it-take-keep-our-species-alive-ncna900151) is that it's in the single-digit thousands.
So: could you have only a few thousand humans left and have mass knowledge loss?
Well, yes, depending on how you define "mass," but certainly a lot of knowledge would be lost, just from a statistical perspective alone this has to be the case:
* The population of earth right now is 7.9 billion. If 7,900 was your population size, that would mean you've lost 99.9999% of the population.
* Of any given profession, how many people would have to survive for knowledge of that profession to be passed down? Remember, it's not enough that some textbooks survived. Even assuming that your civilization is able to create printing presses, learning from unorganized, random books, without the aid of a teacher, is extremely time-consuming, and in general is not going to be a scalable way of people learning lost knowledge. Remember, your people are going to have to be spending the vast majority of their time just foraging for food, water, and protecting themselves and their food from the elements and animals, so people don't have all day to be reading books and trying to learn the hard way with no guidance (not to mention, most people don't have the proclivity for that anyway; remember only a small percentage of the population is nerds who enjoy that kind of thing).
* Of all the professions on earth, how many people have to survive in order for knowledge of their profession to get passed down? It will vary by profession. Carpentry? The answer may be as low as 5 (disclaimer: am not a carpenter). But for building computers? We're talking thousands, at a minimum. You would not believe how much specialized knowledge there is for manufacturing CPUs, let alone everything else involved. But suffice it to say, for some professions this number will be single digits, for others in the dozens, for others in the hundreds or thousands.
* And bear in mind that that many people need to be located together to share their combined knowledge. If it takes the knowledge of 2,000 people to build a CPU, it's not enough that 2,000 people survived...they have to be able to find each other and actually organize to do it.
* Ok so, given that number, what is the likelihood that that many people of that profession survived? For example, if it took 20 people who understand how to make an engine in order for that knowledge to be passed down, what are the odds that, when only .0000001% of the population survived the apocalypse, that that 7,900 people happened to include 20 people who knew how to build an engine? And those people all find each other and work together and have time for that?
**And remember, it's not just the knowledge that you need**, but also the whole supply chain and all of the resources and capabilities to extract those resources, everything that goes into making the thing, not just knowledge of how to make the thing if you were given all the materials on a silver platter.
And you have to pull off the organization of the whole thing.
Another way to look at it: you're one of the 7,900 people who survived the apocalypse. Let's say all 7,900 of you are located within a few hundred miles of each other. You're really outgoing, so you personally know 300 people. You have some knowledge of how to build an engine. You couldn't do it alone, but if you were able to get together with 20 other people who know about building engines, and you were able to convince the population to support you for many years, you could eventually start producing engines.
I say years because remember, you have to manufacture parts to make it, and that involves getting steel, and that involves forges...it wouldn't be enough for the 20 of you to be involved with trying to build engines, you would need hundreds of people at a minimum to be doing other tasks to provide you with the materials you need to build an engine.
Ok, let's say you get all of that buy-in. What are the odds that you even know 20 people, out of those 300 that you know, who have this kind of knowledge? Are 7% of your acquaintances experts in building engines? Not just that they know about it in theory, but they actually know actionable, specific details?
I think it's a good assumption that, given a population this small, the knowledge of how to build engines, as well as how to do a great many other things, would eventually die. Generating electricity is going to be hard, but possible in limited amounts. No one's going to make a full-blown power plant, but maybe some of the simpler ways of generating energy might happen in isolated areas. But without manufacturing happening, there's going to be a lot of difficulty using even that paucity of energy to make most items we're familiar with.
I think it's very plausible for you to get the end-state that you want. | Wow, lots of conflicting responses here. I'm not going to weigh in on whether or not you could break humanity this badly though. Let's ignore the naysayers and (as the slogan goes) *just do it*.
If only there were global stockpiles of explosives powerful enough to not only depopulate large parts of the globe but to smash basically every building, every port, every major infrastructure node into poisonous rubble in a matter of hours. Some sort of weaponry that assures destruction of all of the technologically advanced countries on the planet in a brief but very bright ware. (But who would be MAD enough for that?)
If we took all of those weapons and threw them at all of the tech-rich targets on the planet then all that would be left are a few million people living in wilderness areas, most of whom would die pretty darned quickly. Oh a few might ride out the aftermath for a few years in fallout shelters and such, and the resultant nuclear winter would eradicate a large chunk of the rest. The last few remaining viable populations would be people living near thermal sources and caves, and most of them would starve to death before a sustainable food crop could be located. (Probably mushrooms. I hate mushrooms.)
The first few decades would be pretty harsh. The surviving populations would be entirely focused on survival, with no remaining energy budget for anything as wateful as talking about the lost past. The survivors wouldn't have much of a past to talk about as far as your problem is concerned, since they'd almost exclusively be tribal populations who were living low-tech lives before the End. What little technology they do know about wouldn't be as important knowledge to pass on, except perhaps in cautionary tales.
When the endless winter eventually breaks and the world starts to heal, in a couple of hundred years or so, the descendants of those survivors may eventually spread out to take over the world again, with only garbled retellings of half-remembered stories about what happened. Half of the world will be closed to them due to radiation and toxicity. The parts that weren't smashed flat has fallen to corrosion and the march of time.
---
While not specifically intended for this scenario, it's on the list of considerations for the 1,700 seed vaults and data archives scattered around the world. The most famous is probably the [Svalbard Global Seed Vault](https://en.wikipedia.org/wiki/Svalbard_Global_Seed_Vault). A little less famous is the [Arctic World Archive](https://arcticworldarchive.org/) next door (relatively speaking) which claims to have a data storage medium designed to last for at least 1,000 years. If your survivors eventually dig this all up then they'll find all sorts of interesting things in there, including some of my code on GitHub. (Oh joy, future survivors are going to be shaking their head at my code too.)
At that point the whole "lost past" thing bursts back into public knowledge. Whatever society has been created, whatever technology they've built for themselves, it's all going to change radically once they unearth one of the archives. It might take them decades to understand it all, but they'll have *videos* and *audiobooks* and *cat pictures*! They'll have a full dump of Wikipedia, so they can be just as misinformed as we are! Frabjous day!
(Unless someone nukes Svalbard. At least then my code follies will be safely lost to the mists of time.) |
240,403 | My setting is what I would call "post-post-apocalyptic", meaning that our civilization doesn't exist anymore, but the collapse has happened in a past distant enough that people aren't really dealing with the direct fallouts of it anymore, or at least those aren't the story's focus. I need this setting to :
* Be technologically medieval, save for a few things like firearms – there are story-specific exceptions, but the general population in most of the world doesn't have even the notion of electricity generation ;
* Have very little to no collective memory of the old world and its history, and a very blurry/distorted memory of the collapse.
My issue is that both of those require a radical, virtually permanent knowledge loss, one that is complicated to make happen in our modern, interconnected world. For this reason, my question isn't about what exact type of collapse I should go for, but whether my focus should be "as few people left as possible without Humanity being doomed to extinction."
The idea is that going below certain figures would lead to a statistical lack of specialized individuals to operate/fix/produce modern technological items and act as teachers ; not enough people to spare from essential survival tasks and educate efficiently, let alone send to collect the knowledge still lying around ; large portions of that knowledge would gradually be lost to time as every electronic storage becomes permanently nonfunctional and books are left on their unprotected shelves to endure whatever comes their way for God knows how long. One can also assume that literacy rates would spiral down to abysmal levels, further hindering future generations' ability to retrieve any knowledge from those books on their own.
Until population recovery happens in any significant way (which I'm able to make as long as it needs to be), all those problems would only worsen until common and even "higher" knowledge stabilize around levels that we left eons ago.
So, to summarize :
* Preservation
* Transmission
* Recovery
Do you consider this a plausible way to reach the outcome that I described, or am I underestimating the resilience of our civilization when it comes to either of those three points? | 2023/01/08 | [
"https://worldbuilding.stackexchange.com/questions/240403",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/97222/"
]
| "Too few people left" is indeed a credible explanation. Small groups of surviving people struggling every day cannot pertain knowledge. A reduction in numbers alone is not the point, 1 million people maintaining a city state can save a lot of knowledge, the same number of people scattered in small tribal groups all around the world can't.
There may be additional factors like deliberate destruction of knowledge and technology: After the catastrophic events, some prophets arise and found a new religion and demand to destroy the evil writings of the past that led to the current desaster. Such events have taken place in history in the late Roman Empire after the transition to Christianity, or at the introduction of Islam in the Near East region. | Wow, lots of conflicting responses here. I'm not going to weigh in on whether or not you could break humanity this badly though. Let's ignore the naysayers and (as the slogan goes) *just do it*.
If only there were global stockpiles of explosives powerful enough to not only depopulate large parts of the globe but to smash basically every building, every port, every major infrastructure node into poisonous rubble in a matter of hours. Some sort of weaponry that assures destruction of all of the technologically advanced countries on the planet in a brief but very bright ware. (But who would be MAD enough for that?)
If we took all of those weapons and threw them at all of the tech-rich targets on the planet then all that would be left are a few million people living in wilderness areas, most of whom would die pretty darned quickly. Oh a few might ride out the aftermath for a few years in fallout shelters and such, and the resultant nuclear winter would eradicate a large chunk of the rest. The last few remaining viable populations would be people living near thermal sources and caves, and most of them would starve to death before a sustainable food crop could be located. (Probably mushrooms. I hate mushrooms.)
The first few decades would be pretty harsh. The surviving populations would be entirely focused on survival, with no remaining energy budget for anything as wateful as talking about the lost past. The survivors wouldn't have much of a past to talk about as far as your problem is concerned, since they'd almost exclusively be tribal populations who were living low-tech lives before the End. What little technology they do know about wouldn't be as important knowledge to pass on, except perhaps in cautionary tales.
When the endless winter eventually breaks and the world starts to heal, in a couple of hundred years or so, the descendants of those survivors may eventually spread out to take over the world again, with only garbled retellings of half-remembered stories about what happened. Half of the world will be closed to them due to radiation and toxicity. The parts that weren't smashed flat has fallen to corrosion and the march of time.
---
While not specifically intended for this scenario, it's on the list of considerations for the 1,700 seed vaults and data archives scattered around the world. The most famous is probably the [Svalbard Global Seed Vault](https://en.wikipedia.org/wiki/Svalbard_Global_Seed_Vault). A little less famous is the [Arctic World Archive](https://arcticworldarchive.org/) next door (relatively speaking) which claims to have a data storage medium designed to last for at least 1,000 years. If your survivors eventually dig this all up then they'll find all sorts of interesting things in there, including some of my code on GitHub. (Oh joy, future survivors are going to be shaking their head at my code too.)
At that point the whole "lost past" thing bursts back into public knowledge. Whatever society has been created, whatever technology they've built for themselves, it's all going to change radically once they unearth one of the archives. It might take them decades to understand it all, but they'll have *videos* and *audiobooks* and *cat pictures*! They'll have a full dump of Wikipedia, so they can be just as misinformed as we are! Frabjous day!
(Unless someone nukes Svalbard. At least then my code follies will be safely lost to the mists of time.) |
240,403 | My setting is what I would call "post-post-apocalyptic", meaning that our civilization doesn't exist anymore, but the collapse has happened in a past distant enough that people aren't really dealing with the direct fallouts of it anymore, or at least those aren't the story's focus. I need this setting to :
* Be technologically medieval, save for a few things like firearms – there are story-specific exceptions, but the general population in most of the world doesn't have even the notion of electricity generation ;
* Have very little to no collective memory of the old world and its history, and a very blurry/distorted memory of the collapse.
My issue is that both of those require a radical, virtually permanent knowledge loss, one that is complicated to make happen in our modern, interconnected world. For this reason, my question isn't about what exact type of collapse I should go for, but whether my focus should be "as few people left as possible without Humanity being doomed to extinction."
The idea is that going below certain figures would lead to a statistical lack of specialized individuals to operate/fix/produce modern technological items and act as teachers ; not enough people to spare from essential survival tasks and educate efficiently, let alone send to collect the knowledge still lying around ; large portions of that knowledge would gradually be lost to time as every electronic storage becomes permanently nonfunctional and books are left on their unprotected shelves to endure whatever comes their way for God knows how long. One can also assume that literacy rates would spiral down to abysmal levels, further hindering future generations' ability to retrieve any knowledge from those books on their own.
Until population recovery happens in any significant way (which I'm able to make as long as it needs to be), all those problems would only worsen until common and even "higher" knowledge stabilize around levels that we left eons ago.
So, to summarize :
* Preservation
* Transmission
* Recovery
Do you consider this a plausible way to reach the outcome that I described, or am I underestimating the resilience of our civilization when it comes to either of those three points? | 2023/01/08 | [
"https://worldbuilding.stackexchange.com/questions/240403",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/97222/"
]
| **"Can my modern society be reduced to medieval technology?" has been asked before, and the answer is always "no."**
The examples given by other authors are not from the perspective of modern society. They describe ancient peoples having had complex interdependencies — but compared to today, that simply isn't true. It's only easy to lose knowledge when:
1. Almost no one knows it, and...
2. There's almost no record of it.
**What most people don't realize is that 99% of all human technology was invented over the last 150 years**
And that's a groundswell of what I'll call "knowledge inertia" that's whomping hard to overcome if your goal is to justify a substantial reduction (pre-industrial-revolution) of general knowledge. While some of the most specialized knowledge might (might) be lost (like how to make nuclear reactors) due to lack of people to maintain the study, the vast majority of knowledge (e.g. electricity) would be very, very quickly re-established.
And then you're on a f(150\_years)(population\_growth\_to\_1.5B) or less clock to re-establish all of it.
Remember, knowledge (even advanced knowledge) is located in...
* Universities, colleges, and high school libraries
* Business and industrial centers
* Government repositories and scientific centers
* Even individual homes
And even today, a ton of it is in printed books. Rationalizing the loss of all those books for such a long time is very hard. People live in deserts. Worse, your idea about loss of specialized knowledge isn't practical. You'd be surprised how many PhDs there are in the world (some of whom are working as janitors because there aren't enough jobs for that many PhDs). Knowledge is *everywhere.*
**There isn't a realistic reason for the loss you're looking for, but that doesn't mean you can't reasonably *rationalize* why it doesn't exist**
And this is important. Many authors get caught up in trying to be "realistic." Realism in the central aspects of your story is important. Realism (or too much realism) in the back story is actually counter-productive. What you need is the proverbial one-sentence "reason" to set the story in the circumstances that you want. That "reason" should be based on some basic assumptions:
* Whatever the apocalypse, it drove people away from population centers 5,000 and above. The higher the population, the greater the taboo. This causes the vast majority of knowledge repositories to become unavailable.
* Whatever the apocalypse, it didn't result in a dry climate (perfect for preserving paper!) but a ***wet*** climate (paper rots, gets eaten by pestiferous critters). You also want a warm climate, not a cold climate. The colder it is, the easier it is to preserve the paper. This is also useful for rationalizing the destruction of vast amounts of machinery and technology. Rust is your friend when it comes to loss of knowledge. What you want if for things to *not work.*
* Whatever the apocalypse, the survivors are young. This isn't hard to rationalize. Children and young adults are remarkably resilient. As we age, we become more susceptible to disease, damage, etc. But it's us old folks that have the greater amount of *practical knowledge* in our heads. Don't get me wrong, I've spoken with 13-year-olds who have a breathtaking amount of data in their heads. But what good is it? Answer: not much. That's because they've yet to learn how to use the data (through education or life experience, doesn't matter which). They're also the most likely to forget that data because it hasn't been deeply associated with practical uses.1
* Whatever the apocalypse, the next 2-5 generations need to work like dogs to survive. Maybe this is toxic soil or toxic rain or prolific super-hyenas or whatever the reason that people have a constant and long-term struggle just to survive. The goal here is to rationalize a lack of time to pass knowledge along.
*Keep in mind that none of this would definitively explain a shift from modern tech to medieval tech. That's simply impossible. What it does is allow the reader to suspend their disbelief so they can move on to the story you're actually trying to tell.*
---
1 *While we can always find that one child who is remarkably capable, that isn't a reflection of all children. Children are amazing, but they're not small adults. That's why they can be used to rationalize loss of knowledge.* | Yes, if you just have a few hundred people left globally you wouldn't be surprised they lost a lot of knowledge.
================================================================================================================
An apocalypse bad enough to wipe out humanity to the last few hundred is bad enough that most sources of knowledge could be destroyed, and is enough that there wouldn't be many experts left. You wouldn't necessarily have many books left- if you have as few people as possible, whoever is surviving is probably at somewhere remote without any books. Those in cities probably all died, along with their books. |
240,403 | My setting is what I would call "post-post-apocalyptic", meaning that our civilization doesn't exist anymore, but the collapse has happened in a past distant enough that people aren't really dealing with the direct fallouts of it anymore, or at least those aren't the story's focus. I need this setting to :
* Be technologically medieval, save for a few things like firearms – there are story-specific exceptions, but the general population in most of the world doesn't have even the notion of electricity generation ;
* Have very little to no collective memory of the old world and its history, and a very blurry/distorted memory of the collapse.
My issue is that both of those require a radical, virtually permanent knowledge loss, one that is complicated to make happen in our modern, interconnected world. For this reason, my question isn't about what exact type of collapse I should go for, but whether my focus should be "as few people left as possible without Humanity being doomed to extinction."
The idea is that going below certain figures would lead to a statistical lack of specialized individuals to operate/fix/produce modern technological items and act as teachers ; not enough people to spare from essential survival tasks and educate efficiently, let alone send to collect the knowledge still lying around ; large portions of that knowledge would gradually be lost to time as every electronic storage becomes permanently nonfunctional and books are left on their unprotected shelves to endure whatever comes their way for God knows how long. One can also assume that literacy rates would spiral down to abysmal levels, further hindering future generations' ability to retrieve any knowledge from those books on their own.
Until population recovery happens in any significant way (which I'm able to make as long as it needs to be), all those problems would only worsen until common and even "higher" knowledge stabilize around levels that we left eons ago.
So, to summarize :
* Preservation
* Transmission
* Recovery
Do you consider this a plausible way to reach the outcome that I described, or am I underestimating the resilience of our civilization when it comes to either of those three points? | 2023/01/08 | [
"https://worldbuilding.stackexchange.com/questions/240403",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/97222/"
]
| After the fall of the Roman Empire, no pottery was made in Britain for a substantial period; losing knowledge of historical details or electricity is easy by comparison! | Wow, lots of conflicting responses here. I'm not going to weigh in on whether or not you could break humanity this badly though. Let's ignore the naysayers and (as the slogan goes) *just do it*.
If only there were global stockpiles of explosives powerful enough to not only depopulate large parts of the globe but to smash basically every building, every port, every major infrastructure node into poisonous rubble in a matter of hours. Some sort of weaponry that assures destruction of all of the technologically advanced countries on the planet in a brief but very bright ware. (But who would be MAD enough for that?)
If we took all of those weapons and threw them at all of the tech-rich targets on the planet then all that would be left are a few million people living in wilderness areas, most of whom would die pretty darned quickly. Oh a few might ride out the aftermath for a few years in fallout shelters and such, and the resultant nuclear winter would eradicate a large chunk of the rest. The last few remaining viable populations would be people living near thermal sources and caves, and most of them would starve to death before a sustainable food crop could be located. (Probably mushrooms. I hate mushrooms.)
The first few decades would be pretty harsh. The surviving populations would be entirely focused on survival, with no remaining energy budget for anything as wateful as talking about the lost past. The survivors wouldn't have much of a past to talk about as far as your problem is concerned, since they'd almost exclusively be tribal populations who were living low-tech lives before the End. What little technology they do know about wouldn't be as important knowledge to pass on, except perhaps in cautionary tales.
When the endless winter eventually breaks and the world starts to heal, in a couple of hundred years or so, the descendants of those survivors may eventually spread out to take over the world again, with only garbled retellings of half-remembered stories about what happened. Half of the world will be closed to them due to radiation and toxicity. The parts that weren't smashed flat has fallen to corrosion and the march of time.
---
While not specifically intended for this scenario, it's on the list of considerations for the 1,700 seed vaults and data archives scattered around the world. The most famous is probably the [Svalbard Global Seed Vault](https://en.wikipedia.org/wiki/Svalbard_Global_Seed_Vault). A little less famous is the [Arctic World Archive](https://arcticworldarchive.org/) next door (relatively speaking) which claims to have a data storage medium designed to last for at least 1,000 years. If your survivors eventually dig this all up then they'll find all sorts of interesting things in there, including some of my code on GitHub. (Oh joy, future survivors are going to be shaking their head at my code too.)
At that point the whole "lost past" thing bursts back into public knowledge. Whatever society has been created, whatever technology they've built for themselves, it's all going to change radically once they unearth one of the archives. It might take them decades to understand it all, but they'll have *videos* and *audiobooks* and *cat pictures*! They'll have a full dump of Wikipedia, so they can be just as misinformed as we are! Frabjous day!
(Unless someone nukes Svalbard. At least then my code follies will be safely lost to the mists of time.) |
240,403 | My setting is what I would call "post-post-apocalyptic", meaning that our civilization doesn't exist anymore, but the collapse has happened in a past distant enough that people aren't really dealing with the direct fallouts of it anymore, or at least those aren't the story's focus. I need this setting to :
* Be technologically medieval, save for a few things like firearms – there are story-specific exceptions, but the general population in most of the world doesn't have even the notion of electricity generation ;
* Have very little to no collective memory of the old world and its history, and a very blurry/distorted memory of the collapse.
My issue is that both of those require a radical, virtually permanent knowledge loss, one that is complicated to make happen in our modern, interconnected world. For this reason, my question isn't about what exact type of collapse I should go for, but whether my focus should be "as few people left as possible without Humanity being doomed to extinction."
The idea is that going below certain figures would lead to a statistical lack of specialized individuals to operate/fix/produce modern technological items and act as teachers ; not enough people to spare from essential survival tasks and educate efficiently, let alone send to collect the knowledge still lying around ; large portions of that knowledge would gradually be lost to time as every electronic storage becomes permanently nonfunctional and books are left on their unprotected shelves to endure whatever comes their way for God knows how long. One can also assume that literacy rates would spiral down to abysmal levels, further hindering future generations' ability to retrieve any knowledge from those books on their own.
Until population recovery happens in any significant way (which I'm able to make as long as it needs to be), all those problems would only worsen until common and even "higher" knowledge stabilize around levels that we left eons ago.
So, to summarize :
* Preservation
* Transmission
* Recovery
Do you consider this a plausible way to reach the outcome that I described, or am I underestimating the resilience of our civilization when it comes to either of those three points? | 2023/01/08 | [
"https://worldbuilding.stackexchange.com/questions/240403",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/97222/"
]
| Limited numbers is not enough
=============================
Limiting numbers can be very effective in restricting knowledge. If only a few thousand around the world are left, too few are available to maintain the technologies and knowledge. However, there is a big flaw. The time after which it takes place.
Imagine that for whatever reason all people died, except children without even having seen electricity. No knowledge remains! The problem is that the technology does. There is plenty of simple electronics surviving that people are bound to come across it and start to use it. As simple as dynamo lamps or certain batteries. With enough time to forget the history of why the apocalypse happened, it seems doubtful that any remaining technology or (written) knowledge isn't found and eventually used. Unless you're able to destroy or otherwise make unavailable any piece of technology or knowledge of electricity or similar it is highly unlikely.
Lastly, even if everything is gone, it can be found again. We discovered electricity early on and used it in time.
Does that mean it is impossible? Not at all! There are many factors that can contribute to an electricity free society that has guns. Cultural, genetic or physical are all candidates!
Cultural
--------
The post apocalyptic society could have an aversion for electricity, blaming it for the collapse of society. It can be as simple as that social media is to blame, but as social media doesn't survive they can blame any electronic device. The problem is that such things are difficult to last for generations. We vowed we would never let it come to war after WW2. A generation or two later and it seems forgotten, ignored or even celebrated in the children.
Electricity can also not be understood because of culture and it's knowledge. Electricity was known about thousands of years in varying degrees, but it took very long before it was implemented as more than a curiosity. It is unlikely in your case with their technological progress, it can simply be overlooked.
Genetics
--------
Intelligence is a complex thing. Even between humans we see huge differences in their cognitive abilities with little differences in the brain structures. From hardly able to speak to flawless twelve languages, from understanding complex math to not being able to count.
The apocalypse could've affected the genetics, hampering certain understanding. The technology can be present and guns understood, but electricity or it's potential is lost on them.
Physics
-------
The apocalypse can also have different reasons than humans. If for whatever reason the magnetosphere of the Earth is changed, or the activity and strength of the solar winds, it can cause world wide destruction of any electrical apparatus. Electricity isn't impossible, but many electronics are difficult to use on long term. If every week or year most electronics are subject to a strong EMP of the solar storms it is hard to develop them. | Wow, lots of conflicting responses here. I'm not going to weigh in on whether or not you could break humanity this badly though. Let's ignore the naysayers and (as the slogan goes) *just do it*.
If only there were global stockpiles of explosives powerful enough to not only depopulate large parts of the globe but to smash basically every building, every port, every major infrastructure node into poisonous rubble in a matter of hours. Some sort of weaponry that assures destruction of all of the technologically advanced countries on the planet in a brief but very bright ware. (But who would be MAD enough for that?)
If we took all of those weapons and threw them at all of the tech-rich targets on the planet then all that would be left are a few million people living in wilderness areas, most of whom would die pretty darned quickly. Oh a few might ride out the aftermath for a few years in fallout shelters and such, and the resultant nuclear winter would eradicate a large chunk of the rest. The last few remaining viable populations would be people living near thermal sources and caves, and most of them would starve to death before a sustainable food crop could be located. (Probably mushrooms. I hate mushrooms.)
The first few decades would be pretty harsh. The surviving populations would be entirely focused on survival, with no remaining energy budget for anything as wateful as talking about the lost past. The survivors wouldn't have much of a past to talk about as far as your problem is concerned, since they'd almost exclusively be tribal populations who were living low-tech lives before the End. What little technology they do know about wouldn't be as important knowledge to pass on, except perhaps in cautionary tales.
When the endless winter eventually breaks and the world starts to heal, in a couple of hundred years or so, the descendants of those survivors may eventually spread out to take over the world again, with only garbled retellings of half-remembered stories about what happened. Half of the world will be closed to them due to radiation and toxicity. The parts that weren't smashed flat has fallen to corrosion and the march of time.
---
While not specifically intended for this scenario, it's on the list of considerations for the 1,700 seed vaults and data archives scattered around the world. The most famous is probably the [Svalbard Global Seed Vault](https://en.wikipedia.org/wiki/Svalbard_Global_Seed_Vault). A little less famous is the [Arctic World Archive](https://arcticworldarchive.org/) next door (relatively speaking) which claims to have a data storage medium designed to last for at least 1,000 years. If your survivors eventually dig this all up then they'll find all sorts of interesting things in there, including some of my code on GitHub. (Oh joy, future survivors are going to be shaking their head at my code too.)
At that point the whole "lost past" thing bursts back into public knowledge. Whatever society has been created, whatever technology they've built for themselves, it's all going to change radically once they unearth one of the archives. It might take them decades to understand it all, but they'll have *videos* and *audiobooks* and *cat pictures*! They'll have a full dump of Wikipedia, so they can be just as misinformed as we are! Frabjous day!
(Unless someone nukes Svalbard. At least then my code follies will be safely lost to the mists of time.) |
240,403 | My setting is what I would call "post-post-apocalyptic", meaning that our civilization doesn't exist anymore, but the collapse has happened in a past distant enough that people aren't really dealing with the direct fallouts of it anymore, or at least those aren't the story's focus. I need this setting to :
* Be technologically medieval, save for a few things like firearms – there are story-specific exceptions, but the general population in most of the world doesn't have even the notion of electricity generation ;
* Have very little to no collective memory of the old world and its history, and a very blurry/distorted memory of the collapse.
My issue is that both of those require a radical, virtually permanent knowledge loss, one that is complicated to make happen in our modern, interconnected world. For this reason, my question isn't about what exact type of collapse I should go for, but whether my focus should be "as few people left as possible without Humanity being doomed to extinction."
The idea is that going below certain figures would lead to a statistical lack of specialized individuals to operate/fix/produce modern technological items and act as teachers ; not enough people to spare from essential survival tasks and educate efficiently, let alone send to collect the knowledge still lying around ; large portions of that knowledge would gradually be lost to time as every electronic storage becomes permanently nonfunctional and books are left on their unprotected shelves to endure whatever comes their way for God knows how long. One can also assume that literacy rates would spiral down to abysmal levels, further hindering future generations' ability to retrieve any knowledge from those books on their own.
Until population recovery happens in any significant way (which I'm able to make as long as it needs to be), all those problems would only worsen until common and even "higher" knowledge stabilize around levels that we left eons ago.
So, to summarize :
* Preservation
* Transmission
* Recovery
Do you consider this a plausible way to reach the outcome that I described, or am I underestimating the resilience of our civilization when it comes to either of those three points? | 2023/01/08 | [
"https://worldbuilding.stackexchange.com/questions/240403",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/97222/"
]
| **The answer is undoubtedly yes, because you didn't specify how small the population could be.** Obviously, if you had a population of 2, then it's simply not possible for 2 people to know 99%+ of all modern knowledge.
But I'm guessing that what you really want is a self-sustaining civilization. In other words, you don't want the population to be so small that it goes extinct. If that's the case, then you want to learn about the concept of [Minimum Viable Population](https://en.wikipedia.org/wiki/Minimum_viable_population): the smallest a population can be without a species going extinct over time.
One of the major factors is that you have to have enough DNA in the gene pool to not have inbreeding factors, over time, cause the population to become infertile. That bumps the number up to at least around 100, give or take.
But there are many other factors. The population has to be resilient to a disease or famine or natural disaster (etc) wiping out a chunk of them. There's debate as to what homo sapiens' true MVP is, but [a good guess](https://www.nbcnews.com/mach/science/how-many-humans-would-it-take-keep-our-species-alive-ncna900151) is that it's in the single-digit thousands.
So: could you have only a few thousand humans left and have mass knowledge loss?
Well, yes, depending on how you define "mass," but certainly a lot of knowledge would be lost, just from a statistical perspective alone this has to be the case:
* The population of earth right now is 7.9 billion. If 7,900 was your population size, that would mean you've lost 99.9999% of the population.
* Of any given profession, how many people would have to survive for knowledge of that profession to be passed down? Remember, it's not enough that some textbooks survived. Even assuming that your civilization is able to create printing presses, learning from unorganized, random books, without the aid of a teacher, is extremely time-consuming, and in general is not going to be a scalable way of people learning lost knowledge. Remember, your people are going to have to be spending the vast majority of their time just foraging for food, water, and protecting themselves and their food from the elements and animals, so people don't have all day to be reading books and trying to learn the hard way with no guidance (not to mention, most people don't have the proclivity for that anyway; remember only a small percentage of the population is nerds who enjoy that kind of thing).
* Of all the professions on earth, how many people have to survive in order for knowledge of their profession to get passed down? It will vary by profession. Carpentry? The answer may be as low as 5 (disclaimer: am not a carpenter). But for building computers? We're talking thousands, at a minimum. You would not believe how much specialized knowledge there is for manufacturing CPUs, let alone everything else involved. But suffice it to say, for some professions this number will be single digits, for others in the dozens, for others in the hundreds or thousands.
* And bear in mind that that many people need to be located together to share their combined knowledge. If it takes the knowledge of 2,000 people to build a CPU, it's not enough that 2,000 people survived...they have to be able to find each other and actually organize to do it.
* Ok so, given that number, what is the likelihood that that many people of that profession survived? For example, if it took 20 people who understand how to make an engine in order for that knowledge to be passed down, what are the odds that, when only .0000001% of the population survived the apocalypse, that that 7,900 people happened to include 20 people who knew how to build an engine? And those people all find each other and work together and have time for that?
**And remember, it's not just the knowledge that you need**, but also the whole supply chain and all of the resources and capabilities to extract those resources, everything that goes into making the thing, not just knowledge of how to make the thing if you were given all the materials on a silver platter.
And you have to pull off the organization of the whole thing.
Another way to look at it: you're one of the 7,900 people who survived the apocalypse. Let's say all 7,900 of you are located within a few hundred miles of each other. You're really outgoing, so you personally know 300 people. You have some knowledge of how to build an engine. You couldn't do it alone, but if you were able to get together with 20 other people who know about building engines, and you were able to convince the population to support you for many years, you could eventually start producing engines.
I say years because remember, you have to manufacture parts to make it, and that involves getting steel, and that involves forges...it wouldn't be enough for the 20 of you to be involved with trying to build engines, you would need hundreds of people at a minimum to be doing other tasks to provide you with the materials you need to build an engine.
Ok, let's say you get all of that buy-in. What are the odds that you even know 20 people, out of those 300 that you know, who have this kind of knowledge? Are 7% of your acquaintances experts in building engines? Not just that they know about it in theory, but they actually know actionable, specific details?
I think it's a good assumption that, given a population this small, the knowledge of how to build engines, as well as how to do a great many other things, would eventually die. Generating electricity is going to be hard, but possible in limited amounts. No one's going to make a full-blown power plant, but maybe some of the simpler ways of generating energy might happen in isolated areas. But without manufacturing happening, there's going to be a lot of difficulty using even that paucity of energy to make most items we're familiar with.
I think it's very plausible for you to get the end-state that you want. | "Too few people left" is indeed a credible explanation. Small groups of surviving people struggling every day cannot pertain knowledge. A reduction in numbers alone is not the point, 1 million people maintaining a city state can save a lot of knowledge, the same number of people scattered in small tribal groups all around the world can't.
There may be additional factors like deliberate destruction of knowledge and technology: After the catastrophic events, some prophets arise and found a new religion and demand to destroy the evil writings of the past that led to the current desaster. Such events have taken place in history in the late Roman Empire after the transition to Christianity, or at the introduction of Islam in the Near East region. |
240,403 | My setting is what I would call "post-post-apocalyptic", meaning that our civilization doesn't exist anymore, but the collapse has happened in a past distant enough that people aren't really dealing with the direct fallouts of it anymore, or at least those aren't the story's focus. I need this setting to :
* Be technologically medieval, save for a few things like firearms – there are story-specific exceptions, but the general population in most of the world doesn't have even the notion of electricity generation ;
* Have very little to no collective memory of the old world and its history, and a very blurry/distorted memory of the collapse.
My issue is that both of those require a radical, virtually permanent knowledge loss, one that is complicated to make happen in our modern, interconnected world. For this reason, my question isn't about what exact type of collapse I should go for, but whether my focus should be "as few people left as possible without Humanity being doomed to extinction."
The idea is that going below certain figures would lead to a statistical lack of specialized individuals to operate/fix/produce modern technological items and act as teachers ; not enough people to spare from essential survival tasks and educate efficiently, let alone send to collect the knowledge still lying around ; large portions of that knowledge would gradually be lost to time as every electronic storage becomes permanently nonfunctional and books are left on their unprotected shelves to endure whatever comes their way for God knows how long. One can also assume that literacy rates would spiral down to abysmal levels, further hindering future generations' ability to retrieve any knowledge from those books on their own.
Until population recovery happens in any significant way (which I'm able to make as long as it needs to be), all those problems would only worsen until common and even "higher" knowledge stabilize around levels that we left eons ago.
So, to summarize :
* Preservation
* Transmission
* Recovery
Do you consider this a plausible way to reach the outcome that I described, or am I underestimating the resilience of our civilization when it comes to either of those three points? | 2023/01/08 | [
"https://worldbuilding.stackexchange.com/questions/240403",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/97222/"
]
| This is not only possible, it's happened.
The last Mound-Builder culture of the Mississippi River valley collapsed after the introduction of European epidemic diseases, causing the population to decline to the point it could not maintain the chiefdoms it had consisted of. Some tribes managed to maintain legends that connect them to their ancestors, but others even lost the knowledge that the mounds they lived next to were built by human beings.
Likewise, the Bronze Age collapse meant the loss of the knowledge of how to read Linear B and Linear A -- indeed, only Linear B has been deciphered now.
And these were cultures with a lot less specialization and long-distance interdependences. It would certainly be possible for modern society. | "Too few people left" is indeed a credible explanation. Small groups of surviving people struggling every day cannot pertain knowledge. A reduction in numbers alone is not the point, 1 million people maintaining a city state can save a lot of knowledge, the same number of people scattered in small tribal groups all around the world can't.
There may be additional factors like deliberate destruction of knowledge and technology: After the catastrophic events, some prophets arise and found a new religion and demand to destroy the evil writings of the past that led to the current desaster. Such events have taken place in history in the late Roman Empire after the transition to Christianity, or at the introduction of Islam in the Near East region. |
240,403 | My setting is what I would call "post-post-apocalyptic", meaning that our civilization doesn't exist anymore, but the collapse has happened in a past distant enough that people aren't really dealing with the direct fallouts of it anymore, or at least those aren't the story's focus. I need this setting to :
* Be technologically medieval, save for a few things like firearms – there are story-specific exceptions, but the general population in most of the world doesn't have even the notion of electricity generation ;
* Have very little to no collective memory of the old world and its history, and a very blurry/distorted memory of the collapse.
My issue is that both of those require a radical, virtually permanent knowledge loss, one that is complicated to make happen in our modern, interconnected world. For this reason, my question isn't about what exact type of collapse I should go for, but whether my focus should be "as few people left as possible without Humanity being doomed to extinction."
The idea is that going below certain figures would lead to a statistical lack of specialized individuals to operate/fix/produce modern technological items and act as teachers ; not enough people to spare from essential survival tasks and educate efficiently, let alone send to collect the knowledge still lying around ; large portions of that knowledge would gradually be lost to time as every electronic storage becomes permanently nonfunctional and books are left on their unprotected shelves to endure whatever comes their way for God knows how long. One can also assume that literacy rates would spiral down to abysmal levels, further hindering future generations' ability to retrieve any knowledge from those books on their own.
Until population recovery happens in any significant way (which I'm able to make as long as it needs to be), all those problems would only worsen until common and even "higher" knowledge stabilize around levels that we left eons ago.
So, to summarize :
* Preservation
* Transmission
* Recovery
Do you consider this a plausible way to reach the outcome that I described, or am I underestimating the resilience of our civilization when it comes to either of those three points? | 2023/01/08 | [
"https://worldbuilding.stackexchange.com/questions/240403",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/97222/"
]
| This is not only possible, it's happened.
The last Mound-Builder culture of the Mississippi River valley collapsed after the introduction of European epidemic diseases, causing the population to decline to the point it could not maintain the chiefdoms it had consisted of. Some tribes managed to maintain legends that connect them to their ancestors, but others even lost the knowledge that the mounds they lived next to were built by human beings.
Likewise, the Bronze Age collapse meant the loss of the knowledge of how to read Linear B and Linear A -- indeed, only Linear B has been deciphered now.
And these were cultures with a lot less specialization and long-distance interdependences. It would certainly be possible for modern society. | Yes, if you just have a few hundred people left globally you wouldn't be surprised they lost a lot of knowledge.
================================================================================================================
An apocalypse bad enough to wipe out humanity to the last few hundred is bad enough that most sources of knowledge could be destroyed, and is enough that there wouldn't be many experts left. You wouldn't necessarily have many books left- if you have as few people as possible, whoever is surviving is probably at somewhere remote without any books. Those in cities probably all died, along with their books. |
240,403 | My setting is what I would call "post-post-apocalyptic", meaning that our civilization doesn't exist anymore, but the collapse has happened in a past distant enough that people aren't really dealing with the direct fallouts of it anymore, or at least those aren't the story's focus. I need this setting to :
* Be technologically medieval, save for a few things like firearms – there are story-specific exceptions, but the general population in most of the world doesn't have even the notion of electricity generation ;
* Have very little to no collective memory of the old world and its history, and a very blurry/distorted memory of the collapse.
My issue is that both of those require a radical, virtually permanent knowledge loss, one that is complicated to make happen in our modern, interconnected world. For this reason, my question isn't about what exact type of collapse I should go for, but whether my focus should be "as few people left as possible without Humanity being doomed to extinction."
The idea is that going below certain figures would lead to a statistical lack of specialized individuals to operate/fix/produce modern technological items and act as teachers ; not enough people to spare from essential survival tasks and educate efficiently, let alone send to collect the knowledge still lying around ; large portions of that knowledge would gradually be lost to time as every electronic storage becomes permanently nonfunctional and books are left on their unprotected shelves to endure whatever comes their way for God knows how long. One can also assume that literacy rates would spiral down to abysmal levels, further hindering future generations' ability to retrieve any knowledge from those books on their own.
Until population recovery happens in any significant way (which I'm able to make as long as it needs to be), all those problems would only worsen until common and even "higher" knowledge stabilize around levels that we left eons ago.
So, to summarize :
* Preservation
* Transmission
* Recovery
Do you consider this a plausible way to reach the outcome that I described, or am I underestimating the resilience of our civilization when it comes to either of those three points? | 2023/01/08 | [
"https://worldbuilding.stackexchange.com/questions/240403",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/97222/"
]
| Considering our modern society, I'd say it's very plausible.
If production of electricity becomes impossible during an apocalyptic event, what is left of our modern civilization?
First of all, Wikipedia and all online resources are gone forever. But at the same time food production (the raw materials as well as baked / cooked goods) and transportation become incredibly limited. How could anyone produce car fuel without electricity running machines? So very suddenly you have a huge amount of people stuck in cities that rapidly run out of food and too few people in rural areas to farm the available land without machines. Everyone is scrambling to survive and the only education people get in that scenario is what they need to survive.
Who in North America or Europe is currently able to transport large amounts of food without cars or electricity? Who even has a grain mill and oven that works without electricity? Who still knows how to preserve food without electricity? Who is able to weave and sew new clothing when the old one deteriorates? Who can smelter and/or forge metal without electric kilns?
**Ironically this would have a much bigger impact on industrial countries** relying on automation and global trade than those who have a lower level of industrial development and general education, **probably killing off huge numbers of educated people.**
Let's assume humanity manages to survive that for 1 - 2 generations and people keep books as memorials stored in their homes. Their level of literacy would probably degrade to a level where most people can comprehend "1 chicken costs 10 breads" but any book about science or engineering would be exceedingly hard to comprehend, especially if vital technical terms haven't been in use for decades and people forgot their meaning. So at that time you would need several books of increasing levels of expertise to first learn about the basic concepts and then the advanced engineering. At the same time the people who did learn all that stuff grow old and eventually die.
And let's not forget that modern bleached paper degrades much quicker than vellum, papyrus and other old types of paper you might find in a museum. After 100 years in a not ideal environment the books might be molded, eaten by bugs, or simply crumbling between the fingers of a reader.
And during all that time, the machinery still surviving the apocalypse slowly breaks down, either by disuse or overuse. If possible, people will try reverse-engineering vital machines like water pumps and cranes and rebuild them with readily available materials like wood and stone. Others like clocks will slowly rot and eventually people won't believe that this hunk of rust could once tell the time. **That is a direct equivalent of "medieval technology".**
**However, it's hard to make people completely forget the time before the apocalypse.** We know from religious texts and oral traditions like that of the Australian Aborigines that memories of certain events can survive an incredibly long time if the people deem them important enough. It's not very plausible that an event eradicates all religious elites and their knowledge and literacy from all of humanity. However, even written accounts of events long past lose more and more information. The many contemporary discussions about biblical topics like Noah's Arc or Solomon's Temple and what they actually looked like should be proof enough.
Imagine what a person in 1920 would think about our current life. People back then did theorize what the future would look like, but they imagined flying cars and life on Venus. They had no comprehension of what a "Computer" is and that you could carry a device in your pocket that lets you speak to a remote person, record moving pictures, view moving picture from all over the planet, calculate complex math formulas, translate spoken or written words and read more knowledge than a single person can possibly read in their lifetime. Accurate descriptions of our current life may still exist 100 years after the apocalypse, but they would seem just as real as aliens or high magic in novels, or maybe as real as Jesus parting the sea. | In my opinion, no, not completely. At this stage it's not possible to lose the knowledge so completely so that humanity globally slides back to some less advanced level. Barring Extinction Level Event I can't imagine such situation.
Now, please do not mistake that with complete collapse of our modern society, or even whole civilization. The fact is it is so close to collapse that it's not even funny. More specifically, we are at a stage of transitioning to a global model of technological society based on (and almost completely dependent upon) cheap and abound energy. While disrupting that transition may be catastrophic, and may well end, rather easy, any developed country in mere weeks, it will not be total.
Our globe's regions are still developed - and progress in that development - at different stages, which means somewhere there will be a strong resilience to problems that will be disastrous elsewhere.
And, to be honest, at this stage we're extremely susceptible to cascade failure, leading to collapse. There will be no access to technology, thus leading to mass die-off due to famine, disease and - of course - violence, especially in urban and suburban regions, but it will be quick enough so that some areas will be left relatively intact, and those will be the ones that can easily become self-reliant.
The only way I can imagine it happen is conjunction of several global events, impacting all regions similarly (though at different intensity). As of right now this would be, in my opinion, simultaneous: extremely powerful Solar flare, shift of the magnetosphere (flipping of the magnetic poles) and a global pandemic at the same time.
Explanation is simple: we are spread enough that pocket-sized societies will survive, and enough of them have still access to print-based knowledge that, after some initial adaptation period, people will bounce back up. Admittedly it will be locally only, but it will be enough.
Not to mention that some of those societies - i.e. small towns or large villages - are now being created with the explicit purpose of sheltering their dwellers from outside turbulences and preserving the culture. Of course, they may fail, there may be not enough of them to restore civilization, but again - barring real cosmic disaster - enough of them will survive. |
62,004,876 | I have recursive function for make map from xml
```
def get_map(groovy.xml.slurpersupport.Node Node) {
nodeRootName = Node.name()
if (Node.childNodes().size() == 0) {
return [(nodeRootName): (Node.text())]
} else {
subMap = [(nodeRootName):[]]
for (subNode in Node.childNodes()) {
subMap.nodeRootName.add(get_map(subNode))
}
return subMap
}
}
```
But I can't call function as `.add` argument.
I have error: `java.lang.NullPointerException: Cannot invoke method add() on null object`
How I can call `map.key` through a variable as key? | 2020/05/25 | [
"https://Stackoverflow.com/questions/62004876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11100757/"
]
| Try this:
```
subMap[nodeRootName].add(get_map(subNode))
``` | It only works like this subMap.(subMap.keySet()[0]).add(get\_map(subNode)) |
62,004,876 | I have recursive function for make map from xml
```
def get_map(groovy.xml.slurpersupport.Node Node) {
nodeRootName = Node.name()
if (Node.childNodes().size() == 0) {
return [(nodeRootName): (Node.text())]
} else {
subMap = [(nodeRootName):[]]
for (subNode in Node.childNodes()) {
subMap.nodeRootName.add(get_map(subNode))
}
return subMap
}
}
```
But I can't call function as `.add` argument.
I have error: `java.lang.NullPointerException: Cannot invoke method add() on null object`
How I can call `map.key` through a variable as key? | 2020/05/25 | [
"https://Stackoverflow.com/questions/62004876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11100757/"
]
| Try this:
```
subMap[nodeRootName].add(get_map(subNode))
``` | I do not know what version of Groovy you use. I can not find groovy.xml.slurpersupport.Node class in version 2.5.9. But consider moving creation map out of the **for** loop.
```
def get_map(groovy.xml.slurpersupport.Node Node) {
nodeRootName = Node.name()
if (Node.childNodes().size() == 0) {
return [(nodeRootName): (Node.text())]
} else {
list = []
for (subNode in Node.childNodes()) {
list.add(get_map(subNode))
}
return [(nodeRootName):list]
}
}
``` |
549,437 | I'm not into physics so I don't know the exact wording for this kind of things, but I do my best:
I would like to have a device which generates frequencies. These frequencies should be directed to a antenna or something similar. Is this possible to build on a home-made-basis?
Thanks in advance :-)
Kind regards,
Max | 2020/05/05 | [
"https://physics.stackexchange.com/questions/549437",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/263308/"
]
| I am assuming you are talking about transmitting a carrier frequency. Then you basically have a lot of choices: depending on the range of frequencies (e.g FM, AM, etc).
If you are interested in FM frequencies, this link does a pretty good job describing how you'd build one (<https://www.instructables.com/id/How-to-Make-FM-Transmitter/>). | What you want is called a *radio frequency signal generator*. These are tuneable across broad ranges of frequencies but usually come in several different models depending on which segment of the RF spectrum you wish to work in: low frequency (less than 500 kilohertz), medium frequency (500 kilohertz to 2 megahertz), high frequency (2 megahertz to 50 megahertz) very high frequency (50 to 150 megahertz), ultrahigh frequency (150 to 500 megahertz) are the common ranges.
These will produce an RF signal that, when connected to an antenna, will transmit a (weak) signal over a distance of several feet.
To get more range, you will need an *RF power amplifier*, but for that you will also need to be licensed by the FCC. |
16,933,973 | I am making ActionBar where is date and a button. This is my code:
```
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ActionBar actionBar = getActionBar();
String dateString = (String) android.text.format.DateFormat.format("yyyy/MM/dd", new java.util.Date());
actionBar.setTitle(dateString);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
Button add = (Button) findViewById(R.id.add);
Button edit = (Button) findViewById(R.id.edit);
Button discard = (Button) findViewById(R.id.discard);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.add:
Intent intent = new Intent(MainActivity.this, Add.class);
startActivity(intent);
break;
}
return false;
}
}
```
And a problem is that the Date appears in ActionBar but button don't. Why the button don't appear? | 2013/06/05 | [
"https://Stackoverflow.com/questions/16933973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
]
| Accessing sub-collection will be worked on,
meanwhile you can use this workaround: <http://console.neo4j.org/r/f7lmtk>
```
start n=node(*)
where has(n.name)
with collect(n.name) as names
return reduce(a=[], x in names : a + filter(y in [x] : length(a)<2)) as two_names
```
`Reduce` is used to build up the result list in the aggregator
And `filter` is used instead of the conditional `case ... when ...` which is only available in 2.0
`filter(y in [x] : length(a)<2)` returns a list with the element when the condition is true and an empty list when the condition is false
adding that result to the accumulator with `reduce` builds up the list incrementally | Be careful, the new **filter** syntax is:
filter(x IN a.array **WHERE** length(x)= 3) |
27,417,620 | What I have at hand is a text file of decent size (~ 23MB). I am reading the file line by line and extracting a few words from each line based on some external criteria. For the sake of this example, let's say each line contains at least half a dozen tab-separated values and I am picking up all except the first and the last.
I want to output the set of *unique* words obtained this way, so obviously I want to store the extracted words in a `set`. Also, since `set.update(other)` is significantly faster than looping through `other` and adding one word at a time with `set.add(elem)`, I tried doing this:
```
all_words = set()
with open(my_tsv_file) as tsv_file:
for line in tsv_file:
wordlist = based_on_some_criteria(line) # this is a list, not a set
all_words.update(wordlist)
```
And this works fine. But when I replaced `all_words.update(wordlist)` with `all_words |= wordlist`, I got the following error:
```
TypeError: unsupported operand type(s) for |=: 'set' and 'list'
```
From the documentation, I understand that `update` and `|=` are equivalent. Further, since `|=` is supposed to accept any iterable, I also confirmed by doing this:
```
import collections
isinstance(wordlist, collections.Iterable) # returns True
```
Why is the first approach using `set.update` working, but not the second one using `|=`? | 2014/12/11 | [
"https://Stackoverflow.com/questions/27417620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1011791/"
]
| >
> From the documentation, I understand that update and |= are equivalent. Further, since |= is supposed to accept any iterable...
>
>
>
From the documentation:
>
> Note, the non-operator versions of the `update()`, `intersection_update()`, `difference_update()`, and `symmetric_difference_update()` methods will accept any iterable as an argument.
>
>
>
The documentation does not seem to agree with your understanding. | `set` methods such as `update` accept arbitrary iterables, while `set` operators such as `|` and `|=` require sets.
Quoting [the documentation](https://docs.python.org/2/library/stdtypes.html#set-types-set-frozenset):
>
> Note, the non-operator versions of `union()`, `intersection()`,
> `difference()`, and `symmetric_difference()`, `issubset()`, and `issuperset()`
> methods will accept any iterable as an argument. In contrast, their
> operator based counterparts require their arguments to be sets. This
> precludes error-prone constructions like `set('abc') & 'cbs'` in favor
> of the more readable `set('abc').intersection('cbs')`.
>
>
> |
22,035,446 | I'm new to IOS development. I'm developing an app which involves downloading files and saving that to apps temp folder and I dont know how to do that my current code is given below
```
NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];
NSLog(@"%@",tmpDirURL);
NSString *myString = [tmpDirURL absoluteString];
for(int i=0;i<responseArray.count;i++){
ASIHTTPRequest *saveUrl = [ASIHTTPRequest requestWithURL:responseArray[i]];
[saveUrl setDownloadDestinationPath:myString];
[request startSynchronous];
}
NSError * error;
NSArray * directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:myString error:&error];
NSLog(@"%@",directoryContents);
```
The response array contain a list of URL for downloading files. I know something wrong with my code but I cant find out that error please help me to solve this problem | 2014/02/26 | [
"https://Stackoverflow.com/questions/22035446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1858684/"
]
| I found the solution'
```
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *htmlFilePath = [documentsDirectory stringByAppendingPathComponent:fileName];
[data writeToFile:htmlFilePath atomically:YES];
``` | When downloadDestinationPath is set, the result of this request will be downloaded to the file at this location. If downloadDestinationPath is not set, download data will be stored in memory
```
NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];
NSLog(@"%@",tmpDirURL);
NSString *myString = [tmpDirURL absoluteString];
for(int i=0;i<responseArray.count;i++){
ASIHTTPRequest *saveUrl = [ASIHTTPRequest requestWithURL:responseArray[i]];
[saveUrl setDownloadDestinationPath:[myString stringByAppendingPathComponent:[NSString stringWithFormat:@"%i",i ]]; // for each file set a new location inside tmp
[request startSynchronous];
}
NSError * error;
NSArray * directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:myString error:&error];
NSLog(@"%@",directoryContents);
``` |
29,637,762 | I swear I have included jquery in the page header, it is right there!
Nonetheless the following code, which I've included near the bottom of the page (and inline for now) gives me an error saying "TypeError: $ is not a function."
```
<script>
function displayResult(longA, latA, longB, latB, units) {
$("#distance").html(calcDist(longA, latA, longB, latB, units));
if (units=="m") {
$("#unitLabel").html("miles");
$("units").prop("selectedIndex",0);
} else {
$("#unitLabel").html("kilometers");
$("#units").prop("selectedIndex",1);
}
$("#longA").val(longA);
$("#latA").val(latA);
$("#longB").val(longB);
$("#latB").val(latB);
}
$("#calculateButton").click(function() { //This is the line it's complaining about
var longA=$("#longA").val();
var latA=$("#latA").val();
var longB=$("#longB").val();
var latB=$("#latB").val();
var units=$("#units").val();
displayResult(longA, latA, longB, latB, units);
})(jQuery);
</script>
```
Higher up in the page header I've got the following:
```
<script src="jquery.js" ></script>
<script src="calcDistSinglePage.js" ></script>
```
I'm not using Wordpress or anything, this is a very straightforward hand-coded HTML page. | 2015/04/14 | [
"https://Stackoverflow.com/questions/29637762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/845642/"
]
| Try wrapping your code in a closure (which is considered good practice anyways):
```
(function($) {
$("#calculateButton").click(function() {
// do stuff...
});
}(jQuery));
```
If this snippet still complains with the same error, there's bound to be a problem with the way you're loading the jQuery library.
Also, make sure that you don't overwrite the `$` variable in your other code. For example, inside `calcDistSinglePage.js`.
The dollar-sign is a very straight-forward javascript variable and can be reassigned to whatever you want. According to the error, `$` currently is *something* but *not* a function (otherwise you'd receive a ReferenceError stating that `$` is undefined). So probably, somewhere in your code, you've overwritten it. | You are probably linking it from a root folder that is not your HTML folder. Use an absolute path:
```
<script src="/jquery.js" ></script>
```
Or make sure `jquery.js` is in the *same* folder as your HTML. |
29,637,762 | I swear I have included jquery in the page header, it is right there!
Nonetheless the following code, which I've included near the bottom of the page (and inline for now) gives me an error saying "TypeError: $ is not a function."
```
<script>
function displayResult(longA, latA, longB, latB, units) {
$("#distance").html(calcDist(longA, latA, longB, latB, units));
if (units=="m") {
$("#unitLabel").html("miles");
$("units").prop("selectedIndex",0);
} else {
$("#unitLabel").html("kilometers");
$("#units").prop("selectedIndex",1);
}
$("#longA").val(longA);
$("#latA").val(latA);
$("#longB").val(longB);
$("#latB").val(latB);
}
$("#calculateButton").click(function() { //This is the line it's complaining about
var longA=$("#longA").val();
var latA=$("#latA").val();
var longB=$("#longB").val();
var latB=$("#latB").val();
var units=$("#units").val();
displayResult(longA, latA, longB, latB, units);
})(jQuery);
</script>
```
Higher up in the page header I've got the following:
```
<script src="jquery.js" ></script>
<script src="calcDistSinglePage.js" ></script>
```
I'm not using Wordpress or anything, this is a very straightforward hand-coded HTML page. | 2015/04/14 | [
"https://Stackoverflow.com/questions/29637762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/845642/"
]
| Try wrapping your code in a closure (which is considered good practice anyways):
```
(function($) {
$("#calculateButton").click(function() {
// do stuff...
});
}(jQuery));
```
If this snippet still complains with the same error, there's bound to be a problem with the way you're loading the jQuery library.
Also, make sure that you don't overwrite the `$` variable in your other code. For example, inside `calcDistSinglePage.js`.
The dollar-sign is a very straight-forward javascript variable and can be reassigned to whatever you want. According to the error, `$` currently is *something* but *not* a function (otherwise you'd receive a ReferenceError stating that `$` is undefined). So probably, somewhere in your code, you've overwritten it. | Make sure the **jQuery library** it's the first script you load.
Add this just before the closing `</body>` tag.
```
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-{{JQUERY_VERSION}}.min.js"><\/script>')</script>
```
* Download the file locally and inside js/vendor/ add the file.
* Replace the value {{JQUERY\_VERSION}} in the script above adding your jquery version.
Here one CDN you could use.
<https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js>
<https://code.jquery.com/jquery-2.1.3.min.js> |
29,637,762 | I swear I have included jquery in the page header, it is right there!
Nonetheless the following code, which I've included near the bottom of the page (and inline for now) gives me an error saying "TypeError: $ is not a function."
```
<script>
function displayResult(longA, latA, longB, latB, units) {
$("#distance").html(calcDist(longA, latA, longB, latB, units));
if (units=="m") {
$("#unitLabel").html("miles");
$("units").prop("selectedIndex",0);
} else {
$("#unitLabel").html("kilometers");
$("#units").prop("selectedIndex",1);
}
$("#longA").val(longA);
$("#latA").val(latA);
$("#longB").val(longB);
$("#latB").val(latB);
}
$("#calculateButton").click(function() { //This is the line it's complaining about
var longA=$("#longA").val();
var latA=$("#latA").val();
var longB=$("#longB").val();
var latB=$("#latB").val();
var units=$("#units").val();
displayResult(longA, latA, longB, latB, units);
})(jQuery);
</script>
```
Higher up in the page header I've got the following:
```
<script src="jquery.js" ></script>
<script src="calcDistSinglePage.js" ></script>
```
I'm not using Wordpress or anything, this is a very straightforward hand-coded HTML page. | 2015/04/14 | [
"https://Stackoverflow.com/questions/29637762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/845642/"
]
| Make sure the **jQuery library** it's the first script you load.
Add this just before the closing `</body>` tag.
```
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-{{JQUERY_VERSION}}.min.js"><\/script>')</script>
```
* Download the file locally and inside js/vendor/ add the file.
* Replace the value {{JQUERY\_VERSION}} in the script above adding your jquery version.
Here one CDN you could use.
<https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js>
<https://code.jquery.com/jquery-2.1.3.min.js> | You are probably linking it from a root folder that is not your HTML folder. Use an absolute path:
```
<script src="/jquery.js" ></script>
```
Or make sure `jquery.js` is in the *same* folder as your HTML. |
34,770,891 | I have a button with image.How can I localize it, in order it to have another image on different language ? | 2016/01/13 | [
"https://Stackoverflow.com/questions/34770891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4730700/"
]
| Are you loading the image from a Storyboard or programmatically?
If programmatically, then you can localise the string of the file name and have different images for each localisation. | Select the “image” in the project navigator. Next, bring up the file inspector, and locate the localization section, in which you’ll see a button named “*Localize…*”. Click the button and you’ll be prompted for confirmation. Choose English and click the “Localize” button to confirm.
[](https://i.stack.imgur.com/xaFy4.png)
[](https://i.stack.imgur.com/U8RGi.png)
[](https://i.stack.imgur.com/rsSNF.png)
Switch back to the finder and local the project directory. You’ll find two folders: `en.lproj` and `Base.lproj`. Both folders are automatically generated by Xcode for localization. The `en.lproj` folder stores resource files for English localization,If you localise for french language too, then `fr.lproj` folder will be added and is for French localization. If you look into both folders, each one contains the image file. Download the French version of the cover image from here (or use whatever image you like). Copy the cover image just downloaded and replace the one in `fr.lproj` folder. |
34,770,891 | I have a button with image.How can I localize it, in order it to have another image on different language ? | 2016/01/13 | [
"https://Stackoverflow.com/questions/34770891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4730700/"
]
| Are you loading the image from a Storyboard or programmatically?
If programmatically, then you can localise the string of the file name and have different images for each localisation. | If your image is not in an xcassets you can localize it in the file inspector.
If you image is in an xcassets, you can include the language identifier in its name, or as @jdapps said, localize the image name in a strings file. |
34,770,891 | I have a button with image.How can I localize it, in order it to have another image on different language ? | 2016/01/13 | [
"https://Stackoverflow.com/questions/34770891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4730700/"
]
| Are you loading the image from a Storyboard or programmatically?
If programmatically, then you can localise the string of the file name and have different images for each localisation. | You can add localized names for your images to Localizable.strings file and use "NSLocalizedString(key: String, comment: String)" method to access it. Works great for me. |
34,770,891 | I have a button with image.How can I localize it, in order it to have another image on different language ? | 2016/01/13 | [
"https://Stackoverflow.com/questions/34770891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4730700/"
]
| If your image is not in an xcassets you can localize it in the file inspector.
If you image is in an xcassets, you can include the language identifier in its name, or as @jdapps said, localize the image name in a strings file. | Select the “image” in the project navigator. Next, bring up the file inspector, and locate the localization section, in which you’ll see a button named “*Localize…*”. Click the button and you’ll be prompted for confirmation. Choose English and click the “Localize” button to confirm.
[](https://i.stack.imgur.com/xaFy4.png)
[](https://i.stack.imgur.com/U8RGi.png)
[](https://i.stack.imgur.com/rsSNF.png)
Switch back to the finder and local the project directory. You’ll find two folders: `en.lproj` and `Base.lproj`. Both folders are automatically generated by Xcode for localization. The `en.lproj` folder stores resource files for English localization,If you localise for french language too, then `fr.lproj` folder will be added and is for French localization. If you look into both folders, each one contains the image file. Download the French version of the cover image from here (or use whatever image you like). Copy the cover image just downloaded and replace the one in `fr.lproj` folder. |
34,770,891 | I have a button with image.How can I localize it, in order it to have another image on different language ? | 2016/01/13 | [
"https://Stackoverflow.com/questions/34770891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4730700/"
]
| You can add localized names for your images to Localizable.strings file and use "NSLocalizedString(key: String, comment: String)" method to access it. Works great for me. | Select the “image” in the project navigator. Next, bring up the file inspector, and locate the localization section, in which you’ll see a button named “*Localize…*”. Click the button and you’ll be prompted for confirmation. Choose English and click the “Localize” button to confirm.
[](https://i.stack.imgur.com/xaFy4.png)
[](https://i.stack.imgur.com/U8RGi.png)
[](https://i.stack.imgur.com/rsSNF.png)
Switch back to the finder and local the project directory. You’ll find two folders: `en.lproj` and `Base.lproj`. Both folders are automatically generated by Xcode for localization. The `en.lproj` folder stores resource files for English localization,If you localise for french language too, then `fr.lproj` folder will be added and is for French localization. If you look into both folders, each one contains the image file. Download the French version of the cover image from here (or use whatever image you like). Copy the cover image just downloaded and replace the one in `fr.lproj` folder. |
19,240,001 | My unit tests use the `main` entry point in each of my Java classes. I'm using Eclipse. It's been risky to rely on the test results because sometimes I've forgotten to set `-enableassertions` in the JVM arguments. Is there a universal setting that applies to all current and future `Run Configurations`? | 2013/10/08 | [
"https://Stackoverflow.com/questions/19240001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/427155/"
]
| To make assertions enabled by default, first go to the Eclipse menu named `Window` because Eclipse is a GUI application so it seems to be an excellent reason to put it in a menu called "Window".
Window > Preferences > Java > Installed JREs
Select the JRE that you use.
Click `Edit`. Add to the `Default VM Arguments` textbox the option `-enableassertions`. Click `Apply` if necessary.
Now, even without enabling assertions in the launch configuration, which seems to be synonymous with run configuration, programs run in Eclipse will have assertions enabled. | Use [junit's assertion](http://junit.sourceforge.net/javadoc/org/junit/Assert.html) instead
---
Also See
* [assert vs. JUnit Assertions](https://stackoverflow.com/questions/2966347/assert-vs-junit-assertions) |
19,240,001 | My unit tests use the `main` entry point in each of my Java classes. I'm using Eclipse. It's been risky to rely on the test results because sometimes I've forgotten to set `-enableassertions` in the JVM arguments. Is there a universal setting that applies to all current and future `Run Configurations`? | 2013/10/08 | [
"https://Stackoverflow.com/questions/19240001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/427155/"
]
| To make assertions enabled by default, first go to the Eclipse menu named `Window` because Eclipse is a GUI application so it seems to be an excellent reason to put it in a menu called "Window".
Window > Preferences > Java > Installed JREs
Select the JRE that you use.
Click `Edit`. Add to the `Default VM Arguments` textbox the option `-enableassertions`. Click `Apply` if necessary.
Now, even without enabling assertions in the launch configuration, which seems to be synonymous with run configuration, programs run in Eclipse will have assertions enabled. | Please don't use the Java `assert` in unit tests.
This kind of assertion can be disabled because it is not intended to be used in unit tests at all. This assert only helps you to ensure some conditions at runtime of your actual code. Unit tests are different and done with special means as like [JUnit](http://junit.org/)
There are plenty good ressources to learn about proper unit testing, I would like to propose [this](http://www.vogella.com/articles/JUnit/article.html) as a possible starting point. |
31,355 | This maybe a very general question.
If we have a group given by its presentation only, what kind of properties could be proven about it?
I know examples about non-amenability of some Burnside groups.
What kind of examples are there in literature where one proves some property "just" from a presentation? | 2010/07/11 | [
"https://mathoverflow.net/questions/31355",
"https://mathoverflow.net",
"https://mathoverflow.net/users/7307/"
]
| *Almost nothing* can **reliably** be said about a group just from a presentation **in finite time**. (In fact, the abelianisation is just about the only thing one can reliably compute.) Most strikingly, there is no algorithm to recognise whether a given presentation represents the trivial group. More generally, one cannot in general solve 'the word problem' - ie, there is no algorithm to determine whether a given element is non-trivial. See [Chuck Miller's survey article](http://www.ms.unimelb.edu.au/~cfm/papers/paperpdfs/msri_survey.all.pdf) for details.
(**Update.** I inserted the word 'reliably' above in deference to Joel David Hamkins' fair comment. (**Update 2.** I then inserted the phrase 'in finite time' to be strictly correct, in an effort to head off further argument.) It is true that, in many special cases, there is information that can be read off from a specific presentation. This is more or less the topic of combinatorial group theory! But I want to emphasise that you can do nothing with an arbitrary presentation.)
On the other hand, there is a growing realisation that, surprisingly, if one is given a solution to the word problem (by an oracle, say) then one can compute quite a lot of information. Daniel Groves and I proved that, in these circumstances, one can determine whether the group in question is free. [Nicholas Touikan](http://arxiv.org/abs/0906.3902) generalised this to show that one cam compute the [Grushko decomposition](http://en.wikipedia.org/wiki/Grushko_theorem#Grushko_decomposition_theorem). | Quite a lot, I believe (although `a lot' is subjective).
A neat example of a property which can be read immediately off of a (finite) presentation $\langle X; R \rangle$ is the Deficiency of said presentation. This is defined to be $|X|-|R|$. Now, this contain some intriguing properties. For example, every group of deficiency greater than 2 is large (it has a finite-index subgroup which contains a homomorphism onto a non-abelian free group), while every group of deficiency 1 is infinite and if a deficiency 1 presentation has a relator which is a proper power then this group too is large.
Also, the word, conjugacy, etc. problems for presentations is an intriguing topic. |
31,355 | This maybe a very general question.
If we have a group given by its presentation only, what kind of properties could be proven about it?
I know examples about non-amenability of some Burnside groups.
What kind of examples are there in literature where one proves some property "just" from a presentation? | 2010/07/11 | [
"https://mathoverflow.net/questions/31355",
"https://mathoverflow.net",
"https://mathoverflow.net/users/7307/"
]
| Quite a lot, I believe (although `a lot' is subjective).
A neat example of a property which can be read immediately off of a (finite) presentation $\langle X; R \rangle$ is the Deficiency of said presentation. This is defined to be $|X|-|R|$. Now, this contain some intriguing properties. For example, every group of deficiency greater than 2 is large (it has a finite-index subgroup which contains a homomorphism onto a non-abelian free group), while every group of deficiency 1 is infinite and if a deficiency 1 presentation has a relator which is a proper power then this group too is large.
Also, the word, conjugacy, etc. problems for presentations is an intriguing topic. | Continuing the idea that working with bare presentations is "hard", automatic groups sometimes can give you a handle, if you're trying to study a specific group . [Automatic groups](http://en.wikipedia.org/wiki/Automatic_group) are groups with finite state machines that can, essentially, solve the word problem for that group.
If you're studying a particular group and are lucky, a procedure such as Knuth-Bendix can compute an automatic structure for you. Then lots of hard computations become easy (e.g. the order of the group).
Magma has some of these algorithms implemented, see [this Magma documentation page](http://magma.maths.usyd.edu.au/magma/htmlhelp/text869.htm). |
31,355 | This maybe a very general question.
If we have a group given by its presentation only, what kind of properties could be proven about it?
I know examples about non-amenability of some Burnside groups.
What kind of examples are there in literature where one proves some property "just" from a presentation? | 2010/07/11 | [
"https://mathoverflow.net/questions/31355",
"https://mathoverflow.net",
"https://mathoverflow.net/users/7307/"
]
| *Almost nothing* can **reliably** be said about a group just from a presentation **in finite time**. (In fact, the abelianisation is just about the only thing one can reliably compute.) Most strikingly, there is no algorithm to recognise whether a given presentation represents the trivial group. More generally, one cannot in general solve 'the word problem' - ie, there is no algorithm to determine whether a given element is non-trivial. See [Chuck Miller's survey article](http://www.ms.unimelb.edu.au/~cfm/papers/paperpdfs/msri_survey.all.pdf) for details.
(**Update.** I inserted the word 'reliably' above in deference to Joel David Hamkins' fair comment. (**Update 2.** I then inserted the phrase 'in finite time' to be strictly correct, in an effort to head off further argument.) It is true that, in many special cases, there is information that can be read off from a specific presentation. This is more or less the topic of combinatorial group theory! But I want to emphasise that you can do nothing with an arbitrary presentation.)
On the other hand, there is a growing realisation that, surprisingly, if one is given a solution to the word problem (by an oracle, say) then one can compute quite a lot of information. Daniel Groves and I proved that, in these circumstances, one can determine whether the group in question is free. [Nicholas Touikan](http://arxiv.org/abs/0906.3902) generalised this to show that one cam compute the [Grushko decomposition](http://en.wikipedia.org/wiki/Grushko_theorem#Grushko_decomposition_theorem). | If you have a *finite* presentation of a group $G$, then you can easily derive its abelianization $G^{ab}$ from that, by standard techniques: Basically, you create an integer matrix, with one column for each generator, and one row for each relation, noting in entry $a\_{ij}$ how often the generator $g\_j$ occurred in the relator $r\_i$. Then, compute the Smith normal form of this and you can read of the isomorphism type of $G^{ab}$.
If this happens to be non-trivial, you immediately have a proof that your group is non-trivial. Of course, the converse fails. |
31,355 | This maybe a very general question.
If we have a group given by its presentation only, what kind of properties could be proven about it?
I know examples about non-amenability of some Burnside groups.
What kind of examples are there in literature where one proves some property "just" from a presentation? | 2010/07/11 | [
"https://mathoverflow.net/questions/31355",
"https://mathoverflow.net",
"https://mathoverflow.net/users/7307/"
]
| If you have a *finite* presentation of a group $G$, then you can easily derive its abelianization $G^{ab}$ from that, by standard techniques: Basically, you create an integer matrix, with one column for each generator, and one row for each relation, noting in entry $a\_{ij}$ how often the generator $g\_j$ occurred in the relator $r\_i$. Then, compute the Smith normal form of this and you can read of the isomorphism type of $G^{ab}$.
If this happens to be non-trivial, you immediately have a proof that your group is non-trivial. Of course, the converse fails. | Continuing the idea that working with bare presentations is "hard", automatic groups sometimes can give you a handle, if you're trying to study a specific group . [Automatic groups](http://en.wikipedia.org/wiki/Automatic_group) are groups with finite state machines that can, essentially, solve the word problem for that group.
If you're studying a particular group and are lucky, a procedure such as Knuth-Bendix can compute an automatic structure for you. Then lots of hard computations become easy (e.g. the order of the group).
Magma has some of these algorithms implemented, see [this Magma documentation page](http://magma.maths.usyd.edu.au/magma/htmlhelp/text869.htm). |
31,355 | This maybe a very general question.
If we have a group given by its presentation only, what kind of properties could be proven about it?
I know examples about non-amenability of some Burnside groups.
What kind of examples are there in literature where one proves some property "just" from a presentation? | 2010/07/11 | [
"https://mathoverflow.net/questions/31355",
"https://mathoverflow.net",
"https://mathoverflow.net/users/7307/"
]
| *Almost nothing* can **reliably** be said about a group just from a presentation **in finite time**. (In fact, the abelianisation is just about the only thing one can reliably compute.) Most strikingly, there is no algorithm to recognise whether a given presentation represents the trivial group. More generally, one cannot in general solve 'the word problem' - ie, there is no algorithm to determine whether a given element is non-trivial. See [Chuck Miller's survey article](http://www.ms.unimelb.edu.au/~cfm/papers/paperpdfs/msri_survey.all.pdf) for details.
(**Update.** I inserted the word 'reliably' above in deference to Joel David Hamkins' fair comment. (**Update 2.** I then inserted the phrase 'in finite time' to be strictly correct, in an effort to head off further argument.) It is true that, in many special cases, there is information that can be read off from a specific presentation. This is more or less the topic of combinatorial group theory! But I want to emphasise that you can do nothing with an arbitrary presentation.)
On the other hand, there is a growing realisation that, surprisingly, if one is given a solution to the word problem (by an oracle, say) then one can compute quite a lot of information. Daniel Groves and I proved that, in these circumstances, one can determine whether the group in question is free. [Nicholas Touikan](http://arxiv.org/abs/0906.3902) generalised this to show that one cam compute the [Grushko decomposition](http://en.wikipedia.org/wiki/Grushko_theorem#Grushko_decomposition_theorem). | Continuing the idea that working with bare presentations is "hard", automatic groups sometimes can give you a handle, if you're trying to study a specific group . [Automatic groups](http://en.wikipedia.org/wiki/Automatic_group) are groups with finite state machines that can, essentially, solve the word problem for that group.
If you're studying a particular group and are lucky, a procedure such as Knuth-Bendix can compute an automatic structure for you. Then lots of hard computations become easy (e.g. the order of the group).
Magma has some of these algorithms implemented, see [this Magma documentation page](http://magma.maths.usyd.edu.au/magma/htmlhelp/text869.htm). |
31,355 | This maybe a very general question.
If we have a group given by its presentation only, what kind of properties could be proven about it?
I know examples about non-amenability of some Burnside groups.
What kind of examples are there in literature where one proves some property "just" from a presentation? | 2010/07/11 | [
"https://mathoverflow.net/questions/31355",
"https://mathoverflow.net",
"https://mathoverflow.net/users/7307/"
]
| *Almost nothing* can **reliably** be said about a group just from a presentation **in finite time**. (In fact, the abelianisation is just about the only thing one can reliably compute.) Most strikingly, there is no algorithm to recognise whether a given presentation represents the trivial group. More generally, one cannot in general solve 'the word problem' - ie, there is no algorithm to determine whether a given element is non-trivial. See [Chuck Miller's survey article](http://www.ms.unimelb.edu.au/~cfm/papers/paperpdfs/msri_survey.all.pdf) for details.
(**Update.** I inserted the word 'reliably' above in deference to Joel David Hamkins' fair comment. (**Update 2.** I then inserted the phrase 'in finite time' to be strictly correct, in an effort to head off further argument.) It is true that, in many special cases, there is information that can be read off from a specific presentation. This is more or less the topic of combinatorial group theory! But I want to emphasise that you can do nothing with an arbitrary presentation.)
On the other hand, there is a growing realisation that, surprisingly, if one is given a solution to the word problem (by an oracle, say) then one can compute quite a lot of information. Daniel Groves and I proved that, in these circumstances, one can determine whether the group in question is free. [Nicholas Touikan](http://arxiv.org/abs/0906.3902) generalised this to show that one cam compute the [Grushko decomposition](http://en.wikipedia.org/wiki/Grushko_theorem#Grushko_decomposition_theorem). | Given a group $\Gamma$ which you are interested in, given by a presentation, and an easy group $G$ which you understand (a dihedral group or a symmetric group, maybe), you can often use the presentation to determine whether or not there exists a surjective homomorphism $\Gamma\to G$, and maybe you can even count them. This is a strong tool for showing that two given presentations give rise to different groups, and for showing that your group must be "at least as complicated" as $G$. For instance, Tietze originally proved in 1908 that the trefoil is knotted by exhibiting a surjection from a Wirtinger presentation of the fundamental group of its complement onto the symmetric group $S\_3$, while the fundamental group of the unknot is abelian and so can admit no such homomorphism. |
31,355 | This maybe a very general question.
If we have a group given by its presentation only, what kind of properties could be proven about it?
I know examples about non-amenability of some Burnside groups.
What kind of examples are there in literature where one proves some property "just" from a presentation? | 2010/07/11 | [
"https://mathoverflow.net/questions/31355",
"https://mathoverflow.net",
"https://mathoverflow.net/users/7307/"
]
| Given a group $\Gamma$ which you are interested in, given by a presentation, and an easy group $G$ which you understand (a dihedral group or a symmetric group, maybe), you can often use the presentation to determine whether or not there exists a surjective homomorphism $\Gamma\to G$, and maybe you can even count them. This is a strong tool for showing that two given presentations give rise to different groups, and for showing that your group must be "at least as complicated" as $G$. For instance, Tietze originally proved in 1908 that the trefoil is knotted by exhibiting a surjection from a Wirtinger presentation of the fundamental group of its complement onto the symmetric group $S\_3$, while the fundamental group of the unknot is abelian and so can admit no such homomorphism. | Continuing the idea that working with bare presentations is "hard", automatic groups sometimes can give you a handle, if you're trying to study a specific group . [Automatic groups](http://en.wikipedia.org/wiki/Automatic_group) are groups with finite state machines that can, essentially, solve the word problem for that group.
If you're studying a particular group and are lucky, a procedure such as Knuth-Bendix can compute an automatic structure for you. Then lots of hard computations become easy (e.g. the order of the group).
Magma has some of these algorithms implemented, see [this Magma documentation page](http://magma.maths.usyd.edu.au/magma/htmlhelp/text869.htm). |
63,928,658 | I have two functions. One that creates a multiplication table of a given number and the other function prints the array out. Below is my code:
Here's the error (***Line 18***):
```
expression must be a pointer to a complete object type
```
How do I fix this error and print the array? Also, I don't know how to print a new line after every row.
```
#include "multiplication.h"
#include <stdio.h>
int arr[][];
void mulitpication(int num){
/* initialize array and build*/
int arr[num][num];
for(int i=0; i<num;i++){
for(int j=0;j<num;j++){
arr[i][j]= (i+1)*(j+1);
}
}
}
void print(int arr[][]){
/* print the arr*/
int i;
for(i=0;i<sizeof(arr);i++){
for(int j=0;j<sizeof(arr);j++){
printf("%d ",arr[i][j])**(line 18)**;
}
}
}
``` | 2020/09/16 | [
"https://Stackoverflow.com/questions/63928658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12207989/"
]
| If using C99 or later with VLA support, pass into the print function the dimensions needed.
```
// void print(int arr[][]){
void print(size_t rows, size_t cols, int arr[row][col]){
size_t r,c;
for (size_t r = 0; r < rows; r++) {
for (size_t c = 0; c < cols; c++) {
printf("%d ",arr[r][c]);
}
printf("\n");
}
}
``` | You need to declare the array in `main()`, so it can be passed to both functions.
When an array is passed as a function parameter, it just passes a pointer. You need to pass the array dimensions, they can't be determined using `sizeof`.
To get each row of the table on a new line, put `printf("\n");` after the loop that prints a row.
```
#include <stdio.h>
void multiplication(int num, arr[num][num]){
/* initialize array and build*/
for(int i=0; i<num;i++){
for(int j=0;j<num;j++){
arr[i][j]= (i+1)*(j+1);
}
}
}
void print(int num, int arr[num][num]){
/* print the arr*/
int i;
for(i=0;i<num;i++){
for(int j=0;j<num;j++){
printf("%d ",arr[i][j]);
}
printf("\n");
}
}
int main(void) {
int size;
printf("How big is the multiplication table? ");
scanf("%d", &size);
int arr[size][size];
multiplication(size, arr);
print(size, arr);
return 0;
}
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.