Pointers and Vectors Posted: 07 Apr 2021 08:01 AM PDT If i have an vector can I swap an item inside that vector by getting the pointer to that item and assigning it to a pointer to another item and if so can someone show how you would do that? Also say it was a const vector, can it still be done? |
Setting proxied url on flutter video_player plugin for hls redirection on cdn workflow Posted: 07 Apr 2021 08:00 AM PDT I am newbie on flutter. I have a flutter VOD app on android using video_player plugin that works fine on HLS, but fails using proxied signed url. I serve my video files form a private clouded store through a proxy which works on signing the url. I have my .m3u8 and .ts segments proxied from domain1.com pointing to domain2.com. The .m3u8 loads good, but the .ts segments requests are not pointing to domain1.com and are rejected because my privacy settings. I need set domain1.com as base url for signing the private access, but can't find how to do it. Is there a way to configure the VideoPlayerController.network constructor setting domain1 as base url? Is there other workflow to manage this context? Thanks in advance. |
android app - Java crush when i try to use vibrate Posted: 07 Apr 2021 08:00 AM PDT I look at previous questions about this issue but I couldn't find an answer. I want when the text is empty then the device will vibrate but when I try to run my app the application crush I will be happy to get help I include this line in the XML file <uses-permission android:name="android.permission.VIBRATE" /> package com.example.noambs; import androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.media.AudioAttributes; import android.os.Build; import android.os.Bundle; import android.os.VibrationEffect; import android.view.View; import android.widget.EditText; import android.widget.TextView; import android.os.Vibrator; public class MainActivity extends AppCompatActivity { public static final String VIBRATE = "android.permission.VIBRATE"; EditText firstName; EditText lastName; TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); firstName = (EditText) findViewById(R.id.firstName); lastName = (EditText) findViewById(R.id.lastName); textView = (TextView) findViewById(R.id.print); } public void printName(View view) { String firstNameS = firstName.getText().toString(); String lastNameS = lastName.getText().toString(); if (checkValidName(firstNameS) && checkValidName(lastNameS)) textView.setText(firstNameS + " " + lastNameS); else { vibrate(500); } } public void vibrate(int duration) { Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { vibrator.vibrate(VibrationEffect.createOneShot(duration, VibrationEffect.DEFAULT_AMPLITUDE)); } else { vibrator.vibrate(duration); } } private boolean checkValidName(String name) { return !name.isEmpty(); } } |
QML Listview in Scrollview delegate coordinates Posted: 07 Apr 2021 08:00 AM PDT I have a Listview inside Scrollview with vertical scrollbar. Items in Listview are added dynamically and I need a way to understand was item seen by user or not. For that I need to take item's y coordinate and compare it with scrollbar's y coordinate. I am new to the QML and can't figure out how should I take them to have it correctly, anything I've tried gave me wrong coordinates. So here I seek answers for two questions - How can I take
ListView item's y coordinate when it instantiated using delegate component and all that is inside Scrollview with vertical scrollbar? - How can I take
y coordinate of Scrollview 's vertical scrollbar? |
How can I solve MIME type binary/octet-stream problems? Posted: 07 Apr 2021 08:00 AM PDT I'm trying to download 2+ files when the user clicks on a button. The first file is correctly downloaded most of the time, but the second usually returns this warning and the file is not downloaded: Resource interpreted as Document but transferred with MIME type binary/octet-stream: (Link that installs the file when accessed). - PNG files are always downloaded correctly, but the other types we use often give this problem.
- Chrome is the default browser of the application.
This is the code that I'm using to download the files: if (download.data.type !== 'png') { if (download.download_url) { setTimeout(() => { const link = document.createElement('a'); link.href = download.download_url; link.setAttribute('download', ''); document.body.appendChild(link); link.click(); document.body.removeChild(link); }, 1000); } } else { // PNG download if (download.data.download_url) { const urlParams = new URLSearchParams(download.data.download_url); const response = await axios.get(download.data.download_url, { responseType: 'blob' }); const url = window.URL.createObjectURL(new Blob([response.data])); const link = document.createElement('a'); link.href = url; link.setAttribute('download', `${urlParams.get('asset_id')}.png`); document.body.appendChild(link); link.click(); document.body.removeChild(link); } } }; |
Gunicorn + eventlet use redis connection in SIGTERM signal handler Posted: 07 Apr 2021 08:00 AM PDT I'm facing an issue related to using an active I/O connection in the SigTerm handler using gunicorn eventlet server. server.py def exit_with_grace(*args): conn = get_redis_connection() conn.set('exited_gracefully', True) signal.signal(signal.SIGTERM, exit_with_grace) I also tried to fire up the celery task (using amqp broker) but all my ideas failed. When I start server in debug mode using python server.py it works perfectly. Gunicorn command: gunicorn --worker-class eventlet -w 1 server:ws --reload -b localhost:5001 |
chrome not show original variable names when debugging a bundled javascript file build by webpack Posted: 07 Apr 2021 08:00 AM PDT I use this code to config webpack 5: const path = require('path'); module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js', }, devtool: "source-map" }; and this is my index.js code, const bar=require('./bar.js'); let a=1 console.log(a) bar(); When debugging, I can not access the variable named "a" Is this a bug of webpack? I remember its not like this when I worked with an earlier verison of webpack years ago. |
import value not being read after declaration Posted: 07 Apr 2021 08:00 AM PDT I am trying to import my class from a file I called profileData.js . In this file holds react code to render input fields to the page. very simple stuff. once I do this, from my userProfileContent.js page, I simply import the page and class like so: import CancelButton from '../Stripepayment/cancel' import profileDataForm from '../components/profileData' //this profileDataForm is greyed out, claims its not being called, when a few lines below it is actually being called!!! const UserProfileContent = () => <AuthUserContext.Consumer> {authUser => <ColumnWithHeaderFooterAndScrollableContent header={<TitleWithActions title={authUser.email} />} > <Centered className="userProfileContent"> <h2>Password Reset</h2> <PasswordChangeForm /> <hr/> <profileDataForm /> <ProfilePage/> <CancelButton/> <h2>Sign Out</h2> <SignOutButton /> </Centered> </ColumnWithHeaderFooterAndScrollableContent> } </AuthUserContext.Consumer> export default UserProfileContent; and on my profileData.js page, here's what I have import React, { Component } from 'react' import { AuthorizationHome } from '../models' import { Button, Input, Alert } from 'antd' class profileDataForm extends Component { // constructor(props) { // super(props); // } render() { const { FirstName, LastName, } = this.state; return ( <div> <form id='ProfileDetails'> <Input id="FirstName" type="text" placeholder="hello" /> <Input id="LastName" type="text" placeholder="Confirm New Password" /> </form> </div> ); } } // export default profileDataForm; not sure why this isn't working, it is claiming the value is declared but never read , and it doesn't display profileDataForm on screen, which I am calling from profileData.js |
Keras model accuracy is not improving - Image Classification Posted: 07 Apr 2021 08:00 AM PDT I have 4 classes and building a Keras model for image classification problem. I have tried a couple of adjustments but accuracy is not going beyond 75% and still loss is 64%. I have 90,400 images as a training set and 20,000 images for testing. Here is my model. model = Sequential() model.add(Conv2D(32, kernel_size = (3, 3),input_shape=(100,100,3),activation = 'relu')) model.add(MaxPooling2D(pool_size = (2, 2))) model.add(Dropout(0.25)) model.add(Flatten()) model.add(Dense(64, activation = 'relu')) model.add(Dropout(0.5)) model.add(Dense(4, activation = 'softmax')) model.compile(loss = 'sparse_categorical_crossentropy', optimizer = 'adam', metrics = ['accuracy']) batch_size = 64 train_datagen = ImageDataGenerator (rescale=1./255, shear_range=0.2, zoom_range=0.2, horizontal_flip=True) test_datagen=ImageDataGenerator(rescale=1./255) training_set = train_datagen.flow_from_directory('/dir/training_set', target_size=(100,100),batch_size=batch_size,class_mode='binary') test_set = test_datagen.flow_from_directory('/dir/test_set',target_size=(100,100), batch_size=batch_size, class_mode='binary') # 90,400 images I have under the training_set directory and 20,000 under the test directory. model.fit(training_set, steps_per_epoch=90400//batch_size, epochs=1,validation_data=test_set, validation_steps= 20000//batch_size) I tried adjusting layers and dropouts but no luck, any help will be appreciated! Thanks! |
Java validate String format for directory name Posted: 07 Apr 2021 08:00 AM PDT In Java (Java 11) I need to manage a validation of a String. I would like to validate the format and I would like to raise an Exception only if this string contains some special characters that are not allowed. In few words this string could contain: - Numbers
- Letters (uppercase and lowercase)
- Only some special characters (for example: @!-_~* etc)
This because this string will represents into my logic a name of a directory that I will create. So, I need to avoid to use special characters (like, for example, /) Is already there something like this or I need to write this method manually? |
How to redirect dominio.com/cequesabe to cequesabe.dominio.com on htaccess Posted: 07 Apr 2021 08:01 AM PDT I am trying to create a RewriteRule to achieve the following result: dominio.com/user1 to user1.dominio.com dominio.com/user32 to user32.dominio.com The thing is i need some dynamic solution to deal with several different usernames that might come up once new users regiter on the website. Thanks! |
how can i show android in android studio project option? Posted: 07 Apr 2021 08:00 AM PDT i'm trying to open android in project but i don't have. how can i open android?? what i want is like this but in my android studio is there is no android in project what should i do? |
Why is writing to a channel a blocking call in Go? Posted: 07 Apr 2021 07:59 AM PDT I was reading about the concurrency patterns in Go , and writing to a channel is a blocking call. Why was this design chosen? Like, reading from a channel is blocking makes sense because maybe the read value is being used further down in the function. But can someone provide an example where, had writing to a channel not been blocking, the program would yield "non-desired" output? |
Break ties using rank function (OR other function) PYTHON Posted: 07 Apr 2021 08:01 AM PDT I have the following dataframe: ID Name Weight Score 1 Amazon 2 11 1 Apple 4 10 1 Netflix 1 10 2 Amazon 2 8 2 Apple 4 8 2 Netflix 1 5 Currently I have a code which looks like this #add weight and score column df['Rank'] = df['Weight'] + df['Score'] #create score rank on ID column df['Score_Rank'] = df.groupby('ID')['Rank'].rank("first", ascending = False) This code does not give me exactly what I want. I would like to first rank on Score, without including the weight. And then break any ties in the rank by adding weight column to break them. If there are further ties after weight column has been added, then rank would be by random selection. I think an if statement could work in this scenario, just not sure how. Expected output: ID Name Weight Score Score_Rank 1 Amazon 2 11 1 1 Apple 4 10 2 1 Netflix 1 10 3 2 Amazon 2 8 2 2 Apple 4 8 1 2 Netflix 1 5 3 |
Match a column values to a list of vector of codes and create a column indicating which vector it belongs to Posted: 07 Apr 2021 08:01 AM PDT I have a tibble with codes which need to match to another list of vectors containing codes. So, in the tibble , a new column would be created indicating which vector does the code belong to. The tibble : library(tidyverse) df <- tibble(id = 1:6, code = c("1502", "0223", "", "0380", "0421", "7958")) > df # A tibble: 6 x 2 id code <int> <chr> 1 1 "1502" 2 2 "0223" 3 3 "" 4 4 "0380" 5 5 "0421" 6 6 "7958" The sample of the list of code vectors: code_list <- list( "0" = "", "2" = c("0031", "0202", "0223", "0362", "0380", "0381", "03810", "03811", "03812", "03819", "0382", "0383", "03840", "03841", "03842", "03843", "03844", "03849", "0388", "0389", "0545", "449", "77181", "7907", "99591", "99592"), "5" = c("042", "0420", "0421", "0422", "0429", "0430", "0431", "0432", "0433", "0439", "0440", "0449", "07953", "27910", "27919", "79571", "7958","V08"), "12" = c("1500", "1501", "1502", "1503", "1504", "1505", "1508", "1509", "2301", "V1003")) The column code_cat is the result I am looking for. The code "1502" belongs to vector "12" in the code_list and so on. I could have used one of the join functions had the code_list been a data-frame. But as it is a list, I'm not sure how to proceed. Or maybe we can try converting the code_list to a data-frame. Required result: # A tibble: 6 x 3 id code code_cat <int> <chr> <chr> 1 1 "1502" 12 2 2 "0223" 2 3 3 "" 0 4 4 "0380" 2 5 5 "0421" 5 6 6 "7958" 5 |
Creating dictionary from list with different orders Posted: 07 Apr 2021 08:01 AM PDT Let's say I have a list that looks like this: [[('name', 'n1')], [('value', 'v1')], [('name', 'n2')], [('value', 'v2')], [('name', 'n3')], [('value', 'v3')]] I am able to run the res = dict((str(x[0][1]), y[0][1]) for x, y in zip(new[::2], new[1::2])) where res then equals {'n1':'v1', 'n2':'v2', 'n3':'v3'} , which is exactly what I want in this case. This is the case when the names and values alternate. However, I also have some lists that look like this: [[('name', 'n1')], [('name', 'n2')], [('name', 'n3')], [('value', 'v1')], [('value', 'v2')], [('value', 'v3')]] Here, I have name, name, name followed by the corresponding value, value, value. In this case, I would like to end up with the same res dictionary as above, but the code I had would not work properly on this case. Is there a way I could cover both cases to create a dictionary that maps the names to the corresponding values? (FYI: there might not be three of each each time, it could be more/less). |
How can I split a text file with # as separator and then split the lines inside the separated part? Posted: 07 Apr 2021 08:00 AM PDT I have a text file that have a pattern like # a,b c,d # e,f g,h I want the result to print as each block separated is an element and each line in the block is a sub-element to the block one [[[a, b], [c, d]], [[e, f], [g, h]]] Here is my code, any suggestion from here to get the result ? Thanks ret_list = [] a = open(file_name,'r') content = a.read() content = content.split('#') for l in content: l = l.strip().split('\n') for elem in l: temp = [] elem = elem.split(',') if '' not in elem: temp.append(elem) ret_list.append(temp) a.close() And the result I got [[], [['a', 'b']], [['c', 'd']], [['e', 'f']], [['g', 'h']]] |
Why can't I close when using pystray? Posted: 07 Apr 2021 08:00 AM PDT I've written a program using tkinter which when the main window is closed is supposed to be minimized to the system tray. But when I try to exit the program clicking "Close" in the tray that triggers the following function: def quit_window(icon, item): icon.stop() # Удаление иконки из трея sys.exit(0) # Завершение программы But it does not work and throws the following exception: An error occurred when calling message handler Traceback (most recent call last): File "C:\Users\a-par\mini_library_2020\env\lib\site-packages\pystray\_win32.py", line 386, in _dispatcher return int(icon._message_handlers.get( File "C:\Users\a-par\mini_library_2020\env\lib\site-packages\pystray\_win32.py", line 207, in _on_notify descriptors[index - 1](self) File "C:\Users\a-par\mini_library_2020\env\lib\site-packages\pystray\_base.py", line 267, in inner callback(self) File "C:\Users\a-par\mini_library_2020\env\lib\site-packages\pystray\_base.py", line 368, in __call__ return self._action(icon, self) File "c:/Users/a-par/mini_library_2020/LC.pyw", line 2976, in quit_window sys.exit(0) SystemExit: 0 Also there's a VK bot in the program which is supposed to work when the program is minimized (it's the reason for actually minimizing to the tray). The bot works in a different from GUI thread. I tried to delete the bot fully but it didn't any help. Maybe the problem is threads but I don't think that way... Minimally reproducible non-working code: import pystray import sys import time from PIL import Image from pystray import Menu, MenuItem def exit_action(icon): sys.exit(0) def setup(icon): icon.visible = True i = 0 while icon.visible: # Some payload code print(i) i += 1 time.sleep(5) def init_icon(): icon = pystray.Icon('mon') icon.menu = Menu( MenuItem('Exit', lambda : exit_action(icon)), ) icon.icon = Image.open('C:/Users/a-par/mini_library_2020/logo.ico') icon.title = 'tooltip' icon.run(setup) init_icon() Video |
how to reformat date type from MongoDB to Angular Posted: 07 Apr 2021 08:00 AM PDT My question is simple how can I pipe type date ?? meanes if the date in MongoDB looks like this : 2021-01-31T23:00:00.000+00:00 and in my case I want it to take this format 2021-01-31 no more please how can I do it I'm using MEAN stack (MongoDB, Express js, Angular, Node js) I want to do it without changing it into a string and get a substring is that possible? Please help |
How to fix this dynamic sql query function in php 8? Posted: 07 Apr 2021 08:00 AM PDT In my older projects, I used a function to 'shorten' my code a bit when doing queries. Instead of using the usual approach of $conn = [...] $stmt = $conn->prepare(...) $stmt->bind_param(...) $stmt->execute(); $stmt->close(); $conn->close(); I got a function to do that fore me, called dynamic_db_reader($mysqli, $param, $qry) . It returns an array (or null) like: $array[index]['column_name'] = value Or at least, that's what it used to do in previous versions. (Worked on: php 7.4.16) Here is the code to my function: /** * Dynamically executes a given sql statement as prepared statement (?-placeholder). * Expects correct parameters as an array to replace ?. * Returns an array with ($arr[index]['column_name'] = value), or null. * * @param $ms mysqli * @param $params array * @param $qry string * @return array|null */ function dynamic_db_reader($ms, $params, $qry){ $fields = array(); $results = array(); // Replace prefix (DBPREF in: inc/config.php) if (strpos($qry, 'prefix_') !== false){ $qry = str_replace('prefix', DBPREF, $qry); } // Set charset mysqli_set_charset($ms, 'utf8mb4'); if ($stmt = $ms->prepare($qry)){ // Dynamically bind parameters from $params if (!isset($params) || !empty($params)){ // Parameters are set $types = ''; foreach($params as $param){ // Set parameter data type if (is_string($param)){ $types .= 's'; // Strings } else if (is_int($param)){ $types .= 'i'; // Integer } else if (is_float($param)){ $types .= 'd'; // Double/Float } else { $types .= 'b'; // Default: Blob and unknown types } } $bind_names[] = $types; for ($i = 0; $i < count($params); $i++){ $bind_name = 'bind' . $i; $$bind_name = $params[$i]; $bind_names[] = &$$bind_name; } call_user_func_array(array($stmt, 'bind_param'), $bind_names); } $stmt->execute(); $meta = $stmt->result_metadata(); // Dynamically create an array to bind the results to while ($field = $meta->fetch_field()){ $var = $field->name; $$var = null; $fields[$var] = &$$var; } // Bind results call_user_func_array(array($stmt, 'bind_result'), $fields); // --> Error :( // Fetch results $i = 0; while ($stmt->fetch()){ $results[$i] = array(); foreach($fields as $k => $v){ $results[$i][$k] = $v; } $i++; } // Close statement $stmt->close(); if (sizeof($results) > 0){ return $results; } } return NULL; } The error: Fatal error: Uncaught ArgumentCountError: mysqli_stmt::bind_result() does not accept unknown named parameters in [...]\inc\db.php:87 Stack trace: #0 [...]\root\inc\db.php(87): mysqli_stmt->bind_result(data_key: NULL, data_value: NULL) #1 [...]\root\inc\func\common.php(76): dynamic_db_reader(Object(mysqli), Array, 'SELECT * FROM v...') #2 [...]\root\www\index.php(22): getTestArray() #3 {main} thrown in [...]\root\inc\db.php on line 87 I tried wrapping my head around this for a while now, and managed to come up with this: call_user_func_array($function = array($mysqli_stmt = $stmt, 'bind_result'), array(&$stmt, &$fields)); It eliminates the error, but for some reason the fetch() doesn't work anymore. Doing a var_dump($stmt) I get: object(mysqli_stmt)#2 (10) { ["affected_rows"]=> int(1) ["insert_id"]=> int(0) ["num_rows"]=> int(1) ["param_count"]=> int(0) ["field_count"]=> int(2) ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["sqlstate"]=> string(5) "00000" ["id"]=> int(1) } At the same time, I get the following error: Fatal error: Uncaught Error: Call to a member function fetch() on string in [...] And now I'm totally confused, since the var_dump shows $stmt to be a mysqli_stmt Object (as expected), but a string in the following line? |
Firebase Database console.log() returning Null in Javascript Posted: 07 Apr 2021 08:00 AM PDT I hope to seek help from someone if possible. In the following code. Im trying to console.log() data from My Firebase reference as you can see in my code below. But the Console.log() is returning null instead of the values that are there in Firebase Realtime Database. I have also provided the code for adding which is working well. Please have a look the image of my database if it helps. Firebase DB. I am not getting any other error in my console except the fact that this is returning null . function addFamilyMember() { var NameOfMember = document.getElementById("newFamilyMemberName").value; var DoBOfMember = document.getElementById("newFamilyMemberDoB").value; var EmailOfMember = document.getElementById("newFamilyMemberEmail").value; var ContactOfMember = document.getElementById("newFamilyMemberContactNo").value; if ( NameOfMember.length == "" || DoBOfMember.length == "" || EmailOfMember.length == "" || ContactOfMember.length == "" ) { alert("Please enter all details of your Family Member"); } else { var user = firebase.auth().currentUser; var uid; if (user != null) { uid = user.uid; } firebase .database() .ref("/Users/" + uid + "/Family/" + NameOfMember) .set({ MemberName: NameOfMember, MemberDOB: DoBOfMember, MemberEmail: EmailOfMember, MemberContact: ContactOfMember, }); } } var user = firebase.auth().currentUser; var uid; if (user != null) { uid = user.uid; } firebase .database() .ref("/Users/" + uid + "/Family/") .on("value", function (snap) { var mName = snap.child("MemberName").val(); var mDOB = snap.child("MemberDOB").val(); var mEmail = snap.child("MemberEmail").val(); var mContact = snap.child("MemberContact").val(); console.log(mName + " " + mEmail + " " + mContact + " " + mDOB); }); |
Formatting calculated values in Adobe Document Generation API Posted: 07 Apr 2021 08:00 AM PDT In the template language docs for Adobe Document Generation, mathematical expressions can be done using tags like below... {{expr(revenue - expenditure)}} This works and outputs a number, but is there any way to apply formatting to the number, for example, $50,000.00 where the calculated value is just 50000? |
Azure Pipelines secure file unique identifier Posted: 07 Apr 2021 08:00 AM PDT In Azure Pipelines you can upload a secure file. Below I have uploaded a .p12 certificate file. Then, you can reference this file with the InstallAppleCertificate@2 task. How do you get the GUID value for the unique identifier of the file? I am not seeing where I can find this value. |
undefined is not iterable (cannot read property Symbol(Symbol.iterator)) Posted: 07 Apr 2021 08:00 AM PDT I'm trying to loop through a fileList in order to perform a delete query. First i fetched data from table "files" in database where attribute "postnumber"=user input. Then it is saved into the "fileList:Files[] ". Then a loop through this fileList in order to perform a delete query. but it keeps saying that "ERROR TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))". See this image => forum-admin-list.component.ts import { FileService } from 'src/app/shared/file.service'; import { Files } from 'src/app/shared/files.model'; export class ForumAdminListComponent { fileList:Files[]; onDelete(pNo:string){ this.fservice.getPost(pNo).subscribe(actionArray => { this.fileList = actionArray.map(item => { return { id: item.payload.doc.id, ...item.payload.doc.data() } as Files; }) }); for(let i of this.fileList){ this.storage.storage.refFromURL(i.path).delete(); this.firestore.doc("files/"+i.id).delete(); } } } files.model.ts export class Files { id:string; pNo:string; downloadURL:string; path:string; } file.service.ts export class FileService { formData: Files; constructor(private firestore: AngularFirestore) { } getPost(userRef){ return this.firestore.collection('files',ref=>ref.where('pNo','==',userRef)).snapshotChanges(); } } |
Bluestacks error: Failed to load channels. Unable to connect to the internet Posted: 07 Apr 2021 08:00 AM PDT I keep getting this issue; Failed to load channels. Unable to connect to the internet. When I try to load up bluestacks, I have tried numerous things such as using older versions and latest version of bluestacks, restarting, flushing DNS, using other DNS, using proxy and nothing seems to work. I cannot use any other alternatives to bluestacks. Specs: Windows 10 64bit Intel |
Comparing dates with JUnit testing Posted: 07 Apr 2021 08:00 AM PDT Hello I'm new to the site and have a issue with my application using JUnit testing. My issue is when I try to compare the Date method with itself it always fails. I printed the Date object in the test to see the problem and always end up with the package name and random letters. Here is the Date constructor: public class Date { SimpleDateFormat dformat = new SimpleDateFormat("dd-MM-yyyy"); private int day; private int month; private int year; public Date() { String today; Calendar present = Calendar.getInstance(); day = present.get(Calendar.DAY_OF_MONTH); month = present.get(Calendar.MONTH); year = present.get(Calendar.YEAR); present.setLenient(false); present.set(year, month - 1, day, 0, 0); today = dformat.format(present.getTime()); System.out.println(today); } Here is my test: @Test public void currentDay() { Date current = new Date(); System.out.println(current); assertEquals("today:", current, new Date()); } Yet the result always fails and I get something on the lines of: comp.work.wk.Date@d3ade7 Any help would be appreciated. |
Sequentially iterate over arbitrary number of vectors in C++ Posted: 07 Apr 2021 08:00 AM PDT I have a function that gathers and concatenates some number of vectors (with the same types of elements, of course). Here is the bare-bones idea of it: vector<A> combined; ... for(int i = 0; i < someNumber; i++) combined.insert(combined.end(), GetNextRange().begin(), GetNextRange().end()); All of this is done so that I can sequentially iterate over the combined set. I would like to achieve this without all of the copying business. Since GetNextRange() actually returns a reference to the next vector in line, how can I make use of that fact and put the references together/line them up for the desired access method? |
How to add a library project in xcode? Posted: 07 Apr 2021 08:00 AM PDT How do I add a third party library project to my Xcode project so that the third party Library header files are accessible to the rest of the file in the main project. I tried drag and drop; Added target Dependencies; and did 'Link binary with libraries', but still I am not able to include the third party header files. Am I missing out something? |
Error: JavaFX runtime components are missing, and are required to run this application Posted: 07 Apr 2021 08:00 AM PDT I tried to build the application using javafx ant build, generated jar file. But when I run the jar file, issue: Error: JavaFX runtime components are missing, and are required to run this application. The javafx-class-path: libs/h2.jar libs/jfxrt.jar libs/log4j.jar Running the JAR file using: java -jar app.jar What could it be? |
Get Insert Statement for existing row in MySQL Posted: 07 Apr 2021 08:00 AM PDT Using MySQL I can run the query: SHOW CREATE TABLE MyTable; And it will return the create table statement for the specificed table. This is useful if you have a table already created, and want to create the same table on another database. Is it possible to get the insert statement for an already existing row, or set of rows? Some tables have many columns, and it would be nice for me to be able to get an insert statement to transfer rows over to another database without having to write out the insert statement, or without exporting the data to CSV and then importing the same data into the other database. Just to clarify, what I want is something that would work as follows: SHOW INSERT Select * FROM MyTable WHERE ID = 10; And have the following returned for me: INSERT INTO MyTable(ID,Col1,Col2,Col3) VALUES (10,'hello world','some value','2010-10-20'); |
No comments:
Post a Comment