Posts

C++ Boost - serialization of class containing class-hierarchy objects

Image
Clash Royale CLAN TAG #URR8PPP C++ Boost - serialization of class containing class-hierarchy objects I have a class A , which contains the object of class B and I want to serialize it. The problem is, the class C inherits from B , so A can contain an object of either B or C . How can I efficiently implement the serialization with Boost? A B C B A B C My attempt is below, but I'm getting the error when trying to serialize A with C object, while with B it works correctly. Do you know, what am I doing wrong? A C B I've found some information about class-hierarchy objects serialization here, but it requires an explicit registration of the type in text_iarchive , whereas I need it to be registered in the A class because I'm not directly serializing B objects. text_iarchive A B #include <fstream> #include <iostream> #include <vector> #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> class B friend cla...

Adding character in matrix in R

Image
Clash Royale CLAN TAG #URR8PPP Adding character in matrix in R I import csv by. data<-read.csv('test.csv') and then data has value > data name a b c d 1 a 1 2 1 1 2 b 2 2 2 4 now i wish to add row at the bottom of data so,I add results <- c('aa',2,3,4,5) data[nrow(data)+1,]<-results But it cause me warring and character value is not inserted. Warning message: In `[<-.factor`(`*tmp*`, iseq, value = "aa") : invalid factor level, NA generated and data has value = > data name a b c d 1 a 1 2 1 1 2 b 2 2 2 4 3 <NA> 2 3 4 5 but i want to have > data name a b c d 1 a 1 2 1 1 2 b 2 2 2 4 3 aa 2 3 4 5 I am new in R and have tried for the ans for many hours so any help will be appreciated.Thank you. Try not to have factor variables in your data frame and your code will work. This simple example will show the difference dt = data.frame(x=c("A","B"), y=1:2, stringsAsFactors = T); dt[3,] = c("C",3); dt...

Static variable inside class

Image
Clash Royale CLAN TAG #URR8PPP Static variable inside class I am much confused about static variable actually i am executing below program. class ABC public static int prop get; set; const int i =5; static int j; public ABC() prop = 8; j = 9; Console.WriteLine("Under ABC class's constructor."); public int getValue() j = 6; prop = 89; return j; class Program static void Main(string args) ABC obj = new ABC(); Console.WriteLine(obj.getValue()); //Console.WriteLine(ABC.j); Console.ReadLine(); And its executing without any compile or run time error. I have following confusions. Please explain what from the official documentation about the static keyword is not clear enough. – Camilo Terevinto Aug 12 at 13:18 static Yes camilo, i read this documentation and my main concern is, if we can assign static variable/property from any where within the same class (like normal variable) then what is the use of static constructor? As i used to know fro...

How to reuse code (a Guard) defined in a submachine in the parent SM (using boost-msm)?

Image
Clash Royale CLAN TAG #URR8PPP How to reuse code (a Guard) defined in a submachine in the parent SM (using boost-msm)? I've defined a guard in a sub-state machine and now I want to use the exact logic/guard in the parent SM (using boost-msm). using the same guard in the transition_table results in compilation error: unknown type name 'GuardSS'. I've defined the guard (and its corresponding value) in the sub-machine, but it can be moved to the parent SM if it helps in solving the problem and allows me to reuse the guard. A sample code can be found here. How can I reuse the code used in the guard? Code included: #include <iostream> #include "myfsm.h" int main() std::cout << "Testing boost::msm ..." << std::endl; MyFsm fsm; fsm.start(); fsm.process_event(Event12()); fsm.process_event(Event_ss12()); //guard valu changes MyFsm_::State2 &state = fsm.get_state<MyFsm_::State2&>(); state.m_guardVal = true; fsm.p...

Updating each one of the keys inside an array of tuples

Image
Clash Royale CLAN TAG #URR8PPP Updating each one of the keys inside an array of tuples I have an array of tuples that each contain a key and a value. At the moment I am filtering all the tuples that keys are larger than an Int. Then using this filtered array to update each one of the of their keys but keeping the same values. The way I'm doing it currently doesn't work as it just removes all the tuples that keys are equal to the filtered keys before I have appended the new keys, which is understandable. What I would like to do is, instead of removing them and then adding them back, just update each one of their keys, however with me being relatively new to coding I have no idea how to do this. As I guess its something to do with compactMap or flatMap but again, have no idea how to do this. Any help is greatly appreciated, many thanks!! My tupleArray: [(key: 1, value: "A"), (key: 2, value: "V"), (key: 3, value: "E"), (key: 4, value: "N...

