INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Creating orientation Quaternion from forward vector Suppose that I have an orientation Quaternion `Q`, I can compute its forward vector from `V = Q * Vector3.forward` easily. Inversely, **suppose that I have its forward vector`V`, how do I compute `Q`?** I know that is not possible, please tell me what's needed beside `V`, in order to compute `Q`. Motivation behind the problem: I have a forward direction of a game object, I want to find out its up direction and its right direction. I can find out all these 3 directions if I have the orientation Quaternion.
You can calculate a `right` and `up` directly from the forward. however it is not going to be a unique `up` and `right` because there is an extra degree of freedom you need to consider. Code from Building an Orthonormal Basis, Revisited void branchlessONB(const Vec3f &n, Vec3f &b1, Vec3f &b2){ float sign = copysignf(1.0f, n.z); const float a = -1.0f / (sign + n.z); const float b = n.x * n.y * a; b1 = Vec3f(1.0f + sign * n.x * n.x * a, sign * b, -sign * n.x); b2 = Vec3f(b, sign + n.y * n.y * a, -n.y); }
stackexchange-gamedev
{ "answer_score": 0, "question_score": 0, "tags": "unity, rotation, vector, quaternion" }
How do I get the JS from Fomantic UI to work in my Ruby on Rails App? I'm looking to get the Calendar javascript functionality to work in my Ruby on Rails app, and it's not, and I'm wondering what I'm doing wrong? I've bundle installed both the `fomantic-ui-sass` and the 'jquery-rails'gems in my application, and put into the `app/assets/application.js` the following: // Loads all Semantic javascripts //= require semantic-ui // Load jquery // = require jquery // = require jquery_ujs I then put the JS code I found on Fomantic UI into the application.js file, e.g. $('#standard_calendar') .calendar() ;
There are two things wrong with the above code. Notice that there's a space `// =` instead of `//=`. Second, if the semantic-ui is dependent on jquery, jquery should be loaded first. See Fomantic UI: $(...).calendar is not a function
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, ruby on rails, semantic ui, fomantic ui" }
MultiTouch on Emulator It's possible to test the multi-touch feature into the AVD? I read this thread Android Multitouch - Possible to test in emulator? But it's for 2.0 and maybe this can be added since Jan/2010
Multi-touch is not supported in the emulator. There is an open issue in the Android issue tracker for multi touch support in the emulator. It's not accepted by Google but you can star it.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "android, android emulator, multi touch, android virtual device" }
WordPress Search not returning all post that contain query string I have a wordpress installation which contains many posts. When I search for a keyword such as "epic" it will return posts that contain "epic" in their titles but not if only the content contains "epic". **I need a way for the search to return all posts that contain the search keyword in either their title or content or tag.** I'm new to Wordpress backend development and every article/documentation I've read on WP search says that the search will search through content as well. I'm trying to stay away from plugins unless it's absolutely unavoidable. Any help is appreciated.
So I figured it out after messing around with some of the code in `wp-includes/query.php`. Evidently, WordPress does display all post that have the the keyword in the title and content however they display the list of results in order of posts with the keyword in the title first and then the posts that have the keyword in the content second. I need to have this display all the posts in order of their post date.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "wordpress" }
Regex to match a line if it has the word and the same word should not be selected I want a regex which needs to find a match if the next word is specifically given SAMPLE TEST ONE SAMPLE DIFF ONE My regex should select the line which don't have `TEST` next to `SAMPLE` It should select the line SAMPLE DIFF ONE
^(?!.*?\bSAMPLE\s*TEST\b).*$ You can add a simple `lookahead` for that.See demo. < Your regex will work too ,if you make `space` mandatory.The reason is if you dont have space mandatory after `SAMPLE` regex will check for `TEST` but there is a `space` So it will pass all. ^SAMPLE\s++(?!TEST).*$ See demo. <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "regex" }
Halachos for Counselors Suppose someone is going to be a counselor (in a camp) in the summer. What are some Halachos that specifically pertain to the job that he/she should review?
I'm thinking Lashon HaRa' and Hashavath Aveidah are probably among the two most prevalent sets of Halachoth that would require review. (Of course many other every day Halachoth would be relevant as well, but I'm considering those that might need to be refreshed.)
stackexchange-judaism
{ "answer_score": 7, "question_score": 9, "tags": "halacha, summer, employment" }
Generating sampling points - making series of points in the horizontal centre of a long polygon, equidistant spacing on vertical axis I have a polygon showing the extent of a beach. I would like to create a series of sampling points along that beach, that are equally spaced north to south (say at increments of 100m to the northing value), and lie in the approximate center of the beach polygon at that northing value. ![Sampling points along a beach]( How might I go about this in QGIS?
We will create an equally spaced grid, intersect it's horizontal lines with the beach and calculate centroids of each intersection. ## Steps 1. Use a projected coordinates system (such as UTM). 2. _Vector > Research Tools > Create Grid_ * Grid type: Line * Grid extent: [...] "Use Canvas Extent" or "Use Layer Extent..." * Vertical spacing: 100 ![screenshot of QGIS Create Grid dialogue]( 3. Select by Expression `y_min($geometry) = y_max($geometry)` to select horizontal lines ![screenshot of QGIS Select by Expression, selecting all horizontal lines]( 4. _Vector > Geoprocessing Tools > Intersection_ * Input Layer: Grid ([x] "Selected features only") * Overlay layer: beach ![screenshot of QGIS Intersection dialogue]( 5. _Vector > Geometry Tools > Centroids_ ![screenshot of QGIS Centroids dialogue]( ## Result ![a narrow polygon with equally spaced points](
stackexchange-gis
{ "answer_score": 4, "question_score": 3, "tags": "qgis, point, sampling" }
Calling Python functions passed by weakref Using Boost.Python, is there a way to call a Python function that's been passed through a `weakref`? The following code doesn't work: import weakref def foo(): print 'it works' def func(): return weakref.ref(foo) The following is the C++: object module = import("test"); object func(module.attr("func")); object foo = func(); foo(); // Should print 'it works', but it prints nothing However, if I pass the function object without weakref, it all works fine. Is there any way to make this work?
From weakref documentation: > Return a weak reference to object. **The original object can be retrieved by calling the reference object** if the referent is still alive... So, given your snippet: import weakref def foo(): print "It Works!" def func(): return weakref.ref(foo) ref = func() # func returns the reference to the foo() function original_func = ref() # calling the reference returns the referenced object original_func() # prints "It Works!"
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 0, "tags": "c++, python, boost" }
finding hour difference between two times in php not working I have 2 times in my sql table like 02:56:07pm and 03:56:14pm, so i converted it like: $time1 = date("G:i:s", strtotime($row['timein'])); $time2 = date("G:i:s", strtotime($row['timeout'])); which gives me two times like 14:56:07 and 15:56:14 now am trying to find the difference in hours between this two times and I did like below: $difference = round(abs($time2 - $time1) / 3600,2); echo $difference; but here am getting 0 as answer
This works for me: Using strtotime that converts a date/time string into a Unix Timestamp (eg. 163612416703). Now calculations can be done on the times. $time1 = strtotime('02:56:07pm'); $time2 = strtotime('05:56:14pm'); $difference = date('H:i:s', ($time2 - $time1)); echo $difference; //03:00:07 Play around with the formatting etc..
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "php, mysql, datetime" }
Lower bound on divisors of $\Phi_n(n) $ Take the nth cyclotomic polynomial $\Phi_n(x)$ and let $\phi$ be the Euler totient function. I can prove that all divisors $d$ of $\Phi_n(n)$ are such that $d \ge \phi(n)$ or $d = 1$. The proof is not that intuitive and involves algebraic number theory. I'm wondering if there is an intuitive elementary proof of this fact. Example $n=5$: $\Phi_5(5) = 781 = 11 \times 71$ $\phi(5) = 4$ and indeed both $11, 71$ are larger than $4$
I'm not sure if you will find this proof intuitive, but it is certainly elementary. Cyclotomic polynomials have the following (elementary) property: > If $n>0$ and $a\in\mathbb Z$, then every prime divisor $p$ of $\Phi_n(a)$ satisfies either $p\mid n$ or $p\equiv1\pmod n$. A proof can be found for example [here [Theorem 6]]( In our case $\Phi_n(n)\mid n^n-1$, so if $p\mid\Phi_n(n)$ we certainly have that $p\nmid n$. From the property above it follows that every prime divisor of $\Phi_n(n)$ is at least $n+1$, which is bigger then $\phi(n)$.
stackexchange-math
{ "answer_score": 1, "question_score": 2, "tags": "elementary number theory, algebraic number theory" }
rsnapshot: why daily/weekly/monthly instead of many daily backups? The daily/weekly/monthly backup scheme is often recommended for backups. As far as I understand rsnapshot, backups are really cheap due to hardlinking. Is there any advantage of say retain daily 7 retain weekly 4 retain monthly 12 compared to retain daily 365 if every new backup just takes a little disk space?
They're cheap, but they're not free. You can keep a year's worth of dailies if you want, and if you've got the space, but the moment you start to have disk space pressure, the cost/benefit of keeping them all isn't going to be worth it. Once you're more than a week out, the need for such high fidelity backups tends to disappear.
stackexchange-serverfault
{ "answer_score": 5, "question_score": 3, "tags": "backup, rsnapshot" }
transform the shape from (X, 1) to (X) There is an existing train_labels, which has the following attributes ('labels_train shape ', (3000,)) ('type of labels_train ', <type 'numpy.ndarray'>) and another array is Y, which has the following attributes ('Y ', (3000,1)) ('type of Y ', <type 'numpy.ndarray'>) How to assign `Y` to `labels_train`, or how to make `Y` has the same shape as `labels_train`?
If you want to copy over the content from `Y` to `labels_train`, the following should work. labels_train[:] = Y[:,0] If you want to reshape `Y` to have the same shape as `labels_train` (this only works if they have the same number of elements). Y = Y.reshape(labels_train.shape)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python, numpy, scipy" }
How to unescape/decode escaped HTML characters? When I using nokogiri to parser htmls, the Chinese characters are transfer to escaped sequences like "`&aring;&middot;&#133;&aring;&sup3;&deg;&aring;&raquo;&para;&aelig;&#151;&para;`" How could I decode the escaped characters like "`&aring;&middot;&#133;&aring;&sup3;&deg;&aring;&raquo;&para;&aelig;&#151;&para;`" back to normal characters?
It looks like your HTML page is encoded as UTF-8 but you are parsing as ISO-8859-1. You need to ensure you specify the correct encoding when parsing. If you are parsing from a string Nokogiri should use the same encoding as the string. If you are parsing from an IO object you can specify the encoding as the third argument to the `parse` method: Nokogiri::HTML::Document.parse(io_object, nil, 'UTF-8')
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ruby, nokogiri" }
SQL REPLACE value based on position in string I have a column where the values are all in this format '###-##-#-##-##-###-##-#' I need to format all of the values to where the 2nd to last hyphen is replaced with a period '###-##-#-##-##-###.##-#' Can I use REPLACE based on the position in the string? Example would be changing '068-27-0-40-12-012-00-0' to '068-27-0-40-12-012.00-0'
Assuming you are in sql server, use the STUFF method to get your work done. SELECT STUFF('###-##-#-##-##-###-##-#', 19, 1, '.'); First parameter - character expression Second parameter - starting from nth position Third parameter - no of positions to be replaced Fourth parameter - string to be replaced
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql, sql server, replace" }
What is the equivalent of register-defaults="false" in Spring 4? How can I configure my custom message converter to have **`register-defaults="false"`** in a XML-less project with Spring 4? <mvc:annotation-driven register-defaults="false"> <mvc:message-converters> <bean class="myproject.MyCustomHttpMessageConverter"/> </mvc:message-converters> </mvc:annotation-driven> Currently I have this `Configuration`: @Configuration @EnableWebMvc @ComponentScan public class TestDataConfig extends WebMvcConfigurerAdapter { @Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); converters.add(converter); } } Thank you
Your Java Configuration as it is, is similar to the one with `register-defaults="false"` in XML Configuration. You don't need to do anything. But if you want to Register Defaults you would have to extend from `WebMvcConfigurationSupport` and add the last line specified in the below code snippet. @Configuration @EnableWebMvc @ComponentScan public class TestDataConfig extends WebMvcConfigurationSupport { @Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); converters.add(converter); super.addDefaultHttpMessageConverters(); // Have to call this explicitly to register Default Message Converters. } }
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 7, "tags": "java, spring, spring mvc" }
Magento 2: Uncaught Error: Call to a member function setProduct() on boolean I'm trying to update the product widget to show some custom product data like that <?= $block->getChildBlock('name-of-block')->setProduct($_item)->toHtml() ?> while this code works fine on list.phtml in the CatalogWidget's grid.phtml it cannot set the product
Actually, the problem was that I had to get the layout first, so the working code was ` <?= $block->getLayout()->getChildBlock('name-of-block')->setProduct($_item)->toHtml() ?>`
stackexchange-magento
{ "answer_score": 0, "question_score": 1, "tags": "magento2, widget" }
c# virtual keyboard p/ invoke shift wont "release" key # My current code is: [DllImport("user32.dll", SetLastError = true)] static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo); public const int KEYEVENTF_EXTENDEDKEY = 0x0001; //Key down flag public const int KEYEVENTF_KEYUP = 0x0002; //Key up flag public const int VK_RMENU = 0xA5; keybd_event(VK_SHIFT, 0, KEYEVENTF_EXTENDEDKEY, 0); keybd_event(VK_Q, 0, KEYEVENTF_EXTENDEDKEY, 0); keybd_event(VK_Q, 0, KEYEVENTF_KEYUP, 0); keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0); I get the capital Q as needed, but the problem is, the "Shift" sticks. All letter after that are all capital. the only way to get lowercase is to change to caps lock. How can i solve this problem? Thanks in advance
I believe Cody Gray gave you the resolution for your issue. Just replace your P/Invoke calls with: keybd_event(VK_SHIFT, 0, 0, 0); keybd_event(VK_Q, 0, 0, 0); keybd_event(VK_Q, 0, KEYEVENTF_KEYUP, 0); keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c#, pinvoke, shift, virtual keyboard" }
What recordings does there exist of Lester Young playing along with Dizzy Gillespie? Does there exist recordings of Lester Young playing with Dizzy Gillespie, or with Miles Davis?
**Lester Young / Charlie Parker / Dizzy Gillespie ‎– Early Modern: 1946 Concert Recordings** Label: Milestone Records ‎– MSP 9035 Format: Vinyl, LP, Compilation Country: US Released: 1971 Genre: Jazz Style: Bop, Swing **Miles Davis With Modern Jazz Quartet, The & Lester Young ‎– European Tour '56 With The Modern Jazz Quartet & Lester Young** Label: Definitive Records (2) ‎– DRCD11294 Format: CD,Compilation Country: Europe Released: 2006 Genre: Jazz
stackexchange-musicfans
{ "answer_score": 6, "question_score": 8, "tags": "jazz" }
how to query list of data on firestore? I have a list. I need to check with field on firestore. var ref = _db.collection('requirement') .where('subCategory.id',arrayContains: ['8ZaGrU1kMGqxnYWBGO5R','UHtbfwoHOtdZ1rwlpjFE']); this way is not working.
Possible with IN queries but i think the update will come late to flutter < **Updated:** < 0.12.11 # Added support for in and array-contains-any query operators.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "firebase, flutter, dart, google cloud firestore" }
Is it possible to multiply the string 10 with number 10 Multiplying `'10' * 10` is giving some output value `10101010101010101010` Could any one justify it? ExpressionParser parser = new SpelExpressionParser(); System.out.println(parser.parseExpression("'10' * 10").getValue()); Output : `10101010101010101010`
> It should throw some exception as in java we cannot multiply string with number. SpEL **is not Java** it has some similarities, but it's **not Java**. It doesn't have lambdas, it has different syntax for many things. The multiplier operator applied to a string means concatenate the string that number of times. Similar to `'10' + '10' = '1010'`, `'10' * 2 = '1010'`. Javadoc in the `OpMultiply` class: /** * Implements the {@code multiply} operator directly here for certain types * of supported operands and otherwise delegates to any registered overloader * for types not supported here. * <p>Supported operand types: * <ul> * <li>numbers * <li>String and int ('abc' * 2 == 'abcabc') * </ul> */
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "java, spring, spring el" }
Would it be possible to genetically engineer wings onto humans? This is entirely hypothetical, but there is human gene editing equipment. It is hypothetical because the wings would not work, unless they were ultra-light and the wingspan was 60 feet.
Bird people _maybe_ , but not angels. It's virtually impossible to put working wings on a human, and have them continue to look anything remotely human. Even if you were to get past the wingspan weight problem there is a much larger barrier, muscle placement. Humans have arms, and we often think of the arm muscles being in the arms, but that's not true. The most important muscles for the arms are in our chest and back. Another set of appendages, be it extra arms, legs, or wings would need a similar amount of support muscles on the torso. As a human looks right now there is simply nowhere to put them and still look human. So the best we can do is modify arms into wings. Problem is now if you need a huge wingspan, you need arms to be that long. You probably also need to modify most of the human biology to lower the weight. At the end you are going to end up with something that most likely does not even remotely look or seem human anymore.
stackexchange-worldbuilding
{ "answer_score": 0, "question_score": -4, "tags": "genetics, wings" }
What is the purpose of the _daemon directive in fail2ban? A number of the filters that come with `fail2ban` have a `_daemon` directive, but there is no mention of it in the documentation and no reference to it in any of my jail definitions. What's it for?
The `daemon` directive is used to construct the `__prefix_line` regular expression that many of these filters use. It allows the filter to ignore lines that come from other services, but may otherwise match your regular expression. You can see references to `_daemon` in the `filter.d/common.conf` file.
stackexchange-serverfault
{ "answer_score": 4, "question_score": 6, "tags": "fail2ban" }
Vertical smooth scrolling of values in a text view I have a text view where in i have to keep ages between 1-99. I also have two buttons ^ and v(i mean up and down arrows) on clicking them the values of the age should smoothly scroll to next or previous value. I have been trying different ways but couldnt achieve smooth scrolling. Can anyone please give me any idea of how to achieve the task.
Use the animation framework. When pressing down, start the 'down'-animation. When pressing up, start the 'up'-animation. Read more about animation here: <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "android, scroll, vertical scrolling" }
How to mathematically derive Height & number of Leafs of this Recursion Tree I was studying following tree and get stuck on deriving it's Height & number of Leafs: ![image from clrs book]( **It says the height is [log bn ]: How to derive it?** (also i think height = [logbn] + 1) **How They derive number of Leafs:** **a logbn = nlogba** Please help me to mathematically derive Height & number of Leafs of this Recursion Tree in a very simple way.Thanks
**Height** The top of the tree begins with **n** and for every step down it is divided by **b**. So it goes n, n/b, n/b2,...,1. To find the height we need to find a **k** such that n / bk = 1 or **b k = n**, which gives **k = log bn**. **Number of leaves** For every step down the tree, the leaves are multiplied by **a** times. The number of leaves is **a k**, where k is the number of steps or height of the tree. **The number of leaves = a logbn.**
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "algorithm, recursion, tree, logarithm, recurrence" }
ClearInterval() won't stop my rotate function I'm using the jQuery Rotate plugin, to animate the rotation of an image 90 degrees, and then stop the rotation. My problem is that it won't stop rotating, even after calling clearInterval(); $(document).ready(function() { var finalAngle; var intval = setInterval(function func() { $("#myimg").rotate(1); if(typeof func.angle == 'undefined' ) { func.angle = 0; } func.angle += 1; finalAngle = func.angle; }, 1); if(finalAngle == 90) { clearInterval(intval); } }); Basically all I'm doing is (statically) counting the angles, and once it hits 90, call the clearInterval function. I had to introduce another variable to store the count so that I could access it outside the setInterval function.
It's easy. `setInterval` is called then the condition with `finalAngle` is evaluated and after one milisecond your rotating function is called. Therefore `clearInterval` is never called when `finalAngle` is 90. This code should work for you: $(document).ready(function() { var intval = setInterval(function func() { $("#myimg").rotate(1); if(typeof func.angle == 'undefined' ) { func.angle = 0; } func.angle += 1; if (func.angle == 90) { clearInterval(intval); } }, 1); });
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "javascript, jquery, rotation, intervals" }
Calculating number of coins Q:I need to pay somebody 49 'fake-currency'. I have coins of denomination 1,2,3,4 and 5 and I can pay the amount with a maximum total of 15 coins. Let there be **M** ways of paying. Find the last 3 digits of M. * * * So I wrote a solution in javascript: function pay() { var waysOfPaying= 0; for (e = 0; e < 10; e++) { for (d = 0; d < 13; d++) { for (c = 0; c < 16; c++) { for (b = 0; b < 16; b++) { for (a = 0; a < 16; a++) { if ((a + b + c + d + e <= 15) && (a + (2 * b) + (3 * c) + (4 * d) + (5 * e) == 49)) { waysOfPaying++; } } } } } } return waysOfPaying % 1000 ; } The answer my code gives is 333 however the correct answer is 714. What did I do wrong?
Your algorithm is oriented towards the value of each coin. The problem is that it lost the importance of order: It finds that 9 coins with a value of 5, plus 1 coin with a value of 4 adds up to 49. But it misses the fact that 8 coins with a value of 5, followed by 1 with a value of 4, followed by another 5 also adds up to 49. The original problem is based on moving from space to space, building a trail of moves to square 50. Focus on where you are, instead of the jump value. Think of the decision to be made on each space: \- Are you on space 50? if so, you found a valid trail, count it. \- Are you past square 49, or have you taken 15 moves to get here? If yes, this trail is ended, and there is no point jumping any further. \- If no, then you can make 5 possible moves: jump 1, 2, 3, 4 or 5 spaces. After each one, evaluate your position again. Hint: use a recursive function to simulate your actions on a space.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "javascript" }
Quickfix contains tag Is there an easy way in Quickfix/J of telling whether a FIX message contains a tag which is located in a repeating group? I would like to know if a MarketDataSnapshotFullRefresh contains a bid/ask or a Ticker update without processing the message... i.e. if I could detect the presence of TickDirection (tag 274) I would know the snapshot is a Ticker update and deal with it appropriately. The hacky way to do this would be to get the String and look for 274= but was hoping there was a way to do this within the API. Thxs.
As answered by DumbCoder above: I don't think there is any other way than the 2 you have mentioned. Logically speaking there isn't any.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, quickfix, fix protocol" }
Install MVC 2 after Visual Studio 2010 I have installed Visual Studio 2010 (final) and then Visual Studio 2008. Now I have to open a project with VS2008 that uses MVC2. Is there any problem to install MVC2 after VS2010?
If you want to have the Visual Studio 2008 ASP.NET MVC Project Template, then yes you need to install it, otherwise the assemblies are already in the GAC. Also the project you are trying to open must have been created with VS2008.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "asp.net mvc, visual studio 2008, visual studio 2010" }
SQL Server 2008 R2 Transaction is @@error necessary and is ROLLBACK TRANS necessary My colleague has this in a procedure: BEGIN TRAN --Some deletes and inserts IF(@@error <> 0) BEGIN ROLLBACK TRAN RETURN END COMMIT TRAN I have another in a stored procedure that simply is: BEGIN TRANSACTION --Some deltes and inserts COMMIT TRANSACTION I have tested and found that my procedure always rolls everything back during an error (tested for example changing a column data type etc.) without explicitly coding a rollback. Also I have read that using `@@error` condition is outdated for SQL Server 2005 and above. What would you say is the correct way of doing a transaction for SQL Server 2008 R2 and above? Thanks
**YES** , the `ROLLBACK` is necessary! I would do a stored procedure based on this template for SQL Server 2005 and newer: BEGIN TRANSACTION BEGIN TRY -- put your T-SQL commands here -- if successful - COMMIT the work COMMIT TRANSACTION END TRY BEGIN CATCH -- handle the error case (here by displaying the error) SELECT ERROR_NUMBER() AS ErrorNumber, ERROR_SEVERITY() AS ErrorSeverity, ERROR_STATE() AS ErrorState, ERROR_PROCEDURE() AS ErrorProcedure, ERROR_LINE() AS ErrorLine, ERROR_MESSAGE() AS ErrorMessage -- in case of an error, ROLLBACK the transaction ROLLBACK TRANSACTION -- if you want to log this error info into an error table - do it here -- *AFTER* the ROLLBACK END CATCH
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 2, "tags": "sql, sql server 2008, transactions, sql server 2008 r2" }
UITabBarViewController doesn't rotate - iOS I have a `UITabBarViewController` that contains 5 tabs and a login view which is not part of my tab bar, in my settings I have set that I support all device orientations. but when I run my app, only my login view is the only which rotates. I have created a custom `UITabBarController` and implemented these methods -(BOOL)shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } still my tabbar doesn't rotate, but I can see that my status bar disappears when change my device orientation to landscape. How can I solve this?
Try to override this method, don't call super - (void)viewWillTransitionToSizeCGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { //[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; [self.selectedViewController viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ios, uitabbarcontroller, autorotate, shouldstartload" }
"Device connection lost " error in android app I am finding "a device connection lost" error when i am getting values from external sensor and displaying in android app and web service. I can display some values but after some time the app is closing by giving message "device connection lost". If anybody can help me by letting me know whats the main reason to lost connection, will be really appreciable. Thx in advance
Two things : 1. Try different USB ports on your computer. 2. Check if the USB cord you are using is faulty.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, php, android, rest, sensors" }
Printing a list to a Tkinter Text widget I have a list of strings, and I want to print those strings in a _Tkinter_ text widget, but I can't insert each string in a new line. I tried this but didn't work: ls = [a, b, c, d] for i in range(len(lst)): text.insert(1.0+i lines, ls[i])
Append newline (`'\n'`) manually: from Tkinter import * # from tkinter import * lst = ['a', 'b', 'c', 'd'] root = Tk() t = Text(root) for x in lst: t.insert(END, x + '\n') t.pack() root.mainloop() BTW, you don't need to use index to iterate a list. Just iterate the list. And don't use `list` as a variable name. It shadows builtin function/type `list`.
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 4, "tags": "python, text, tkinter, widget" }
use regex or php function to get all characters before ":" (colon) I have many fields that are like this pattern: re2man: (johnny bravo) re1man: (john smith)...... user: (firstname lastname).. I wanted to use regex, or another php function to get only characters before the colon (":")
Look at `explode()` to simply split the string at the ':'. For instance, `list($username) = explode(':', $string);` (`list()` is being used to assign just the first part of the exploded string to `$username` and discard the rest; a longer way to do it would be: $parts = explode(':', $string); $username = $parts[0]; Also, you could use the extra limit parameter to indicate that you don't need the rest of the parts, like: `list($username) = explode(':', $string, 1);` That may or may not be faster. Also, I would expect using `explode()` to be more efficient than some of the other regex-based solutions offered.
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 2, "tags": "php, regex" }
How to write htaccess rule to redirect all the url's that contains the text between the slashes to a page How to write htaccess rule to redirect all the url's that contains the sometext word between the slashes Ex: ALL THESE need to redirect to a single page. Thanks for help in advance.
Try this then: RedirectMatch ".*\/sometext(.*?)\/" "
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -3, "tags": "php, .htaccess, url" }
Not receiving any push notification in iPhone I have made a sample PushTest app for Push Notification using this tutorial. And using above tutorial I got the message that 'PushTest' would like to send you Push Notification (exactly once) and after that I delete the app from iPhone, restart the iPhone but unable to get the same message again. I have run the script sample.php (updating the changes suggested) and got the message 'connected to APNS' & 'your message send'. But I didn't receive any single push notification. Please guide me where I am wrong? Or what shod I try for push notification receive.
You will not receive Push only in 2 cases 1.) If your application is in foreground. 2.) you device token is not valid for receiving the push notification please check both the condition if you still do not receive push please let me know. Thanks
stackexchange-stackoverflow
{ "answer_score": 30, "question_score": 23, "tags": "ios, iphone, objective c, push notification, apple push notifications" }
How to know name of the person in the image? I implemented face recognition algorithm in raspberry pi(python 2.7 is was used), i have many sets of faces, if the captured face is one in database then the face is detected(i am using eigen faces algo). My question is can i know whose face(persons name) is detected? (can we have sort of tags to image and display name corresponding to it when the face is detected) Note: OpenCV used
You can use the _filename_ of the image for that purpose. All you need to do is keep the filenames stored somewhere in your application, alongside the `Mat` objects.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python 2.7, opencv" }
Calculus - How to disprove one function greater than another? I have the below inequality which I know is not true. A, B, and x are all within (0, 1) and B > A. If I replace values for A, B, and x, the inequality doesn't hold. But I am not able to prove it (or in other words, disprove it). $$\frac{e^{xB}}{e^{xA}} \gt \frac{xA-1}{xB-1}$$
Note that $$\frac{e^{xB}}{e^{xA}} \gt \frac{xA-1}{xB-1}\iff xB-xA >\log(1-xA)-\log(1-xB)$$ $$\iff \log(1-xB)+xB>\log(1-xA)+xA$$ which is false, indeed $$f(y)=\log(1-y)+y\implies f'(y)=\frac{-1}{1-y}+1=\frac{-y}{1-y}<0 \quad y\in(0,1)$$
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "calculus" }
text substation in zsh/oh-my-zsh having a strange problem since starting to use zsh, which is not present in bash. I am using both zsh and oh-my-zsh, I think I have narrowed the problem to oh-my-zsh My old password has a !2 in it. When I type !2 the text gets replaced to cd ->dev [jellin:~]$ !2 [jellin:~]$ cd dev haven't a clue whats doing this. Any ideas? Seems like an odd substitution.
This is simply history id expansion. To prove this, $ history | grep 'cd dev' | head You will see that around id 2, you did a `cd dev`.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "zsh, oh my zsh" }
datatable fnReloadAjax success I need to use icons but they disappear when I reload the datatable. When I declare the datatable I use fnInitComplete "fnInitComplete": function(oSettings, json) { $(".readable_row").button({icons:{secondary:"ui-icon-folder-open"}}); $(".editable_row").button({icons:{secondary:"ui-icon-wrench"}}); } Is there a way to use fnInitComplete with fnReloadAjax? Or maybe a to wait for fnReloadAjax to succeed in retrieving data and reloading the datatable?
Using a handler attached to the draw event I was able to re-attach the icons. I didn't even have to use `fnInitComplete`. Using `.on()`: $("#example").on("draw", function() { $(".readable_row").button({icons:{secondary:"ui-icon-folder-open"}}); $(".editable_row").button({icons:{secondary:"ui-icon-wrench"}}); }); I had to use `.delegate()` since I had an older version of jQuery : $("body").delegate("#example", "draw", function() { $(".readable_row").button({icons:{secondary:"ui-icon-folder-open"}}); $(".editable_row").button({icons:{secondary:"ui-icon-wrench"}}); });
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jquery, ajax, jquery ui, datatable" }
Do Login Flows Get Triggered when attepting to "Login As" another User? I'd like to create "Test Users" for QA personnel to login into Production during deployment. I want to use delegate administration so I can manually login as these test users and grant account login access to QA personnel. I'd like to add extra security and use a "Login Flow" to only allow QA personnel to login as the Test Users during Support Hours. My question is does the "Login as" link trigger a Login Flow?
I spoke to our Salesforce team that owns this feature and confirmed that when logging in as another user that has login flows on their profiles, the admin user is not subject to login flows. And when an admin user has login flows on their profile and they log in as another user, the admin user isn't subject to login flows when they click the Login link. The admin still has to complete login flows when they login to the app with their own user credentials. We are also working on documenting this information about how Login As and Login Flows interact and will update this thread as I have more information. Thank you
stackexchange-salesforce
{ "answer_score": 2, "question_score": 2, "tags": "login, grant login access, loginflow, delegated authentication" }
R Install and load packages from a specific location I am using windows 7, I can't seem to find the solution to this very simple issue on the internet. I get an error saying that cannot Install package to a location I don't know about (I:/R/win-library/3.5). How can I change that so the packages are installed to a location I choose and so that it loads from that location? I read about changing the environment variables in control panel, but R Studio is not listed. Many thanks!
You can change the directory were packages are installed (and searched) with `.libPaths()`. If you want to add a new directory you can run .libPaths("new/directory")
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "r, package" }
In a Javascript event, how to determine stopPropagation() has been called? If `e.preventDefault()` is called, can see reflected in `e.defaultPrevented` method. Is there a similar property for `e.stopPropagation()`? If not, how to determine?
I haven't looked through jQuery to see their method, but it seems you could override the `stopPropagation` method on the base `Event` object, set a flag, and then call the overridden method. Something like: var overriddenStop = Event.prototype.stopPropagation; Event.prototype.stopPropagation = function(){ this.isPropagationStopped = true; overriddenStop.apply(this, arguments); }
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 12, "tags": "javascript, triggers, dom events" }
Deployment warning for JBoss 4.0.4 WARN [SchemaTypeCreator] JAX-RPC does not allow collection types skipping: My web service can deploy and work fine with JBoss 5.0 but it gives above warning when try to deploy on JBoss 4.0.4 for following method @WebMethod public AccountSummary getAccountSummaryForCustomer(String customerID) { //AccountSummary class has two ArrayLists as attributes return AccountSummary; } I think sum libraries are missing in my server. How can I identify those libraries or solve this issue.? This is the complete Warning on server terminal WARN [SchemaTypeCreator] JAX-RPC does not allow collection types skipping: com.directfn.webservices.AccountSummary.cashAccountDetails WARN [SchemaTypeCreator] JAX-RPC does not allow collection types skipping: com.directfn.webservices.AccountSummary.portfolioDetails
Most probably your method’s return object AccountSummary may contain collection types that does not support the above jboss version. If your class contains any attributes as Object[] arrays, change them to specific object types. Eg: change **Object[]** to **someClass[]** , hope this will help you!
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, web services, jboss, jbossws" }
Using a 3rd party control Please excuse the noobness that is probably about to follow... I'm making an vb.net 2010 app which needs to have a calendar system in which the user can add appointments and events etc. I've downloaded the source for a control which looks promising (< but I have no idea how to add this in to my project. I've googled for help on adding the control but have had no luck. If I right click on my toolbox, go 'choose items...' and try and add it there, it tells me it couldnt be opened. Any help is appreciated!
Well you've downloaded the source code. Place the source code in a specific location on your pc and then compile it 9If your planning to use this control in your own project then compile it in release mode. Assuming that there are no compile errors close visual studio and then open up the project of your own that you want to use this control in. Right click on the general tab in the toolbox and click choose items. Using the bowse button in the choose items dialog navigate to the folder in which you placed the source code for the control you want to use. Now locate the 'Bin' folder and in that locate the 'release' folder. Inside that you will see a dll (named presumably something like MothCalendar.dll. Select that dll and then click add and OK (Button sequence will vary according to vs version). The control should then appear in your toolbox under the general tab and you should then be able to drag it onto your forms for use in your project.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "vb.net, calendar, controls" }
Почему нельзя сделать свой оператор С++ Почему нельзя перегрузить свой оператор? Это же удобно.
При создании своих операторов встает масса вопросов - в частности, об их приоритетах, ассоциативности и тому подобном. Все это следует каким-то образом пояснять компилятору. Кроме того, возникает ряд проблем с синтаксическим анализом исходного кода. При этом многие авторы умных книг, мягко говоря, не в восторге от возможности переопределения даже имеющихся операторов. Особенно если их семантика оказывается далекой от семантики стандартных операторов. Такие удачные перегрузки, как `>>` и `<<` \- скорее исключения, подтверждающие правило..
stackexchange-ru_stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "c++, перегрузка операторов" }
What is the phrase 'spot of black' supposed to mean here? I read a sentence in a chapter in textbook which was: > But Sadao, searching the **spot of black** in the twilighted sea that night, had his reward. There was no prick of light in the dusk. No one was on the island. Let me provide you the context here. Sadao was helping a person in escape by instructing him to go to an island and flash a torch if he was there the next day. But he had gone so there was no prick of light. But I want to ask what he means by searching the "spot of black". He should've searched for light not for blackness. Moreover I think "black" has been used as a noun here and no definition for the noun sense of "black" seems to fit for me here. Does "of black" mean "having the color black" here? What am I missing?
The "spot of black" refers to the **island** which is silhouetted against the twilight sea, where blackness is all there is to be seen. I think this is literary device, intended to be set against the following "prick of light." * spot of black * prick of light The first is set against twilight, the second against dusk, and both synonyms contrast with the absence, or presence, of light. Unusually, it is the absence of light which is preferred.
stackexchange-ell
{ "answer_score": 1, "question_score": 0, "tags": "grammar" }
How to git grep the main repository and all its submodules? I found this at a blog to grep project and submodules: [alias] sgrep = "!f() { git grep \"$1\"; git submodule foreach \"git grep '$1'; true\" | grep -B 1 \"$1\"; }; f" I updated my `~/.gitconfig` to include it, but when I use the alias, it says: `fatal: bad config file line 9 in /home/myname/.gitconfig` What am I doing wrong?
Generally, similar to "GitConfig: bad config for shell command", it may be because the '`\`' character is interpreted by git first, before being executed in a shell. But in your case, this should work as expected because of the surrounding double-quotes. It does work on my git 1.8.4 on Ubuntu. So simplify your `.gitconfig` and check if works better if it contains your alias (and _nothing_ ) else. If that does work, then the issue is elsewhere in your config file.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 16, "tags": "git, grep, git submodules" }
android Reading image into byte array and last byte of image Android: I have two byte arrays one byte array of bitmap and another byte array of String. I have combine these two byte arrays into 3rd one. I will write 3rd byte array into storage. When i read that image which is created from combine byte array of image and string i want to know in byte[] that where image bytes ends and where string bytes gets start. How do i know the byte representation of end of image byte ? or starting of string byte ? Thanks in advance.
Before you write out the byte array, you should write out the length of the image part. That way you'll know how much data to read. So your file will look like this: * Length of image (4 bytes, probably - use `DataOutputStream` for simplicity) * Image data * Text data (As an aside, I suggest you explicitly write out the text data as UTF-8, and read it as UTF-8. Or you could just use `DataOutputStream.writeUTF` and `DataInputStream.readUTF` of course...)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "android, image, eof" }
Highstocks, line missing but data is there I've been playing around with Highstocks for a while now and for some reason one of my lines has disappeared when zooming in, yet it is still visible once zoomed out. It still shows the dot once hovering over it including the data that belongs to it. Needless to say I'm pretty clueless about what went wrong, so any suggestions would be great. Zoomed in: !Zoomed in Zoomed out (hard to see but the red line is there) !Zoomed out PS. Website can be found here Skami.net
Your series contains doubled values for the same data, for example: [1368450000000, null], [1368450000000, 117.200050354004], [1368451800000, null], [1368451800000, 117.599990844727], [1368453600000, null], [1368453600000, 117.710151672363] Which is not allowed in Highcharts. Remove extra point and will be working fine.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "highcharts" }
Is there any way to explicitly send event message to dead letter queue from inside AWS lambda function on certain condition? I'm trying to send s3event message to rabbitmq by invoking AWS lambda function. I have configured SQS as my dead letter queue(DLQ). I know the message is sent to DLQ when there failure in invocation of lambda or situations like timeouts or resource constraints. My question is ,I want to send event message to DLQ from inside lambda function on certain condition like if rabbitmq is down or some other condition of my interest. Is there any possiblity for the same? Should I throw exception or there is some other better approach to send event message to DLQ. I'm using java for development and connecting to rabbitmq from my lambda function.
The DLQ is simply an SQS Queue, so you could send a message to it like you would any other queue. You would want it to be formatted the same way that Lambda natively puts message in the DLQ so that whatever processing you have on the DLQ can perform the same way for all messages. You would want to ensure that you treat the lambda as successfully executed in this instance though so that the normal DLQ process doesn't pick up the same message twice.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 7, "tags": "amazon web services, amazon s3, aws lambda, dead letter" }
Why Business Class router don't usually include ADSL? I am shopping for a good VPN router to replace my terrible stock ADSL modem + router from my ISP, which need to be restarted 4 times a day. This is for my office use, which connected by around 17 devices or more in the future, and also able to setup a VPN for my sales person to access intranet web server. While searching around, I find that most business router don't come with ADSL2+ connection. This mean I need to spend money for a modem too. My question is, why don't they design a modem + router device just like consumer router? And when I search for "business modem", I don't get much useful result... How do small business design their Network and connect to internet?
Because "business class" implies use in many situations where the service may be supplied by something other than ADSL. Combined router/modems are pretty much a home/consumer niche device. * Getting your signal via DOCSIS cable? ADSL is useless to you. * Got a Fiber line? - ADSL is useless to you. * Got an ethernet feed from a provider in your office building? ADSL is useless to you. Likewise, a true "business class" router is hardly ever _also_ a WiFi access point (and if it claims to be the one and has the other built in, I'll tend to regard its claims of business-class as bogus until proven otherwise.) Meanwhile most consumers don't even know the difference between the two functions.
stackexchange-networkengineering
{ "answer_score": 2, "question_score": 2, "tags": "router, adsl, cisco small business, modem" }
Non-Isomorph trees of a graph Please consider this graph !enter image description here How many non-Isomorph trees with 4 vertex has this graph? Is there any formula that show number of non-Isomorph trees with $n$ vertices? thanks
There are only two 4-node trees up to isomorphism: the straight line and the Y-shaped graph. The above graph contains both of them. For the number of trees with $n$ vertices, Wikipedia links here : < .
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "graph theory, trees, graph isomorphism" }
Unable to scan wifi with iwslist when network-manager down I try to scan wireless networks. If network-manager service is up and wifi interface connected, iwlist give only one cell - the same it connected with, but if I try disconnect wifi interface by shutting down network-manager interface, iwlist give no result at all. Also if I try to start up networking service. user@comp-nam:~$ sudo iwlist wlan0 scan | head -n 2 wlan0 Scan completed : Cell 01 - Address: 2E:2F:97:D7:22:24 user@comp-name:~$ sudo service network-manager stop network-manager stop/waiting user@comp-name:~$ sudo iwlist wlan0 scan wlan0 Interface doesn't support scanning : Network is down user@comp-name:~$ sudo service networking start networking stop/waiting user@comp-name:~$ sudo iwlist wlan0 scan wlan0 Interface doesn't support scanning : Network is down I use Ubuntu 12.04.1
Turn on the interface, not the network manager. sudo service network-manager stop sudo ifconfig wlan0 up sudo iwlist wlan0 scan
stackexchange-superuser
{ "answer_score": 5, "question_score": 1, "tags": "linux, wireless networking" }
Does philosophical knowledge always conflict with religion? What part of philosophy supports religion ? Or is religion itself its own philosophy ?
There have been long periods of time in every major philosophical tradition when philosophy has been carefully shaped to lie within a religious context. Hindu philosophy is clearly Hindu. Aristotelian philosophy between the time Greece left off leading the West, and the time it got back to Europe, was carefully cultivated in a way that would not offend Islam. Platonic and Aristotelian philosophy within Europe was carefully monitored and fitted into a Christian context from early on until the end of Scholasticism. And so forth. So, historically, there seems to be no basic clash between philosophy and religion, except over which should dominate the mindset of a period. Our own period is one that cannot see religion as a predominant force in shaping thought, but that is largely a post-Victorian phenomenon, restricted to the West.
stackexchange-philosophy
{ "answer_score": 3, "question_score": 3, "tags": "philosophy of religion, introduction to philosophy" }
Sencha Touch 2 + PhoneGAP VS android SDK I am just confusing, the Sencha Touch 2 with PhoneGAP is a powerful things, they only need to develop once then able to run in IOS and Android Operating system. why still so many people is choosing use Android SDK to develop mobile apps? may i know what is the limitation of Sencha Touch 2 to develop Android? i m feeling i have no reason refuse use Sencha Touch 2 to develop mobile Apps. just give me some guide, which one is better. Sencha Touch 2 With PhoneGAP or just use Android SDK with Eclipse ? P/S: i have never been develop any mobile apps yet, just want to start the first apps, that is why need to research which one is better.
Sencha Touch and Phonegap are basically javascript libraries. They are webpages use html5 and css. Phonegap uses javascript libraries to invoke native java code to access device features like camera. They are slow. On the other hand native apps are coded using java(android) and objective C (ios). Native apps are much faster than application built using sencha touch and phonegap.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "android, ios, cordova" }
brew install OpenCV for macOS arm i am using macOS arm, and install OpenCV for c++ using this command: brew install --build-from-source OpenCV download packages completed, and then i get this error: ==> Installing OpenCV Error: An exception occurred within a child process: RuntimeError: Unexpected architecture: arm64. This only works with Intel architecture. can you help me?
Clone sources git clone Create build directory mkdir -p build && cd build Configure cmake ../opencv Build cmake --build .
stackexchange-stackoverflow
{ "answer_score": -1, "question_score": 0, "tags": "macos, opencv, arm, homebrew" }
Where is my (algebra) mistake? Converting parametric to Cartesian equation I'm having a problem with my solution to a textbook exercise: **Find the Cartesian equation of the curve given by this parametric equation:** $$x = \frac{t}{2t-1}, y = \frac{t}{t+1}$$ The textbook's answer is $y = \frac{x}{3x-1}$ My solution is different. I understand how the textbook got to its solution, but I can't find where I made my mistake. Can anyone spot my error below? $$x = \frac{t}{2t-1} = \frac{t}{2t} - \frac{t}{1}$$ $$\implies x = \frac{1}{2} - t$$ $$\implies x - \frac{1}{2} = -t$$ $$\implies t = -x + \frac{1}{2}$$ Sub this into $y = \frac{t}{t+1} \implies y = \frac{-x + \frac{1}{2}}{-x + \frac{1}{2} + 1}$ $$= \frac{-x + \frac{1}{2}}{-x + \frac{1}{2}} + \frac{-x + \frac{1}{2}}{1}$$ $$= 1 - x + \frac{1}{2}$$ $$= -x + \frac{3}{2}$$ So $y = -x + \frac{3}{2}$ * * * I suspect my error is when I split my fractions up, but if so, why can't I do it like that? Many thanks!
As you said Danny, $$\frac{a}{b+c} \neq \frac{a}{b} + \frac{a}{c}$$ and Theo pointed out with a simple example why: $$0.5 = \frac{1}{2} = \frac{1}{1+1} \neq \frac{1}{1} + \frac{1}{1} = 2 \; .$$ It is a common mistake however, so tempting that few people have resisted making it. P.S: Note you made the mistake twice, once in the formula with $x$ and once in the one with $y$.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "calculus, algebra precalculus, plane curves" }
Android: trouble using Thread and Handler I have an Activity from which a new thread is called (for downloading same data). In my Activty, I implemented a Handler that receives a message from the aforementioned thread. When that message is received some code is executed (this code will not impact the UI). My question is: If my actvity is in background (state pause or stop) what happens when message sent from the thread is received? Can the activity manage the message received and execute some code? And what happen if this code try to update the UI?
As far as i know about Android. You can update activity content if still is in background. But we should be sure that how long activity will be in background. It can be killed in extreme low memory situation. So in **HandleMessage() of Handler, Check if(Activity.this!=null){Update UI}**
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "android, multithreading, user interface, handler, message" }
Asymptotic behavior of $R(4,k)$. I’m struggling to understand a step in the application of the following formula to a specific case. > THEOREM. If $$\binom{n}{k}p^\tbinom{k}{2}+\binom{n}{t}(1-p)^\tbinom{t}{2}<1$$ for some $p \in[0,1],$ then $R(k, t)>n$ > Let us examine the asymptotics of $R(4, t) .$ We want $\binom{n}{4}p^{6}=c n^{4} p^{6}<1$ so we take $p=\varepsilon n^{-2 / 3}$. Now we estimate $\binom{n}{t}$ by $n^{t}(!), 1-p$ by $e^{-p}$ and $\binom{t}{2}$ by $t^{2} / 2,$ so we want $n^{t} e^{-p t^{2} / 2}<1 .$ Taking $t$-th roots and $\operatorname{logs}, p t / 2>\ln n$ and $t>(2 / p) \ln n=$ $K n^{2 / 3} \ln n .$ Expressing $n$ in terms of $t$ $$ R(4, t)>k t^{3 / 2} / \ln ^{3 / 2} t=t^{3 / 2+o(1)} $$ What happens at that part “expressing $n$ in terms of $t$”?
Before that part, we've used the theorem you've quoted to show that $R(4,t) > n$ provided that $t > K n^{2/3} \ln n$. We want to show that there is a $k$ such that $n < k (\frac{t}{\ln t})^{3/2}$, then $t > K n^{2/3} \ln n$. Well, if $n < k (\frac{t}{\ln t})^{3/2}$, then (for $t$ large enough, specifically $t \ge e^{k^{2/3}}$) we also have $n < t^{3/2}$, so $\frac23\ln n < \ln t$. This gives us $$ \frac23n^{2/3}\ln n < k^{2/3} \left(\frac{t}{\ln t}\right) \ln t = k^{2/3}t \implies \frac{2}{3k^{2/3}} n^{2/3}\ln n < t $$ and we get the inequality we want when we take $k = (3K/2)^{-3/2}$, which gives $\frac{2}{3k^{2/3}} = K$. We conclude that $R(4,t) > n$ for every $n$ such that $n < k(\frac{t}{\ln t})^{3/2}$; in other words, $R(2,t) \ge k(\frac{t}{\ln t})^{3/2}$.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "proof explanation, asymptotics, approximation, estimation, ramsey theory" }
Difference between "Piccolo" and "Basso" What is the difference between `Piccolo` and `Basso`? They both mean `Small`, right??
_Basso_ is not only _short_ , and _piccolo_ is not only _small in size_! _Piccolo_ , as laika remarked, can also mean "[very] young" when referred to a person. _Basso_ can be used to refer to a small amount of money ("una cifra _bassa_ ", "uno stipendio _basso_ "). We say _basse aspettative_ ("low expectations"), while _piccole aspettative_ sounds awkward. We say _un piccolo problema_ ("a small problem") while _un problema basso_ is absurd. Quantity can be _piccola_ ("small quantity"), whereas quality can be _bassa_ ("low quality"). Talking about sound, _basso_ can mean "low-pitched" but also "low in volume". Basically, when you are not talking about people, _basso_ translates to "low" in most cases, not "short", and it is not always about height... Fun fact: _Basso Medioevo_ means "Late Middle Ages"! It's not that simple, and you should address each case individually depending on the domain.
stackexchange-italian
{ "answer_score": 4, "question_score": 2, "tags": "difference" }
do animations in order | CSS animation Could someone tell me how to make a div that will make two animations, but the second div should be only when the first is completed? .CodeMode { z-index: 1; position: absolute; animation: MoveTop 2s, FullScreen 3s; } @keyframes MoveTop { from {top: 90%;} to {top: 0%;} } @keyframes FullScreen { from {height: 10vh;} to {height: 100vh;} } Example of how I want that to work: MoveTop --> Waiting until the animation ends --> FullScreen
Add a delay to your second animation, which is the third value after the animation name in the `animation` property. Per MDN: > The animation shorthand CSS property applies an animation between styles. It is a shorthand for animation-name, animation-duration, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, animation-fill-mode, and animation-play-state. To apply this in your code: .CodeMode { z-index: 1; position: absolute; animation: MoveTop 2s, FullScreen 3s linear 2s; }
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "css, css animations" }
Get files from FTP in ant I have a FTP folder structure as, \-- Folder 1 \-- Folder 2 \-- external -- Code \-- MY Dir Now, I want to get the folder "Code" from here. I am using the code, <ftp action="get" server="server" userid="administrator" password="pass" > <fileset dir="Code"> </fileset> </ftp> But this gets my whole contents present in the FTP rather than getting only the folder "Code". Please let me know.
remote dir has to be used within the Ftp. The example is given below. <ftp action="get" server="sever" userid="user" password="pass" separator="/" remotedir="/remotedir"> <fileset dir="e:/temp/"> <include name="**/*" /> </fileset> </ftp>
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "ant, ftp" }
Sending json data to php web service I am sending to the server this call: var Message = {}; Message['islands'] = '1-15-13'; Message['newMessageText'] = 'this is test message'; $.ajax({ url: "sendnote.php", type: "POST", data: Message, dataType: "json", contentType: "charset=utf-8", success: function (data) { alert(data["result"]); }, error: function (data) { alert(data["result"]); } }); and on server (sendnote.php) I have print_r($_POST); just to check do I receive anything, but after cchecking response in Firebug I see that this array is empty. What am I doing wrong in sending data? Thanks in advance! PS I've checked previous post on this subject, but still have problems with it.
The problem is the contentType Try this: jQuery $(document).ready(function(){ var Message = {}; Message['islands'] = "1-15-13"; Message['newMessageText'] = 'this is test message'; $.ajax({ url: "sendnote.php", type: "POST", data: Message, dataType: "json", success:function(data) { alert("Islands: "+data.islands+", Message: "+data.newMessageText); }, error:function(data) { alert('error'); } }); }); php <?php echo json_encode($_POST); ?>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, jquery, json, web services" }
Permission denied on function Lambda I get access denied when I run a node.js function on AWS Lambda. I am uploading a zip file which contains the index.js and the node module packets. Have run through this twice now and still get same error as below so any help is appreciated. { "errorMessage": "EACCES: permission denied, open '/var/task/read.js'", "errorType": "Error", "stackTrace": [ "Object.fs.openSync (fs.js:549:18)", "Object.fs.readFileSync (fs.js:393:15)"
I got the same problems weeks ago. Appears that setting file permissions on .js files before zipping solves this error. Run: `filename.js chmod -R 644` in your Terminal Hope this saves someone else time & effort.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 4, "tags": "node.js, amazon web services, aws lambda" }
Adding invariant check to every method of a Class I have a class with many methods and would like to check for pre/post conditions, such as is mMember == null and invoke function x() if not. Is it possible to add pre/post conditions to every member of that class automatically? The class is defined in class.h and all methods are defined in class.cpp. Being able to define a macro at the start of the class.cpp would be ideal that would be inserted on every function entry in that file only. I know I can manually add the same precondition/postcondition (using destructors) manually on every function entry but I keep running into this problem time and time again. This is not ideal as I can not check these changes in and must maintain them locally and they bit root from other people's changes.
I have not ever been able to do this in C++; I've always used a set of macros manually added to each member function. It sounds like a job that might be well-suited to Aspect Oriented Programming, though, and I see that there are libraries out there for AOP in C++, such as AspectC++. It might be worth at least taking a look at one of these and seeing if it can be used to solve your problem.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "c++, gcc" }
Why do you not want to make this trip? From Hiroshima, Japan to Nantucket, Massachusetts. Try to solve this without Google.
The reason is: > the airport codes are HIJ ACK > > Yes, I've heard this one before ;-)
stackexchange-puzzling
{ "answer_score": 10, "question_score": -6, "tags": "pattern" }
From two django signals works only the last one I have made two signals for loggin, but works only the last one. And if I switch them still works the last. Is there any way to close this decorators or something like that? @receiver(post_delete, sender = Student) def add_score(instance, **kwargs): newChange = Changes(table_name = 'Student',type='delete') newChange.save() @receiver(post_delete, sender = Group) def add_score(instance, **kwargs): newChange = Changes(table_name = 'Group',type='delete') newChange.save()
Try to change name of functions to something like `add_score_student` and `add_score_group`.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, django, python 2.7" }
renaming a group of files I want to rename all files with this pattern `-512-` to `-256-` in a folder? How can I do that with mv? I know I have to use `xargs` and pipe it to `find` but don't know how to tell xargs find . -name *-512-* and xargs mv ?????
for i in *-512-*; do mv "$i" "${i/-512-/-256-}"; done
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 0, "tags": "bash, xargs, mv" }
Linux Command to find all the client names and their mountpoints Is there any command so that one can get all the client names and their mount points by this single command in Linux? How about in Windows?
You can use `usermount` command to list all the mount points. But also you can give a try to check `/etc/fstab` file cat /etc/fstab or df -k
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "linux, windows, client, mount point" }
Unexpected character '@' from [script.*.js] When I try to production build angular, i encountered the error 'Unexpected character '@' [scripts.*.js]'. Production command ng build --prod Angular version: 7.* Node modules used : 1\. ag-grid
When anyone gets the error 'Unexpected character '@' [scripts. _.js]' or 'Unexpected token ',' [scripts._.js]'. The above error could be from our code or the node_modules which we would have installed. Error : You can see the error here To find the source, execute the command **_ng build --prod --source-map_** After executing source map, we can get the source file that causes error enter image description here The above command would point us to the file that causes the error while taking a production build. If the command doesn't point to the source, please ensure that **sourcemap=true** in angular.json for production is true
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "javascript, angular, build" }
Android error when I set android:debuggable = "false" or "true" Please help me to solve this error. When I put debuggable, the error appear like this "Avoid hardcoding the debug mode; leaving it out allows debug and release builds to automatically assign one". So i don't know what to do.... Anyone can help me. Thank you
This is **NOT** an error, merely a warning. You can still compile, debug & run your application on emulators / devices. When you _export_ your application to create a release build, by default this APK is **NOT** debuggable, since this APK will be released to users, but the APK you are currently building is debugabble by default, so if you wish you can remove the `android:debuggable` tag. **References:** **1.** SDK Tools In the above link go to `SDK Tools, Revision 8` and there see `General Notes`. **2.** Setting up a Device for Development
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": -2, "tags": "android, android manifest, android debug" }
Memory allocation for object in inheritance in C# I'm confused about how object allocation is done in the case of inheritance consider the following code. class Base { } class Derived : Base { // some code } and from main if we do Derived d = new Derived(); and Base b = new Derived(); what is the memory allocation of both cases in the heap. Is the derived object in inside base object or they both are beside each other
Memory allocation for both objects will look exactly the same. Both objects are of the same type `Derived`. Of course, each object will be allocated in its own space on the heap. What counts when creating objects is the class (type) used to construct the object, not the type of reference where object will be stored. Each object exists as complete entity, but you can look at it as summary of all parts from all the classes it inherits from. In a way `Derived` object instance contains `Base` object instance inside. Not the other way around.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 5, "tags": "c#, .net, oop, inheritance, heap memory" }
Can not access internal network services through external IPs We have multiple servers running on our network using a ASA 5510 as the firewall and router. NAT is used to give the servers their external IPs. When a request made externally using the external IP it works find such as just going to the webpage < but when a request is made internally using the external IP it fails so if you were to be on an internal server and curl < it will timeout. Though if you use the internalip it will work. I am thinking this a routing issue of not being able to go out on an external ip and come back in. Any suggestions would be appreciated.
You are correct, that is not possible. You could set up internal DNS to use the same hostnames (e.g. You have an internal server on 10.0.0.1 that is NATed to 1.2.3.4. Externally, foo.bar.com resolves to 1.2.3.4. Internal DNS (possibly using split horizon if you already run your own) would allow you to do this.)
stackexchange-serverfault
{ "answer_score": 3, "question_score": 1, "tags": "nat, cisco asa" }
AWK Compare Two files I learn AWK not long a go and still confused. I try using AWK to compare two txt files and generate a merged output based on the compare results. file1.txt budi andi file2.txt sinta Sep 29 17:12 andi Sep 15 17:12 kuro Sep 9 17:12 budi Sep 2 17:13 I try using awk 'FNR==NR{a[$1];next};$NF in a' cobafull.txt coba.txt > result.txt` Here is the result budi andi Output I want like this budi Sep 2 17:13 andi Sep 15 17:12 Please need your advice. Thank you. sorry add noted that file1.txt = coba.txt file2.txt = cobafull.txt
If file `file1.txt` is accepted as `coba.txt` and `file2.txt` as `cobafull.txt` than: awk 'NR == FNR {A[$1]=$0; next}; {print A[$0]}' coba{full,}.txt output: budi Sep 2 17:13 andi Sep 15 17:12 If the order of the output is not important: awk 'A[$1]++' coba{,full}.txt output: andi Sep 15 17:12 budi Sep 2 17:13
stackexchange-unix
{ "answer_score": 2, "question_score": 0, "tags": "awk" }
Can i run C code on dalvik Can i run **C code on dalvik VM** on android ? VM runs byte codes, but I need run c-code on dalvik-VM for myApps. is it possible??
First of all, the **Dalvik VM** can only run (his own format of) java bytecode. If you need to run C code on Android, you'll have to use the Android NDK, write your C code, cross-compile it, and then you will be able to run it on your android platform. If you need to use this code from a Android application, you will need to create a JNI interface to bind your C code to java (as described in the examples of the NDK), then your java application running on the dalvik vm will call some java libraries that will call your C code (as a standard library).
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 3, "tags": "android, android ndk, dalvik" }
A method was called at an unexpected time I'm trying to iterate all files in a directory using GetFilesAsync, but every time I call the GetResults method, it throws an exception that says > System.InvalidOperationException: A method was called at an unexpected time The code is simply var files = myStorageFolder.GetFilesAsync(); //runs fine var results = files.GetResults(); //throws the exception I'm new to Win 8 dev so I might be missing something obvious. **Edit (solved)** I'm running my console application, but now that the program runs async, the `files.GetResult()` method no longer exists. static void Main(string[] args) { var files = GetFiles(myStorageFolder); var results = files.GetAwaiter().GetResults();//Need to add GetAwaiter() } static async Task GetFiles(StorageFolder sf) { await sf.GetFilesAsync(); }
You need to wait for the async method to complete. So you could use the new await as one option: var files = await myStorageFolder.GetFilesAsync(); You might want to check the documentation on dealing with async methods here.
stackexchange-stackoverflow
{ "answer_score": 13, "question_score": 25, "tags": "exception, windows 8, windows runtime, local storage, winrt async" }
Set cookie inside websocket connection I know that I can set cookies during handshake: const wss = new WebSocketServer({ server, path: '/ws' }); wss.on('headers', headers => { headers.push('Set-Cookie: my-cookie=qwerty'); }); How can I change cookies inside websocket connection? For example, I want to set session cookie after some client message: ws.on('message', () => { // something like ws.setCookie('my-cookie=qwerty'); });
You can't set a cookie upon receipt of a webSocket message because it's not an http request. Once the webSocket connection has been established, it's an open TCP socket and the protocol is no longer http, thus there is no built-in way to exchange cookies. You can send your own webSocket message back to the client that tells it to set a cookie and then be listening for that message in the client and when it gets that message, it can set the cookie in the browser.
stackexchange-stackoverflow
{ "answer_score": 14, "question_score": 18, "tags": "node.js, websocket" }
jQuery - Menu Scroll Item Effect Example - What is it called? Does anyone know what the jQuery effect on this page is called? < As you scroll down the page, a different left menu item selects based on your scroll location. I need to know what the effect is called or how to re-create it?
I believe your looking for a tutorial along the lines of this < I would call it a 'fixed menu/nav', or sometimes people call it a 'sticky menu/nav'. Its done pretty easily by using the position:fixed CSS and working on from there. Hope that helps
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 2, "tags": "jquery, scroll, effects" }
How to retrieve deleted wired.com articles? Once in a while on Wired: Software there's an entry which is listed in the feed _and_ on the web site but the link just shows a "Page not found" error mere hours after going online. Because these articles seem to all have some sort of inflammatory title, I suspect they have been deleted shortly after publication. Example: > The Legacy of Linus Torvalds: Linux, Git, and One Giant Flamethrower > > Linus Torvalds created Linux, which now runs vast swathes of the internet, including Google and Facebook. And he invented Git, software that's now used by developers across the net to build new applications of all kinds. But that's not all Torvalds has given the internet. He's also started some serious flame wars. Is there some way I can retrieve the text of these articles before they are removed? It would be interesting to see what sort of self-censoring Wired does, but I don't want to hammer their servers to get at the text.
There's no easy way to do about this - you'll have to rely on a bit of a luck that: * Google has indexed the page & added to it's Web Cache. To find if this is done, search Google with the **URL** as the search keyword. If Google has indexed the page & stored to it's webcache, you'll find the link to it !enter image description here * Alternatively, if you're using Google Chrome, prepend `cache:` to the URL & Chrome will try to find the cached version, without you having to do the other steps * Another alternative is to add Wired's feed to a feed reader like Google Reader which tends to fetch the articles as soon as it's published. You can then refer to the feed view to check the article
stackexchange-webapps
{ "answer_score": 1, "question_score": 4, "tags": "wired.com" }
Renaming Multiples Files To delete first portion of name I have a list of files like so : 10_I_am_here_001.jpg 20_I_am_here_003.jpg 30_I_am_here_008.jpg 40_I_am_here_004.jpg 50_I_am_here_009.jpg 60_I_am_here_002.jpg 70_I_am_here_005.jpg 80_I_am_here_006.jpg How can I rename all the files in a directory, so that I can drop `^[0-9]+_` from the filename ? Thank you
Using pure BASH: s='10_I_am_here_001.jpg' echo "${s#[0-9]*_}" I_am_here_001.jpg You can then write a simple for loop in that directory like this: for s in *; do f="${s#[0-9]*_}" && mv "$s" "$f" done
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "bash, shell, batch file, file rename" }
What does "educated" mean in "educated guess"? > Make an educated guess. What is the meaning of _educated_ in the sentence?
An _educated guess_ is a guess in which you take into account factors which might affect the outcome using reason. It is a term used to clarify that a guess is not one which is made “off the top of your head”—that is, guessing the first possibility that comes to mind—but rather one which, although it is still a guess, is generated by considering multiple possibilities and selecting the one thought most likely by considering those factors that a reasonable person might assume will affect the outcome.
stackexchange-english
{ "answer_score": 7, "question_score": 5, "tags": "meaning" }
Extract data separated by a comma from a single cell I have a spreadsheet with data relating to meetings . One of the cells has the name of meetings with the amount of participants under brackets as follows. Staff meeting (65), HR meeting (15), Pension meeting (4) There can be in between 1 to 9 meetings in a single cell. I am looking for a way to extract each meeting name and number (all information between commas) in separate cells. Does anyone know how can this be done?
Select the column with the meetings. Then select `Text to Columns` on the Data tab of the Ribbon. Choose 'Delimited' and the 'Comma' as the separator.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "excel, extract, vlookup, vba" }
Finding DEM for Greece (in high resolution) in order to calculate road slopes? I want to calculate the slope of road segments and I need dem for Greece. Where can I find it? I have found another one but the slopes were huge which is impossible.
ASTER GDEM V2 provides global elevation at 30-meter resolution < available for download through NASA Reverb: < or USGS: <
stackexchange-gis
{ "answer_score": 2, "question_score": 2, "tags": "data, dem, road, slope, greece" }
find region of convergence of the series I tried to solve this question **Find domains of convergence of the series** $$\sum_{n=1}^ \infty \frac{z^n}{n (\log n)^2 }$$ How can I do this .
$$\sum_{n=1}^ \infty \frac{z^n}{n (\log n)^2 }\\\ \lim_{n\to\infty}\left|\frac{z^{n+1}}{(n+1) (\log (n+1))^2 }\frac{n (\log n)^2 }{z^n}\right|<1\\\ \implies |z|\lim_{n\to\infty}\left|\frac{n (\log n)^2}{(n+1) (\log (n+1))^2 }\right|<1$$ See that $\lim_{n\to\infty}\left|\frac{n (\log n)^2}{(n+1) (\log (n+1))^2 }\right|\to1$, and thus, the sum converges for $$|z|<1\\\ \implies z\in(-1,1)$$ Note however, that if $z=1$, then $$\sum_{n=1}^ \infty \frac{1}{n (\log n)^2 }$$ Converges. Thus, the sum converges for $$\boxed{x\in[-1,1]}$$
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "sequences and series, power series" }
how to break loop from for and form a string value again? I have map which size is 10.from the Map from each 3 keys i have to form a string. then the string is set to empty.from the next (3 to 6) map keys again i want to form a string. Please guide me Apex class String strval=''; Integer incrementer=0; for(String strId:mapVal.keyset()){ incrementer++ if(strval== ''){ strval= '\'' + strId+ '\''; } else { strval+= ',\'' + strId+ '\''; } if(incrementer==3){ system.debug('strval******'+strval); break; } } Eg mapVal={01='apple'},{02='banaa'},{03='mango'},{04='cat'},{05='dog'} for the first time if map size until 3 i want like this `strval=applebanaamango` After that strval=catdog
You can use the following code. Result of this concatenation would be return by method. private List<String> getConcatanetedValues(Map<String, String> mapToProcess, Integer count){ List<String> result = new List<String>(); String tempValue = ''; for(Integer i=0; i<mapToProcess.values().size(); i++){ String value = mapToProcess.values().get(i); tempValue+=value; if(Math.mod(i, count) == count-1) { result.add(tempValue); tempValue = ''; } } if(String.isNotBlank(tempValue)){ result.add(tempValue); } return result; } Usage: Map<String, String> mapValues = new Map<String, String>{ '01' => 'apple', '02' => 'banana', '03' => 'mango', '04' => 'cat', '05' => 'dog' }; System.debug(getConcatanetedValues(mapValues, 3)); //DEBUG|(applebananamango, catdog)
stackexchange-salesforce
{ "answer_score": 1, "question_score": 0, "tags": "apex, for" }
Is there a way to use JavaScript on Home Page Components? We can see that the support for JavaScript on home page components is being phased out as described here: < Is there an alternative to add java script on a homepage?
It really depends on what you are going to do: **Use Case 1** If you just need a homepage component which uses JavaScript and have the access of JavaScript limited to the **component itself** then you should use the new HTML Area Home Page Components: < **Use Case 2** If you need your JavaScript to access the **entire homepage** and/or other pages where the sidebar is available, you can have a look at the workaround described here End of javascript sidebar workarounds? which is working at least in summer'14. This would apply mostly to use cases discussed here Why do we still need to hack the Sidebar? Usecases - Workarounds - Alternatives please mind, that these approaches may also be discontinued at some point in the future by Salesforce.
stackexchange-salesforce
{ "answer_score": 1, "question_score": 2, "tags": "javascript, home page component" }
Can you store a Shatter spell in a magic mouth? The Magic Mouth spell allows the caster to store a message within an object. One of my players asked me to define a message as he wanted to store a captured monster's roar as evidence, so I dictated that the spell could hold and recite any audible noise provided it was not more than 25 distinct noises and did not exceed the 10-minute mark as specified in the spell. This seemed reasonable to me until he asked to store a shatter spell. Shatter is a spell that when cast emits "A sudden loud ringing noise" that will damage nearby creatures and objects. Because the effects of the spell are entirely vocal, could you store a shatter spell inside a magic mouth, and if not, to what extent can you store no-traditional messages such as monster noises and other audible cues that don't specifically convey any message?
### _Magic mouth_ cannot be used to record _anything_ except for the sound of your own voice speaking words. _Magic mouth_ defines "message" for us: > speak the message, which _must be 25 words or less_ Non-descript noises, grunts, growls, sonic booms, and the sound of a _shatter_ spell are not words, so are not eligible for storage in a _magic mouth_. Further, _magic mouth_ states: > _You_ implant a message within an object in range, [...] speak the message [...] > > [...] a magical mouth appears on the object and recites the message in _your voice_ and at the _same volume you spoke_. _Magic mouth_ cannot be used to record _anything_ except for the sound of your own voice speaking words, and doesn't produce any sound except the sound of your own voice, speaking those words, exactly as you recited them when you cast the spell.
stackexchange-rpg
{ "answer_score": 12, "question_score": 3, "tags": "dnd 5e, spells" }
Is it possible to log the commands executed on AIX to syslog? As above, is there a syslog facility to capture users' activities in AIX? Or can this be done only through shell configurations (i.e. command history)?
I believe you can enable process accounting touch /var/adm/pacct chmod 666 /var/adm/pacct su – adm -c /usr/lib/acct/nulladm /var/tmp/wtmp /var/adm/pacct su – root -c /usr/sbin/acct/startup \- from FreeUnixTips By using the `acctcom` command you should be able to view a list of programs run by users. Each record represents one completed process. The default display consists of the command name, user name, tty name, start time, end time, real seconds, CPU seconds, and mean memory size (in kilobytes). These default items have the following headings in the output: COMMAND START END REAL CPU MEAN NAME USER TTYNAME TIME TIME (SECS) (SECS) SIZE(K)
stackexchange-superuser
{ "answer_score": 1, "question_score": 2, "tags": "logging, aix" }
Export List in Parallel via ClusterExport in R I have a list of objects of considerate size that that i need to export to a PSOCKcluster in R. I'm doing this in the following way: cl <- makePSOCKcluster(3, methods = TRUE) listOfMatrices <- c(bigMatrix1, bigMatrix2, bigMatrix3) for(i in 1:3){ bigMatrix <- listOfMatrices[i] clusterExport(cl[i], "bigMatrix", envir = environment()) } However this approach is sequential as export n+1 needs for export n to finish first. Is there a more efficient way to do this in parallel?
You can do this with the `clusterApply` function: library(parallel) cl <- makePSOCKcluster(3) listOfMatrices <- list(matrix(1,2,2), matrix(2,2,2), matrix(3,2,2)) clusterApply(cl, listOfMatrices, function(m) {bigMatrix <<- m; NULL}) You can verify that it worked correctly using `clusterEvalQ`: clusterEvalQ(cl, bigMatrix)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "r, parallel processing" }
Azure Kubernetes - No connection to Server when I execute the following PowerShell command: .\kubectl get nodes I get no nodes in response. I noticed that the config file from kubectl is empty too: apiVersion: v1 clusters: - cluster: server: "" name: cl-kubernetes contexts: [] current-context: "" kind: Config preferences: {} users: [] When I enter the server address at the config file, I get the message that the connection was refused. I suspect that it is due to missing certificates. During another installation this (apparently) following information was created automatically, which is now missing: certificate-authority-data, contexts - cluster, contexts - user, current context, users - name, client-certificate-data, client-key-data, token, Could that be it? If so, where do I get this information? Many thanks for the help
You need to use the Azure CLI first to get the credentials. Run az aks get-credentials <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "azure, kubernetes, kubectl" }
How do I limit JPQ output? I need to limit number of entities returned by a query to some certain value inside a JPA query (through JPQL). Particularly: select m from Manual m //constraint e.g. in sql (mysql syntax) I would do it like: select * from Manual limit 1 The only solution that comes up is simply to get all entities and then choose first one, which is out of the question. Any ideas?
To do that I may limit Query instance, as follows: em.createQuery("select m from Manual m").setMaxResults(1).getSingleResult()
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "java, jpa, java ee 6, jpql" }
Generate unique temporary file paths I want to generate unique file paths in Objective-C. I looked at `NSTemporaryDirectory()` but the closest I could get was to this and this. But in the second one they create such a file. I do not want to create it, I just want an NSString for a unique writable path... I don't need paths to folders, just files. How is this possible?
You can create file name using present system date and time (`[[NSCalendarDate calendarDate] descriptionWithCalendarFormat:@"%m%d%Y%H%M%S%F"]`) .... this include even milliseconds ... use returning string as unique file name .... Read more about date formates -> <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "objective c, nsstring, unique, temporary files" }
Defining a new word within frequency analysis I would like to know how to define a new word which can include others. For example: Word Frequency 0 game 52055 1 laura 24953 2 luke 21133 3 story 20739 4 dog 17054 35 cat 4244 I would like to 'create' a new word, `pet`, which include `dog` and `cat` and their corresponding frequency. Something like this: Word Frequency 0 game 52055 1 Laura 24953 4 pet 21298 2 luke 21133 3 story 20739 I am thinking of using a dictionary to do it: thisdict = { "dog": "pet", "cat": "pet"} but I am not sure on how to apply it and if this can allow me to keep also their values (21298 in total)
`replace` first then do `groupby` df.Word.replace(thisdict,inplace=True) df Out[104]: Word Frequency 0 game 52055 1 laura 24953 2 luke 21133 3 story 20739 4 pet 17054 35 pet 4244 df = df.groupby(['Word'], as_index=False).sum() df Out[106]: Word Frequency 0 game 52055 1 laura 24953 2 luke 21133 3 pet 21298 4 story 20739
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "python, pandas" }
Cooking cakes with Pop Rocks / Space Dust I want to build a cake with Pop Rocks / space dust. Has anyone got any ideas on how I would do this? If I add the Pop Rocks straight to my cake mixture, then I believe it'll just react. Any suggestions?
I was speaking to a chef at the weekend who makes chocolate with space dust in it, and this works ok because the chocolate doesn't have any water. You might be able to make chocolate chips which have space dust in them, mix these in to you mixture and hope that the cake sets before the chocolate melts and lets the space dust get into contact with the moisture in the mix. Not sure if there is anything you can do to the chocolate which will raise the melting temperature, which would also help. EDIT: I asked this question which might help.
stackexchange-cooking
{ "answer_score": 8, "question_score": 11, "tags": "cake, pop rocks" }
not able to create path with single occurence of double quote in TCL I have path in TCL as set replacementPth "C:/SVN/simulation" I need to create a string like > fopen("C:/SVN/simulation from the $replacementPth I have tried many ways to escape the single occurence of double quote but failed. For example set x1 fopen($replacementPth gives > fopen(C:/SVN/simulation Any help. sedy
You should use a strategic backslash in front of the double quote. set x1 fopen(\"$replacementPth At this point, I'd probably put the whole thing in double quotes, just because it looks nicer (not that it makes any semantic difference): set x1 "fopen(\"$replacementPth"
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "tcl" }
Boundary of a set difference If we have any two sets $E,F$, how do i show $∂(E$ \ $F ) ⊂ ∂E ∪ ∂F$, i.e. the boundary of $E$ \ $F$ is a subset of union of boundary $E$ and boundary $F$? I have proved that $∂(E ∪ F ) ⊂ ∂E ∪ ∂F$ and it just seems intuitive that the set difference is obviously true but I cannot seem to derive it using the same way I proved it for union through the property Boundary is Intersection of Closure with Closure of Complement.
$\partial (E\backslash F) \subset \partial E \cup \partial F$ can be deduced from $\partial (E\cup F) \subset \partial E \cup \partial F$ and the fact that $\partial A = \partial A^c$ for any set $A$. $$ (E\backslash F )^c = F \cup E^c$$ so $$\partial (E\backslash F) = \partial (F \cup E^c) \subset \partial F \cup \partial E^c = \partial E \cup \partial F$$
stackexchange-math
{ "answer_score": 4, "question_score": 1, "tags": "real analysis" }
How to solve "Error from the operating system 'The user name or password is incorrect." in c# How to solve > "Could not create Windows user token from the credentials specified in the config file. Error from the operating system 'The user name or password is incorrect." when I am creating/moving file to network path I got the above error. And below I have mentioned my Web config tag. <identity impersonate="true" userName="UserName" password="******"/>
The most obvious reason is that `userName` or `password` is wrong in your `Web.config` file. Another possible reason is that the userName has no domain information. <identity impersonate="true" userName="DOMAIN\UserName" password="******"/>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "c#" }
Are multiple lets in a guard statement the same as a single let? Is there any functional difference between: guard let foo = bar, let qux = taco else { ... } And: guard let foo = bar, qux = taco else { ... } It seems to me they're the same and the extra `let` is not required?
These are different in Swift 3. In this case: guard let foo = bar, let qux = taco else { you're saying "optional-unwrap bar into foo. If successful, optional unwrap taco into qux. If successful continue. Else ..." On the other hand this: guard let foo = bar, qux = taco else { says "optional-unwrap bar into foo. As a Boolean, evaluate the assignement statement `qux = taco`" Since assignment statements do not return Booleans in Swift, this is a syntax error. This change allows much more flexible `guard` statements, since you can intermix optional unwrapping and Booleans throughout the chain. In Swift 2.2 you had to unwrap everything and then do all Boolean checks at the end in the `where` clause (which sometimes made it impossible to express the condition).
stackexchange-stackoverflow
{ "answer_score": 17, "question_score": 8, "tags": "swift, swift3, guard" }
How to print a YACC grammar graph starting from a specific node? I have a vast YACC grammar for processing a family of related standards. I want to print its graph with `bison --graph` command, but the generated `.dot` file has over 40 thousand lines. The graph is so big, `xdot` and `dot` tools are unable to render it. I finally managed to generate an output with `sfdp`, but the resulting image has over 50MB and is simply unintelligible. !Resulting grammar graph I am only interested in visualizing a part of the grammar, preferably a subset starting from a specific grammar rule. Is there a way to add such constraints to the graph generation or rendering?
You can restrict a grammar to the subset starting at a _nonterminal_ by adding %start the_nonterminal You'll get lots of useless production and useless non-terminal warnings, but you'll still get the graph. If you want to restrict it to a single production of a non-terminal, you could temporarily introduce a new start non-terminal for only that production (assuming that the grammar for the original non-terminal is not recursive).
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "bison, graphviz, yacc, dot" }
drf-yasg: How to change operationId? !enter image description here How do I change the name of the request that appears automatically in `redoc-ui` when using `drf-yasg`. For example: In the image, you can see that that the request is named **`fid_data-entities_update`** , it is picking this up from the URL. How do I override/rename it?
You can use the **`@swagger_auto_schema(...)`** decorator to override the **`operationId`** spec as using **`operation_id`** parameter from rest_framework import generics from rest_framework.response import Response **from drf_yasg.utils import swagger_auto_schema** class OperationIdOverrideAPI(generics.ListAPIView): **@swagger_auto_schema(operation_id="Your awesome name")** def get(self, request, *args, **kwargs): return Response({"message": "ok"})
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "django, django rest framework, swagger 2.0, drf yasg, redoc" }