INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Remove application from Windows 7 search bar results Is it possible to stop appearing in the results when searching in the search bar in Windows 7? **Update** : I'm often opening text documents in Notepad++ to paste text to store as a reference or so I don't lose stuff in my clipboard accidentally. When searching for Notepad++ in the search bar, even if I type in the exact name of the application "Notepad++", the search results always show the old notepad.exe as the first result. This means I have to press the down arrow a couple of times to get the application I want. If I could somehow remove notepad.exe from the search results, I wouldn't have to do this anymore and it would make me about 2 seconds more productive every day.
If you don't need Notepad in the list (which is coming from Program Files short-cuts) simply try deleting the short-cut when it appears. It won't delete notepad but it will remove the short-cut from the results.
stackexchange-superuser
{ "answer_score": 1, "question_score": 0, "tags": "windows 7, search, notepad++" }
warning: Time#succ is obsolete; use time + 1 What is this error all about? I'm running a standard query like so: time_range = (1.month.ago.beginning_of_month..1.month.ago.end_of_month) Feed.find(:all, :conditions => ['created_at = ? AND id not in (?)', time_range, [1,2,3]]).count Any ideas? Thanks
I had this problem and the solution was to add "to_date" so that it iterates over the days, like so: time_range = (1.month.ago.beginning_of_month.to_date..1.month.ago.end_of_month.to_date)
stackexchange-stackoverflow
{ "answer_score": 21, "question_score": 9, "tags": "ruby on rails, ruby on rails 3, activerecord" }
Convert database definition files into SQL I'm interested in analyzing some of the virus definition files used by antivirus software. All of them provide free access to the databases, but all the one's I've found so far are in some kind of in-house data file format (.AVC for Kaspersky Anti-virus, etc). Is there any software that uses a data format closer to MySQL, or can any of these in-house data files be converted?
You could look at ClamAV virus definitions, which are in an open format (as ClamAV itself is open source). There appears to be some documentation of how to create signatures.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "mysql, database" }
Extracting div attributes based on text I am using Python 3.6 with bs4 to implement this task. my div tag looks like this <div class="Portfolio" portfolio_no="345">VBHIKE324</div> <div class="Portfolio" portfolio_no="567">SCHF54TYS</div> I need to extract portfolio_no i.e 345. As it is a dynamic value it keeps changing for multiple div tags but whereas the text remains same. for data in soup.find_all('div',class_='Portfolio', text='VBHIKE324'): print (data) It outputs as None, where as I'm looking for o/p like 345
Here you go for data in soup.find_all('div', {'class':'Portfolio'}): print(data['portfolio_no']) If you want the portfolio_no for the one with text `VBHIKE324` then you can do something like this for data in soup.find_all('div', {'class':'Portfolio'}): if data.text == 'VBHIKE324': print(data['portfolio_no'])
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python 3.x, web scraping" }
Does a cron job with no schedule ever fire? Consider this in crontab.xml which I've found in a third party plugin... <config xmlns:xsi=" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd"> <group id="default"> <job name="the_job_name" instance="Vendor\Name\Cron\Order\Retry" method="execute" /> </group> So it has no `<schedule>` element. Will it ever fire?
It will not run on schedule. You can check this by running php bin/magento cron:run And you can see its not there. also it will not fire after: php bin/magento cron:run --group="yourcustom_crongroup" its on import export module for example: <config xmlns:xsi=" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd"> <group id="default"> <job name="magento_scheduled_import_export_log_clean" instance="Magento\ScheduledImportExport\Cron\ScheduledLogClean" method="execute" /> </group> </config> There is also one example in unit tests: vendor/magento/module-cron/Test/Unit/Model/Config/_files/crontab_valid_without_schedule.xml They will fire after set settings in backend. You don't need it for example for import export on default settings. Only when You decide to have that cron. Probably your module have this settings in the backend.
stackexchange-magento
{ "answer_score": 0, "question_score": 1, "tags": "magento2, cron, crontab" }
Is it possible to do this? Write a fraction as a product I have two quantities $A$ and $B$ and I consider the fraction $$\frac{1}{A+B}$$ I would like to write the above expression as a Product, i.e. find functions $F$ and $G$ such that $$\frac{1}{A+B} = F(A)G(B)$$ for any functions F and G I don't even need them to be explicit, I just need to know if that is possible :) Thank you very much!
$G(1)F(x)=\frac{1}{1+x}$ so we see that $F(x)=\frac{1}{G(1)(x+1)}$ and similarly $G(x)=\frac{1}{F(1)(x+1)}$. Then $$F(A)G(B) = \frac{1}{F(1)G(1)} \frac{1}{(1+A)(1+B)}$$ $F(1)G(1)=\frac{1}{2}$, so this means: $$\frac{1}{A+B}=F(A)G(B) = \frac{2}{(1+A)(1+B)}$$ or $$(1+A)(1+B)=2(A+B)$$ That means that $1+AB=A+B$ for all $A,B$, or $(A-1)(B-1)=0$. But this is only equal when $A=1$ or $B=1$.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "calculus, real analysis, algebra precalculus" }
How to access stack base pointer (rbp) using inline assembly? My requirement is to access a function call parameters by offsetting rbp using inline assembly. But I couldn't find a suitable operand constraint to specify the base pointer in x86. I am using Intel compiler but it's documentation states that it supports GCC style inline assembly. So GCC based example would be sufficient.
You can try: #include <stdio.h> #include <inttypes.h> int main(int argc, char **argv) { uint64_t n; __asm__ __volatile__( "movq %%rbp, %0\n\t" : "=r"(n) ); printf("rbp = 0x%" PRIx64 "\n", n); return 0; }
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "assembly, inline assembly, icc" }
How to convert a string to an array according to a specific separator? I have a string like this: $str = "it, is, a, test"; Now, I want this: _(separator is`,`)_ <small> <a href='#'>it</a> <a href='#'>is</a> <a href='#'>a</a> <a href='#'>test</a> </small> How can I do that?
Just use explode .. $str = "it, is, a, test"; $res = explode( ', ', $str ); echo "<small>"; foreach($res as $result){ echo "<a href='#'>" . $result . "</a>"; } echo "</small>"; <
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "php, html, explode, implode" }
wp-paginate() showing blank page while navigating to other pages I am using wp-paginate plugin for pagination on my wordpress site. The pagination links are showing fine. The problem is every page shows a blank page. I am using following code to call pagination. I am new to wordpress so sorry for any mistakes.. <?php if ( have_posts() ) : ?> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', get_post_format() ); ?> <?php endwhile; ?> <?php //twentytwelve_content_nav( 'nav-below' ); ?> <?php if(function_exists('wp_paginate')) { wp_paginate(); } else { twentytwelve_content_nav( 'nav-below' ); } ?>
Finally I found the solution. There was a page named page.php on my server's root folder. I deleted it and problem solved.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "php, wordpress, pagination" }
GKMatchmakerViewController does not handle touches I am showing this modalView and it does not handle touches. I am using cocos2d-iphone. mControllerView= [[UIViewController alloc] init]; //mControllerView.view = [[CCDirector sharedDirector] openGLView]; //this was the old method, it worked, but since ios6 it crashes [[[CCDirector sharedDirector] openGLView] addSubview:mControllerView.view]; theClass = [[TheClass alloc] init: mControllerView]; // this shows the GKMatchmakerViewController inside mControllerView
I have changed cocos2d to a newer version, and didn't check what changed, or what should I refactor in the appDelegate. Now it works.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "objective c, cocos2d iphone, game center, gamekit, gkmatchmaker" }
NSMutable Array and leaking Problem Hey - does somebody know why i get a leak when i use this line of code ??? : [self setModules:[[aDictionary objectForKey:KEY_MODULES] mutableCopy]]; Thanks in advance pk
As you create a copy of existing object via `mutableCopy` then you're responsible to release it (assuming you also retain it in setModules method): [self setModules:[[[aDictionary objectForKey:KEY_MODULES] mutableCopy] autorelease]]; Check also that you release `modules` iVar in your class's dealloc method.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "objective c, ipad" }
Is it possible to launch Download Manager (a process) in .NET As the title says, it is possible to launch Download Manager (such as Orbit) passing the URL of the file to download? Edit: How can I check how those programs are expecting the url??? What parameters are needed to be passed ?? My problem is , I do NOT know how those programes are expecting their inputs. Before that, I also would like to check if one of download managers has installed in the machine.
string path = @"C:\Program Files\Orbit\Orbit.exe"; string arg = @" System.Diagnostics.Process.Start(path, arg);
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c#, .net" }
searching a txt file with jquery to find element and display next line i am trying to jquery a file preferably .txt but can be .html of which there is example Group 1: Score: Group 2: score: Can i use jquery within html to search for 'Group 2' and display the next line in div?
You wouldn't normally use jQuery to go directly to the file. It'd be better to use some server side code to parse the parse the file, return it in some meaningful state (JSON maybe)? Then return that into a div with jQuery rather than parsing the text with it. This way you can still manipulate the HTML with jQuery but the actual processing of the file would be done server side, which would be better anyway as it would mean say if you had a really large file to parse, you can't just hang the browser. Although technically you may be able to get around it so you could do a ajax request to get the file, it would probably be a pain in the ass to support.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "jquery, search, import" }
Create bundle without default controller and route Is this possible to create bundle without default controller and route?
Yes, it is. Only required file in the bundle is the bundle class. Read more in the official documentation: <
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "symfony" }
using one of the ouput parameter of a function oracle PL/SQL I have an ORACLE Function with the below signature. Function function1(parameter1 in number, parameter2 in number, parameter3 in number, parameter4 out number, parameter5 out varchar(20), parameter6 out varchar(20)) RETURN number is I want use this function in a SQL like this, Select parameter5 from table1 ti where function1(t1.parameter1,t1.parameter2,t1.parameter3) How can I access the output parameter5 in my Select statement? As I want to perform the above select operations in bulk , I am not comfortable using a variable and looping through the resultset. I dont want use an array as I have to perform few operations in bulk with above SQL Query. Thanks in Advance! Cheers, Dwarak
I assume you need both parameter5 and the number returned, so maybe it would be better if you create a type and retun it instead. something like this: create type res_type as object ( rc number, parameter5 varchar2(20) ); Function function1(parameter1 in number, parameter2 in number, parameter3 in number, parameter4 out number, parameter5 out varchar(20), parameter6 out varchar(20)) RETURN res_type is UPDATE: Then in your select you can do something like this: select function1(t1.parameter1,t1.parameter2,t1.parameter3).parameter5 from table1 ti where function1(t1.parameter1,t1.parameter2,t1.parameter3).rc = ....
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql, oracle, plsql" }
How to get a preview of a second monitor? I have connected a projector, but I don't see the image of this second "monitor" very well (it's quite far). **Is it possible to get a live preview of this second monitor in a small window on a first monitor?** Something like "picture in picture".
Run 2 programs, in 2 terminals; an `x11vnc` server and an `xvncviewer`. E.g. $ x11vnc -viewonly -clip 1920x1080+1920+0 -scale 0.4 and $ xvncviewer :0 The `x11vnc` server sets up a VNC view connection to the indicated screen region of the main display. I've assumed a xinerama set up with the local monitor 1920x1080 to the left and the remote projector 1920x1080 to the right; i.e., the projector is at +1920+0 with display size 1920x1080. You would change those to suit your actual set up. E.g. 1024x768+1920+0 if the projector has resolution 1024x768 and is (notionally) to the right of the first monitor with resolution 1920x1080. You may use `xrandr` to see your actual set up. I've suggested using `xvncviewer` as VNC viewer. There are a number of other viewers to choose from.
stackexchange-unix
{ "answer_score": 3, "question_score": 2, "tags": "x11, manjaro" }
How to open javascript items array in a new window instead of the same window? I have a great working code that opens a link in the same window when I click it, it's inside a dropdown menu. This is in javascript. problem is that I would like it to open up in a new tab instead of the same window. How can I do this? here is my code: items["linkeee"] = { "label": "mylabel", "action": function(obj) { openUrl(' + addId); } }; update -- also my html looks like this: <a href="#">mylabel</a> BUT I don't have direct access to the html without messing stuff up. I gotta do this up there with the javascript update how do i combine `' + addId` to add `, "_blank"` please help thanks
Turn off pop-up blockers for the domain at browser preferences or settings, see chrome Pop-up blocker when to re-check after allowing page. Use `window.open()` var w; items["linkeee"] = { "label": "mylabel", "action": function(obj) { w = window.open(" "_blank"); } }; Alternatively, use `<a>` element at `html` with `target` attribute set to `"_blank"` <a href=" target="_blank">mypageeaa</a> Using `javascript` var a = document.createElement("a"); a.href = " + addId; // `encodeURIComponent(addId)` a.target = "_blank"; document.body.appendChild(a); a.click();
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, arrays, tabs" }
kerberos enabled Yarn - Unable to submit job with REST API I have enabled kerberos with apache hadoop 2.7.1 With this I can run mapreduce example jars and also can write files in hdfs with REST API. But I am unable to submit the job with REST API. May someone help me to check this problem, Thanks!
The reason it fails is because you have an ancient version of curl. Upgrade to the most recent one (7.49.0) and everything will work. SPNEGO have been made working from 7.38.0 and later.
stackexchange-stackoverflow
{ "answer_score": -1, "question_score": -3, "tags": "mapreduce, hadoop yarn, hadoop2" }
In Wordpress, if I'm styling my own custom template, where do I put the CSS file? I have a child theme that I'm modifying with my own custom page, and I wanted to change the CSS on the page, but in the header of the page when I put the `<link rel="stylesheet" href="" />` part, I'm not sure where I should point the href to.
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" />
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "wordpress" }
Can a server join a GetInstant room in order to get notified of changes? Can a server join a room in order to get notified of changes? Usecase: A user updates a field A, for which another calculated field B must be updated. However only the server is able (has the rules) to calculate the field B based on A. What I mean would be the following flow: 1. user updates field A. 2. gets synced to GetInstant 3. GetInstant notifies all users in the room among which the server, of the changed field A 4. Server calculates field B 5. field B gets synced to GetInstant 6. (optional: clients get notified of updates of field B) As a workaround I could let all updates go through by own server and do the plumbing myself, but I'd rather not. Moreover, directing traffic like this is costly for the sporadic case that I need to do these calculated field transforms.
At the moment you can't join a room via the rest api and register for notifications server-side. This is on the roadmap, however. Currently your options to do this serverside are limited to polling.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "goinstant" }
No sound as root and even with sudo su pi It works if I try to play a sound/mp3 with mpg321 as a pi user: mpg321 Yeah-sound.mp3 but sudo -u pi mpg321 Yeah-sound.mp3 does nothing and sudo mpg321 Yeah-sound.mp3 leads to error > Can't find a suitable libao driver. (Is device in use?) I need to allow root user to play a sound or somewhat switch the user to play it. But interestingly this also does not work: pi@raspberrypi:~/Music $ sudo su pi pi@raspberrypi:~/Music $ mpg321 Yeah-sound.mp3 it leads to output similar to a case where the sound is played but nothing really happened. It looks like the sound output is transmitted somewhere else. Any ideas? I am using latest and pure install of Voice HAT for Raspberry Pi downloaded from github
All that leads to behaviour specific error related to OS version (Voice HAT on Raspberry Pi). Problem with sudo not playing music was resolved after installing pure "Raspbian Stretch Lite" and adding all necessary drivers.
stackexchange-raspberrypi
{ "answer_score": 2, "question_score": 2, "tags": "audio, sudo" }
How to search GitHub user with location has space The request to GitHub Api is as simple as By this request, I would like to find out the current GitHub user who is in "Hong Kong". But the result return is not as expected,it doesn't return my colleagues GitHub results. If I change "Hong Kong" to "HK", the result is fine. Are there are any space character is not represent as %20 in their web request?
You should probably encapsulate the location in quotation-marks: "Hong Kong". (Where `%22` is the URl-encoded form of `"`)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "javascript, ajax, github" }
css outer div max-width scale inner image Is it possible to fit an image to its outer div width which is limited by max-width? Here is a fiddle example: < <div style="width:100%;"> <div style="max-width:30%; background-color:red; float:right; padding:10px;"><img src=" lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum </div>
Sure it is :) make your CSS like so .container { width:100%; } .image-container { width:100%; max-width:30%; } .image-container img { width:100%; height:auto; } and HTML like so <div class="container"> <div class="image-container"> <img src="/img/source"> </div> <p>Your Text</p> </div> As a side note, try not to inline style items - makes for less reusable code. Let me know if there is anything else I answer.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "css" }
Exercise on Random Variables I´m struggling with a random variable exercise of a book I´m reading. Anyone has an idea of how to approach this problem? !enter image description here Thanks in advance :)
$$E(X)=\int^{1}_{0}\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}x(x^{a-1}(1-x)^{b-1})=\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}\int^{1}_{0}x^{a}(1-x)^{b-1}=\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}\left(\frac{\Gamma(a+1)\Gamma(b)}{\Gamma((a+b)+1)}\right)\int_{0}^{1}\left(\frac{\Gamma((a+b)+1)}{\Gamma(a+1)\Gamma(b)}\right)x^{(a+1)-1}(1-x)^{b-1}=\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}\left(\frac{\Gamma(a+1)\Gamma(b)}{\Gamma((a+b)+1)}\right)=\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}\left(\frac{a\Gamma(a)\Gamma(b)}{(a+b)\Gamma(a+b)}\right)=\frac{a}{a+b}$$
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "random" }
List processing Suppose I have a list that looks like the following (Town names and total distance to that town) resupply = { {"Coleman", 0}, {"Highwood House", 106}, {"Canmore", 229}, {"Exshaw", 245}, {"Ghost Station", 288}, {"MountainAire", 370}, {"Nordegg", 552}, {"Robb", 672}, {"Hinton", 720} } How would I process that list to give me something like Coleman - Highwood House 106 km Highwood House - Canmore 123 km Canmore - Exshaw 16 km and so on. The output gives me the two towns being travelled between, and the distance between them.
StringTemplate["`1` - `3` <*#4-#2*> km"] @@@ Flatten /@ Partition[resupply, 2, 1] > > { > "Coleman - Highwood House 106 km", > "Highwood House - Canmore 123 km", > "Canmore - Exshaw 16 km", > "Exshaw - Ghost Station 43 km", > "Ghost Station - MountainAire 82 km", > "MountainAire - Nordegg 182 km", > "Nordegg - Robb 120 km", "Robb - Hinton 48 km" > } >
stackexchange-mathematica
{ "answer_score": 21, "question_score": 11, "tags": "list manipulation" }
How can I get an Azure blob without downloading to a local file using Java? (For Azure for SDK 10) I'm able to download a file to memory, but I'd like to just download it to a blob or other local object. * There appears to be a download function for BlockBlobURL, but this returns a Single<> object: is there a more direct way to just get the blob contents? * This link describes downloading to file. * I am looking for the Java equivalent of this.
BlobURL had a low level interface that I could extract the byte stream from. This was my workaround: ByteBuffer byteBuffer = blobURL.download(null, null, false, null) .blockingGet() // DownloadResponse .body(null) // Flowable<ByteBuffer> .firstOrError() .blockingGet();
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 3, "tags": "java, azure, azure blob storage" }
SQL Server multiple tables query for a specific date from many I have three tables: Table 1 - Members Id Name 1 Member1 2 Member2 Table 2 - Activity Id Member_id Activity Date 1 1 Activity1 2001-1-1 2 1 Activity2 2001-2-1 3 1 Activity3 2001-3-1 4 2 Test 2010-4-1 Table 3 – Detailed Id Activity_id Information 1 2 Information From the following, the Member id 1 has three activities: SELECT Member.id, COUNT(*) AS number FROM Member INNER JOIN Activity ON Activity.Member_ID = Member.id GROUP BY Member.id My question is how I can find the id and date of the second activity (table 2) for all Members from table(1) who has 2 activities and also retrieve the information related to this activity id from table 3. Thanks in advance
Row number function would help you here. select * from ( select *, rn = row_number() over (partition by member_id order by id) from activity ) activityWithRn inner join detailed on detailed.activity_id = activityWithRn.id where activityWithRn.rn = 2 Here I've partitioned the data by member id and the ordered the activity by its id but maybe you want to order by date?
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "sql server" }
How to check if only one value is not null in Javascript? Let's say I have 3 textboxes in cshtml. What I am trying to do in Javascript is the following: Check if ANY OF those 3 values and ONLY THEM is not null. The only way I can think of is doing it manually: if ((val1 & !val2 & !val3) || (!val1 & val2 & !val3) || (!val1 & !val2 & val3)) It is okay if it is a small number of textboxes, but if such number grows to 10+, it might become a hassle. **Is there any efficient way to implement such logic in Javascript regardless of how many textboxes we are dealing with?**
You can use `.reduce`: var nonEmpty = [val1, val2, val3].reduce(((c, v) => c += (v !== "")), 0); if (nonEmpty === 1) { // exactly one is not empty } Any other way of counting the non-empty inputs and checking that the count is equal to 1 would work too of course. What that `.reduce()` code does is use an "arrow function" that increments a counter (`c`) when a value is not the empty string. (If you want to check for null, you can do that instead of course.) You could use a plain old-fashioned function too: var nonEmpty = [val1, val2, val3].reduce(function(c, v) { return c += (v !== ""); }, 0); The `.reduce()` function is passed 2 parameters: that callback function, and the initial value of `c` (zero in this case). The return value will be the _final_ value of `c` returned by the last call to the callback.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, razor, null" }
groovy split exception java.lang.ArrayIndexOutOfBoundsException: 1 I have this code to split the line to get key value pair, if value is missing it throw exection. why its giving execption? what is the right way to split this key value pair line. def lline="name=" def (key, value) = lline.split("=") Error: Caught: java.lang.ArrayIndexOutOfBoundsException: 1 java.lang.ArrayIndexOutOfBoundsException: 1 thanks
That's because `lline.split("=")` returns an array of 1 item `['name']`, which you try and put the first item into `key` and the second into `value` If you instead use the version of `split` that takes a limit: def (key, value) = lline.split( "=", 2 ) it should work
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "groovy" }
Context free grammar of $L = \{w \in \{a, b, c\}^* : |w|_{c} = 3k +1 \}$ So, this is my first homework in conext free grammar, I want the grammar that generates all possible words in L, I have come out with the following rules $$ S \rightarrow aS | bS| cX\\\ X \rightarrow aX| bX| cY\\\ Y \rightarrow aY|bY|cZ|cS\\\ Z \rightarrow aZ|bZ |cK\\\ K \rightarrow aK| bK| a| b| \epsilon $$ but it does not generate words of for wc where c is not in w.
You seem to have the right idea, but as you say, you're missing the case where $c$ is at the end of the word. Moreover, no word generated by your grammar has less than $4$ $c$'s in it, i.e. you're missing the case where $|w|_c = 1$. I think the problem is that you have too many states. You just need the three states for the number of $c$'s modulo $3$. You start in $S$ can be $0$ mod $3$, $X$ can be $1$ mod $3$, and $Y$ can be $2$ mod $3$. You move between these states by adding another $c$, stay in the states by adding $a$ or $b$, and you can only terminate from state $X$. That is, I suggest: \begin{align*} S &\to aS \mid bS \mid cX \\\ X &\to aX \mid bX \mid cY \mid \varepsilon \\\ Y &\to aY \mid bY \mid cS. \end{align*}
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "context free grammar" }
I want to sort the subarrays in a NumPy array that I have according to their length I want to sort the sub-arrays in a NumPy array that I have according to their length. For example my array is myArray = [[1,2,3,4,5,6,7], [8,9,10,11], [12], [13], [14,15,16,17,18,19,20,21,22,23,24]] and I want to sort them as myArray = [[14,15,16,17,18,19,20,21,22,23,24], [1,2,3,4,5,6,7], [8,9,10,11], [12], [13]] Is there any possible way to doing this? **The content of my sub-arrays should not change.**
That is a simple list of lists - to do what you need: sorted(myArray, key=lambda x: -len(x)) **FOLLOW UP** : if you have a `numpy` array, as follows: myArray = np.array([np.array(x) for x in [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11], [12], [13], [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]]]) You can obtain a similar result: np.array([y for x,y in sorted([(-len(x), x) for x in myArray])]) OUTPUT: array([array([14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]), array([1, 2, 3, 4, 5, 6, 7]), array([ 8, 9, 10, 11]), array([12]), array([13])], dtype=object)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python, arrays, numpy, matrix, numpy ndarray" }
как выровнять все горизонтали столкнулся с такой проблемой. Я не могу выровнять все го горизонтали. Как сделать что бы текст и иконки были по центру &__contact { } &__title { color: #000; } &__items { display: flex; justify-content: space-between; } &__item { } &__icon { max-width: 64px; height: 64px; img { max-width: 100%; } } &__text { position: relative; } ![введите сюда описание изображения]( ![введите сюда описание изображения](
Для `.contacts__item`, дайте свойства: display: flex; flex-direction: column; align-items: center;
stackexchange-ru_stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "html, css, веб программирование" }
Derivation of Poisson PDF from Binomial: questions on a Wiki proof Wiki has a proof and I have questions regarding it. a) $$ \lim_{n\rightarrow\infty} {n \choose k} p^k_n(1-p_n)^{n-k} = \lim_{n \rightarrow \infty} \frac {n(n - 1)(n - 2) \cdots (n - k + 1)}{k!} \left ( \frac \lambda n\right)^k \left(1 - \frac \lambda n \right)^{n-k} $$ **Question 1** how was the $(n -k +1)$ term in the numerator derived? b) $$ = \lim_{n\rightarrow \infty} \frac {n^k + O(n^{k-1})}{k!} \frac {\lambda^k}{n^k} \left(1 - \frac \lambda n \right)^{n-k} $$ c) $$ = \lim_{n\rightarrow\infty} \frac {\lambda^k}{k!} \left(1 - \frac \lambda n\right)^{n-k} $$ **Question 2** how does form (b) become (c)? Does $\frac {n^k + O(n^{k-1})}{n^k} = 1$ somehow? If big-O $O(n^{k-1}) = (\lim_{n\rightarrow\infty} n^{k-1}) \le C n^{k-1}$, then (b) becomes $\frac {n^k + Cn^{k-1}}{n^k} = 1 + C n^{-1}$. I'm confused here.
Question 1: See big O notation. Question 2: We have $$\frac {n!}{k!(n -k)!}=\frac {n(n-1)(n-2)(n-3)...(n-k+1)}{k!}$$ This really is obvious ($n!$ is series of products from $n$ to one and $(n-k)!$ a series from $n-k$ to one), but we can also use induction to prove it. If $k=1$, then $$\frac {n!}{k!(n -k)!}=\frac {n!}{1!(n -1)!}=\frac {n (n-1)!}{(n -1)!}=n=\frac{(n-k+1)}{k!}$$ Let now the relation hold for $k$, and we will show that this holds for $k+1$. We have $$\frac {n!}{(k+1)!(n -(k+1))!}$$ $$=\frac {(n-k)n!}{(k+1)k!(n -k)!}$$ $$=\frac {n (n-1)(n-2)...(n-(k+1)+1)}{(k+1)!}$$ This gives the claim.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "probability theory, probability distributions" }
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 Estoy aprendiendo programación básica en Java y al intentar recorrer un `array` unidimensional me sale este error: > > Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 > at Array_2.main(Array_2.java:6) > Y realmente no se que puedo hacer para solucionarlo, este es el código: public class Array_2 { public static void main(String args[]) { int t = 0; int numeros[] = new int[5]; for (int i = 0; i <= 5; i++) { numeros[i] = i + 10; } for (int j = 0; j <= 5; j++) { System.out.println(numeros[t]); t++; } } }
1ro, que no es `<= 5` si no `< 5`. 2do, en el segundo for ya tienes declarado `j`, entonces para que utilizas `t`. Te dejo el codigo: public class Array_2{ public static void main(String args[]){ int numeros[] = new int[5]; for(int i = 0; i < 5; i++) { numeros[i] = i + 10; } for(int j = 0; j < 5; j++) { System.out.println(numeros[j]); } } } Si realizas una prueba de escritorio te daras cuenta que cuando `i` sea igual a 5, la condicion del for se cumple, por lo que entra a ejecutar el cuerpo o bloque del for, y cuando se trate de acceder a la posicion 5 del array arrojara una excepcion indicando que ese indice (`i` o `j`) esta fuera de los limites del array. ¿Y... por que esto? Pues por que estas declarando un array de 5 posiciones, pero se empienza a contar desde la posicion cero, y de cero a cuatro ya estan las cinco posiciones.
stackexchange-es_stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java" }
How to use "of which"? Is this sentence correct? The object of which you want to monitor the movements Is there another way to say the same thing?
The phrase is correct, at least in the sense that it is in accordance with the precepts of Latin grammar as they have been applied to English. There is no particular reason, other than arbitrary decree and academic habit, why the sentence should have been constructed in that way (which was very likely in order to avoid ending the sentence/clause with a preposition). A more natural formulation using approximately the same words would have been > The object which you want to measure the movements of That formulation has the unfortunate property that it violates prescriptive grammar as jarringly as the prescriptive formulation violates natural grammar. An alternative that would say the same thing without disturbing anybody's sensibilities would be > The object whose movements you want to measure
stackexchange-english
{ "answer_score": 1, "question_score": -1, "tags": "pronouns" }
Generating/selecting non-standard HTML tags with jQuery, a good idea? I've noticed that jQuery can create, and access non-existent/non-standard HTML tags. For example, $('body').append('<fake></fake>').html('blah'); var foo = $('fake').html(); // foo === 'blah' Will this break in some kind of validation? Is it a bad idea, or are there times this is useful? The main question is, although it can be done, should it be done? Thanks in advance!
There's really no reason to do something like this. The better way is to use classes like <p class = "my_class"> And then do something like $('p.my_class').html('bah'); **Edit:** The main reason that it's bad to use fake tags is because it makes your HTML invalid and could screw up the rendering of your page on certain browsers since they don't know how to treat the tag you've created (though most would treat it as some kind of DIV). That's the main reason this isn't good, it just breaks standards and leads to confusing code that is difficult to maintain because you have to explain what your custom tags are for. If you were really determined to use custom tags, you could make your web page a valid XML file and then use XSLT to transform the XML into valid HTML. But in this case, I'd just stick with classes.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 5, "tags": "javascript, jquery, html, javascript framework" }
How to use a getter in a class for multiple class without instantiation I would like to instantiate a class and use a getters for multiple class without instantiation. For example: If user can be logged , I would to instantiate a class new MyClass(aParameter) The user can be navigate for multiple view, and during the navigation I would like to use a getter String get ParamUser => user; I show my example class class MyClass { String param; MyClass(String el) { this.param = el; } String get ParamUser => param; set setparam(String ParamUser ) => param = ParamUser ; } Thanks for your help
Make everything in your class `static`: class MyClass { static String param; static String get ParamUser => param; static set setparam(String ParamUser) => param = ParamUser ; } Then access elements with static access syntax e.g. `MyClass.ParamUser`
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "flutter, dart" }
Python script to exe on python 3.5 What can I use to go from a python script to an exe on 3.5? Because both py2exe and CxFreeze only support up to 3.4. Also, would it be possible to create an executable without a bunch of .dll's generated? Because I would like to have just a single .exe to share. Thank you
Try pyinstaller. It worked for me fine with python 3.5. Install `pyinstaller` with the following command pip install pyinstaller and build you exe with `pyinstaller --onefile your_pyfile.py`. `--onefile` option generates one file of about 6-8 megs max.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 5, "tags": "python, exe" }
Select the html in an 'a' tag with jquery but getting html is not a function Getting: > `this.html()` is not a function? $('a[href*="section"]').click(function() { var texthtml = this.html(); $(document).find("div.SectionExpandable__title:contains("+texthtml+")").click(); }); How do I get the html from an `a` tag so I can pass it to the next part of the code?
When using `this`, you can call DOM methods on it, but not jQuery methods. When using `$(this)`, you can call jQuery methods on it, but not DOM methods. and `html()` is jQuery method, so : Change : this.html(); To : $(this).html();
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "javascript, jquery, html" }
How to skip (not execute!) a call in GDB when debugging without symbols? I am debugging a Linux program to which I have no symbols. The binary is stripped. No big deal, I can handle that. However, how can I skip a call inside the debugger when I reach a particular piece of code? What I am asking is _not_ this: Use gdb to debug assembly, how to skip a call I am interested if I have a: call 0x12345678 ... to jump to the `...` straight **without _executing_ the `call`**. How can I do that?
After some more reading I found the solution. In my case I know the opcode for the `call` is fives bytes long, so I can resolve it by setting the GDB register name `$pc` ("program counter") to jump over it: set $pc+=5 According to the comment on this answer by Employed Russian the following provides the same functionality: jump *$pc+5 Assuming you have the `call` _at_ address `0x01234567` and want to skip five bytes, you can do the following in your `.gdbinit`: b *0x01234567 commands 1 x/i $pc echo Not executing the call\n set $pc+=5 x/i $pc end
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "linux, assembly, gdb, 64 bit" }
What is one-level deep copy in JavaScript? What is one-level deep copy in JavaScript?
This means a copy of an object in which the each property refers to a copy of the original property, (deep), but nested properties refer to the (uncloned) original nested properties (only 1 level of cloning)
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "javascript" }
Stream Audio from Ubuntu Desktop to Android Mobile via bluetooth Is there any way to play music on your PC and stream it to your android phone via bluetooth, e.g I want to play a youtube video on computer and listen that audio via my phone.
Yeah! I explain the way I used (which worked) but I don't know if it's the only method one... You need to use **bluetooth** and **pulseaudio** : * pair PC and phone * set the phone as _external speaker_ via `pavucontrol` application on the PC
stackexchange-askubuntu
{ "answer_score": 5, "question_score": 9, "tags": "16.04, bluetooth, android" }
Supplementary properties/settings for JavaScript:window.print() to enable Backgrounds by default I would like tot give my _`Print this Page`_ button a special magical property sothat it automatically enabled the by default unset property (see picture) namely to Do Print the Backgrounds of div colors and bg images etc. <a href="#" onclick="javascript:window.print()"><? echo __('Print'); ?></a> Clues, ideas, code, answers or suggestions as answers are all tremmendously welcome and I a will appreciate any hints at all for this dream to come true. Thanks in advance. !enter image description here
This cannot be done, unfortunately. This is disabled across all browsers by default (unless a user changes it in _their_ settings).
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "javascript, jquery, printing, colors, background" }
How much data can Kafka topic store? I read through the documentation of Kafka 0.8.0 in its entirety, but could not find an answer to this question. If anyone has experience with Kafka, whats the maximum amount of data it can hold assuming your hardware has not reached its point of failure. We are planing on storing our payload in kafka for DR purposes.
There is no limit in Kafka itself. As data comes in from producers it will be written to disk in file segments, these segments are rotated based on time ( _log.roll.hours_ ) or size ( _log.segment.bytes_ ) according to configuration. Older segments are deleted based on retention configuration ( _log.cleanup.policy, log.retention.minutes, log.retention.bytes_ ) which can be turned off. Do note however that the broker will keep each segment file open, so make sure your file descriptor limits are set accordingly. Broker configuration documentation: <
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 4, "tags": "apache kafka, persistent storage" }
Merging a rebased branch into the un-rebased version of it I have a branch FEATURE that was split from MAIN about a year ago, and has some extra features. I have created a new branch MY-FEATURE from the FEATURE branch. I have rebased MY-FEATURE branch to the latest MAIN branch, and I discarded a commit, where MAIN was merged into FEATURE about 6 months ago. What's the best way to now make the remote FEATURE Branch same as the MY-FEATURE branch? Would merging MY-FEATURE into FEATURE do the trick? It feels like I may start getting into a world of pain, especially since I discarded a merge commit during the rebase.
If you just want the `FEATURE` branch to point to the `MY-FEATURE` branch, you may simply hard reset the former to the latter: # from FEATURE git reset --hard MY-FEATURE # force push, if you like git push --force FEATURE Note that a force push of `FEATURE` to the remote would be necessary here, as its history has been rewritten. You should probably avoid doing this if `FEATURE` be in use by other people.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "git, git merge, git rebase" }
How can I switch tab bar tabs using left and right swipe gestures? I have a `UITabBarController` with two tabs connected to it. How can I use left and right swipe gestures in the two views to switch tabs left and right? I've seen other questions similar to this but all of them use Objective-C. Also, if this can be all done in the storyboard, I'd prefer that over having to use Swift code.
Add following swipe gestures to your viewcontroller view let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(swiped)) swipeRight.direction = UISwipeGestureRecognizerDirection.right self.view.addGestureRecognizer(swipeRight) let swipeLeft = UISwipeGestureRecognizer(target: self, action: #selector(swiped)) swipeLeft.direction = UISwipeGestureRecognizerDirection.left self.view.addGestureRecognizer(swipeLeft) // below code create swipe gestures function // MARK: - swiped @objc func swiped(_ gesture: UISwipeGestureRecognizer) { if gesture.direction == .left { if (self.tabBarController?.selectedIndex)! < 2 { // set here your total tabs self.tabBarController?.selectedIndex += 1 } } else if gesture.direction == .right { if (self.tabBarController?.selectedIndex)! > 0 { self.tabBarController?.selectedIndex -= 1 } } }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "ios, swift, xcode, uitabbar, gesture" }
Number of biased coin tosses needed to match headscount for a number of tosses of a different biased coin I have two different biased coins with probabilities $p_1$ and $p_2$. Coin 1 I toss $n$ times. I would like to know how often I should toss coin 2 to be $p_3$% sure I'll have more heads from coin 2 than from coin 1. I have read up on binomial distributions and I could figure out the answer by summing those from a guessed starting point and going up or down by trial and error on the computer, but I'm hoping there is an easier way. Context: Actually the coin flips are archers in a computer game facing off against opposing archers, each having a chance to incapacitate an opponent, I expect there will be anywhere from 1 to 1000 archers on each side. A cautious artificial intelligence wants to know how many archers it has to take so it's reasonably save to go near and have a positive outcome where fewer of his archers fall than those of the enemy.
This is essentially finding the probability mass function for the difference of two independent binomial random variables (and then finding the cdf and evaluating it at zero). This involves hypergeometric functions - see, for example, here: Difference of two binomial random variables An approximation could be developed using normal distributions, where $$P[B<A] =P[B-A<0]= \Phi \left( {\mu_A - \mu_B } \over {\sqrt{\sigma^2_A + \sigma^2_B}} \right)$$ However, this could be problematic for some parameter values of interest to you.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "probability" }
Developing for XP, Win 7 and Vista - do I need to test Vista separately? I am currently developing a service app on Windows XP with VS 2010 and the target is to XP, Vista and 7. The service run as admin on the installed computer and as such I don't see many problems with user controls but I do know there are noticable differences between each listed OS. If I develop it on Windows XP and test it mainly on Win XP and Win 7 should I consider testing it on Vista too, or are the tests done on Win 7 will most likely be comparable or the same as on Vista? Are there differences that would require me to have a Vista machine to test on as well?
If you're releasing this software to the public and you claim to support XP, Vista and 7, then you should test on Vista. It's true that Vista and 7 are similar operating systems. It's also true that the majority of the changes to running services occurred between XP and Vista. But this doesn't absolve you of the responsibility to test each platform you support. You should consider defining a list of officially supported operating systems. For example, you might 'officially' support: Windows 7 SP1 32/64 Windows Vista SP2 32/64 Windows XP SP3 Unofficially any variant of XP, Vista or 7 should work, but these are the operating systems you guarantee to your customer will work. Of course the only way you can make this guarantee is by testing on each of these operating systems ;).
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "c#, testing, windows 7, windows xp, windows vista" }
Why it is a StackOverFlow Exception? Why following code throws `StackoverflowException`? class Foo { Foo foo = new Foo(); } class Program { static void Main(string[] args) { new Foo(); } }
in Main you create a new Foo object, invoking its constructor. inside Foo constructor, you create a different Foo instance invoking again Foo constructor. This lead to infinite recursion and end with a StackOverflow exception
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 1, "tags": "c#, stack overflow" }
organizing phone number using regular expression There are two strings like 'my phone number is 010-1111-1456' 'my house address is 123-456' my code: text1 = 'my phone number is 010-1111-1456' text2 = 'my house address is 123-456' print(re.search('[0-9]+[-]+[0-9]+[^-]', text1)) print(re.search('[0-9]+[-]+[0-9]+[^-]', text2)) How the output should be like: <re.Match object; span=(20, 27), match='123-456'> My output: <re.Match object; span=(19, 27), match='010-1111'> <re.Match object; span=(20, 27), match='123-456'> My problem: i want to print only the second one like <re.Match object; span=(20, 27), match='123-456'> how can i get this code right?
what you want is `\d{3}\-\d{3}$`, depending on use-case, `(?:$|[^\d-])(\d{3}-\d{3})(?:$|[^\d-])` is an alternative. Use regex101.com to find the one that fits your usage please.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, python 3.x, regex" }
Is there a way of making my div background less and less transparent while user keeps scrolling the webpage? I have a bootstrap webpage that uses video background. What is more, I'm using the following css code: .transparent{ box-shadow: 0 0 0 1000px rgba(0, 999, 0, 1); overflow:hidden; } #imgBox{ box-shadow: 0 0 0 1000px rgba(0, 999, 0, 1); } to make the "hole" in a covering layer, so that when user see's the layer - he only see a part of video underneath. It's hard to explain, so just take a look at this example: < I want to achieve an effect, that the green layer is transparent at the very beginning (let's say it has `rgba(0, 999, 0, 1)`, but when user keeps scrolling down and this layer becomes more and more visible, it gets less transparent (so when it's fully visible it should have `rgba(0,999,0,1)` for example. How can I achieve it with jquery or css?
I am not sure about your requirement but checkout this updated jsfiddle of your's Just added `$("#black").css("opacity",$("body").scrollTop()/1000);` in `$(window).scroll` such that it will increase the opacity on window scroll and I am using very small amount since the value of opacity can be only withing the range of 0 to 1 <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, jquery, html, css, twitter bootstrap" }
How handle multiple environment for AWS SNS? I have a server using intensively AWS SNS. Of course I have multiple environments (dev, QA, production, custom, etc.) Knowing that SNS let you register only one endpoint per token (so, AFAIK, I can't have two differents Endpoints with the same token, even if created from different PlatformApplication), how could I manage separation between my different environments? EDIT: all our environment are in the same AWS IAM account.
SNS does allow you to subscribe multiple HTTP/HTTPS endpoints to a single Topic but it sounds like you need an SNS topic per environment so that the dev Topic dispatches requests to a dev HTTP endpoint. The recommended AWS strategy for multiple environments in 2017 is to use multiple accounts -- one per environment. You can use consolidated billing for all of your accounts. If you separated them then you would wind up creating an SNS topic for each environment and each would publish requests to the appropriate endpoint for that environment. The single account solution would be to create one Topic per environment and to update your app config or environment variables to use the ARN appropriate to the environment.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "amazon web services, environment, amazon sns" }
nginx rewrite rule exclude numbers Need some help with Nginx write rule such that: All urls of type:- /1.1.1/xyz/abc/z.js /2.2.2/xyz/def/c.css are re-directed to /xyz/abc/z.js /xyz/def/c.css Want to exclude the numeric part which comes at the beginning of URL.
location ~ ^/[0-9\.]+(/.*) { try_files $1 $1/; }
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "nginx, url rewriting" }
Duplicate Document ID In Document Library I have a document library in SharePoint 2013 that has a few documents with the same document ID. Is there anyway I can regenerate this without reuploading the documents? I've tried the fix mentioned here for SharePoint 2010 but that didn't work.
you can reset the all document Id in a site please look at this post <
stackexchange-sharepoint
{ "answer_score": 1, "question_score": 3, "tags": "sharepoint enterprise, document library, document id" }
Strip everything but URL from a string in python I'm grabbing a series of links from a website with python and BS4 but i need to clean them up so I only get the URL in the string. the links i get look like this: > javascript:changeChannel('< 20); and i need it to look like this > <
Well, if all the links are like that one you can do it with a very simple approach: s.split("'")[1] For example: >>>s="javascript:changeChannel(' 20);" >>>s.split("'") ['javascript:changeChannel(', ' ', 20);']
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "python, string" }
how to connect the UITabbar to viewcontroller I don't use UITabbarController,I just add the UITabbar in ViewController.I know when we use UITabbarController,we will create one array which contain viewcontrollers,so when we tap the tab,will show the specific viewcontroller,but the UITabbar just can add UITabbarItems,so how to connect the viewcontroller to the Tab?just like UITabbarController. thank you in advance.
Attach a `UITabBarDelegate` to your `UITabBar`: self.tabbar.delegate = self; // make sure you declared self to be a UITabBarDelegate in your header Then implement: - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item { // item is the selected tab bar item }
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "iphone, ios" }
Is there any way to get out of a dungeon once cleared? It is very annoying having to walk all the way back out of the cave once I have done the mission, especially if there is lots of traps.
Generally in most dungeons when you clear it (kill the boss, loot the final chest, get a word of power, etc.) there is a path you can keep exploring. The path can sometimes be activated by a switch or lever and opens up a new route. This new route can either take you near the entrance of the dungeon or takes you outside. This eliminates the need to walk all the way back to the entrance the way you came.
stackexchange-gaming
{ "answer_score": 15, "question_score": 2, "tags": "the elder scrolls v skyrim" }
Instantiate an array of objects, in simpliest way? Given a class: class clsPerson { public int x, y; } Is there some way to create an array of these classes with each element initialized to a (default) constructed instance, without doing it manually in a for loop like: clsPerson[] objArr = new clsPerson[1000]; for (int i = 0; i < 1000; ++i) objArr[i] = new clsPerson(); Can I shorten the declaration and instantiation of an array of N objects?
You must invoke the constructor for each item. There is no way to allocate an array and invoke your class constructors on the items without constructing each item. You could shorten it (a tiny bit) from a loop using: clsPerson[] objArr = Enumerable.Range(0, 1000).Select(i => new clsPerson()).ToArray(); Personally, I'd still allocate the array and loop through it (and/or move it into a helper routine), though, as it's very clear and still fairly simple: clsPerson[] objArr = new clsPerson[1000]; for (int i=0;i<1000;++i) clsPerson[i] = new clsPerson();
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 5, "tags": "c#, arrays, object, constructor, new operator" }
Hide null values on parameter value I have a stored parameter with a where clause between start and end dates that includes null values: WHERE a.date is null OR a.date between @StartDate AND @EndDate These null values are obviously being selected when any parameter value (date range) is chosen in my SSRS report.... my question is, is there a way to not show these null values when a specific parameter value (date range) is selected? P.S. I can hide the row where parameter equals a value and the a.date field is null in Row Visibility within a SSRS report but I want to avoid this if possible. Thanks in advance!
You can extend the filtering conditions: WHERE a.date is null AND (@startDate is NOT NULL OR @EndDate IS NOT NULL) OR a.date between @StartDate AND @EndDate
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "sql, tsql, parameters, null, ssrs 2012" }
move the values from data segment via offset I have data segment dataseg segment para 'data' var1 db 3 var2 db 5 dataseg ends i'm trying to move the values, i.e. mov ax, offset var2 mov bx, [ax] but it doesnt work
In 16-bit real mode, `ax` is not allowed to be used between brackets (as a base register), but `bx` is: mov bx, offset var2 ; BX INSTEAD OF AX. mov ax, [bx] Only `bx` and `bp` can be used in this way as base registers when addressing memory. `ax` is generally used to store/accumulate values for other purposes. By the way, your variables are size "byte", but you are moving their value into a size "word" register. You can fix it in two ways: var1 DW 3 ; USE A WORD SIZE VARIABLE. or mov al, [bx] ; USE A BYTE SIZE REGISTER.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "assembly, x86, tasm" }
ui-grid header content menu button overlaps text ![enter image description here]( have noticed that header column menu button is overlapping with the header label, it also happens if you resize the column width How can this issue be resolved? .ui-grid-column-menu-button { position: absolute; right: 1px; top: 0; } Example of this can be seen here as well <
i was able to resolve it with below css .ui-grid-header-cell .ui-grid-cell-contents { display: block; width: calc(100% - 12px); }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, html, angularjs, css, angular ui grid" }
Not loading white pixels in picture in processing2.0 This is for the programing language Processing (2.0). Say I wish to load a not square image (lets use a green circle for the example). If I load this on a black background you can visibly see the white square of the image(aka all parts of image that aren't the green circle). How would I go about efficiently removing them? It can not think of an efficient way to do it, I will be doing it to hundreds of pictures about 25 times a second(since they will be moving). Any help would be greatly appreciated, the more efficient the code the better.
Pixels are stored in the Pixels[] array, you can use a for loop to check to see if the value is 0 (aka white). If it is white load it as the black background.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "performance, image processing, processing, pixel" }
SQL: Use calculated column just defined in subsequent calculation The title looks a little bit bulky, but I don't know any better words to phase, what I want to achieve. It's a pretty simple question: If I define a column in my SQL query with the `AS` keywords, can I immediately access this column from the next column? SELECT LEAD(StoredOn) OVER (PARTITION BY ID_ChargeCarrier ORDER BY StoredOn) AS LeftOn, LeftOn - StoredOn AS TimeDifference FROM MyTable This one, quite obviously, doesn't work. I know, that I could make it work by replacing the `LeftOn` in the second column definition with the exact same `LEAD` function. But does that harm the performance, or does SQL server understand, that the two calls are redundand?
use `subquery` select t1.LeftOn, t1.LeftOn - t1.StoredOn AS TimeDifference from (SELECT LEAD(StoredOn) OVER (PARTITION BY ID_ChargeCarrier ORDER BY StoredOn) AS LeftOn, StoredOn FROM MyTable) t1
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -1, "tags": "sql, sql server" }
Strange variable comparison result - no return if echo $obj['URLvideo']; prints **< and echo " . $myimage; prints **< shouldn't " .$myimage == $obj['URLvideo']; return **true** ?? For some reason, it's just returning **NOTHING** for me... I'm stumped, but then, I've been awake for 32 hours. HELP?
You are doing and assignment, not a comparison. Change the single `=` to `==`. **Edit:** Since you said that you mistyped `==`: The Problem is then that PHP prints an empty string for booleans. Do either `echo (int)(expression);` or `echo expression ? "true" : "false";`. The first will print and integer (0 or 1) and the second, well true or false.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 0, "tags": "php, variables, comparison" }
Convert text to SVG/vector in a Word document (custom fonts) I have a couple of custom fonts which I would like to use in a handout I am sending out. However, as a base font I use a custom font that other users will not have installed. Is it possible to embed this font one way or another in an Office Word document? I was thinking SVG or any other vector format (I don't want to use a rasterized image!) Note that I also want the imported "image"/vector to be compatible with the pdf format so that I can export the Word document as PDF as well.
There is no need for SVG conversion, but if you want that it is doable with Inkscape. Launch Word, create/open a document then go to * File * Options * Save and check `Embed fonts in document`.
stackexchange-superuser
{ "answer_score": 1, "question_score": 0, "tags": "pdf, fonts, microsoft word 2013, svg, vector graphics" }
How to get full height of webpage with CSS? I am trying to create a pseudo lightbox using very little Javascript. I am in the process of creating the translucent black overlay behind the modal but I am having problems stretching the black overlay all the way down the length of the page. The overlay stops at the end of the initial scrollable area. So, if the user scrolls down the page, the page is not completely covered by the overlay. Here is the code that I am using for the overlay: .black-overlay { position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: #000000; z-index: 1001; -moz-opacity: 0.8; opacity: .80; filter: alpha(opacity=80); } It's probably the heigh: 100% that is limiting the page from spanning the whole length of the page.
Try `position: fixed;` instead.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "html, css" }
What is the transfer function of this block diagram I and my friend have different answer for this block diagram ![enter image description here]( Mine: $$y[n] = -\frac23x[n] + x[n-1] -\frac12[n-2]$$ Hence $$H(z) = \frac{1}{-\frac23 + z^{-1} -\frac12z^{-2}}$$ My friend: $$q[n]=x[n]-\frac12q[n-1]$$ $$y[n] = -\frac23x[n]+q[n-1]$$ $$Y(z) = \frac23X(z)+z^{-1}Q(z)=\frac23X(z)+z^{-1}\frac{X(z)}{1+\frac12z^{-1}}$$ Hence $$H(z)=\frac{Y(z)}{X(z)}=\frac23+\frac{z^{-1}}{1+\frac12z^{-1}} = \frac{4z^{-1}+2}{3+\frac32z^{-1}}$$ I don't know how can he come to that result but I'm not sure about mine either
As pointed out in the other answers, your friend's approach is correct. However, his end result for $H(z)$ isn't. With $q[n]$ the input signal of the delay element, you get $q[n-1]$ at its output, and the given difference equation for $q[n]$ follows easily. The output $y[n]$ can then be written in terms of $x[n]$ and $q[n-1]$. In the $\mathcal{Z}$-transform domain you get algebraic equations in terms of $X(z)$, $Q(z)$, and $Y(z)$, from which you can eliminate $Q(z)$, leaving you with an expression for $H(z)=Y(z)/X(z)$: $$H(z)=\frac{Y(z)}{X(z)}=-\frac23+\frac{z^{-1}}{1+\frac12 z^{-1}}=-\frac23\frac{1-z^{-1}}{1+\frac12 z^{-1}}\tag{1}$$ So it was basically just a sign error that messed up the end result.
stackexchange-dsp
{ "answer_score": 2, "question_score": 0, "tags": "discrete signals, z transform, transfer function" }
How to 'summarize' variable which mixed by 'numeric' and 'character' here is data.frame `data` as below , how to transfer it to `wished_data` Thanks! library(tidyverse) data <- data.frame(category=c('a','b','a','b','a'), values=c(1,'A','2','4','B')) #below code can't work data %>% group_by(category ) %>% summarize(sum=if_else(is.numeric(values)>0,sum(is.numeric(values)),paste0(values))) #below is the wished result wished_data <- data.frame(category=c('a','a','b','b'), values=c('3','B','A','4'))
Mixing numeric and character variables in a column is not tidy. Consider giving each type their own column, for example: data %>% mutate(letters = str_extract(values, "[A-Z]"), numbers = as.numeric(str_extract(values, "\\d"))) %>% group_by(category) %>% summarise(values = sum(numbers, na.rm = T), letters = na.omit(letters)) category values letters <chr> <dbl> <chr> 1 a 3 B 2 b 4 A In R string math does not make sense, `"1+1"` is not `"2"`, and `is.numeric("1")` gives `FALSE`. A workaround is converting to list object, or to give each their own columns.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "r, dataframe, tidyverse" }
How can I read the lines between the "start" and "end" flags from a file by using python For example, the content of the file is: this is the first line; start this is the second line; this is the third line; this is the forth line; this is the fifth line; end this is the sixth line; this is the seventh line; "start" and "end" are flags,i want print the lines between these two flags. Result I want is: this is the second line; this is the third line; this is the forth line; this is the fifth line; So, how can i process this file.
Do it in Python just like you'd do it in any other language. The process would be: * Initialize flag to False * Open file * Start reading lines; For each line read: * If flag is False: * Check if line == "start", if so set flag to True * If flag is True: * Check if line == "stop", if so stop reading * Else, print (or save) line * Close file, etc. Nothing Python-specific about it. Start by seeing how you do each of those things in Python (hint: it shouldn't be more lines than the lines of pseudocode above, really). If you have specific issues after you've tried, ask again.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "python, file" }
Como fazer o PHP aceitar acentuação? Como posso fazer o PHP aceitar acentuações como " ´ " e "^". Ele teria que funcionar nessa lista que eu criei em PHP (Esse não é o código completo da lista). <td><?php echo $dado['RM'];?></td> <td><?php echo $dado['Nome'];?></td> <td><?php echo $dado['Email'];?></td> <td><?php echo $dado['Turma_ID'];?></td>
Coloque o trecho abaixo na parte da sua página que tem o HTML, lá onde tem o HEAD. <head> <meta charset="utf-8"> </head> Coloque também no seu código PHP em cada linha que imprimir dados, mas teste algo asim: <td><?php echo utf8_decode($dado['RM']);?></td> Ou <td><?php echo utf8_encode($dado['RM']);?></td> No meu início com PHP, HTML, CSS, Javascript e etc... usei muito esta fonte de consulta: W3 Schools
stackexchange-pt_stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "php" }
Postfix Whitelist for RBL Googles outgoing Servers are today listen on SORBS NOQUEUE: reject: RCPT from mail-ot0-f180.google.com[74.125.82.180]: 451 4.7.1 Service unavailable; Client host [74.125.82.180] blocked using dnsbl.sorbs.net; Currently Sending Spam See: now I want to whitelist them. But this is not working: whitelist_recipient: /^mail-.*\.google\.com$/ OK Postfix config: main.cf: smtpd_recipient_restrictions = .... check_recipient_access hash:/etc/postfix/whitelist_recipient, .... reject_rbl_client dnsbl.sorbs.net, .... But why? postmap whitelist_recipient I had do. And a postmap -q "mail-ot0-f180.google.com" regexp:whitelist_recipient Says: OK What do I wrong? Thank you for any help!
Ok, after a lot of time, I found my mistake! main.cf: smtpd_recipient_restrictions = .... check_client_access regexp:/etc/postfix/whitelist_recipient, .... reject_rbl_client dnsbl.sorbs.net, .... It not **hash:** it must **regexp:**
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "postfix mta" }
Installing multiple libraries from one python environment to another I'm a novice in Python and I wanted to migrate my work from one Python Environment to another one in a different machine, so is there another way to reinstall all of those libraries that I used in my original environment.
To do so, you can check the libraries (and their dependencies) and store them in a text file using this command: pip freeze > requirements.txt Then, when you are using your other machine, or even a different python environment on the same machine, install all of the libraries using this command: pip install -r /Path to file..../requirements.txt I hope this answers your question.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "python, anaconda" }
keep formatting entered in asp.net textbox (carriage return, new line, etc) I have a textbox using multiline mode and when I create the stored procedure parameter for updating I use `Server.HtmlEncode` on the textbox value. I can copy the content from the data record into Notepad and it shows the spaces where the user has pressed the Enter key for new paragraphs. When displaying that content on a page (not a textbox for editing; just assigning the content to a Literal control), it has all the text run together. I have done some searches about using Replace and different escape sequences or `Environment.NewLine`. I am still confused about how to have the text display as the user entered it.
Assuming you're using C# you can do the following when you display the string on the page theStringYouWantToFormat.Replace(char.ConvertFromUtf32(13),"<br/>") When you call `Server.HtmlEncode` on the value you grab from a text box it'll look at the text and encode any HTML tags contained in that text box so for example `<script></script>` would be encoded to `&lt;script&gt;&lt;/script&gt;`.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "asp.net, textbox, text formatting" }
Difference between Vector Functions and Vector Field I understand that a vector function is a function that has a domain $\mathbb{R}^n$ and range on $\mathbb{R}^m$ so it takes vectors and gives vectors right? So what is a vector field?And how can I visualize them?
A vector field $F|_S\colon S\to\mathbb{R}^n$ is an assignment of $n$-dimensional real vectors to points in a subset of $\mathbb{R}^n$ so it's really just a vector-valued function $F\colon\mathbb{R}^n\to\mathbb{R}^n$ restricted to a subdomain $S\subset\mathbb{R}^n$. Note that the domain and codomain of $F$ have the same dimension, but $S$ can possibly be a lower-dimensional subspace (for instance a proper linear subspace or a sphere). _(Note: there is a more sophisticated definition of a vector field which is defined in terms of tangent spaces and tangent bundles, but the above definition more than likely suffices for introductory calculus courses.)_
stackexchange-math
{ "answer_score": 4, "question_score": 4, "tags": "calculus, multivariable calculus, vector analysis, advice, vector fields" }
Number of attributes of a case class in Scala What is the most efficient way to get the number of attributes of a case class in Scala? I need to do this before any instantiation. For instance for the case class: Person(name: String, weight: Float) I would like to do something like: Person.attributes_length // returning 2
## With an instance You can make a "fake" instance or if you have one: Person(null, 0).productArity ## By reflection Another option is to use reflection. ### Scala 2.11 Add the reflection lib to SBT: "org.scala-lang" % "scala-reflect" % "2.11.8" And do: weakTypeOf[Person].decl(termNames.CONSTRUCTOR).asMethod.paramLists.size ### Scala 2.10 Add the reflection lib to SBT: "org.scala-lang" % "scala-reflect" % "2.10.6" And do: import scala.reflect.runtime.universe._ weakTypeOf[Person].declaration(nme.CONSTRUCTOR).asMethod.paramss.head.size Cheers
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "scala" }
Does anybody wish to help a poor researcher publish a paper? I don't know if this is a good place to beg for help, but here it goes: basically, I need to run a secure recommender system simulation (C++ console application) in order to meet tonight's deadline, and the faculty's server grid decided to go offline. I could really use something like 10+ (actually, about 16 would be required to meet the deadline) virtual instances of some Linux that has GMP installed... Ideally, they should all have the same specs, because a part of the simulation will represent performance benchmarks. If my question is inappropriate in any way, I kindly ask the administrators to remove it.
Amazon Elastic Computing Cloud is what you're looking for. Those are relatively cheap servers rent on demand. 32 Extra Large servers for 8h will cost you a bit under $164. Those are 15 GB, 4 core, 8 thread machines with 1690GB of storage. If you don't need something as big, there are machines from 1 core, 1 thread, 1.7GB or RAM up. There are also memory and CPU optimised instances. If you want to have an already configured cluster machine, Quadruple Extra Large machines (23 GB memory, 33.5 cores) cost $1.3 per hour...
stackexchange-serverfault
{ "answer_score": 4, "question_score": -2, "tags": "cluster, batch processing, grid" }
Sard's theorem and Whitney approximation I'm confused about John Lee's proof of Whitney approximation theorem in Introduction to Smooth Manifolds. It claims that the theorem is an application of Sard's theorem, but I didn't find where it was applied. Also, he didn't prove the case that $F$ is not smooth on some closed set, and I've got no clue to utilizing the pattern (partition of unity) he showed. link
You're right. In that proof, the author did not use Sard Theorem. The theorem that you refer to is called _Whitney Approximation Theorem **for Functions**_ , which means that the continuous function on manifold that we want to approximate has Euclidean space as the target space. As pointed out by Ted Shifrin, we can always take $A=\emptyset$ if there's no such closed subset $A$. The claim that Sard Theorem is used to prove Whitney approximation theorem is not about _Whitney Approximation Theorem for Functions_ above, but about _The Whitney Approximation Theorem_ (Theorem 10.21 proved later in the book) which involves function between manifolds, and the first step to prove this is to embed our target space (a manifold) into some Euclidean space using Whitney Embedding Theorem, which is a corollary of Sard Theorem.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "differential geometry, differential topology, smooth manifolds, smooth functions" }
What is this table called and how do I read it? I'm reading the powerpoint specification and I came across a table like this: ![enter image description here]( Do tables like these have a name? How do I read this? I'm pretty sure it means that the first 4 bits identifies the `recVer` and the next 12 identifies the `recInstance`, but what about `recLen`? Do all 32 bits pull double-duty and identify the `recLen` or does that mean the next 32 bits do that?
It looks like some type of packet header. The numbers at the top are the bit position. It is read left to right, top to bottom, so it is telling you that the header is made up of 4 bits interpreted as the recVer, followed by 12 bits that is interpreted as recInstance, followed by 16 bits that is the recType, followed by 32 bits which is the recLen. This is a common way to show the header structure, as can be seen on Wikipedia's TCP page.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "specifications, bit" }
Footer div is not being pushed down in Chrome (tried clear: both) I have a form that is higher than its parent `<div>` and overflows its parent `<div>`. I want the next `<div>` (the footer) to get pushed down by the `<div>` that holds the form. Unfortunately, the footer starts where the parent `<div>` ends and not where the form `<div>` ends. I tried to put in a new `<div>` with `style="clear:both"` above the footer, but that doesn't work either. It works in Firefox but it doesn't work in chrome. Here is my real example: <
Add `float: left;` to `.row-fluid` .row-fluid { width: 100%; float: left; }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "html, css" }
Databases: Insert from multipler servers Rally DB newbie question: I am trying to insert user records to a DB. The id type could be an autoincrementing serial, or an INT. How do I insert a record with an ID that is unique, and I can get that ID back, making sure that if the request is handled by multiple application servers, then I don't generate duplicate id's. e.g. * Server 1 needs to insert: ( 'John', 'Smith', 25 ) * Server 2 needs to insert: ( 'John', 'Rambo', 25 ) The app server wants the id's of the generated records back. I can't do a select based on attributes because 1. They could be duplicate 2. It's expensive. One solution is that each app server also inserts a server id, server update no, combination and then selects on the basis of that. I feel like this should be such a generic problem that there is would be a much simpler solution. I'm using PostgreSQL if it matters.
With postgres you can use the RETURNING clause to return the value of a column such as INSERT INTO table (col1,col2,col3) VALUES (1,2,3) RETURNING id;
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "database, postgresql" }
Fixing Non-manifold edges for 3D printing This is my first model for 3D printing, and I'm trying to fix non manifold edges. I included a screenshot, there are 6 non manifold edges. Things I already tried: \- recalculate normals \- remove doubles To me it looks like there are no double edges left, so I'm clueless to what causes this problem. :) Who can help me? The way I created this part is deleting two faces in the wall, extruding the floor face and merging the vertices to make it 1 piece again. ![enter image description here](
Non-manifold geometry is geometry where an edge is shared by more than 2 faces: ![enter image description here]( This is what you should be looking for. It's easy to find using Select -> Select All by Trait -> Non Manifold ![enter image description here]( Once you find it you can fix it by deleting some unnecessary faces, or separating the edges. You could use Edge split for that: ![enter image description here]( Note that it splits them all so you need to move one and then remerge the two you like connected(you can use Merge by Distance for that)
stackexchange-blender
{ "answer_score": 2, "question_score": 1, "tags": "3d printing" }
Nginx high memory usage duplicate SSL We have an NGINX running with a lot of virtual hosts (~600) Unfortunately the NGINX workers are each using a large chunk of residential memory (~6GB) When inspecting the memory (strings) it yields the duplicate meta information you usually find in SSL certs (duplicated up to over 100.000 times). We only use a handful different certs. I suspected ssl_session_cache could be the culprit. It is set to > ssl_session_cache shared:SSL:10m; which would nicely add up to our memory usage (10MB*600=6GB) But according to the docs < > A cache with the same name can be used in several virtual servers. And increasing that value does apparently have no effect memory usage. We also heavily rely on lua-resty, but that shouldn't affect how SSL is handled? Do you know what could be causing this high memory usage? nginx version: openresty/1.13.6.1
We were using Openresty mostly for authentication. As we were suspecting Openresty to cause the high memory usage we extracted all lua parts with an `auth_request` Now we have an nginx which proxies back to openresty for authentication. With the same number of hosts and SSL certificates we now have a much lower memory usage (~150MB per worker instead of 6GB). Also openresty only uses a negligible amount of memory. So there seems to have been some problem with openresty in combination other parts of our configuration. While this does not exactly answers the original question, it is a useful workaround for us and hopefully anyone else who hits this issue.
stackexchange-serverfault
{ "answer_score": 0, "question_score": 2, "tags": "nginx, memory usage" }
APScheduler options I'm trying to schedule programmatically some jobs with Advace Python Scheduler, my problem is that in the documentation it is only mentioned how to schedule with 'interval' trigger type, what about 'cron' and 'date'. Is there any complete documentation about scheduling options of APScheduler? For instance: #!/usr/bin/env python from time import sleep from apscheduler.scheduler import Scheduler sched = Scheduler() sched.start() # define the function that is to be executed def my_job(text): print text job = sched.add_job(my_job, 'interval', id='my_job', seconds=10, replace_existing=True, args=['job executed!!!!']) while True: sleep(1) How I can schedule based on 'date' or 'cron' I'm using latest APScheduler version 3.0.2 Thanks
sched.add_job(my_job, trigger='cron', hour='22', minute='30') Means call function 'my_job' once every day on 22:30. APScheduler is a good stuff, but lack of docs, which is a pity, you can read the source codes to learn more. There is some more tips for you: 1. use * sched.add_job(my_job, trigger='cron', second='*') # trigger every second. 2. some more attributes {'year': '*', 'month': 1, 'day': 1, 'week': '*', 'day_of_week': '*', 'hour': 0, 'minute': 0, 'second': 0} And in my opinion, cron job can replace date jobs in most situations.
stackexchange-stackoverflow
{ "answer_score": 28, "question_score": 13, "tags": "python, apscheduler" }
why to use resultset!=null does it check for null I have following code if (rs != null) { out.println("result set has got something"); while (rs.next()) { //I am processing result set now } } else { out.println("result set is empty"); } Even though rs is null it is printing **"resultset has got something"**. Why is it happening like that and how can I check for empty result set?
You could check it with: if(rs != null && rs.next()) { out.println("result set has got something"); do { // do what you have to do } while (rs.next()); } else { out.println("result set is empty"); }
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 0, "tags": "java, jdbc" }
Targetting a text element with no tag in Beautiful Soup I'm trying to target a date in `bs4` that has no tag associated with it. The structure of the HTML is: <div class="story-postdate"> <div class="label-inline">Published</div> Feb 6, 2020, 4:40 pm SGT </div> I've tried `.findAll(attrs={'class' : 'story-postdate'})` and then tried to use the `sibling` selector. But no joy. I've also tried to target it with `.text` at the end of the CSS selector. But that still returns a none object type.
Try this from bs4 import BeautifulSoup from simplified_scrapy import SimplifiedDoc html = """<div class="story-postdate"> <div class="label-inline">Published</div> Feb 6, 2020, 4:40 pm SGT </div>""" # using BeautifulSoup soup = BeautifulSoup(html,features='lxml') print (soup.find('div',attrs={'class' : 'story-postdate'}).div.next_sibling) # using SimplifiedDoc doc = SimplifiedDoc(html) print (doc.select('div.story-postdate>div').nextText()) Here are more examples of SimplifiedDoc Library: <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, beautifulsoup" }
How to get current channel domain in pipeline based on the current application In pipeline, I need to get channel domain to which current application is assigned. I get current ApplicationBO instance but I haven't been able to get channel domain from it (I tried inspecting it in debugger, but I can only get domain for the application but not for the channel). This is how currently applications and channels are assigned: Company organization: * Channel 1 * App 1 <\--- Get Channel1 if in this app * Channel 2 * App 2 <\--- Get Channel2 if in this app Both applications share the common cartridge which contains pipeline in which I need to get current channel
There are two options: 1. Call pipeline `DetermineRepositories-Channel` which returns you a Repository object (that is the Channel). On the Repository use object path `Repository:RepositoryDomain` to get the Domain. I'm not sure how big the performance implication is though.. 2. Use object path `ApplicationBO:Extension("PersistentObjectBOExtension"):PersistentObject:Domain` to get the owning domain of the application itself. That will always be the channel(Domain). Because that's where storefront applications are born. In case you need to convert the Domain object to a Repository object you can use pipelet `GetRepositoryByRepositoryDomain`.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 2, "tags": "intershop" }
How to solve this complex limits at infinity with trig? Please consider this limit question $$\lim_{x\rightarrow\infty}\frac{a\sin\left(\frac{a(x+1)}{2x}\right)\cdot \sin\left(\frac{a}{2}\right)}{x\cdot \sin\left(\frac{a}{2x}\right)}$$ How should I solve this? I have no idea where to start please help.
A hint is given in the comment box, another hint is that $\lim_{x\rightarrow\infty}\dfrac{a(x+1)}{2x}=\dfrac{a}{2}$, then $\lim_{x\rightarrow\infty}\sin\left(\dfrac{a(x+1)}{2x}\right)=\sin\left(\lim_{x\rightarrow\infty}\dfrac{a(x+1)}{2x}\right)=\sin\left(\dfrac{a}{2}\right)$. The fact that one can swipe the limit and the $\sin$ function needs some justification, essentially it is about the continuity of $\sin$ at any point, in this case, it is at the point $a/2$: $|\sin u-\sin(a/2)|<\epsilon$ for all $|u-a/2|<\delta$, now choose a large $M>0$ such that $\left|\dfrac{a(x+1)}{2x}-\dfrac{a}{2}\right|<\delta$ for all $x\geq M$, then for such an $x$, one has $\left|\sin\left(\dfrac{a(x+1)}{2x}\right)-\sin\left(\dfrac{a}{2}\right)\right|<\epsilon$.
stackexchange-math
{ "answer_score": 2, "question_score": 2, "tags": "limits" }
_dontEnumPrototype method in ActionScript 3? What do _(undocumented)_ `_dontEnumPrototype`, `_init` and `_setPropertyIsEnumerable` methods of the `Object` class do ? * * * I'm just asking because I noticed how annoying it is to type the beginning of my fields and methods to make code completion do an _**acceptable**_ job. When I hit `Ctrl + Space` I expected a list with stuff that I want to be displayed. Instead I get ugly underscored methods that I never use. So now I'm interested what are they for ? Are they important ? "Goto Declaration" in FlashDevelop (4.2.3 RTM) takes me to `"[model] Object.as"`. !enter image description here After updating to FlashDevelop 4.6.1.30 the methods are still there.
I'm answering this myself because there is no other article about this like **in the whole internet.** `Menu` → `Tools` → `Program Settings` → `AS3Context` → `Lazy Classpath Exploration` false // to show those methods true // to hide those methods Just the solution (to hide those methods) no explanation, sorry. _(I tracked the`[model] Object.as` down to `C:\Program Files (x86)\FlashDevelop\Tools\flexsdk\frameworks\libs\player\11.5\playerglobal.swc`)_
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "actionscript 3, flash, object, actionscript" }
PHP get key value from array When I put `print_r($data);` I get the following Array ( [name] => Cheese ) Is there a way to get the key `name` in a variable on its own? There may be occasions that `name` could be `email` and other values.
Use `array_keys()`: var_dump(array_keys($data)); > Return all the keys or a subset of the keys of an array
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "php" }
Necessary to synchronize a concurrent HashMap when calling values()? In the following code: private final Map<A, B> entriesMap = Collections .synchronizedMap(new HashMap<A, B>()); // ... List<B> entries = new ArrayList<>(this.entriesMap.values()); If `entriesMap` is being accessed/modified by multiple threads in other methods, is it necessary to `synchronize` on `entriesMap`? In other words: List<B> entries; synchronize (this.entriesMap) { entries = new ArrayList<>(this.entriesMap.values()); } If I am correct, `values()` is not an atomic operation, unlike `put()` and `get()`, right? Thanks!
The problem is that even if `values()` itself were atomic, the act of _iterating_ over it is isn't. The `ArrayList` constructor can't take a copy of the values in an atomic way - and the iterator will be invalidated if another thread changes the map while it's copying them.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "java, concurrency, hashmap" }
Is this really an acceptable answer? I had just failed a review audit for the first time which had the following post: < ![Image of failed review audit - low quality posts]( "Click to zoom.") Shouldn't this be a comment, and if this was a comment, be flagged as "obsolete" as the questioner has updated the question? I'd really like an explain why this is an acceptable answer on Stack Overflow.
This is just one of those unfortunate situations where everything occurred out of order. The answer was selected as an audit candidate because of its upvotes, which most likely occurred _before_ the question was modified. During a review audit, you're not shown those votes. When evaluating low-quality posts, ask yourself the following questions: 1. Is it spam? 2. Is it "thanks?" 3. Is it "I have the same problem?" 4. Is it an attempt to ask a brand new question, or 5. Is it an attempt to answer the original question in any of its original incarnations, no matter how feeble the attempt, even if the answer is wrong? If the answer to the first 4 is no, and the answer to 5 is yes, it doesn't merit deletion.
stackexchange-meta
{ "answer_score": 16, "question_score": 4, "tags": "discussion, review, review audits, specific answer, disputed review audits" }
Python Runserver error based on Mac vs Windows Environment Nonexistant Parent Node Error the repository for this is. I'm using windows so I installed everything and I get this error, is there someway I could fix this problem on Windows, apparently it works fine on MAC, I used miniconda to install numpy and panda. Django and python 3.5 are also installed with system environment variable paths. Help would be appreciated. Thanks. New Error,Updated Final Edit: Solved the problem thank you.
1 - Have you tried install with virtual env? 2 - Which version of the Django are you using? You should use the 1.7... 3 - As the last resort I'd remove the patterns from the tournament/urls.py Original: from django.conf.urls import patterns, include, url NEW: from django.conf.urls import include, url I really think it is the django version the problem...
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, django, pandas, numpy" }
How to extract protocols (http)[s] to check url using shell script ## I have tried below one: * * * A= echo -e ${A//:*} _Result_ : **`https`** * * * **Please describe me that, how this`${A//:*}` term results https or http and what's the concept behind it, share a article or pdf if possible.** * * * ## For Worldwide web [www] **Its preety simple to extract this one:** * * * A=www.google.com echo -e ${A::3} * * * _Result_ : **`www`**
`${parameter:offset:length}` — This is referred to as Substring Expansion. In your example `${A::3}` means `${A:0:3}` and returns the first 3 characters of the variable `A`. `${parameter/pattern/string}` — This notation replaces the first match of pattern with a string. If pattern begins with `/`, all matches of pattern are replaced with string. In your example `${A//:*}` means `${A//:*/}` and it replaces all patterns `:*` with an empty string.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "linux, shell, kali linux, termux linux" }
Optional volume/secret volume in kubernetes? I'd like to mount volume if it exists. For example: apiVersion: v1 kind: Pod metadata: name: mypod spec: containers: - name: mypod image: redis volumeMounts: - name: foo mountPath: "/etc/foo" volumes: - name: foo secret: secretName: mysecret is the example from the documentation. However if the secret `mysecret` doesn't exist I'd like to skip mounting. That is optimistic/optional mount point. Now it stalls until the secret is created.
secret and configmap volumes can be marked optional, and result in empty directories if the associated secret or configmap doesn't exist, rather than blocking pod startup apiVersion: v1 kind: Pod metadata: name: mypod spec: containers: - name: mypod image: redis volumeMounts: - name: foo mountPath: /etc/foo volumes: - name: foo secret: secretName: mysecret optional: true
stackexchange-stackoverflow
{ "answer_score": 17, "question_score": 12, "tags": "kubernetes" }
How do I write up my models' code to fetch according to my database FirebaseDatabase1 modellogcatRefview
had to change: val model = snapshot.getValue(BestDealModel::class.java) tempList.add(model!!) to val model = itemSnapshot.getValue(BestDealModel::class.java) tempList.add(model!!)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "android, firebase, kotlin, getter setter" }
QImage class : file loading If I want to load file directly (`QImage i1("image1.jpg");`) where should I store it? If I have to give full path of file or only short path is required?
If you don't want to worry about an image (and you are not having too much of them), consider using Qt Resources. Qt Resources will embed the image into the executable independent of the platform. The images would be pulled from the filesystem at compile time, and an IDE like Qt Creator actually helps you with that. E.g. if you created an resource called "image" containing your file, you could reference your image by typing `QImage(":/images/image1.jpg")`
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 2, "tags": "qt" }
The reference to the class in ES6 is lost I have the following structure Javacript es5-es6 and the controller class loses the reference in the class Get, I was already investigating but I can not find how to avoid losing the reference. class Controller { constructor() { this.name = 'Test'; } test() { console.log(1, this.name); } } referenceController = new Controller(); // working reference: console.log(1, 'Test'); referenceController.test(); class Get { method() { return { controller: referenceController.test } } } // Lost self reference: console.log(1, undefined) new Get().method().controller()
In this section, you add the test function as a property of the returned object. { controller: referenceController.test } Then, when you call it as a method of that object (`method().controller()`) `this` refers to the object, and the `name` property is read from the object. You could bind the context to preserve the reference: referenceController.test.bind(referenceController)
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 4, "tags": "javascript, ecmascript 6, class reference" }
Symplectic structure on $Sym^kG^{\mathbb{C}} $ Let $G$ be a compact Lie group, and let $G^\mathbb{C}$ be its complexification. I am looking for a symplectic structure (without use of coordinates) on $$ Sym^kG^{\mathbb{C}}, $$ PS:Here $G^{\mathbb{C}}=T^*G$.(this equality is trivial by polar decomposition in the case, when $G$ is compact Lie group ) i.e. on the space of all symmetric tensors of order $k$ defined on $G^\mathbb{C}$.
Such a thing doesn't exist. The symmetric square of the cotangent bundle of a real $n$-dimensional manifold has dimension $n + {n+1 \choose 2}$, which is in particular odd whenever $n \equiv 2 \bmod 4$. So for example we can take $G = \text{SU}(2), G_{\mathbb{C}} = \text{SL}_2(\mathbb{C})$, which has real dimension $6$.
stackexchange-mathoverflow_net_7z
{ "answer_score": 2, "question_score": 0, "tags": "ag.algebraic geometry, lie groups, mp.mathematical physics, lie algebras, sg.symplectic geometry" }
How can I update an existing serverless 0.5.x stack with serverless 1.x? We have several aws stacks that were deployed using serverless 0.5 and now we are trying to move to serverless 1.x. We have migrated the configuration (serverless.yml) and all, but our problem comes when we try to update the actual stack. Serverless 1 uses deployment buckets that the old serverless 0.5 stacks don't have and we can't seem to get those buckets to create. We get the following error: `Resource ServerlessDeploymentBucket does not exist for stack <stack name>`. Is there any way around this other than simply deleting all the old stacks? Some of them have database tables and buckets associated with them and we can't risk loosing the data in them. Any help would be greatly appreciated.
OK, so I got around this issue by using the plug-in `serverless-plugin-create-deployment-bucket`. It works well and now I can take over old serverless 0.5 stacks... just need to be able to update lambdas now...
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "serverless framework, aws serverless" }
How to read .txt or .doc file in codeigniter? I am trying to follow this tutorial < and then I make this controller to display the file txt content which I call test.txt class File_controller extends CI_Controller { function __construct(){ parent::__construct(); $this->load->helper('url'); $this->load->helper('file'); } public function index() { $string = read_file(base_url().'test.txt'); echo $string; } } when I am testing this in browser no error is found, but the program is not displaying my file txt content,so 1.how to display test.txt correctly? 2.what the meaning is this parameter: './path/to/file.php' when I am using read_file('./path/to/file.php');
First off edit your project index.php and set the environment to development so that errors are properly displayed. You do have an error its just suppressed with this change it will show you your errors. First one I can spot myself I think - the php function is actually `readfile()` not `read_file()`. For your use I think you will find `file_get_contents()` works better. As regards your file path. As you have it your text file needs to be at the root of the project at the same level as your index.php file. It also will need to be readable. With error reporting in development mode you will get an error if any issues with path or permissions
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "php, codeigniter, filereader" }