Copy an entire row from sheet 2 which contains any value from column A on sheet 1

Image
Clash Royale CLAN TAG #URR8PPP Copy an entire row from sheet 2 which contains any value from column A on sheet 1 I would like to be able to copy any row from sheet 2 which contains any value from column a in sheet 1. I so far have this code but keep getting subscript out of range errors. Any help would greatly be appreciated. Thanks Sub test() Dim MyCell As Range, MyRange As Range Dim row_counter As Long, col_counter As Long Set MyRange = Sheets(“Sheet1”).Range("A1") For Each MyCell In MyRange If Cell.Value = MyCell.Value Then Cell.EntireRow.Copy End If Next MyCell End Sub Do you mean If MyCell.Value = MyRange.Value ? There is no variable here defined as Cell so something is off in your If statement – urdearboy Aug 12 at 15:59 If MyCell.Value = MyRange.Value Cell If Do you understand that you're iterating over single cell? – JohnyL Aug 12 at 17:45 Also you're doing .copy but not .paste ... – Marcucciboy2 Aug 13 at ...

Enable buttons and other events outside modal without closing it

Image
Clash Royale CLAN TAG #URR8PPP Enable buttons and other events outside modal without closing it I would like to ask if it is possible to enable events outside modal. For example: [I would like to click on this button outside modal without closing it.][1] By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

How to switch all lights on/off at once in Cycles?

Image
Clash Royale CLAN TAG #URR8PPP How to switch all lights on/off at once in Cycles? In cycles, lights intensity can be modulated by varying their Color values. Is there a way to do this for multiple lights at once without using individual keyframes (keying a single object is ok). My need is only to have two states (black, white) if this is more simple to obtain. 1 Answer 1 You could just use instances. (Copying with Alt + D) Or, after the fact, assign the same Data Block to every light here: Alternative with Drivers: Add a driver like this to the Strength of every lamp. That way you can maintain more control over individual lamps. This uses the zLocation of an Empty and multiplies it with the Strength. You would simply use the same Empty for all Lamps. That way you can control them all at once. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the webs...

Multiline regex find third div in div group

Image
Clash Royale CLAN TAG #URR8PPP Multiline regex find third div in div group How can I write a regular expression to find the third div class name in a group div? So in the instance below, I'd like to find clsA3 <div class="clsA"> <div class=clsA1">blah</div> <div class=clsA2">blah</div> <div class=clsA3">blah</div> </div> I'm trying to use Visual Studio 2013 Search and Replace using Regular Expression option. The purpose of this task is one-time maintenance task. You mean this regex101.com/r/rX5eE5/4 ? – Avinash Raj Dec 10 '14 at 18:57 1 Answer 1 Works with VS2010. Not sure if VS2013 does normal regex yet. Find: <div class=[^>]*>[ n]*(<div class=[^>]*>[^<]*</div>[ n]*)^2<div class="@[^">]+"@>[^<]*</div>[ n]*</div> Replace: 1Hello World2 Output: <div class="clsA"> <div class=clsA1">blah</...

Python Merge the lines between triple single quotes and then replace the starting quote with '#'

Image
Clash Royale CLAN TAG #URR8PPP Python Merge the lines between triple single quotes and then replace the starting quote with '#' ''' Created on Mar 11, 2017 @author: XXZ This file is to demonstrate the word frequency counter. This is a very important practical ''' Required Output: #Created on Mar 11, 2017 @author: XXZ This file is to demonstrate the word frequency counter. This is a very important practical (I want to count it as a comment) By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

How to remove or stop BIOS built-in NVMe Bus Driver

Image
Clash Royale CLAN TAG #URR8PPP How to remove or stop BIOS built-in NVMe Bus Driver I am developing a NVMe test tool under UEFI environment. But I found that BIOS built-in NVMe bus driver will interfere with my tool. For example, my tool will re-initialize all NVMe registers for testing purpose, but NVMe bus driver will sometimes change them back to their original values. So, is there any way to remove or stop BIOS built-in NVMe bus driver? I tried disconnecting the controller before running my tool, but some platform will hang. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Netty dependency issue with ElasticSearch 6.3.2

