INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Generate bitcoin address from derivation scheme I have a derivation scheme starting with tpub... for testnet and I want to be able to generate bitcoin addresses from derivation scheme. Also I want a method be applicable to mainnet, is any library available that could help me in this task. And code example how to do it what be great. I was thinking bitcore-lib would help, but didn't found anything useful for my task. But any solution would be fine. All useful information I found was a bunch of bips, but I doubt that I need to do that from scratch, and want to avoid it.
Have a time to publish a full answer now: var runningNetwork = bjs.networks.testnet const bip32 = require('bip32') const bjs = require('bitcoinjs-lib') let { address } = bjs.payments.p2wpkh({pubkey: bip32.fromBase58(dvScheme,runningNetwork).derive(0).derive(1).publicKey,}) console.log(`${address}`)
stackexchange-stackoverflow
{ "answer_score": -1, "question_score": -3, "tags": "javascript, node.js, bitcoin" }
Azure Cosmos DB Table API - LIST Generic We recently move form Doc DB to using the table api with COSMOS DB on Azure. We wanted a generic list method like: public async Task<IEnumerable<T>> ListEntityAsync(Expression<Func<T, bool>> predicate) { // Filter against a property that's not partition key or row key TableQuery<T> query = new TableQuery<T>().Where(predicate); var results = _table.ExecuteQuery(query); return results.ToList(); } but we get invalid cast exceptions as the Where clause returns an IQueryable and the execute method needs TableQuery. Any ideas would be appreciated! Thanks!
You can convert an IQueryable instance generated by the Where clause to TableQuery instance using the AsTableQuery extension method provided by the SDK, under the Queryable namespace (below) References * < * <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, azure, generics" }
How to pass Javascript variable with form on submit? I want to pass a variable created with Javascript to $form_state so that I can use this variable in the form_submit function. In an ajaxified form I can use: Drupal.ajax[ajax_el].options.data._my_vars = JSON.stringify(js_object); But how can I accomplish it in a non ajax form? Is there another possibility than using a hidden field? It might be possible to pass it to a field with `#access => FALSE`? I would welcome every advice. Many thanks! Daniel
Create a field for that variable, like this: $form['_my_vars'] = array('#type' => 'hidden', '#default_value' => $_my_vars); Whenever you are changing variable, update field's value. **Do not** use '#access' => FALSE The Form API Reference clarifies it: > when FALSE, the element is not rendered and the user submitted value is not taken into consideration.
stackexchange-drupal
{ "answer_score": 2, "question_score": 4, "tags": "7, forms, javascript" }
Can I adjust the "100+ matches in X files" from Intellijs "find in path" Is it possible to change the max value of shown results in the "find in path" feature in intellij? ![enter image description here]( I sometimes wished that I would see more results. of course I would need to scroll much more, but that's what I want. Can I change that number 100 to like 200, 1000 or even maybe endless?
**Edit:** _This answer is outdated._ You can now set the parameter `ide.usages.page.size` to increase the number of displayed findings. See RoryGS' answer for details. **Old answer:** Currently you only have the option to hit the **Open in Find Window** button (in the bottom right). But there is an open issue for IntelliJ to change this limit: ~~ < ![Find window](
stackexchange-stackoverflow
{ "answer_score": 26, "question_score": 79, "tags": "intellij idea" }
DropDown Swift 3 compile error I upgraded my Podfile to us target 'MyApp' pod 'DropDown' end post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['ENABLE_BITCODE'] = 'NO' config.build_settings['SWIFT_VERSION'] = "3.0" end end end When I try to compile, I get Swift3 compile errors with the DropDown pod. But their page says they support Swift3 natively. < I am attempting to use Edit > Convert, I still get errors. Why is this happening? Same issue with AlamoFire. I updated to the latest version by removing the version requirement from the Podfile, removed Pods directory, pod install, updated my swift version to 3.0 in the target settings and I'm getting compile errors.
Rather than removing the version requirement, I would suggest explicitly defining a version that is Swift-3 compatible. It could be that your pods repo is out of date, so it's picking up older versions of the pods.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "swift3, cocoapods, alamofire" }
Using XMLHttpRequest synchronously in IE9 does not return any data This is the code i have used: if(window.XDomainRequest) {xml_add_http = new XDomainRequest();} else if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xml_add_http=new XMLHttpRequest(); } else {// code for IE6, IE5 xml_add_http=new ActiveXObject("Microsoft.XMLHTTP"); } var main_url = " xml_add_http.open("GET",main_url,false); xml_add_http.send(null); var xml_add_Doc=xml_add_http.responseText; console.log(xml_add_Doc); } On chrome or firefox in concole window it returns: > {"datetime":"Thu, 04 Jul 2013 20:11:21 +0000"} But in internet explorer 9 it only returns: > LOG:
After removing XDomainRequest from the code, it works on ie.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript" }
Back up localdb for db migration I've made my app on LocalDb\v11.0 on my own PC, and I'm trying to launch the website now. First I need to get the database filled with test data. I think the best way to do this is make a .bak file of my current database and restore it on the host. But how do I make a back up file (.BAK) of my LocalDb inside MVS?
I found a way to back up my Database using a SQL query. BACKUP DATABASE AdventureWorks2008R2 TO DISK = 'Z:\SQLServerBackups\AdventureWorks2008R2.Bak' WITH FORMAT, MEDIANAME = 'Z_SQLServerBackups', NAME = 'Full Backup of AdventureWorks2008R2'; found this on <
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "entity framework, asp.net mvc 4" }
What are the minimum permissions needed to run a Scheduled Task on Server 2003? I'm trying to set up a scheduled task on my server 2003 box (that is sitting on the WWW) to read web logs into a database. When I run the .cmd file that I have set up using `runas`, the task succeeds. However, when I try to schedule the task under the user, I get the following error: "ImportToday.job" (ImportToday.cmd) 9/15/2010 2:37:30 PM ** ERROR ** Unable to start task. The specific error is: 0x80070005: Access is denied. Try using the Task page Browse button to locate the application. Adding the account `logimporter` into the `Administrators` group lets the scheduled task succeed, but this is really not a long-term option. I have tried adding the `Log on as a service` right, and the account currently has the `Log on as a batch job` right. What do I need to do?
And..... I found it. By default, `CMD.EXE` requires special permissions when not logged on to a desktop session. So, by adding `Read` and `Read & Execute` permissions for the account has fixed my problem. That is: cacls C:\Windows\system32\cmd.exe /e /g logimporter:r fixed it for me.
stackexchange-serverfault
{ "answer_score": 1, "question_score": 1, "tags": "windows server 2003, permissions, scheduled task" }
Java collections array How can I create an array of collection in Java? For example in c++ we have: vector <int> adj[10]; and then initialize it using for loop: cin >> nodes; cin >> edges; for(int i = 0;i < edges;++i) { cin >> x >> y; adj[x].push_back(y); adj[y].push_back(x); } eg: 6 4 1 2 2 3 1 3 4 5 For above input adj will be as follows: index 0 - 1 - 2 3 2 - 1 3 3 - 2 1 4 - 5 5 - 4 6 - 7 -
This is one java version of your C++ code: public static void main(String[] args) { ArrayList<Integer>[] adj = new ArrayList[10]; for (int i = 0; i < adj.length; i++) adj[i] = new ArrayList<>(); Scanner in = new Scanner(System.in); int nodes = in.nextInt(); int edges = in.nextInt(); for (int i = 0; i < edges; ++i) { int x = in.nextInt(); int y = in.nextInt(); adj[x].add(y); adj[y].add(x); } for (int i = 0; i < adj.length; i++) System.out.println(adj[i]); }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "java, arrays, collections" }
How many directions are there in the Non Maximum Suppression part of the Canny Edge Detector In the Non-maximum suppression algorithm, each pixel has a total of 4 directions since there are 8 neighboring pixels. But why there is not 8 directions instead, please? I see below there are 8 directions not only 4: ![enter image description here](
There are 8 directions to be considered in non-maximum suppression as used in the Canny edge detector. But each pair of opposite directions can be handled with the same code.
stackexchange-dsp
{ "answer_score": 3, "question_score": 0, "tags": "image processing, edge detection, software implementation, canny edge detector" }
Need regular expression for validating date in dd-MMM-yyyy format I am not expert in writing regular expressions so need your help. I want to validate date in "dd-MMM-yyyy" format i.e. 07-Jun-2012. I am using RegularExpressionValidator in asp.net. Can anybody help me out providing the expression? Thanks for sharing your time.
Using a DatePicker is probably the best approach. However, since that's not what you asked, here's an option (although it's case sensitive): ^(([0-9])|([0-2][0-9])|([3][0-1]))\-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\-\d{4}$ In addition, here's a place you can easily test Regular Expressions: <
stackexchange-stackoverflow
{ "answer_score": 26, "question_score": 10, "tags": "asp.net, regex" }
Page load time of a target page or URL with jquery Is there a way I can get the load time of a URL or page from Jquery? For example, I make ajax request to " I want to know how long it took to load the page completely. I am aware of the same domain policy. But I just want to write a simple javascript utility that can let me know page load time. I know there are tools like YSlow etc, but I want this utility to be running continuously in browser tab and alert(javascript) alert when the page load time is beyond some threshold. Thanks, J
Something like this should work nicely. var startTime; $.ajax({ // url, type, dataType, etc beforeSend: function(xhr){ startTime = +new Date(); } complete: function(xhr, state){ var latency = (+new Date()) - startTime; window.console.log(latency); } });
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "javascript, jquery, jquery plugins, page load time" }
html/css page displayed not in full size in mobile version I'am working on `HTML/CSS` project, Project contains 3 files: index.html contacts.html style.css Two web pages and one `CSS` file, project almost done. index.html// fully adaptive `contacts.html` adaptive for laptops, tablets, but when I use: @media(max-width: 667px){ } `contacts.html` displayed not in full size: < here is link to web page: < How I should fixed it?
This part of your CSS seems to cause the problem: @media (max-width: 1024px) @media (max-width: 667px) @media (max-width: 1024px) .contacts { padding-left: 180px; padding-right: 180px; } A padding is set to your `.contacts` class. Try removing this padding, as it resizes your `div` element. Also remove the `width: 450px;` from your `.FeedBack`class. Change: .FeedBack { margin-left: 50px; margin-right: 50px; border-radius: 10px; width: 450px; padding: 20px 10px; border: 1px solid lightblue; color: lightgray; } to: .FeedBack { margin-left: 50px; margin-right: 50px; border-radius: 10px; padding: 20px 10px; border: 1px solid lightblue; color: lightgray; }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "html, css" }
How to build a binary tree in O(N ) time? Following on from a previous question here I'm keen to know how to build a binary tree from an array of N unsorted large integers in order N time?
OK, just for completeness... The binary tree in question is built from an array and has a leaf for every array element. It keeps them in their original **index** order, **not value** order, so it doesn't magically let you sort a list in linear time. It also needs to be balanced. To build such a tree in linear time, you can use a simple recursive algorithm like this (using 0-based indexes): //build a tree of elements [start, end) in array //precondition: end > start buildTree(int[] array, int start, int end) { if (end-start > 1) { int mid = (start+end)>>1; left = buildTree(array, start, mid); right = buildTree(array, mid, end); return new InternalNode(left,right); } else { return new LeafNode(array[start]); } }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "algorithm" }
Atmel C compiler manual? I'm just getting started with the Attiny84 on AVR Studio 5 (based off of Visual Studio). However, I cant find the C programmers manual for it so I can figure out how to write ISR's, address GPIO pins, etc... Any ideas where I could find the manual for it?
So the official manual is located here (provided by Atmel Applications Engineer): < It had all the information I needed to get up and running.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "embedded, microprocessors, atmel" }
How to create additional drupal sites with a drush script I'm using **drush site-install** for my initial site, and everything works great, but when I go to try create another site (using table prefixes so I can use the same database), drush attempts to drop and recreate the database, so I loose all the table from my first site. I know how to target drush to a particular subsite, but I'm not sure how to tell the drush site-install command not to drop the database tables. Is there a better way to do this if I want to setup a initial site with 2 additional sites?
Drush has very limited support for table prefixes; site-install is just one of the ways that Drush can fail. sql-sync has similar problems. It would take a lot of work to fully support table prefixes everywhere; it is best and safest to just use multiple databases when using Drush.
stackexchange-drupal
{ "answer_score": 1, "question_score": 1, "tags": "drush" }
How to convert a UTF8 string in a float value in objective-c I here is the problem: I have a NSString that contain "1.7" (for example) and I have to get the float number = 1.7 I' ve tried with `[mystring floatValue]` but the result is 1.700000000004576 If I try with "1.74" the result is 1.74000000000000000067484 how can I fix it? thank you!
Solved! I used sqlite3_bind_text even if my database attribute is FLOAT value and I used mystring instead of myfloat and it work fine! Thank you!
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "objective c, ios4, nsstring, floating point" }
How to kill the X server and end up with a CLI? Is it possible to kill the GUI and end up with a CLI since the GUI runs on the top of the shell? I have check the question below How to kill and to start the X server? Magic keys restarted the GUI and I ended up with the login menu but not a CLI I am using Ubuntu 12.04 , I dont want to use virtual terminal I just want to prove to myself that the GUI runs on top of the shell and I can always exit the GUI to the shell Thanks
To shut down your X session type in the command line: sudo service lightdm stop So you will end up in the virtual terminal #7. You then can hit `Ctrl`+`Alt`+`F1` \- `Ctrl`+`Alt`+`F6` to get a login prompt. For terminal #7 (`Ctrl`+`Alt`+`F7`) there is no tty started because it's meant for the x server. **Edit:** If you want to end of in a shell, then create a file called `/etc/init/tty7.conf` with content: # tty7 - getty # # This service maintains a getty on tty7 from the point the system is # started until it is shut down again. start on runlevel [23] and not-container stop on runlevel [!23] respawn exec /sbin/getty -8 38400 tty7 After creating this file reboot the system, and then when you perform `sudo service lightdm stop` you will end up in a login shell.
stackexchange-askubuntu
{ "answer_score": 3, "question_score": 2, "tags": "xorg" }
Does Firebird support filtered indexes? I am trying to create filtered indexes in Firebird but I cannot find it. Is it possible? I mean indexes that use a portion of rows in the table. It exists in MS SQL Server.
No, Firebird does not have filtered (or partial) indexes. There is an improvement ticket in the Firebird tracker: [Partial Indexes (not partitioning) [CORE3384] #3750]( (pull request), which is likely to become available in Firebird 5.0 (crossing my fingers, as it hasn't been merged yet).
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "firebird" }
Protected in Ruby I have this question: > Class members in Ruby marked as protected > > a. Can only be accessed by the exact instance that owns those members > b. (a), and also any other instances of that class > c. (a), (b), and also any subclasses of that class > d. (a), and any module code imported into that class The answer I'm told is b. But I think it should be c, as a subclass is also an instance of the super class (according to our notes) I was hoping someone with some more Ruby knowledge could help me out.
"A protected method is like a private method in that it can only be invoked from within the implementation of a class or its subclasses. (...)" (The Ruby Programming Language, Flanagan & Matsumoto, page 232) So yes, answer c seems correct.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ruby, protected" }
Steering Rack Clicking Noise My steering wheel on a Mitsubishi Outlander MY2011 is making a clicking noise that seems to come from right tyre (on a RHD). All tie rods and bushes have just been replaced, as was the CV Boot. The suspension was also checked. Here's a video of the noise when driving on an all weather road, while not holding the steering so it's playing from side to side. The video was shot at night, so it's dark. Other than the spring noise, the louder sound is the steering. <
Eventually took apart the rack, and the gear was worn. It had free play and also appears the bearing underneath was worn too. Got a salvage sterring gear and rack and the noise is gone. However, my repair guy was of the opinion that the steering gear was usable for more than 20,000 kilometres and even more. It's worth changing when steering becomes too difficult. Apparently later model Subarus with electric steering are even worse since they fail faster under rough roads and are at least more than 3 times the cost of hydraulic ones. So the owners just live with the noise.
stackexchange-mechanics
{ "answer_score": 2, "question_score": 0, "tags": "steering" }
How to block some url on android browser? How to block some url (site) on android default browser??? I want to restrict user to access some url which are black listed. eg. If i want to block facebook then phone inbuilt app browser will not access this facebook site. Thanks in advance!
Do you want to block some websites on a user's device by letting them install an app? If that is the case, it will only work if they are rooted. If they are, then you could add an entry of the url to the hosts file and redirect it to another ip address (eg 127.0.0.1). But since they need to be rooted, they will probably get a popup asking for permission to access root. This could raise some suspicion with the user. On a device that's not rooted, preventing the standard browser from accessing a certain website is not possible by installing an app.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 7, "tags": "android, browser" }
using Python2 library in Python3/Django1.8 web app I'm trying to use this SDK/API, but it's built for Python2 and I'm working in a Django 1.8.8 / Python 3.5.1 site. I'm sure I could trigger a Python2 script from Python3-Django, but is it safe to pass secure, web-submitted information to it? Is there a better way to handle this altogether? I can't find anything about SecureSubmit in StackExchange, even though it seems to be huge, and I'm not finding much on using mixed Python (Python2 + Python3) libraries at all... Heartland has been around awhile and their SecureSubmit service has APIs for many languages (PHP, .Net, Java, Ruby, Python and nodeJS). If it's better to integrate one of those with my Django site rather than launch a Python2 script, let me know! (I've contacted Heartland, too, but who knows when I'll get a response...) Thanks!
I think it's great you grasped the nettle, I am sure all who use your work will appreciate the ability to use python 3 with this. I am happy to have inspired you to try.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "python, django, credit card" }
Unable to Debug Event Receiver I have create custom content type using that content type I have created list in site. Now trying to develop event receiver on list item events. but now I'm unable to debug the code . ![enter image description here]( **Updated** Here is the message display on break opint ![enter image description here](
Try to do the following to hit your breakpoint * Retract your solution. * Perform `IISRESET`. * Deploy it again. * Set your breakpoint and make sure it's not disabled. * Open SharePoint Portal. * Attached Visual Studio project to the `w3wp.exe` processes * Choose `managed code` in the attach to process dialog. * Try to delete an item from your list , that should hit your breakpoint now.
stackexchange-sharepoint
{ "answer_score": 5, "question_score": 0, "tags": "event receivers, debugging" }
How to get information for fps for a video file in properties menu? (Ubuntu 14.04) I want to find information on fps for video easily, Can I display that in properties menu after right-clicking on file? How to find it?
You can view this in the Audio/Video tab of the Properties window of Nautilus: !enter image description here
stackexchange-askubuntu
{ "answer_score": 1, "question_score": -2, "tags": "file properties" }
What is the function of "Volume up + Volume down" Combo? 1. Phone L535DS 2. OS : W10M(10.0.15047.0-Fast Ring) As we all know `**VolUp` \+ `Power`** combo is designated for taking screenshot and `**VolDown` \+ `Power`** is designated for launching Feedback Hub. But when I press `**VolUp**` and `**VolDown`** buttons simultaneously for three times, a strange thing happens. 1. My phone vibrates three times. 2. Then screen goes black for a very short interval of time. 3. Then return to its previous state. I'm unable to understand what my phone is doing and for what purpose this combo is used. I can't figure out any change or can't see any app launched. **So my question is that what exactly this combo does and for what purpose it is used?**
It is indeed a tickle test (see < ). If you keep pressing `**VolDown` \+ `Power`** you will do a soft reset.
stackexchange-windowsphone
{ "answer_score": 1, "question_score": 8, "tags": "windows 10 mobile, buttons" }
how to get other attributes corresponding an attribute I've got a table with ID information. Now I need to replace them with other attributes(such as name, grade) corresponding to each ID. This is what I have: 1782 1709 1689 1911 1247 1468 This is what I expect: Andrew 10 Cassandra 9 Gabriel 9 Gabriel 11 Alexis 11 Kris 10
So there are two tables, one is Likes, with two attrbutes: ID1,ID2, describing ID1 likes ID2; one is Highschooler, with three attributes: ID, name, grade. The question asks to find out each situation where A likes B, but B likes a different person C, and then return the names and grades of A, B, and C. I found out a solution: select H1.name,H1.grade,H2.name,H2.grade,H3.name,H3.grade from (select Like1.ID1 New1, Like1.ID2 New2, Like2.ID2 New3 from Likes Like1, likes Like2 where Like1.ID2=Like2.ID1 and Like1.ID1<>Like2.ID2) New, Highschooler H1, Highschooler H2, Highschooler H3 where New1=H1.ID and New2=H2.ID and New3=H3.ID;
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "sql" }
Windows Server more vulnerable for password extraction during shutdown? Is a Windows Server (e.g. Windows Server 2008) more vulnerable during the shutdown process compared to the Server is up and running? Does the process of shutting down Windows introduce additional vulnerabilities concerning password dumps/extractions?
In most scenarios, no. In the normal working fine scenario, the processes that could cause sensitive data leaks are ended before the general system processes, so there is no danger here. In the case one such sensitive process is stuck, the OS does not end task the others before action is taken for the stuck one (in this case the well known screen with wait or end task appears). In the case of operating system getting stuck, there can be indeed a problem depending how complete that halt is, but this should not happen on W2008, unless there's some bad hardware involved or really bad software installed (in which case the system is already compromised).
stackexchange-security
{ "answer_score": 4, "question_score": 0, "tags": "password management, vulnerability, one time password, windows server" }
Initialising ' ... *__strong' with an expression of incompatible type 'id<UIApplicationDelegate> _Nullable' I have just updated my copy of Xcode and find that I now have lots of warnings. I am struggling to get the following one sorted out though: ObAppDelegate *appdelegate = [[UIApplication sharedApplication]delegate]; causes this warning: > Initializing `ObAppDelegate *__strong` with an expression of incompatible type `id<UIApplicationDelegate> _Nullable` Can anyone point me in the right direction to fix this warning? For information this is the related code used prior to the problem line: - (NSManagedObjectContext *) managedObjectContext { return [(ObAppDelegate *) [[UIApplication sharedApplication] delegate] managedObjectContext]; }
You have: ObAppDelegate *appdelegate = [[UIApplication sharedApplication]delegate]; This will give a warning: > Initializing `ObAppDelegate *__strong` with an expression of incompatible type `id<UIApplicationDelegate> _Nullable` Rewrite as: ObAppDelegate *appdelegate = (ObAppDelegate*)[[UIApplication sharedApplication]delegate]; That will eliminate the warning.
stackexchange-stackoverflow
{ "answer_score": 29, "question_score": 8, "tags": "objective c, xcode" }
How do I get this small empty box? I'm trying to copy over a question from my math homework to LaTeX, and can't figure out how to replicate this box between `$G_1$` and `$G_2$`: ![enter image description here]( I've tried `\qed`, but that is always preceded with a space: ![enter image description here]( I've tried `\fbox{}`, but it is too low in the line: ![enter image description here]( How do you think my professor achieved the box?
Turns out `$\square$` did the job. D'oh. `$\Box$` also works.
stackexchange-tex
{ "answer_score": 1, "question_score": 1, "tags": "box" }
How to decompile a regex? Is there any way to decompile a regular expression once compiled?
Compiled regular expression objects have a "pattern" attribute which gives the original text pattern. >>> import re >>> regex = re.compile('foo (?:bar)*') >>> regex.pattern 'foo (?:bar)*'
stackexchange-stackoverflow
{ "answer_score": 40, "question_score": 18, "tags": "python, regex" }
Magento 2: Delete data in custom module I need to delete my custom table data, I tried below code, but its not works for me. **my table:** test_id product_id testing 1 15 12345 **my code:** try{ $model = $this->zipcodeFactory->create(); $modelcollection = $this->zipcodeFactory->create()->getCollection(); foreach($modelcollection as $modeldata){ $model->load($modeldata['test_id']); $model->delete(); } }catch (Exception $e){ } Suggest Me What i Miss in this code.
Use `\Magento\Ui\Component\MassAction\Filter` class for massDelete protected $zipcodeFactory; public function __construct( \Magento\Ui\Component\MassAction\Filter $filter, \Vendor\Module\Model\ResourceModel\Class\zipcodeFactory $zipcodeFactory, \Magento\Backend\App\Action\Context $context ) { $this->filter = $filter; $this->zipcodeFactory = $zipcodeFactory; parent::__construct($context); } public function execute() { try { $logCollection = $this->filter->getCollection($this->zipcodeFactory->create()); foreach ($logCollection as $item) { $item->delete(); } echo "Items Deleted"; exit; } catch (\Exception $e) { $this->messageManager->addError($e->getMessage()); } }
stackexchange-magento
{ "answer_score": 2, "question_score": 1, "tags": "magento2, magento 2.1, controllers, resource model, delete" }
Informal relations > Both my prefix prefix, > and my suffix suffix, > became so the same sec, > as my infix infix. What am I?
I am going to guess the answer is > Panama Both my prefix prefix > Papa (informal for father) and my suffix suffix, > Mama (informal for mother) became so the same sec, > When their child was born as my infix infix. > Nana (informal for grandmother)
stackexchange-puzzling
{ "answer_score": 8, "question_score": 10, "tags": "riddle, word" }
see who entered profile with facebook api I have recently see facebook api, I am interested in that. Does Facebook have any API that help me to visit who entered my profile. I want to know is there any way to track who entered my Facebook page.
To build an app that tracks profiles is against the Facebook platform policies. You can read about it in the "Prohibited Functionality" section of their policy guide.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -4, "tags": "facebook" }
Hide number in ordered list if there is only one element in the list Say I have a ordered list like this. <ol> <li>a</li> <ol> Since this ol only has one item, I want to render it as a On the other hand, if there are more than one item in the list like below, I want to render 1., 2.s. <ol> <li>a</li> <li>b</li> <ol> should be 1. a 2. b Is there a way to do this in pure CSS?
li:only-of-type { list-style-type: none; } <h1>List 1</h1> <ol> <li>Coffee</li> <li>Tea</li> </ol> <h1>List 2</h1> <ol> <li>Coffee</li> </ol>
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "html, css" }
What happens when an AC source is connected to a capacitor and a LED? When a DC source is connected to a capacitor and a LED, and the voltage is removed when capacitor is charged, the capacitor supplies current to it for some time. What happens if this DC source is changed to AC source. Don't hate.:)
Because an LED acts like a diode, the negative current from the AC source will be clipped and the capacitor will always be charged and it will act like a second voltage source. Look at my picture below. You can see that the green line represents the voltage going through the capacitor and the blue line (it's a little hard to see since it's covered up by the green line) is behaving the same way as it represents the voltage across the LED (or the output voltage). ![enter image description here](
stackexchange-physics
{ "answer_score": 3, "question_score": 0, "tags": "electric circuits, capacitance, light emitting diodes" }
Loading external .bundles on iPhone I would like to add resource files to a .bundle and push them to my application and it seems to work fine in the simulator but fails to build when I change to the device. > /Users/sosborn/Projects/MyPro/build/Debug-iphoneos/FooBar.bundle: object file format invalid or unsuitable I don't want to load any code or anything, just plain text and jpegs and it would be nice to be able to package them as dependencies.
I found a better solution to my problem. It actually doesn't require the use of bundles at all. I just created an aggregate target instead of a bundle target. Then I added a copy step and a script step. The copy step contains all of the resources I had in the bundle target and the script step actually zips up the files. Then when I download the content into my application I can just unzip it and use it just as if it were a bundle since I'm just storing resource dependencies. Thanks for your help.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "iphone" }
How to make imageview constantly spin? <ImageView android:id="@+id/imageView1" android:layout_width="300dp" android:layout_height="300dp" android:src="@drawable/zaid1" android:layout_centerVertical="true" android:layout_centerHorizontal="true" /> I have an imageview in the middle of an activity, how would I make it so it rotates 360 degrees endlessly?
Try to use `RotateAnimation`: RotateAnimation rotateAnimation = new RotateAnimation(0, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation.setInterpolator(new LinearInterpolator()); rotateAnimation.setDuration(500); rotateAnimation.setRepeatCount(Animation.INFINITE); findViewById(R.id.imageView1).startAnimation(rotateAnimation);
stackexchange-stackoverflow
{ "answer_score": 25, "question_score": 9, "tags": "android, imageview, spin" }
Measurability and continuity for general topological spaces Let $(X,\tau)$ be a topological space. We call $S\subseteq X$ _saturated_ if $S=\bigcap\\{U\in\tau: U\supseteq S\\}$. Let $\sigma(X,\tau)$ be the $\sigma$-algebra generated by $\tau\cup\\{K\subseteq X: K \text{ is compact and saturated}\\}$. Let $(X_i, \tau_i)$ be topological spaces for $i=1,2$. A function $f:X_1\to X_2$ is said to be _measurable_ if $S\in \sigma(X_2,\tau_2)$ implies $f^{-1}(S)\in\sigma(X_1,\tau_1)$. Are there topological spaces $X,Y$ and a continuous function $f: X\to Y$ such that $f$ is not measurable in the above sense?
I'm assuming that by "compact" you only mean which satisfies the finite cover properties, and not compact and Hausdorff. in this case the following produces a counterexample: Let $X_1$ be $\mathbb{R}$ with the ordinary topology, (and assume that there is at least one non Borel subset of $\mathbb{R}$...). Let $X_2$ be $\mathbb{R}$ with the co-finite topology. then the identity map from $X_1$ to $X_2$ is continuous, but any subset of $X_2$ is saturated and compact hence in the tribe you define.
stackexchange-mathoverflow_net_7z
{ "answer_score": 3, "question_score": 2, "tags": "gn.general topology, measure theory" }
Test or check if sheet exists Dim wkbkdestination As Workbook Dim destsheet As Worksheet For Each ThisWorkSheet In wkbkorigin.Worksheets 'this throws subscript out of range if there is not a sheet in the destination 'workbook that has the same name as the current sheet in the origin workbook. Set destsheet = wkbkdestination.Worksheets(ThisWorkSheet.Name) Next Basically I loop through all sheets in the origin workbook then set `destsheet` in the destination workbook to the sheet with the same name as the currently iterated one in the origin workbook. How can I test if that sheet exists? Something like: If wkbkdestination.Worksheets(ThisWorkSheet.Name) Then
Some folk dislike this approach because of an "inappropriate" use of error handling, but I think it's considered acceptable in VBA... An alternative approach is to loop though all the sheets until you find a match. Function WorksheetExists(shtName As String, Optional wb As Workbook) As Boolean Dim sht As Worksheet If wb Is Nothing Then Set wb = ThisWorkbook On Error Resume Next Set sht = wb.Sheets(shtName) On Error GoTo 0 WorksheetExists = Not sht Is Nothing End Function
stackexchange-stackoverflow
{ "answer_score": 232, "question_score": 149, "tags": "excel, vba" }
Python - Add Formatted Number To String Using Python v2, I have the following code: print ("Total of the sale is: ${:,.2f}".format(TotalAmount)) This is taking the string called "TotalAmount" and formatting it so that it looks like this: $100.00, ie: a monetary value, no matter what the number is. Is there a way to write the formatted output to a string? Thanks for any help.
yourVar = "Total of the sale is: ${:,.2f}".format(TotalAmount)
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "python, string, format" }
Perl Readbackwards and gzipped files I want to read backwards line by line from a gzipped file. I know about the ReadBackwards module, but how do can I make it work on a gzipped file? Is there a different module I should be using?
Why do you want to read it backwards? There is no performance boost from trying to read a compress file backwards. You must first decompress it (to understand what byte n means you must first have decompressed bytes 0 .. n). You probably aren't going to get better in terms of speed than: #!/usr/bin/perl use strict; use warnings; die "usage: $0 filename" unless defined(my $file = shift); open my $fh, "<:gzip", $file or die "could not open $file: $!"; my @lines; while (<$fh>) { push @lines, $_; shift @lines if @lines > 10; } print @lines;
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 2, "tags": "perl, gzip" }
C# WCF Methods OperationContract In WCF, methods or functions that aren't marked as `OperationContract` won't be read or presented as service methods. But what if I used for example: [ServiceContract] public interface IService1 { void Connect(); [OperationContract] DataTable SelectData(string Proc, SqlParameter[] param); } Then I used the `Connect` method in the `SelectData` function that it needs a connection provided by the `Connect` method, will it still work? I'm using the WCF services in a Windows Phone application. The main question is: should I work only on the classes `IService1`/`Service1` and put all my functions and methods on, or can I add classes for example Ip1/p1 ?
The `IService1` interface is your **contract** with the outside world - what the outside world (other code) can see and call. How you **implement** that internally is totally up to you and doesn't matter to the outside world. So if you need helper methods and classes, just **go ahead** and create and use them!! No harm in doing so! But that's just the "inside" world of your service implementation - the outside world doesn't know nor care about how this is implemented in detail - the outside world (the code calling your service) **_only_** knows (and cares) about the contract defined by the interface.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c#, wcf" }
How does a mobile WordPress theme differ from a simple theme? 1. What should be taken care of while coding a mobile theme as compared to a simple one? 2. Is there any tutorial available that teaches how to develop a **mobile** theme from scratch?
It's really not a "wordpress" specific, it's just the css. You just give it a css for mobile browsers. That's it. here are few good readings on how to get about the css for mobile: * < * < if you still have some questions, feel free to ask. ;)
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "theme development, mobile" }
How to make a two way table from 2 numpy arrays? I have 2 numerical arrays from numpy, `A` and `B` of length `i` and `j` (`i != j`). I want to make a two-way table with them to compute the difference for each element of `B` with all the elements of `A`. I know how to compute the difference between each element using for loops, but this prevents me from knowing from which elements `B[i]` and `A[j]` the `C[i][j]` difference was calculated (which I need for further analysis). I assume this table can be easily created with pandas but don't know which function or how to implement it. Thanks in advance.
Is this what you're looking for? import numpy as np # Sample data x = np.random.randint(0,10,5) y = np.random.randint(0,10,3) diff_matrix = x[:,None]-y[None,:] And you get: In [1]: print(x) [2, 8, 0, 8, 8] In [2]: print(y) [7, 0, 6] In [3]: print(diff_matrix) [-5, 2, -4], [ 1, 8, 2], [-7, 0, -6], [ 1, 8, 2], [ 1, 8, 2]] So `diff_matrix[i,j]` is `x[i]-y[j]`
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python, python 3.x, numpy" }
Scala: Is it possible to remove implicit context in the function? Suppose, I have a signature like this: def mergesortT (implicit ord: T => Ordered[T], man: Manifest[T]): Array[T] = { //... } Is it possible to throw away the implicit part `(implicit ord: T => Ordered[T], man: Manifest[T])` and keep function working? I can use `T <% Ordered[T]` but in that case I still need `man: Manifest[T]`.
You can write: def mergesort[T <% Ordered[T] : Manifest](xs: Array[T]): Array[T] = { //... } but understand that you are not actually "getting rid of" the implicit argument list, you are just hiding it using syntactic sugar. The compiler will simply (in effect) convert this internally into the original form.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "scala" }
How do I avoid Race Conditions in UnrealScript? I'm trying to create a pseudo turn based battle system in the Unreal Engine (think Final Fantasy style). I'm trying to avoid the Enemies and the players attacking while another animation is in progress. I thought the most simple solution is to have a flag somewhere that the player controllers check before starting an animation, and set it to a value before they start, and then reset it when they've finished. However, I could see this leading to race conditions if two controllers (AI or player) try to access the variable at the same time, then both start their animations. If I was writing this in Java I'd obviously use synchronized methods, but I haven't come across anything like that in UnrealScript. Is there another way to avoid this? Its probably not the end of the world, as its a pretty unlikely occurance, but I'd like to try and avoid it completely if possible.
> obviously use synchronized methods, but I haven't come across anything like that in UnrealScript Unreal script is only allowed and runs only in the main-thread, so there is no need to add synchronization objects to Unreal Script. In other words, two lines of script code can never access a variable at the same time from different threads, so no worries about race conditions in Unreal Script :)
stackexchange-gamedev
{ "answer_score": 5, "question_score": 1, "tags": "udk, unreal" }
python if condition and "and" >>> def foo(a): print "called the function" if(a==1): return 1 else: return None >>> a=1 >>> if(foo(a) != None and foo(a) ==1): print "asdf" called the function called the function asdf Hi. how can i avoid calling the function twice without using an extra variable.
You can chain the comparisons like this if None != foo(a) == 1: This works like if (None != foo(a)) and (foo(a) == 1): except that it only evaluates foo(a) once.
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 5, "tags": "python" }
Generate multiple renders of same scene, each at a different resolution? I would like to generate several renders of a static scene, each render being a different size (eg `1024x1024`, `512x512` etc). Other than the size, each render will be identical. Is there a way of doing this using, say, the command line, or a script? I am currently doing this by manually changing the dimensions within the render panel every time, but I was wondering if there's a quicker way. I am using Blender Internal in this specific instance. Many thanks
Yes, there is a way to do this from one blender file. You have to create new _Scenes_ , using the _Link Objects_ method (available from the _Info_ header) then you can change the render settings just like you normally would. (Also see Can I set render settings by individual scenes? for more info about scene copying options.) !enter image description here !enter image description here !enter image description here **Note:** * As previously mentioned by tobkum, in your case where the resolutions sizes are multiples of one another you might be better off just rendering out the largest one and then re-sizing the smaller ones. * As previously mentioned by gandalf3, you can also make sure you have a large enough render to encompass all the different sizes/aspect ratios, then crop/scale in the compositor. After doing this, you can automate rendering these by batch rendering multiple scenes from the command line.
stackexchange-blender
{ "answer_score": 8, "question_score": 8, "tags": "rendering, scene" }
Prolog discarding permutation I haven't been able to discard repetition permutations.For example, I want to get ?-permutation([1,2,1],L). L = [1, 2, 1] ; L = [1, 1, 2] ; L = [2, 1, 1] ; . but i am getting ?-permutation([1,2,1],L). L = [1, 2, 1] ; L = [1, 1, 2] ; L = [2, 1, 1] ; L = [2, 1, 1] ; L = [1, 1, 2] ; L = [1, 2, 1] ; .
I think the simpler way could be perm_no_rep(L, P) :- setof(P, permutation(L, P), Ps), member(P, Ps). it's almost ok: ?- perm_no_rep([1,2,1],P). P = [1, 1, 2] ; P = [1, 2, 1] ; P = [2, 1, 1]. beware that will be `factorial(Num_Distinct_Elements_in_L) = length(Ps)` i.e. possibly very large lists.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "prolog" }
Admin Panel Save button is unresponsive in Manage Products menu and other places We just migrated our application from our development environment to the UAT server that runs on the cloud. After deploying all the files and setting up the magento pages everything seemed to work fine. The only issues seem to be in the magento admin panel, Catalog -> Manage Products menu when i am trying to add product and save it is unresponsive. nothing happens. Infact the save option is not responding in alomost all of the magento admin panel pages. Any help would be appreciated
This should probably be a javascript issue. You should try replacing the prototype.js file with the one that you have used in the test environment.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "php, magento" }
Cordova add custom framework - Link errors I'm trying to add a custom framework to the plugin I'm building. The issue is that the header file has dependencies to my framework folder If I do it like this, I have an issue because it can't find the framework at runtime. <source-file src="src/ios/my.framework" framework="true"/> If I do it like this I have linker errors <framework src="src/ios/my.framework" custom="true" embed="true" /> I could fix it manually on xCode, but I require when adding the plugin, to be automatically working. any suggestions on how to solve this? Thanks
Can you include both the header-file and framework lines? I have plugins that include native frameworks and reference them from the plugin implementation. <header-file src="src/ios/SomePlugin.h" target-dir="SomePlugin" /> <source-file src="src/ios/SomePlugin.m" target-dir="SomePlugin" /> <framework src="SomeSDK" type="podspec" spec="~> 1.9.9"/> Before CocoaPods I'd do something like <framework src="lib/SomeSDK.framework" custom="true"/>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "ios, cordova, plugins" }
Firebase JavaScript SDK - Retrieve Users IP Address Assuming my browser script automatically signs any user in anonymously, is it possible to collect the users public IP address? I found the `firebase.auth().currentUser.metadata` property but it only includes `LastSignInTime` and `creationTime`. Is the users public IP address available via the Firebase authentication (or any part of the Firebase JavaScript API) system?
Firebase Authentication does not expose IP address as part of the user record, nor is it exposed anywhere in the client side SDKs. You will need a backend to record that for yourself.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "firebase, firebase authentication" }
Where is the code for the PrimeFaces datatable csv export? I'm looking at some java code which exports csv & Excel from a PrimeFaces datatable. I've actually not quite got it up and running yet so can't debug, just was having a quick looksee. Oddly it's relatively clear what is going on for Excel & PDF (excel-type-excel- _.jar & excel-type-pdf-_.jar) but I can't find any reference to the presumably default code which exports the plain old csv file. It doesn't seem to be in jsf-exporter-core or the export-source-primefaces*.jar which seem to expect a IExportType object - IExportType exporter @Override public void exportData(DataTable source, DataTableExportOptions configOptions, IExportType<?, ?, ?> exporter, FacesContext context) throws Exception { This is a bit of a outside shot but I just wondered if anyone could tell me where I should look for the code doing (presumably the default) csv type export ?
The code is right here in GitHub as contains all the classes that do the exporting. < However since you mentioned "excel-type-excel-.jar & excel-type-pdf-.jar" are you sure the code you are looking at isn't using a custom exporter and not the PF built in exporter? To me is sounds like it might be a mix because I have never heard of either one of those JAR files.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "csv, jsf, primefaces" }
How do I reverse filter a visual? I am trying to filter a visual so that all values are included except the ones I specify, I know I can filter normally by selecting all values and then de select the oens I dont want, but this is not feasible I need an easier way to exclude some values from the visual as a filter. For example one table holds string values A,B,C,D,E,F and I want to show in the visual all values apart from A and B. How can I do this so that I specify the A and B as opposed to electing all the other values I want, because they could be 10 000s
I believe you can use the NOT IN { List } Something like: FORMULA = CALCULATE( [MEASURE] , NOT (Table[Column] IN { "A", "B" }))
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "powerbi, powerbi desktop" }
Truststore and Keystore Definitions What's the difference between a keystore and a truststore?
A keystore contains private keys, and the certificates with their corresponding public keys. A truststore contains certificates from other parties that you expect to communicate with, or from Certificate Authorities that you trust to identify other parties.
stackexchange-stackoverflow
{ "answer_score": 300, "question_score": 317, "tags": "keystore, encryption asymmetric, truststore" }
bounds for conditional expectation and variance let X and Y be random variables with density: $$f_{x,y}(x,y)=\frac{1}{\pi}\mathbf{1}_{\\{x^2+y^2\le1\\}}$$ Find $$E[X|Y] \& Var(X|Y)$$ So what I did was: $$E[X|Y]=\int_{-\sqrt{1-y^2}}^{\sqrt{1-y^2}}\frac{x}{2\sqrt{1-y^2}}dx=0$$ $$Var(X|Y)=\int_{-\sqrt{1-y^2}}^{\sqrt{1-y^2}}\frac{x^2}{2\sqrt{1-y^2}}dx=-\frac{y^2-1}{3\sqrt{1-y^2}}$$ Does this seem right? I'm not sure about the bounds I used to get the marginal distributions.
The variance is wrong. But without a lot of calculations, when you got your conditional density $f_{X|Y}(x|y)=\frac{1}{2\sqrt{1-y^2}}$ $-1\leq y \leq 1$ You can observe that this is a Uniform$(a;b)$ distribution $$(X|Y)\sim U(-\sqrt{1-y^2};\sqrt{1-y^2})$$ Then you can calculate * mean as: $\frac{a+b}{2}=0$ * variance as: $\frac{(b-a)^2}{12}=\frac{1-y^2}{3}$
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "probability, conditional probability, variance" }
How to refresh div onclick in jquery? I'm new to jquery programming. I was curious if there is a way to refresh div on button click? I only know window.location.reload() method, but it refreshes my whole page. <div id="container"> <div id="content"> <p style="border: 2px solid black"> What's up? </p> </div> <button>Refresh DIV</button> </div>
Here is some example: var storeColor = 'red'; $('#container').on('click', 'button', function() { var $p = $('#content p'); var tmp = $p.css('border-color'); $p.css('border-color', storeColor); storeColor = tmp; }); <script src=" <div id="container"> <div id="content"> <p style="border: 2px solid black"> What's up? </p> </div> <button type="button">Refresh DIV</button> </div>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, jquery, html, css" }
Calculate complete function from imaginary part in raman response When I want to calculate the raman response function $R$ from the molecular responses $g_a$ and $g_b$, I have to use the functions $$g_n(\Omega) = 2\gamma f_r\text{Im}\left[\tilde{R}_n\left(\Omega\right)\right]\text{ with } n = a, b$$ $\tilde{R}$ is the fourier transformation of $R$. My problem is now that thanks to several papers I know that I can calculate $g_n$ if I have $R$, but I do not know how to calculate $R$ if I have $g_n$, because of the $\text{Im}[]$-part. Is there a way to calculate the real part of $\tilde{R}$ out of $g$ somehow?
This sounds very much like you want to use Kramers-Kronig relations to relate the real and imaginary parts of the Raman response function. Now I don't much care for the Wikipedia entry on Kramers-Kronig but it is a start. I prefer either Boyd's Nonlinear Optics (most other discussions will only cover the linear case). This article Kramers–Kronig relations and resonance Raman scattering Hassing, S. and Mortensen, O. Sonnich, The Journal of Chemical Physics, 73, 1078-1083 (1980), DOI:< seems like it would be a good start too.
stackexchange-physics
{ "answer_score": 1, "question_score": 0, "tags": "raman spectroscopy" }
java while and for loops dilemma I m working on this example and I cannot seem to figure what i am doing wrong. public class NestedLoop { public static void main(String[] args) { int userNum = 0; int i = 0; int j = 0; while (j <= userNum) { System.out.println(j); ++j; for (i = j; i <= userNum; ++i) { System.out.print(" "); } } return; } } The result is below. as you can see my result is backward and I am not sure what I am doing wrong. I have tried to change the variables all around and I am not getting any where. any help will be greatly appreciate. Expected output: 0 1 2 3 Your output: 0 1 2 3 Thanks
You are using `userNum` to increment which is wrong and increment `j++` after spaces return. You can also remove the return statement. Corrected code: public class NestedLoop { public static void main(String[] args) { int userNum = 3; int i = 0; int j = 0; while (j <= userNum) { System.out.println(j); for (i = 0 ; i <= j; ++i) { System.out.print(" "); } ++j; } } }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "java" }
JQuery .hide & .show occupy space even is hide <script async src="//jsfiddle.net/andersonkoh/y6s9esnh/2/embed/"></script> As you can see, when I select request then **.show my** **.request-row** but it goes down and when I right click > Inspect in browser it show that **.enquiry-row** is hidden but occupy the space. How do I make it in the same line without pushing it go down?
You should hide this itself `<div class="col col-6">` rather than hidding element which is inside the `<div class="col col-6"><div id="enquiry-row" style="display:none;"></div></div>`, in your case `class="col col-6"` this take the space of the element. So it should like this `<div class="col col-6" id="enquiry-row" style="display:none;"><div></div></div>`. Here is the **JSFIDDLE**
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "jquery, css, html, bootstrap 4" }
How to convert Bitmap image to byte array in wp7? using (MemoryStream ms = new MemoryStream()) { image.CreateOptions = BitmapCreateOptions.None; image.UriSource = new Uri("/Images/chef.png", UriKind.Relative); WriteableBitmap LoadedPhoto = new WriteableBitmap(image); LoadedPhoto.SaveJpeg(ms, LoadedPhoto.PixelWidth, LoadedPhoto.PixelHeight,0,95); ms.Seek(0, 0); byte[] data = new byte[ms.Length]; ms.Read(data, 0, data.Length); ms.Close(); } I am getting NullReferenceException at image, but my path is also correct and image also exists. WriteableBitmap LoadedPhoto = new WriteableBitmap(image); Is anything goes wrong.
Please Refer the solution. which shows the solution to converting the bitmapimages to byte array. I hope you will understand.. conversion of bitmapimage to byte array Refer this link..
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, visual studio 2010, windows phone 7" }
Negative dimension size caused by subtracting 5 from 4 I am trying to add another layer in my model but I am getting an error. It works great with 2 layers but when adding another I get the error message Negative dimension size caused by subtracting 5 from 4 My code: model = tf.keras.models.Sequential([ tf.keras.layers.Conv2D(32, kernel_size=(5, 5), input_shape=(28, 28, 1)), tf.keras.layers.MaxPool2D(), tf.keras.layers.Conv2D(64, kernel_size=(5, 5)), tf.keras.layers.MaxPool2D(), tf.keras.layers.Conv2D(128, kernel_size=(5, 5)), tf.keras.layers.MaxPool2D(), tf.keras.layers.Flatten(), tf.keras.layers.Dense(1024, activation="relu"), tf.keras.layers.Dropout(0.2), tf.keras.layers.Dense(10, activation=tf.nn.softmax) ])
Each convolution or pooling layer reduces the size of your input. The MaxPool cuts it in half (in each dimension); the Conv2D reduces it by one less than the size of the window for the convolution. So your 28x28 input becomes 24x24 after the first Conv2D, then 12x12 after the first MaxPool, then 8x8 after the second ConvD, then 4x4 after the second MaxPool. So it's now a 4x4, to which you're trying to apply a third 5x5 Conv2D.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, keras, neural network" }
SharePoint time field value using jQuery I am trying to get the time selected from SharePoint list and store it one variable. I have attached an image for reference, Can anyone help me with this?![enter image description here](
No need to use the jquery, you can do that using vanilla JS `querySelector` var time = document.querySelector("selectid='Scheduled_x0020_time_0c63521b-1292-45ae-a881-f85e14c83ca7_$DateTimeFieldDateHours'").value + ":" + document.querySelector("select[id='Scheduled_x0020_time_0c63521b-1292-45ae-a881-f85e14c83ca7_$DateTimeFieldDateMinutes'").value console.log(time); Explanation, The `datetime` field has two select controls to show the time value * `DateTimeFieldDateHours` for **Hours** * `DateTimeFieldDateMinutes` for **Minutes** So you are trying to query the selector with the actual ID `id=`, or using contains `id=^` then try to concatenate both values to get the desired value as shown below. **Output** [![enter image description here](
stackexchange-sharepoint
{ "answer_score": 1, "question_score": 0, "tags": "sharepoint online, jquery" }
How to randomly discard a number of elements in a set using Python? for example, I have this Set object: `a = {0,1,2,3,4,5}` how to randomly remove fixed number of elements from this set?
To remove 2 random elements, sample 2 random elements, then remove them: a.difference(random.sample(a, 2)) or just sample two elements less than the size of the set: set(random.sample(a, len(a) - 2)) If you want a destructive operation (so that `a` changes), you can use `difference_update` on it instead: a.difference_update(random.sample(a, 2))
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 1, "tags": "python, data structures, set" }
Use the results of an Excel formula in another formula as a cell indexer I have a basic formula: =(RANDBETWEEN(1,20)) which gives me a value, what I want to do is take that value (for the sake of argument '12') and use it to get another cell via another formula, i.e. =(RANDBETWEEN(1, B<result>)) where `B` is the column, `<result>` is the result of the first formula. Can this be done? (I'm using Excel 2013)
Try using INDEX, so if you have the `=RANDBETWEEN(1,20)` formula in cell D1 you can use this formula in another cell `=RANDBETWEEN(1,INDEX(B:B,D1))` If the first formula returns 12 then the INDEX part will return the value from B12 If you don't want the first formula in a cell you can use it directly in the second formula like this: `=RANDBETWEEN(1,INDEX(B:B,RANDBETWEEN(1,20)))`
stackexchange-superuser
{ "answer_score": 3, "question_score": 5, "tags": "microsoft excel" }
How do I correct/set/syncronize time on Watchguard Firebox X500? Looking at the logs on my firewall in realtime it appears that the time is slow by about 13 minutes. I might not have noticed but I'm troubleshooting a lan to lan VPN connection. It may be purely cosmetic or it might actually be an issue if the time is too far out of synch. Either way I'd like to correct the time on the firewall. Can anyone tell me how to do so?
For your model I believe the system time gets set from the log host, so you'll need to install and configure a log host in order to set the time.
stackexchange-serverfault
{ "answer_score": 2, "question_score": 1, "tags": "firewall, watchguard, firebox" }
Amazon S3 with s3fs and fuse, transport endpoint is not connected Redhat with Fuse 2.4.8 S3FS version 1.59 From the AWS online management console i can browse the files on the S3 bucket. When i log-in (ssh) to my /s3 folder, i cannot access it. also the command: "/usr/bin/s3fs -o allow_other bucket /s3" return: s3fs: unable to access MOUNTPOINT /s3: Transport endpoint is not connected What could be the reason? How can i fix it ? does this folder need to be unmount and then mounted again ? Thanks !
Well, the solution was simple: to unmount and mount the dir. The error `transport endpoint is not connected` was solved by unmounting the s3 folder and then mounting again. **Command to unmount** fusermount -u /s3 **Command to mount** /usr/bin/s3fs -o allow_other bucketname /s3 Takes 3 minutes to sync.
stackexchange-stackoverflow
{ "answer_score": 59, "question_score": 27, "tags": "amazon web services, amazon s3, mount, s3fs" }
Any way to keep an html button pressed? I have a button `<input type="button" name="name" value="value"/>`. Is there any way to keep it visually pressed and unpress it via javascript? Thanks
I would try CSS and use the border-style `inset`, personally. <input type="button" value="Inset Border" style="border-style:inset;" /> For a list of different styles, please see this jsFiddle.
stackexchange-stackoverflow
{ "answer_score": 23, "question_score": 25, "tags": "javascript, html" }
REST service for intranet and internet scenarios I am developing a web application which uses REST services. The requirement is that 1. REST service has to be exposed to public 2. Consumed by web application The web application & REST service are two different war files. But will be deployed in same application server. Since the REST service is deployed in the same server, instead of using ` URI, can I use some different approach for better performance? I meant, instead of using HTTP is it possible to use TCP or some other methodology so that performance will be good, because both applications are deployed in same server.
If you use typical REST approach (like Resteasy, which is JAX-RS implementation) you are bound to use HTTP - it is by design, all that GET/POST, content type stuff is connected with HTTP communication handling. If these two applications has to interact, then you can consider usage of Java Messaging Service (JMS) or Hessian or plain Java Sockets for inter-application communication and relay on Resteasy for exposing external API.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "jakarta ee, jboss7.x, resteasy" }
Why can't set `document.getElementById` to be global variable? For the code structure here var mydo=sessionStorage.getItem("action"); function to_delete(){ var _table=document.getElementById("showTable"); //omit } window.onload=function(){ to_delete(); } I get desired result. Now rewrite the code structure as below: var mydo=sessionStorage.getItem("action"); var _table=document.getElementById("showTable"); function to_delete(){ //omit } window.onload=function(){ to_delete(); } An error occur, `TypeError: _table is null`. Why can't set `document.getElementById` to be global variable?
In your rewrite `var _table=document.getElementById("showTable");` runs before the document loads so the element does not exist. Instead declare the global `var _table;` outside the function and assign to it in the load event.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "javascript" }
Youtube iframe API - resetting volume I created an embedded iframe with the api and set the volume to zero. I use a script to change the source of the iframe, and noticed that the volume goes back to full. I tried attaching `player.setVolume(0);` to the script to execute each time the source of the iframe is changed, but I'm getting an error that endlessly repeats a few times per second, constantly: `Unable to post message to Recipient has origin www-widgetapi-vflXx2oJO.js:26 g.A www-widgetapi-vflXx2oJO.js:26 g.F www-widgetapi-vflXx2oJO.js:25` this is the exact script: $("#channel-1").click(function(){ $("#tv").attr("src", channel1); $(".mid-bar").text("TNT"); player.setVolume(0); }); where #tv is the iframe element generated by the youtube iframe api. **What's a better way to change the video source while keeping the volume at 0?**
Instead of $("#tv").attr("src", channel1); Try player.cueVideoById(channel1); (or `player.loadVideoById` if you want it to autoplay) That should load a new video into the existing player, keeping all other player parameters the same (including any event listeners you've set up).
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, youtube api, youtube iframe api" }
How to insert multiple elements into a list? In JavaScript, I can use `splice` to insert an array of multiple elements in to an array: `myArray.splice(insertIndex, removeNElements, ...insertThese)`. But I can't seem to find a way to do something similar in Python _without_ having concat lists. Is there such a way? (There is already a Q&A about inserting single items, rather than multiple.) For example `myList = [1, 2, 3]` and I want to insert `otherList = [4, 5, 6]` by calling `myList.someMethod(1, otherList)` to get `[1, 4, 5, 6, 2, 3]`
To extend a list, you just use `list.extend`. To insert elements from any iterable at an index, you can use slice assignment... >>> a = list(range(10)) >>> a [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> a[5:5] = range(10, 13) >>> a [0, 1, 2, 3, 4, 10, 11, 12, 5, 6, 7, 8, 9]
stackexchange-stackoverflow
{ "answer_score": 105, "question_score": 45, "tags": "python, list, insert" }
how to handle React axios how to handle net::ERR_CONNECTION_REFUSED It was asked before, but if I follow the solution still in the console there is an uncouth error:- getExchangeAmount(){ var url = ' '&exCurrency='+this.state.excurrency+'&amount='+this.state.amount axios.get(url) .then(response => { // success this.setState({result: response.data}) }) .catch((error) => { // handle this error console.log('error: '+error); }) } in the console:- > GET net::ERR_CONNECTION_REFUSED The above is in red which is an error. how to avoid or catch this?
if you are using a node server so install **cors** package on the server side: npm i cors --save in index.js of server side: const cors= require('cors'); app.use(cors()); then your code shall work.. if you are not using a node server so try this: getExchangeAmount(){ var url = '/excurrency?currency='+this.state.currency+ '&exCurrency='+this.state.excurrency+'&amount='+this.state.amount axios.get(url) .then(response => { // success this.setState({result: response.data}) }) .catch((error) => { // handle this error console.log('error: '+error); }) }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "reactjs, axios" }
is there a TranslateAnimation onComplete? I am animating a view to move off the screen, on complete i would like to call another function but I cant seem to find a onComplete method. int originalPos[] = new int[2]; icons.getLocationOnScreen( originalPos ); layoutMoved = originalPos[0]+icons.getWidth(); TranslateAnimation anim = new TranslateAnimation( 0, -layoutMoved , 0, 0); anim.setDuration(500); anim.setFillAfter( true ); icons.startAnimation(anim); icons.setVisibility(View.GONE);
Set an AnimationListener, you'll have access to OnAnimationEnd. anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { // do your stuff } @Override public void onAnimationRepeat(Animation animation) { } });
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "android, animation" }
Playing m3u8 form local storage We want to play m3u8 with ts files stored locally on SD card in Android 4.0 and above devices. I tried using video TAG inside HTML residing locally on the SD card and android native media player. Both the codes are failing with the error. The same set of ts and m3u8 files are working fine when played from online when served from a webserver connected through http. Can we play m3u8 using native support for files stored offline or do we need to use 3rd party libraries. I searched in internet and didn’t find article about not supporting the same. Any help or recommendation would help my work. Thanks a lot
**Issue Solved** we used nano http server to serve m3u8 file to with all videos parts. Very simple and easy way to play m3u8 video file.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "android, media, m3u8" }
How to update multiple tables in kdb Say I have a list of tables. (`sym1, sym2, sym3` etc) How would I add a new column to each table called `Sym` containing the table name? Thank you
Another way to achieve this : q){update Sym:x from x}each `sym1`sym2`sym3 q)raze (sym1;sym2;sym3) p s Sym ---------------- 2.08725 75 sym1 2.065687 6 sym1 2.058972 63 sym2 2.095509 62 sym2 2.036151 90 sym3 2.090895 63 sym3 If you are getting these tables (`sym1,sym2,sym3`) as the output of another function call like : f each `s1`s2`s3 then I'll suggest updating the function to add the column `Sym` just before return these individual tables. f:{ /some logic update Sym:x from t } This will save an operation of adding a new column separately
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "kdb" }
MySQL pivot table - NOT IN In a MySQL database I have the following tables: **customers** CUSTOMER_ID | NAME --------------------------- 1 | John Doe 2 | Peter Jones 3 | David Smith **products** PRODUCT_ID | DESCRIPTION --------------------------- 1 | Toothbrush 2 | Shaving cream 3 | Deodorant **customer_product** CUSTOMER_ID | PRODUCT_ID --------------------------- 1 | 2 1 | 3 2 | 1 3 | 1 3 | 2 The table **customer_product** is a pivot table. When a customer orders a product, it will be logged there. My question is: how can I select all customers that didn't ordered a certain product? So for example, I want to retrieve all customers that never ordered a Toothbrush.
You can use `NOT EXISTS`: SELECT CUSTOMER_ID,NAME FROM customers AS c WHERE NOT EXISTS ( SELECT 1 FROM customer_product AS cp INNER JOIN products AS p ON cp.PRODUCT_ID= p.PRODUCT_ID WHERE p.DESCRIPTION = 'Toothbrush' AND cp.CUSTOMER_ID = c.CUSTOMER_ID)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "mysql, pivot table" }
Magento Seems Incomplete is it? I downloaded and installed magento on xampp by bitnami. Here is a screenshot of what i can see once i open localhost/magento : !enter image description here I was watching a video on youtube about magento but he had a bit different view: !enter image description here So what i wanted to know was, is my install incomplete? because it lacks the main content it just has the side bar content and the top bar. (Note: In the video the guy had also said that all that was pre-made and he did not add any of that himself) What is it? and if it comes automatically how do i add it? re-install?
Yes that guy did not enter all that himself but he uses the sample data provided by magento itself. Magento has a sample data archive available that contains sample products and CMS pages to allow you to explore your new Magento installation without having to create everything from scratch. Note: You cannot install that sample data now. You need to re-install with some more steps. Here is the magento page about all this.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "magento" }
Dynamic Arrays in Excel not Spilling I just bought a new computer and installed Windows 10 and latest version of office 365 Home. When I use dynamic arrays in Excel there is suddenly no longer any spill which creates issues since I use files with macros that are adapted after the typical behavoir of dynamic arrays. I can type in a dynamic array and values appear like before. But instead of "spilling" values to neigbouring cells excel instead pastes values into those cells. There is also no longer any gray text in the formula bar and if I delete the original cell which contains the dynamic array formula all other cells remain. I havent changed any of the files and have tried to reinstall excel without success. I also cant find any other that previously have reported this issue. Any suggestions on how to solve this?
Thx for the quick input. I found out what the issue was thanks to your clarifying questions. The sequence formula turned out to work as expected which excluded that it was an issue with Excel. The formulas I was using was instead related to an excel plugin called "Börsdata". And although I've installed it like before this time the initial settings turned out to be different. After changing the settings to "show data as dynamic array" it now works as expected.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "excel, office365, dynamic arrays, spill range" }
How can I implement a local testing database for my Azure Website? I have a website I'm developing that uses an SQL Azure database. I want to be able to test my website using a database locally hosted on the debugging machine so that my designer can work on style and content without having to deal with the overhead of firing up the Azure emulator and communicating with an external service as he is often in areas with no-connectivity. I imagine it would be possible to extract the .sql scripts to create the database and execute them every test run, but this seems tedious. Similarly I'm not sure what the best way to configure these deployment details would be in order to switch between development, and published configurations. I'm a new web-developer cutting my teeth on a rather large project. Using ASP.NET MVC4 and have MSSQL 2012 installed for what it's worth.
You can export your SQL azure database as .bacpac format and then import it into your sql server database. It will create all tables and fill with data. You don't need to do it on every test run, just do it once and you will have proper database for debug needs. Switching between debug and release (or you can rename it if you want, e.g. Local and Production) configurations and using different web.config (or config transformations) is a good way to work with different settings. If you want to store your db scripts (db structure or data) in your VCS - you can use Entity Framework migrations (new fancy way) or separate project of "SQL Server database" type (old school but proven way :) ). Also EF migrations allows you to easily recreate db (with different name) on each run (for unit testing purposes. And then you can use SQL Express file instance (keep in mind that it's only for local work, your designer wont be able to access sql express instances afaik)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "asp.net, sql, sql server, asp.net mvc 4, azure sql database" }
How to overwrite a file in C? I am trying to overwrite the contents of a FILE in C. Currently I have: FILE* file = fopen("filename.txt", "r+"); fprintf(file, "%d", 1); // regardless of what's in the file, i want to clear it and put 1 in there ... // legacy code somewhere else in the code base. can't change. rewind(file); fprintf(file, "%d", 2); fflush(file); However, this will not work properly. The result will be: 1, 21 Each subsequent number will be written to the beginning of the 1. For example: 1, 21, 31, 41, ... I would like to know if there is a way to always overwrite what's in the file so the following is produced: 1, 2, 3, 4, ... Any assistance would be appreciated. Thank you. EDIT: I have changed the code to: FILE* file = fopen("filename.txt", "w+"); The problem still persists.
You decide that in `fopen`. Just use `"w"` or `"w+"` instead of `"r+"`.
stackexchange-stackoverflow
{ "answer_score": 18, "question_score": 7, "tags": "c, file io" }
Prove that a set is Borel(and hence Lebesgue) I'm trying to practice for the real-analysis final exam and I found this...Could you please help? For $n$ $\in$ $\mathbb{N}$, define the following subsets of $\mathbb{R}$: $$ A_n=\begin{cases} (0,1]\cup[n,n+1) & , n-even \\\ (0,1]\cup[n,n+2) & ,n-odd \end{cases} $$ Justify why $A_n$ is Borel and find $\lim_{x \to +\infty} \lambda(A_n).$ I was thinking that we could write these intervals as unions of open intervals and, being countable, they are Borel, but I'm not sure if this is correct...Also, I think that the result of the limit is 2 in the first case and 3 in the last one?
All intervals are Borel sets and unions of two Borel sets are Borel. Hence each $A_n$ is Borel . As far as $\lim \lambda (A_n)$ is concerned the limit does not exist since there are two limit points $2%$ and $3$.
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "real analysis, lebesgue measure, borel sets" }
why did launchd open a port and what is listening? My router indicates that one TCP port (6183) has been opened by an application I run (unbeknownst to me) Using the `lsof`(as answered here)`lsof -iTCP:6183 -sTCP:LISTEN`, I found that launchd is the culprit. Is it possible to find out which of launchd's 'scripts' is responsible?
You could try hunting through the ".plist" files that launchd uses like this: find ~/Library/LaunchAgents /Library/LaunchAgents /Library/LaunchDaemons /System/Library/LaunchAgents /System/Library/LaunchDaemons -name "*.plist" -exec grep -H 6183 "{}" \; 2>/dev/null find ~/Library/LaunchAgents /Library/LaunchAgents /Library/LaunchDaemons /System/Library/LaunchAgents /System/Library/LaunchDaemons -name "*.plist" -exec defaults read "{}" 2>/dev/null \; | grep 6183
stackexchange-stackoverflow
{ "answer_score": 13, "question_score": 4, "tags": "listener, port, launchd, lsof" }
Electromagnetic radiation emission Does Bremsstrahlung radiation produce only a certain type of electromagnetic radiation (for example X-ray) or can it also produce visible light when the trajectory of the incoming electron is not affected a lot. This video might help to understand the question:
Yes it is possible to have visible wavelength bremsstrahlung. There are many setups available, one of them is when you use a Large Helical Device, an 84 inch optical fiber array, an interference filter and 84 photomultipliers. > Visible bremsstrahlung emission has been measured by two diagnostics in NBl-heated discharges of LHD. The contribution of line emissions was estimated to be 20-30 Vo by separating the continuum emission in the visible spectrum measured by the spectrometer. < Just to clarify, the wavelength of bremsstralung can theoretically be any wavelength, though, our experiments and energy levels limit the emitted photons' wavelength. > Bremsstrahlung has a continuous spectrum, which becomes more intense and whose peak intensity shifts toward higher frequencies as the change of the energy of the decelerated particles increases. <
stackexchange-physics
{ "answer_score": 0, "question_score": 0, "tags": "particle physics, nuclear physics, atomic physics, physical chemistry" }
Can Nullity Be Used to Show That Nullspace is a Basis? Can I show that the nullspace of a matrix is a basis by finding the nullity? For example, given matrix **A** , I can find the nullspace of the matrix, which is the span of a set of vectors. I can also find the nullity of **A** (the dimension of the nullspace of **A** ) by reducing A to Reduced Echelon Form and counting the number of free variables. If the nullity of **A** is equal to the number of vectors that span the nullspace of **A** , can I say that those vectors spanning the nullspace is a basis of the nullspace? EDIT* comment from @Niing
Yes. For $n$ dimensional vector space $V$, any set of $n$ vectors that span the set is a basis and it's rather easy to prove. _Hint: Take a basis of $V$ and use replacement theorem._
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "linear algebra" }
Accessing element with ID that contains "." character I'm trying to access elements using jquery `$('#elementID')` method. If any element contain **"."** character like id="element.0" id="element.1" i can't access that element. Is it because of the **"."** character in id string ?
You need to escape the dot with `\\` $('element\\.0'); <
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "jquery" }
Finding the probability of a random variable from its cumulative distribution function How would I go about finding the probability of a random variable based on its piece-wise CDF? For example, I'm trying to find $P(X > 0.5)$ and $P(0.2 < X < 0.8)$ of $$F_X(x) = \begin{cases} 0 & x \leq 0 \\\ x^3 & 0 \leq x \leq 1 \\\ 1 & x \geq 1 \end{cases}$$
In general $F_{X}(x)=P(X \le x)$ and one uses this fact to compute probabilities of intervals. In the case of an interval $x>c$ we can use the fact that $P(X>c)=1-P(X \le c)$, which is $1-F(c)$ by definition. (I dropped the subscript $X$ on the function F.) Also in general to find $P(a<X<b)$ one applies the formula $F(b-)-F(a).$ The extra tag of $-$ after the $b$ indicate limit from the left. The left limit at $b$ is necessary only if $F$ is discontinuous at $b$. There are plenty of other possible forms of intervals, all treated in a similar way. But if you notice that your cumulative is continuous, as in your example, you can safely just plug in endpoints and subtract.
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "probability, probability distributions" }
How to retrieve the full directory path from Lucene.Net.Store.Directory? I'm trying to access the directory path from Lucene.Net.Store.Directory, and I can't find any properties where it exists. If I call ToString() I see the path along with the type name, etc. and I would just like the path.
The `Lucene.Net.Store.Directory` class does not have a `DirectoryInfo` (or `Directory`) property since its a abstract class and does not directly access the file system, with even some derived classes not using the file system at all to store the index (take for instance the `RAMDirectory`). However, for the `Lucene.Net.Store.SimpleFSDirectory` directory class, you can access the `Directory` property, type `DirectoryInfo` and then its `FullName` property to get the absolute directory path in use, var directoryInfo = simpleFSDirectory.Directory; var fullPath = directoryInfo.FullName;
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "lucene.net" }
Why can't I initialize and declare pointer to pointer to NULL in C? I wrote a C program. Some part of the code which is inside a function looks like this: struct node* functionName(struct node *currentFirstPointer){ struct node **head = NULL; *head = currentFirstPointer; return *head; } Here `node` is a structure. But this line gives me a `segmentation fault` when I run the program. But if I declare and initialize the pointer to pointer in separate statements inside the same function like below then it works fine. struct node* functionName(struct node *currentFirstPointer){ struct node **head; *head = NULL; *head = currentFirstPointer; return *head; } What could be the reason that the 1st block doesn't work and the 2nd block works fine?
You have two examples of dereferencing a pointer. struct node **head = NULL; *head = currentFirstPointer; and struct node **head; *head = NULL; *head = currentFirstPointer; Both are cause for undefined behavior. In the first, you are dereferencing a NULL pointer. In the second, you are dereferencing an uninitialized pointer. **The second block may appear to work** but that's the problem with undefined behavior. You need to allocate memory for `head` first before you can dereference the pointer. struct node **head = malloc(sizeof(*head)*SOME_COUNT); *head = currentFirstPointer;
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c, pointers, null, operators, dereference" }
What does this array syntax mean in Ruby? I just came across this code: @board=Array.new(7){Array.new(7)} I've never seen this syntax for an array in ruby and I couldn't find much on it after a search. I don't really get what's going on with the curly braces here. I was hoping someone could just give me a brief explanation. Thanks!
The block-syntax of `new` allows you to initialize the individual array elements, optionally based on the `index` number. In your case, the index is not used, but all 7 array elements are initialized with a nested array of also 7 elements, so you get a 7x7 "matrix". To illustrate: $ irb irb(main):001:0> Array.new(7) => [nil, nil, nil, nil, nil, nil, nil] $ irb irb(main):001:0> require 'pp' => true irb(main):002:0> pp Array.new(7) {Array.new(7)} [[nil, nil, nil, nil, nil, nil, nil], [nil, nil, nil, nil, nil, nil, nil], [nil, nil, nil, nil, nil, nil, nil], [nil, nil, nil, nil, nil, nil, nil], [nil, nil, nil, nil, nil, nil, nil], [nil, nil, nil, nil, nil, nil, nil], [nil, nil, nil, nil, nil, nil, nil]]
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "arrays, ruby, syntax" }
How else can you say "use aggressive language?" How else can you say _use **aggressive** language_? What other word or phrase can I use to describe _aggressive_ in a neutral way like forceful or strong, not hostile and not assertive either?
You could say _**authoritative**_ : > showing that you are confident, in control, and expect to be respected and obeyed: > > * She has an _authoritative_ manner that at times is almost arrogant. (Cambridge) > _**Compelling**_ could also be an option, it has the right meaning, but it is too commonly used as a synonym of _convincing_ , so it might not be the best choice.
stackexchange-english
{ "answer_score": 0, "question_score": 1, "tags": "synonyms" }
Why ||T|| is attainable? I am having trouble to understand why sup will turn out to max. It is from Kesavan Functional Analysis. I know realvalued continuous functions on compact space attend maximum value but here the domain is closed unit interval minus origin which is not compact. How can I use that result here: !enter image description here
Note that $$\frac{\Vert Tx \Vert}{\Vert x \Vert}= \left\Vert T\left(\frac{x}{\Vert x \Vert}\right)\right\Vert,$$ thus $$ \sup_{0<\Vert x \Vert \le 1} \frac{\Vert Tx \Vert}{\Vert x \Vert} = \sup_{\Vert y \Vert=1}\Vert Ty \Vert.$$ Now on the RHS you take the supremum of a continuous function over the compact unit sphere $\\{y \in \mathbb{R}^n \vert ~ \Vert y \Vert =1\\}$ and thus the supremum is attained.
stackexchange-math
{ "answer_score": 3, "question_score": 1, "tags": "normed spaces" }
How can I find the group id (gid) for the sdcard_r group on android? The question says it all. All folders on my sdcard has owner set as 0(root) and group set as `sdcard_r` \- means all apps that have permissions to access the sdcard. However, since I have root, I want to change the group of this folder using `chgrp`, so that only a selected app can access this. I know how to do this too, so no probs until now. However, I don't want this to be a one-way setting, I want to be able to revert back to `sdcard_r` in case something goes wrong. Now I don't know the actual gid of this group sdcard_r and chgrp only works with gids, not names. So, how can I find the gid of this group, sdcard_r?
Use the following command to see GID of the concerned group: id -G _group_name_ Courtesy of this answer of doylefermi. It is very much possible that the GID would be 1028 given this line in source code of Android.
stackexchange-android
{ "answer_score": 3, "question_score": 2, "tags": "linux, permissions, file permissions" }
Why is decomposition failing me here Why is decomposition failing me here, and what can I do about it in the future $$8x^2+10x+3 = 8x^2-2x+12x+3 = -2x(-4x+1)+3(4x+1) $$ see how one $4x$ is negative? That's what I mean by failing
$8x^2+10x+3 = (8x^2 + 4x) + (6x + 3) = 4x(2x+1)+3(2x+1)=(4x+3)(2x+1)$
stackexchange-math
{ "answer_score": 4, "question_score": 1, "tags": "algebra precalculus, polynomials, quadratics, factoring" }
KeyError 0 when trying to traverse session dictionary in Django I'm trying to traverse the session variable to print out all of its contents. for s in request.session: print str(s) The resulting error is as follows KeyError at /<app name>/searchResults/ 0 With the following traceback. /usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py in get_response 115. response = callback(request, *callback_args, **callback_kwargs) /<path to django app>/views.py 106. for s in request.session: /usr/local/lib/python2.7/dist-packages/django/contrib/sessions/backends/base.py in __getitem__ 46 return self.__session[key] Any idea what '0' means as an error? I've never seen this kind of thing before.
The correct way to iterate over the session's values is `request.session.itervalues()` \- the base session class exposes the same key/value/item options as a standard dictionary. I am unsure so far where it's getting the values your for loop is finding, but it's not the values.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "python, django, dictionary, keyerror" }
Is there a benefit in using a separate thread to handle serial data in Python? I am building an application in Python and TkInter, which accepts a constant stream of data through the serial port of the PC, at about 10-100Hz (i.e. a packet of data will arrive every 10-100ms). This data is then processed and presented to the user. A simple implementation would be to have a big loop, where the new values are received through the serial and then the GUI is updated. Another implementation which I find more robust, would be to have a separate thread to handle the incoming data and then send the data to the main application to update the GUI. I am not sure how to implement this, though. Would the separate thread give any benefit in this situation?
Yes, a separate thread would definitely be beneficial here, because the call you use to accept serial data will most likely block to wait for data to arrive. If you're using just a single thread, your entire GUI will freeze up while that call blocks to wait for data. Then it will just briefly unfreeze when data is received and you update the UI, before being frozen again until more data arrives. By using a separate thread to read from the serial port, you can block all you want without ever making your GUI unresponsive. If you search around SO a bit you should be able to find several questions that cover implementing this sort of pattern. Also note that since your thread will primarily be doing I/O, you should not be noticeably affected by the GIL, so you don't need to worry about that.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, multithreading, serial port" }
Java Exceptions. Cast one type to another Could someone explain why the first cast does not give a CCE ? public class Test { public static void main(String[] args) throws Throwable { Test.<RuntimeException>throwIt(new Exception()); } @SuppressWarnings("unchecked") private static <T extends Throwable> void throwIt(Throwable throwable) throws T { throw (T) throwable; // no ClassCastException throw (RuntimeException) throwable; // ClassCastException(as it should be) } } P.S. Comment one cast (otherwise it won't compile).
This is the feature of Java generics realization, it was realized through type erasure, that's why (T) cast actually cast it to Throwable as leftmost bound. Because, new Exception() produces a Throwable object you can safely throw it. You can check it in JSL <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, exception" }
js code doesn't work on web hosting but it works on localhost I'm trying to run some AJAX code on my web hosting. The problem is that it works on my localhost but it doesn't work on my web hosting. Do anybody know how to solve this problem? This is the code: function validarCorreo(mail){ var bool = false; var mail = {"mail" : mail}; $.ajax({ data: mail, url: '/carepets/validaciones/validarCorreo.php', type: 'post', async: false, success: function(response){ if(response == true){ $("#autenticacionCorreo").html("El correo esta disponible.").css("color","green"); bool = true; }else{ $("#autenticacionCorreo").html("El correo esta ya registrado o es incorrecto.").css("color","red"); } } }); return bool; }
Two things you should check: Check if you properly included jQuery in your project. Also check if relative path of validarCorreo.php file is correct on your server and if it is ok then check if there are no errors in that file. It would be good if you could check your Network Activity tab to see and share with us what happens when you invoke validarCorreo function.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -3, "tags": "javascript, php, ajax" }
Grundgesetz zitieren? In einem Deutschaufsatz (erörternde textbasierte Argumentation) habe ich folgendes geschrieben: > Diese grundlegende Idee ist sogar im deutschen Grundgesetz, Artikel 2, festgehalten: „Jeder hat das Recht auf die freie Entfaltung seiner Persönlichkeit […].“ Meine Deutschlehrerin hat an den Rand geschrieben: > [fehlt] Woher zitiert? Meiner Meinung nach ist die Angabe des Artikels im Gesetz Angabe genug. **Frage:** Ist bei Zitaten von Gesetzen eine Quellenangabe anders als ich sie bereits gemacht habe nötig?
Aus dem Fließtext ist klar ersichtlich, woher das Zitat stammt. Daher verwundert mich die Randnotiz deiner Lehrerin. Möglicherweise habt ihr im Unterricht aber bestimmte Formen des Zitierens gelernt, die ihr hier anwenden solltet. So ist es in geisteswissenschaftlichen Arbeiten oftmals vorgeschrieben, dass der Verweis auf die Quelle in Klammern hinter dem Zitat stehen muss. In naturwissenschaftlichen und technischen Publikationen wird oft verlangt, dass dem Zitat eine laufende Nummer in eckigen Klammern folgt, wobei die Nummer auf einen Eintrag in einer Liste im Anhang des Dokuments verweist, wo dann die entsprechende Quelle angeführt ist. Es gibt viele verschiedene Regeln, wie in wissenschaftlichen Texten zu zitieren ist. Ob deine Lehrerin auf einer bestimmten formalen Form des Zitieren besteht, kann ich aus der Ferne nicht beurteilen.
stackexchange-german
{ "answer_score": 14, "question_score": 5, "tags": "quotes" }