Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
58,909,097 | Prevent function taking const std::string& from accepting 0 | <p>Worth a thousand words:</p>
<pre><code>#include<string>
#include<iostream>
class SayWhat {
public:
SayWhat& operator[](const std::string& s) {
std::cout<<"here\n"; // To make sure we fail on function entry
std::cout<<s<<"\n";
return *this;
}
};
int main() {
SayWhat ohNo;
// ohNo[1]; // Does not compile. Logic prevails.
ohNo[0]; // you didn't! this compiles.
return 0;
}
</code></pre>
<p>The compiler is not complaining when passing the number 0 to the bracket operator accepting a string. Instead, this compiles and fails before entry to the method with:</p>
<pre><code>terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid
</code></pre>
<p>For reference:</p>
<pre><code>> g++ -std=c++17 -O3 -Wall -Werror -pedantic test.cpp -o test && ./test
> g++ --version
gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC)
</code></pre>
<p><strong>My guess</strong></p>
<p>The compiler is implicitly using the <code>std::string(0)</code> constructor to enter the method, which yields the same problem (google the above error) for no good reason.</p>
<p><strong>Question</strong></p>
<p>Is there anyway to fix this on the class side, so the API user does not feel this and the error is detected at compile time? </p>
<p>That is, adding an overload</p>
<pre><code>void operator[](size_t t) {
throw std::runtime_error("don't");
}
</code></pre>
<p>is not a good solution.</p>
| <c++><string><std><implicit-conversion> | 2019-11-18 06:34:30 | HQ |
58,911,507 | keycloak bearer-only clients: why do they exist? | <p>I am trying to wrap my head around the concept of <code>bearer-only</code> clients in Keycloak.</p>
<p>I understand the concept of public vs confidential and the concept of service accounts and the <code>grant_type=client_credentials</code> stuff. But with <code>bearer-only</code>, I'm stuck.</p>
<p>Googling only reveals fragments of discussions saying:</p>
<blockquote>
<p>You cannot obtain a token from keycloak with a <code>bearer-only</code> client.</p>
</blockquote>
<p>The docs are unclear as well. All they say is:</p>
<blockquote>
<p>Bearer-only access type means that the application only allows bearer token requests.</p>
</blockquote>
<p>Ok, if my app only allows bearer token requests, how do I obtain this token if I cannot get it from Keycloak using client id / client secret?</p>
<p>And if you can't obtain a token, what can you at all? Why do these clients exist? Can somebody please provide an example of using this type of client? </p>
| <keycloak> | 2019-11-18 09:31:27 | HQ |
58,912,460 | Auriez-vous une solution pour détecter les erreurs de memoire dans un programme en C? | Salut,
je suis actuellement en train de recoder certaines fonctions de la lib C et je suis confronté à un problème de type "détection d'erreur mémoire".
Pour la fonction strcpy,
...
char *my_strcpy(char *str1, char *str2)
{
int i = 0;
for (; str2[i] != 0; i++)
str1[i] = str2[i];
str1[i] = 0;
return (str1);
}
...
en utilisant le test criterion suivant:
...
#include <criterion/criterion.h>
char *my_strcpy(char *str1, char *str2);
Test(my_strcpy, in_allocated_string)
{
char *src = "Hello World";
char dest[11];
my_strcpy(dest, src);
cr_assert_str_eq(dest, "Hello World");
cr_assert_eq(dest, my_strcpy(dest, src));
}
...
la destination étant plus petite que la source je devrai obtenir un segfault, pourtant ni valgrind ni scan build ne me donne d'information ou d'erreur, le programme compile et s'execute sans erreur.
je vous laisse un petit makefile pour compile avec ou sans les tests.
...
SRC = code.c \
SRC_TEST = test.c \
LDFLAGS = -L./lib/my -lmy
OBJ = $(SRC:.c=.o)
CC = gcc
CFLAGS = -W -Wall -Wextra -Werror -fstack-protector -fstack-protector-all -fstack-protector-strong -Wstack-protector
NAME = libmy.a
all: $(NAME)
$(NAME): $(OBJ)
ar rc $@ $^
test: $(SRC) $(SRC_TEST)
$(CC) -fprofile-arcs -ftest-coverage -Isrc/main -DMOCKING $(CFLAGS) $(shell pkg-config --libs --cflags criterion) $^ -o tests
./tests
clean:
rm -rf *.gcda *.gcno *.info $(OBJ)
fclean: clean
rm -f $(NAME)
rm -rf tests
re: fclean all
...
Auriez-vous une solution pour détecter les erreurs de memoire dans un programme en C ?
| <c> | 2019-11-18 10:27:06 | LQ_EDIT |
58,912,672 | How to access Rest APIs mentioned in Cotroller class of a Jar file in my Spring Boot Application | I am new to Spring / Spring Boot.
In my Spring Boot Application, I have a **JAR** file which has a Controller class and corresponding Service Interface (not class). I have implemented the Service interface and created a Service class with some logic. Now I want to access the APIs (/v1/getDetails) present in Controller class of JAR file.
Can we access the REST APIs present in Controller class of JAR file? If so then please guide me.
PS: I have tried to search on internet but didn't get a clear answer. | <java><spring><spring-boot> | 2019-11-18 10:38:11 | LQ_EDIT |
58,913,428 | What alternatives are there to Hibernate Validator's @SafeHtml to validate Strings? | <p>As stated in the JavaDocs, it will be removed in a future release.
Is there any alternative library which works similarly via annotations?</p>
| <java><hibernate-validator> | 2019-11-18 11:19:51 | HQ |
58,914,523 | Return multiple values from dictionary, python | I've this dictionary
`{'people': [{'name': 'Christina Koch', 'craft': 'ISS'}, {'name': 'Alexander Skvortsov', 'craft': 'ISS'}, {'name': 'Luca Parmitano', 'craft': 'ISS'}, {'name': 'Andrew Morgan', 'craft': 'ISS'}, {'name': 'Oleg Skripochka', 'craft': 'ISS'}, {'name': 'Jessica Meir', 'craft': 'ISS'}], 'number': 6, 'message': 'success'}`
I need to get just the names, like below
Alexander Skvortsov
Alexey Ovchinin
Andrew Morgan
Christina Koch
Luca Parmitano
Nick Hague
Thank you for your help
| <python><string><list><sorting><dictionary> | 2019-11-18 12:24:26 | LQ_EDIT |
58,915,131 | CAN I USE BOTH PYRHON2 AND PYTHON3 TO DEBUG IN PYCHARM | I'v already install python3 in my windows, but recently i need to use python 2 for a project. I created a new environment in my anaconda, but in pycharm I when wanted to debug the python2 code, a problem occured:
*(Connection to Python debugger failed
Socket operation on nonsocket: configure Blocking)*
I can and only can debug python 3 code in pycharm in another environment ,there's no problem, because python3 is in my windows path with a name python(am I right?), and I add python2 to my windows path too, but I renamed it python2 not python to avoid th same path names. Is this the problem why pycharm can't recognize python2 and to debug my python2 code? If it is , how can I solve it to make pycharm can debug both python2 and python3 . Or If it isn't , what's the problem? Thank you guys!! | <python><pycharm> | 2019-11-18 12:59:46 | LQ_EDIT |
58,915,746 | SQL Server select multiple entries from a single column into a single row result | <p>I need to extract some system user data from table "userrole" into a configuration record, but these user permissions are held in a single column and identified by a different roleid.</p>
<p>So my userrole data table looks like this,</p>
<pre><code>UserID RoleID Discriminator
int int NVarChar
3483 1 Pathologist
3483 2 Histotech
3483 3 Configuration
3483 4 WebViewer
3484 1 Pathologist
3484 4 WebViewer
3485 1 Pathologist
3485 4 WebViewer
3487 1 Pathologist
3487 2 Histotech
3487 3 Configuration
3487 4 WebViewer
3488 1 Pathologist
3488 2 Histotech
3488 3 Configuration
3488 4 WebViewer
</code></pre>
<p>and my target result is </p>
<pre><code>3483 Pathologist Histotech Configuration WebViewer
3484 Pathologist WebViewer
3484 Pathologist WebViewer
3487 Pathologist Histotech Configuration WebViewer
</code></pre>
<p>etc.</p>
<p>But every attempt at "grouping by" just still me multiple rows returned, for example</p>
<pre><code> select USERID
,(select Discriminator where roleid = 1) as Pathologist
,(select Discriminator where roleid = 2) as Histologist
,(select Discriminator where roleid = 3) as Configuration
,(select Discriminator where roleid = 4) as Web
FROM [Workflow].[UserRole]
group by userid, RoleID, discriminator
</code></pre>
<p>gives </p>
<pre><code> USERID Pathologist Histologist Configuration Web
3483 Pathologist NULL NULL NULL
3483 NULL Histotech NULL NULL
3483 NULL NULL Configuration NULL
3483 NULL NULL NULL WebViewer
3484 Pathologist NULL NULL NULL
3484 NULL NULL NULL WebViewer
3485 Pathologist NULL NULL NULL
3485 NULL NULL NULL WebViewer
</code></pre>
<p>Trying to use a DISTINCT or MIN function on the userid as suggested in <a href="https://stackoverflow.com/questions/11937206/sql-query-multiple-columns-using-distinct-on-one-column-only">SQL Query Multiple Columns Using Distinct on One Column Only</a> (not quite the same scenario I know) also still gives me the same multiple row results.</p>
<p>I have reached a bit if a block as to what to try next, so any suggestions most gratefully received.</p>
| <sql><sql-server><select><row><col> | 2019-11-18 13:31:09 | LQ_CLOSE |
58,917,659 | difference between npm run and nmp start? | <p>we have a lot of ts code which we can compile and run via "npm run dev". This allows us to hit the test js code via localhost. however, in the chrome debugger, 90% of the code is not visible (anonymous), and code which is not is too generic (such as find) to figure out how the thing which the debugger is showing as being slow or called a lot relates to our source code.</p>
| <javascript><npm> | 2019-11-18 15:14:51 | LQ_CLOSE |
58,919,064 | Why in C++ do static_cast<unsigned> of negative numbers differ if the number is constant or not | <p>What's the C++ rules that means <strong>equal</strong> is <em>false</em>?. Given:</p>
<pre><code>float f {-1.0};
bool equal = (static_cast<unsigned>(f) == static_cast<unsigned>(-1.0));
</code></pre>
<p>E.g. <a href="https://godbolt.org/z/fcmx2P" rel="noreferrer">https://godbolt.org/z/fcmx2P</a></p>
<pre><code>#include <iostream>
int main()
{
float f {-1.0};
const float cf {-1.0};
std::cout << std::hex;
std::cout << " f" << "=" << static_cast<unsigned>(f) << '\n';
std::cout << "cf" << "=" << static_cast<unsigned>(cf) << '\n';
return 0;
}
</code></pre>
<p>Produces the following output:</p>
<pre><code> f=ffffffff
cf=0
</code></pre>
| <c++><casting> | 2019-11-18 16:31:45 | HQ |
58,919,753 | CSS - how to target only one element with desired class in div? | <div class="menu">
<ul>
<li>
<ul class="sub-menu">
<li>
<ul class="sub-menu">
<li></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
Could You please tell me how to target just first ul element with "sub-menu" class as on an example above? Every pseudo-class I know targets both "sub-menu" ul-s at the same time. | <html><css><css-selectors> | 2019-11-18 17:11:40 | LQ_EDIT |
58,920,848 | Creates a text on a site and retrieves it? c# | <p>I would like to know if there is a text editor or a file uploader/downloader (like pastebin or mega) but for C# program</p>
<p>I explain myself: I am making a program for my college, I would like that when everyone opens my program, that everyone is the same text file, that it can be modified and then saved and when the others load it, there will be the modifications on it</p>
<p>I don't know if it's very clear, but I'd like not to go through servers because I don't understand anything about them</p>
<p>Will there be a solution?</p>
<p>Thank you. </p>
| <c#><file> | 2019-11-18 18:33:50 | LQ_CLOSE |
58,921,593 | (Java)How can I check if an 2d array contains a certain line? | If given a 2D array, for example int[][] arr = {{2,3}, {53, 2}, {23,13}}; how can i check if the row {53, 2} exist in the array?
I have the following code:
```
int[][] arr = {{1, 3}, {2, 2}, {2, 5}, {3, 1}, {3, 4}, {3, 7}, {4, 3}, {4, 6}, {5, 2}, {5, 5},
{5, 8}, {6, 4}, {6, 7}, {7, 3}, {7, 6}, {7, 9}, {8, 5}, {8, 8}, {9, 7}};
for(int i = 0; i < 11; i++) {
for(int j = 0; j < 11; j++) {
//here i want to check if arr contains the row {i, j}
}
}
}
```
How can this be done simply and efficiently? | <java><arrays> | 2019-11-18 19:28:23 | LQ_EDIT |
58,922,602 | i cannot use my arraylist in class fragment | i try to use arraylist in fragment
my arraylist not work in fragment class.
please help me fix this
before i use this code in main activity, and then i added menu fragment i move this code to this fragment
and then my **arraylist** get error
```
public class HomeFragment extends Fragment {
RecyclerView mRecyclerView;
MyAdapter myAdapter;
public HomeFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_home, container, false);
mRecyclerView = v.findViewById(R.id.recyclerView);
mRecyclerView.setLayoutManager(new RelativeLayout(this));
myAdapter = new MyAdapter(this, getMyList());
mRecyclerView.setAdapter(myAdapter);
return v;
}
private ArrayList<Model> getMyList(){
ArrayList<Model> models = new ArrayList<>();
Model m = new Model();
m.setTitle("Al-Lahab");
m.setDescription("Surah Al-Lahab adalah surat ke-111 dalam Al-Qur'an.");
m.setDetails("تَبَّتْ يَدَا أَبِي لَهَبٍ وَتَبّ\n"
);
m.setImg(R.drawable.al_lahab);
models.add(m);
return models;
}
``` | <java><android><android-fragments><arraylist> | 2019-11-18 20:42:23 | LQ_EDIT |
58,923,552 | count only letter abcdefghijklmnopqrstuvwxyz in a list | How to count only letter abcdefghijklmnopqrstuvwxyz in a list in alphabetical order without "Counter"??
For example
input
['Bro', 'lo', '27', 'b']
output
[['b', 1], ['l', 1], ['o', 2], ['r', 1]]
| <python><python-3.x> | 2019-11-18 22:00:46 | LQ_EDIT |
58,924,617 | componentWillReceiveProps has been renamed | <p>I'm using Material ui SwipeableViews That use ReactSwipableView package, I'm getting this error on the console</p>
<blockquote>
<p>react-dom.development.js:12466 Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See for details.</p>
<ul>
<li>Move data fetching code or side effects to componentDidUpdate.</li>
<li>If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: </li>
<li>Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run <code>npx react-codemod rename-unsafe-lifecycles</code> in your project source folder.</li>
</ul>
<p>Please update the following components: ReactSwipableView</p>
</blockquote>
<p>is there any way to get rid of this error i did try UNSAFE_componentWillReceiveProps but nothing change</p>
| <reactjs> | 2019-11-18 23:50:54 | HQ |
58,929,997 | trying to use bulksms,com api using guzzle in laravel but returning erros | i have been trying to use guzzle for sending bulk sms from bulksms.com and it is returning this error,guzzlehttp\exception\clientexception client error: post https://api.bulksms.com/v1/messages resulted in a 401 full authentication is required to access this resource response: : "type" "https://developer.bulksms.com/json/v1/errors#authentication-failed
my code
```
$client = new Client([
'base_uri'=>'https://www.bulksms.com/',
'timeout'=>'900.0'
]); //GuzzleHttp\Client
// $result = $client->post('', [
// 'form_params' => [
// 'sample-form-data' => 'value'
// ]
// ]);
$result = $client->request('POST','https://api.bulksms.com/v1/messages', [
'form_params' => [
'username' => 'username',
'password' => '****',
'sender' => 'my appname',
'recipients' => '+5555555555',
'message' => 'Testing message',
]
]); | <php><laravel><guzzle><laravel-5.8><bulksms> | 2019-11-19 08:53:37 | LQ_EDIT |
58,930,851 | android: button click error (string array) | When I select an item with a spinner and click the button, I want to create a program that generates an array of choices with the spinner, such as 5 to add random numbers and float them in a textview. There are no errors, but when running, click the button to exit the program. Which part is the problem? The entire code is as follows:
package ac.kr.kgu.esproject;
import android.app.Activity;
import android.os.Bundle;
import android.provider.Settings.System;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
public class ArrayAdderActivity extends Activity {
static int numnum;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Spinner s = (Spinner) findViewById(R.id.spinner);
final Button button1 = (Button) findViewById(R.id.button1);
final TextView text1 = (TextView) findViewById(R.id.textv);
ArrayAdapter adapter = ArrayAdapter.createFromResource(
this, R.array.planets, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s.setAdapter(adapter);
s.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String num=s.getSelectedItem().toString();
numnum = Integer.parseInt(num);
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
int array1[] = null;
String string1[];
for (int i = 0; i<numnum; i++){
array1[i]=((int)(Math.random()));
text1.setText("num #"+(i+1)+": "+array1[i]+"/n");
}
}
});
}
} | <android><button> | 2019-11-19 09:40:02 | LQ_EDIT |
58,932,620 | c# open another form from current form button click | <p>I want to open another form on button click and it is image viewer form and i want to enter data on first form with reference as second form but not working, all controls are there on second form itself even in minimization , after closing that form only allowing to enter data on first form.</p>
| <c#><asp.net><.net><winforms><desktop-application> | 2019-11-19 11:06:46 | LQ_CLOSE |
58,933,420 | hello i want to open a file (pdf,docx) in the browser with nodejs ,can any one help me out please . for example with php i'can do it like bellow a | $doc = Document::findOrFail($id);
$path = Storage::disk('local')->getDriver()->getAdapter()->applyPathPrefix($doc->file);
$type = $doc->mimetype;
Log::addToLog('Document ID '.$id.' à été consulté');
if ($type == 'application/pdf' || $type == 'image/jpeg' ||
$type == 'image/png' || $type == 'image/jpg' || $type == 'image/gif')
{
return response()->file($path, ['Content-Type' => $type]);
}
elseif ($type == 'video/mp4' || $type == 'audio/mpeg' ||
$type == 'audio/mp3' || $type == 'audio/x-m4a')
{
return view('documents.play',compact('doc'));
}
else {
return response()->file($path, ['Content-Type' => $type]);
}
} | <node.js> | 2019-11-19 11:48:17 | LQ_EDIT |
58,934,022 | React-Native: Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template | <p>While executing <code>npx react-native init MyProject</code> I ran into the following error:</p>
<pre><code>✖ Installing CocoaPods dependencies (this may take a few minutes)
error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
</code></pre>
<p>Which seems to be related to an earlier error displayed:</p>
<pre><code>checking for arm-apple-darwin-gcc... /Library/Developer/CommandLineTools/usr/bin/cc -arch armv7 -isysroot
checking whether the C compiler works... no
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'
</code></pre>
<p>XCode and its CLI seem to all run fine.</p>
<p>My configuration:</p>
<ul>
<li>MacOS Catalina 10.15.1 (19B88) </li>
<li>NPM 6.11.3 </li>
<li>React-Native 0.61.4 </li>
<li>XCode 11.2.1 (11B500)</li>
</ul>
<p>Any leads appreciated.</p>
| <ios><react-native><npm> | 2019-11-19 12:21:36 | HQ |
58,934,303 | Convert letters to lowercase from an array in JS | <p>I have the following code:</p>
<pre><code>var str = "abcabcABCABC"
var chars = str.split("");
var lettersCount = {};
for (var i = 0; i < chars.length;i++)
{
if (lettersCount[chars[i]] == undefined )
lettersCount[chars[i]] = 0;
lettersCount[chars[i]] ++;
}
for (var i in lettersCount)
{
console.log(i + ' = ' + lettersCount[i]);
}
</code></pre>
<p>This code is counting how many same letters are in a word. What am I trying is to convert the uppercase letters to lowercase so it should show like this: a - 4, b -4, now it shows: a - 2, A - 2.
I've just started with Js so please be good with me. :)</p>
| <javascript><uppercase><lowercase> | 2019-11-19 12:37:01 | LQ_CLOSE |
58,936,470 | Why my <div class="header"> doesn't display full width 100% in smallscreen | <p><a href="https://i.stack.imgur.com/kGvkD.jpg" rel="nofollow noreferrer">enter image description here</a></p>
<p>Here is the problem</p>
| <html><css> | 2019-11-19 14:37:19 | LQ_CLOSE |
58,936,628 | PHP - PDO OOP MySQL database connection is being repeated, is that a normal behavior? | <p>I am using a class for db connection like this...</p>
<pre><code>class Dbh
{
private $host;
private $dbName;
private $password;
private $dbUser;
private $charset;
protected function connect ()
{
$this->host = 'localhost';
$this->dbName = 'test';
$this->password = '';
$this->dbUser = 'root';
$this->charset = 'utf8mb4';
try
{
$dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->dbName . ';charset=' . $this->charset;
$pdo = new PDO($dsn, $this->dbUser, $this->password);
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
return $pdo;
}
catch (PDOException $exception)
{
$message = 'Connection failed:' . $exception->getMessage();
return $message;
}
}
}
</code></pre>
<p>... Now what worries me if I echo in <code>try</code> for example <code>echo 'Connected';</code> and call for example...</p>
<pre><code>$user = new User();
$users = $user->getAllUsers();
$update = $user->updateUser();
$insert = $user->insertUsers();
</code></pre>
<p>It will output 3 times 'Connected' on a page, where it should do probably only once as 1 connection is enough. </p>
<p>How to fix this?</p>
| <php><mysql><oop><pdo> | 2019-11-19 14:46:33 | LQ_CLOSE |
58,937,509 | Is there a better solution to this JavaScript code? | I'm trying to create QR codes in tables.
Links from which i need QR code is in div tag innerHTML.
<script type="text/javascript">
function myfunction() {
// PAGE 1 STARTS
// ROW 1
var TextInsideA2 = document.getElementById('A2').innerHTML;
document.getElementById('barcodeA2').src = "https://api.qrserver.com/v1/create-qr-code/?data='" + TextInsideA2 +"'&size=85x85";
var TextInsideA3 = document.getElementById('A3').innerHTML;
document.getElementById('barcodeA3').src = "https://api.qrserver.com/v1/create-qr-code/?data='" + TextInsideA3 +"'&size=85x85";
var TextInsideA4 = document.getElementById('A4').innerHTML;
document.getElementById('barcodeA4').src = "https://api.qrserver.com/v1/create-qr-code/?data='" + TextInsideA4 +"'&size=85x85";
// ROW 2
var TextInsideA5 = document.getElementById('A5').innerHTML;
document.getElementById('barcodeA5').src = "https://api.qrserver.com/v1/create-qr-code/?data='" + TextInsideA5 +"'&size=85x85";
var TextInsideA6 = document.getElementById('A6').innerHTML;
document.getElementById('barcodeA6').src = "https://api.qrserver.com/v1/create-qr-code/?data='" + TextInsideA6 +"'&size=85x85";
var TextInsideA7 = document.getElementById('A7').innerHTML;
document.getElementById('barcodeA7').src = "https://api.qrserver.com/v1/create-qr-code/?data='" + TextInsideA7 +"'&size=85x85";
// ROW 3
var TextInsideA8 = document.getElementById('A8').innerHTML;
document.getElementById('barcodeA8').src = "https://api.qrserver.com/v1/create-qr-code/?data='" + TextInsideA8 +"'&size=85x85";
var TextInsideA9 = document.getElementById('A9').innerHTML;
document.getElementById('barcodeA9').src = "https://api.qrserver.com/v1/create-qr-code/?data='" + TextInsideA9 +"'&size=85x85";
var TextInsideA10 = document.getElementById('A10').innerHTML;
document.getElementById('barcodeA10').src = "https://api.qrserver.com/v1/create-qr-code/?data='" + TextInsideA10 +"'&size=85x85";
// ROW 4
var TextInsideA11 = document.getElementById('A11').innerHTML;
document.getElementById('barcodeA11').src = "https://api.qrserver.com/v1/create-qr-code/?data='" + TextInsideA11 +"'&size=85x85";
var TextInsideA12 = document.getElementById('A12').innerHTML;
document.getElementById('barcodeA12').src = "https://api.qrserver.com/v1/create-qr-code/?data='" + TextInsideA12 +"'&size=85x85";
var TextInsideA13 = document.getElementById('A13').innerHTML;
document.getElementById('barcodeA13').src = "https://api.qrserver.com/v1/create-qr-code/?data='" + TextInsideA13 +"'&size=85x85";
// PAGE 1 ENDS
}
window.onload = myfunction;
</script>
This code works but QRs are generating slow and I need more of them.
Is there any better or "lightweight" solution that I can use instead of this? | <javascript> | 2019-11-19 15:28:03 | LQ_EDIT |
58,939,470 | Removing the Hardcoded MYSQL connection string | [this it the connection string that is hardcoded][
ost <<" DRIVER=SQL Server Native Client 11.0; SERVER=Avchar-D\\ENTERPRISE2014;Database="<< czDataSourceName << ";Uid=da; Pwd=P@ssw0rd10;Integrated Security=SSPI;Persist Security Info=False";
| <c++><sqlconnection><hardcoded> | 2019-11-19 17:12:06 | LQ_EDIT |
58,942,470 | Having trouble compiling an ultimate tic tac to code I found because it is in a different coding language than what I am learning | <p>I have a code that I want to run (mega tic tac toe code) that I got from the description of a video, however its in a different language that i am used to (Im learning java and the code is in C#) so I don't know how I should go about compiling this code. I messed around with some of the more well known compilers like visual studio and mono, however both seemed confusing to me as I am used to the eclipse compiler for java. Here is the video I am referring to. the code should be in the description of the video <a href="https://www.youtube.com/watch?v=oJ3TQdgkfBQ&t=366s" rel="nofollow noreferrer">https://www.youtube.com/watch?v=oJ3TQdgkfBQ&t=366s</a>.
Please let me know any tips or solutions</p>
| <c#><compilation> | 2019-11-19 20:41:05 | LQ_CLOSE |
58,943,242 | How to take backup of a Bigquery view script using BQ? | I need to take backup of a view while testing the new bug fixes in the same bq view script. can i use a script to do so?
Also how to I pass table name as a argument in the BQ script? | <google-bigquery> | 2019-11-19 21:42:36 | LQ_EDIT |
58,944,555 | How to strip every character from a string except numeric characters and decimal point | <p>'US $109.90/ea' should become '109.90'</p>
| <javascript><regex> | 2019-11-19 23:44:46 | LQ_CLOSE |
58,944,956 | How do I read content from a .txt file and then find the average of said content in java | I was tasked with reading a data.txt file using the scanner import. The data.txt file looks like this:
```
1 2 3 4 5 6 7 8 9 Q
```
I need to read and find the average of these numbers, but stop when I get to something that is not an integer.
This is the code that I have so far.
```
public static double fileAverage(String filename) throws FileNotFoundException {
Scanner input = new Scanner(System.in);
String i = input.nextLine();
while (i.hasNext);
return fileAverage(i); // dummy return value. You must return the average here.
} // end of method fileAverage
```
As you can see I did not get very far and I cannot figure this out. Thank you for your help. | <java><file><java.util.scanner><average><throws> | 2019-11-20 00:38:45 | LQ_EDIT |
58,945,950 | how to get different columns by joining two tabl | Problem:
I am trying to join table1 and table2 to get the wk_nmbr for begin_date and end_date.
**table1**
begin_date,
end_date
**table2**
cal_date,
wk_nmbr
**Condition:**
table1.begin_date=table2.cal_date and
table1.end_date=table2.cal_date
**expected result in table 3:**
begin_date,
wk_nmbr_begin,
end_date,
wk_nmbr_end,
| <sql><sql-server> | 2019-11-20 02:56:59 | LQ_EDIT |
58,951,770 | Grid System Horizontal Order | <p>Is there any way I can accomplish the following order without adding any div's?</p>
<p><strong>t1 t2 t3</strong></p>
<p><strong>d1 d2 d3</strong></p>
<pre><code><dl>
<dt>t1</dt>
<dd>d1</dd>
<dt>t2</dt>
<dd>d2</dd>
<dt>t3</dt>
<dd>d3</dd>
</dl>
</code></pre>
| <html><css><bootstrap-4><grid> | 2019-11-20 10:13:09 | LQ_CLOSE |
58,952,835 | How do i extract or cut particular data from file | Linux | | I have a Scenario where I want to cut only particular data from file
My file contain below data
/f/demo/Dummy/g/STSE/abc.xml:262:123: <NAME ="ABC_BCD">
/f/demo/Dummy/g/STSE/cde.xml:263:ABX: <NAME ="ABC_BCDXXXXX OBH=TYPE">
/f/demo/Dummy/g/STSE/12a.xml:264:2:456: <NAME ="ABC_BCD">
/f/demo/Dummy/g/STSE/a2c.xml:265: <NAME ="ABC_BCD">
/f/demo/Dummy/g/STSE/wed.xml:266: <NAME ="ABC_BCD" TYPE=LS OBG=UI RML=HJ>
/f/demo/Dummy/g/STSE/as.xml:267:234: <NAME ="ABC_BCD" TYPE=LS OBG=UI RML=HJ>
/f/demo/Dummy/g/STSE/ass.xml:268:LMD : <NAME ="ABC_BCD" TYPE=LS OBG=UI>
/f/demo/Dummy/g/STSE/sc.xml:269:22221: <NAME ="ABC_BCD" TYPE=LS OBG=UI RML=HJ>
I need output in below format only excluding duplicate
<NAME ="ABC_BCD">
<NAME ="ABC_BCDXXXXX OBH=TYPE">
<NAME ="ABC_BCD">
<NAME ="ABC_BCD">
<NAME ="ABC_BCD" TYPE=LS OBG=UI RML=HJ>
<NAME ="ABC_BCD" TYPE=LS OBG=UI RML=HJ>
<NAME ="ABC_BCD" TYPE=LS OBG=UI>
<NAME ="ABC_BCD" TYPE=LS OBG=UI RML=HJ>
I used the below command not worked
sed 's/[[:digit:]]/+[[:space:]]/+ filename | <shell><sed> | 2019-11-20 11:03:42 | LQ_EDIT |
58,953,776 | i can't solve my Error i'm doing CHECKBOX in recyclerview | '''
package com.example.project.Holder;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.example.project.Model.User;
import com.example.project.R;
import java.util.List;
public class AttendanceViewHolder {
private Context mContext;
private UserAdapter userAdapter;
public void setConfig(RecyclerView recyclerView,Context context,List<User> users,List<String> keys){
mContext=context;
userAdapter=new UserAdapter(users,keys);
recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerView.setAdapter(userAdapter);
}
class UserItemView extends RecyclerView.ViewHolder {
public ImageView attendanceitem_imageview;
private TextView attendanceitem_textview;
private String key;
public CheckBox attendance_checkBox;
public UserItemView(ViewGroup parent) {
super(LayoutInflater.from(mContext).
inflate(R.layout.item_attendance_bottom, parent, false));
attendanceitem_imageview = (ImageView) itemView.findViewById(R.id.attendanceitem_imageview);
attendanceitem_textview = (TextView) itemView.findViewById(R.id.attendanceitem_textview);
attendance_checkBox =(CheckBox) itemView.findViewById(R.id.attendance_checkBox);
}
public void bind(User user, String key) {
attendanceitem_textview.setText(user.getUsername());
this.key = key;
}
}
class UserAdapter extends RecyclerView.Adapter<UserItemView> {
List<User> userList;
private List<String> mkeys;
public UserAdapter(List<User> userList, List<String> mkeys) {
this.userList = userList;
this.mkeys = mkeys;
}
@NonNull
@Override
public UserItemView onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new UserItemView(parent);
}
@Override
public void onBindViewHolder(@NonNull UserItemView holder, int position) {
final int pos = position;
holder.attendance_checkBox.setChecked(userList.get(position).isCheckBox());
holder.attendance_checkBox.setTag(userList.get(position));
holder.bind(userList.get(position),mkeys.get(position));
Glide.with(holder.attendanceitem_imageview.getContext())
.load(userList.get(position).profileImageUrl)
.apply(new RequestOptions())
.into(holder.attendanceitem_imageview);
holder.attendance_checkBox.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
CheckBox attendance_checkBox = (CheckBox) view;
User contact = (User) attendance_checkBox.getTag();
contact.setCheckBox(attendance_checkBox.isChecked());
userList.get(pos).setCheckBox(attendance_checkBox.isChecked());
}
});
}
@Override
public int getItemCount() {
return userList.size();
}
}
}
'''
package com.example.project.Model;
import android.net.Uri;
import android.widget.ImageView;
public class User {
public String email;
public String profileImageUrl;
public String username;
public String uid;
public String pushToken;
public String job;
public String comment;
public Boolean checkBox;
public User() {
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getProfileImageUrl() {
return profileImageUrl;
}
public void setProfileImageUrl(String profileImageUrl) {
this.profileImageUrl = profileImageUrl;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getPushToken() {
return pushToken;
}
public void setPushToken(String pushToken) {
this.pushToken = pushToken;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public boolean isCheckBox() {
return checkBox;
}
public void setCheckBox(Boolean chechBox) {
this.checkBox = chechBox;
}
}
'''
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
at com.example.project.Model.User.isCheckBox(User.java:77)
at com.example.project.Holder.AttendanceViewHolder$UserAdapter.onBindViewHolder(AttendanceViewHolder.java:80)
at com.example.project.Holder.AttendanceViewHolder$UserAdapter.onBindViewHolder(AttendanceViewHolder.java:58)
at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6937)
at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6979)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5896)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6163)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6002)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5998)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2226)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1558)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1518)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:613)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4033)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3750)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4303)
at android.view.View.layout(View.java:21927)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
at android.view.View.layout(View.java:21927)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:21927)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
at android.view.View.layout(View.java:21927)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:779)
at android.view.View.layout(View.java:21927)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3080)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2590)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1721)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7598)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
at android.view.Choreographer.doCallbacks(Choreographer.java:790)
at android.view.Choreographer.doFrame(Choreographer.java:725)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:951)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
''' | <android> | 2019-11-20 11:53:39 | LQ_EDIT |
58,954,935 | How to set a checkbox based on a string | <p>I have a function which reads some data from a txt file and than writes the data into my project.</p>
<p>My problem is that i can't fill my checkboxes because they don't recognize strings.</p>
<p>For example</p>
<pre><code>CheckBox1.IsChecked = File.ReadLines(filename).Skip(0).Take(1).First();
</code></pre>
<p>It says that a string can't be converted into a bool value.</p>
<p>The first line in my txt file is obviously false in this example so the Output is not the problem.</p>
| <c#><wpf> | 2019-11-20 12:59:18 | LQ_CLOSE |
58,955,733 | How can I Avoid NaN,While adding numbers from Array in Java Script? | <p><strong>While I get Inputs from text box,and adding those input if i leave space then my result comes with NAN.</strong></p>
| <javascript> | 2019-11-20 13:39:17 | LQ_CLOSE |
58,958,328 | Is there any way to have text size change with window size? | <p>I need <code>font-size</code> to be relative to the windows size. Is there any way that I can do that?</p>
| <javascript><html><css> | 2019-11-20 15:48:06 | LQ_CLOSE |
58,960,843 | How to detect division by zero using std::error_code | <p>I want to detect division by zero using std::error_code. Without the use of exceptions. How can I do that? Write some simple examples.</p>
| <c++><math><std><divide> | 2019-11-20 18:10:51 | LQ_CLOSE |
58,961,900 | While Loop stops working before condition C++ | <p>The while loop should stop at 12 but ends at 9. Also, please ignore I spelled inches incorrectly.</p>
<pre><code>int main() {
double rainFall[12];
int i = 0;
while(rainFall[i] > 0 && i < 12 ){
cout << "Enter your rainfaill in incehs for month #" << i + 1 << ": " ;
cin >> rainFall[i];
i++;
}
}
</code></pre>
<p>Input / Output:
Enter your rainfaill in incehs for month #1: 9 </p>
<p>Enter your rainfaill in incehs for month #2: 9 </p>
<p>Enter your rainfaill in incehs for month #3: 9</p>
<p>Enter your rainfaill in incehs for month #4: 9</p>
<p>Enter your rainfaill in incehs for month #5: 9</p>
<p>Enter your rainfaill in incehs for month #6: 9</p>
<p>Enter your rainfaill in incehs for month #7: 9</p>
<p>Enter your rainfaill in incehs for month #8: 9</p>
<p>Enter your rainfaill in incehs for month #9: 9</p>
| <c++> | 2019-11-20 19:24:18 | LQ_CLOSE |
58,962,573 | C language : 0xC0000374: A heap has been corrupted (parameters: 0x77AAB960) | The code bellow sometimes throws exceptions similar to:
Exception thrown at 0x779CC19E (ntdll.dll) in Matriks.exe: 0xC0000005: Access violation reading location 0x0000001D.
I'm new to C and just learned to use pointers. Any tips ? Are there other problems in my code that are worth criticizing ?
```
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
main()
{
int *Matrix_01, *Matrix_02;
int a, b, i, n,valid=1;
srand(time(0));
do
{
printf("Insert number of rows: ");
scanf("%d", &a);
printf("Insert number of columns: ");
scanf("%d", &b);
if (a >= 0 && b >= 0)
valid = 0;
else
{
printf("Invalid input!");
system("pause>null & cls");
}
} while (valid == 1);
Matrix_01 = (int *)malloc(a * b * sizeof(int)+1);
Matrix_02 = (int *)malloc(a * b * sizeof(int)+1);
for (i = 0; i < a; i++)
for (n = 0; n < b; n++)
{
Matrix_01[a*i + n] = rand() % 50;
Matrix_02[a*i + n] = rand() % 50;
}
printf("\nFirst matrix:\n");
for (i = 0; i < a; i++)
{
printf("\n");
for (n = 0; n < b; n++)
{
printf("%4d", Matrix_01[a*i + n]);
}
}
printf("\n\nSecond Matrix:\n");
for (i = 0; i < a; i++)
{
printf("\n");
for (n = 0; n < b; n++)
{
printf("%4d", Matrix_02[a*i + n]);
}
}
printf("\n\nAddition:\n");
for (i = 0; i < a; i++)
{
printf("\n");
for (n = 0; n < b; n++)
{
printf("%4d", Matrix_01[a*i + n]+Matrix_02[a*i + n]);
}
}
printf("\n\nSubtraction:\n");
for (i = 0; i < a; i++)
{
printf("\n");
for (n = 0; n < b; n++)
{
printf("%4d", Matrix_01[a*i + n] - Matrix_02[a*i + n]);
}
}
printf("\n");
system("pause>null");
}
``` | <c> | 2019-11-20 20:10:45 | LQ_EDIT |
58,963,394 | Best way to find how many times an item in a list repeats in a row, in C#? | <p>Given a list, for example:
<code>List<int> _ = new List<int>() { 1, 1, 1, 3, 3, 4, 4, 1, 1, 8, 8, 8, 5, 6, 7, 7, 7, 7, 8, 8 };</code></p>
<p>What would be the best / fastest / most efficient way to find how many times an item repeats in a row, in C#?
For this list, the result I'd be looking for is something that looks like this:</p>
<p>1 * 3</p>
<p>3 * 2</p>
<p>4 * 2</p>
<p>1 * 2</p>
<p>8 * 3</p>
<p>5 * 1</p>
<p>6 * 1</p>
<p>7 * 4</p>
<p>8 * 2</p>
<p>Doesn't have to be in this odd multiplication format, I think it makes it a bit easier to understand.</p>
<p>I've been trying looping over the List and comparing each item to the next, but I inevitably get stuck, and don't really know what to do.</p>
| <c#><list><iteration> | 2019-11-20 21:08:06 | LQ_CLOSE |
58,967,161 | How to populate a dictionary's value with a list using for loop while? | <p>I wonder how to populate a dictionary's value, for example, having a list with 1000 values or even up to 1000, using for loops while</p>
<pre><code>dict = {}
values= [1,1,1,1,1,1,1,1,1,1,..,1]
dict={'x':[1,1,1,1,1,1,1,1,1,1,..,1]}
</code></pre>
| <python><list><dictionary> | 2019-11-21 04:07:06 | LQ_CLOSE |
58,970,558 | Java NullPointerException on concatenating Double types but not on String types | <pre><code> Double d1 = null;
Double d2 = null;
System.out.println(d1+d2);//throw NullPointerException
String s1 = null;
String s2 = null;
System.out.println(s1+s2);//doesn't throw any exception prints nullnull
</code></pre>
<p>Since both Double and String are of type Object then why Double types throw exception??</p>
| <java><nullpointerexception> | 2019-11-21 08:41:30 | LQ_CLOSE |
58,971,126 | PHP is not recognizing file upload extension | <p>I have the following array sent by ajax when echoed in php</p>
<pre><code>[file] => Array
( [name] => XXXX.jpg [type] => image/jpeg [tmp_name] => D:\xampp\tmp\phpC5F2.tmp
[error] => 0 [size] => 25245 )
</code></pre>
<p>and the following code to process the upload:</p>
<pre><code>if(isset($_FILES['file'])) {
$natid = '9999';
$target_dir = "../uploads/";
$fname = $_FILES['file']['name'];
$target_file = $target_dir . $natid .'/'. $fname;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
if($imageFileType == "jpg" && $imageFileType == "png" && $imageFileType == "jpeg" && $imageFileType == "gif") {
$check = getimagesize($_FILES["file"]["tmp_name"]);
if($check !== false) { // !== not equal
echo "File is an image - " . $check["mime"] . ".<br>";
} else {
echo "the file is not an image.";
}
} elseif ($imageFileType == "pdf"){
echo "File is a PDF - " . $check["mime"] . ".<br>";
} else {
echo "Sorry, only PDF, JPG, JPEG, PNG & GIF files are allowed.";
}
}
</code></pre>
<p>When I run the code I get the reply from php saying that file is neither an image nor a PDF although </p>
<blockquote>
<p>$imageFileType gives me 'jpg'</p>
</blockquote>
| <php><html><ajax><pdf> | 2019-11-21 09:12:45 | LQ_CLOSE |
58,971,397 | For loop using more than one list in Python | <p>I'm looking for solution to my problem. At the moment I have two list of elements:</p>
<pre><code>column_width = ["3", "3", "6", "8", "4", "4", "4", "4"]
fade = ["100", "200", "300"]
</code></pre>
<p>What I want to achieve is to create for loop which wil give me following output:</p>
<pre><code>column-3-fade-100
column-3-fade-200
column-6-fade-300
column-8-fade-100
column-4-fade-200
...
</code></pre>
<p>Nested for loop doen't work for me:</p>
<pre><code>for i in fade:
for c in column_width_a:
print("column-{0}-fade-{1}".format(c, i))
</code></pre>
<p>Is there any other way to generate this output?</p>
| <python><loops><for-loop><nested> | 2019-11-21 09:26:16 | HQ |
58,971,881 | Remove the web apps using google apps script | Suppose i have list of web apps in Google admin console. I want to remove the webapps from the list.I know i can remove my webapp from admin console one by one.
But i want to remove(or revoke) the web apps using google apps script. Can we do it? if yes,can you please post the code.
Thanks.
| <google-apps-script><google-admin-sdk><gsuite> | 2019-11-21 09:50:15 | LQ_EDIT |
58,974,054 | How to this box in C? | %@@@%
%...%
%...%
%...%
%@@@%
Where is my mistake pls let me know i am beginner i just started programing. I would apreciate your help
#include<stdio.h>
int main(){
int i,j,num;
scanf("%d", &num);
for(i=0;i<num;i++){
for(j=0;j<num;j++){
if((i==0)||(i==num-1)){
printf("@");
}
else if((j==i-1)||(j==num-1)){
printf("%");
}
else
printf(".");
}
printf("\n");
}
}
| <c> | 2019-11-21 11:35:31 | LQ_EDIT |
58,974,315 | hi, i have a page with side navbar, i want to move this side navbar when i change the page direction to rtl | I have a page which has one sidebar to open different pages. It is working as desired with direction left to right but I want to move this sidebar to the right side when i change the page direction to right to left.
Following is the HTML of my page.
I have searched on internet but I did not get any solution.
From my side I have tried to change the direction of the page in HTML but it is not working.
| <html><css> | 2019-11-21 11:48:34 | LQ_EDIT |
58,974,616 | Finding out if a big number is a perfect square numbers using C# | <p>Is there a fast and simple way to write a program in C#, that finds out if a big (something like 25 digits big) number is a perfect square or not?</p>
<p>Perfect squares are the numbers: 0^2=0,1^2=1,2^2=4,3^2=9,4^2=16,...</p>
| <c#><math><numbers><square><largenumber> | 2019-11-21 12:03:11 | LQ_CLOSE |
58,975,182 | Deprecation: Doctrine\ORM\Mapping\UnderscoreNamingStrategy without making it number aware is deprecated | <p>I'm using Symfony 4.3.8 and I can't find any information about thoses deprecations :</p>
<blockquote>
<p>User Deprecated: Creating Doctrine\ORM\Mapping\UnderscoreNamingStrategy without making it number aware is deprecated and will be removed in Doctrine ORM 3.0.</p>
<p>Creating Doctrine\ORM\Mapping\UnderscoreNamingStrategy without making it number aware is deprecated and will be removed in Doctrine ORM 3.0.</p>
</blockquote>
<p>I searched in stacktrace and found this :</p>
<pre><code>class UnderscoreNamingStrategy implements NamingStrategy
{
private const DEFAULT_PATTERN = '/(?<=[a-z])([A-Z])/';
private const NUMBER_AWARE_PATTERN = '/(?<=[a-z0-9])([A-Z])/';
/**
* Underscore naming strategy construct.
*
* @param int $case CASE_LOWER | CASE_UPPER
*/
public function __construct($case = CASE_LOWER, bool $numberAware = false)
{
if (! $numberAware) {
@trigger_error(
'Creating ' . self::class . ' without making it number aware is deprecated and will be removed in Doctrine ORM 3.0.',
E_USER_DEPRECATED
);
}
$this->case = $case;
$this->pattern = $numberAware ? self::NUMBER_AWARE_PATTERN : self::DEFAULT_PATTERN;
}
</code></pre>
<p>In this class, the constructor is always called without params, so $numberAware is always false.</p>
<p>This class is called in file which has been auto generated by the Symfony Dependency Injection, so I can't "edit" it ...</p>
<p>I thought maybe it was in doctrine.yaml :</p>
<pre><code>doctrine:
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
</code></pre>
<p>But I have not found any option to allow the number aware :(</p>
| <symfony><doctrine-orm><doctrine> | 2019-11-21 12:33:35 | HQ |
58,976,425 | AAPT: error: attribute android:requestLegacyExternalStorage not found | <p>collection error in AndroidManifest.xml</p>
<p>AAPT: error: attribute android:requestLegacyExternalStorage not found.</p>
<p>Although the attribute is there but it writes an error</p>
<p>My AndroidManifest.xml</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="android.apps">
<uses-feature android:name="android.hardware.wifi" android:required="false" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="@mipmap/launcher_icon"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/launcher_icon"
android:supportsRtl="true"
android:theme="@style/Theme.MaterialFiles"
tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">
<activity
android:name="android.apps.filelist.FileListActivity"
android:label="@string/file_list_title"
android:theme="@style/Theme.MaterialFiles.TransparentStatusBar"
android:visibleToInstantApps="true"
tools:ignore="UnusedAttribute">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="inode/directory" />
<data android:mimeType="resource/folder" />
<data android:mimeType="vnd.android.document/directory" />
</intent-filter>
<!-- @see android.apps.file.MimeTypes#isSupportedArchive(String) -->
<!--
~ We don't really support content URI archives.
~ TODO: Figure out a good way to allow choosing this activity only in our app, or
~ support content URI archives.
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/gzip" />
<data android:mimeType="application/java-archive" />
<data android:mimeType="application/rar" />
<data android:mimeType="application/zip" />
<data android:mimeType="application/vnd.android.package-archive" />
<data android:mimeType="application/vnd.debian.binary-package" />
<data android:mimeType="application/x-7z-compressed" />
<data android:mimeType="application/x-bzip2" />
<data android:mimeType="application/x-compress" />
<data android:mimeType="application/x-cpio" />
<data android:mimeType="application/x-deb" />
<data android:mimeType="application/x-debian-package" />
<data android:mimeType="application/x-gtar" />
<data android:mimeType="application/x-gtar-compressed" />
<data android:mimeType="application/x-java-archive" />
<data android:mimeType="application/x-lzma" />
<data android:mimeType="application/x-tar" />
<data android:mimeType="application/x-xz" />
</intent-filter>
-->
<!-- @see https://android.googlesource.com/platform/packages/apps/DocumentsUI/+/master/AndroidManifest.xml -->
<intent-filter>
<action android:name="android.intent.action.OPEN_DOCUMENT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="*/*" />
</intent-filter>
<!--
~ Unusable until we implement DocumentsProvider.
<intent-filter>
<action android:name="android.intent.action.CREATE_DOCUMENT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="*/*" />
</intent-filter>
-->
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="*/*" />
</intent-filter>
<!--
~ Unusable until we implement DocumentsProvider.
<intent-filter>
<action android:name="android.intent.action.OPEN_DOCUMENT_TREE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
-->
<intent-filter>
<action android:name="android.apps.intent.action.VIEW_DOWNLOADS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<activity
android:name="android.apps.filelist.OpenFileAsDialogActivity"
android:autoRemoveFromRecents="true"
android:icon="@drawable/open_as_icon"
android:label="@string/file_open_as_title"
android:theme="@style/Theme.MaterialFiles.Translucent" />
<activity
android:name="android.apps.ftpserver.FtpServerActivity"
android:label="@string/ftp_server_title"
android:launchMode="singleTop"
android:theme="@style/Theme.MaterialFiles">
<intent-filter>
<action android:name="android.apps.intent.action.MANAGE_FTP_SERVER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="android.apps.filelist.FileListActivity" />
</activity>
<activity
android:name="apps.settings.SettingsActivity"
android:label="@string/settings_title"
android:launchMode="singleTop"
android:theme="@style/Theme.MaterialFiles">
<intent-filter>
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="android.apps.filelist.FileListActivity" />
</activity>
<activity
android:name="android.apps.settings.StandardDirectoriesActivity"
android:label="@string/settings_standard_directories_title"
android:launchMode="singleTop"
android:theme="@style/Theme.MaterialFiles">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="android.apps.settings.SettingsActivity" />
</activity>
<activity
android:name="android.apps.settings.BookmarkDirectoriesActivity"
android:label="@string/settings_bookmark_directories_title"
android:launchMode="singleTop"
android:theme="@style/Theme.MaterialFiles">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="android.apps.settings.SettingsActivity" />
</activity>
<activity
android:name="android.apps.about.AboutActivity"
android:label="@string/about_title"
android:launchMode="singleTop"
android:theme="@style/Theme.MaterialFiles">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.filemanagere.android.apps.filelist.FileListActivity" />
</activity>
<activity
android:name="android.apps.filejob.FileJobActionDialogActivity"
android:autoRemoveFromRecents="true"
android:theme="@style/Theme.MaterialFiles.Translucent" />
<activity
android:name="android.apps.filejob.FileJobConflictDialogActivity"
android:autoRemoveFromRecents="true"
android:theme="@style/Theme.MaterialFiles.Translucent" />
<activity
android:name="android.apps.viewer.text.TextEditorActivity"
android:label="@string/text_editor_title"
android:theme="@style/Theme.MaterialFiles">
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/ecmascript" />
<data android:mimeType="application/javascript" />
<data android:mimeType="application/json" />
<data android:mimeType="application/typescript" />
<data android:mimeType="application/x-sh" />
<data android:mimeType="application/x-shellscript" />
<data android:mimeType="application/xml" />
<data android:mimeType="text/*" />
</intent-filter>
</activity>
<activity
android:name="android.apps.viewer.image.ImageViewerActivity"
android:label="@string/image_viewer_title"
android:theme="@style/Theme.MaterialFiles.Immersive">
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
<service android:name="android.apps.filejob.FileJobService" />
<service android:name="android.apps.ftpserver.FtpServerService" />
<provider
android:name="android.apps.AppProvider"
android:authorities="@string/app_provider_authority"
android:exported="false" />
<provider
android:name="android.apps.file.FileProvider"
android:authorities="@string/file_provider_authority"
android:exported="false"
android:grantUriPermissions="true" />
<receiver android:name="android.apps.filejob.FileJobReceiver" />
<receiver android:name="android.apps.ftpserver.FtpServerReceiver" />
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
<!-- We need to reference a MD2 theme in XML for R8 to keep relevant resources. -->
<activity
android:name=".KeepMd2Resources"
android:theme="@style/Theme.MaterialFiles.Md2" />
</application>
</code></pre>
<p></p>
<p>Знаете кого-нибудь, кто может ответить?
ошибка сбора в AndroidManifest.xml</p>
<p>AAPT: ошибка: атрибут android: requestLegacyExternalStorage не найден.</p>
| <android> | 2019-11-21 13:42:03 | HQ |
58,976,666 | Java class is despite new ...; not called up | <p>I have a problem with call up a class. I'm programming in Eclipse and I have another Java Program, which works very well, but I can't see any difference. Here is the code of the Main class:</p>
<pre><code>public class Main {
public static void main(String[] args) {
new Var();
new GUI();
new Label();
new ActionHandler();
}
}
</code></pre>
<p>If I place a <code>System.out.println("Test");</code>in the Label class, I don't get the output.
Here is the Label class:</p>
<pre><code>import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JLabel;
public class Label extends JLabel {
private static final long serialVersionUID = 1L;
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.drawImage(Var.ibackground, 0, 0, 1920, 1080, null);
}
}
</code></pre>
<p>Thanks in advance,
Lupus</p>
| <java><paintcomponent> | 2019-11-21 13:57:13 | LQ_CLOSE |
58,976,715 | Find first occurrence of a string in a String array in Typescript/Javascript | <p>I have an empty string array. I push into it new strings, and I do this one by one. Then, it will happen that the string I'm pushing is already in the array, and I want to find the index of that original string and split the array in the range:</p>
<p><code>[start, index_of_firstString]</code>.</p>
<p>So if we have:</p>
<pre><code>myArray: string[] = [];
function(myString: string) {
this.myArray.push(myString);
}
</code></pre>
<p>What could be a good solution? I need to check for duplicates every time I push a new string.</p>
| <javascript><arrays><typescript><duplicates> | 2019-11-21 14:00:24 | LQ_CLOSE |
58,979,526 | How to set ADC for MC9S08QG8 micro controller in C language | <p>Im new to coding in C language and I don't know how to activate the Analogue to Digital converter on the QG8 micro controller. Its quite outdated tech as far as I'm aware as I'm struggling to find any code for it. The overall project is to create a Voltmeter using a potential divider, so I'm having a voltage going from the potential divider into the ADC then the output is displayed on a LCD. Looking to find some C language code that will do it.</p>
<p>Any help will be appreciated, Thanks all</p>
| <c><microcontroller><electronics> | 2019-11-21 16:29:59 | LQ_CLOSE |
58,981,896 | Why does it show none at the end? Once i call the main function? How does the code need to be improved to not have it show none at the end? | <p>Once i call the main function I get none at the end. How does the code need to be improved to not have it show none in the end of the function call.
<a href="https://i.stack.imgur.com/H0oEa.png" rel="nofollow noreferrer">def count_spaces, then call main function to count number of spaces</a></p>
| <python><function> | 2019-11-21 18:55:26 | LQ_CLOSE |
58,982,286 | Spring Security 5 Replacement for OAuth2RestTemplate | <p>In <code>spring-security-oauth2:2.4.0.RELEASE</code> classes such as <code>OAuth2RestTemplate</code>, <code>OAuth2ProtectedResourceDetails</code> and <code>ClientCredentialsAccessTokenProvider</code> have all been marked as deprecated.</p>
<p>From the javadoc on these classes it points to a <a href="https://github.com/spring-projects/spring-security/wiki/OAuth-2.0-Migration-Guide" rel="noreferrer">spring security migration guide</a> that insinuates that people should migrate to the core spring-security 5 project. However I'm having trouble finding how I would implement my use case in this project.</p>
<p>All of the documentation and examples talk about integrating with a 3rd part OAuth provider if you want incoming requests to your application to be authenticated and you want to use the 3rd party OAuth provider to verify the identity. </p>
<p>In my use case all I want to do is make a request with a <code>RestTemplate</code> to an external service that is protected by OAuth. Currently I create an <code>OAuth2ProtectedResourceDetails</code> with my client id and secret which I pass into an <code>OAuth2RestTemplate</code>. I also have a custom <code>ClientCredentialsAccessTokenProvider</code> added to the <code>OAuth2ResTemplate</code> that just adds some extra headers to the token request that are required by the OAuth provider I'm using.</p>
<p>In the spring-security 5 documentation I've found a section that mentions <a href="https://docs.spring.io/spring-security/site/docs/current/reference/html5/#customizing-the-access-token-request-3" rel="noreferrer">customising the token request</a>, but again that looks to be in the context of authenticating an incoming request with a 3rd party OAuth provider. It is not clear how you would use this in combination with something like a <code>ClientHttpRequestInterceptor</code> to ensure that each outgoing request to an external service first gets a token and then gets that added to the request. </p>
<p>Also in the migration guide linked above there is reference to a <code>OAuth2AuthorizedClientService</code> which it says is useful for using in interceptors, but again this looks like it relies on things like the <code>ClientRegistrationRepository</code> which seems to be where it maintains registrations for third party providers if you want to use that provide to ensure an incoming request is authenticated.</p>
<p>Is there any way I can make use of the new functionality in spring-security 5 for registering OAuth providers in order to get a token to add to outgoing requests from my application?</p>
| <java><spring-boot><spring-security><spring-security-oauth2> | 2019-11-21 19:20:03 | HQ |
58,982,603 | How to properly step by step install java and javafx in Intellij on Linux? | <p><br> I think I am not alone who doesn't know how to properly download Java and JavaFX on Linux. And how make it works in IntelliJ Idea <br><br>
So my questions are: <br></p>
<ol>
<li>I'm looking for Java JRE or Java SDK?</li>
<li>Must Java and JavaFX be at same version?</li>
<li>How I will connect it with IntelliJ</li>
<li>Do I have to write something like in windows "path variable"?</li>
</ol>
<p><br>
Maybe this is not proper question, because it was answered somewhere else, but I dont undrestand basic things about installation of Java. <br> Thanks everyone.</p>
| <java><linux><javafx><sdk> | 2019-11-21 19:40:20 | LQ_CLOSE |
58,985,626 | IndexOutOfBounds: Why does low keep going past high | <p>I keep getting an IndexOutOfBounds error for the if statement down below and I don't know why. low is initially 0, high is set to 24, and the size of the ArrayList is 25. </p>
<pre><code> for(int i = low + 1; low <= high; i++){
if(list.get(i).compareTo(list.get(pivIndex)) < 0){ //this line
E temp = list.get(pivIndex);
list.remove(pivIndex);
list.add(pivIndex, list.get(i));
list.remove(i);
list.add(i, temp);
}
}
</code></pre>
| <java><for-loop><arraylist><indexoutofboundsexception><quicksort> | 2019-11-22 00:10:32 | LQ_CLOSE |
58,988,269 | How to convert multi String array to string array in swift | <p>var names:[[String]] = [["google"],["yahoo"],["facebook"]]</p>
<p>var convertNames:[String] = []</p>
<p>//how to convert names multi String array to convertNames String Array</p>
| <swift><multidimensional-array> | 2019-11-22 05:53:37 | LQ_CLOSE |
58,989,076 | Use default predicate in WHERE method | <p>Can I use a default predicate in the <code>where</code> method?</p>
<p>In my db I have a column <code>IsDeleted</code> for every tables. Is there a way when i get some data like this</p>
<pre><code>_dbContext.Person.Where(x => x.Age > 35).FirstOrDefault();
</code></pre>
<p>it will also use another predicate like <code>x.IsDeleted == false</code> by default?</p>
| <c#><linq> | 2019-11-22 06:59:08 | LQ_CLOSE |
58,989,993 | Can I convert numbers to amount of characters in python | Hi just wondering if I can convert a number like 3 into a string wich gives me the amount of characters in a input. Like: 3 = --- and 6 = ------
Thanks in advance, Thijs | <python> | 2019-11-22 08:08:44 | LQ_EDIT |
58,992,060 | Java - How to get items out of a list with String Arrays | <p>How do I get a specific item out of a "List" at a specific index?</p>
<pre><code>private List<String[]> rows;
</code></pre>
| <java><list><get> | 2019-11-22 10:16:48 | LQ_CLOSE |
58,993,190 | What does `{...}` mean in a python 2 dictionary value printed? | <p>While debugging a python program I had to print the value of a huge dictionary on a log file. I copy-pasted the value and when I assigned it in the python 2 interpreter I got <code>SyntaxError: invalid syntax</code>. What? How was that possible? After a closer look I realised the dictionary in the file was something like this:<br><p><code>{'one': 1, 'two': 2, 'three': {...}}</code></p>The key <code>three</code> value was <code>{...}</code>, which caused the invalid syntax error.<br><p>Pasting this dictionary on a python 2 interpreter raises a <code>Syntax Error</code> exception. Pasting it on a python 3 interpreter the assigned value results to be <code>{'one': 1, 'two': 2, 'three': {Ellipsis}}</code>. <p>So, what does <code>{...}</code> mean in python 2 and why the syntax is invalid in python 2 even if the value is printed in the log file from a python 2 script?</p></p>
| <python><dictionary><printing><ellipsis> | 2019-11-22 11:19:27 | LQ_CLOSE |
58,993,381 | Portuguese Vehicle plate verification | I want to validate if a plate of a portuguese car is valid.
Portuguese Plate is XX-XX-XX alpha numeric.
It's Alpha numeric but you can´t have a number and a Char on the same position
Example : A5-99-AB -> It's wrong / 55-99-AB-> it's right
| <javascript><outsystems> | 2019-11-22 11:29:28 | LQ_EDIT |
58,993,845 | c# Transfer multiple records in list in class | I want to pass class to front angular app from backend c#
for that I made special class where I pass some params. PLease take a look at the last one.
There is seperate table in DB which stores pics. And I want to pass list of pictures with other data. for that in transfer class I tried to declare list of piclass.
> public List<PicsClass> PicsClass{ get; set; }
This gave me error and after some googling I've found this
> public List<Type> PicsClass{ get; set; }
So here are my transfer and pic classes.
public class TransferClass
{
public int TransferClassID { get; set; }
public string param1{ get; set; }
public int param2{ get; set; }
public List<Type> PicsClass{ get; set; }
}
public class PicsClass
{
public int PicsClassID{ get; set; }
public int param1ID { get; set; }
public int param2ID{ get; set; }
}
Now in controller I query DB for pics and put them into list of TransferClass object
List<PicsClass> Images = _context.PicsClasses.Where(u => u.param2ID== param2ID).ToList();
TransferClass.Images = Images;
And get error
> Cannot implicitly convert type
> system.coolection.......Entities.PicsClass to
> system.coolections.generic.list<system.type>
How can I fix this ? | <c#><list><class> | 2019-11-22 11:59:06 | LQ_EDIT |
58,994,348 | Flutter How to not show the [] Brackets of a list when being displayed as a text? | <p>I am trying to display a list rendered in text. But when I do I see the []</p>
<p>I have tried the following.</p>
<pre><code>Text(hashList.toString().replaceAll("(^\\[|\\])", ""))
</code></pre>
<p>Brackets are still there.</p>
| <flutter><dart> | 2019-11-22 12:29:41 | LQ_CLOSE |
58,994,456 | How to return multiple results from store procedure using dapper | I have two tables Attributes and Types. Both I need to return at the same time using store proc in dapper. | <asp.net-mvc><sql-server-2012><dapper> | 2019-11-22 12:36:32 | LQ_EDIT |
58,996,344 | Learned how to make responsive HTML Emails from scratch using HTML & CSS. What's next? | <p>Looking at jobs online most of them have: Experience using MailChimp or Oracle responsys. Are these what most HTML Email developers use at work? </p>
<ul>
<li>Also I tested my code using the free <a href="https://putsmail.com/tests/new" rel="nofollow noreferrer">https://putsmail.com/tests/new</a> on gmail and hotmail apps (iphone)</li>
</ul>
<p>They both looked great.</p>
<p>Is that enough? If not, what website is the best for testing to make sure it works well on every email clients?</p>
| <html><css><html-email><mailchimp><email-templates> | 2019-11-22 14:31:21 | LQ_CLOSE |
58,998,337 | When adding string to Hashtable, string gains unrecognizable characters | <p>So currently I have a hash table that I create and populate it with keys and values</p>
<pre><code>Hashtable m_hash = new Hashtable();
</code></pre>
<p>I then have a string that I have created with a value that will replace a specific value in the hash table.</p>
<pre><code>string birthday = "1979/01/01"
</code></pre>
<p>I then remove the existing value from the hash table and we add in our new value into the hash table.</p>
<pre><code>//0x00080023 is the key in the hash table
m_hash.Remove(0x00080023);
//Then we add in the new value into the key location
m_hash.Add(0x00080023, birthday);
</code></pre>
<p>After we write the hash table to the file. However, when you open up the file the result is as follows:</p>
<p><a href="https://i.stack.imgur.com/VwYkn.png" rel="nofollow noreferrer">Results of our program</a></p>
<p>As you can see at the end of the string there are some unrecognizable characters in the string. Could this be because of the way that we are adding the string into the hash table? Should the string be formatted in a specific way? (Currently it's formatted normally as UTF 16) Any help is appreciated. </p>
| <c#><string><hashtable> | 2019-11-22 16:36:58 | LQ_CLOSE |
58,999,218 | Public alias for non-public type | <p>I wonder if it is valid C++ :</p>
<pre><code>class Test {
struct PrivateInner {
PrivateInner(std::string const &str) {
std::cout << str << "\n";
}
};
public:
using PublicInner = PrivateInner;
};
//Test::PrivateInner priv("Hello world"); // Ok, private so we can't use that
Test::PublicInner publ("Hello World"); // ?, by using public alias we can access private type, is it ok ?
</code></pre>
| <c++><alias><access-modifiers> | 2019-11-22 17:38:42 | HQ |
58,999,621 | Make website remain in desktop view both on mobile view | <p>I want my site to have the exact same desktop view on mobile, any possible solution is okay.To get exactly what I meant, open bithubpay.com on your mobile and desktop, they both got the same view.
I will tag many options because I don't know where the solution will come from</p>
| <javascript><jquery><html><css> | 2019-11-22 18:10:17 | LQ_CLOSE |
59,000,503 | PHP/MySQLi: Get recent 10 entries from all tables | Is there any way to get last entry from all tables? I even did not find way to query all tables, tried this: [code]SELECT * FROM *[/code]. | <php><mysql> | 2019-11-22 19:21:05 | LQ_EDIT |
59,002,108 | Is there a better way to convert string list having nan values to list | input list = `'[12,2,4,nan,0]'`
ouput = `['12','2','4','nan','0']`
One option is yaml.safe_load(), But it's too slow. I am looking for a efficient way to transform. | <python><python-3.x><parsing> | 2019-11-22 21:41:34 | LQ_EDIT |
59,002,745 | c#, get and set for class property seems to have no effect | <p>so in my little c# console-program, i have i have this class, where I use get and set methods for my properties</p>
<pre><code>class myClass
{
public int ID { get; set; }
public string value { get; set; }
public myClass(int ID, string value)
{
this.ID = ID;
this.value = value;
}
}
</code></pre>
<p>however when i am im my main method, i am not able to access these two properties through the get-method, neither am i able to use set() on any of them, what am I doing wrong? </p>
| <c#> | 2019-11-22 22:47:15 | LQ_CLOSE |
59,002,746 | How do you keep taking input as constantly C++ | Let's say that the input is like this:
2
xsad
sadsad
There are no constraints so how do you create a loop function that will keep on going that will store each of those in a string.
Like the first number is the amount of lines of strings. How do you create a loop function that would read the first number ex: 1000 and keep storing it in different strings? | <c++> | 2019-11-22 22:47:33 | LQ_EDIT |
59,003,612 | Extend SwiftUI Keyboard with Custom Button | <p>I'm trying to find a way to add a key or button to the SwiftUI numberPad. The only
references I have found say it is not possible. In the Swift world I added a toolbar
with a button to dismiss the keyboard or perform some other function.</p>
<p>I would even build a ZStack view with the button on top but I can't find a way to add the
numberPad to my own view.</p>
<p>All I'm really trying to do in this case is dismiss the numberPad when the data is
entered. I first attempted to modify the SceneDelegate to dismiss on taps, but that
only works if I tap in another text or textfield view not in open space on the view.</p>
<pre><code>window.rootViewController = UIHostingController(rootView: contentView.onTapGesture {
window.endEditing(true)
})
</code></pre>
<p>Ideally, I'd add a Done key to the lower left space. Second best add a toolbar if
it can be done in SwiftUI.</p>
<p><a href="https://i.stack.imgur.com/tDT8M.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tDT8M.png" alt="enter image description here"></a></p>
<p>Any guidance would be appreciated.</p>
<p>Xcode Version 11.2.1 (11B500)</p>
| <ios><xcode><keyboard><swiftui> | 2019-11-23 00:56:51 | HQ |
59,005,951 | I can't create a struct with the data retrieved from request | <p>I'm trying to get the values passed by json in my API, example below:</p>
<p><a href="https://i.stack.imgur.com/R9bMI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R9bMI.png" alt="Insomnia data"></a></p>
<p>The code:</p>
<p><a href="https://i.stack.imgur.com/wYAZj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wYAZj.png" alt="handle code"></a></p>
<p>The struct</p>
<p><a href="https://i.stack.imgur.com/6s468.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6s468.png" alt="Gerente struct"></a></p>
<p>I already tried to use <code>`json:"nome"`</code></p>
<p>I already tried to change the declaration, the way to instantiate the struct and already tried several approaches to get the values and create the "gerente object"</p>
<p>The result is always the same.</p>
<p><a href="https://i.stack.imgur.com/y4RSn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y4RSn.png" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/8NRil.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8NRil.png" alt="enter image description here"></a></p>
| <json><go><struct><mux><insomnia> | 2019-11-23 08:42:39 | LQ_CLOSE |
59,007,007 | Is there an equivalent of "tools:layout=" for FragmentContainerView? | <p>In order to be able to see the content of a certain view inside a fragment when previewing a layout in Android Studio, it is possible to do <a href="https://developer.android.com/studio/write/tool-attributes#toolslayout" rel="noreferrer">this</a>:</p>
<pre class="lang-xml prettyprint-override"><code><MainLayoutView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<fragment
...
tools:layout="@layout/my_fragment_view"/>
</MainLayoutView>
</code></pre>
<p>However, if you switch from <code>fragment</code> to <code>androidx.fragment.app.FragmentContainerView</code>, this handy tool stops working and the fragment just appears blank on the preview screen.</p>
<p>Is there any way to show content inside a <code>FragmentContainerView</code> when previewing it in a layout in Android Studio?</p>
| <android><android-studio> | 2019-11-23 11:12:24 | HQ |
59,009,048 | What are the possible ways that test cases can be written for Set() type of method | I'm completely new to writing unit test cases for the code using ```xUnit```. I'm unsure of what else can be tested for my method ```TranslateResponse()``` . It basically checks the type of translator and calls the translator's associated ```set()``` method.
```
public async Task TranslateResponse(Policy response)
{
foreach (var t in await _translatorFactory.BuildTranslators())
{
var policyTranslator = t as IPolicyAwareTranslator;
policyTranslator?.SetPolicy(response);
var additionalInterestTranslator = t as IAdditionalInterestAwareTranslator;
additionalInterestTranslator?.SetAdditionalInterests(response.AdditionalInterests);
var locationsTranslator = t as ILocationsAwareTranslator;
locationsTranslator?.SetLocations(response.Locations);
}
}
```
I'm writing test cases for the ```TranslateResponse()``` method. As far as I figured out, I'm verifying that the calls to respective methods happens based on the provided type of translator.
The test case lines
```
Mock<ITranslator> mockedTranslator = new Mock<ITranslator>(); mockedTranslator.Setup(t => t.Translate(_translatorDataAccessor.Object));
var mockedPolicyTranslator = mockedTranslator.As<IPolicyAwareTranslator>();
mockedPolicyTranslator.Setup(t => t.SetPolicy(It.IsAny<Policy>()));
mockedPolicyTranslator.Verify(t => t.SetPolicy(It.IsAny<Policy>()), Times.AtLeastOnce);
```
My concerns are
1. I'm curious to know whether I can test something more than verifying calls?
2. Should I test for the logic of the set() method here or in it's own class? Even, then I'm not able to figure out what to Assert in the test case for the ```Set()``` which will set the private field with the passed in argument.
```
public class PolicyTranslator : ITranslator, IPolicyAwareTranslator
{
private Policy _policy;
public void SetPolicy(Policy policy)
{
_policy = policy;
}
//translate()
} | <c#><unit-testing><mocking><moq><xunit.net> | 2019-11-23 15:13:37 | LQ_EDIT |
59,009,184 | What technology can mainframe folks learn and work in the future | <p>Can anyone please let me know what technology we can shift after reaching 10 years of experience(I.T) in mainframes. Can we learn the skills Python, Cloud(AWS/AZURE/Openstack), Data science or _ with mainframes?</p>
<p>Any suggestions on this.</p>
| <generics><mainframe> | 2019-11-23 15:29:52 | LQ_CLOSE |
59,014,656 | Css fille issue | I have tried too many times to link the css file externally but it doesn't work yet. It is working fine with internal css and inline css but not with external css. I have checked too many times the name, location and folder of that file but still not find any solution. Here are some codes of mine.
<!-- language: lang-html -->
<!doctype html>
<html>
<head>
<title>My Webpage</title>
<link rel="stylesheet" type="text/css" href="Samar/s.css"/>
</head>
<body>
<img src="samar.jpg" width="300" height="370" align="right" alt="My Image"/>
<h1><center><i> Welcome to Samar Club </i></center></h1>
<p> Hello Everyone, My name is Samar. I am here to give you guys the solutions of NCERT Maths problems.</p>
</body>
</html>
<!-- end snippet -->
</body>
Here is my css file
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
h1{
font-family: Arial;
font-size: 37px;
border: 12px double grey;
color:maroon;
}
p{
text-align:right;
font-family:sans-serif;
font-weight:bold;
font-size:25px;
margin-top:35px;
background-color:yellow;
}
<!-- end snippet -->
| <html><css> | 2019-11-24 04:26:43 | LQ_EDIT |
59,015,801 | Horizontally and vertically flexbox css not working | <p>I'm trying to center the below HTML vertically and horizontally but it's not working vertically, only horizontally. Please could someone help explain why it's not working?</p>
<pre><code><body>
<header class="nav">
<img class="icon" src="./img/eiffel-tower.svg" attr="Icon made by Monkik from www.flaticon.com">
<a class="home-anchor" href="./index.html">Learn</a>
</header>
<div class="quiz-container">
<p class="word-to-conjugate" id="randomWord"></p>
<input type="text" id="userGuess">
<button class="answer-button" id="checkAnswer">Answer</button>
</div>
</body>
</code></pre>
<p>My CSS using flexbox trying to center the quiz horizontally and vertically</p>
<pre><code>.quiz-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.word-to-conjugate {
font-size: 2rem;
font-family: 'Source Sans Pro', sans-serif;
text-align: center;
}
input {
font-family: 'Roboto', sans-serif;
font-weight: bold;
padding: 10px;
font-size: 1.5rem;
border: 1px solid #333;
border-radius: 5px;
margin-bottom: 20px;
}
.answer-button {
background-color: #505FDF;
font-size: 1.5rem;
text-align: center;
color: #FFFFFF;
padding: 10px;
border-radius: 5px;
border: none;
font-family: 'Roboto', sans-serif;
margin-bottom: 3%;
}
</code></pre>
| <css><flexbox> | 2019-11-24 08:13:42 | LQ_CLOSE |
59,016,061 | Please help on Arduino | I wrote a program for Arduino for object avoiding using three ultrasonic sensors but it is giving error in compile. Can anyone suggest why is the error coming and how I can resolve it:
int trigPin = 6;<br/>
int echoPin = 7;<br/>
int trigPin = 8;<br/>
int echoPin = 9;<br/>
int trigPin = 10;<br/>
int echoPin = 11;<br/>
<br/>
int revleft4 = 2;<br/>
int fwdleft5 = 3;<br/>
int revright6 = 4;<br/>
int fwdright7 = 5;<br/>
<br/>
long duration, distance, RightSensor,FrontSensor,LeftSensor;<br/>
<br/>
void setup()<br/>
{<br/>
delay(random(500,2000));<br/>
Serial.begin (9600);<br/>
pinMode(revleft4, OUTPUT);<br/>
pinMode(fwdleft5, OUTPUT);<br/>
pinMode(revright6, OUTPUT);<br/>
pinMode(fwdright7, OUTPUT);<br/>
<br/>
pinMode(trigPin1, OUTPUT);<br/>
pinMode(echoPin1, INPUT);<br/>
pinMode(trigPin2, OUTPUT);<br/>
pinMode(echoPin2, INPUT);<br/>
pinMode(trigPin3, OUTPUT);<br/>
pinMode(echoPin3, INPUT);<br/>
}<br/>
<br/>
void loop() <br/>
SonarSensor(trigPin1, echoPin1);<br/>
RightSensor = distance;<br/>
SonarSensor(trigPin2, echoPin2);<br/>
LeftSensor = distance;<br/>
SonarSensor(trigPin3, echoPin3);<br/>
FrontSensor = distance;<br/>
<br/>
<br/>
if(FrontSensor<=20 && LeftSensor<=20)<br/>
{<br/>
Serial.println("Turn right");<br/>
digitalWrite(fwdright7,HIGH);<br/>
digitalWrite(revright6,LOW);<br/>
digitalWrite(fwdleft5,HIGH);<br/>
digitalWrite(revleft4,LOW);<br/>
}<br/>
else if(FrontSensor<=20 && RightSensor<=20)<br/>
{<br/>
Serial.println("Turn left");<br/>
digitalWrite(fwdright7,LOW);<br/>
digitalWrite(revright6,HIGH);<br/>
digitalWrite(fwdright5,LOW);<br/>
digitalWrite(revright4,HIGH);<br/>
}<br/>
else<br/>
{<br/>
Serial.println("Forward");<br/>
<br/>
digitalWrite(fwdright7,LOW);<br/>
digitalWrite(revright6,HIGH);<br/>
digitalWrite(fwdright5,HIGH);<br/>
digitalWrite(revright4,LOW);<br/>
}<br/>
delay(5);<br/>
}<br/>
<br/>
<br/>
void SonarSensor(int trigPin,int echoPin)<br/>
{<br/>
digitalWrite(trigPin, LOW);<br/>
delayMicroseconds(2);<br/>
digitalWrite(trigPin, HIGH);<br/>
delayMicroseconds(10);<br/>
digitalWrite(trigPin, LOW);<br/>
duration = pulseIn(echoPin, HIGH);<br/>
distance = duration/58.2; <br/>
} | <c++><arduino> | 2019-11-24 08:55:11 | LQ_EDIT |
59,018,001 | when should we use semaphore vs Dispatch group vs operation queue ? [Swift iOS] | when should we use semaphore vs Dispatch group vs operation queue ?
i am aware of part how all of them works, but i am not sure when to use which option. since all of the things i can achieve with semaphore can also be achieved through dispatch group and also through operation queue.
Is there any specific area when each one should be preferred over other ? | <ios><swift><multithreading> | 2019-11-24 13:13:11 | LQ_EDIT |
59,018,462 | Why is a commit not showing on the github repo but I can provide a working link to said commit? | <p>So I have been trying to figure out why <a href="https://github.com/mwoolweaver/tweetStats/commit/a0e70c7b7aba44e62c69edbff022a6d6452f7ee6" rel="nofollow noreferrer">this commit</a> is not showing anywhere? </p>
| <github> | 2019-11-24 14:02:37 | LQ_CLOSE |
59,018,601 | Can I tell C# nullable references that a method is effectively a null check on a field | <p>Consider the following code:</p>
<pre><code>#nullable enable
class Foo
{
public string? Name { get; set; }
public bool HasName => Name != null;
public void NameToUpperCase()
{
if (HasName)
{
Name = Name.ToUpper();
}
}
}
</code></pre>
<p>On the Name=Name.ToUpper() I get a warning that Name is a possible null reference, which is clearly incorrect. I can cure this warning by inlining HasName so the condition is if (Name != null).</p>
<p>Is there any way I can instruct the compiler that a true response from HasName implies a non-nullability constraint on Name? </p>
<p>This is important because HasName might actually test a lot more things, and I might want to use it in several places, or it might be a public part of the API surface. There are many reasons to want to factor the null check into it's own method, but doing so seems to break the nullable reference checker.</p>
| <c#><nullable-reference-types> | 2019-11-24 14:16:49 | HQ |
59,019,259 | how to invoke the _Verify_range in vector in c++? |
my code
```c++
#include <iostream>
#include <vector>
#include <algorithm>
using std::vector;
using std::cout;
using std::endl;
using std::back_inserter;
int main(void) {
vector<int> coll1 {1, 2, 3, 4};
vector<int> coll2;
copy(coll1.begin(), coll1.end(), back_inserter(coll2));
const auto start = coll2.cbegin();
const auto stop = coll2.cend();
// start: class std::_Vector_const_iterator<class std::_Vector_val<struct std::_Simple_types<int> > >
cout << typeid(start).name() << endl;
// _ITERATOR_DEBUG_LEVEL: 2
cout << _ITERATOR_DEBUG_LEVEL << endl;
std::_Verify_range(start, stop);
for (auto ele: coll2)
cout << ele << ", " << ele << endl;
return 0;
}
```
compile error
```
error C2672: 'std::_Verify_range': no matching overloaded function found
error C2784: 'void std::_Verify_range(const std::_Array_const_iterator<_Ty,_Size> &,const std::_Array_const_iterator<_Ty,_Size> &) noexcept': could not deduce template argument for 'const std::_Array_const_iterator<_Ty,_Size> &' from 'const std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>'
error C2784: with
error C2784: [
error C2784: _Ty=int
error C2784: ]
VC\14.22.27905\include\xutility(1467): message : see declaration of 'std::_Verify_range'
error C2784: 'void std::_Verify_range(const std::reverse_iterator<_BidIt> &,const std::reverse_iterator<_BidIt2> &)': could not deduce template argument for 'const std::reverse_iterator<_BidIt> &' from 'const std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>'
error C2784: with
error C2784: [
error C2784: _Ty=int
error C2784: ]
VC\14.22.27905\include\xutility(983): message : see declaration of 'std::_Verify_range'
error C2784: 'void std::_Verify_range(const _Ty *const ,const _Ty *const ) noexcept': could not deduce template argument for 'const _Ty *const ' from 'const std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>'
error C2784: with
error C2784: [
error C2784: _Ty=int
error C2784: ]
VC\14.22.27905\include\xutility(193): message : see declaration of 'std::_Verify_range'
```
this is the code in vector
```
// CLASS TEMPLATE _Vector_const_iterator
template <class _Myvec>
class _Vector_const_iterator : public _Iterator_base {
public:
...
#if _ITERATOR_DEBUG_LEVEL != 0
friend void _Verify_range(const _Vector_const_iterator& _First, const _Vector_const_iterator& _Last) {
_STL_VERIFY(_First._Getcont() == _Last._Getcont(), "vector iterators in range are from different containers");
_STL_VERIFY(_First._Ptr <= _Last._Ptr, "vector iterator range transposed");
}
#endif // _ITERATOR_DEBUG_LEVEL != 0
...
}
```
the compiler seems only try to match this three prototype function:
```
void std::_Verify_range(const std::_Array_const_iterator<_Ty,_Size> &,const std::_Array_const_iterator<_Ty,_Size> &);
and
void std::_Verify_range(const std::reverse_iterator<_BidIt> &,const std::reverse_iterator<_BidIt2> &)
and
void std::_Verify_range(const _Ty *const ,const _Ty *const ) noexcept;
```
can anyone help me to figure it out?
can anyone help me to figure it out?
can anyone help me to figure it out?
can anyone help me to figure it out?
can anyone help me to figure it out?
can anyone help me to figure it out?
can anyone help me to figure it out?
can anyone help me to figure it out?
can anyone help me to figure it out?
can anyone help me to figure it out? | <c++><vector><visual-c++> | 2019-11-24 15:26:45 | LQ_EDIT |
59,019,435 | Submit form to fill up the last recent ID row [MySQL] | <p>Lets say I have this table:</p>
<pre><code>------------------
ID | Car |
------------------
25 | Honda |
.. | ... |
.. | ... |
.. | ... |
123 | Toyota |
------------------
</code></pre>
<p>How to start fill in at row 124 instead of filling up row 1 til row 24 first? Assuming the <code>ID</code> is auto-incremental value.</p>
<p>Actual problem: my form method post fill up row with <code>ID = 1</code> instead of <code>ID = 124</code></p>
| <php><mysql> | 2019-11-24 15:45:54 | LQ_CLOSE |
59,020,090 | How do I set the value of a key in on array as the key in an other array | I am trying to get the value("feature_1") of a key("name") from the array("data") and set the value of that key as the key to another array("asset") which has an array as value. Is that possible ?
Example :
```
//input:
data: {
name: "feature_1",
value_a: 1,
value_b: 2
}
//Output:
asset: {
feature_1:[{1},{2}]
}
| <javascript><arrays><json> | 2019-11-24 16:51:37 | LQ_EDIT |
59,022,821 | Matlab - Incorrect dimensions for raising a matrix to a power | <p>Suppose we have <code>a=60</code> and <code>B=60</code>. I am trying to calculate this area:</p>
<p><a href="https://i.stack.imgur.com/qE4bT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qE4bT.png" alt="enter image description here"></a></p>
<p>when I try this:</p>
<pre class="lang-matlab prettyprint-override"><code>W = ((u^2)* cot(B) + (v^2 * cot(a))/8;
</code></pre>
<p>I get this error:</p>
<blockquote>
<p>Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers,
use '.^'.</p>
</blockquote>
<p>How can I use <code>u^2</code> in the right way?</p>
| <matlab><vector><angle><area> | 2019-11-24 21:56:28 | LQ_CLOSE |
59,022,859 | Multiply by transposing rows by date in R | I want to convert this table :
[![enter image description here][1]][1]
to that table with **R**
[![enter image description here][2]][2]
In brief : converting the time periods between start date and end date to months table vertically
Thanks!
[1]: https://i.stack.imgur.com/7s8SQ.png
[2]: https://i.stack.imgur.com/rXYbp.png | <r><date><dataframe><reshape> | 2019-11-24 22:01:06 | LQ_EDIT |
59,022,968 | Java array inheritance not recognized by subclass | <p>I am working on a project where several classes have to inherit information. I am currently trying to get a subclass to inherit and work with an array from a superclass. The subclass isn't doing anything when I try to access the array. I can return the array after the information is read from the text file and placed into the array, but if I don't return it the subclass will do nothing with it. </p>
<p>Superclass:</p>
<pre><code>package Objects;
import java.io.*;
import java.util.*;
public abstract class Shape{
public static void main(String[] args) {
String[] shape = new String[12];
int i;
BufferedReader reader;
try {
reader = new BufferedReader(new FileReader(
"src/Data.txt"));
String line = reader.readLine();
while (line != null) {
for (i=0; i < 13; i+=2) {
shape[i] = line.substring(0, line.indexOf(" "));
shape[i+1] = line.substring(line.length() - 1, line.length());
line = reader.readLine();
}
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
catch(NullPointerException e)
{
}
}//end main
}//end shape
</code></pre>
<p>Subclass:</p>
<pre><code>package Objects;
import java.io.*;
import java.util.*;
public abstract class TwoDShape extends Shape{
System.out.println(Arrays.toString(shape));
public double getArea() {
return 0.0;
}
}//end 2D
</code></pre>
| <java><arrays><inheritance> | 2019-11-24 22:16:09 | LQ_CLOSE |
59,023,616 | Why isn't `std::mem::drop` exactly the same as the closure |_|() in higher-ranked trait bounds? | <p>The implementation of <a href="https://doc.rust-lang.org/std/mem/fn.drop.html" rel="noreferrer"><code>std::mem::drop</code></a> is documented to be the following:</p>
<pre class="lang-rust prettyprint-override"><code>pub fn drop<T>(_x: T) { }
</code></pre>
<p>As such, I would expect the closure <code>|_| ()</code> (colloquially known as the <a href="https://enet4.github.io/rust-tropes/#toilet-closure" rel="noreferrer">toilet closure</a>) to be a potential 1:1 replacement to <code>drop</code>, in both directions. However, the code below shows that <code>drop</code> isn't compatible with a higher ranked trait bound on the function's parameter, whereas the toilet closure is.</p>
<pre class="lang-rust prettyprint-override"><code>fn foo<F, T>(f: F, x: T)
where
for<'a> F: FnOnce(&'a T),
{
dbg!(f(&x));
}
fn main() {
foo(|_| (), "toilet closure"); // this compiles
foo(drop, "drop"); // this does not!
}
</code></pre>
<p>The compiler's error message:</p>
<pre class="lang-none prettyprint-override"><code>error[E0631]: type mismatch in function arguments
--> src/main.rs:10:5
|
1 | fn foo<F, T>(f: F, x: T)
| ---
2 | where
3 | for<'a> F: FnOnce(&'a T),
| ------------- required by this bound in `foo`
...
10 | foo(drop, "drop"); // this does not!
| ^^^
| |
| expected signature of `for<'a> fn(&'a _) -> _`
| found signature of `fn(_) -> _`
error[E0271]: type mismatch resolving `for<'a> <fn(_) {std::mem::drop::<_>} as std::ops::FnOnce<(&'a _,)>>::Output == ()`
--> src/main.rs:10:5
|
1 | fn foo<F, T>(f: F, x: T)
| ---
2 | where
3 | for<'a> F: FnOnce(&'a T),
| ------------- required by this bound in `foo`
...
10 | foo(drop, "drop"); // this does not!
| ^^^ expected bound lifetime parameter 'a, found concrete lifetime
</code></pre>
<p>Considering that <code>drop</code> is supposedly generic with respect to any sized <code>T</code>, it sounds unreasonable that the "more generic" signature <code>fn(_) -> _</code> is not compatible with <code>for<'a> fn (&'a _) -> _</code>. Why is the compiler not admitting the signature of <code>drop</code> here, and what makes it different when the toilet closure is placed in its stead?</p>
| <rust><closures><traits><type-inference><higher-kinded-types> | 2019-11-25 00:00:17 | HQ |
59,023,891 | Loading script in functions.php Wordpress | <p>So I'm trying to put some javascript into my functions.php and run it from there but everytime I do that I get an error on my page when site is reloaded... </p>
<p>"Parse error: syntax error, unexpected 'wp_enqueue_script' (T_STRING) Local Sites\custom-site\app\public\wp-content\themes\theme\functions.php on line 35"</p>
<p>Here is the code, and yes I did put wp_footer in my footer.php file to run it... </p>
<pre><code>function addjs() {
wp_register_script('jquery', get_template_directory_uri() . '/plugin-frameworks/jquery-3.2.1.min.js', array() , 1, 1, 1)
wp_enqueue_script('jquery');
wp_register_script('bootstrap', get_template_directory_uri() . '/plugin-frameworks/bootstrap.min.js', array() , 1, 1, 1)
wp_enqueue_script('bootstrap');
wp_register_script('swiper', get_template_directory_uri() . '/plugin-frameworks/swiper.js', array() , 1, 1, 1)
wp_enqueue_script('swiper');
wp_register_script('scripts', get_template_directory_uri() . '/common/scripts.js', array() , 1, 1, 1)
wp_enqueue_script('scripts');
wp_register_script('custom', get_template_directory_uri() . '/custom.js', array() , 1, 1, 1)
wp_enqueue_script('custom');
}
add_action('wp_enqueue_script', 'addjs', 999);
</code></pre>
<p>I really don't know what I'm doing wrong here... Thanks in advance :)</p>
| <javascript><php><wordpress> | 2019-11-25 00:44:53 | LQ_CLOSE |
59,024,519 | C# array include symbol | <p>I have list of items:</p>
<pre><code>Apple\3
Orange\8
Kivi\9
</code></pre>
<p>I wish to add these items in C # array:</p>
<pre><code>string[] fruit={"Apple\3","Orange\8","Kivi\9"};
</code></pre>
<p>But it return me error as the backslash not acceptable ("\"), by the way the backslash is a must to include, anyone have ideas?</p>
| <c#> | 2019-11-25 02:35:13 | LQ_CLOSE |
59,030,500 | How google tracks me without using mobile my internet data plan? | I'm developing an app that can shows all the bus lines in my city, i'd like to show if the bus is crowed or not, and even get the bus position by another user that is inside it.
But I don't want to use all the internet plan from my users, i see that google does that, he know when a restaurante or bar has people there, knows if a street is congested, and also get your path history.
I'm not asking for all the code, but kind of how does google does that? | <google-maps><tracking> | 2019-11-25 11:14:36 | LQ_EDIT |
59,030,668 | How do I insert a Machine Name info a path? | So my goal is to put a MachineName string into the path location.
Here = MachineName1
string MachineName1 = Environment.MachineName;
Path = @"C:\Users\ Here \AppData\Local\Secret\Secret"; | <c#><string><path> | 2019-11-25 11:22:50 | LQ_EDIT |
59,031,273 | REIMPLEMENTING SPLIT FUNCTION IN C | How can i rewrite the following code into the one below but be able to can the delimiter on each call to the function. I am trying to split line into an array of char*
CODE 1:
```
char *split(const char *string)
{
char *words[MAX_LENGTH / 2];
char *word = (char *)calloc(MAX_WORD, sizeof(char));
memset(word, ' ', sizeof(char));
static int index = 0;
int line_index = 0;
int word_index =0;
while (string[line_index] != '\n')
{
const char c = string[line_index];
if (c == ' ')
{
word[word_index+ 1] = '\0';
memcpy(words+index,&word,sizeof(word));
index+=1;
if(word!=NULL)
{
free(word);
char *word = (char *)calloc(MAX_WORD,sizeof(char));
memset(word, ' ', sizeof(char));
}
++line_index;
word_index =0;
continue;
}
if (c == '\t')
continue;
if (c == '.')
continue;
if (c == ',')
continue;
word[word_index] = c;
++word_index;
++line_index;
}
index =0;
if(word!=NULL)
{
free(word);
}
return *words;
}
```
CODE 2:
```
char **split(char *string)
{
static char *words[MAX_LENGTH / 2];
static int index = 0;
// resetting words
for (int i = 0; i < sizeof(words) / sizeof(words[0]); i++)
{
words[i] = NULL;
}
const char *delimiter = " ";
char *ptr = strtok(string, delimiter);
while (ptr != NULL)
{
words[index] = ptr;
ptr = strtok(NULL, delimiter);
++index;
}
index = 0;
return words;
}
```
However i noticed that the memory of word+index is been reassigned to the same location thereby causing word duplication .
| <c><arrays><string><pointers> | 2019-11-25 11:54:40 | LQ_EDIT |
59,031,968 | how to apply for-loop in between string data to create an order in shopify through api | <pre><code>string data = @"
{
""order"": {
""line_items"": [
{
""variant_id"":" + varientid_arr[0] +@",
""quantity"":" + quantity_arr[0] + @"
}
],
""customer"": {
""id"": 2750996643918
},
""financial_status"": ""pending""
}
}
";
</code></pre>
<p>in this code i want to iterate line items(varientid_arr[0], quantity_arr[0] ) for creating order with multiple products in shopify. i want to apply for loop in line items only within string.</p>
| <c#><string><api><loops><shopify> | 2019-11-25 12:33:50 | LQ_CLOSE |
59,033,156 | JavaScript code not working with "toLowerCase" on equating it with value received from prompt | <pre><code>let browser = prompt('Enter browser name','Enter here..');
if (browser.toLowerCase=='edge') {
alert('You got the Edge!');
}
else if (browser.toLowerCase=='chrome' || browser.toLowerCase=='firefox' || browser.toLowerCase=='safari' || browser.toLowerCase=='opera') {
alert('Okay we support these browsers too!')
}
else {
alert('We hope this page looks okay!');
}
</code></pre>
<p>The above code is only executing the "Else" condition (last one).
Removing "toLowerCase" makes it work perfectly, but why don't it works with "toLowerCase"?? </p>
| <javascript><loops><prompt><lowercase> | 2019-11-25 13:39:39 | LQ_CLOSE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.