Image
Clash Royale CLAN TAG #URR8PPP Netty dependency issue with ElasticSearch 6.3.2 I'm using spring boot and trying to connect with Elasticsearch recent version 6.3.2 but couldn't Do we need to specify any appropriate jar version Error: Caused by: java.lang.NoClassDefFoundError: io/netty/util/internal/logging/InternalLoggerFactory at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_161] at java.lang.ClassLoader.defineClass(Unknown Source) ~[na:1.8.0_161] at java.security.SecureClassLoader.defineClass(Unknown Source) ~[na:1.8.0_161] at java.net.URLClassLoader.defineClass(Unknown Source) ~[na:1.8.0_161] at java.net.URLClassLoader.access$100(Unknown Source) ~[na:1.8.0_161] at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.8.0_161] at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.8.0_161] at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_161] at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_161] at java.lang.C...

Angular Http method not found

Image
Clash Royale CLAN TAG #URR8PPP Angular Http method not found I've used this as core project for one of my project and I am stuck with it. I trying to use the http method but it fails. I've tried add the HttpClientModule to the app.module but still nothing. The error that i get is : app.ae014c5e7b696f87de83.bundle.js:107 ERROR TypeError: Cannot read property 'method' of undefined All I did in the app.component.ts file add export class AppComponent extends BaseComponent implements OnInit { constructor( private readonly i18nStore: Store<I18NState>, private readonly config: ConfigService, private http: HttpClient, @Inject(PLATFORM_ID) public platformId: Object ) super(); // TODO: ngx-i18n-router // private readonly i18nRouter: I18NRouterService) ngOnInit(): void this.i18nStore.dispatch(new Init(this.config.getSettings('i18n'))); createUserA(): void this.http.get<any>('https://swapi.co/api/people/1') .subscribe(data => conso...

Difference between %% and % in R [closed]

Image
Clash Royale CLAN TAG #URR8PPP Difference between %% and % in R [closed] What is the difference between %% and % in the R programming language? %% % I am getting the following result: > 5%%2 [1] 1 > 5%2 Error: unexpected input in "5%2" where can we use a single % in R ? % This question appears to be off-topic. The users who voted to close gave this specific reason: There is no single % in R. help("%")# No documentation for ‘%’ in specified packages and libraries: – akrun Aug 12 at 13:28 % help("%")# No documentation for ‘%’ in specified packages and libraries: 2 Answers 2 In R , there is no % . We can find it from R % help(`%`) No documentation for ‘%’ in specified packages and libraries: you could try ‘??%’ In R %% gives remainder of first vector with the second as follows a example. %% first <- c( 2,5.5,6) second <- c(8, 3, 4) print(first%%second) Output will be as follows. [1] 2.0 ...

Trying to access first member(itself a volatile pointer) of struct pointer does not return the stored member pointer but the struct address

Image
Clash Royale CLAN TAG #URR8PPP Trying to access first member(itself a volatile pointer) of struct pointer does not return the stored member pointer but the struct address I am trying to implement some pointer substitution for some communication interface by passing on a pointer to a struct of pointers to some implementation. This is meant to run on an Atmega328p and is being compiled with avr-gcc.exe (AVR_8_bit_GNU_Toolchain_3.5.4_1709) 4.9.2, installed in/via msys2 64bit on Windows 10 Now, given the following struct typedef struct volatile uint8_t* baudrateRegister; volatile uint8_t* statusRegister; volatile uint8_t* controlRegister; volatile uint8_t* dataRegister; CommRegisters; I create this as a file scope variable in my main file and fill it with the corresponding addresses (in this case 0xB9, 0xB8, 0xBC, 0xBB ) according to my datasheet. 0xB9, 0xB8, 0xBC, 0xBB CommRegisters myInterface = &BAUDRATEREGISTER, &STATUSREGISTER, &CONTROLREGISTER, &DATAREGISTER; ...

Error: No build files found, please run `nuxt build` before launching `nuxt start

Image
Clash Royale CLAN TAG #URR8PPP Error: No build files found, please run `nuxt build` before launching `nuxt start I created a nuxt boilerplate using vue-cli nuxt-community/starter-template I also created another using create-nuxt-app . They both create my boilerplate properly. But anytime i try to build start my projects using yarn start I get this error: Error: No build files found, please run nuxt build before launching `nuxt start nuxt build furthermore, whenever i run nuxt build I get this: No command 'nuxt' found, did you mean: Command 'next' from package 'nmh' (universe) nuxt: command not found but when i run yarn build it builds and running yarn start a second time works but without hot module reloading. I don't know what the problem is. I don't know whether my yarn is broken or nuxt. Please help! 1 Answer 1 nuxt build does not work from your command line, because you have not added it to your PATH variable. npm run build ...