instruction
stringlengths
0
30k
Hi I was facing this Issue when i was using Bootstrap 5 & angular12 <button class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" type="button" id="dropdownMenuButton" aria-haspopup="true" aria-expanded="false">Dropdown button </button> **And in angular.js** "scripts": [ "./node_modules/jquery/dist/jquery.min.js", "./node_modules/@popperjs/core/dist/umd/popper.min.js", "./node_modules/bootstrap/dist/js/bootstrap.bundle.min.js" ]
The kernel I have used is the as a Laplacian kernel, which is commonly used for sharpening images. It enhances the edges and details in the image. Secondly in the code for the TwoD_convolution I have made the following modifications: 1. I have tried normalizing the kernel, ensuring that the overall intensity of the image remains relatively stable across different regions. 2. I have clipped the values ensuring that no overflow occurs, thus minimizing artifacts like green dots. I have run this on google colab and it works ``` import numpy as np from PIL import Image import matplotlib.pyplot as plt import requests def TwoD_convolution(img, kernel): kernel = kernel[::-1] for i in range(len(kernel)): kernel[i] = kernel[i][::-1] convolve = np.zeros((img.shape[0]+len(kernel)-1, img.shape[1]+len(kernel[0])-1, 3), np.uint8) midx = len(kernel) // 2 midy = len(kernel[0]) // 2 # HERE I NORMALIZE THE KERNEL kernel_sum = np.sum(kernel) if kernel_sum == 0: kernel_sum = 1 normalized_kernel = kernel / kernel_sum for i in range(convolve.shape[0]): for j in range(convolve.shape[1]): for k in range(3): cur = 0 for x in range(-midx, midx+1): for y in range(-midy, midy+1): if i+x >= 0 and i+x < img.shape[0] and j+y >= 0 and j+y < img.shape[1]: cur += ((img[i+x][j+y][k]) * (normalized_kernel[midx+x][midy+y])) convolve[i][j][k] = np.clip(cur, 0, 255) # RANGE CHECKING return convolve url = 'https://upload.wikimedia.org/wikipedia/en/7/7d/Lenna_%28test_image%29.png' image = Image.open(requests.get(url, stream=True).raw) img_array = np.array(image) kernel = np.array([[0, -1, 0], [-1, 5, -1], [0, -1, 0]]) convolved_img = TwoD_convolution(img_array, kernel) plt.figure(figsize=(10, 5)) plt.subplot(1, 2, 1) plt.imshow(img_array) plt.title('Original Image') plt.axis('off') plt.subplot(1, 2, 2) plt.imshow(convolved_img) plt.title('Convolved Image') plt.axis('off') plt.show() ``` I'm sorry If I have putted all of this code here but it's to get the example clear
{"OriginalQuestionIds":[2960772],"Voters":[{"Id":523612,"DisplayName":"Karl Knechtel","BindingReason":{"GoldTagBadge":"python"}}]}
Have a custom live search feature on our wordpress website, which only displays 20 products in the middle of the screen for any given search. Would like to be able to remove this 20 limit, so that either 50 products, or unlimited products are shown.(Would like to try both options, to see which works best). So far have come up with the code below for our function.php file, which unfortunately doesn't work: function search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_wpsc_gc_live_search_pre_get_posts) { $query->set('posts_per_page', -1); } } } add_action('pre_get_posts','search_filter');` Code below from the live search file that may help with the tweaking of the above code: function wpsc_gc_start_search_query() { global $wp_query, $wpsc_query; $product_page_id = wpsc_get_the_post_id_by_shortcode('[productspage]'); $post = get_post( $product_page_id ); $wp_query = new WP_Query( array( 'pagename' => $post->post_name ) ); add_action( 'pre_get_posts', 'wpsc_gc_live_search_pre_get_posts' ); wpsc_start_the_query(); remove_action( 'pre_get_posts', 'wpsc_gc_live_search_pre_get_posts' ); list( $wp_query, $wpsc_query ) = array( $wpsc_query, $wp_query ); // swap the wpsc_query object $GLOBALS['nzshpcrt_activateshpcrt'] = true; What we are basically trying to do is set the following: Number of products per page to show during the live search, at either 50, or unlimited (would like to try both scenarios). Code below, which relates to the number of products showing per page: wpsc_products_per_page Would be great for some help and advise on how we can getting the above filter to work. Created the above filter for our themes function.php file, which needs tweaking.
How to integrate sinhala character recognition to Flutter application. I want to convert image file to sinhala word file I tried various way for do this.(Google's ML Kit for Flutter) but i cant reach to proper converting sinhala characters. Please can you any help for this...
sinhala character recognition to Flutter application
|flutter|ocr|
null
I am observing a strange behaviour where GCC (but not clang) will skip a pointer-reset-after-free expression in the global destruction phase and with certain values of `-O?`. I can reproduce this with every version I tried (7.2.0, 9.4.0, 12.3.0 and 13.2.0) and I'm trying to understand if this is a bug or not. The phenomenon occurs in the [C++ wrapper for lmdb][1]; here are the functions that are involved directly: static inline void lmdb::env_close(MDB_env* const env) noexcept { delete ::mdb_env_close(env); } class lmdb::env { protected: MDB_env* _handle{nullptr}; public: ~env() noexcept { try { close(); } catch (...) {} } MDB_env* handle() const noexcept { return _handle; } void close() noexcept { if (handle()) { lmdb::env_close(handle()); _handle = nullptr; // std::cerr << " handle now " << handle(); } // std::cerr << "\n"; } I use this wrapper in a class `LMDBHook` of which I create a single, static global variable: class LMDBHook { public: ~LMDBHook() { if (s_envExists) { s_lmdbEnv.close(); s_envExists = false; delete[] s_lz4CompState; } } static bool init() { if (!s_envExists) { try { s_lmdbEnv = lmdb::env::create(); //snip } catch (const lmdb::error &e) { // as per the documentation: the environment must be closed even if creation failed! s_lmdbEnv.close(); } } return false; } //snip static lmdb::env s_lmdbEnv; static bool s_envExists; static char* s_lz4CompState; static size_t s_mapSize; }; static LMDBHook LMDB; lmdb::env LMDBHook::s_lmdbEnv{nullptr}; bool LMDBHook::s_envExists = false; char *LMDBHook::s_lz4CompState = nullptr; // set the initial map size to 64Mb size_t LMDBHook::s_mapSize = 1024UL * 1024UL * 64UL; I first came across this issue because an application using `LMDBHook` would crash just before exit when built with GCC but not with clang, and initially thought that this was some subtle compiler influence on the order of calling dtors in the global destruction phase. Indeed, allocating `LMDH` *after* initialising the static member variables will not trigger the issue. But the underlying issue here is that the line `_handle = nullptr;` from `lmdb::env::close()` will be skipped by GCC in the global destruction phase (but not when called e.g. just after `lmdb::env::create()` in `LMDBHook::init()`) and "only" when compiled with -O1, -O2 -O3 or -Ofast (so not with -O0, -Og, -Os or -Oz). The 2 trace output exprs in `lmdb::env::close()` are mine; if I outcomment them the reset instruction is not skipped. The fact that it only happens under specific circumstances during global destruction makes me think it is maybe not a bug though if so the behaviour should not depend on the optimisation level. I have made a self-contained/standalone demonstrator that contains the `lmdb++` headerfile extended with trace output exprs and where the create and close functions simply allocate the `MDB_env` structure with `new` and `delete`, plus the `lmdb` headerfile with an added definition of the `MDB_env` structure (normally it's opaque) : https://github.com/RJVB/gcc_potential_optimiser_bug.git . The README has instructions how to use the Makefile but it should be pretty self-explanatory. Here's some example output: > make -B CXX=g++-mp-12 && lmdbhook g++-mp-12 --version g++-mp-12 (MacPorts gcc12 12.3.0_4+cpucompat+libcxx) 12.3.0 Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. g++-mp-12 -std=c++11 -O3 -o lmdbhook lmdbhook.cpp LMDBHook::LMDBHook() s_lmdbEnv=0x404248 lmdb::env::env(MDB_env*) this=0x404248 handle=0 lmdb::env::env(MDB_env*) this=0x7ffec95f40f8 handle=0x1333020 lmdb::env::~env() this=0x7ffec95f40f8 void lmdb::env::close() this=0x7ffec95f40f8 handle=0 static bool LMDBHook::init() s_lmdbEnv=0x1333020 handle=0x1333020 void lmdb::env::close() this=0x404248 handle=0x1333020 void lmdb::env_close(MDB_env*) env=0x1333020 static bool LMDBHook::init() s_lmdbEnv=0 handle=0 lmdb::env::env(MDB_env*) this=0x7ffec95f40f8 handle=0x1333020 lmdb::env::~env() this=0x7ffec95f40f8 void lmdb::env::close() this=0x7ffec95f40f8 handle=0 static bool LMDBHook::init() s_lmdbEnv=0x1333020 handle=0x1333020 mapsize=67108864 LZ4 state buffer:16384 LMDB instance is 0x404248 lmdb::env::~env() this=0x404248 void lmdb::env::close() this=0x404248 handle=0x1333020 void lmdb::env_close(MDB_env*) env=0x1333020 LMDBHook::~LMDBHook() void lmdb::env::close() this=0x404248 handle=0x1333020 void lmdb::env_close(MDB_env*) env=0x1333020 *** Error in `lmdbhook': double free or corruption (!prev): 0x0000000001333020 *** Abort > make -B CXX=clang++-mp-12 && lmdbhook clang++-mp-12 --version clang version 12.0.1 Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /opt/local/libexec/llvm-12/bin clang++-mp-12 -std=c++11 -O3 -o lmdbhook lmdbhook.cpp LMDBHook::LMDBHook() s_lmdbEnv=0x205090 lmdb::env::env(MDB_env *const) this=0x205090 handle=0 lmdb::env::env(MDB_env *const) this=0x7ffef6c06ca0 handle=0x2e8c20 lmdb::env::~env() this=0x7ffef6c06ca0 void lmdb::env::close() this=0x7ffef6c06ca0 handle=0 static bool LMDBHook::init() s_lmdbEnv=0x2e8c20 handle=0x2e8c20 void lmdb::env::close() this=0x205090 handle=0x2e8c20 void lmdb::env_close(MDB_env *const) env=0x2e8c20 static bool LMDBHook::init() s_lmdbEnv=0 handle=0 lmdb::env::env(MDB_env *const) this=0x7ffef6c06ca0 handle=0x2e8c20 lmdb::env::~env() this=0x7ffef6c06ca0 void lmdb::env::close() this=0x7ffef6c06ca0 handle=0 static bool LMDBHook::init() s_lmdbEnv=0x2e8c20 handle=0x2e8c20 mapsize=67108864 LZ4 state buffer:16384 LMDB instance is 0x205090 lmdb::env::~env() this=0x205090 void lmdb::env::close() this=0x205090 handle=0x2e8c20 void lmdb::env_close(MDB_env *const) env=0x2e8c20 LMDBHook::~LMDBHook() void lmdb::env::close() this=0x205090 handle=0 EDIT: The above examples are with self-built compilers on Linux but the system compilers show the same behaviour, also on Mac, and the choice of C++ runtime (libc++ or libstdc++) has no influence on either platform. EDIT2: the demonstrator also has an alternative implementation of `lmdb::env::close()` as I would have written it, which caches the `_handle` ptr in a tmp. variable, resets `_handle` and only then frees the cached pointer. This implementation is not subject to whatever this issue really is. [1]: https://github.com/bendiken/lmdbxx
{"Voters":[{"Id":2872922,"DisplayName":"Ron Rosenfeld"}],"DeleteType":1}
I have written a code for finding prime numbers using sieve of Eratosthenes algorithm, but the problem is my code works as it tends to be, but for only some numbers. It shows like "entering upto-value infinitely" as the error and for some numbers it works perfectly. As I started recently studying C in-depth I couldn't find what is going wrong. I request the code-ies to help me in this case, and also help me realize what is the mistake, why it happens and how to prevent it. Here's the code: ``` #include <stdio.h> int main() { int n; printf("enter number: "); scanf("%d",&n); int arr[n],i,pr=2; for(i=0;pr<=n;i++) { arr[i]=pr; pr++; } int j,k; while(arr[k]<=n) { for(j=2;j<n;j++) { for(k=0;k<n;k++) { if(arr[k]%j==0 && arr[k]>j) arr[k]=0; } } } for(i=0;arr[i]<=n;i++) { if(arr[i]!=0) printf(" %d",arr[i]); } printf("\n"); return 0; } ```
I work with the Spring framework and I encounter problem with mapping set of roles from many-to-many table. Let me show you my classes. ``` public class Role { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @NonNull private String authority; @ManyToMany(mappedBy = "roles", fetch = FetchType.EAGER/*, cascade=CascadeType.MERGE*/) private Set<AppUser> appUsers; public Role(@NonNull String authority) { this.authority = authority; } public Role() { } } ``` ``` public class AppUser implements Serializable { @Serial private static final long serialVersionUID = -8357820005040969853L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; // @NonNull @Column(unique = true) private /*final*/ String username; // @NonNull private /*final*/ String password; @ManyToMany(fetch = FetchType.EAGER/*, cascade=CascadeType.MERGE*/) // @NonNull @JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "role_id"/*, referencedColumnName = "id"*/), inverseJoinColumns = @JoinColumn(name = "user_id"/*, referencedColumnName = "id"*/)) private Set<Role> roles; } ``` Here is the saving process: ``` @Bean // @Transactional public CommandLineRunner run(RoleRepository roleRepository, UserRepository userRepository, PasswordEncoder passwordEncoder) { return args -> { if (roleRepository.findByAuthority("ADMIN").isEmpty()) { Role admin = roleRepository.save(new Role("ADMIN")); Role user = roleRepository.save(new Role("USER")); userRepository.save(new AppUser("admin", passwordEncoder.encode("admin"), new HashSet<>() { { add(admin); add(user); } })); } }; } ``` And here is the moment when I want to retrieve roles for the user: ``` @Component public class UserInterceptor implements HandlerInterceptor { private final UserRepository userRepository; private final RoleRepository roleRepository; public UserInterceptor(UserRepository userRepository, RoleRepository roleRepository) { this.userRepository = userRepository; this.roleRepository = roleRepository; } @Override public void postHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler, ModelAndView modelAndView) { if (modelAndView != null) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); Optional<AppUser> appUser = userRepository.findByUsername(authentication.getName()); if (appUser.isPresent()) { Set<Role> set = roleRepository.findByAppUsers(new HashSet<>() { { add(appUser.get()); } }); log.info("Roles for user {}: {}", appUser.get().getUsername(), appUser.get().getRoles()); modelAndView.addObject("username", appUser.get().getUsername()); modelAndView.addObject("roles", appUser.get().getRoles()); } else modelAndView.addObject("username", "anonymous"); } } } ``` The most interesting part is that when I login into system as the "admin" with the password "admin", it sees my User in the database and I actually have value inside Optional<AppUser> appUser. After checking presence I create simple set just to check, whether it maps roles for particular users and it does, after that I have set of roles retrieved by User object. And now comes the magic part: if I try to get roles from the user doing appUser.get().getRoles(), I get EMPTY SET OF ROLES IN THE appUser OBJECT. I mean, I could have tried to get all roles using an extra set created by userRepository.findByUsername, but I feel like it shouldn't work this way. Can anyone help me please, I would appreciate it and it would help me to get Spring framework. Thanks in advance. P.S. Here is the table from the database and yes, names of columns are messed up, I've fixed it already. [![Database](https://i.stack.imgur.com/jsPHv.png)](https://i.stack.imgur.com/jsPHv.png)
To build a subset of a third-party C++ library like XLA as a static library with headers using Bazel, you need to properly define your BUILD file and ensure that the necessary targets are included. also, Regarding the absence of the .a or .lo file in your bazel-bin directory, it's possible that Bazel is not actually building the library because it's empty due to having no source files. Since you mentioned you want to compile a dynamic library with some wrapper code, you'll need to add some source files to your my_xla target, even if they're just empty placeholder files. cc_library( name = "my_xla", hdrs = glob(["path/to/xla/client/*.h"]), ### Adjust the path srcs = ["path/to/emptyfile.cc"], ### Replace Placeholder source file deps = [ "@xla//xla/client:xla_builder", "@com_google_absl//absl/strings:str_format", "@tsl//tsl/platform:logging", "@tsl//tsl/platform:platform_port", ], )
i am using java big decimal. but still i am not getting expected result.. public class DecimalAdjustEx { public static void main(String[] args) { BigDecimal v1 = new BigDecimal("100"); BigDecimal v2 = new BigDecimal("75"); BigDecimal reminder = BigDecimalUtils.divide(v1,v2); System.out.println("reminder= "+reminder); BigDecimal v1Result = BigDecimalUtils.multiply(reminder,v2); System.out.println("v1 Result= "+v1Result); } } Utils class: public class BigDecimalUtils { public static final MathContext DEFAULT_MATH_CONTEXT = new MathContext(34, RoundingMode.HALF_UP); public static BigDecimal multiply(BigDecimal value1, BigDecimal value2) { return value1.multiply(value2,DEFAULT_MATH_CONTEXT); } public static BigDecimal divide(BigDecimal value1, BigDecimal value2) { return value1.divide(value2,DEFAULT_MATH_CONTEXT); } public static BigDecimal add(BigDecimal value1, BigDecimal value2) { return value1.add(value2,DEFAULT_MATH_CONTEXT); } public static BigDecimal subtract(BigDecimal value1, BigDecimal value2) { return value1.subtract(value2,DEFAULT_MATH_CONTEXT); } } output: reminder= 1.333333333333333333333333333333333 v1 Result= 99.99999999999999999999999999999998 here v1 Result should be 100 right. but why it is giving wrong one. how to handle these problems. i cannot use more than 34 digits precision. and i do not want rounding. please suggest a solution.. consider i have huge application, no of arthimatic calculations going on. please suggest a feasible solution.
How can I add a whole column of data as a row?
|t-sql|sql-server-2012|
I am trying to define path as ```js { path: '/:not-found(.*)', name:'Not-Found', component : NotFound } ``` which is not working in vue 3, bit when I am trying to define same path as ```js { path: '/:notFound(.*)', name:'Not-Found', component : NotFound } ``` it is working fine. Why so? Why such behavior from vue 3? I am using "vue-router": "^4.2.5"
It depends what you understand as "typical medium enterprise" AWS offers their own MongoDB, they name it DocumentDB and it is compatible to MongoDB. However, AWS DocumentDB does not provide the full set of features as MongoDB does. MongoDB Enterprise has two license models. The first model is based on the amount of total amount of RAM you have installed at your MongoDB the data bearing nodes (i.e. `mongos` roters, config server and arbiter node do not cost anything) The second model I don't remember anymore, either it was based on the amount of data or number of hosts.
The answer in the following link explains it better than I ever could. The answer goes into all the different date/time classes in Java, as well as their relation to sql types. https://stackoverflow.com/questions/32437550/whats-the-difference-between-instant-and-localdatetime/32443004#32443004 A short summary: The classes Instant and ZonedDateTime (as well as OffsetDateTime) represent the same thing: a moment in time. The difference is that ZonedDateTime and OffsetDateTime offer extra context and functionality about timezones or time offsets, whereas Instant has no timezone or offset specified. This can lead to differences especially when Daylight Saving Time is involved. For instance, take the following snippet of code: ZonedDateTime z1 = ZonedDateTime.of(LocalDateTime.of(2019, 10, 26, 6, 0, 0), ZoneId.of("Europe/Amsterdam")); Instant i1 = z1.plus(1, ChronoUnit.DAYS).toInstant(); Instant i2 = z1.toInstant().plus(1, ChronoUnit.DAYS); System.out.println(i1); System.out.println(i2); The result will be this: 2019-10-27T05:00:00Z 2019-10-27T04:00:00Z The difference stems from the fact that in the Amsterdam timezone, the 27th of October has an extra hour. When we convert to Instant the timezone information is lost, so adding a day will add only 24 hours. LocalDateTime is a different beast alltogether. It represents a date and time without timezone information. It does *not* represent a moment in Time. It is useful for writing things such as "Christmas morning starts at december 25th 00:00:00". This is true regardless of timezone, and as such a ZonedDateTime or Instant would not be appropriate.
You can approach this by pivoting the dataset to a long format, then summing the rows where the party matches the population, and then pivoting back to wide. ``` library(tidyverse) df |> mutate(country=row_number())|> pivot_longer(cols=-c(PartyA, PartyB, country),names_pattern = "(.*)Pop") |> group_by(country) |> mutate(PartyRel=sum(value[name==PartyA|name==PartyB])) |> pivot_wider(id_cols = c(PartyA, PartyB,country,PartyRel)) # A tibble: 5 × 9 # Groups: country [5] PartyA PartyB country PartyRel Christian Muslim Jewish Sikh Buddhist <chr> <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> 1 Christian Jewish 1 21 12 71 9 0 1 2 Muslim Muslim 2 93 1 93 2 0 0 3 Muslim Christian 3 79 74 5 12 1 2 4 Jewish Muslim 4 86 14 86 0 0 0 5 Sikh Buddhist 5 55 17 13 4 10 45 ``` To understand what is happening here have a look at the result after the pivot_longer(): ``` # A tibble: 25 × 5 PartyA PartyB country name value <chr> <chr> <int> <chr> <dbl> 1 Christian Jewish 1 Christian 12 2 Christian Jewish 1 Muslim 71 3 Christian Jewish 1 Jewish 9 4 Christian Jewish 1 Sikh 0 5 Christian Jewish 1 Buddhist 1 6 Muslim Muslim 2 Christian 1 7 Muslim Muslim 2 Muslim 93 8 Muslim Muslim 2 Jewish 2 9 Muslim Muslim 2 Sikh 0 10 Muslim Muslim 2 Buddhist 0 # ℹ 15 more rows # ℹ Use `print(n = ...)` to see more rows ``` then it's just a case of identifying the correct rows to sum. I think this is neater than a rowwise calculation.
null
I am trying to make a CountDownTimer for my Android app, but every time I try to start it using just `timer.start()`, it starts multiple timers. I don't know why. My code for this is: ``` val timer = object: CountDownTimer(5000, 1000) { override fun onTick(millisUntilFinished: Long) { println(millisUntilFinished) if (new == null) { skipTimeButton.visibility = View.GONE exoSkip.visibility = View.VISIBLE dissappeared = false return } } override fun onFinish() { val skip = currentTimeStamp skipTimeButton.visibility = View.GONE exoSkip.visibility = View.VISIBLE disappeared = true } } timer.start() ```
Your fairly "verbose" code can be written a lot shorter if you leave out all the repetitions: <!-- begin snippet:js console:true --> <!-- language:lang-html --> A<button id="na">1</button> B<button id="nb">1</button> X<button id="nx">1</button> Y<button id="ny">1</button> Z<button id="nz">1</button> <div id="highest"></div> <!-- language:lang-js --> const btns=[...document.querySelectorAll("button")], highest=document.getElementById("highest"); btns.forEach(b=>b.onclick=()=>{ b.textContent=+b.textContent+1; highest.textContent="The most popular button ID is "+btns.reduce((a,c)=>(+c.textContent>+a.textContent?c:a)).id }); setInterval(()=>btns[Math.floor(btns.length*Math.random())].click(), 1000); <!-- end snippet --> The above snippet does not use local storage as this is not supported on Stackoverflow. If you require this feature, then the local storage command should be included within the `onclick` function definition. Maybe the expression ``` btns.reduce((a,c)=>(+c.textContent>+a.textContent?c:a)).id ``` deserves a short explanation: it uses the `Array.reduce()` method that loops over all elements of the `btns` array and compares each element's `.textContent` attribute value with the one in the accumulator variable `a`. Tha `a` variable is initially set to the first element of the `btns` array and is assigned the result of the ternary operator expression `(+c.textContent>+a.textContent?c:a)`. So, if the current element's (`c`) value is higher than the one stored in `a` it will be assigned to `a`. At the end of the `.reduce()` loop the element stored in `a` is returned and its attribute `.id` is then used for the outer expression stating the most popular id.
I think if you just explicitly capture both `chatForView` and `chatUser`, it should work: ``` .fullScreenCover(isPresented: $shouldNavigateToChatView) { [chatUser, charForView] in if let user = chatUser { ChatView(oppUser: user) } else if let chat = chatForView { ChatView(chat: chat) } else { ProgressView() } } ``` That said, this is a use case for `fullscreenCover(item:)`, assuming `ChatModel` and `User` are `Identifiable`. This overload presents the full screen cover when `item` is not nil. ``` .fullScreenCover(item: $chatUser) { user in ChatView(oppUser: user) } .fullScreenCover(item: $chatForView) { chat in ChatView(chat: chat) } ``` Now you don't need `shouldNavigateToChatView`. Other notes: `viewModel` should be `@StateObject`: ``` @StateObject private var viewModel = ChatListViewModel() ``` When setting `chatForView` or `chatUser`, remember to set the other one to `nil`, e.g. ``` chatForView = chat chatUser = nil // also do this ``` <hr> If there is a case where `chatForView`/`chatUser` are received later, but you want to show the full screen cover first, it'd better to model the three situations with an enum: ``` enum ChatInfo: Hashable, Identifiable { case chat(ChatModel) case user(User) case loading(SomeInfo) var id: ChatInfo { self } } ... @State chatInfo: ChatInfo? ... .fullScreenCover(item: $chatInfo) { info in // ChatView will decide what to do in each case // e.g. in the case of .loading, display a progress // indicator and use SomeInfo to fetch things. ChatView(info) } ```
why Java BigDecimal giving Precision Errors
|java|bigdecimal|arbitrary-precision|fault-tolerance|
null
{"OriginalQuestionIds":[9003969],"Voters":[{"Id":295783,"DisplayName":"mplungjan","BindingReason":{"GoldTagBadge":"html"}}]}
Error WebMock::NetConnectNotAllowedError in testing with stub using minitest in rails (using Faraday)
|ruby-on-rails|testing|minitest|faraday|webmock|
I am trying to connect below spark connectors from Databricks to Snowflake.On the snowflake side i can access the account using "Login via AzureAD" which is my own azure account credentials. But while trying to provide the same in spark connectors for snowflake is not working. options = { "sfUrl": url, "sfUser": my azure username, "sfPassword": corresponding pwd, "sfDatabase": db, "sfSchema": schema, "sfWarehouse": warehouse, "Role":role } Please note if i have login using service account details created in snowflake side then that is working. Any pointer how to connect to snowflake using own credentials from databricks?
Spark connectors from Azure Databricks to Snowflake using AzureAD login
|azure|apache-spark|snowflake-cloud-data-platform|databricks|
You could rewrite `(?<=^| )` as `(?:\s|^)` and keep that match in the replacement instead of using `\K` which is not supported in JavaScript. You could write the pattern as: ((?:\s|^)([a-z])\2+)(?=\s|$)|([a-z])(?=\3) The pattern matches: - `(` Capture **group 1** - `(?:\s|^)` Match either a whitespace char or assert the start of the string - `([a-z])\2+` Capture a single char a-z in **group 2** and repeat matching that same char 1 or more times - `)` Close group 1 - `(?=\s|$)` Positive lookahead, assert either a whitespace char or the end of the string to the right - `|` Or - `([a-z])(?=\3)` Capture a single char a-z in **group 3** while asserting the same character directly to the right [Regex demo](https://regex101.com/r/YG00j9/1) <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> const regex = /((?:\s|^)([a-z])\2+)(?=\s|$)|([a-z])(?=\3)/g; [ "aaa baaab xxx", "ahhj aaab cc iiik", "#$aa$aa#aaa bbb" ].forEach(s => console.log(s.replace(regex, "$1")) ) <!-- end snippet --> <hr> If you want to match any letter: const regex = /((?: |^)([\p{L}\p{M}])\2+(?= |$))|([\p{L}\p{M}])(?=\3)/gu; See another [regex demo](https://regex101.com/r/LH61YB/1)
In the realm of computer programming and system administration, efficiency and precision are paramount. Command-line interfaces (CLIs) have long been the go-to tool for professionals seeking to interact with computers at a granular level. At the heart of many CLI operations lie command-line arguments, powerful tools that enable users to tailor program behavior, configure settings, and execute complex tasks with ease. In this comprehensive guide, we will delve deep into the world of command-line arguments, exploring their nuances, syntax, and practical applications. https://stackoverflow.comhttps://stackoverflow.com/questions/ask#Types of Command-Line Arguments: Flags or Options: Flags or options modify the behavior of a program by enabling or disabling certain features or settings. They are preceded by a hyphen (-) or double hyphen (–), followed by a keyword or abbreviation representing the option. For example: $ ls -l $ git commit -m “Initial commit” Positional Arguments: Positional arguments are parameters provided to a program based on their position in the command-line invocation. They are not preceded by flags or options and are instead interpreted based on their order. For example:........... [text](https://tazakhabarr.tech/explain-the-command-line-argument/) [text](https://tazakhabarr.tech/explain-the-command-line-argument/)
Fixed it. It works if I create the ```.gitignore``` using Windows Subsystem for Linux (Ubuntu). It does not work if created through Windows 10 VS Code editor. A similar thing is also mentioned in this [solution][1]. It also worked when I created the ```.gitignore``` file using echo in Git Bash which is a Linux environment. Strange indeed! It probably has something to do with the carriage return (CR) and line feed (LF). [1]: https://stackoverflow.com/a/11451916/21205111
I am trying to simulate a web site access via C# code. The flow is 1) HTTP Get the the login Page. This succeeds. 2) HTTP Post to login page. This returns status 302, I disabled auto redirect in HttpClientHandler. Validated the cookie returned, it has the login cookie. 3) HTTP Get the actual content page. Returns success code 200, but the content is always trimmed. This is the same page to which step 2 re-directs. I have tried by even letting the auto-redirect enabled in the HttpClientHandler. Even then the response is trimmed. In postman, when I directly do step 2 allowing re-direct. The content comes properly. This used to work sometime back on the website. It's PHP based website and it's protected by CloudFare. Not sure if the cloudfare is recent thing. I checked the headers sent via the browser for the same and replicated the same in the code but still it doesn't seems to work. [Chrome Browser Request & Response Headers for step 1](https://i.stack.imgur.com/eAA48.png) [Chrome Browser Request & Response Headers for step 2](https://i.stack.imgur.com/g2MTU.png) [Chrome Browser Request & Response Headers for step 3](https://i.stack.imgur.com/FNgbT.png) [From the code I set these headers for step 1](https://i.stack.imgur.com/oM0Fw.png) [From the code I set these headers for step 2](https://i.stack.imgur.com/7Xxr9.png) [From the code I set these headers for step 3](https://i.stack.imgur.com/basAU.png) The response header in code via HttpClient is as below: {StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Transfer-Encoding: chunked Connection: keep-alive pragma: no-cache vary: Accept-Encoding x-turbo-charged-by: LiteSpeed CF-Cache-Status: DYNAMIC Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=2FygAzdvahT%2BLZRFN%2FqyPoa5sEwVhapX0RvMwgRhImHcb7v9D%2BvHZUoaNKdBk71QKedjbv2F1I9w6DouYNuurOSsqldc0Mx12d4b3rcyTfHDxU%3D"}],"group":"cf-nel","max_age":604800} NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800} CF-RAY: 85a11083296bb2af-MAA Cache-Control: no-store, must-revalidate, no-cache Date: Fri, 23 Feb 2024 17:07:20 GMT Server: cloudflare Via: HTTP/1.1 m_proxy_che2 Via: HTTP/1.1 s_proxy_che2 Content-Type: text/html; charset=UTF-8 Expires: Thu, 19 Nov 1981 08:52:00 GMT }} But this response is truncated. I have enabled automatic de-compression of the data. Any idea what might be missing. Interestingly, when posting to login page via Postman without explicitly adding any other header, the login process works and retrieves the re-directed page.
I have two dataframes. df1 col1 var1 var2 var3 X11 NA (for var3) X12 NA (for var2) X13 NA (for var1) df1 has a few columns (float64 type representing some categories) like var1, var2, var3 with values between 1-5 for each and some missing values for the categories. I want to fill in the missing values (in each of var1, var2, and var3 columns) using another dataframe, df2 such that df2 has a column with the value for the category. df2 col1 col2 val col4 X11 var1 3 X11-X21 X12 var3 2 X21-X22 X13 var2 1 X13-X32 col4 is the concatenation of col1 and col2 but it did not help much. How could I do this? Since we need to look up on several columns and also because of the structure of df1, I found it complicated to use pivot or melt or even one-hot encoding (produces 5 columns each with _1 to _5 suffixed. I also though about creating a set but then the pairs must be unique which is not the case. Same when I thought of using dictionary as I cannot think of unique keys. How could I solve this issue? Thanks.
{"Voters":[{"Id":21625319,"DisplayName":"TraderInTheMaking"}],"DeleteType":1}
Is the following of any help? The basic paradigm is to put your read sockets to a list, then do a select and then check which socket has data available and then act on the data. #!/usr/bin/python3 import time import socket import select import threading glob_control_read_socket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) glob_control_read_socket.bind(('localhost', 0)) glob_control_write_socket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) glob_control_write_socket.connect(('localhost', glob_control_read_socket.getsockname()[1])) glob_server_read_socket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) glob_server_read_socket.bind(('localhost', 12000)) print("Server running on port " + str(glob_server_read_socket.getsockname()[1])) def sockets_shutdown(): glob_control_write_socket.close() glob_control_read_socket.close() glob_server_read_socket.close() print("Graceful shutdown") def handle_server_read(): read_str = glob_server_read_socket.recv(100).decode("utf-8") print("Server got: " + read_str.rstrip()) def sockets_thread_main(): read_sockets_list = [glob_control_read_socket, glob_server_read_socket] while True: try: read_sockets,_,_ = select.select(read_sockets_list, [], []) for ready_socket in read_sockets: if ready_socket == glob_control_read_socket: control_bytes = glob_control_read_socket.recv(32) if control_bytes == b"QUIT": sockets_shutdown() return if ready_socket == glob_server_read_socket: handle_server_read() except Exception as e: print(str(e)) sockets_thread = threading.Thread(target = sockets_thread_main, args = ()) try: sockets_thread.start() while True: time.sleep(100000) # Placeholder, do something real here except KeyboardInterrupt: glob_control_write_socket.send(b"QUIT") sockets_thread.join() Tested on recent Windows 10 and ncat (funnily, if I connect with ncat to localhost, it is unable to make the connection and reports "An existing connection was forcibly closed by the remote host." I need to use 127.0.0.1) Test run: [![Test run][1]][1] EDIT: Is socketpair() even available in Windows? [1]: https://i.stack.imgur.com/KTyRT.png
I use expo go and expo 48 on the frontend and firebase admin sdk on the backend. using cloud functions I push notifications like [![expo API sending notifications from the server][1]][1] When I send the body, everything works fine but when I try to send the data object nothing happens. I sometimes don't receive the notification at all or sometimes it comes and the data object is null. I use "expo-notifications": "0.18.1" like this [![expo handling incoming notifications][2]][2] [1]: https://i.stack.imgur.com/ddHV2.png [2]: https://i.stack.imgur.com/GaCRR.png Everything was working before just fine and there was no issue and then all of a sudden I had this issue. I'm having this issue going on for 5 days now. thanks in advance
explian the line command argument
|python|python-3.x|linux|command|command-line-arguments|
null
Rust cannot borrow as mutable
Based on the answer given by phd, I decided to tweak it a bit and write a script that automatically fixes the tab width based on pressing `2<Tab>` for going from 2 to 4 tabs, as well as being able to fix intermingled tab/4-space indentation by pressing `4<Tab`. It makes use of a global variable to prevent the command from running multiple times, but otherwise simply executes the commands given in phd's answer. Pressing a number key and then Tab in normal mode will cause the indentation to be changed from that number to your default tabstop setting. let g:retab_done = 0 function Retab() if !v:count || g:retab_done return endif let g:retab_done = 1 let current_width = &tabstop execute "set noexpandtab tabstop=" . v:count retab! execute "set expandtab tabstop=" . current_width retab return endfunction nmap <Tab> :call Retab()<CR>
Here is a regex that will match any phone number for every country in the world regardless of the number of digits. It matches formatted and unformatted national and international phone numbers. ```js // This will match any phone number in a file const pattern = /(\+)?(\(?\d+\)?)(([\s-]+)?(\d+)){0,}/g // If you want to match phone numbers line by line consider // adding '^' at beginning of regex and '$' at end of it // like below const pattern = /^(\+)?(\(?\d+\)?)(([\s-]+)?(\d+)){0,}$/g ``` If you want to adjust it to match a certain number of digits, you can do that easily. Example of phone numbers that it will match: ## Afghanistan: - Formatted: (020) 1234 5678 - Unformatted: +932012345678 ## Albania: - Formatted: (04) 234 5678 - Unformatted: +35542345678 ## Algeria: - Formatted: (021) 234 5678 - Unformatted: +213212345678 ## Andorra: - Formatted: (07) 123 456 - Unformatted: +3767123456 ## Angola: - Formatted: (222) 123 456 - Unformatted: +244222123456 ## Antigua and Barbuda: - Formatted: (268) 123 4567 - Unformatted: +12681234567 ## Argentina: - Formatted: (011) 1234-5678 - Unformatted: +541112345678 ## Armenia: - Formatted: (010) 123456 - Unformatted: +37410123456 ## Australia: - Formatted: (02) 1234 5678 - Unformatted: +61212345678 ## Austria: - Formatted: (01) 2345678 - Unformatted: +4312345678 ## Azerbaijan: - Formatted: (012) 345 67 89 - Unformatted: +994123456789 ## The Bahamas: - Formatted: (242) 456-7890 - Unformatted: +12424567890 ## Bahrain: - Formatted: (01) 234 567 - Unformatted: +9731234567 ## Bangladesh: - Formatted: (02) 12345678 - Unformatted: +880212345678 ## Barbados: - Formatted: (246) 234-5678 - Unformatted: +12462345678 ## Belarus: - Formatted: (017) 123-45-67 - Unformatted: +375171234567 ## Belgium: - Formatted: (012) 34 56 78 - Unformatted: +3212345678 ## Belize: - Formatted: (501) 234-5678 - Unformatted: +5012345678 ## Benin: - Formatted: (21) 12 34 56 - Unformatted: +22921123456 ## Bhutan: - Formatted: (02) 334 567 - Unformatted: +9752334567 ## Bolivia: - Formatted: (02) 1234567 - Unformatted: +59121234567 ## Bosnia and Herzegovina: - Formatted: (033) 123-456 - Unformatted: +38733123456 ## Botswana: - Formatted: (02) 123 4567 - Unformatted: +26721234567 ## Brazil: - Formatted: (11) 1234-5678 - Unformatted: +551112345678 ## Brunei: - Formatted: (03) 123 4567 - Unformatted: +67331234567 ## Bulgaria: - Formatted: (02) 123 4567 - Unformatted: +35921234567 ## Burkina Faso: - Formatted: (25) 12 34 56 - Unformatted: +22625123456 ## Burundi: - Formatted: (22) 12 34 56 - Unformatted: +25722123456 ## Cabo Verde: - Formatted: (261) 23 45 67 - Unformatted: +238261234567 ## Cambodia: - Formatted: (023) 123 456 - Unformatted: +85523123456 ## Cameroon: - Formatted: (22) 12 34 56 - Unformatted: +23722123456 ## Canada: - Formatted: (416) 555-1234 - Unformatted: +14165551234 ## Central African Republic: - Formatted: (21) 12 34 56 - Unformatted: +23621123456 ## Chad: - Formatted: (225) 12 34 56 - Unformatted: +235225123456 ## Chile: - Formatted: (02) 1234 5678 - Unformatted: +56212345678 ## China: - Formatted: (010) 1234-5678 - Unformatted: +861012345678 ## Colombia: - Formatted: (1) 2345678 - Unformatted: +5712345678 ## Comoros: - Formatted: (269) 23 45 67 - Unformatted: +269269234567 ## Congo, Democratic Republic of the: - Formatted: (12) 34 56789 - Unformatted: +243123456789 ## Congo, Republic of the: - Formatted: (22) 12 34 56 - Unformatted: +24222123456 ## Costa Rica: - Formatted: (02) 1234 5678 - Unformatted: +506212345678 ## Côte d’Ivoire: - Formatted: (20) 12 34 56 - Unformatted: +22520123456 ## Croatia: - Formatted: (01) 234 5678 - Unformatted: +38512345678 ## Cuba: - Formatted: (07) 1234567 - Unformatted: +5371234567 ## Cyprus: - Formatted: (022) 123456 - Unformatted: +35722123456 ## Czech Republic: - Formatted: (02) 1234 5678 - Unformatted: +420212345678 ## Denmark: - Formatted: (32) 12 34 56 - Unformatted: +4532123456 ## Djibouti: - Formatted: (21) 12 34 56 - Unformatted: +25321123456 ## Dominica: - Formatted: (767) 235-6789 - Unformatted: +17672356789 ## Dominican Republic: - Formatted: (809) 234-5678 - Unformatted: +18092345678 ## East Timor (Timor-Leste): - Formatted: (333) 12 345 - Unformatted: +67033312345 ## Ecuador: - Formatted: (02) 123 4567 - Unformatted: +59321234567 ## Egypt: - Formatted: (02) 12345678 - Unformatted: +20212345678 ## El Salvador: - Formatted: (2222) 1234 - Unformatted: +50322221234 ## Equatorial Guinea: - Formatted: (333) 12 34 56 - Unformatted: +240333123456 ## Eritrea: - Formatted: (1) 23 45 67 - Unformatted: +2911234567 ## Estonia: - Formatted: (07) 234 5678 - Unformatted: +37272345678 ## Eswatini: - Formatted: (240) 23456 - Unformatted: +26824023456 ## Ethiopia: - Formatted: (011) 123 4567 - Unformatted: +251111234567 ## Fiji: - Formatted: (331) 2345 - Unformatted: +6793312345 ## Finland: - Formatted: (02) 1234567 - Unformatted: +35821234567 ## France: - Formatted: (01) 23 45 67 89 - Unformatted: +33123456789 ## Gabon: - Formatted: (01) 23 45 67 - Unformatted: +2411234567 ## The Gambia: - Formatted: (20) 1234567 - Unformatted: +220201234567 ## Georgia: - Formatted: (032) 123 456 - Unformatted: +99532123456 ## Germany: - Formatted: (030) 12345678 - Unformatted: +493012345678 ## Ghana: - Formatted: (030) 123 4567 - Unformatted: +233301234567 ## Greece: - Formatted: (210) 1234567 - Unformatted: +302101234567 ## Grenada: - Formatted: (473) 234-5678 - Unformatted: +14732345678 ## Guatemala: - Formatted: (02) 3456 7890 - Unformatted: +502234567890 ## Guinea: - Formatted: (30) 12 34 56 - Unformatted: +22430123456 ## Guinea-Bissau: - Formatted: (245) 23 45 67 - Unformatted: +245245234567 ## Guyana: - Formatted: (592) 234-5678 - Unformatted: +5922345678 ## Haiti: - Formatted: (509) 34 56 78 90 - Unformatted: +50934567890 ## Honduras: - Formatted: (504) 2345-6789 - Unformatted: +50423456789 ## Hungary: - Formatted: (01) 234 5678 - Unformatted: +3612345678 ## Iceland: - Formatted: (415) 123-4567 - Unformatted: +3544151234567 ## India: - Formatted: (080) 12345 678 - Unformatted: +918012345678 ## Indonesia: - Formatted: (021) 1234567 - Unformatted: +62211234567 ## Iran: - Formatted: (021) 2345 6789 - Unformatted: +982123456789 ## Iraq: - Formatted: (01) 234 5678 - Unformatted: +96412345678 ## Ireland: - Formatted: (01) 123 4567 - Unformatted: +35311234567 ## Israel: - Formatted: (02) 123 4567 - Unformatted: +97221234567 ## Italy: - Formatted: (02) 1234 5678 - Unformatted: +390212345678 ## Jamaica: - Formatted: (876) 234-5678 - Unformatted: +18762345678 ## Japan: - Formatted: (03) 1234 5678 - Unformatted: +81312345678 ## Jordan: - Formatted: (06) 123 4567 - Unformatted: +96261234567 ## Kazakhstan: - Formatted: (727) 123 4567 - Unformatted: +77271234567 ## Kenya: - Formatted: (020) 1234567 - Unformatted: +254201234567 ## Kiribati: - Formatted: (751) 23 45 - Unformatted: +6867512345 ## Korea, North: - Formatted: (02) 1234 5678 - Unformatted: +850212345678 ## Korea, South: - Formatted: (02) 1234 5678 - Unformatted: +82212345678 ## Kosovo: - Formatted: (038) 123 456 - Unformatted: +38338123456 ## Kuwait: - Formatted: (02) 123 4567 - Unformatted: +96521234567 ## Kyrgyzstan: - Formatted: (312) 12 34 56 - Unformatted: +996312123456 ## Laos: - Formatted: (021) 234 567 - Unformatted: +85621234567 ## Latvia: - Formatted: (06) 123 4567 - Unformatted: +37161234567 ## Lebanon: - Formatted: (01) 234 567 - Unformatted: +9611234567 ## Lesotho: - Formatted: (22) 123 456 - Unformatted: +26622123456 ## Liberia: - Formatted: (01) 123 456 - Unformatted: +2311123456 ## Libya: - Formatted: (021) 234 5678 - Unformatted: +218212345678 ## Liechtenstein: - Formatted: (234) 567 890 - Unformatted: +423234567890 ## Lithuania: - Formatted: (08) 123 4567 - Unformatted: +37081234567 ## Luxembourg: - Formatted: (02) 123 456 - Unformatted: +3522123456 ## Madagascar: - Formatted: (20) 12 345 67 - Unformatted: +261201234567 ## Malawi: - Formatted: (01) 234 5678 - Unformatted: +26512345678 ## Malaysia: - Formatted: (03) 1234 5678 - Unformatted: +60312345678 ## Maldives: - Formatted: (331) 2345 - Unformatted: +9603312345 ## Mali: - Formatted: (20) 12 34 56 - Unformatted: +22320123456 ## Malta: - Formatted: (21) 234 567 - Unformatted: +35621234567 ## Marshall Islands: - Formatted: (692) 234-5678 - Unformatted: +6922345678 ## Mauritania: - Formatted: (45) 12 34 56 - Unformatted: +22245123456 ## Mauritius: - Formatted: (230) 123 4567 - Unformatted: +2301234567 ## Mexico: - Formatted: (55) 1234 5678 - Unformatted: +525512345678 ## Micronesia, Federated States of: - Formatted: (691) 320 1234 - Unformatted: +6913201234 ## Moldova: - Formatted: (022) 123 456 - Unformatted: +37322123456 ## Monaco: - Formatted: (377) 1234 5678 - Unformatted: +37712345678 ## Mongolia: - Formatted: (11) 123 456 - Unformatted: +97611123456 ## Montenegro: - Formatted: (020) 123 456 - Unformatted: +38220123456 ## Morocco: - Formatted: (052) 123 4567 - Unformatted: +212521234567 ## Mozambique: - Formatted: (21) 123 456 - Unformatted: +25821123456 ## Myanmar (Burma): - Formatted: (01) 234 567 - Unformatted: +9511234567 ## Namibia: - Formatted: (061) 123 4567 - Unformatted: +264611234567 ## Nauru: - Formatted: (674) 444 5678 - Unformatted: +6744445678 ## Nepal: - Formatted: (01) 2345678 - Unformatted: +97712345678 ## Netherlands: - Formatted: (020) 123 4567 - Unformatted: +31201234567 ## New Zealand: - Formatted: (09) 123 4567 - Unformatted: +6491234567 ## Nicaragua: - Formatted: (505) 2345 6789 - Unformatted: +50523456789 ## Niger: - Formatted: (20) 12 34 56 - Unformatted: +22720123456 ## Nigeria: - Formatted: (01) 234 5678 - Unformatted: +23412345678 ## North Macedonia: - Formatted: (02) 123 4567 - Unformatted: +38921234567 ## Norway: - Formatted: (02) 123 456 - Unformatted: +472123456 ## Oman: - Formatted: (02) 1234 5678 - Unformatted: +968212345678 ## Pakistan: - Formatted: (021) 1234567 - Unformatted: +92211234567 ## Palau: - Formatted: (680) 488 1234 - Unformatted: +6804881234 ## Panama: - Formatted: (212) 345-6789 - Unformatted: +5072123456789 ## Papua New Guinea: - Formatted: (675) 123 4567 - Unformatted: +6751234567 ## Paraguay: - Formatted: (021) 1234567 - Unformatted: +59521234567 ## Peru: - Formatted: (01) 1234567 - Unformatted: +5111234567 ## Philippines: - Formatted: (02) 123 4567 - Unformatted: +6321234567 ## Poland: - Formatted: (12) 345 67 89 - Unformatted: +48123456789 ## Portugal: - Formatted: (01) 234 5678 - Unformatted: +35112345678 ## Qatar: - Formatted: (4017) 0123 - Unformatted: +97440170123 ## Romania: - Formatted: (021) 123 4567 - Unformatted: +40211234567 ## Russia: - Formatted: (812) 123-45-67 - Unformatted: +78121234567 ## Rwanda: - Formatted: (250) 123 456 789 - Unformatted: +250123456789 ## Saint Kitts and Nevis: - Formatted: (869) 765-1234 - Unformatted: +18697651234 ## Saint Lucia: - Formatted: (758) 234-5678 - Unformatted: +17582345678 ## Saint Vincent and the Grenadines: - Formatted: (784) 456-7890 - Unformatted: +17844567890 ## Samoa: - Formatted: (685) 23456 - Unformatted: +68523456 ## San Marino: - Formatted: (0549) 123456 - Unformatted: +378549123456 ## Sao Tome and Principe: - Formatted: (981) 23 45 - Unformatted: +2399812345 ## Saudi Arabia: - Formatted: (01) 234 5678 - Unformatted: +96612345678 ## Senegal: - Formatted: (33) 123 45 67 - Unformatted: +221331234567 ## Serbia: - Formatted: (011) 1234567 - Unformatted: +38111234567 ## Seychelles: - Formatted: (248) 2 34 56 - Unformatted: +24823456 ## Sierra Leone: - Formatted: (22) 123456 - Unformatted: +23222123456 ## Singapore: - Formatted: (02) 1234 5678 - Unformatted: +65612345678 ## Slovakia: - Formatted: (02) 1234 5678 - Unformatted: +421212345678 ## Slovenia: - Formatted: (01) 234 56 78 - Unformatted: +38612345678 ## Solomon Islands: - Formatted: (677) 23456 - Unformatted: +67723456 ## Somalia: - Formatted: (061) 1234567 - Unformatted: +252611234567 ## South Africa: - Formatted: (011) 234 5678 - Unformatted: +27112345678 ## Spain: - Formatted: (91) 123 45 67 - Unformatted: +34911234567 ## Sri Lanka: - Formatted: (011) 234 5678 - Unformatted: +94112345678 ## Sudan: - Formatted: (012) 345 6789 - Unformatted: +249123456789 ## Sudan, South: - Formatted: (011) 123 4567 - Unformatted: +21111234567 ## Suriname: - Formatted: (597) 123456 - Unformatted: +597123456 ## Sweden: - Formatted: (08) 123 456 78 - Unformatted: +46812345678 ## Switzerland: - Formatted: (044) 123 45 67 - Unformatted: +41441234567 ## Syria: - Formatted: (011) 1234567 - Unformatted: +96311234567 ## Taiwan: - Formatted: (02) 1234 5678 - Unformatted: +886212345678 ## Tajikistan: - Formatted: (372) 12 34 56 - Unformatted: +992372123456 ## Tanzania: - Formatted: (022) 234 5678 - Unformatted: +255222345678 ## Thailand: - Formatted: (02) 123 4567 - Unformatted: +6621234567 ## Togo: - Formatted: (22) 12 34 56 - Unformatted: +22822123456 ## Tonga: - Formatted: (22) 12345 - Unformatted: +6762212345 ## Trinidad and Tobago: - Formatted: (868) 234-5678 - Unformatted: +18682345678 ## Tunisia: - Formatted: (71) 234 567 - Unformatted: +21671234567 ## Turkey: - Formatted: (0212) 345 67 89 - Unformatted: +902123456789 ## Turkmenistan: - Formatted: (12) 34 56 78 - Unformatted: +99312345678 ## Tuvalu: - Formatted: (688) 23 456 - Unformatted: +68823456 ## Uganda: - Formatted: (041) 1234567 - Unformatted: +256411234567 ## Ukraine: - Formatted: (044) 123 45 67 - Unformatted: +380441234567 ## United Arab Emirates: - Formatted: (02) 123 4567 - Unformatted: +97121234567 ## United Kingdom: - Formatted: (020) 1234 5678 - Unformatted: +442012345678 ## United States: - Formatted: (212) 555-1234 - Unformatted: +12125551234 ## Uruguay: - Formatted: (02) 123 4567 - Unformatted: +59821234567 ## Uzbekistan: - Formatted: (71) 123 45 67 - Unformatted: +998711234567 ## Vanuatu: - Formatted: (555) 2345 - Unformatted: +6785552345 ## Vatican City: - Formatted: (06) 6982 0026 - Unformatted: +390669820026 ## Venezuela: - Formatted: (0212) 123 45 67 - Unformatted: +582121234567 ## Vietnam: - Formatted: (024) 1234 5678 - Unformatted: +842412345678 ## Yemen: - Formatted: (01) 234 567 - Unformatted: +9671234567 ## Zambia: - Formatted: (021) 1234567 - Unformatted: +260211234567 ## Zimbabwe: - Formatted: (024) 12345 - Unformatted: +2632412345
I suspect the reason is that you've defined the 'status' field as text in the index's schema. The text type is used for free-text searches, and as such has the notion of "stop words" - common words that are ignored - and "on" is probably there. You should use a tag field instead.
I was trying to run my assembly language program and it is when i try to enter the 2nd input, the cursor freezes and the DOSbox emulator would crash after a few seconds of delay. I've tried running other assembly language programs and they seem to be working fine. Im not sure of the reason behind this, could it be an error in my code (MASM format) / not enough RAM to run the program? My code is attached below and I had 1.5GB of RAM available while I was running the program. ``` .MODEL SMALL .STACK .DATA msg1 DB "Quantity (unit): $" msg2 DB 13,10,"Unit price (RM): $" msg3 DB 13,10,"Total amount is RM$" Quantity DB 0 Unit_price DB 0 Total DB 0 Q DB 0 R DB 0 .CODE MAIN PROC MOV AX, @DATA MOV DS, AX MOV AH, 09H LEA DX, msg1 INT 21H MOV AH, 01H INT 21H MOV Quantity, AL MOV AH, 09H LEA DX, msg2 INT 21H MOV AH, 01H INT 21H MOV Unit_price, AL MOV AH, 09H LEA AX, msg3 INT 21H XOR AX, AX SUB Quantity, '0' SUB Unit_price, '0' MOV AL, Quantity MUL Unit_price MOV Total, AL XOR AX, AX MOV DX, 10H DIV DX MOV Q, AL MOV R, AH MOV AH, 02H MOV DL, Q INT 21H MOV AH, 02H MOV DL, R INT 21H MOV AH, 4CH INT 21H MAIN ENDP END MAIN ```
DOSbox automatically freezes and crashes without any prompt warnings
|assembly|dosbox|
null
I am trying to do a transparent background for my MatDialog component. Here is the code: *parent.component.html* openDialog(){ const dialogConfig = new MatDialogConfig(); dialogConfig.width = '340px'; dialogConfig.height = '476px'; dialogConfig.autoFocus = false; dialogConfig.panelClass = "dialogClass"; dialogConfig.data = this.item; this.dialog.open(ChildComponent, dialogConfig) } *styles.css (global file, not the parent component one)* .dialogClass{ background-color: pink; //pink to see if it works } *(changes background for this particular dialog)* **OR** mat-dialog-container { background-color: pink; } *(changes background for all dialogs)* This code works (I can see pink for a second every time I open the dialog), but it gets instantly covered with a white layer. All I have in my ChildComponent is displayed *over* this layer: **MatDialog background -> White layer -> ChildComponent** If ChildComponent *.css* and *.html* files are empty, it still appears. Setting a block with transparent background doesn't help either. How do I delete this white layer from a dialog?
First make sure you are using the latest version of UMP SDK inside your dependencies and don't rely on the version embedded with `play-services-ads`, that version could be outdated. ```gradle dependencies { implementation("com.google.android.gms:play-services-ads:22.6.0") implementation("com.google.android.ump:user-messaging-platform:2.2.0") } ``` Second, in my case Android [DataStore][1] was causing preferences reset. The same preferences file is used to store consent from UMP SDK, coincidently they had the same name. It seems that DataStore tries to migrate all preferences when it finds the preferences file, and then deletes it, which causes UMP SDK to lose stored consent info. ```kotlin companion object { private const val PREFS_FILE_NAME = "user_prefs" private val Context.dataStore by preferencesDataStore( name = PREFS_FILE_NAME, produceMigrations = { listOf(SharedPreferencesMigration(it, it.packageName + "_preferences")) }) } ``` UMP SDK uses `my.package.name_preferences.xml` file by default (can't change it) to store consent info. My old preferences also were stored in the same file, and when I switched to DataStore I had to make a migration from that file. To resolve the issue, I simply removed the migration since it is not that important for me. [1]: https://developer.android.com/topic/libraries/architecture/datastore
I could do it with possible hack, i don't know its right solution but it works. I took 4 different radio buttons and HBox widgets.HBox([radio1,radio2,radio3,radio4]) Then after selecting one radio button i m de-selecting the other radio button which is selected. Here how i done : import ipywidgets as widgets output_radio_selected = widgets.Text() radio1 = widgets.RadioButtons(options=['Option 1']) radio2 = widgets.RadioButtons(options=['Option 2']) radio3 = widgets.RadioButtons(options=['Option 3']) radio4 = widgets.RadioButtons(options=['Option 4']) radio1.index = None radio2.index = None radio3.index = None radio4.index = None def radio1_observer(sender): #print(sender) radio2.unobserve(radio2_observer, names=['value']) radio2.index = None radio3.unobserve(radio3_observer, names=['value']) radio3.index = None radio4.unobserve(radio4_observer, names=['value']) radio4.index = None global selected_option output_radio_selected.value = radio1.value selected_option = output_radio_selected.value print('Selected option set to: ' + selected_option) radio2.observe(radio2_observer, names=['value']) radio3.observe(radio3_observer, names=['value']) radio4.observe(radio4_observer, names=['value']) def radio2_observer(sender): radio1.unobserve(radio1_observer, names=['value']) radio1.index = None radio3.unobserve(radio3_observer, names=['value']) radio3.index = None radio4.unobserve(radio4_observer, names=['value']) radio4.index = None global selected_option2 output_radio_selected.value = radio2.value selected_option2 = output_radio_selected.value print('Selected option set to: ' + selected_option2) radio1.observe(radio1_observer, names=['value']) radio3.observe(radio3_observer, names=['value']) radio4.observe(radio4_observer, names=['value']) def radio3_observer(sender): radio1.unobserve(radio1_observer, names=['value']) radio1.index = None radio2.unobserve(radio2_observer, names=['value']) radio2.index = None radio4.unobserve(radio4_observer, names=['value']) radio4.index = None global selected_option3 output_radio_selected.value = radio3.value selected_option3 = output_radio_selected.value print('Selected option set to: ' + selected_option3) radio1.observe(radio1_observer, names=['value']) radio2.observe(radio2_observer, names=['value']) radio4.observe(radio4_observer, names=['value']) def radio4_observer(sender): radio1.unobserve(radio1_observer, names=['value']) radio1.index = None radio2.unobserve(radio2_observer, names=['value']) radio2.index = None radio3.unobserve(radio3_observer, names=['value']) radio3.index = None global selected_option4 output_radio_selected.value = radio4.value selected_option4 = output_radio_selected.value print('Selected option set to: ' + selected_option4) radio1.observe(radio1_observer, names=['value']) radio2.observe(radio2_observer, names=['value']) radio3.observe(radio3_observer, names=['value']) radio1.observe(radio1_observer, names=['value']) radio2.observe(radio2_observer, names=['value']) radio3.observe(radio3_observer, names=['value']) radio4.observe(radio4_observer, names=['value']) widgets.HBox([radio1,radio2,radio3,radio4])
"https://exp.host/--/api/v2/push/send" api doesn't work when sending the data object
|react-native|expo|expo-notifications|
According to the [docs][1], to be on the safe side you should append the absolute path of the image or directory you want to serve. app.use('/uploads', express.static(__dirname + '/uploads')) [1]: https://expressjs.com/en/starter/static-files.html#:~:text=const%20path%20%3D%20require(%27path%27)%0Aapp.use(%27/static%27%2C%20express.static(path.join(__dirname%2C%20%27public%27)))
# bollingers bands always give the same value and give the same value in each symbol there is no error in the code sequence but there is a logical error can you help \` #property copyright "Copyright 2024, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { double bb_degeri = iBands(NULL,PERIOD_CURRENT,21,0,2,PRICE_CLOSE); Alert(""); Alert(bb_degeri); \` # it needs to give a different value for each symbol and the forex bot I will write will open and close trades according to these values
mql4 bollingers bands always give the same value
|mql4|mql5|mql|
null
I am trying to make a CountDownTimer for my Android app, but every time I try to start it using just `timer.start()`, it starts multiple timers. I don't know why. My code for this is: ``` fun DissapearSkip(){ skipTimeButton.visibility = View.VISIBLE exoSkip.visibility = View.GONE skipTimeText.text = new.skipType.getType() skipTimeButton.setOnClickListener { exoPlayer.seekTo((new.interval.endTime * 1000).toLong()) } val timer = object: CountDownTimer(5000, 1000) { override fun onTick(millisUntilFinished: Long) { println(millisUntilFinished) if (new == null) { skipTimeButton.visibility = View.GONE exoSkip.visibility = View.VISIBLE dissappeared = false return } } override fun onFinish() { val skip = currentTimeStamp skipTimeButton.visibility = View.GONE exoSkip.visibility = View.VISIBLE dissappeared = true } } timer.start() } ``` also the new variable is for getting the timestamp type and info
I'm new at ReactJs and trying to learn ContextAPI but I'm having this error. I read titles about this situation but I can't reach to solution. Firstly I tried to re-install react as a old version but it didn't changed. I tried to wrap App inside of app.js instead of index.js but I had same result as it happens right now. >*App.js* import React, { Component } from 'react' import './App.css'; import UserFinding from './components/UserFinding'; class App extends Component { render() { return ( <div> <UserFinding/> </div> ) } } export default App; >*UserFinding.js* import React, { Component } from 'react' import User from './User.js' import UserConsumer from '../context.js' export default class UserFinding extends Component { render(){ return( <UserConsumer> {value=>{ const users=value; return( <div> { users.map(user=>{ return( <User key={user.id} id={user.id} userName= {user.userName} department={user.department}/> ) } ) } </div> ) }} </UserConsumer> ) } } >*User.js* import React, { Component } from 'react' export default class User extends Component { state={ isVisible:true } hideShowCard=()=>{ this.setState({ isVisible:!this.state.isVisible }) } deleteOnUser=()=>{ //Dispatch } render() { return ( <div> <div className="row"> <div className="col-sm-6"> <div className="card"> <div className="card-body"> <h5 className="card-title">{this.props.userName}<i onClick= {this.deleteOnUser} className="fa fa-trash ml-2"></i></h5> {this.state.isVisible ? <p className="card-text"> {this.props.department}</p>:null} <div onClick={this.hideShowCard} className="btn btn-primary"> {this.state.isVisible ? "Hide" : "Show"}</div> </div> </div> </div> </div> </div> ) } } >*context.js* import React,{Component} from 'react'; const UserContext=React.createContext(); export class UserProvider extends Component { state={ users:[ { id:1, userName:"Ufuk Oral", department:"Software Engineering" }, { id:2, userName:"Emre Çorbacı", department:"Data Science" } ] } render(){ return ( <UserContext.Provider value={this.state}> {this.props.children} </UserContext.Provider> ) } } const UserConsumer=UserContext.Consumer; export default UserConsumer; >*index.js* import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; import * as serviceWorker from './serviceWorker'; import UserProvider from './context.js'; ReactDOM.render( <UserProvider><App/></UserProvider>,document.getElementById('root')); serviceWorker.unregister(); These is my code.
|javascript|reactjs|jsx|react-dom|
I'm currently developing my first project, a simple paint application using Java Swing and AWT. While implementing the painting functionality, I encountered an issue with accurately capturing mouse movements, especially when moving the mouse quickly. I've designed the application to update the drawing coordinates in response to mouse events (mouseDragged and mouseMoved methods in the PaintPanel class), triggering repaints to render the drawings. However, despite my efforts, I've noticed that fast mouse movements sometimes result in skipped points, leading to gaps in the drawn lines. Here's my PaintPanel class, which manages the painting functionality: ``` public class PaintPanel extends JPanel implements MouseMotionListener{ public Point mouseCoordinates; boolean painting = false; public PaintPanel() { this.setPreferredSize(new Dimension(1000,550)); this.setBackground(Color.white); this.addMouseMotionListener(this); } public void paintComponent(Graphics g) { Graphics2D g2D = (Graphics2D) g; g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); if(painting == false) { super.paintComponent(g2D); } if(mouseCoordinates != null) { g2D.setColor(UtilePanel.col); g2D.fillOval((int)mouseCoordinates.getX(),(int)mouseCoordinates.getY(),UtilePanel.brushSize, UtilePanel.brushSize); this.setCursor( this.getToolkit().createCustomCursor( new BufferedImage( 1, 1, BufferedImage.TYPE_INT_ARGB ), new Point(), null ) ); } } @Override public void mouseDragged(MouseEvent e) { mouseCoordinates = e.getPoint(); painting = true; repaint(); } @Override public void mouseMoved(MouseEvent e) { mouseCoordinates = e.getPoint(); repaint(); } } ``` Here's the UtilePanel class if it help : ``` public class UtilePanel extends JPanel { static Color col=Color.black; static int brushSize = 5; public UtilePanel(){ this.setPreferredSize(new Dimension (1000,150)); JPanel container = new JPanel(); container.setLayout(new GridLayout(1,0)); this.setLayout(new GridLayout(0,1)); Brushes brushes = new Brushes(); Shapes shapes = new Shapes(); LoadImage loadImage = new LoadImage(); container.add(brushes); container.add(shapes); container.add(loadImage); this.add(new JPanel()); this.add(container); this.add(new JPanel()); setBorder(BorderFactory.createEtchedBorder(0)); } public class Brushes extends JPanel{ JRadioButton Size1; JRadioButton Size2; JRadioButton Size3; JRadioButton Size4; ButtonGroup group; JButton color; public Brushes() { Size1 = new JRadioButton(); Size2 = new JRadioButton(); Size3 = new JRadioButton(); Size4 = new JRadioButton(); group = new ButtonGroup(); color = new JButton(); color.setBackground(col); color.setBorder(BorderFactory.createEtchedBorder(0)); color.setPreferredSize(new Dimension(20,20)); Size1.setSelected(true); JColorChooser colorchooser= new JColorChooser(); color.addActionListener(e->{ col = JColorChooser.showDialog(null, "Pick a color ",Color.black); color.setBackground(col); }); Size1.addActionListener(e->{ brushSize = 5; }); Size2.addActionListener(e->{ brushSize = 10; }); Size3.addActionListener(e->{ brushSize = 15; }); Size4.addActionListener(e->{ brushSize = 20; }); group.add(Size1); group.add(Size2); group.add(Size3); group.add(Size4); this.add(Size1); this.add(Size2); this.add(Size3); this.add(Size4); this.add(color); this.setLayout(new FlowLayout()); } } public class Shapes extends JPanel{ public Shapes() { ShapeButton circule = new ShapeButton ("circule"); ShapeButton rect = new ShapeButton ("Rectangle"); ShapeButton triangle = new ShapeButton ("Tri"); ShapeButton line = new ShapeButton ("Line"); this.setLayout(new FlowLayout()); ButtonGroup bg = new ButtonGroup(); bg.add(rect); bg.add(triangle); bg.add(circule); bg.add(line); this.add(circule); this.add(rect); this.add(triangle); this.add(line); } class ShapeButton extends JRadioButton { public ShapeButton(String s) { setIcon((new ImageIcon(creatImage(new Color(0x00FFFFFF, true),s)))); setSelectedIcon(new ImageIcon(creatImage(Color.gray,s))); } } public BufferedImage creatImage(Color color,String shape) { BufferedImage bi = new BufferedImage(40,40, BufferedImage.TYPE_INT_ARGB); Graphics2D g = (Graphics2D) bi.getGraphics(); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setStroke(new BasicStroke(5)); g.setColor(color); g.fillRect(0,0,40,40); g.setColor(Color.black); switch(shape) { case "circule": g.drawOval(5, 5, 30,30); break; case "Rectangle": g.drawRect(5,5,30,30); break; case "Tri": int[] X= {5,16,30}; int[] Y= {30,5,30}; g.drawPolygon(X,Y,3); break; case "Line": g.drawLine(5,30,30,5); break; } //g.dispose(); return bi; } } public class LoadImage extends JPanel{ public LoadImage() { JButton loadButton = new JButton("Import Image"); loadButton.setPreferredSize(new Dimension(100,50)); JFileChooser f = new JFileChooser(); loadButton.addActionListener(e->{ int resp = f.showOpenDialog(null); if(resp == JFileChooser.APPROVE_OPTION) { File file = new File(f.getSelectedFile().getAbsolutePath()); System.out.println(file.getAbsolutePath()); } }); this.add(loadButton); } } } ``` Additionally, I attempted to incorporate a game loop to continuously poll for mouse input, hoping it would improve the accuracy of mouse movement capturing. However, even with the game loop in place, the problem persists. I'm unsure if my approach to painting by omitting super.paintComponent(g) in paintComponent is the correct way or there's a better way to do it. Could someone provide insights or suggestions on how to improve the mouse event capturing to guarantee precise rendering, especially during rapid mouse movements? Your assistance would be greatly appreciated. Thank you! [1]: https://i.stack.imgur.com/3A1M7.png
I am trying to simulate a web site access via C# code. The flow is 1) HTTP Get the the login Page. This succeeds. 2) HTTP Post to login page. This returns status 302, I disabled auto redirect in HttpClientHandler. Validated the cookie returned, it has the login cookie. 3) HTTP Get the actual content page. Returns success code 200, but the content is always trimmed. This is the same page to which step 2 re-directs. I have tried by even letting the auto-redirect enabled in the HttpClientHandler. Even then the response is trimmed. In postman, when I directly do step 2 allowing re-direct. The content comes properly. This used to work sometime back on the website. It's PHP based website and it's protected by CloudFare. Not sure if the cloudfare is recent thing. I checked the headers sent via the browser for the same and replicated the same in the code but still it doesn't seems to work. [Chrome Browser Request & Response Headers for step 1](https://i.stack.imgur.com/eAA48.png) [Chrome Browser Request & Response Headers for step 2](https://i.stack.imgur.com/g2MTU.png) [Chrome Browser Request & Response Headers for step 3](https://i.stack.imgur.com/FNgbT.png) [From the code I set these headers for step 1](https://i.stack.imgur.com/oM0Fw.png) [From the code I set these headers for step 2](https://i.stack.imgur.com/7Xxr9.png) [From the code I set these headers for step 3] Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7 Accept-Language: en-IN,en-US;q=0.9,en-GB;q=0.8,en;q=0.7 Cache-Control: max-age=0 Connection: keep-alive Host: abc.MaskingItForStackOverflow.com Referer: https://abc.MaskingItForStackOverflow.com/auth-login.php Sec-Fetch-Dest: document Sec-Fetch-Mode: navigate Sec-Fetch-Site: same-origin Sec-Fetch-User: ?1 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 sec-ch-ua: "Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121" sec-ch-ua-mobile: ?0 sec-ch-ua-platform: "Windows" The response header in code via HttpClient is as below: {StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Transfer-Encoding: chunked Connection: keep-alive pragma: no-cache vary: Accept-Encoding x-turbo-charged-by: LiteSpeed CF-Cache-Status: DYNAMIC Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=2FygAzdvahT%2BLZRFN%2FqyPoa5sEwVhapX0RvMwgRhImHcb7v9D%2BvHZUoaNKdBk71QKedjbv2F1I9w6DouYNuurOSsqldc0Mx12d4b3rcyTfHDxU%3D"}],"group":"cf-nel","max_age":604800} NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800} CF-RAY: 85a11083296bb2af-MAA Cache-Control: no-store, must-revalidate, no-cache Date: Fri, 23 Feb 2024 17:07:20 GMT Server: cloudflare Via: HTTP/1.1 m_proxy_che2 Via: HTTP/1.1 s_proxy_che2 Content-Type: text/html; charset=UTF-8 Expires: Thu, 19 Nov 1981 08:52:00 GMT }} But this response is truncated. I have enabled automatic de-compression of the data. Any idea what might be missing. Interestingly, when posting to login page via Postman without explicitly adding any other header, the login process works and retrieves the re-directed page.
I followed Herb Sutter's [NVI idiom][1] on my class design because of its benefits. My abstract class is as follows in short. class Communicator { public: bool Connect(void) { // some preoperations return DoConnect(); } // 3 more similar public member functions private: virtual bool DoConnect(void) = 0 // 3 more similar pure virtual member functions } I inject Communicator class to the class I want to test as follows (I found this method from [Google docs][2]) : template <typename CommunicatorClass> // There will be some constraints class TestingClass { public: TestingClass(std::unique_ptr<CommunicatorClass> comm) : comm_{std::move(comm)} { } private: std::unique_ptr<CommunicatorClass> comm_ = nullptr; } My Mock class : class MockCommunicator : public Communicator { public: MOCK_METHOD(bool, Connect, ()); // 3 more mocks } My Test suite Setup: // some code .. auto mock = std::make_unique<MockCommunicator>(); TestingClass<MockCommunicator>(std::move(mock)); As you can guess since I did not override 4 private virtual functions MockCommunicator becomes abstract and the compiler gives error. Options I thought : 1) Overriding virtual functions in MockCommunicator. (It seems ugly, but I am closest to this approach) 2) I could convert pure virtual functions to virtual functions but I am not the only one who owns the code base. I want to force other developers to implement their own implementation. 3) Making MockCommunicator the friend of Communicator class and mock private virtual functions. ( I think this is absolutely wrong. Is it?) 4) Giving up on NVI because of its complexity to the code base Is there any recommended way of handling this situation? Note : I use C++20 [1]: http://www.gotw.ca/publications/mill18.htm [2]: https://google.github.io/googletest/gmock_cook_book.html#MockingNonVirtualMethods
Mocking problem on Non-Virtual functions with NVI Idiom
|c++|c++20|googletest|googlemock|non-virtual-interface|
You can send the token as part of the request body, headers, or query parameters using an HTTPS request. const express = require('express'); const jwt = require('jsonwebtoken'); const app = express(); const jwtSecret = process.env.JWT_SECRET; app.post('/fetchElement', (req, res) => { const token = req.body.token; // Assuming token is sent in the request body jwt.verify(token, jwtSecret, (err, decoded) => { if (err) { return res.status(401).json({ message: 'Unauthorized' }); } const userId = decoded.user_id; // Extract user_id from decoded token // Fetch the corresponding element using the user_id // Example: Element.findOne({ userId: userId }, (err, element) => { ... }); // Respond with the fetched element res.json({ element: fetchedElement }); }); }); app.listen(3000, () => console.log('Express server running')); Ensure that both Laravel and Express.js applications have the same JWT secret to encode and decode tokens correctly.
I have been accustomed for years to using the shortcut `Ctrl + Shift + F` to find similar words in Android Studio. The results have always brought me all the similar words, but suddenly, there are similar texts that are not included in the search. Why is this happening? [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/tSuo2.png
If the linked server is not available for editing, you can always use cast(RogueCol as text) in OPENQUERY SELECT RogueCol FROM OPENQUERY([LinkServer], ' SELECT cast (RogueCol as text) as RogueCol FROM public.MyTbl ')
I am discovering the concept of source generators. In order to execute some logic with a source generator on some files (image files more precisely) based on the folders structure of the targeted/referencing project, I need to: - Get the path/Directory of the targeted/referencing project. ### First approach ``` namespace SourceGen { [Generator] public class Class1 : IIncrementalGenerator { public void Initialize(IncrementalGeneratorInitializationContext context) { var projDirectory = context.AnalyzerConfigOptionsProvider .Select((x, _) => x.GlobalOptions .TryGetValue("build_property.MSBuildProjectDirectory", out var projectDirectory) ? projectDirectory : null); File.AppendAllText("\\" + "log.txt", projDirectory ); } } } ``` I am logging to a file for debugging purposes (to check the property value I am reading in this case) since I can't find another way to debug this kind of project. In the log file I get, since `IncrementalValueProvider<string>.ToString()` returns the type and not whatever value is there: > Microsoft.CodeAnalysis.IncrementalValueProvider`1[System.string]. ### Second approach following https://stackoverflow.com/a/66548212 : ``` var mainSyntaxTree = context.CompilationProvider.Select((x, _) => x.SyntaxTrees.First(x => x.HasCompilationUnitRoot)); var directory = Path.GetDirectoryName(mainSyntaxTree.Select((x, _) => x.FilePath); ``` The same issue `Path.GetDirectoryName()` is complaining that the provided parameter is of type `IncrementalValueProvider<string>` while expecting a `string`. Not sure how can I get a useful string value (`FilePath`) out of the type `IncrementalValueProvider<string>`. ### Third approach This time the log file was not written/created at all: ``` var provider = context.AnalyzerConfigOptionsProvider.Select((x, _) => { x.GlobalOptions.TryGetValue("build_property.MSBuildProjectDirectory", out var projectDirectory); File.AppendAllText("\\" + "log.txt", "testing" + projectDirectory); return projectDirectory; }); ``` Docs: https://github.com/dotnet/roslyn/blob/main/docs/features/incremental-generators.cookbook.md
Source generators get the referencing project path - retrieve useful value from IncrementalValueProvider<string>
|c#|msbuild|roslyn|sourcegenerators|csharp-source-generator|
i am using following endpoint to get response from API using paid version: https://api.aviationstack.com/v1/flights?access_key=fi324rkjn32e2e44%20flight_status=active also tried this: https://api.aviationstack.com/v1/flights?access_key=fi324rkjn32e2e44 but I am getting null in "live" and "aircraft": ``` { "pagination": { "limit": 100, "offset": 0, "count": 100, "total": 454057 }, "data": [ { "flight_date": "2024-03-30", "flight_status": "active", "departure": { "airport": "King Khaled International", "timezone": "Asia/Riyadh", "iata": "RUH", "icao": "OERK", "terminal": "T4", "gate": null, "delay": 11, "scheduled": "2024-03-30T09:55:00+00:00", "estimated": "2024-03-30T09:55:00+00:00", "actual": "2024-03-30T10:05:00+00:00", "estimated_runway": "2024-03-30T10:05:00+00:00", "actual_runway": "2024-03-30T10:05:00+00:00" }, "arrival": { "airport": "Istanbul Airport", "timezone": "Europe/Istanbul", "iata": "IST", "icao": "LTFM", "terminal": "1", "gate": null, "baggage": "25", "delay": null, "scheduled": "2024-03-30T14:50:00+00:00", "estimated": "2024-03-30T14:50:00+00:00", "actual": null, "estimated_runway": null, "actual_runway": null }, "airline": { "name": "Aeroflot", "iata": "SU", "icao": "AFL" }, "flight": { "number": "4115", "iata": "SU4115", "icao": "AFL4115", "codeshared": { "airline_name": "saudia", "airline_iata": "sv", "airline_icao": "sva", "flight_number": "263", "flight_iata": "sv263", "flight_icao": "sva263" } }, "aircraft": null, "live": null } ``` I tried to fetch api and get its live data, but not getting it. I am expecting to get lat long in live section as they told in their documentation
Not getting Live data from Aviationstack api
|api|null|fetch|response|live|
null
In addition to adding code, you can also add a module, user form, or class module. I think the reason for that is that VBA needs one of those four things to determine that a file is a macro-enabled workbook. My guess is that this was done to distinguish between files that contain macros (and therefore have to be enabled) and files that *can* contain macros but do not (e.g. xlsm, xlsb, etc. file with no macros.) As would be expected, if you later remove the code or modules / userform later and there are no more in the file, Excel will remove your custom name. And the custom name reverts back to VBAProject
[Screenshot][1] app theme: Theme.Material3.DayNight.NoActionBar this id manifest: <activity android:name=".ui.activities.BaseActivity" android:exported="false" android:label="@string/title_activity_base" android:theme="@style/AppTheme" /> <activity android:name=".ui.activities.MainActivity" android:exported="true" android:screenOrientation="portrait" android:theme="@style/AppTheme"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> [1]: https://drive.google.com/file/d/1K5-7GF4vTdt9-gQbTmqVJgSnNlUZJHSh/view?usp=sharing
In EF terms it seems like it could just be: var d = db.Users .OrderByDescending(u => u.Xp) .AsEnumerable() .Select((u, i) => new { Rank=i+1, User = u }) .ToDictionary(at => at.Rank, at=>at.User); You list all your users out of the DB in order of XP, and you use the overload of `Select((user,index)=>...)` to assign the rank (the index + 1) and for convenience let's put them in a dictionary indexed by rank Now you have a dictionary where, for any given user you can get the surrounding users by the rank of the user you already know: var user = d.Values.FirstOrDefault(u => u.Name == "user6"); var prev = d[user.Rank - 1]; var next = d[user.Rank + 1]; Just need some code to prevent a crash if you find the top or bottom ranked user (look at TryGetValue)
I am trying to do pip install the OpenAI library and I get this error. I tried Windows shell in Visual Studio Code and I have Visual&nbsp;Studio C++ installed. I uninstalled and reinstalled Python three separate times. The Windows console output is below. I have made sure I installed Visual&nbsp;Studio C++. My old computer never did this, so I don't have any idea on how to fix this. I am using Python 3.12. ``` cd C:\Users\yeet pip install openai ``` Output: ``` Defaulting to user installation because normal site-packages is not writeable Collecting openai Using cached openai-0.28.1-py3-none-any.whl.metadata (11 kB) Collecting requests>=2.20 (from openai) Using cached requests-2.31.0-py3-none-any.whl.metadata (4.6 kB) Collecting tqdm (from openai) Using cached tqdm-4.66.1-py3-none-any.whl.metadata (57 kB) Collecting aiohttp (from openai) Using cached aiohttp-3.8.6.tar.gz (7.4 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... done Collecting charset-normalizer<4,>=2 (from requests>=2.20->openai) Using cached charset_normalizer-3.3.1-cp312-cp312-win_amd64.whl.metadata (33 kB) Collecting idna<4,>=2.5 (from requests>=2.20->openai) Using cached idna-3.4-py3-none-any.whl (61 kB) Collecting urllib3<3,>=1.21.1 (from requests>=2.20->openai) Using cached urllib3-2.0.7-py3-none-any.whl.metadata (6.6 kB) Collecting certifi>=2017.4.17 (from requests>=2.20->openai) Using cached certifi-2023.7.22-py3-none-any.whl.metadata (2.2 kB) Collecting attrs>=17.3.0 (from aiohttp->openai) Using cached attrs-23.1.0-py3-none-any.whl (61 kB) Collecting multidict<7.0,>=4.5 (from aiohttp->openai) Using cached multidict-6.0.4-cp312-cp312-win_amd64.whl Collecting async-timeout<5.0,>=4.0.0a3 (from aiohttp->openai) Using cached async_timeout-4.0.3-py3-none-any.whl.metadata (4.2 kB) Collecting yarl<2.0,>=1.0 (from aiohttp->openai) Using cached yarl-1.9.2-cp312-cp312-win_amd64.whl Collecting frozenlist>=1.1.1 (from aiohttp->openai) Using cached frozenlist-1.4.0-cp312-cp312-win_amd64.whl Collecting aiosignal>=1.1.2 (from aiohttp->openai) Using cached aiosignal-1.3.1-py3-none-any.whl (7.6 kB) Collecting colorama (from tqdm->openai) Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB) Using cached openai-0.28.1-py3-none-any.whl (76 kB) Using cached requests-2.31.0-py3-none-any.whl (62 kB) Using cached tqdm-4.66.1-py3-none-any.whl (78 kB) Using cached async_timeout-4.0.3-py3-none-any.whl (5.7 kB) Using cached certifi-2023.7.22-py3-none-any.whl (158 kB) Using cached charset_normalizer-3.3.1-cp312-cp312-win_amd64.whl (98 kB) Using cached urllib3-2.0.7-py3-none-any.whl (124 kB) Building wheels for collected packages: aiohttp Building wheel for aiohttp (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for aiohttp (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [110 lines of output] ********************* * Accelerated build * ********************* running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-cpython-312 creating build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\abc.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\base_protocol.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\client.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\client_exceptions.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\client_proto.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\client_reqrep.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\client_ws.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\connector.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\cookiejar.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\formdata.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\hdrs.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\helpers.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\http.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\http_exceptions.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\http_parser.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\http_websocket.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\http_writer.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\locks.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\log.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\multipart.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\payload.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\payload_streamer.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\pytest_plugin.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\resolver.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\streams.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\tcp_helpers.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\test_utils.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\tracing.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\typedefs.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\web.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\web_app.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\web_exceptions.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\web_fileresponse.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\web_log.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\web_middlewares.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\web_protocol.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\web_request.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\web_response.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\web_routedef.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\web_runner.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\web_server.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\web_urldispatcher.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\web_ws.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\worker.py -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\__init__.py -> build\lib.win-amd64-cpython-312\aiohttp running egg_info writing aiohttp.egg-info\PKG-INFO writing dependency_links to aiohttp.egg-info\dependency_links.txt writing requirements to aiohttp.egg-info\requires.txt writing top-level names to aiohttp.egg-info\top_level.txt reading manifest file 'aiohttp.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'aiohttp' anywhere in distribution warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no previously-included files matching '*.pyd' found anywhere in distribution warning: no previously-included files matching '*.so' found anywhere in distribution warning: no previously-included files matching '*.lib' found anywhere in distribution warning: no previously-included files matching '*.dll' found anywhere in distribution warning: no previously-included files matching '*.a' found anywhere in distribution warning: no previously-included files matching '*.obj' found anywhere in distribution warning: no previously-included files found matching 'aiohttp\*.html' no previously-included directories found matching 'docs\_build' adding license file 'LICENSE.txt' writing manifest file 'aiohttp.egg-info\SOURCES.txt' copying aiohttp\_cparser.pxd -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\_find_header.pxd -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\_headers.pxi -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\_helpers.pyi -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\_helpers.pyx -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\_http_parser.pyx -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\_http_writer.pyx -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\_websocket.pyx -> build\lib.win-amd64-cpython-312\aiohttp copying aiohttp\py.typed -> build\lib.win-amd64-cpython-312\aiohttp creating build\lib.win-amd64-cpython-312\aiohttp\.hash copying aiohttp\.hash\_cparser.pxd.hash -> build\lib.win-amd64-cpython-312\aiohttp\.hash copying aiohttp\.hash\_find_header.pxd.hash -> build\lib.win-amd64-cpython-312\aiohttp\.hash copying aiohttp\.hash\_helpers.pyi.hash -> build\lib.win-amd64-cpython-312\aiohttp\.hash copying aiohttp\.hash\_helpers.pyx.hash -> build\lib.win-amd64-cpython-312\aiohttp\.hash copying aiohttp\.hash\_http_parser.pyx.hash -> build\lib.win-amd64-cpython-312\aiohttp\.hash copying aiohttp\.hash\_http_writer.pyx.hash -> build\lib.win-amd64-cpython-312\aiohttp\.hash copying aiohttp\.hash\_websocket.pyx.hash -> build\lib.win-amd64-cpython-312\aiohttp\.hash copying aiohttp\.hash\hdrs.py.hash -> build\lib.win-amd64-cpython-312\aiohttp\.hash running build_ext building 'aiohttp._websocket' extension creating build\temp.win-amd64-cpython-312 creating build\temp.win-amd64-cpython-312\Release creating build\temp.win-amd64-cpython-312\Release\aiohttp "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD "-IC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.240.0_x64__qbz5n2kfra8p0\include" "-IC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.240.0_x64__qbz5n2kfra8p0\Include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" /Tcaiohttp/_websocket.c /Fobuild\temp.win-amd64-cpython-312\Release\aiohttp/_websocket.obj _websocket.c aiohttp/_websocket.c(1475): warning C4996: 'Py_OptimizeFlag': deprecated in 3.12 aiohttp/_websocket.c(3042): error C2039: 'ob_digit': is not a member of '_longobject' C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.240.0_x64__qbz5n2kfra8p0\include\cpython/longintrepr.h(87): note: see declaration of '_longobject' aiohttp/_websocket.c(3097): error C2039: 'ob_digit': is not a member of '_longobject' C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.240.0_x64__qbz5n2kfra8p0\include\cpython/longintrepr.h(87): note: see declaration of '_longobject' aiohttp/_websocket.c(3238): error C2039: 'ob_digit': is not a member of '_longobject' C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.240.0_x64__qbz5n2kfra8p0\include\cpython/longintrepr.h(87): note: see declaration of '_longobject' aiohttp/_websocket.c(3293): error C2039: 'ob_digit': is not a member of '_longobject' C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.240.0_x64__qbz5n2kfra8p0\include\cpython/longintrepr.h(87): note: see declaration of '_longobject' aiohttp/_websocket.c(3744): error C2039: 'ob_digit': is not a member of '_longobject' C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.240.0_x64__qbz5n2kfra8p0\include\cpython/longintrepr.h(87): note: see declaration of '_longobject' error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for aiohttp Failed to build aiohttp ERROR: Could not build wheels for aiohttp, which is required to install pyproject.toml-based projects ```
I think this is what `Array.flat` does, but I like to use the spread `...` operator to spread arrays so then I can join them again. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> var arr1 = [{ "a": "1" }] var arr2 = [{ "b": "2" }] var combined = [...arr1, ...arr2] console.log(combined) <!-- end snippet -->
I am kind of confused on how to find the number of cycles. Although it appears to be pretty simple. Is it supposed to be number of cycles = (Clock Rate) * (CPI) * (Time) or number of cycles = (Clock Rate) * (Time) [image shows required information ](https://i.stack.imgur.com/vsBTk.png) This is the question: **If the processors each execute a program in 100 seconds, find the number of cycles and the number of instructions for each processor** i saw 2 solutions which made me confused, that's why i need your help
Unresolved Similar Texts: Anomalies in Android Studio's Ctrl + Shift + F Search Results
|android-studio|
Karate uses [Gatling][1] under the hood hence you need to compare Gatling versus JMeter, not Karate versus JMeter and the questions you need to answer are: 1. [Network protocols][2] supported. JMeter out of the box supports more and even more protocols are available via [JMeter Plugins project][3] 2. Distributed execution mode. In JMeter it [comes out of the box][4] and for Gatling you will need to [come up with your own implementation][5] 3. Programming language knowledge required. JMeter allows you to create tests using GUI and provides [recording capabilities][6]. With Gatling you will need to write test logic in Scala, Java or Kotlin. More information and criteria: [Gatling vs. JMeter: The Ultimate Comparison][7] [1]: https://gatling.io/ [2]: https://en.wikipedia.org/wiki/Lists_of_network_protocols [3]: https://jmeter-plugins.org/ [4]: https://jmeter.apache.org/usermanual/jmeter_distributed_testing_step_by_step.html [5]: https://www.baeldung.com/gatling-distributed-perf-testing [6]: https://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.html [7]: https://www.blazemeter.com/blog/gatling-vs-jmeter
I am playing with Scrapy and I am able to scrape with it data from different URLs. One thing I am trying to obtain, and so far unsuccessfully, is stats data, particularly `finish_reason` and `elapsed_time_seconds`. My `testspider.py`'s structure looks pretty standard: class TestSpider(scrapy.Spider): name = 'testspider' def parse(self, response): ... reason = self.crawler.stats.get_value('finish_reason') print(reason) print(self.crawler.stats.get_value('elapsed_time_seconds')) print(self.crawler.stats.get_value('log_count/DEBUG')) and on the output is the following ... None # finish_reason None # elapsed_time_seconds 75 # log_count/DEBUG 2024-02-26 16:03:03 [scrapy.core.engine] INFO: Closing spider (finished) 2024-02-26 16:03:03 [scrapy.statscollectors] INFO: Dumping Scrapy stats: {'downloader/request_bytes': 3039, 'downloader/request_count': 4, 'downloader/request_method_count/GET': 4, 'downloader/response_bytes': 126947, 'downloader/response_count': 4, 'downloader/response_status_count/200': 4, 'elapsed_time_seconds': 0.964805, 'finish_reason': 'finished', 'finish_time': datetime.datetime(2024, 2, 26, 15, 3, 3, 840387, tzinfo=datetime.timezone.utc), 'httpcompression/response_bytes': 639395, 'httpcompression/response_count': 4, 'item_scraped_count': 68, 'log_count/DEBUG': 75, 'log_count/INFO': 10, 'memusage/max': 63651840, 'memusage/startup': 63635456, 'request_depth_max': 2, 'response_received_count': 4, 'robotstxt/request_count': 1, 'robotstxt/response_count': 1, 'robotstxt/response_status_count/200': 1, 'scheduler/dequeued': 3, 'scheduler/dequeued/memory': 3, 'scheduler/enqueued': 3, 'scheduler/enqueued/memory': 3, 'start_time': datetime.datetime(2024, 2, 26, 15, 3, 2, 875582, tzinfo=datetime.timezone.utc)} 2024-02-26 16:03:03 [scrapy.core.engine] INFO: Spider closed (finished) I cannot access some fields from the `def parse` method, perhaps because the script is still running? How do I achieve that? I would like to have direct access to the data in `Scrapy stats` and save it "manually" to the database. How do I achieve that?
Can't start complete colima & docker engine as x86_64 on arm64
|x86-64|arm64|docker-engine|
null
## A leaky abstraction ActiveRecord tries to cross the chasm between the table based world of your database and objects in your application and stumbles like any ORM. `update_all` is one of the methods that operates in the SQL world instead of on objects like `update` does. While it can take a hash and translate it into simple SQL that doesn't apply to structured data types like JSON. ActiveRecord only somewhat supports JSON columns - the types are supplied by the database drivers which handle conversion to and from the database to Ruby types but you can't work with the data inside with the ActiveRecord query interface as the JSON operators/functions are very vendor specific. Having accessors in your model doesn't magically let you update the contents of a JSON object in the database world. Even less so when what you have stored isn't actually a JSON object. ## The foot gun `store` is an old hack from the dark days before RDMBS systems had structured data types such a JSON and JSONB. It stores serialized data as a string (in a text or varchar type column) and then deserializes it in the application when models are hydrated with data from the database. If you use `store` with a native JSON column you're storing an escaped string instead of JSON objects. So you have potentially shot yourself in the foot by filling the database with garbage. It comes with the following warning: > NOTE: If you are using structured database data types (e.g. PostgreSQL > hstore/json, or MySQL 5.7+ json) there is no need for the > serialization provided by .store. Simply use .store_accessor instead > to generate the accessor methods. **Do not use it outside of legacy applications.** # The fix A first step towards fixing your issue would be to fix any existing data in the table and convert the strings stored into actual JSON which you can work with in the database. You can either do this by using `update_all` and the [database JSON functions][1] or by looping through the data in Ruby if performance is not an issue. IMHO if your data is structured enough that you're creating accessors for it in the model it isn't unstructured enough to warrant the use of JSON. I would just declare columns and fill them by looping through the junk data once. That gives you normalized data that you can work with in a sane way and you're avoiding an anti-pattern. If you want to stick with putting what should be columns into a JSON column you would need to use the MySQL specific JSON function to update the data. Model.update_all('model.settings = JSON_MERGE_PATCH( model.settings, \'{"unit_of_distance": "miles" }\' )') [1]: https://dev.mysql.com/doc/refman/8.3/en/json-function-reference.html
The [bash manpage](https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html) says that the variable **`OSTYPE`** stores the name of the operating system: > `OSTYPE` Automatically set to a string that describes the operating system on which bash is executing. The default is system- dependent. It is set to `linux-gnu` here.
null
|php|wordpress|permissions|comments|
null
# bollingers bands always give the same value and give the same value in each symbol there is no error in the code sequence but there is a logical error can you help \` property copyright "Copyright 2024, MetaQuotes Ltd." property link "https://www.mql5.com" property version "1.00" property strict //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { double bb_degeri = iBands(NULL,PERIOD_CURRENT,21,0,2,PRICE_CLOSE); Alert(""); Alert(bb_degeri); \` # it needs to give a different value for each symbol and the forex bot I will write will open and close trades according to these values
I am trying to use the POST method to insert some data from a person with JSON. I am using the code from JS to construct, but when i start the transformation, it sends me: > "ERROR: invalid character ' ' in literal true (expecting 'e')". Does anyone know how to solve it? <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> const obj = { "num_matricula": num_matricula, "limit_date": "2022-05-20", "admission_date": admission_date, "cost_center": cost_center, "pos_number": pos_number, "role": role, "department": department, "pagamento": { "vinculo": vinculo, "valor": valor, "recorrencia": recorrencia, "contaBancaria": { "banco": "001", "carta": "c9160763-db6c-4e8c-a1ad-ad8709c99be2" } }, "deficiencia": deficiencia, "jornada": jornada, "profile": { "name": name, "email": email, "mobile": mobile }, "exame": { "clinica": "6dc84ce4-7d9f-48ec-b9b1-a8a895a21fd4", "data": "2022-05-15", "hora": "14:00", "obs": "Comparecer de manhã", "guia": "e37dab24-c7a4-4b92-b9d1-32ed538b8300", }, "docs": ["c9e26093-5e0c-4bd2-bea3-ac5182a6179f"], "send_sms": true, "send_email": true }; const myJSON = JSON.stringify(obj); <!-- end snippet --> Some columns are already provided with data from previous step (you can see in the images below), that is why i just repeated the column name in the JS code. Just to let you know, the boolean types of data are the columns: send_email, send_sms and deficiencia. [![enter image description here][1]][1] [![enter image description here][2]][2] [![enter image description here][3]][3] [1]: https://i.stack.imgur.com/2SMY0.png [2]: https://i.stack.imgur.com/l9nFp.png [3]: https://i.stack.imgur.com/n9t8Q.png