Dataset Viewer
Auto-converted to Parquet Duplicate
prompt
stringlengths
49
4.73k
response
stringlengths
238
35k
How to set default app launcher programmatically? I am creating a launcher (kiosk) app that will be downloadable through google. When first installing this application the user has the ability of choosing which launcher (mine or the stock) will be the default. I am trying to bring this up manually if the user does not ...
This is actually possible with a little workaround: Create an empty `Activity` that acts as a launcher called `FakeLauncherActivity`. Add it to your manifest as a **disabled** component: ``` <activity android:name="com.path.to.your.FakeLauncherActivity" android:enabled="false"> <intent-filter> ...
What is the most efficient method for adding/removing classes from DOM elements using Javascript? I'm iterating over a large number of dom elements in Javascript, and I'd like to add/remove classes as appropriate. What's the most efficient add/remove class operation I can use?
- Small class strings: [JSPerf](http://jsperf.com/best-way-to-remove-class). - Bigger class strings: [JSPerf](http://jsperf.com/best-way-to-remove-class/2). - Bigger class strings, repeated class names: [JSPerf](http://jsperf.com/best-way-to-remove-class/3). ## Remove The fastest reliable way (small/medium size): ...
glassfish v3 vs tomcat 7 Which one do you recommend for web and why?
I don't recommend any particular one. If you want just JSP/Servlet support, both suffices. If you want more than that (e.g. *anything* provided by the [Java EE API](http://download.oracle.com/javaee/6/tutorial/doc/) which is *much more* than alone JSP/Servlet), then Tomcat simply don't suffice without manually adding a...
Sharing JS variables in multiple I'm working on a CodeIgniter application. I have a view, let's call it Calendar, which has a JS/jQuery `<script>` block in it. Looks like this: ``` $(document).ready(function() { $("#day_list").fadeIn(600); // init var current_month = <?= $init['cu...
It's really important to learn to namespace your variables in JavaScript. Scope matters, and it matters a lot. Right now because you're using the "var" keyword, your stuff will be in the local scope. Some of the other answers here say that you should move them into the global scope. That works, unless something else ...
Why does Excel average gives different result? Here's the table: [![enter image description here](https://i.stack.imgur.com/Nl9rA.png)](https://i.stack.imgur.com/Nl9rA.png) Should not they have the same result mathematically? (the average score of the per column and per row average)
The missing cells mean that your cells aren't all weighted evenly. For example, row 11 has only two cells 82.67 and 90. So for your row average for row 11 they are weighted much more heavily than in your column averages where they are 1/13 and 1/14 of a column instead of 1/2 of a row. Try filling up all the empty ...
How to select domain name from email address I have email addresses like `user1@gmail.com`, `user2@ymail.com user3@hotmail.com` ... etc. I want a Mysql `SELECT` that will trim user names and .com and return output as `gmail`,`ymail`,`hotmail`, etc.
Assuming that the domain is a single word domain like gmail.com, yahoo.com, use ``` select (SUBSTRING_INDEX(SUBSTR(email, INSTR(email, '@') + 1),'.',1)) ``` The inner `SUBSTR` gets the right part of the email address after `@` and the outer `SUBSTRING_INDEX` will cut off the result at the first period. otherwise...
Why `std::prev` does not fire an error with an iterator of `std::unordered\_set`? My question is related to the question linked below. [Bidirectional iterators in unordered\_map?](https://stackoverflow.com/questions/2998452/bidirectional-iterators-in-unordered-map) Since I did not know `std::unordered_set` does not ...
`std::prev` only produces defined behavior for bidirectional iterators. --- The GNU ISO C++ library (used by GCC 4.8.2) uses `std::advance` to implement `std::prev`, and `std::advance` itself is implemented like this: - for random access iterators: ``` __i += __n; ``` - for bidirectional iterators: ``` i...
Unlimited method arguments without GC I am trying to make a function that can receive unlimited amount of arguments without crating GC. I know that this can be done with the `params` keyword but it creates GC. Also understand that you can pass array to to the function but I want to know if it is possible to pass unli...
Yes, it is possible to create a function with unlimited arguments without causing memory allocation. You can do this with the undocumented `__arglist` keyword and wrapping our unlimited `params` inside it. Change your `moveObjects(newPos, 3f, player1, player2, enemy1, enemy2, enemy3)` to `moveObjects(newPos, 3f, ...
Javascript navigator.cookieEnabled Browser Compatibility How well supported is `navigator.cookieEnabled`? Can I safely rely on it for all browsers?
I know it's present in [at least IE 6 and later](http://msdn.microsoft.com/en-us/library/ms533694(v=vs.85).aspx), [Firefox 1 and later](https://developer.mozilla.org/en/DOM/window.navigator.cookieEnabled), and Dottoro reports that it is [supported by all major browsers](http://help.dottoro.com/ljbwtjwn.php). However, i...
rails ancestry pagination I've just followed the Railscast tutorial: <http://railscasts.com/episodes/262-trees-with-ancestry> Is it possible to paginate results from Ancestry which have been arranged? eg: Given I have the following in my Message controller: ``` def index @messages = Message.arrange(:order => ...
It is possible but I've only managed to do it using two database trips. The main issue stems from not being able to set limits on a node's children, which leads to either a node's children being truncated or children being orphaned on subsequent pages. An example: ``` id: 105, Ancestry: Null id: 117, Ancestry: ...
SQLAlchemy emitting cross join for no reason I had a query set up in SQLAlchemy which was running a bit slow, tried to optimize it. The result, for unknown reason, uses an implicit cross join, which is both significantly slower and comes up with entirely the wrong result. I’ve anonymized the table names and arguments b...
This is because a `joinedload` is different from a `join`. The `joinedload`ed entities are effectively anonymous, and the later filters you applied refer to different instances of the same tables, so `customers` and `projects` gets joined in twice. What you should do is to do a `join` as before, but use [`contains_ea...
how to fade out a data bound text block when the property it is bound to is changed, using MVVM i am using the MVVM design pattern and do not want much code in my code behind. coding in XAML and C#. when a user saves a new record i would like "record saved" to appear in a text Block then fade away. this is the sor...
You're using a DataTrigger which needs to be in a style. ``` <Window.DataContext> <WpfApplication2:TestViewModel/> </Window.DataContext> <Grid> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <Grid.Resources> <Style x:Key="textBoxStyle" TargetTy...
How to pass formData for POST request in swagger.json? In my play framework application, I have registered APIs in route file as: ``` POST /api/rmt-create-request controllers.Api.CreateRMTRequestForm ``` On action of controller, I am using following code to access formData submitted with form submit as : ``` pu...
You are mixing OpenAPI 2.0 and 3.0 syntax. In OpenAPI 3.0, request body (including form data) is defined using the [`requestBody`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-operationrequestbody) keyword instead of `in: formData` parameters. Also, OAS3 does not use `cons...
How to Implement dynamic routing in routes.js for generated menu items in sidebar in universal react redux boilerplate by erikras I am currently working on a CMS based project. For which i am using the universal react redux boilerplate by erikras I really need suggestions on handling dynamic routing Lets take a s...
It is not clear from your example which component should be rendered for `/test` url? I suppose it is value of `property` key, right? ### First option You can do is something like this: ``` <Route path="/:page" component={Page}/> ``` It will allow you to render `Page` component for each url, that starts from `...
jquery mobile, disable all button when loading overlay is showed Actually i can call this code ``` $(":input").attr("disabled",true); //Disable all input fields ``` to disable all buttons on my page. But i don't know how good is the performance when i have a lot of button on my page. I saw a trick that we create...
A simple way I've just found is to use a fixed background with `z-index` and `opacity`: Add this CSS: ``` .ui-loader-background { width:100%; height:100%; top:0; margin: 0; background: rgba(0, 0, 0, 0.3); display:none; position: fixed; z-index:100; } .ui-loading .ui-loader-backgrou...
Reusablity of controller in MVC In the MVC pattern, the controller is the least reusable, compared to the other two aspects. Now let's say I have an app (say for Ordering Pizza), which is available both as a web app and a mobile app (say iPhone). So in that case, I think the model (or data) can be reused. The view mig...
The controller calls a service layer. The service layer uses the model to do business logic. Controller never contains business logic. It should only delegate work to the service layer. I consider the service layer as the part that the domain model exposes, you could say it is the "Model" in MVC. That said, I don't t...
How to copy the data of all of the rows in Task Manager in Windows8? Currently, you can only select one row, press ctrl+c and then press ctrl +v to excel. If there is no way to do it from Task Manager, is there some other ways? Such as from cmd.exe. Thanks in advance. ![enter image description here](https://i.stack...
Press you Windows Key, then type `Powershell` to open a PowerShell session, then type `ps` to get a list of all processes with some standard columns. To copy the information, use one of the out- cmdlets: ``` ps | Out-Clipboard ``` or ``` ps | Out-File C:\processes.txt ``` to limit the number of processes t...
C++ header files with no extension I am using an open source project (Open Scene Graph). I found that all the header file names are in `File` format, which I found to be *File With No Extension* as mentioned in some website. I would like to know why those developer used this extension, rather than the traditional `.h...
It seems you are talking about [this repository](https://github.com/openscenegraph/OpenSceneGraph) of C++ code. It looks like the authors of that code decided to follow the patterns of the C++ standard library. In standard C++, library headers are not supposed to have the `.h` extension. So the following is correct: ...
How to calculate the resulting filesize of Image.resize() in PIL I have to reduce incoming files to a size of max 1MB. I use `PIL` for image operations and python 3.5. The filesize of an image is given by: ``` import os src = 'testfile.jpg' os.path.getsize(src) print(src) ``` which gives in my case 1531494 If I op...
Long story short, you do not know how well the image will be compressed, because it depends a lot on what kind of image it is. That said, we can optimize your code. Some optimizations: - Approximate the number of bytes per pixel using the memory size and the image width. - performing a ratio updated based on the ne...
React navigation header right button I want add button in react-native header , the button is to mas and unmask password in the page, the problem on click when i change the state to change secureTextEntry value, the icon wont change will keep as the initial value; the function is working fine but the icon cant change ...
The problem is **this.setState** will not re-render header component . if you want to change header right then you have to call **setParams** again Try this code in **componentDidMount** ``` componentDidMount() { this.props.navigation.setParams({ headerRight: this.setHeaderRight(this.state.secureTextEntr...
How Can I Access the WiFiManager Framework iOS? I am trying to access the WiFiManager Framework (previously apple80211) and can't find the right information. I understand Apple doesn't allow the use of private frameworks for apps on the app store but I am writing this app for personal use so this is of no concern to me...
See my answer [here](https://stackoverflow.com/questions/2053114/iphone-wi-fi-manager-sdk/2152933#2152933). ``` //IN YOUR APP notify_post("com.yourcompany.yourapp.yournotification"); //IN YOUR DYLIB #import <SpringBoard/SBWiFiManager.h> HOOK(SpringBoard, applicationDidFinishLaunching$, void, id app) { //List...
Can I access the DATA from a required script in Ruby? Is it possible to access the text after `__END__` in a ruby file other than the "main" script? For example: ``` # b.rb B_DATA = DATA.read __END__ bbb ``` . ``` # a.rb require 'b' A_DATA = DATA.read puts 'A_DATA: ' + A_DATA puts 'B_DATA: ' + B_DATA __END__ ...
Unfortunately, the `DATA` global constant is set when the "main" script is loaded. A few things that might help: You *can* at least get `A_DATA` to be correct. Just reverse the order of the first two operations in `a.rb`: ``` # a.rb A_DATA = DATA.read require 'b' ... ``` You can get the `B_DATA` to be correct if...
The program can't start because mfc120ud.dll is missing from your computer I'm trying to run an application that I've recently developped onto another computer and which I've compiled using VS2013. Running it I get: > > The program can't start because mfc120ud.dll is missing from your computer. Try reinstalling t...
> > The program can't start because mfc120ud.dll is missing from your computer. Try reinstalling the program to fix this problem. > > > That is one of the debug libraries for MFC. That's the library that you link against when you build debug releases of your program. It is present on your developer machine, but ...
for( in ) loop index is string instead of integer Consider following code: ``` var arr = [111, 222, 333]; for(var i in arr) { if(i === 1) { // Never executed } } ``` It will fail, because `typeof i === 'string'`. Is there way around this? I could explicitly convert `i` to integer, but doing so se...
You have got several options 1. Make conversion to a Number: ``` parseInt(i) === 1 ~~i === 1 +i === 1 ``` 2. Don't compare a type (Use `==` instead of `===`): ``` i == 1 // Just don't forget to add a comment there ``` 3. Change the for loop to (I would do this but it depends on what you are trying to achieve)...
Push notification not received when App is in Background in iOS 10 I'm using FCM(Firebase Cloud Messaging) for sending push notifications in iOS. I'm able to receive the notification when App is in foreground state. But when the App is in background state, the notification is not received. Whenever the application wi...
For iOS 10, we need to call the 2 methods below. **For FOREGROUND state** ``` - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { NSLog( @"Han...
URL scheme - Qt and mac I'm trying to implement a custom URL scheme for my application. I've added the necessary lines for my Info.plist. After calling the specified url (eg.: myapp://) the application launches. If I want to handle the URL, I've found these steps: ``` @interface EventHandler : NSObject { } @end @...
I was also trying to get my Qt-based application handle a custom URL scheme on the Mac and went down the same path as the original poster. It turns out that Qt4 already supports URL events on the Mac, and there's no need to write Objective-C code to receive them. This is in fact the reason that you didn't receive any U...
Netbeans UI empty in DWM I'm trying to use dwm Windows Manager, everything is fine (1mb ram ;) but when I run netbeans it load but with a grey and empty interface. (it works fine in Unity or E17 ) Any Idea ? I have found out this <http://netbeans.org/bugzilla/show_bug.cgi?id=86253> but the solutions proposed doesn'...
Perhaps your issue is the same as this xmonad issue? <http://www.haskell.org/haskellwiki/Xmonad/Frequently_asked_questions#Problems_with_Java_applications.2C_Applet_java_console> > > The Java gui toolkit has a hardcoded list of so-called > "non-reparenting" window managers. xmonad is not on this list (nor are > ...
Any better way to solve Project Euler Problem #5? Here's my attempt at Project Euler Problem #5, which is looking quite clumsy when seen the first time. Is there any better way to solve this? Or any built-in library that already does some part of the problem? ``` ''' Problem 5: 2520 is the smallest number t...
You are recomputing the list of prime numbers for each iteration. Do it just once and reuse it. There are also better ways of computing them other than trial division, the [sieve of Eratosthenes](http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) is very simple yet effective, and will get you a long way in Project Eul...
pandas pivot\_table with dates as values let's say I have the following table of customer data ``` df = pd.DataFrame.from_dict({"Customer":[0,0,1], "Date":['01.01.2016', '01.02.2016', '01.01.2016'], "Type":["First Buy", "Second Buy", "First Buy"], "Value":[10,20,10]}) ``` which looks lik...
Use [`unstack`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.unstack.html): ``` df1 = df.set_index(['Customer', 'Type']).unstack() df1.columns = ['_'.join(cols) for cols in df1.columns] print (df1) Date_First Buy Date_Second Buy Value_First Buy Value_Second Buy Customer ...
Java 8 Stream vs Collection Storage I have been reading up on Java 8 Streams and the way data is streamed from a data source, rather than have the entire collection to extract data from. This quote in particular I read on [an article](http://www.drdobbs.com/jvm/lambdas-and-streams-in-java-8-libraries/240166818?pgno=...
The statement about streams and storage means that a stream doesn't have any storage *of its own*. If the stream's source is a collection, then obviously that collection has storage to hold the elements. Let's take one of examples from that article: ``` int sum = shapes.stream() .filter(s -> s.getC...
How to make console be able to print any of 65535 UNICODE characters I am experimenting with unicode characters and taking unicode values from [Wikipedia](http://en.wikipedia.org/wiki/List_of_Unicode_characters) page Ihe problem is my console displays all of **C0 Controls and Basic Latin** unicode characters ie from ...
There's a lot of history behind that question, I'll noodle about it for a while first. Console mode apps can only operate with an 8-bit text encoding. This goes back to a design decision made 42 years ago by Ken Thompson et al when they designed Unix. A core feature of Unix that terminal I/O was done through pipes and ...
Overloading new operator in the derived class I have overloaded `new` operator in the Base class. However, when I add additional overloaded `new` to the Derived class gcc compiler does not find `new` operator in the Base class. Why? Best, Alex ``` #include <stdlib.h> template <class t> class Base { public: ...
When you invoke the `operator new` via the placement `new` expression ``` new (loc) Derived<char>(); ``` the compiler looks for an overload of `operator new` in the `Derived` class (and not the `Base` class). It finds it, but your overload ``` void * operator new (size_t size, int sz, void *loc) { return loc; ...
Kind of load balanced thread pool in java I am looking for a load balanced thread pool with no success so far. (Not sure whether load balancing is the correct wording). Let me explain what I try to achieve. Part 1: I have Jobs, with 8 to 10 single tasks. On a 6 core CPU I let 8 thread work on this tasks in parallel ...
One possibility might be to use a standard `ThreadPoolExecutor` with a different kind of task queue ``` public class TaskRunner { private static class PriorityRunnable implements Runnable, Comparable<PriorityRunnable> { private Runnable theRunnable; private int priority = 0; public Priority...
php - filter\_input - set to default value if GET key not set I'd like to have a clean, elegant way to set a variable to a GET parameter if said parameter is set (and numeric), and to 0 (or some other default) if it's not set. Right now I have: ``` if (($get_id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT))...
The [`filter_input`](http://php.net/manual/en/function.filter-input.php) function accepts an `options` parameter. Each filter accepts different options. For example, the `FILTER_VALIDATE_INT` filter can accept `default`, `min_range` and `max_range` options [as described here](http://php.net/manual/en/filter.filters.val...
Why is FAT#2 rarely used? I read a single-line explanation of FAT#2 from Peter Abel's book *IBM PC Assembly Language and Programming*. It says: > > Although FAT2 is still maintained, its use has never been implemented. > > > Wikipedia says: > > The FAT Region. > > > This typically contains two copies (...
Assuming "FAT2" means a second copy of the FAT (File Allocation Table) then the basic problem is that it's of little practical use, but I'm not sure if it's true if its actually never used. The FAT is a central data structure in the FAT file system, so central that the file system itself is named after it. It's not o...
Regexp matching a string - positive lookahead Regexp: `(?=(\d+))\w+\1` String: `456x56` Hi, I am not getting the concept, how this regex matches "56x56" in the string "456x56". 1. The lookaround, (?=(\d+)), captures 456 and put into \1, for (\d+) - The wordcharacter, \w+, matches the whole string("456x56") - \1,...
You don't anchor your regex, as has been said. Another problem is that `\w` also matches digits... Now look at how the regex engine proceeds to match with your input: ``` # begin regex: |(?=(\d+))\w+\1 input: |456x56 # lookahead (first group = '456') regex: (?=(\d+))|\w+\1 input: |456x56 # \w+ regex: (?=(\d+))\w+|\...
Receiving an Arabic datetime error in asp.net I use ADO disconnected mode to get data from database by filling dataset ds. All data come true except the date field ``` string strDate = ds.Tables[0].Rows[0]["H_DT"].ToString(); ``` it throws an exception says: > > Specified time is not supported in this calendar...
From [`DateTime.ToString` method](http://msdn.microsoft.com/en-us/library/k494fzbf%28v=vs.110%29.aspx) > > The `ToString()` method returns the string representation of the date > and time in the calendar used by the current culture. If the value of > the current `DateTime` instance is earlier than > `Calendar.M...
Select from two tables with group by date I have two tables: Table t1: ``` id | date_click 1 | 2016-02-31 17:17:23 2 | 2016-03-31 12:11:21 3 | 2016-03-31 13:13:23 ``` So from this table I want to get count field `Id` for each day. For this I use next query: ``` SELECT date_format(date_click, '%Y-%m-%d') ...
First you should UNION these results and then group by days and select aggregate fields. Also you can JOIN these queries but it can be a problem if some days miss in one of two tables: ``` SELECT date_sent_push, MAX(count_click) as count_click, MAX(count_sent) as count_sent FROM (SELECT date_format(d...
How to create a local read-only variable in bash? How do I create both `local` and `declare -r` (read-only) variable in bash? If I do: ``` function x { declare -r var=val } ``` Then I simply get a global `var` that is read-only If I do: ``` function x { local var=val } ``` If I do: ``` function...
Even though `help local` doesn't mention it in Bash *3.x*, `local` can accept the same options as `declare` (as of at least Bash 4.3.30, this documentation oversight has been corrected). Thus, you can simply do: ``` local -r var=val ``` That said, `declare` *inside a function* by default behaves the same as `loc...
How do I adjust a QTableView height according to contents? In my layout, my dynamically generated QTableViews seem to get resized to only show one row. I want to have the container of the table views to have a scrollbar instead of the individual table views, which should show full contents.
@savolai Thank you very much for your code, it works well for me. I just do additional checks: ``` void verticalResizeTableViewToContents(QTableView *tableView) { int rowTotalHeight=0; // Rows height int count=tableView->verticalHeader()->count(); for (int i = 0; i < count; ++i) { // 2018-03...
Need help parsing string in bash I have a script that uses sensors to get CPU temps in Ubuntu. ``` IN="`/usr/bin/sensors -f | grep 'Core ' | cut -f2 -d"+" | cut -f1 -d '.'`" echo $IN ``` It yields results like this ``` 96 100 98 102 ``` What I need to do is be able to call it like cpu1 to get the first, cpu2 ...
You can convert `$IN` to an array like this: ``` TEMPERATURES=($IN) ``` Then you can index into that array to get a particular temperature; for example: ``` echo ${TEMPERATURES[0]} ``` If you pass a command-line parameter to your script, you can use that as an array index: ``` WHICH=$1 ...
Elixir: Modifying value of module attribute Is it possible to achieve below behavior wherein one tries to change the value of a module attribute to alter the behavior of the module methods? ``` defmodule Adder do @num_to_add 10 def addTo(input), do: input + @num_to_add end IO.inspect Adder.addTo(5) # Prints 15...
This is not possible since attributes only exist up until compilation of that specific module. When the module is compiled all the attributes are inlined and forgotten about, so at the point you are able to call functions from that module it is no longer possible to modify the attributes. This code should show this a...
Magento EU VAT tax validation fails, customer group change not applied Our company is VAT registered and removes VAT from EU B2B sales where a valid VAT number has been provided. Magento version is 1.9 which includes support for this tax issue, customer group is (was) automatically assigned once the VAT number is valid...
There are 2 fields for the VAT ID inside Magento. The first one is related to the customer entity, which won't be checked against the VAT validation service "VIES". It has only some information character, but is has no impact of the customer group assignment. The second VAT ID field is related to the customer addres...
SQL Server Configuration Manager express 2012 I want to enable TCP/IP on my SQL Server Express 2012 but I cannot find SQL Server Configuration Manager. I have windows 8 and I made a search for "SQL Server Configuration Manager" but nothing comes up. Do I have to install SQL Server Configuration Manager separately or ...
As is [stated on My Tec Bits](http://www.mytecbits.com/microsoft/sql-server/sql-server-2012-configuration-manager-in-windows-8): If you have installed SQL Server 2012 on windows 8, you may not see the Configuration manager in the app list. SQL Server 2012 configuration manager is not a stand alone program. it is a sn...
Slick Carousel next and previous buttons showing above/below, rather than left/right I'm using Slick Carousel [this](http://kenwheeler.github.io/slick/) and my "next" and "previous" arrows are appearing above and below my images, rather than on each side. I'm just looking for it to appear the way it does in the Slick d...
I had a similar problem with slick; the navigations where above and under the image. but i solved it with this simple css. ``` .nextArrowBtn{ position: absolute; z-index: 1000; top: 50%; right: 0; color: #BFAFB2; } .prevArrowBtn{ position: absolute; z-index: 1000; top: 50%; left: ...
Round to nearest MINUTE or HOUR in Standard SQL BigQuery There are some easy short ways to round to nearest MINUTE for T-SQL as noted [here](https://stackoverflow.com/questions/6666866/t-sql-datetime-rounded-to-nearest-minute-and-nearest-hours-with-using-functions). I am looking to get the same short syntax for Stand...
Below is for BigQuery Standard SQL ``` #standardSQL WITH `project.dataset.table` AS ( SELECT DATETIME '2018-01-01 01:05:56' input_datetime ) SELECT input_datetime, DATETIME_TRUNC(input_datetime, MINUTE) rounded_to_minute, DATETIME_TRUNC(input_datetime, HOUR) rounded_to_hour FROM `project.dataset.table` `...
Open XFCE Terminal Window and Run command in same Window I would like to start 'xfce4-terminal' and then run a command but finish with a prompt to repeat the command. I use the software 'todo.txt' and like to have it open in a small window which I can refer to and add entries, etc. At the moment, I have the followi...
Use `-c` option for bash command to wrap multiple commands, like this: ``` $ bash -c "ls /var/log/apt; bash" history.log history.log.4.gz term.log.10.gz term.log.5.gz history.log.10.gz history.log.5.gz term.log.11.gz term.log.6.gz history.log.11.gz history.log.6.gz term.log.12.gz term.log.7.gz history.log...
Why do we need natural log of Odds in Logistic Regression? I know what an odds is. It's a ratio of the probability of some event happening to the probability it not happening. So, in the context of classification, the probability that an input feature vector $X$ belongs to class 1 is $p(X)$ then the Odds is:- $O = \f...
I think I figured out the answer myself after doing a bit of reading so thought of posting it here. It looks like I got little confused. So as per my post $$O = \frac{P(X)}{1-P(X)}.$$ So I forgot to take into account the fact that $P(X)$ itself is the probability given by the logistic function:- $$P\_\beta(X) =...
open or create file in python and append to it how do you do this series of actions in python? 1) Create a file if it does not exist and insert a string 2) If the file exists, search if it contains a string 3) If the string does not exist, hang it at the end of the file I'm currently doing it this way but I'm m...
Try this: ``` with open(path, 'a+') as file: file.seek(0) content = file.read() if string not in content: file.write(string) ``` seek will move your pointer to the start, and write will move it back to the end. Edit: Also, you don't need to check the path. Example: ``` >>> f = open('examp...
SVG image inside circle I want to create a circle which contains an image, I already tried using `pattern` or `filter` but none of them give me the expected result. Below is the code: ``` <svg id="graph" width="100%" height="400px"> <!-- filter --> <filter id = "born1" x = "0%" y = "0%" width = "100%" heig...
A pattern will work. You just have to give the `<image>` a size. Unlike HTML, SVG images default to width and height of zero. Also, if you want the image to scale with the circle, then you should specify a `viewBox` for the pattern. ``` <svg id="graph" width="100%" height="400px"> <!-- pattern --> <defs>...
Initialize array holding struct more efficiently I have the following code: ``` const N: usize = 10000; const S: usize = 7000; #[derive(Copy, Clone, Debug)] struct T { a: f64, b: f64, f: f64 } fn main() { let mut t: [T; N] = [T {a: 0.0, b: 0.0, f: 0.0}; N]; for i in 0..N { t[i].a = 0.0...
> > I'm unsure why the array `t` must be initialized that way. > > > Because Rust doesn't let you touch (entirely or partially) uninitialised values. The compiler isn't smart enough to prove that the loop will *definitely* initialise everything, so it just forbids it. Now, the *optimiser* is a different story....
FileStream locking a file for reading and writing I have the following code block which is giving me a headache. Logically it should work as I am using the filestream providing the lock within the using statement. When it gets to the line that creates the StreamWriter, it fails saying "the file is not writable". No...
The FileShare.None flag does not cause threads to queue, it just locks the file, hence the exception that you get. To provide mutually exclusive access you can lock a shared object prior to writing. But you say this "Now my program is a multithreaded application. Any thread could be trying to write to this file." Now...
Determine if an app exists and launch that app on iOS Is there a way to check iOS to see if another app has been installed and then launched? If memory serves me this was not possible in early versions but has this been changed?
Doable, but tricky. Launching installed apps, like the FB or Twitter apps, is done using the Custom URL Scheme. These can be used both in other apps as well as on web sites. [Here's an article about how to do this with your own app](http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-ur...
Databinding a label in C# with additional text? Is there an easy way to databind a label AND include some custom text? Of course I can bind a label like so: someLabel.DataBindings.Add(new Binding("Text", this.someBindingSource, "SomeColumn", true)); But how would I add custom text, so that the result would be som...
You can always use Binding.Format event. <http://msdn.microsoft.com/en-us/library/system.windows.forms.binding.format.aspx> > > The Format event is raised when data > is pushed from the data source into > the control. You can handle the Format > event to convert unformatted data from > the data source into fo...
remove gradient of a image without a comparison image currently i am having much difficulty thinking of a good method of removing the gradient from a image i received. The image is a picture taken by a microscope camera that has a light glare in the middle. The image has a pattern that goes throughout the image. How...
I have done some work in this area previously and found that a large Gaussian blur kernel can produce a reasonable approximation to the background illumination. I will try to get something working on your example image but, in the meantime, here is an example of your image after Gaussian blur with radius 50 pixels, whi...
How can I get rid of the 'remote: ' messages that appear on every line returned by post-receive in git? I've created a post-receive hook in git. The hook output messages to the screen, which are sent back to the git client doing the push, and outputted back. How can I get rid of the 'remote: ' text before every sing...
Note: The prefix can be important to avoid mistaking messages from the remote system as messages from the local system. That said, there is no way to turn off the prefix, but they are all written to stderr. You could redirect/capture/filter the stderr of *git push* to do what you want. A rough way of doing might be...
Flutter - How to display a GridView within an AlertDialog box? I'm trying to display a GridView of images to allow a user to pick from within a Dialog Box and I'm having rendering issues. My UI fades as if a view was appearing on top of it, but nothing displays. Here is my code... ``` Future<Null> _neverSatisfied() ...
The issue is that, the `AlertDailog` tries to get the intrinsic width of the child. But `GridView` being lazy does not provide intrinsic properties. Just try wrapping the `GridView` in a `Container` with some `width`. Example: ``` Future<Null> _neverSatisfied() async { return showDialog<Null>( context: conte...
Auto mocking container for Windsor and Rhino I am want to do automocking with Windsor so that I can do something like ``` _controller = _autoMockingContainer.Create<MyControllerWithLoadsOfDepdencies>(); ``` There used to be a Windsor auto mocking container in [Ayende's](http://ayende.com/blog/) [Rhino](http://bl...
Thanks to @mookid8000's link and help from a colleague, I created this......which seems to do the trick. ``` public abstract class TestBase { static readonly WindsorContainer _mockWindsorContainer; static TestBase() { _mockWindsorContainer = new WindsorContainer(); ...
How do you resolve a "The parameters (number[]) don't match the method signature for SpreadsheetApp.Range.setValues" error I am getting this error: > > "The parameters (number[]) don't match the method signature for SpreadsheetApp.Range.setValues." > > > in my Google Apps Script when I try to write an array o...
[`setValues`](https://developers.google.com/apps-script/reference/spreadsheet/range#setValues(Object)) accepts(and [`getValues()`](https://developers.google.com/apps-script/reference/spreadsheet/range#getValues()) returns): - 1 argument of type: - `Object[][]` a **two** dimensional array of objects It does **NOT** ...
how to mimic search and replace in google apps script for a range I wanted to automet some text replacement in a Google sheet. I utilized the record a macro functionality while doing CTRL-H seacrch and replace, but nothing got recorded. Then I tryed this code: ``` spreadsheet.getRange('B:B').replace('oldText','...
- You want to replace `oldText` to `newText` for the specific column (in this case, it's the column "B".) - You want to achieve this using Google Apps Script. If my understanding is correct, how about this answer? Please think of this as just one of several answers. Unfortunately, `replace()` cannot be used for the...
How to access subprocess Popen pass\_fds argument from subprocess? So the title is a bit long but it is the only thing I cannot find online, with a little bit searching. How do I access the `pass_fds` argument from subprocess? ``` # parent.py import subprocess subprocess.Popen(['run', 'some', 'program'], pass_fds=...
You need to explicitly inform the child of the fds passed in some way. The most common/simple mechanisms would be: 1. Via an environment variable set for the child 2. Via an argument passed to the child 3. (Less common, but possible) Written to the child's `stdin` All of these require the child's cooperation of cou...
Homebrew GDB can't open core file on Yosemite 10.10 I installed GDB 7.8.1 and GCC 4.9 through Homebrew. When I open a core file generated by a GCC-compiled (`gcc-4.9 -g xxx.c -o xxx`) program, it reports: ``` → gdb ./list_test /cores/core.1176 GNU gdb (GDB) 7.8.1 Copyright (C) 2014 Free Software Foundation, Inc. ...
Based on [the long GDB developers' discussion thread on this issue](https://cygwin.com/ml/gdb/2014-01/msg00035.html), it seems Apple did not merge their changes back to the official GNU mainline, and instead chose to publish the modified source code on their own site. As a result, the Homebrew GDB install (which uses t...
Is it possible to have multiple local strategies in passport implemented with NestJS I have a scenario where I need to implement an authentication mechanism for admin and for normal users in my application using the Passport local strategy. I implemented the strategy for the normal users as described [here](https://doc...
You could make a second strategy based on `passport-local` but give it a specified name like `admin` by following the [named strategies](https://docs.nestjs.com/security/authentication#named-strategies) part of the docs. Something like ``` @Injectable() export class LocalAdminStrategy extends PassportStrategy(Strate...
When to convert an ordinal variable to a binary variable? I have seen some people convert their ordinal variable to a binary one, especially in the public opinion literature. For instance, when there is a four-scale question with responses including "Strongy agree," "Agree," "Disagree," and "Strongly disagree," some au...
While I am not sure there is ever a time that one needs to convert ordinal data to binary, there are times when it may be more appropriate. First, the authors may simply choose to opt for a simpler model. That is to say, a logistic model is easier to run and analyze than is an ordinal model. Also, fewer assumptions t...
Arraylist not able to remove duplicate strings ``` public static void main(String[] args) { List<String> list = new ArrayList(); list.add("AA");list.add("Aw");list.add("Aw");list.add("AA"); list.add("AA");list.add("A45");list.add("AA"); list.add("Aal");list.add("Af");list.add("An"); ...
this is wrong: ``` for (int i = 0; i < list.size(); i++) { if (list.get(i).equals("AA")) { list.remove(i); } } ``` because your list is changing its size as long as you remove elements.... you need an iterator: ``` Iterator<String> iter = list.iterator(); while (iter.hasNe...
Python Kafka consumer reading already read messages Kafka consumer code - ``` def test(): TOPIC = "file_data" producer = KafkaProducer() producer.send(TOPIC, "data") consumer = KafkaConsumer( bootstrap_servers=['localhost:9092'], auto_offset_reset='latest', consumer_timeout_ms=1000, group_id="Group2...
``` from kafka import KafkaConsumer from kafka import TopicPartition from kafka import KafkaProducer def test(): TOPIC = "file_data" producer = KafkaProducer() producer.send(TOPIC, b'data') consumer = KafkaConsumer( bootstrap_servers=['localhost:9092'], auto_offset_reset='latest', ...
AWS .NET Core 3.1 Mock Lambda Test Tool, cannot read AppSettings.json or App.config Using the AWS .NET Core 3.1 Mock Lambda Test Tool, I cannot get the lambda function to read from an appsettings.json or even an app.config file. That is two sperate methods that when I try to get a return value, each method returns nu...
From this [blog post](https://aws.amazon.com/blogs/compute/announcing-aws-lambda-supports-for-net-core-3-1/) > > The test tool is an ASP.NET Core application that loads and executes the Lambda code. > > > Which means that this web app has its own config file that is different from your application's one. And i...
Intuition as to why estimates of a covariance matrix are numerically unstable It is well known that estimating the covariance matrix by the ML estimator (sample covariance) can be very numerically unstable (in high dimensions), which is why it is preferable to do PCA with the SVD, for example. But I haven't been able t...
The reason that the SVD of the original matrix $X$ is preferred instead of the eigen-decomposition of the covariance matrix $C$ when doing PCA is that that the solution of the eigenvalue problem presented in the covariance matrix $C$ (where $C = \frac{1}{N-1}X\_0^T X\_0$, $X\_0$ being the zero-centred version of the or...
R Sort strings according to substring I have a set of file names like: ``` filelist <- c("filea-10.txt", "fileb-2.txt", "filec-1.txt", "filed-5.txt", "filef-4.txt") ``` and I would like to filter them according to the number after "-". In python, for instance, I can use the `key`parameter of the sorting function...
I'm not sure of the actual complexity of your list of file names, but something like the following might be sufficient: ``` filelist[order(as.numeric(gsub("[^0-9]+", "", filelist)))] # [1] "filec-1.txt" "fileb-2.txt" "filef-4.txt" "filed-5.txt" "filea-10.txt" ``` --- Considering your edit, you may want to ...
Old SQL History in Oracle SQL Developer In SQL Developer, i was finding some SQL commands of previous month but not able to find that as it is showing only the records of last 4-5 days. Is there any way to find the old SQL commands those are not displaying under SQL history tab. Thanks.
As Oracle has documented, there is a SQL history folder and it is larger (has more SQL queries that go back about a year) than the SQL History tool bar (a couple of months). Here is the content of my SQL History tool bar: ![SQL History tool bar](https://i.stack.imgur.com/KsIo2.jpg) With respect to the SQL history...
Copy one column to another for over a billion rows in SQL Server database Database : SQL Server 2005 Problem : Copy values from one column to another column in the same table with a billion+ rows. ``` test_table (int id, bigint bigid) ``` Things tried 1: update query ``` update test_table set bigid = id ``...
I'm going to guess that you are closing in on the 2.1billion limit of an INT datatype on an artificial key for a column. Yes, that's a pain. Much easier to fix before the fact than after you've actually hit that limit and production is shut down while you are trying to fix it :) Anyway, several of the ideas here will...
Samba 4.9.0 ./configure lmdb error I'm very new to Linux and installing Samba and I'm trying to make my Centos 7 into a ADDC. However, whenever I want to configure I get the following message: > > Checking for lmdb >= 0.9.16 via header check : not found > > Samba AD DC and --enable-selftest requires lmdb 0....
The actual dependency to install ([for Red Hat Enterprise Linux 7 / CentOS 7 / Scientific Linux 7](https://wiki.samba.org/index.php/Package_Dependencies_Required_to_Build_Samba#Red_Hat_Enterprise_Linux_7_.2F_CentOS_7_.2F_Scientific_Linux_7)) is `lmdb-devel`. Rather than following some random tutorial for a now EOL ve...
Multiple taps on the same row in a table view I am working on putting a checkbox in every row of a table view. When I tap a row, its value should get saved into an array, on tap of another row, its value should likewise get saved to the same array, and on a tap of the same row, the value should get deleted from the arr...
list is the array name which contains all the data that is viewed in tableview replace it with your own array name Suppose tableArray is your array in which values are inserted and deleted. in .h file ``` NSMutableArray *tableArray; ``` in .m file in view didload ``` tableArray=[[NSMutableArray alloc]init]; ``...
Does Google Guava Cache do deduplication when refreshing value of the same key I implemented a non-blocking cache using Google Guava, there's only one key in the cache, and value for the key is only refreshed asynchronously (by overriding reload()). My question is that does Guava cache handle de-duplication if the fi...
Yes, see the documentation for [`LoadingCache.get(K)`](http://google.github.io/guava/releases/snapshot/api/docs/com/google/common/cache/LoadingCache.html#get-K-) (and it sibling, [`Cache.get(K, Runnable)`](http://google.github.io/guava/releases/snapshot/api/docs/com/google/common/cache/Cache.html#get-K-java.util.concur...
Laravel eager loading vs explicit join This might sound like an obvious question but I just want to get some reassurance. Using Laravel's eager loading functionality, from what I understand it will create **two queries** to return a whole list of related results (say if you're working with two tables). However, and c...
You are absolutely right about your understanding. If you write a `join` statement to join two or more tables using `join()` in `Laravel` then it makes only one query where using an `Eloquent` model with `eager loading` technique requires more than one query. > > should I not bother with eager loading and instead j...
Is GCC 4.8.1 C++11 complete? OS is windows. I'll start off by saying that I have no experience with C++, or any other compiled language. I've used CPython a bit and am familiar with that, but, until earlier today, I'd never even glanced at C++ source. I'm trying to teach myself C++, so I've been playing around with...
My understanding is that, other than `regex` support, G++'s C++11 support is largely complete with 4.8.1. The following two links highlight the status of C++11 support in G++ 4.8.1 and libstdc++: - [C++11 status in GCC 4.8.x.](http://gcc.gnu.org/gcc-4.8/cxx0x_status.html) - [C++11 status in libstdc++.](http://gcc....
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
8