qid int64 10 74.7M | question stringlengths 15 26.2k | date stringlengths 10 10 | metadata list | response_j stringlengths 27 28.1k | response_k stringlengths 23 26.8k |
|---|---|---|---|---|---|
26,155 | (Related: [Warfare without Metal](https://worldbuilding.stackexchange.com/q/11042/9498))
In my setting, metals (including common metals such as tin and iron) are a rare commodity. Because of this, humans have to make weapons such as firearms (guns) with other resources.
In order to get to the level of technology that... | 2015/09/22 | [
"https://worldbuilding.stackexchange.com/questions/26155",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/9498/"
] | For single shot "zip gun" type weapons, almost any material can do. Indeed, with the restrictions given, it is difficult to imagine a firearm in the sense that we know today as being possible.
To make a modern "repeating" firearm, the challenge is multifold. The chamber needs to contain high pressures and high tempera... | The answer would depend heavily on how gun like you want your non-metal guns to be. The Hwacha (the MythBusters did an episode on It) looks like a good starting point for a non metal gun, reducing the size of the arrows, and developing an automatic reloading system. It might look something like the Gyrojet guns develop... |
45,524,174 | I want my app to invoke a lambda function. The lambda function should create an instance of a lambda function, make the instance a sort of a cron job which runs every hour for upto N times (N = 1000), and pass event keys to the lambda function.
The pseudocode for the lambda function which does the bulk of the work is:... | 2017/08/05 | [
"https://Stackoverflow.com/questions/45524174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/558972/"
] | This
```
var my_var = <?php echo json_encode($title); ?>;
```
evaluates to:
```
var my_var = sometitle;
```
and *sometitle* is probably not defined. You want it to be a string:
```
var my_var = "<?php echo json_encode($title); ?>";
``` | That is because `my_var` is not being treated as a placeholder for a `string`. Instead, my\_var is being treated as a place holder for another variable named `<?php echo json_encode($title); ?>`. Make the following change and everything should work:
```
var my_var = "<?php echo json_encode($title); ?>";
var url = "//... |
10,144,462 | I'm by no means a java programmer, so this may seem pretty basic.
Which of these are 'better' when you want to keep your code lines short.
```
String str = "First part of a string.";
str += " Second part of string.";
```
or
```
String str = "First part of string." +
" Second part of string."
```
I guess my que... | 2012/04/13 | [
"https://Stackoverflow.com/questions/10144462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/799858/"
] | I prefer the 2nd method. The reason is that the compiler will likely combine the result of the concatenation into a single string at compile time while the 1st method may be done at run-time (depending on the actual implemention.) It's a small thing unless you're doing something millions of times, however. | Following Java's coding conventions:
```
String str = "First part of string. "
+ "Second part of string.";
```
Make sure the '+' operator begins the next line this improves readability.
Using this style allows for readable and efficient code.
<https://www.oracle.com/technetwork/java/javase/documentation... |
8,611,816 | In my Show User page, I want to add a link to an external website with some values saved in the table passed as parameters.
I got the first part working right, that's simple.
```
<%= link_to "Outside Site", "http://outsidesite.com/create" %>
```
But I also want to pass some paramaters which are saved in the databas... | 2011/12/23 | [
"https://Stackoverflow.com/questions/8611816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1053709/"
] | You can write the helper method such as url patern. You can check the code bellow:
```
def generate_url(url, params = {})
uri = URI(url)
uri.query = params.to_query
uri.to_s
end
```
After that, you can call the helper method like:
```
generate_url("YOUR-URL-ADDR-HERE", :param1 => "first", :param2 =>... | Because rails don't know how the website want it's paramteres, I think you must do it with string concatenation. At least, you can write a helper to do this for you but will just become a string concatenation in the end. |
19,574,643 | I've been struggling for a while with this one. I have a Rails4/Devise 3.1 app with two users in the system:
1. Graduates
2. Employers
and one devise User who can be either a Graduate or Employer via a polymorphic `:profile` association. I have Graduates sign up via `/graduate/sign_up` path and employers via `/emplo... | 2013/10/24 | [
"https://Stackoverflow.com/questions/19574643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2619188/"
] | [Apparently](http://bendyworks.com/blog/respond-with-an-explanation), the `:location` parameter is ignored if you have an existing template called, well, in this case, #index. I still don't understand why Devise redirects to #index or #show when the resource has errors on it.
I'll update this answer as I find out more... | Calling `respond_with` will render the default action of that resource. This I believe is the `index` action (/users/) and thus the cause for the redirect.
I think what you want to do is render the `new` action instead. Try the following:
```
if resource.save
...
else
clean_up_passwords(resource)
render :action... |
7,893,128 | I have a char array that is really used as a byte array and not for storing text. In the array, there are two specific bytes that represent a numeric value that I need to store into an unsigned int value. The code below explains the setup.
```
char* bytes = bytes[2];
bytes[0] = 0x0C; // For the sake of this example, I... | 2011/10/25 | [
"https://Stackoverflow.com/questions/7893128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/469319/"
] | ```
unsigned int val = (unsigned char)bytes[0] << CHAR_BIT | (unsigned char)bytes[1];
```
This if `sizeof(unsigned int) >= 2 * sizeof(unsigned char)` (not something guaranteed by the C standard)
Now... The interesting things here is surely the order of operators (in many years still I can remember only `+, -, * and ... | ```
unsigned int val = bytes[0] << 8 + bytes[1];
``` |
25,946,407 | In ios8 delegate methods of UIActionSheet calling multiple times
```
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
```
I have checked in ipad 2 with IOS 8 | 2014/09/20 | [
"https://Stackoverflow.com/questions/25946407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2401215/"
] | Its a bug of the ios 8..
As the @rob said `UIActionSheet` is deprecated in iOS 8. (UIActionSheetDelegate is also deprecated.)
To create and manage action sheets in iOS 8 and later, use `UIAlertController` | If you want to continue using the existing API, there is a bit of behavior that lets you know when to run your code and when to ignore the delegate call - the `buttonIndex`.
The first time the delegate methods are called, they are always passed the correct `buttonIndex`. The second time through, however, they are call... |
27,877,498 | I have 2 columns in my table in sql server – [Occurrence Time (NT)] and [Clearance Time(NT)] having the format yyyy-mm-dd hh:mm:ss and a third column [Outage Duration] with the format hh:mm:ss
[Identifier] | [Occurrence Time(NT)] | [Clearance Time(NT)] | [Outage Duration]
4 | 2014-12-28 15:06:33.000 | 2014-12-28 15:1... | 2015/01/10 | [
"https://Stackoverflow.com/questions/27877498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4440075/"
] | you need to use `datediff` function.
First find the `difference` in `seconds` between the two dates.
```
select Datediff(SECOND, [Clearance Time(NT)], [Occurrence Time(NT)])
```
Now convert the `seconds` to `hh:mm:ss` using this code.
```
DECLARE @TimeinSecond INT
SET @TimeinSecond = 86399 -- Change the seconds
SE... | Good old SQL DATEDIFF.
Here's the duration function I use. All wrapped up in a UDF.
```
CREATE FUNCTION fDuration(@DtStart DATETIME, @DtEnd DATETIME)
RETURNS VARCHAR(10)
AS
BEGIN
RETURN (
SELECT
CONVERT(VARCHAR(10), t.Hours) + ':' +
RIGHT('00' + CONVERT(VARCHAR(10), t.Minutes), 2) + ':' +
RIGHT('00' + CONVERT(VAR... |
475,970 | How can I specify a multiline commit message for mercurial on the command line?
```
hg commit -m "* add foo\n* fix bar"
```
does not work. The log shows:
```
changeset: 13:f2c6526e5911
tag: tip
date: Fri Jan 23 23:22:36 2009 +0100
files: foobar.cpp
description:
* add foo\n*fix bar
``` | 2009/01/24 | [
"https://Stackoverflow.com/questions/475970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52986/"
] | I know, there is already a solution for linux users, but I needed another solution for windows command line, so I was looking for it...
And I found one:
<https://www.mercurial-scm.org/pipermail/mercurial/2011-November/040855.html>
```
hg commit -l filename.txt
```
I hope, it's useful for someone out there ,)
[EDI... | In bash (since version 2.0):
```
hg commit -m $'foo\nbar'
```
(I.e. put a **dollar sign** before an opening single quote to make it parse escape sequences (like `\n)` within the string — note that it doesn't work with double quotes.) |
28,577,178 | I'm trying to check modulo of a number against a tuple of numbers, if the modulo is equals to one of the values in the tuple I want to return True else return False.
This is what I had tried so far:
```
def check(y):
k = (2, 5, 8, 10, 13, 16, 19, 21, 24, 27, 29)
for i in range(0, len(k)):
if k[i] == y... | 2015/02/18 | [
"https://Stackoverflow.com/questions/28577178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/84199/"
] | It always returns false because this code:
```
for i in range(0, len(k)):
if k[i] == y % 30:
return True
else:
return False
```
returns true or false based only on the *first* item in the array, because it returns in *both* possible code paths. Either `k[0] == y % 30` and it returns true, or ... | You can accomplish this with a generator expression inside `any()`:
```py
def check(y):
return any(n == y % 30 for n in k)
```
This builds an iterator of booleans that is true for all elements of k that are divisors of `y`. |
53,355 | Assuming the following:
* Operating arbitrary software in a completely read only environment is impractical. (While some software will operate RO without issue, it can be nigh impossible for other software, particularly if source code is not available as is sometimes the case)
* Rebuilding any machine in place is triv... | 2014/03/14 | [
"https://security.stackexchange.com/questions/53355",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/41980/"
] | You have a non-question right here.
Let's look at your second and third assumptions. Rebuilding a machine has negligible cost with zero downtime. The logical conclusion in this ideal world is rebuilding after any instruction is executed. After all, it has zero cost.
Then you say,
>
> Ideally a way that avoids 'unne... | It strikes me that this question is very similar to "How often should I change my password?".
There is possibly some benefit to a regular password change / machine rebuild, in that any compromises will be destroyed. However, unless you have invested a huge amount of capital into automation, there will be a non-trivial... |
9,928,877 | I'm trying to create a windows phone app with lots of texts like this text here under, but it either gets chopped or gets only on 1 line. I have tried different solutions of scrollable textblock and etc but nothing seems to work. The text I want to post in the app is around 30000 characters long. | 2012/03/29 | [
"https://Stackoverflow.com/questions/9928877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1111704/"
] | You have to set the [TextWrapping property](http://msdn.microsoft.com/en-us/library/system.windows.controls.textblock.textwrapping%28v=vs.95%29.aspx) to `wrap`.
```
<TextBlock TextWrapping="Wrap"/>
```
Also make sure you don't constrain the TextBlock in terms of height. | I created a RSS reader page within the wp application which solved my issue of text being chopped. My intent with this app was to integrate some info about my clients company.
Regards Joel |
2,339,280 | I am working the iphone/ipad 3.2 SDK and have created a subdirectory named "Docs" under the default Resources directory "Resources-iPad". If I place "file.pdf" directly in the resources directory and make this call, all works well:
```
CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(),CFSTR("file.pdf")... | 2010/02/26 | [
"https://Stackoverflow.com/questions/2339280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/81524/"
] | The information on core data memory management is good info and technically the answer by Arthur Kalliokoski is a good answer re: the difference between a leek and object allocation. My particular problem here is related to an apparently known bug with setBackgroundImage on a button in the simulator, it creates a memor... | You can have a continuously growing program without necessarily leaking memory. Suppose you read words from the input and store them in dynamically allocated blocks of memory in a linked list. As you read more words, the list keeps growing, but all the memory is still reachable via the list, so there is no memory leak. |
8,407,025 | I'm getting a parameter and getting a specific product from a stored procedure. This stored procedure is returning many columns (I think around 15-20). Unfortunately, some of these values may be null and this of course produces an error when I try to put them in a variable. Is there a simple way to check and see if the... | 2011/12/06 | [
"https://Stackoverflow.com/questions/8407025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1078251/"
] | ```
int? x = dt.Field<int?>( "Field" );
```
Or
```
int y = dt.Field<int?>( "Field" ) ?? 0;
```
[C# DBNull and nullable Types - cleanest form of conversion](https://stackoverflow.com/questions/1706405/c-sharp-dbnull-and-nullable-types-cleanest-form-of-conversion)
The top is probably your best approach. You current... | Peform a check for DBNULL for the field you may suspect is a null value. In this case all of them.
```
if (! DBNull.Value.Equals(row[fieldName]))
return (string) row[fieldName] + " ";
else
return String.Empty;
```
What you can do is create a function that has several overloads for int, string, and Da... |
4,091,458 | I love JOCL, Java bindings for OpenCL. I would like to run Cuda-memcheck on an executable from Java, but whenever I make Java applications, they are always just JAR files that point to a Main-Class. Is there a way to create a .exe file like C++ does and feed that to Cuda-memcheck? | 2010/11/03 | [
"https://Stackoverflow.com/questions/4091458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1202394/"
] | While [Jon has answered](https://stackoverflow.com/a/4091497/4751173) the question on making the list immutable, I would like to also point out that even if the list is immutable, its contained objects are not automatically immutable.
Even if you make the list immutable (for instance by copying its contents into a `Re... | AFAIK, because of the less complex structure, the rule would be: If you need to increase or decrease the size of the collection, use list, if not and you are only using it for enumeration, use array.
I don't think constant vs regular variable makes much of a different in the instantiation of the object. |
54,972,875 | Suppose I have a string
```
String str =" Hello, @John how's going on"
```
Now I want to know., how to highlight the word `@John` and wanna make it clickable from Textview | 2019/03/03 | [
"https://Stackoverflow.com/questions/54972875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8469107/"
] | You can use `clickable span` in a `spannable` string like the following :-
```
SpannableString ss = new SpannableString(" Hello, @John how's going on");
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View textView) {
//perform click operation
}
@Override
public vo... | This will also work with multible mentions.
```js
var str = "Hello, @John how's going on. Greedings to @Bob.";
var regex = /[@]\S[^. ]*/g;
var matches = str.match(regex)
var split = str.split(regex);
for(var i = 0; i<matches.length;i++){
document.body.appendChild(document.createTextNode... |
18,754,420 | I learned that when constructing an object, `super()` will be called, whether you write it in the constructor or not. But I noticed that in some code, the `super()` method is called explicitly. Should I be calling `super()` implicitly or explicitly in a constructor? What's the difference? | 2013/09/12 | [
"https://Stackoverflow.com/questions/18754420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2749891/"
] | Had a hard time with this myself. In foundation 5, solution is below. Referenced from: <https://github.com/zurb/foundation/issues/4468>
```
$(document).foundation({
joyride: {
post_ride_callback : function () {
alert('yay');
}
}
}).foundation('joyride', 'start');
``` | You need to explicitly either blankety declare foundation on the whole document first or call joyride on the document first then call start + your config... not sure why it's set up this way as it's very confusing but here it is:
```
var config = {
nubPosition : 'auto',
postRideCallback : function() {
al... |
126,413 | I currently work for a medium-large (~500 employees) Italian company as a Linux developer. I work in a team of 8 people, most of them are really awesome and really friendly, the day life is good and so is the comfort that the company offers.
To reach the office I have to drive around 75km per day, on alternating weeks... | 2019/01/14 | [
"https://workplace.stackexchange.com/questions/126413",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/97910/"
] | Many people I know have felt exactly as you do, leaving both better and significantly worse employers than yours. I felt the same, when I left my first employer. I confused the personal loyalty I felt to my team, my manager and the company with my duty as an employee. Of course you feel loyal, you've worked there for a... | **No you should not be concerned about your future-ex company.**
This is business, not college and **you're working to make money, not friends**.
Most workplaces guilt trip you into thinking that you somehow owe them anything. Truth is: you don't. As a worker you are creating revenue for the company (despite them pa... |
25,656,375 | How don't i apply css of jquery mobile to specific elements?
Isn't there any way to do this without modifying the css file of jquery mobile?
plz help me. | 2014/09/04 | [
"https://Stackoverflow.com/questions/25656375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2503508/"
] | By default, jQuery `$.ajax` will submit your request as form data. If you open your browser debugger while the request is sent, you would see this request data:
```
system[]:31
system[]:32
system[]:33
system[]:34
system[]:35
system[]:36
system[]:37
system[]:38
system[]:39
system[]:42
system[]:43
```
PHP understands ... | I awarded the answer to `@Barmar` as his solution solved the original OP. I still had a problem with getting the JS arrays across to the PHP array due to using `system = $(this).attr('data-system')`. Changing the code to the following fixed that issue:
```
$('#sub_category_box_systems').on('click', '.sub_category_link... |
3,448,952 | What's wrong with this code? Why doesn't it show value?
```
<script>
$(document).ready(function()
{
$('#radio_div').change(function(event){
var value = $("input[@name='rdio']:checked").val();
$('#update_text').html('Radio value:' + value);
});
});
</script>
<... | 2010/08/10 | [
"https://Stackoverflow.com/questions/3448952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/415459/"
] | You're adding a `change` handler to a `<div>` element.
Since `<div>` elements never generate `change` events, your code doesn't work.
Instead, you should add the `change` handler to the `input` elements *inside* the `<div>` element, like this:
```
$('#radio_div :radio').change(...)
```
(The [`:radio` selector](h... | Try this :
```
$('#radio_div input:radio').click(function() {
if($(this).is(':checked')) {
$(this).val(); // $(this).attr('value');
}
});
``` |
10,305,047 | ```
ImageIcon backpackImageIcon = new ImageIcon("images/gui/button_backpack.png");
JButton backpackButton = new JButton();
backpackButton.setBounds(660,686,33,33);
backpackButton.setBorderPainted(false);
backpackButton.setFocusPainted(false);
backpackButton.setVisible(true);
backpackButton.getInputMap(JComponent.WHEN_I... | 2012/04/24 | [
"https://Stackoverflow.com/questions/10305047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/572286/"
] | This function will return a BufferedImage with a color offset (ie. lighter/darker)
```
public BufferedImage shiftColor(BufferedImage img, int rShift, int gShift,int bShift) {
Color tmpCol;
for (int x = 0; x < img.getWidth(); x++) {
for (int y = 0; y < img.getHeight(); y++) {
tmpCol=new Colo... | Check out this [tutorial](http://docs.oracle.com/javase/tutorial/uiswing/events/mouselistener.html). You are probably interested in mouseEntered. As instead of changing the color of the backpack in Java consider 2 images, one of a light backpack and another of a dark backpack. Change them when you hover over the button... |
44,234,876 | I am new to spark and scala. I want to read a directory containing json files. The file has attribute called "EVENT\_NAME" which can have 20 different values. I need to separate the events, depending upon the attribute value. i.e. EVENT\_NAME=event\_A events together. Write these in hive external table structure like: ... | 2017/05/29 | [
"https://Stackoverflow.com/questions/44234876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1728716/"
] | I'm assuming you mean you'd like to save the data into separate directories, without using Spark/Hive's `{column}={value}` format.
You won't be able to use Spark's `partitionBy`, as Spark partitioning forces you to use that format.
Instead, you have to break your `DataFrame` into its component partitions, and save th... | <https://spark.apache.org/docs/latest/sql-programming-guide.html#upgrading-from-spark-sql-16-to-20>
>
> Dataset and DataFrame API `registerTempTable` has been deprecated and replaced by `createOrReplaceTempView`
>
>
>
<https://spark.apache.org/docs/2.1.1/api/scala/index.html#org.apache.spark.sql.DataFrameWriter@s... |
32,423,408 | I am trying and failing to save a grid of ggplots as a .png on my hard drive and would appreciate some help troubleshooting my code.
Here's an example that reproduces my error using public data on Lego Star Wars sets:
```
library(dplyr)
library(ggplot2)
library(grid)
library(gridExtra)
# Load the Lego data and subse... | 2015/09/06 | [
"https://Stackoverflow.com/questions/32423408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1708299/"
] | If you're saving to a single png file, you probably don't mean to use `marrangeGrob()` (**m**ultiple pages), but `arrangeGrob()`.
The error you see is due to a check in `ggplot2::ggsave`, which should disappear in the next release. In the meantime you can either call `png()` explicitly, or install the dev version of gg... | Using the devel version of `dplyr/ggplot2` in `R 3.2.2`, it worked for me.
```
lego.grid <- marrangeGrob(lego_plot_list, nrow=2, ncol=2, top="")
grid.newpage()#from @baptiste's comments
ggsave("legostarwars.png", lego.grid)
#Saving 7 x 6.99 in image
```
[
After set Deployment Target:-

he... | Yes , you can create and test your application on iOS 5.0 simulator too in Xcode 5.
They would just be created with the iOS 7.0 SDK as the base SDK |
15,612,279 | Is there any way to print the first N words of a file? I've tried cut but it reads a document line-by-line. The only solution I came up with is:
```
sed ':a;N;$!ba;s/\n/δ/g' file | cut -d " " -f -20 | sed 's/δ/\n/g'
```
Essentially, replacing newlines with a character that doesn't not exist in the file, applying "cu... | 2013/03/25 | [
"https://Stackoverflow.com/questions/15612279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1651270/"
] | You could use `awk` to print the first n words:
```bsh
$ awk 'NR<=8{print;next}{exit}' RS='[[:blank:]]+|\n' file
```
This would print the first 8 words. Each word is output on a separate line, are you looking to keep the original format of the file?
**Edit:**
The following will preserve the original format of the ... | Why not try turning your words into lines, and then just using `head -n 20` instead?
For example:
```
for i in `cat somefile`; do echo $i; done | head -n 20
```
It's not elegant, but it does have considerably less line-noise regex. |
313,384 | I'm working on a somewhat simple game. Currently trying to implement the game logic for moving the pieces around.
Logic is something like this:
```
does player have pieces in inventory?
if yes:
did they try to move it to an empty location
if yes: ...
if no: ...
if no:
.... | 2016/03/21 | [
"https://softwareengineering.stackexchange.com/questions/313384",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/201143/"
] | I advocate for the middle path. There's nothing wrong with if statements but deep nesting is something you want to avoid. As a rule of thumb, if you get to the third level of nesting, you should probably restructure the code. The first and most basic approach is to create new methods. So in your example, you'd have the... | you could make use of OOP to solve this.
```
var piece = GetPiece(..);
if (piece != null)
{
board.Move(piece,location);
}
else
{
//do something
}
```
Now the first line, `piece != null` handles the
>
> does player have pieces in inventory?
>
>
>
The `board.Move(piece,location)` would have the logic to s... |
62,115,591 | As Async Storage is deprecated what other way is there to store a variable locally??
I have a React Native ios App with a Notification Centre.
Each time the user enters the Notification Centre a Cognito access Token was generated. To avoid excess of token generation the Tokens were saved through Async storage an... | 2020/05/31 | [
"https://Stackoverflow.com/questions/62115591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13246365/"
] | **AsyncStorage is deprecated so use below package**
Get library With Yarn:
```
yarn add @react-native-async-storage/async-storage
```
**Once done, import the header**
```
import AsyncStorage from '@react-native-async-storage/async-storage';
```
**For store a value**
```
const storeData = async (value) => {
tr... | Async storage from `react-native` library is deprecated, they split it from react-native core into a community library.
You can always use Async Storage from this [library](https://github.com/react-native-community/async-storage)
Just follow installation steps from [docs](https://react-native-community.github.io/asyn... |
44,183,784 | I would like to ask you if the current schema design on a HBase table is correct for the following scenario:
I receive 10 million events per day each having a unix epoch timestamp and an id. I will have to group by day, so that I can easily scan for those events that happened on a specific day.
**Current design**:
Eve... | 2017/05/25 | [
"https://Stackoverflow.com/questions/44183784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7804338/"
] | ```
#include <iostream>
enum Direction { UP, UP_RIGHT, RIGHT, DOWN_RIGHT, DOWN, DOWN_LEFT, LEFT, UP_LEFT };
Direction GetDirectionForAngle(int angle)
{
const Direction slices[] = { RIGHT, UP_RIGHT, UP, UP, UP_LEFT, LEFT, LEFT, DOWN_LEFT, DOWN, DOWN, DOWN_RIGHT, RIGHT };
return slices[(((angle % 360) + 360) % ... | ```
switch (this->_car.getAbsoluteAngle() / 30) // integer division
{
case 0:
case 11: this->_car.edir = Car::EDirection::RIGHT; break;
case 1: this->_car.edir = Car::EDirection::UP_RIGHT; break;
...
case 10: this->_car.edir = Car::EDirection::DOWN_RIGHT; break;
}
``` |
3,743,726 | >
> How to efficiently perform matrix inversion more than once $\left(A^TA + \mu I \right)^{-1}$ if $\mu \in \mathbb{R}$ is changing but $A \in \mathbb{R}^{n \times m}$ is fixed?
>
>
>
>
> Or do I need to invert the whole matrix in every update of $\mu$?
>
>
> | 2020/07/03 | [
"https://math.stackexchange.com/questions/3743726",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/602319/"
] | Do you need to have the matrix in explicit form, or are you happy for it to be factored? If the latter, then note that adding a constant to the diagonal of a matrix leaves the eigenvectors unchanged and shifts all the eigenvalues by that constant. That's easy to see since if A*x*=$\lambda$*x*, then (A+$\mu$I)*x* = ($\l... | To invert any matrix $\bf X$ you can reformulate it into
"Find the matrix which if multiplied by $\bf X$ gets closest to $\bf I$".
To solve that problem, we can set up the following equation system.
$$\min\_{\bf v}\|{\bf M\_{R(X)}} {\bf v} - \text{vec}({\bf I})\|\_2^2$$
where $\text{vec}({\bf I})$ is vectorization ... |
59,308 | I would like to remove a wall in my walk-out basement but I don't know how to interpret this architectural blueprint. Based on this blueprint, is the wall bearing load or not? I have highlighted the wall in question in the pictures below.
[](https://i... | 2015/02/10 | [
"https://diy.stackexchange.com/questions/59308",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/7085/"
] | EDIT: On second look, the drawing actually tells us. There's a note box to the right: TYP BEARING WALL 2x4 stud 16" O.C. on Continuous footing. The dashed line around the wall indicates the footing.
ORIGINAL:
If I'm reading the drawing correctly, **IT DEFINITELY IS**.
For the sake of this discussion, north is the top... | Everything Chris said is true...but I’m not sure if the note box gives us information about mentioned wall or different one.It't hard to tell from the drawing, at least for me...I don't know the standards in your country, and if house is built according to regulations, but bearing walls should be either vertical or hor... |
3,047,195 | How to show that $\langle \textbf {a,b} \rangle = \|\textbf {a}\| \|\textbf {b}\| \cos \theta$ where $\langle \cdot , \cdot \rangle$ denotes the usual real inner product or dot product on $\Bbb R^2$, $\| \cdot \|$ is the usual or Euclidean norm on $\Bbb R^2$ and $\theta$ is the angle between the vectors $\textbf {a}$ a... | 2018/12/20 | [
"https://math.stackexchange.com/questions/3047195",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/543867/"
] | If you have a valid proof for the case when the order of $a$ is two, $o(a)=2$, then I'm pretty sure that you're done with the question — because the order of $a$ doesn't really matter here. The order of $z=xax^{-1}$ is equal to the order of $a$; so, just as you said, by uniqueness it implies that $xax^{-1}=a$, and you'... | What you want to show is that $\forall x \in G, x.a.x^{-1} = a$. The thing you miss is probably that $(x.a.x^{-1})^k = x.a^k.x^{-1}$ for any integer $k$. If you write the product down, you will see that all the intermediate $x^{-1}.x$ terms cancel each other $(x.a.x^{-1})^n = (x.a.x^{-1})(x.a.x^{-1})\ldots(x.a.x^{-1})$... |
27,022,915 | I have the following code that draws an image to a canvas and gets the pixel data:
```
var canvas=$('#canvas'),
ctx=canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
var data=ctx.getImageData(0, 0, canvas.width, canvas.height);
```
This pulls `RGBA` values which I need to store into an array that... | 2014/11/19 | [
"https://Stackoverflow.com/questions/27022915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1020936/"
] | What you can do is loop through the entire image data array and extract the values you need:
Each pixel takes up four spaces in the array for its rgba values, so we can loop through the total number of pixels and grab four values from the array each time.
You can get the y value (or row the pixel is on) by dividing t... | `ctx.getImageData` returns an object that contains a `.data` property.
That data property is an array that already contains all the pixel colors that you're looking for.
```
// get the imageData object
var imageData=ctx.getImageData(0, 0, canvas.width, canvas.height);
// get the pixel color data array
var data=imag... |
4,938,397 | I would like to dynamically add properties to a ExpandoObject at runtime. So for example to add a string property call NewProp I would like to write something like
```
var x = new ExpandoObject();
x.AddProperty("NewProp", System.String);
```
Is this easily possible? | 2011/02/08 | [
"https://Stackoverflow.com/questions/4938397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27294/"
] | Here is a sample helper class which converts an Object and returns an Expando with all public properties of the given object.
```
public static class dynamicHelper
{
public static ExpandoObject convertToExpando(object obj)
{
//Get Properties Using Reflections
BindingFlags fl... | This is the best solution I've found. But be careful with that. Use exception handling because it might not work on all of the cases
```
public static dynamic ToDynamic(this object obj)
{
return JsonConvert.DeserializeObject<dynamic>(JsonConvert.SerializeObject(obj));
}
``` |
31,096 | I'm trying to find out how much memory my own .Net server process is using (for monitoring and logging purposes).
I'm using:
```
Process.GetCurrentProcess().PrivateMemorySize64
```
However, the Process object has several different properties that let me read the memory space used:
Paged, NonPaged, PagedSystem, NonP... | 2008/08/27 | [
"https://Stackoverflow.com/questions/31096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | Is this a fair description? I'd like to share this with my team so please let me know if it is incorrect (or incomplete):
There are several ways in C# to ask how much memory my process is using.
* Allocated memory can be managed (by the CLR) or unmanaged.
* Allocated memory can be virtual (stored on disk) or loaded (... | Working set isn't a good property to use. From what I gather, it includes everything the process can touch, even libraries shared by several processes, so you're seeing double-counted bytes in that counter. Private memory is a much better counter to look at. |
182,663 | I wrote the `TOTAL_FREQUENCY` values manually. But I want to automatically write this values with a script. Namely, I want to write sum of column 3 to all of the the column 5 rows. How can I do it with a script?
[](https://i.stack.imgur.com/l0i3J.jpg... | 2016/02/29 | [
"https://gis.stackexchange.com/questions/182663",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/68219/"
] | The following Python script (created by Terry Giles and mentioned in this [ESRI forum](http://forums.esri.com/Thread.asp?c=93&f=1728&t=241385)) allows you to sum the values of a field and paste the sum in another field. The script is designed to work in the **Toolbox** so that when you run it, you can enter the *Layer ... | It seems OP seeking field calculator expression. Here is one:
```
def getTotal(name,field):
mxd = arcpy.mapping.MapDocument("CURRENT")
lr=arcpy.mapping.ListTableViews(mxd,name)[0]
tbl=[row[0] for row in arcpy.da.TableToNumPyArray(lr,field)]
return sum(tbl)
```
=======================================
```
getTota... |
378,484 | I need to add a description on my Account every time an Opportunity's stage is changed.
I tried the following and getting NULL pointer exception.
```java
public class opportunityTriggerHandler {
public static void oppStgChangeDetails(List<Opportunity> oppList, map<Id, Opportunity> oldmap, boolean isInsert, bool... | 2022/06/15 | [
"https://salesforce.stackexchange.com/questions/378484",
"https://salesforce.stackexchange.com",
"https://salesforce.stackexchange.com/users/104956/"
] | Let's rewrite this to be cleaner and use `getInstance()` properly
```
public class UpdateOpportunity{
public static void checkOpportunityStage(List<Opportunity> opportunityList){
List<Task> taskList = new List<Task>();
Task_Settings__mdt TaskDomain = Task_Settings__mdt
.getInstance('Manage_P... | You need to put this statement to set the subject
```
task1.Subject = TaskDomain.FieldName__c;
``` |
21,646,179 | When I tried
```
$ sudo apt-get install python-matplotlib
```
I got the following error:
```
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-matplotlib
```
How to `install` it? | 2014/02/08 | [
"https://Stackoverflow.com/questions/21646179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3151082/"
] | One "cleaner" way to install matplotlib is to go through pip:
```
sudo apt-get install python-pip
sudo pip install matplotlib
```
It will also ensure that you'll get the most up to date stable version and will be easier to maintain when an upgrade is pushed to pypi.
If the build process complains about missing head... | type the following commands in terminal:
```
$ wget https://github.com/matplotlib/matplotlib/zipball/master
$ unzip master
$ cd matplotlib-matplotlib-bb3ea55
$ sudo python2.7 setup.py build
$ sudo python2.7 setup.py install
```
If the `unzip` command doesn't work properly, extract the files manually. `$ cd matplotli... |
154,427 | Boot now freezes the system at the "Ubuntu purple screen" with the 5 dots under it. I cannot even CTRL-ALT-F1 to get to an alternate console. Have to push reset button on computer to reboot.
After the 12.04 update crash, the system would boot, but I had no icons and no launch bar and errors about missing dependencies.... | 2012/06/22 | [
"https://askubuntu.com/questions/154427",
"https://askubuntu.com",
"https://askubuntu.com/users/72433/"
] | You can boot into recovery mode. Choosing From Boot Menu. From there you can backup your data or try to update again. | I had this same exact problem. Just burn 12.4 on a disk, run in Live DVD mode (try Ubuntu), backup your files, and then boot the DVD again and try the option that will say "Upgrade 12.4 into 12.4". If it doesn't work, then just do a clean installation. |
2,543,313 | ```
market_l="${echo $1 | awk '{print tolower($0)}'}"
echo $market_l
```
when i execute this its giving me an error below:
```
./test: market_l="${echo $1 | awk '{print tolower($0)}'}": The specified substitution is not valid for this command.
``` | 2010/03/30 | [
"https://Stackoverflow.com/questions/2543313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/134713/"
] | Did you mean to use the `$()` operator instead of `${}`? | you should use `$()` to assign output to a variable. not `${}`
```
market_l="$(echo $1 | awk '{print tolower($0)}')"
```
or you can do it with ksh
```
#!/bin/ksh
typeset -l market_l
market_l="$1"
echo $market_l
```
Other ways to change case besides `awk`, fyi
```
$ echo "$1"|tr [A-Z] [a-z]
$ echo "$1"|sed 'y/AB... |
21,775,709 | I want to set a **tinyint** field as autoincrement, but table constructor dont let me do it. But he lets to **int** and **bigint** types. Whats the problem?
Here is the screenshot: <http://gyazo.com/ce8d345ee94bf26e833fe16133b5eee5.png>
The first row "Идентификация" is an **Identity** field in English. | 2014/02/14 | [
"https://Stackoverflow.com/questions/21775709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2932802/"
] | SQL Server Compact only support int and bigint with IDENTITY | First of all, why do you use TinyInt? TinyInt has a range from -128 to +127, so is is not very well suited for auto\_increment columns. |
32,633,799 | I want to execute a code block only on devices running with an OS older than `iOS8`. I can't do:
```
if #available(iOS 8.0, *) == false {
doFoo()
}
```
The solution I'm using for now is:
```
if #available(iOS 8.0, *) { } else {
doFoo()
}
```
, but it feels clunky. Is there another way to negate the `#a... | 2015/09/17 | [
"https://Stackoverflow.com/questions/32633799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1173513/"
] | I use a `guard` for this:
```
guard #available(iOS 8.0, *) else {
// Code for earlier OS
}
```
There's slight potential for awkwardness since `guard` is required to exit the scope, of course. But that's easy to sidestep by putting the whole thing into its own function or method:
```
func makeABox()
{
let bo... | **Swift 5.6, Xcode 13.3 Beta**
```
if #unavailable(iOS 13, *) {
// below iOS 13
} else {
// iOS 13 and above
}
```
**Swift 5.5 and earlier**
a simple way to check is by using `#available` with a `guard` statement
```
guard #available(iOS 13, *) else {
// code for earlier versions than iOS 13
return
}
... |
43,208,196 | I have some radio button which I put in radio button group.
So, how can I get the radio button index value or selected index value when I going to click on a particular radio button.
Here is my code
```
bg=new ButtonGroup();
for(i=0;i<8;i++){
rbt =new RadioButton();
rbt.setName("rbt"+i);
radioList.add(rbt);
}
... | 2017/04/04 | [
"https://Stackoverflow.com/questions/43208196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7136032/"
] | see snippet below or **[jsfiddle](https://jsfiddle.net/b74a3kbs/5/)**
it will work regardless how many cols you have or rows
first ( on big screen ) all rows have `margin-bottom` except the last one
then on medium screen , the rows won't have any margin and the cols will all have margin-bottom except the **last col**... | Use Gutters in row: <https://getbootstrap.com/docs/5.0/layout/gutters/>
```
<div class="row gy-2">
...
</div>
``` |
21,304,282 | I'm writing a script that takes an output file from another platform (that sadly doesn't produce CSV output, instead it's around 7 lines per record), grabbing the lines that have the values I'm interested in (using `select-string`) and then scanning the `MatchInfo` array, extracting the exact text and building an array... | 2014/01/23 | [
"https://Stackoverflow.com/questions/21304282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1868534/"
] | I hope this helps someone else.
I spent a day on a similar problem: Progress bar was very very slow.
My problem however was rooted in the fact that I had made the screenbuffer for the powershell console extremely wide (9999 instead of the default 120).
This caused Write-Progress to be slowed to the extreme every time... | I completely removed my old answer for sake of efficiency, Although modulus checks are efficient enough, they do take time, especially if doing a modulus 20 against say 5 million - this adds a decent amount of overhead.
For loops, all I do is something simple as follows
---which is similar to the stop watch method, i... |
169,219 | In my medieval-fantasy world, there’s a secret civilization with modern technology.
A “powerful” dragon accidentally came across them and they became good allies. The dragon was introduced to the concept of aircraft and it wasn’t long until she decided to ride one.
The dragon shrunk into a more humanoid form, with th... | 2020/02/21 | [
"https://worldbuilding.stackexchange.com/questions/169219",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/72381/"
] | Convenience and speed.
Unless your dragon has some magical powers helping it along, there is no way she ever could achieve the same speeds as a fighter plane.
Also, who doesn't prefer driving a car over walking? If it can be easier, then why not use the possibility?
Now how she will afford the fuel is another questi... | I'd say that the best reason is that she can't fly properly anymore for some reason, and flying an airplane is the closest she can get. Maybe she has something like a torn wing that didn't heal properly, so she can't fly very well naturally anymore. If she were injured helping someone from the secret civilization, this... |
3,295,783 | If you are not developing for an Apple platform, are there reasons to choose Objective-C? I know of GNUstep (which I do not find visually pleasing), but what else is there?
If you want to develop for multiple platforms, including OS X or iOS but also Linux or Windows, when might Objective-C be a good choice? | 2010/07/21 | [
"https://Stackoverflow.com/questions/3295783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/397408/"
] | Outside Apple, The only major Objective-C environment is GNUSTEP/Windowmaker.
It's a shame, since Objective-C is a much nicer and saner language than C++. | There is [The Cocotron](http://www.cocotron.org/)
[Clozure Common Lisp (CCL)](http://openmcl.clozure.com/) on 32-bit Windows platforms now includes experimental support for the Cocoa frameworks using the Cocotron open source project. |
50,961,544 | While i am working with open vino to convert .pb file into inference format using model optimizer, i am continuously facing "graph contains a cycle error".
And we have used TensorFlow Object Detection Models and SSD Inception V2 to generate .pb file.
```
[ ERROR ] -------------------------------------------------
[ E... | 2018/06/21 | [
"https://Stackoverflow.com/questions/50961544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9428127/"
] | **@+id/name** When you create a `new id`
**"@id/"** When you `link to existing id`
**Use-case example 1:**
Let's say you created your own resource in XML:
```
<resources>
<item name="plusIcon" type="id"/>
</resources>
```
Now you can use this resource at multiple places without creating a new resource using *... | Defining the constraints within a **RelativeLayout** might be a good example.
```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
... |
13,500,741 | Good evening! I have a web app with login-logout, where you can buy or sell some products. My queries are stored in a java class, called `DBManager`, which has just static methods that are called from servlets (I can't use JSP because in this project we can't use them, the professor gives us this constraint).
So here... | 2012/11/21 | [
"https://Stackoverflow.com/questions/13500741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1392008/"
] | Instead of arbitrary getting the connection, you could change your class to receive a connection. That allows you to pass any instance of connection (what happens if you need to get data from another database?).
Also, imagine that the code will be ported to desktop. With this approach you can reuse your [DAO](http://e... | In your `HttpServlet` `doPost` or `doGet` methods you can call `getServletContext()`.
```
ServletContext sc = getServletContext();
DataSource ds = (DataSource) sc.getAttribute("ds");
Connection conn = ds.getConnection();
```
>
> A servlet can bind an object attribute into the context by name. Any attribute bound in... |
311,206 | >
> Let $f$ be a fixed nonzero linear functional on an $n$-dimensional vector space $V$ and
> $H=\{\alpha \in V:f(\alpha)=0\}$. Then $H$ is a subspace of $V$ and its dimension is $n-1$.
>
>
>
I have shown that $H$ is a subspace of $V$. Do you have an idea how to show that its dimension is $n-1$? Thanks a lot. | 2013/02/22 | [
"https://math.stackexchange.com/questions/311206",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/52337/"
] | $\dim (\ker(f))+ \dim(\operatorname{Im}(f)) = \dim V=n$ your $H=\ker(f)$ and $\dim(\operatorname{Im}(f))=1$ | Here a complete proof. Suppose that $f:V\rightarrow F$ nonzero linear functional on an n-dimensional vector space $V$ over a field $F$.
We know that $f(V)=\operatorname{Im}(f)$ is a subspace of $F$ so $0\leq\dim\, \operatorname{Im}(f)\leq \dim F =1$. But $\dim\, \operatorname{Im}(f)\neq 0$ because $f$ is a nonzero line... |
283 | ```
void removeForbiddenChar(string* s)
{
string::iterator it;
for (it = s->begin() ; it < s->end() ; ++it){
switch(*it){
case '/':case '\\':case ':':case '?':case '"':case '<':case '>':case '|':
*it = ' ';
}
}
}
```
I used this function to remove a string that has any... | 2011/01/27 | [
"https://codereview.stackexchange.com/questions/283",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/530/"
] | One thing that I would change about your function (in addition to Jonathan's recommendation of using a string to store the forbidden characters), is the argument type of `removeForbiddenChar` to `string&` instead of `string*`. It is generally considered good practice in C++ to use references over pointers where possibl... | Solution with no conditional branching.
Swapping space for time optimization.
Simplified algorithm:
```
void removeForbiddenChar(string* s)
{
for (string::iterator it = s->begin() ; it < s->end() ; ++it)
{
// replace element with their counterpart in the map
// This replaces forbidden chara... |
2,446,175 | I have a block of text which occasionally has a really long word/web address which breaks out of my site's layout.
What is the best way to go through this block of text and shorten the words?
**EXAMPLE:**
this is some text and this a long word appears like this
```
fkdfjdksodifjdisosdidjsosdifosdfiosdfoisjdfoijsd... | 2010/03/15 | [
"https://Stackoverflow.com/questions/2446175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175562/"
] | You need **[wordwrap](http://php.net/manual/en/function.wordwrap.php)** function i suppose. | Based on @JonnyLitt's answer, here's my take on the problem:
```
<?php
function insertSoftBreak($string, $interval=20, $breakChr='­') {
$splitString = explode(' ', $string);
foreach($splitString as $key => $val) {
if(strlen($val)>$interval) {
$splitString[$key] = wordwrap($val, $interv... |
25,642,244 | I'm mostly coding in Perl and struggle now with a regex in Java. I have this:
```
// String dbfPath = "/result_feature/Monocytes-CD14+_H3K4me3_ENCODE_UW_bwa_samse"
// rs.getString = "Monocytes-CD14+_H3K4me3_ENCODE_UW_bwa_samse"
if(! dbfPath.matches(".*" + rs.getString("rs_name") + "/*"))
```
My problem is that the ... | 2014/09/03 | [
"https://Stackoverflow.com/questions/25642244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1520203/"
] | Wrap your `rs.getString()` inside a `Pattern.quote`:
```
Pattern.quote(rs.getString("rs_name"))
```
>
> Returns a literal pattern String for the specified String.
>
>
> | You could add '\Q' & '\E' in your string direclty.
```
\Q Nothing, but quotes all characters until \E
\E Nothing, but ends quoting started by \Q
if(! dbfPath.matches(".*\\Q" + rs.getString("rs_name") + "\\E/*"))
```
One thing, you should make sure your string doesn't contain '\E', if yes, the safe way is using P... |
16,249 | Example:
>
> The **cat** was lying on a cat bed, barely visible under
> the blankets, an IV wrapped around one of her front legs. Judging by
> the triangular shape of her head, her black nose ears and ears, she seemed
> to be a Siamese. Not that I was an expert at identifying cats; I only
> recognized this kind b... | 2015/02/17 | [
"https://writers.stackexchange.com/questions/16249",
"https://writers.stackexchange.com",
"https://writers.stackexchange.com/users/1544/"
] | What you're talking about are [epithets](http://dictionary.reference.com/browse/epithet), and depending on who you talk to, they are either a necessary tool of writing or the bane of existence.
When overdone, epithets can make a simple conversation between two people feel like an orgy. If Bob, Frank, the blond, the re... | While it's a good idea to vary your descriptions occasionally for variety, in this instance, *Siamese* is not just a way to refer to *the cat,* but a way to differentiate this cat from *other* cats.
If the scene were in someone's living room, then *Siamese* would help you identify that cat as opposed to the tabby, tu... |
60,503,529 | I want to use a `<select>` to be able to choose between several values, or choose none.
My component is this one :
```
<select @bind="SelectedValue">
<option value="null">Null</option>
@for (int i = 0; i < 10; i++)
{
<option value="@i">Value : @i </option>
}
</select>
<hr />
@if (Selected... | 2020/03/03 | [
"https://Stackoverflow.com/questions/60503529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/704012/"
] | Why don't you just use -1 instead of null?
```
<select @bind="SelectedValue">
<option value="-1">Null</option>
@for (int i = 0; i < 10; i++)
{
<option value="@i">Value : @i </option>
}
</select>
<hr />
@if (SelectedValue>-1)
{
<p>The selected value is : @SelectedValue.Value</p>
}
else
{... | >
> As a workaround, make a second property to translate.
>
>
> Also, you can't use an empty string instead of 'null', although you
> can use a different string. If you use an empty string then the Text
> property, rather than the Value property is passed as the selected
> Value.
>
>
>
```
//On Entity
public ... |
16,751 | In Mac Lane, there is a definition of an arrow between adjunctions
called a map of adjunctions. In detail, if a functor $F:X\to A$ is left
adjoint to $G:A\to X$ and similarly $F':X'\to A'$ is left adjoint to
$G':A'\to X'$, then a map from the first adjunction to the second is a
pair of functors $K:A\to A'$ and $L:X\to ... | 2010/03/01 | [
"https://mathoverflow.net/questions/16751",
"https://mathoverflow.net",
"https://mathoverflow.net/users/2734/"
] | One of the applications of adjoint functors is to compose them to get a monad (or comonad, depending on the order in which you compose them). A map of adjoint functors gives rise to a map of monads. So one might ask: what are maps of monads good for? Many algebraic categories (such as abelian groups, rings, modules) ca... | The 2-category of categories, adjunctions, and conjugate natural transformations (i.e., maps of adjunctions between the same categories) is used in an approach to modal type theory in [Adjoint Logic with a 2-Category of Modes](http://dlicata.web.wesleyan.edu/pubs/ls15adjoint/ls15adjoint.pdf).
The general 2-categorical... |
21,691,409 | I'm relatively new to programming, so when someone suggested that building an array of structs (each containing n attributes of a particular "item") was faster than building n arrays of attributes, I found that I didn't know enough about arrays to argue one way or the other.
I read this:
[how do arrays work internall... | 2014/02/11 | [
"https://Stackoverflow.com/questions/21691409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2127595/"
] | Let's take a simpler example. Let's say you have a array `int test[10]` which is stored like this at address 1000:
>
> 1|2|3|4|5|6|7|8|9|10
>
>
>
The complier knows that, for example, an int is 4 bytes. The array access formula is this:
>
> baseaddr + sizeof(type) \* index
>
>
>
The size of a struct is just... | so here is the whole trick, array elements are adjacent in memory.
when you declare an array for example: `int A[10];`
the variable `A` is a pointer to the first element in the array.
now comes the indexing part, whenever you do `A[i]` it is exactly as if you were doing `*(A+i)`.
the index is just an offset to t... |
137,241 | I quoted the next code snippet from `config.status` generated by `configure`.
```
if test ! -f "$as_myself"; then
{ { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
{ (exit 1); exit 1; }; }
fi
```
In the co... | 2014/06/15 | [
"https://unix.stackexchange.com/questions/137241",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/64173/"
] | Executing `(exit 1);` is the simplest way of triggering an `ERR` trap. It will also trigger immediate exit if `set -e` is in effect. (Triggering the error condition requires a command to fail; `exit` with a failure value in a subshell causes the subshell to fail.)
`exit 1;` will do neither of those things.
So `{(exit... | There is no purpose for this as far as I can see, there is nothing that can be achieved directly by starting a subshell and then immediately exiting.
Things like this are most likely a side effect of automatically generating code - in some cases there may be other commands executed in the subshell where having the `ex... |
13,436,520 | Recently I am writing some micro-benchmark code, so I have to print out the JVM behaviors along with my benchmark information. I use
```
-XX:+PrintCompilation
-XX:+PrintGCDetails
```
and other options to get the JVM status. For benchmark information, I simply use `System.out.print()` method. Because I need to know t... | 2012/11/18 | [
"https://Stackoverflow.com/questions/13436520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1643467/"
] | For `-XX:+PrintCompilation`, you could use `-XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation` flags instead to get a "verbose" output in separate "hotspot.log" file. This file is in XML format and contains both the information from `-XX:+PrintCompilation` and the cause of such compilations. The file path can be chang... | First, I'd try what @barracel noted about using System.out.println().
I don't know much about Java, but you could also write out all of your debug messages to stderr and leave stdout for the JVM. This may prevent the pollution of stdout that's apparently happening when multiple threads write to the same file descripto... |
1,435,138 | Well it should work in IE, I know IE doesnt support content property anything other that? | 2009/09/16 | [
"https://Stackoverflow.com/questions/1435138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116489/"
] | The only option is the the [`content`](http://www.w3.org/TR/CSS21/generate.html#content) property:
>
> The content property is used with the
> `:before` and `:after` pseudo-elements, to
> insert generated content.
>
>
>
But as you point out, this is part of CSS 3 and is not supported by IE. In the meantime you ... | It is quite possible to solve this without Javascript, using a combination of HTML and CSS. The trick is to duplicate the content added by the CSS in the HTML an IE-specific conditional comment (not shown by other browsers) and use the `display` CSS selector to toggle when that element is shown. [According to MSDN](htt... |
198,143 | I'm looking for a way to get the list of all plugins listed in the [WordPress.org Plugin Directory](https://wordpress.org/plugins/).
There is one other post I've [found on StackOverflow](https://wordpress.stackexchange.com/questions/95836/list-of-all-existing-wordpress-plugins) regarding this which recommends [using t... | 2015/08/10 | [
"https://wordpress.stackexchange.com/questions/198143",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43881/"
] | You can start with something like this:
```
https://api.wordpress.org/plugins/info/1.2/?action=query_plugins&request[page]=1&request[per_page]=400
```
I think it's self-explanatory. | good day dear Davemackey - hello Michael Field
its been a long time that this has been asked - but anyway.. here my little idea that i can come up with..
Not the best answer but I tried to solve my own problem the best way I could.
Getting a list of plugins
=========================
This will **not** return ALL plug... |
48,630 | I have a computer running TightVNC server. It is on my home network. The computer it is installed on has a locally static ip address 192.168.1.100. I am able to connect to this vnc server from my home network fine, but unable to connect from outside my network (using the IP address that I see at [www.whatismyip.com](ht... | 2009/09/29 | [
"https://superuser.com/questions/48630",
"https://superuser.com",
"https://superuser.com/users/8610/"
] | I would double check that you have forwarded the port as that is all you should need to do.
If there is a problem, try changing the default port in case your ISP is blocking it.
Lastly, you may want to double check that you have forwarded the correct protocol, I can't remember if it is TCP or UDP that is needed, but ... | I'm betting (could be wrong) that you probably actually need to forward 5901/5801. Doesn't VNC add the display number to the port you select? The first display number is 1. Been awhile since I messed with VNC but just a thought. |
3,156,744 | I have a problem when I try to do a git svn rebase on my repository. It displays :
```
Checksum mismatch: code/app/meta_appli/app_info.py
expected: d9cefed5d1a630273aa3742f7f414c83
got: 4eb5f3506698bdcb64347b5237ada19f
```
I searched a lot but haven't found a way to solve this problem.
If anybody knows, please... | 2010/07/01 | [
"https://Stackoverflow.com/questions/3156744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/119190/"
] | [This solution](http://www.victoriakirst.com/?p=903) was the only one that worked for me:
>
> See what was the revision number of the last change on the file:
>
>
> `git svn log chrome/test/functional/search_engines.py`
>
>
> Reset svn to be closest parent before that revision:
>
>
> `git svn reset -r62248 -p`
... | In our practice the error "Checksum mismatch:" on .shtml files in git svn clone ... command was caused by the setup of the front-end Apache server to interpret the.shtml files (from SVN) as Server-Side Includes (SSI) and thus produce live content instead of just providing the stored file content. Disabling SSI in Apach... |
18,603,181 | In C# I use strategy pattern with dictionary like this:
```
namespace NowListeningParserTool.Classes
{
using System.Collections.Generic;
public class WebsiteDictionary
{
private readonly Dictionary<string, WebsiteParser> _website = new Dictionary<string, WebsiteParser>();
public WebsiteDictionary()
{
... | 2013/09/03 | [
"https://Stackoverflow.com/questions/18603181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1395676/"
] | Option 1: Returns the content from the executed function.
```
function getWebsite() {
var websites = [
['grooveshark.com',getTrackGrooveshark],
['977music.com',getTrack977Music],
['sky.fm/play',getTrackSkyFm],
['iheart.com',getTrackIHeart],
['live365.com'... | I think this is really a matter of using a simple JavaScript object. Basically you can reference any property of an object in a similar fashion as you are doing in C#, but I think in a much simpler way. Of course that is my opinion :) I like to structure my modules in a self instantiating manner, like jQuery, so there ... |
46,787,432 | I am creating an array in Javascript where the product id is used for the key. As the key is numeric, the array is filling gaps with null.
So for example, if I had only two products and their ids were 5 and 7, I would do something like:
```
var arr = []
arr[5] = 'my first product';
arr[7] = 'my second product';
```
... | 2017/10/17 | [
"https://Stackoverflow.com/questions/46787432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/857903/"
] | For iterating the array, you could use [`Array#forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach), which skips sparse items.
```js
var array = [];
array[5] = 'my first product';
array[7] = 'my second product';
array.forEach(function (a, i) {
console.log(... | >
> Forcing javascript key integer fills array with null
>
>
>
You are declaring an empty array and then setting values into 6th and 8th element in the array. That leaves the values of other elements as null.
If you don't intend to `push` items into array, i.e. use objects. Something like,
```
var obj = {};
obj[... |
63,666,195 | I am a very new user here so, apologies in advance if I break any rule. Here is the problem I am facing and need suggestions please.
I have a Chrome extension which works with Gmail & consumes APIs from my web server running on nginx through Phusion Passenger server of Rails application.
My Nginx version is nginx ver... | 2020/08/31 | [
"https://Stackoverflow.com/questions/63666195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13319628/"
] | I got the same issue following Cosmos DB SQL API getting started guide.
The fix was to specify `ConnectionMode = ConnectionMode.Gateway`
```
var cosmosClient = new CosmosClient(EndpointUrl, AuthorizationKey, new CosmosClientOptions() { AllowBulkExecution = true, ConnectionMode = ConnectionMode.Gateway });
``` | Please ensure below points are taken care in .NET SDK:
* Initialize a singleton DocumentClient
* Use Direct connectivity and TCP protocol (ConnectionMode.Direct and ConnectionProtocol.Tcp)
* Use 100s of Tasks in parallel (depends on your hardware)
* Increase the MaxConnectionLimit in the DocumentClient constructor to ... |
13,727,089 | I am trying to update the metadata on the multimedia image in C# using Tridion's TOM.NET API like this
```cs
componentMM.LoadXML(localComponent.GetXML(XMLReadFilter.XMLReadALL));
// make changes to the component mm multimedia text;
localComponent.UpdateXML(componentMM.InnerXML);
localComponent.Save(True)
```
Whi... | 2012/12/05 | [
"https://Stackoverflow.com/questions/13727089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1373140/"
] | Include only the tcm:Metadata node in your update?
Specifically, it is complaining about you specifying the size of the mm file, which you shouldn't, that's a system property. Clean up the XML you receive from Tridion to remove that property (it might then complain about another property, just do what it asks you to)... | When you do this you need to only save the modified metadata data (not the entire XML). Try removing all of the child nodes except tcm:Metadata from the XML structure before calling `.UpdateXML()`
Perhaps you could paste your sample XML if you need further assistance. |
18,683,338 | is it possible to get metadata of an OData service in JSON format?
When I try to use `format=json` , it doesn't work. Here is what I tried:
```
http://odata.informea.org/services/odata.svc/$metadata/?format=json
``` | 2013/09/08 | [
"https://Stackoverflow.com/questions/18683338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/668082/"
] | The `$metadata` document is in the CSDL format, which currently only has an XML representation. (As a side note, if you do want to request the json format for a different kind of OData payload, make sure the `format` query token has a `$` in front of it: `$format=json`.)
So, no it is not possible. You can, however, ge... | I agreed with the previous answer. This isn't supported by the specification but some OData frameworks / libraries are about to implement this feature.
I think about Olingo. This is could be helpful for you if you also implement the server side. See this issue in the Olingo JIRA for more details:
* **OLINGO-570** - <... |
445,739 | I have lines that look like this
```
123-456-789 12.34.56 example
```
I want to select the 12, add 2 to it, then print the whole line as is. So the result should be :
```
123-456-789 14.34.56 example
```
I have this awk expression :
```
awk 'BEGIN {FS="[ .]"}{$2=$2+2}{print}'
```
But it gives me
```
123-456-7... | 2018/05/24 | [
"https://unix.stackexchange.com/questions/445739",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/292395/"
] | Trying to "*restore*" a complex/compound field separator will likely break some values and the consistency of the whole record.
Instead, use the following approach:
```
awk '{ n = substr($2, 1, index($2, ".")); sub(/[^.]+\./, n + 2 ".", $2) }1' file
```
The output:
```
123-456-789 14.34.56 example
```
---
The ... | Use `split` function in your `awk` script that allows capturing the field separator:
```
awk '{split($0,a,"[- .]",sep); a[4]+=2; for(i in a) printf "%s%s",a[i], sep[i]; printf "\n"}' file
```
Alternatively, you can make use of `RS` and `RT` variables
```
awk -v RS='[- .]' 'NR==4{$1+=2} {printf "%s%s",$0,RT}' fil... |
1,521,071 | How do I shift an array of items up by 4 places in Javascript?
I have the following string array:
```
var array1 = ["t0","t1","t2","t3","t4","t5"];
```
I need a function convert "array1" to result in:
```
// Note how "t0" moves to the fourth position for example
var array2 = ["t3","t4","t5","t0","t1","t2"];
```... | 2009/10/05 | [
"https://Stackoverflow.com/questions/1521071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184481/"
] | ```
array1 = array1.concat(array1.splice(0,3));
```
run the following in Firebug to verify
```
var array1 = ["t0","t1","t2","t3","t4","t5"];
console.log(array1);
array1 = array1.concat(array1.splice(0,3));
console.log(array1);
```
results in
```
["t0", "t1", "t2", "t3", "t4", "t5"]
["t3", "t4", "t5", "t0", "t1",... | One more way would be this:
```
var array2 = array1.slice(0);
for (var i = 0; i < 3; i++) {
array2.push(array2.shift());
}
``` |
151,933 | Setting Overview
----------------
My world suffers from an abundance of a particular type of energy. This energy can be safely absorbed and utilized by living cells, enabling, for example, a dragon's flight and fiery breath or a human's ability to manipulate his environment through "magic."
However, this energy also ... | 2019/07/30 | [
"https://worldbuilding.stackexchange.com/questions/151933",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/6986/"
] | **Energy Absorption Mechanism + constant movement**
This is a dumb idea but hey, worth a shot. The idea is that these machines must have some initial energy stored within them to allow them to get to perform certain tasks as directed by the AI. Obviously the dragons and whatnot will try to fight them back, so instead ... | >
> However, this energy also amplifies the effects of electricity, such as lightning or computer circuitry. In the latter case, unshielded components tend to fail spectacularly in short order.
>
>
>
This is marvellous news. Now for every watt of energy used, many more watts of power become available.
If anything... |
1,310,890 | $$\lim\_{x\to\infty}\left(\sin{\frac 1x}+\cos{\frac 1x}\right)^x$$
It is about the $(\to1)^{(\to\infty)}$ situation. Can we find its limit using the formula $\lim\_{x\to\infty}(1+\frac 1x)^x=e$? If yes, then how? | 2015/06/03 | [
"https://math.stackexchange.com/questions/1310890",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/245612/"
] | Put $y=\dfrac{1}{x} \to \displaystyle \lim\_{x\to \infty}\ln(f(x))=\displaystyle \lim\_{y\to 0}\dfrac{\ln\left(\sin y+\cos y\right)}{y}=\displaystyle \lim\_{y\to 0} \dfrac{\cos y - \sin y}{\sin y+ \cos y}=1\to \displaystyle \lim\_{x \to \infty} f(x) = e$. | Set $1/x=h$ to get
$$\lim\_{x\to\infty}\left(\sin\frac1x+\cos\frac1x\right)^x=\lim\_{h\to 0^+}\left(\sin h+\cos h\right)^{\frac1h}$$
Now $(\sin h+\cos h)^2=1+2\sin h\cdot\cos h=1+\sin2h$
$$\lim\_{h\to 0^+}\left(\sin h+\cos h\right)^{\frac1h}=\lim\_{h\to 0^+}\left[\left(\sin h+\cos h\right)^2\right]^{\frac1{2h}}$$
... |
323,482 | Setting:
* Longitudinal data on outcome Yi,t of a group of individuals, i={1,...,N}, over time, t={1,...,T}
* On this group, a sequence of RCTs (r={1,...,R}) staggered over time is applied.
* Each RCT is measuring the effect of a specific treatment and treats a small percentage of the population.
* Once an individual... | 2018/01/17 | [
"https://stats.stackexchange.com/questions/323482",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/64472/"
] | You could do a chi-square test of goodness of fit.
This is explained on this page: <http://stattrek.org/chi-square-test/goodness-of-fit.aspx?Tutorial=AP>
So, let's see what your expected value is. There's always 0 days after a marketing event, but there may seldom be 5 days after a marketing event (if the marketing e... | Categorizing your data (2<=x<=4) needs some theory to support it. Is there a marketing theory that says calls in this region are optimal? If so, you could do a multiple regression analysis with planned contrasts. |
1,896,468 | I am working on a project which needs to insert the member birthday's into MySQL database. But i am confused. Actually i am using it like that:
int(10)
So i change the format e.g. "27/06/1960" to unix time using PHP and use the function date() to show the birthday. Is there any better solution? and is there any good ... | 2009/12/13 | [
"https://Stackoverflow.com/questions/1896468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/180685/"
] | The fastest way to find out when somebody birthday is would be to use 2 or 3 separate INT columns and probably an addition column to store the whole thing as a DATETIME. While you don't normally use ints nor multiple columns to represent date, keep in mind if you have a lot of rows in this table, doing something like
... | Use a DATE column. MySQL expects input as "YYYY-MM-DD" and outputs values like that.
A date that was not (yet) provided by user may be encoded as a NULL column. Though you may not need the extra bit that the "NULL" requires, you may even write the special value "0000-00-00" for that. |
26,449,109 | I am trying to develop a simple mode for codemirror.
This mode will colour paragraphs alternatively in blue and green. A separation between paragraph is an empty line or a line containing only spaces.
Here is a version of the code that works, but with the big issue that empty lines are not detected:
```
CodeMirror.de... | 2014/10/19 | [
"https://Stackoverflow.com/questions/26449109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1484601/"
] | ```
/url\(([^"']+?)\)|'([^'"]+?)'\)|"([^'"]+?)"\)/g
```
Try this.Grab the captures.See demo.
<http://regex101.com/r/qQ3kG7/1> | Try this:
```
var results = str.match(/url\(['"]?[^\s'")]+['"]?\)/g)
.map(function(s) {
return s.match(/url\(['"]?([^\s'")]+)['"]?\)/)[1];
});
```
[Demo](http://jsfiddle.net/yw3n2aaw/) |
338,405 | I have a layer file which I use as reference for symbology for future layers. It is based on unique values, however there is over 100 unique values, and each one have their own icon.
If I apply this symbology to a small layer, its legend or symbology table will have over 100 items, even if the layer only uses 3-4 symb... | 2019/10/10 | [
"https://gis.stackexchange.com/questions/338405",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/150721/"
] | In ArcGIS Pro, try checking the "Only show features visible in the map extent" box, which can be found under Feature Display Options menu. This will make it so that only things that appear in the current map extent are displayed in your legend.
<https://pro.arcgis.com/en/pro-app/help/layouts/work-with-legend-items.htm... | In layout view, click on the legend item. This opens the Format Legend Item area where there is an to "Only show features visible in the map extent". |
17,727,101 | I have the following code:
```
g = lambda a, b, c: sum(a, b, c)
print g([4,6,7])
```
How do I get the lambda function to expand the list into 3 values? | 2013/07/18 | [
"https://Stackoverflow.com/questions/17727101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2089675/"
] | Expand the list t0 3 values can be done by this:
```
g(*[4,6,7])
```
But the `sum` won't work in your way.
Or you can write this way:
```
>>> g = lambda *arg: sum(arg)
>>> print g(4, 5, 6)
15
>>>
```
Or just make your lambda accept a list:
```
g = lambda alist: sum(alist)
print g([4,6,7])
``` | If your lambda expects to have a list/tuple of fixed length passed in, but wants to expand the values in that list/tuple into separate parameter variables, the following will work.
```
g = lambda (a, b, c): a + b + c
g([4, 6, 7])
```
Note the parentheses around the parameter list.
This "feature" works in Python 2.x... |
4,289,629 | Is it normal for methods with a question mark to return something that's truthy (for example, a number) to indicate that something is true, or should `true` itself be returned?
Are there any examples of truthiness being used in the Ruby standard library or by Rails, for example?
**Background:** Someone wrote a `Strin... | 2010/11/27 | [
"https://Stackoverflow.com/questions/4289629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38765/"
] | It is *usual* for methods ending with `?` to return either `true` or `false` but it is not systematic and no core method will assume it.
An example in the core classes is `Numeric#nonzero?` which *never* returns `true` or `false`.
```
42.nonzero? # => 42
```
The library `Set` has `add?` and `delete?` too. I wish `E... | I renamed the method in question to remove the `?`, which was really not important to the question being answered. Scanning through the core functions that end in ?s, the only ones I spotted that returned data or nil were the `add?` and `delete?` methods on Set. |
12,283,436 | I'm working on a wikipedia reader where I want the user to be able to share the article he is reading to a friend using NFC. I dont want to be able to open these intents or anything fancy like that, just allow the friend to open up the url in the browser of his choice. I'm using a webview so getting ahold of the url wo... | 2012/09/05 | [
"https://Stackoverflow.com/questions/12283436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1468731/"
] | It's really easy. To share something via Android Beam, you have to create a so-called NDEF message. An NDEF message contains one or more records, which have a specific type (e.g. URI, text, MIME type, etc.) and contain the data you want to share.
Add this piece of code somewhere in the Activity that shows the URL you ... | You should look at UriRecord or AbsoluteUriRecord, or even you can try an Android Application Record if you can find the one which launches the browser(?). And you should look into beam - there is a project boilerplate in the download sections [here](http://code.google.com/p/nfc-eclipse-plugin/) (shameless plug) :-) Yo... |
39,578 | I want to get 2 columns from another list and merge these columns. But when I am trying to do this via Lookup, they are not shown under "Add a column to show each of these additional fields".
But when I tried a simple text one (not lookup) it is shown.
Is there anyway to show a column which a kind of lookup field? | 2012/06/27 | [
"https://sharepoint.stackexchange.com/questions/39578",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/9035/"
] | It was very annoying not be able lookup currency column,
however I found this workaround that worked in SP 2013.
1. Create calculated column of type "Single Line"
2. Use formula to format text as currency `=TEXT([Price],"$0.00;($0.00)")`
3. Now this new column can be referenced as secondary column and visible in the ... | I found a work around for this, what you do is use a wf to move the column into a text field. Go the origional list that has the information you'd like to look up. Creat a new text column and give it a name similar to the one you would like to dupilicate. Then create a WF to auto-populate that column into a text field.... |
19,487 | I am planning to test a filesystem.
What all should i consider to do. or how to accomplish the same.
Are there are any tools to test a filesystem or any reliable references?
Purpose: Planning to shift from ext3 to EFS. | 2009/06/04 | [
"https://serverfault.com/questions/19487",
"https://serverfault.com",
"https://serverfault.com/users/360512/"
] | Don't just test for speed, also consider reliability. Try to, e.g., power down disks on a busy filesystem and see what's left.
The quality of the repair and recovery tools available is also important, and very hard to test discretely. Block structure may e.g. inhibit tools that try to salvage data in raw mode from a u... | While [bonnie++](http://www.coker.com.au/bonnie++/) is primarily focused on bench-marking performance it does work above the filesystem. It performs some tests that give different results per-filesystem. I suspect you are probably interested in the change in performance related to EFS as well, so you may want to try th... |
322,291 | How to stop the Tomcat 6.0 server ?
Under bin direcctory it has got only 4 files namely
bootstrap, tomcat6 , tomcat6w , tomcat-juli
Under TaskManager also , Windows Processes also , there is nothing related to tomcat
How can we stop the server instance now (I need to stop it as i modified some web.xml file ) | 2011/10/17 | [
"https://serverfault.com/questions/322291",
"https://serverfault.com",
"https://serverfault.com/users/-1/"
] | Depends on how you started it.
If you started it by `startup.bat`, just use `shutdown.bat` which reside in the very same folder.
If it's started as Windows service (why have you by the way installed it as a Windows service if your intent is apparently to develop with it, not to run in production?), then you should re... | If tomcat 6 on windows is started as a service with a diffeernt name, you have to copy tomcat6w.exe to servicenamew.exe. Then it will find it. Don't forget the w. For example, i have a tomcat6 that runs as "talend\_tac". I had to copy tomcat6w to talend\_tacw.exe, then it would control the service. |
65,005,506 | How to execute the form submit in Button click using ICommand
How to pass parameter in ICommand execute
```
@using System.Windows.Input
<button @onclick="buttonClick"> Blazor Button</button>
@code {
private ICommand _command;
public ICommand Command
{
get => _command;
set => _command = ... | 2020/11/25 | [
"https://Stackoverflow.com/questions/65005506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8204457/"
] | You can use `Row.fromSeq`:
```
val m = Map("com.project.name" -> "A", "com.project.age" -> "23")
val row = Row.fromSeq(m.toSeq)
```
or alternatively `Row(m.toSeq:_*)`
both giving `[(com.project.name,A),(com.project.age,23)]` | You can convert map into the dataframe as follows :
```
import org.apache.spark.sql.types._
import org.apache.spark.sql.functions._
val input : Map[String,String] = Map("com.project.name" -> "A", "com.project.age" -> "23")
val df = input.tail
.foldLeft(Seq(input.head._2).toDF(input.head._1))((acc,curr) =>
acc.withC... |
60,292,616 | I am try to installing Chaincode, follow the tutorial of hyperledger. But when I try to run the command
`peer chaincode install -p chaincodedev/chaincode/sacc -n mycc -v 0`
The terminal gives error message
>
> Error: error getting chaincode deployment spec for mycc: error getting chaincode package bytes: failed to... | 2020/02/19 | [
"https://Stackoverflow.com/questions/60292616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10514498/"
] | I solved it today:
After loging into CLI contaier execute the following command (import the shim package). This will import the package into cli container where the chaincode will be compiled.
go get github.com/hyperledger/fabric-chaincode-go/shim
then execute
peer chaincode install -p chaincodedev/chaincode/sacc ... | In my case the reason was incorrect path. CLI container work dir has already `chaincodedev` part of the path
```
cli:
...
working_dir: /opt/gopath/src/chaincodedev
```
You can do following to validate if this is true in your case
```
docker exec -it cli bash
pwd
```
You have to see `/opt/gopath/src/chainc... |
31,436 | Do you know any good GUI for pacman and arch? Where I could view packages installed and possible to install? And of course do anything as in pacman. | 2012/02/11 | [
"https://unix.stackexchange.com/questions/31436",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/1924/"
] | I think "PackageKit" is the best choise for Gtk's desktop, So for QT you can use "Appset-qt". | pacmanxg ... <https://bbs.archlinux.org/viewtopic.php?id=125872> |
2,661,065 | I'm looking for a good sorted list for java. Googling around give me some hints about using TreeSet/TreeMap. But these components is lack of one thing: random access to an element in the set.
For example, I want to access nth element in the sorted set, but with TreeSet, I must iterate over other n-1 elements before I c... | 2010/04/18 | [
"https://Stackoverflow.com/questions/2661065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/244000/"
] | SortedList decorator from Java Happy Libraries can be used to decorate TreeList from Apache Collections. That would produce a new list which performance is compareable to TreeSet.
<https://sourceforge.net/p/happy-guys/wiki/Sorted%20List/> | What about using a `HashMap`? Insertion, deletion, and retrieval are all O(1) operations. If you wanted to sort everything, you could grab a List of the values in the Map and run them through an O(n log n) sorting algorithm.
**edit**
A quick search has found [LinkedHashMap](http://java.sun.com/j2se/1.4.2/docs/api/jav... |
19,594,231 | we want to publish an update of our app. Is it possible to rename the app after the update? let's say the app is called **myApp** and I want it to be called **myApp 2** after the update... can it be done? | 2013/10/25 | [
"https://Stackoverflow.com/questions/19594231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1862909/"
] | *In Build Setting*, You can change **Product Name**.
 | For changing the apps name see <https://developer.apple.com/library/ios/qa/qa1625/_index.html>
However, the directory for the app's data will change as well. If you want to move some data, you can find the directory used by the simulator e.g. with:
NSString \*homeDir = NSHomeDirectory(); NSLog(@"%@",homeDir);
before ... |
2,807,502 | I have [this](http://pastebin.org/219615) ASP.NET page with ASP.NET UpdatePanel and jQueryUI droppable and sortable components. The page works fine in all browsers, but doesn't in Internet Explorer (IE8 tested).
After I try to call ASP.NET AJAX event (by pressing my asp.net button inside the UpdatePanel) my sortable l... | 2010/05/11 | [
"https://Stackoverflow.com/questions/2807502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/136666/"
] | I believe this is a bug in JQuery - I think there is a fix where you redefine the offset function to work under IE:
<http://dev.jqueryui.com/ticket/4918>
Cheers | The solution
```html
<%@ Page Language="C#" AutoEventWireup="true" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<style type="text/css">
#sortable
{
list-style-type: none;
margin: 0;
... |
55,096,252 | Assume we have a dataset like:
```
a: 1,2,3,5,6
b: 4,1,2
c: 1,4
```
Now we want to transform this dataset to:
```
1: a,b,c
2: a,b
3: a
4: b,c
5: a
6: a
```
This transform could be done by a dictionary but is there a way to do this more efficiently
Currently I do as below:
```
uFile = open("t/u.txt","r")
uDic =... | 2019/03/11 | [
"https://Stackoverflow.com/questions/55096252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4716337/"
] | Use defaultdict for this:
```
from collections import defaultdict
d = {'a': [1, 2, 3, 5, 6], 'b': [4, 1, 2], 'c': [1, 4]}
o = defaultdict(list)
for k, v in d.items():
for vv in v:
o[vv].append(k)
print(dict(o))
{1: ['a', 'b', 'c'],
2: ['a', 'b'],
3: ['a'],
5: ['a'],
6: ['a'],
4: ['b', 'c']}
``` | I would go with a simpler way as following:
```
In [2]: d
Out[2]: {'a': [1, 2, 3, 5, 6], 'b': [4, 1, 2], 'c': [1, 4]}
In [3]: dd = {}
In [4]: for k,v in d.items():
...: for e in v:
...: val = dd.get(str(e), [])
...: dd[str(e)] = val + [k]
...:
In [5]: dd
Out[5]:
{'1': ['a'... |
35,278,621 | I am using the Facebook Javascript SDK to enforce that users who access my site must be logged into Facebook. I'm using the function *StatusChangeCallback* to redirect visitors to a Facebook login page if they aren't logged into Facebook. I have copied a snippet of my script below, which is in the Head tag of my web pa... | 2016/02/08 | [
"https://Stackoverflow.com/questions/35278621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5900211/"
] | I don't know if a generator itself can be recursive.
Will M [proved me wrong](https://stackoverflow.com/a/35279624/1187415)!
Here is a possible implementation for a pre-order traversal, using a stack for the child nodes which still have to be enumerated:
```
extension XMLNode : SequenceType {
public func genera... | While Martin's answer is certainly more concise, it has the downside of making a lot of using a lot of array/insert operations and is not particularly usable in lazy sequence operations. This alternative should work in those environments, I've used something similar for `UIView` hierarchies.
```
public typealias Gener... |
56,109,891 | I made a GUI with Tkinter in python 3. Is it possible to close the window and have the application stays in the Windows System Tray?
Is there any lib or command within Tkinter for this. | 2019/05/13 | [
"https://Stackoverflow.com/questions/56109891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11490650/"
] | If your controller path is `/App/Http/Controllers/API`, you need to adjust it's namespace :
```php
namespace App\Http\Controllers\API;
```
If your controller path is `/App/Http/Controllers`, you need to adjust your routes:
```php
Route::post('login', 'UserController@login');
``` | **1**. Copy the existing functions of your controller and delete it.
**2**. Recreate your controller but this time specifying the location of were you want to place it, in the Controllers directory. e.g.
php artisan make:controller NameOfYourSubFolder\YourControllersName
**3**. Paste you functions. |
16,990,782 | I'm very new to GAE/Java/Maven and coming from a .net background, is eager to try it out.
I've installed the Google App Engine plugin for eclipse 4.2. I created an application using the Google plugin, and everything went according to plan. It works nicely. I can develop, test on local server and deploy to the cloud wi... | 2013/06/07 | [
"https://Stackoverflow.com/questions/16990782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The best way is to use *Maven Goals* from the command line. From the Google Documentation for [Deploying a Java App](https://cloud.google.com/appengine/docs/standard/java/tools/uploadinganapp):
>
> If you are using the App Engine SDK-based Maven plugin, use the
> command:
>
>
>
> ```
> mvn appengine:update
>
> `... | I tried to follow the document and use maven for upload new code, the command run without error and can run at local but it does not affect the app on google cloud. I went to dashboard of the project, I found under tab versions there are some instance include the new one. At this tab I found I made a mistake with app v... |
6,256,552 | I have found only
<http://ispras.linux-foundation.org/index.php/API_Sanity_Autotest>
because it is listed on Wikipedia. Is there any other Sanity suite for C++? | 2011/06/06 | [
"https://Stackoverflow.com/questions/6256552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48465/"
] | The simplest way to check this is with a [regular expression](http://www.regular-expressions.info/):
```
function(str){
return /^[A-Z]/.test(str);
}
```
returns `true` when the input string starts with a capital, false otherwise. (This particular regular expression - the bits between the // characters - is sayin... | This will check to see if the username entered starts with a capital letter, and is followed by 5 - 24 alphanumeric characters.
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript">
... |
45,098,535 | I have 2 views.
1)MyMenuRestaurent.axml 2) ImageAndSubTitle.axml
code for MyMenuRestaurent.axml
```
<LinearLayout>
<ListView>
</ListView>
</LinearLayout>
```
Code For Image And Sub Title
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
and... | 2017/07/14 | [
"https://Stackoverflow.com/questions/45098535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8187944/"
] | It's likely `docker run` did work, but since you did not specify any command to run, the container stopped working just after starting. With `docker ps -a` you should see some exited ubuntu containers.
If you run the container as daemon (`-d`) and tell it to wait for interactive input (`-it`) it should stay running. H... | I did not understand the question correctly. What you want to do is bash connection maybe parameter to execute is incorrect
```
sudo docker run -t -i /bin/bash ubuntu
```
Go for it |
9,299,717 | I am trying to run some javascript (toggleClass) only if the clicked menu link has a submenu. Is this possible? Thanks in advance for your help.
```
$('#nav a').click(function () {
if (???) {
$(this).toggleClass('sf-js-enabled');
}
});
``` | 2012/02/15 | [
"https://Stackoverflow.com/questions/9299717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1149767/"
] | ```
$('#nav a').click(function () {
// Proceed only if children with your submenu class are present
if ($(this).find('.submenuClass').length > 0) {
$(this).toggleClass('sf-js-enabled');
}
})
``` | Try this.
```
$('#nav a').click(function () {
if ($(this).find('submenuSelector').length) {
$(this).toggleClass('sf-js-enabled');
}
})
```
Alternatively you can use `has(selector)` method which reduces the set of matched elements to those that have a descendant that matches the selector or DOM elemen... |
20,506,612 | I am reading "Python programming for the absolute beginner" and in there there is this piece of code:
```
@property
def mood(self):
unhappiness = self.hunger + self.boredom
if unhappiness < 5:
m = "happy"
elif 5 <= unhappiness <= 10:
m = "okay"
elif 11 <= unhappiness <= 15:
m = ... | 2013/12/10 | [
"https://Stackoverflow.com/questions/20506612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2870783/"
] | It's just a matter of taste.
A property is used where an access is rather cheap, such as just querying a "private" attribute, or a simple calculation.
A method is used where a rather "complicated" process takes place and this process is the main thing.
People are used to using getter and setter methods, but the tend... | It's essentially a preference. It allows you to type `object.property` rather than `object.property()`.
So when should you use which? You have to use context to decide. If the method you have returns a value based upon properties of the object, it saves you the time of creating a variable and setting it equal to some... |
7,727,142 | Can anyone tell me what this is:
```
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie ie6" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie ie7" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie ie8" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js iframe" lang="en... | 2011/10/11 | [
"https://Stackoverflow.com/questions/7727142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/596952/"
] | Those are only checks for compatibility with older browsers
`<!DOCTYPE html>` usually refers to HTML5, browsers below IE9 don't support HTML5 at all, so tweaks are needed. That's why there are HTML if-clauses that check if you use IE and which version. The HTML element gets a special class for that browser version so ... | You should use this as your Doctype: `<!DOCTYPE html>`
The rest is not relevant for the doctype, and is IE-specific. |
68,612,455 | I've been experimenting with for loops, mostly with a condition 'less than or equal'. However, I wanted to make the condition of a for loop so that the number in the initialization is bigger than that one in the condition. When I ran the code, it didn't work. And when I added the bigger than or equal operator, it crash... | 2021/08/01 | [
"https://Stackoverflow.com/questions/68612455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15453757/"
] | ```
for will run while condition is true
// will exit right away, i is smaller then 4
for (let i = 0; i > 4; i++) {
console.log(i);
}
// will exit right away, i is smaller then 4
for (let i = 0; i >= 4; i++) {
console.log(i);
}
// will exit right away, i is smaller then 4
for (let i = 0; i === 4; i++) {
... | The issue you're encountering is that the condition needs to resolve to "*true*" in order for the loop to continue. Let's run through your examples...
For the first one, you start with **i** is equal to zero (**0**), and then test for **i** being greater than four (**4**). Well, zero (**0**) is less than four (**4**).... |
2,934,832 | I have a page in which there are multiple hrefs. i want to find out which href is clicked and based on that href click I want to show and hide a div? | 2010/05/29 | [
"https://Stackoverflow.com/questions/2934832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/324831/"
] | I'm going to assume you have control over the href's here and you want to have the simplest markup possible, in that case you can do something like this:
```
<a href="#div1">Toggle Div 1</a>
<a href="#div2">Toggle Div 2</a>
<div id="div1" class="toggleDiv">Div 1 Content</div>
<div id="div2" class="toggleDiv">Div 2 Co... | This should give you something to start with:
```
$('a').click(function()
{
var href = this.href;
// Show/hide your div.
return false;
});
```
Just implement your logic in the `click` handler function. |
191,835 | I was reviewing an application for a grant and found out that one of the applicants has included a publication on his CV that does not exist in the journal. It was supposedly published several years ago. I counterchecked the list of publications of that particular journal, including the issue and volume, but it's non-e... | 2022/12/21 | [
"https://academia.stackexchange.com/questions/191835",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/78095/"
] | You only really have a few options, if the granting institution is "typical".
1. Your best option is to contact the person coordinating the review with your concern (in the NIH hierarchy, that may be a program officer or scientific review officer).
2. You can ignore the issue.
3. You can hold hold on to the issue, sav... | For clarification, you may consider asking the applicant directly. There might be a silly explanation that avoids all confusion.
Of course, depending on the answer of the applicant, you may take the necessary steps.
Claiming something that doesn't exist is of course a very serious academic offense. That is why you sh... |
2,205,128 | I am trying to create HTTP connection using AsyncTask class.
Is it possible to create HTTP connection ?
Can you suggest sample source code ?
Thanks in advance. | 2010/02/05 | [
"https://Stackoverflow.com/questions/2205128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/164589/"
] | As an inner class inside your activity :
```
public final class HttpTask
extends
AsyncTask<String/* Param */, Boolean /* Progress */, String /* Result */> {
private HttpClient mHc = new DefaultHttpClient();
@Override
protected String doInBackground(String... params) {
publishProgr... | i think this may help u...
<http://androidbeginner.blogspot.com/2010/01/communication-with-httprequest.html>
Atul yadav |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.