summary
stringlengths
15
147
text
stringlengths
1
19.3k
answer
stringlengths
32
22.6k
labels
float64
0.33
1
answer_summary
stringlengths
5
164
Juddering under load
My 2001 Ford Focus judders when idle, and is most seen under load. The rev counter goes from roughly 500rpm to 1500rpm during this juddering cycle, as if it is "hunting" for the correct place to be. When the lights are on, they noticeably dim during this time - which lasts for about 2 seconds, every 15 to 20 seconds. The alternator is the likely culprit, however this was replaced two years ago and the battery is still being charged. This behavior is most noticeable under electrical load, but also happens when the lights are off. This behavior is intermittent, and does not occur when the car is in motion - only when idling. So, is the alternator the culprit, or is there something else which may be causing this?
It is most likely NOT your alternator. Everything is going to dim in the car when the idle drops down to 500rpm because the alternator cannot put out enough juice to keep things up to snuff. To check it, have someone keep the engine up over 1000 rpm while you put a multi-meter on the battery terminals. Voltage should be around 13.5-14.1 vdc. When you say "juddering" ... Is this just your way of saying "shuddering" or rough idle? Assuming this is what you are saying, there could be a plethora of things causing this. Is the car over a 100k miles? If so, have you done a tune up on it (ie: plugs and O2s))? Have you tried cleaning the MAF and throttle body? Does it need a clean air filter? Do you have any codes? The Air Idle Control (AIC) valve might be your problem. Any/all of these and more could be causing your rough idle and bouncing rpms.
0.777778
Is it just your way of saying "juddering" or rough idle?
Paying for mortgage points vs investing that money
First time home buyer here. So I've been reading about points and how an up-front payment can save you money in the long term. At first, the numbers seem pretty convincing. For example, pay $5000 upfront for a whopping saving of $20,000 over 30 years. ... But if you took that $5000 and invested it, wouldn't you get a lot more than that over 30 years, even at a modest return rate of 6-7%? Suddenly points seem worthless. Is my math wrong? Is there some other advantage regarding points that I'm missing?
Let me give you the benefit of my experience. I paid a bunch of points (4) when I bought my first house for similar reasons than you mentioned including: Lower interest rate would result in savings over life of 30yr loan I had a big capital gain from cashing out stocks for the house down payment and the points (as interest) would offset the tax liability. Why I wish I hadn't: (1) Interest rates plummeted (not as likely to happen today) and I wound up refinancing the loan within the fist 10 years negating the savings that I would have had over the life of the loan. Also, it made me feel stupid for paying close to $5K to knock 1% or so off the loan rate only to have an even lower rate offered to me with no points within a decade. (2) I didn't take into account that I'm the type of person who would try to pay the loan off early, and I did. Way Early. So even if I hadn't refinanced, the extra points were really a waste of money. (3) In the US, at least, you can't always deduct ALL of the money you paid in points in the first year. You may have to spread that deduction over several years. (4) You are right about the alternative being better (investing the points), since the benefit of paying them is at most 1-2% on your loan, you don't even need a 6-7% return to make it a better deal to invest them. HOWEVER, I get skeptical when people compare paying interest to returns on invested money like that. If you don't pay the points will you actually invest that money for the 30 years (or whatever the term of the loan is)? It's easy to say that when you are talking theoreticals, but $5k in your pocket is also pretty tempting when the deal is done. Good luck with the new house!
1
Why did I pay a bunch of points when I bought my first house for similar reasons?
How to change title of button A when button B is pressed?
In Swift, I want to change the title of Button A when Button B is pressed. I tried sender.ButtonA.setTitle("Title", forState: UIControlState.Normal) under IBAction Button B but it couldn't work.. it was just a guess anyway..
You can't use the sender for your needs. Because sender is the button you've clicked on and not the one you want to change the title of. So, you need to make an IBOutlet of your button like you did by creating your IBAction. Then you can call it like that: yourButton.setTitle("Title", forState: UIControlState.Normal)
0.888889
Create an IBOutlet of your button
jQueryUI Spinner widget with knockout
How can I use a jQuery UI Spinner widget in Knockout bound input? <tbody data-bind="foreach: orders"> <tr> <td data-bind="text: Name"></td> <td><input type="number" style="width: 100px;" data-bind="value: Price" /></td> <td><input type="number" style="width: 50px;" data-bind="value: VAT" /></td> <td><input type="number" style="width: 50px;" data-bind="value: Number" /></td> <td data-bind="text: Final()"></td> <td><a href="javascript:void(0);" data-bind="click: $root.removeOrder">Remove</a></td> </tr> </tbody>
The answers on this page are correct and helpful. I found, however, that I was getting bad behaviour when someone was typing a value in the field. Each key press seems to fire a "spinstop" event too. Further, the keypresses were bypassing the field formatting and options.step. Fortunately we can examine the incoming event to see what's actually happening. There may be better ways but I thought I'd share anyway. // Abstract to a function to allow for multiple binding types function createSpinner(defaultOptions) { return { init: function (element, valueAccessor, allBindingsAccessor) { var options = $.extend(true, {}, allBindingsAccessor().spinnerOptions, defaultOptions); var widget = $(element); var observable = valueAccessor(); widget.spinner(options); // handle field changes onblur [copies field -> model] ko.utils.registerEventHandler(element, "blur", function (event) { var inputValue = Number(widget.spinner("value")); var modelValue = observable(); if (inputValue !== modelValue) { // Set the widget (this forces formatting and rounding) - does not fire events widget.spinner("value", inputValue); // Read the value back out (saves us rounding) var numberValue = Number(widget.spinner("value")); // Set the observable observable(numberValue); } }); // handle other field changes ko.utils.registerEventHandler(element, "spinstop", function (event) { // jQuery.spinner spinstop is a bit overzealous with its spinstop event. if (event.keyCode !== undefined) { // If it has a keyCode someone is typing... so don't interfere } else if (event.originalEvent && event.originalEvent.type === "mouseup") { // This is an *actual* spinstop var numberValue = Number(widget.spinner("value")); observable(numberValue); } }); // handle disposal ko.utils.domNodeDisposal.addDisposeCallback(element, function () { widget.spinner("destroy"); }); }, update: function (element, valueAccessor) { // [copies model -> field] var widget = $(element); var observable = valueAccessor(); var inputValue = Number(widget.spinner("value")); var modelValue = observable(); if (inputValue !== modelValue) { widget.spinner("value", modelValue); } } }; } ko.bindingHandlers.moneyspin = createSpinner({ numberFormat: 'C0', culture: 'en-GB', min: 0, incremental: true }); ko.bindingHandlers.intspin = createSpinner({ numberFormat: 'n0', culture: 'en-GB' });
0.888889
jQuery.spinner spinstop is overzealous with its spinstop event
WordPress Show Single Post on Home Page with previous/ Next Button
I am new to WordPress and recently doing some stuff with WordPress. I am using WordPress and want to make theme. I want to show a full post on the home page and at the bottom I want to show next and previous post links. There will only be one category in which I will post and only one post will display on the home page at a time.
Reducing the number of blog posts to show at Settings->Reading from 10 to 1 might do it for you.
0.888889
Reduce the number of blog posts to show at Settings->Reading from 10 to 1
Two sets came to an intersection
Challenge: Print set intersections. Specifications: Your program should accept as its first argument a path to a filename. Each line in the file is a test case. Each test case contain two semicolon delimited sorted lists of numbers in ascending order, whose numbers are separated by a comma. Print out the ascending order sorted intersection of the lists, one per line. Print empty new line in case the lists have no intersection Solution: import java.io.File; import java.io.FileNotFoundException; import java.util.LinkedHashSet; import java.util.Scanner; import java.util.Set; public class SetIntersection { public static void main(String[] args) throws FileNotFoundException { Scanner input = new Scanner(new File(args[0])); String[] parts; while (input.hasNextLine()) { parts = input.nextLine().split(";"); System.out.println( findIntersection( toIntArray(parts[0].split(",")), toIntArray(parts[1].split(",")) ) ); } } private static String findIntersection(int[] foo, int[] bar) { Set<Integer> intersection = new LinkedHashSet<>(); for (int i = 0, j = 0; i < foo.length; i++) { while (foo[i] > bar[j] && j < bar.length) { j++; } if (foo[i] < bar[j]) { continue; } else { intersection.add(bar[j++]); } } if (intersection.isEmpty()) { return ""; // none found } String result = intersection.toString(); return result.substring(1, result.length() - 1); } private static int[] toIntArray(String[] array) { int[] nums = new int[array.length]; for (int i = 0; i < array.length; i++) { nums[i] = Integer.parseInt(array[i]); } return nums; } } Sample Input: 9,10,11;33,34,35 3,7,8,22;11,22 11,12,13,14;14,15,16 20,21,22;45,46,47 77,78,79;78,79,80,81,82 33,35;3,18,26,35 Sample Output: 22 14 78, 79 35 I wanted to take advantage of the fact the lists were sorted, but I fear my efforts only served to render my code convoluted and inefficient. What do you think?
First of all, I have to say that the code formatting is very clean. It's been a long while since I read such well-formatted code. It's probably even cleaner than my own code, and definitely cleaner than my apartment. It is good to take advantage of the specification that the inputs are sorted. Overall you have done so nicely, but I have a few comments. int[] foo, int[] bar Please, oh please, no such variable names! I would prefer input1 and input2 or something like that. foo and bar are names which is okay to use in example code, but not in actual code like this. The choice of choosing a Set<Integer> to store the results is not that optimal when you want the end result as a String. Here I would definitely go for StringBuilder, which also saves you the handling of an edge-case. In fact, I believe your current handling of intersection.isEmpty() isn't necessary either, as an empty set will have the toString value {} which thanks to your substring call will be converted to an empty string. StringBuilder result = new StringBuilder(); ... if (result.length() > 0) { result.append(','); } result.append(bar[j++]); ... return result.toString(); Also, this part can be simplified: if (foo[i] < bar[j]) { continue; } else { intersection.add(bar[j++]); } to: if (foo[i] >= bar[j]) { intersection.add(bar[j++]); } Although you probably would want to check for == instead of >= there.
0.666667
Int[] foo, int[[] bar
get_permalink to attachment not working
I have following code <?php $args = array( 'post_type' => 'attachment', 'numberposts' => 12, 'post_status' => null ); $attachments = get_posts( $args ); if ( $attachments ) { foreach ( $attachments as $attachment ) { echo '<li><a href="'.get_permalink( $attachment->ID ).'">'; echo wp_get_attachment_image( $attachment->ID, array('100', '100') ); echo '</a></li>'; } } ?> The point of this script is to show last added 12 photos (thumbs of it). And this works perfect. But I want to add second funcionality - link to the page where it comes from (usually native gallery embed into post/page) The problem is that in this case the link is corrupted. It always links to the very first post. What I am doing wrong?
The Problem is that you query for Post Status null. Try setting this to publish or inherit, because get_permalink is a function for published items, not for any post status. This is because Permalinks to items with a status like draft should not be shown to the user.
1
How to query for Post Status null?
Basic steps to develop python API in Unix environment
I am developing an API in Unix environment for virtual machines. Most of the modules are developed in python. I have few questions on this. I have the file extension as abc.py. I would like to make this as a command. For example , virtman dominfo [vmid] should be the command syntax. Now I have to give ./virtman.py dominfo [vmid] to achieve this. And I have first line as #!/usr/bin/python in the python file. So how can make this as a command? My echo $PATH looks like '/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin0' I read a lot of articles but I didn't get the clear picture,so any hints/suggestions would be helpful.
You seem to be mistaken in that abc.py would not be a command. If you can execute it, then is, just one with a dot in the name. Execute in the sense that you can do ./abc.py, so the execute bits must be set. If you have to do python abc.py than you it is not a command (yet). In general, to make a normal python file abc.py executable you should make sure the first line reads: #!/usr/bin/env python (This assumes you have /usr/bin/env as a program, and that will find the python command, which might be in /usr/local/bin. It also assumes that you want to run the default python (which is normally a link to a particular python version like python2.7), you could also use python3 if that is available as a command). After that do chmod +x abc.py mv abc.py abc And then you can run ./abc. If the current directory is in your path, or if you move abc to a directory in your path, you should be able to execute abc from anywhere.¹ There are however disadvantages of renaming and moving the file: you can no longer to from abc import SomeClass, as the file is renamed If the file is under revision control it might no longer be So instead, what I normally do, is make a new file /usr/local/bin/abc that looks like: #!/usr/bin/env python from abc import main main() and have at the bottom of abc.py: def main(): doing the real stuff if __name__ == '__main__': main() The directory of abc.py needs to be in the PATH python searches for modules, but this way it doesn't have to be changed, and can be used by any program as an import, and started as python abc.py. ¹ The mv is necessary to get rid of the dot in the command name, but not really necessary, you can invoke ./abc.py if you don't rename it.
1
Execute in the sense that you can do ./abc.py
A Generic error occured in GDI+ in Image.Save() method
I'm trying to use this class but I'm getting a Generic error occured in GDI+ in Image.Save() method. From what I read it's some stream I need to close but I don't know which one. I'm calling using this: Image image = Image.FromFile(@"C:\a.jpg"); using (var resized = ImageUtilities.ResizeImage(image, 50, 100)) { //save the resized image as a jpeg with a quality of 90 ImageUtilities.SaveJpeg(@"C:\myimage.jpeg", resized, 90); } Why is that error and how do I solve this?
Have you tested saving the images in different locations? If it is still failing then without knowing exactly what is going on in your code I would hazard a guess to say that the original image is getting disposed somewhere before it should be. That's usually the most common cause of the error. I've written a library that handles many different imaging operations whilst ensuring that memory is correctly handled. It's well tested and very simple to use. You can get it here. http://imageprocessor.org/ Example code using the library: using (ImageFactory imageFactory = new ImageFactory()) { // Load, resize, set the quality and save an image. imageFactory.Load(@"C:\a.jpg") .Resize(new Size(50, 100)) .Quality(90) .Save(@"C:\myimage.jpeg); }
1
How do you save images in different locations?
Deciding how to articulate Baroque semiquavers
I'm playing a movement (from a Quantz flute concerto) in 2/4 time. There are reasonably lengthy passages of semiquavers with no slurs marked. I appreciate I want to vary my articulation to make it more interesting, so how would I go about deciding where to place my slurs? Are there certain beats I shouldn't slur between because it would add emphasis in the wrong place? Of course you can't give me a definitive answer without seeing the music, but presumably there are some general rules to follow.
It really depends on the music. I don't think there are any rhythmic permutations of 2/4 time that we could definitively say should not be slurred. Emphasis could be anywhere in a measure depending on where the composer has decided to phrase. Perhaps one thing you might try doing is finding repeated material and play it differently (either with dynamics or articulation) the second time around. However, you do want to stay true to the style of that historical music. Have you listened to professional recordings that use period instruments and performance practice? You may find that each note in that passage is meant to be articulated, but at the same time there may be a few things you can do to vary that articulation; perhaps by experimenting with different tongue positions and note lengths.
1
Do you want to stay true to the style of historical music?
Can water be magnetized?
This may be a stupid question, so feel free to shoot it down. Assuming all atoms have a magnetic moment, I would assume the water molecule too would have a resultant magnetic moment; ergo, it may be possible to magnetize a body of water. Can water be magnetized?
Pass a lot of electricity through a small amount of water(behaves as an electric conductor). There will be field around it. If you want to have magnetism for a non-electrocuted water, its impossible(to get higher B values). But, using some solutes you can increase the magnetic property of water.
1
Pass a lot of electricity through a small amount of water
What is the kernel doing when I bring a TUN/TAP interface up
I'm playing around with the TUN/TAP device on Linux. I've created a simple program that creates a TAP interface and prints anything that is sent through it. When I bring the interface up with ip link set tap1 up six frames are sent through it. What are these frames? I've pasted them here
OK, I can't get the packet imported into Wireshark (there must be some headers extra or missing, not bothering to figure that out) but, this is IPv6. From your first frame, you see ff 02 00 00 00 00 00 00 00 00 00 00 00 00 00 16. That's the IPv6 address ff02::16, used for MLDv2. Edit: from your first frame, here is the IPv6 part in a format Wireshark can understand when you select "File->Import" and pick Encapsulation type of Raw IP or Raw IPv6 (this starts after 36 octets of other headers): 0000 60 00 00 00 00 24 00 01 00 00 00 00 00 00 00 00 0010 00 00 00 00 00 00 00 00 ff 02 00 00 00 00 00 00 0020 00 00 00 00 00 00 00 16 3a 00 05 02 00 00 01 00 0030 8f 00 d1 ff 00 00 00 01 04 00 00 00 ff 02 00 00 0040 00 00 00 00 00 00 00 01 ff ea 9c a0 00 00 Edit(2): If you trim off the leading 4 octets 00 00 86 dd, then it decodes properly as an Ethernet frame. Edit(3): Here is your whole capture, with those 4 octets removed from each packet and massaged so Wireshark can import it (encapsulation Ethernet): http://pastebin.com/sUfCfPC4
0.888889
IPv6 packet imported into Wireshark
How to display JSON returned (from external REST API) in a Block? [my code attempt inside]
I am trying to display the data from a REST API (URL: 'http://api.kivaws.org/v1/loans/38239/lenders.json') to display in a block. Below is my code. It is not working, any hint on why will be sincerely appreciated. /** * Implements hook_block_info(). */ function restapiexample_block_info() { // This example comes from node.module. $blocks['kiva'] = array( 'info' => t('Kiva Test Block'), 'cache' => DRUPAL_NO_CACHE ); return $blocks; } /** * Implements hook_block_view(). */ function restapiexample_block_view($delta = '') { // This example is adapted from node.module. $block = array(); switch ($delta) { case 'kiva': $block['subject'] = t('Kiva Example'); $block['content'] = array( '#theme' => 'page', '#markup' => kiva_list_loans(), break; } return $block; } function kiva_list_loans() { $request = drupal_http_request('http://api.kivaws.org/v1/loans/38239/lenders.json'); return drupal_json_decode($request->data); } You can try the URL, good JSON data is being returned. Error I receive is several instances of the following text in the $messages area: "Warning: Cannot use a scalar value as an array in drupal_render() (line 5859 of /home/drupalpro/websites/example7.dev/includes/common.inc)" UPDATE 1: With help from comments/answer below, I made some progress. from my function "kiva_list_loans()", I am able to see the response in my $page array. I changed the '#theme' in my "$block['content']" in hook_block_view to 'page' - but still I only see the word "Array". How to get this to render?
$block['content'] should be an array, like in the example for hook_block_view: $block['content'] = array( '#theme' => 'feed_icon', '#url' => 'rss.xml', '#title' => t('Syndicate'), ); For more examples, see Examples for Developers project, block_example module. If you are putting array there, it must be a renderable array. If it's not, then either: Implode it into string. With nested arrays, it can get a bit complicated. Put it as an element in $block['content'] array, and set $block['content']['#theme'] element to something that can theme it. More complicated, but also more versatile and cleaner solution.
1
Using nested arrays
How to unbrick galaxy grand 2
I want to unbrick my galaxy grand 2 but instead of flashing the stock rom through odin, is there any other way to flash a custom rom instead?
No. Odin the stock ROM to get everything back to normal (you may need to use the appropriate PIT file to repartition), and then afterward you can flash a custom ROM as you would normally.
0.888889
Using PIT file to repartition a custom ROM
Regex findall on a function definition. Want to match args but not function
I have a list of strings that look like "funcname(arg, another_arg)*20 + second_func(arg1, arg2)" and I want to pull out just the args. I've tried the following: re.findall(r'\w[\w\d_]+(?!\()', string) however this returns ['funcnam', 'arg', 'another_arg', '20', 'second_fun', 'arg1', 'arg2'] Firstly, I'm a bit confused as to why I am seeing the '20', since I specified the string should start with a word character. Secondly, I'm wondering how I can improve my look-ahead to match what I'm looking for. I should note that some of the strings don't have functions and look like "value1 + value_two" so I can't simply search inside the parentheses.
Here is a regex that should work better: (?!\w+\()[^\W\d]\w+ For example: >>> s = "funcname(arg, another_arg)*20 + second_func(arg1, arg2)" >>> re.findall(r'(?!\w+\()[^\W\d]\w+', s) ['arg', 'another_arg', 'arg1', 'arg2'] [^\W\d] is equivalent to [a-zA-Z_]. This uses the same logic as your regex, but by moving the lookahead to the beginning of the string you prevent a match like funcnam from funcname(...). Here is a similar alternative: [^\W\d]\w+(?![\w(])
1
funcnam is equivalent to funcname(?)
Goalkeeper Jumping Algorithm?
This may be a "best way to" question, so may be susceptible to opinion-based answers (which is ok for me). But I would also like if there are any tutorials , research papers , etc. I'm trying to make a 3D free kick game, and I want to decide on the Goalkeeper algorithm. Usually (and in my game) the shot is a function of direction , power and swerve. Maybe wind can be a factor too. So the shots trajectory is pre-deterministic, i.e., the point that intersects the goal (or out) plane is determined as soon as the shot fires. So what could be a good approach for the goalkeeper to jump (or walk) ? I have two approaches in mind : 1- determine the point, and jump to there. 2- when the ball is closer than a threshold distance, estimate the point by the ball's velocity vector, and jump to there. The problem with the first approach is, goalkeeper will always save the shot, which I want to prevent. So there should be some kind of randomness, or the goalkeeper's ability to jump and walk will be restricted. The problem with the second approach is, when there is a high amount of swerve, the goalkeeper will always fail to save the shot. So how could these approaches be better? Thanks for any help ! Edit: if you want to play the game, click here
My team is working in a Football MMO and our approach is to attribute goal keepers (and other players) with several attributes, such as JUMP, PHYSIQUE, AGILITY, REACTION, REASON, POSITIONING, to name a few. The probability to perform a task is then a weighted sum of the attributes of the player related to that task. In your case, the task is to defend the shoot. You can model this as simple or complex as you like, depending on the quantity of skills used. You can also save presets of the skills set and use them depending on the difficulty, for example. Finally, to get some randomness, just simulate a dice and use it to check if the returned value is within the probability threshold. If it is, the shoot is defended. If not, it is a goal.
0.777778
The probability to perform a task is then a weighted sum of the attributes of the player .
Should if/else statements be arranged by rareness of cases or difficulty of dealing with them?
In some code I'm writing right now, I have something like this: if (uncommon_condition) { do_something_simple(); } else { do(); something(); long(); and(); complicated(); } Part of me thinks "It's fine the way it's written. Simple cases should go first and more complicated cases should go next." But another part says: "No! The else code should go under the if, because if is for dealing with unusual cases and else is for dealing with all other cases." Which is correct or preferable?
As for such scenarios there is no thumb rule for it. But possibly we can follow to write the positive or most likely code in the if block and left out in the else block or default cases.
1
Write the positive or most likely code in the if block or default cases
How to get Ajax into a theme - without writing a plugin?
Okay, I'm starting out with some AJAX stuff in a wordpress theme 1) I'm building a child theme OFF the thematic framework 2) My child theme has a header.php, index.php, functions.php and style.css (at this stage) In my header.php I have the following (btw: the code is adapted from http://codex.wordpress.org/AJAX_in_Plugins): <?php if( !is_admin() ) { add_action('wp_ajax_my_special_action', 'my_action_callback'); add_action('wp_ajax_nopriv_my_special_action', 'my_action_callback'); $_ajax = admin_url('admin-ajax.php'); } ?> <script type="text/javascript" > jQuery(document).ready(function($) { var data = { action: 'my_special_action', whatever: 1234 }; jQuery.post('<?php echo($_ajax); ?>', data, function(response) { jQuery('#output').html('Got this from the server: ' + response); }); }); </script> </head> Right so that's all cool - and it updates the OUTPUT div on the page with "Got this from the server: 0" I need a PHP function called "my_action_callback" - so in my theme's functions.php I have the following: function my_action_callback() { $whatever = $_POST['whatever']; $whatever += 10; echo 'whatever now equals: ' . $whatever; die(); } This is the ONLY function in my functions.php To make sure the PHP function is working I stick my_action_callback() into my index.php - and it outputs "whatever now equals: 10" as expected. HOWEVER - the AJAX response is always 'Got this from the server: 0' Ajax never seems to get the response from the PHP function. I tried adding .ajaxError() to see if there were any errors - nope. I tried adding the PHP functions to another plugin of mine - nope. What am I missing that jQuery isn't doing the ajax bit for me? Thanks in advance
Put those add_action functions in your functions.php file too. If they're in header.php, WordPress never registers them since header isn't loaded in AJAX. Also, you don't need that is_admin() check. The theme's header will never load in admin. So, your functions file should look like this: add_action('wp_ajax_my_special_action', 'my_action_callback'); add_action('wp_ajax_nopriv_my_special_action', 'my_action_callback'); function my_action_callback() { $whatever = $_POST['whatever']; $whatever += 10; echo 'whatever now equals: ' . $whatever; die(); } And the beginning of that part of your theme's header file should look like this: <?php $_ajax = admin_url('admin-ajax.php'); ?> <script type="text/javascript" > jQuery(document).ready(function($) { Other than that, your code looks like it's good to go!
0.888889
Add_action functions in functions.php file
What kind of gasoline additives will help maintain the engine efficiency/life?
Aside from the traditional maintenance of oil changes, and keeping fluid levels correct - what else will help prolong the engine's life? I recall a few years back gasoline additives were the thing to go with - what's the best/recommended one currently? If any. Edit: I recall reading about each gasoline brand having their own set of additives at one point, where it was suggested to cycle between a few different brands every X amount of km/miles. The reason behind switching was so that the next brand would cleanup any sediments left by the previous brand. How likely is this in today's world? And better yet, how important is it?
You should without a doubt make sure to handle any issues as they "pop up". Yes, there are times where money isn't the easiest thing to come by (Trust me. I know), when this is the case just make sure to handle it as soon as you can. Also it's vital that you keep up with your vehicles service intervals as described in your vehicles manuals. In my opinion there is no real science to to it. It's more or less logic and common sense. If something doesn't feel right then have it looked at by a professional that you trust as soon as possible. Waiting on repairs only puts more wear on the other components that work with it. This usually brings repair bills through the roof and customers into "panic" mode. Usually ending with the customer saying "I'll just drive it till it dies". Which then makes their driving environment much more dangerous not only for them, but for everyone around them. I have supplied two links that will provide online (.pdf) version of the service manuals for the vehicles that you have listed. I hope this helps. 2005 Toyota Tacoma 2013 Nissan Rogue
1
Make sure to handle any issues as they "pop up"
Is it right to say "Viewpoints made easy"?
I'm not native in the English language and I'd like to know if when I say "Viewpoints made easy" your perception leads you to something like: Viewpoints made easy. An easy form to connect and represent points of view and understandings about the world knowledge.
As a native (American) English speaker, my perception is that when someone or something says "X made easy", X is normally considered to be a difficult and complicated item, program, or topic, which the speaker (or book, program, product, etc.) proposes to demystify and explain. I would not ordinarily consider an individual's point of view to be inherently a difficult thing to comprehend. (Some may certainly be more difficult than others, but as a general rule, "putting yourself in another's shoes" is not too tough.) Judging by your example of what you want the sentence to mean, I am inclined to think that "Viewpoint relationships and mappings made easy" might be the better way to express your meaning, as your form sounds like it's designed to create charts and diagrams showing the connections between different points of view.
1
"X made easy" is a difficult and complicated item, program, topic, or topic .
Why is age 3 the age at which a girl is able to have intercourse?
In msh210's answer to this question of mine, he stated that: women...who physically could be [intimate with men], which is those who had reached their third birthday. In comments, he mentioned that: age three is the age at which a girl is halachically considered to be physically able to have intercourse. Could you explain why and where this comes from? Keep in mind I am not Jewish, so if it specific to some non-OT writings, please explain those as well.
OK. The reason is that according to halacha a hymen will regrow if ruptured before the age of three.1 For this reason, it is considered as if no sexual act has occurred as far as the girl's halachic status is concerned, to the extent that her status as a virgin has not changed. Hence, she (for example) is entitled to a minimum kesuba of 200 zuz, just as any other virgin is.2 There are people who like to use misunderstandings, misinterpretations, and even misrepresentations of these and related laws as a means to vilify Jews and Judaism. I'm not going to address that here, though there are rebuttals available. 1: This is mentioned throughout the Talmud, see for example Niddah 45a 2: Rambam Hilchos Ishus 11:3 h/t DoubleAA for corrections.
1
halacha hymen will regrow if ruptured before the age of three
Bash - use loop to make backup script more efficient
I've a backup script (bash). Part of it is shown below. This script does a 14 day rotation of the backup. If I want to change this to say 30 days, I'd have to write out 30 such if-then blocks. I'm sure this could be replaced by a nifty for-loop. What would it be? # step 1: delete the oldest snapshot, if it exists: if [ -d $BACKUP_DIR/daily.14 ] ; then \ $RM -rf $BACKUP_DIR/daily.14 ; \ fi ; # step 2: shift the middle snapshot(s) back by one, if they exist if [ -d $BACKUP_DIR/daily.13 ] ; then \ $MV $BACKUP_DIR/daily.13 $BACKUP_DIR/daily.14 ; \ fi; if [ -d $BACKUP_DIR/daily.12 ] ; then \ $MV $BACKUP_DIR/daily.12 $BACKUP_DIR/daily.13 ; \ fi; if [ -d $BACKUP_DIR/daily.11 ] ; then \ $MV $BACKUP_DIR/daily.11 $BACKUP_DIR/daily.12 ; \ fi; if [ -d $BACKUP_DIR/daily.10 ] ; then \ $MV $BACKUP_DIR/daily.10 $BACKUP_DIR/daily.11 ; \ fi; if [ -d $BACKUP_DIR/daily.9 ] ; then \ $MV $BACKUP_DIR/daily.9 $BACKUP_DIR/daily.10 ; \ fi; if [ -d $BACKUP_DIR/daily.8 ] ; then \ $MV $BACKUP_DIR/daily.8 $BACKUP_DIR/daily.9 ; \ fi; if [ -d $BACKUP_DIR/daily.7 ] ; then \ $MV $BACKUP_DIR/daily.7 $BACKUP_DIR/daily.8 ; \ fi; if [ -d $BACKUP_DIR/daily.6 ] ; then \ $MV $BACKUP_DIR/daily.6 $BACKUP_DIR/daily.7 ; \ fi; if [ -d $BACKUP_DIR/daily.5 ] ; then \ $MV $BACKUP_DIR/daily.5 $BACKUP_DIR/daily.6 ; \ fi; if [ -d $BACKUP_DIR/daily.4 ] ; then \ $MV $BACKUP_DIR/daily.4 $BACKUP_DIR/daily.5 ; \ fi; if [ -d $BACKUP_DIR/daily.3 ] ; then \ $MV $BACKUP_DIR/daily.3 $BACKUP_DIR/daily.4 ; \ fi; if [ -d $BACKUP_DIR/daily.2 ] ; then \ $MV $BACKUP_DIR/daily.2 $BACKUP_DIR/daily.3 ; \ fi; if [ -d $BACKUP_DIR/daily.1 ] ; then \ $MV $BACKUP_DIR/daily.1 $BACKUP_DIR/daily.2 ; \ fi; # step 3: make a hard-link-only (except for dirs) copy of the latest snapshot, if that exists if [ -d $BACKUP_DIR/daily.0 ] ; then \ $CP -al $BACKUP_DIR/daily.0 $BACKUP_DIR/daily.1 ; \ fi;
#!/bin/bash MAX=29 for i in `seq 1 $MAX` do echo " check file exists directory.$i" echo "mv directory.$i to directory" `expr $i - 1` done This might be a good starting point
0.888889
#!/bin/bash MAX=29
Are DSLRs a dying breed, making now the time to switch to a mirrorless camera system?
I came across this thought provoking article on Stuck in Customs today that makes a strong case to hold off too much investment in DSLR gear, and instead switch to mirror-less cameras like the Sony NEX. The author prefers to call such cameras 3rd generation cameras to prevent any bias. The crux of the argument lies in the smaller size and faster shooting speeds of the new cameras, while the sensor size is an area where they seem to be lacking (Sony & Samsung cameras are APS-C sized though). Currently the big makers - Nikon & Canon - have practically no presence in this market (Nikon seems to be doing something with the V1). However, they seem to have slowed down the introduction of new entry level DSLR models over the last year as well. So, as DSLR users looking to build and enhance their kit (there are many like me who've jumped the bandwagon over the last couple of years, and are just starting to build their kit), what are the advantages of sticking with the DSLR system rather than switching to the 3rd gen cameras? IMO, one point that could cause a massive switch in the DSLR base would be if Nikon & Canon announced mirror-less models compatible with their current lens lineups, but that is a hypothetical scenario. P.S. There is a similar question on mirror-less cameras, but that seems to be from the perspective of a person starting out rather than a person already invested in the DSLR system.
DSLRs are certainly not going away any time soon, especially at the high end of the market - ruggedness, speed, large sensor size, and the continued availability of excellent glass will keep them around for some time. Large sensor cameras will also continue to appeal to nature photographers, as the 1.0x crop factor on the higher end models will allow them to shoot wider than APS-C, m4/3, or smaller sensored cameras, lens for lens. That said, I believe that growth of the DSLR market will slow, perhaps even flattening, as I think there are two kinds of DSLR user - pros/enthusiasts who need specific feature sets and are willing to deal with larger size and weight, and people who want better than a point-and-shoot, who would prefer a smaller camera and get some of the benefits of a larger one (APS-C sensors, for example). It's the latter group who will poach market share from both the DSLR and point-and-shoot market segments. Neither will be destroyed, but I believe both will lose some share. As for me, I'm a long time SLR user, who's taking the plunge, selling his Nikon bodies and lenses, and going mirrorless (X-Pro1 when it drops). I think it will offer a compromise of features and size that will get me shooting more, because I'm carrying less. And the point is to be out there shooting, after all...
1
DSLRs are not going away any time soon, especially at the high end of the market .
Why would a sump pump cycle when pumping large amounts of water?
In my septic system, I have a sump pump that pumps the liquid into the drainage field. We have a tank alarm in this tank with the pump, but someone (not sure if it was me or someone else) forgot to turn back on the alarm one time. So now that 1000 gallon tank is over flowing. The pump circuit has been blowing for me at the fuse box. It seems to blow the circuit based on getting a bunch of rain. I'll do a separate question for that. My question is this. I can hear the pump run for a bit (I haven't kept track of the time) then stop. After a while it will start again. Is there a safety or something that would cause the pump to not run until there is no water left? This happens no matter if the float is hooked up or I am just plugged in straight. Or could it be the drainage field is full of water and needs to seep out so there is room for more? I know the tank isn't empty cause shortly after the pump stops, water starts seeping out of the lid again. (and the alarm light is still on).
I'm sorry, I forgot to update this. I called a septic company and they said it sounded like the pump was bad. They replaced it for me and I haven't had any problems since.
0.888889
septic company replaced pump for me .
Why would a sump pump cycle when pumping large amounts of water?
In my septic system, I have a sump pump that pumps the liquid into the drainage field. We have a tank alarm in this tank with the pump, but someone (not sure if it was me or someone else) forgot to turn back on the alarm one time. So now that 1000 gallon tank is over flowing. The pump circuit has been blowing for me at the fuse box. It seems to blow the circuit based on getting a bunch of rain. I'll do a separate question for that. My question is this. I can hear the pump run for a bit (I haven't kept track of the time) then stop. After a while it will start again. Is there a safety or something that would cause the pump to not run until there is no water left? This happens no matter if the float is hooked up or I am just plugged in straight. Or could it be the drainage field is full of water and needs to seep out so there is room for more? I know the tank isn't empty cause shortly after the pump stops, water starts seeping out of the lid again. (and the alarm light is still on).
When you hear the motor running, do you get a discharge? If not, it's the pump. If so, it's the motor.
0.888889
Do you get a discharge when you hear the motor running?
How to change port number in vino?
How to change port number in vino ubuntu 11.10? Cannot find option to change from port 5900 on vino vnc 'remote desktop' window, nor can I find it via gconf-editor as was available in previous ubuntu version. Please help
On Ubuntu 14.10, gconf-editor was required. dconf-editor set a value, but it was not used, and displayed as 0 (5900) in gconf-editor. sudo apt-get install gconf-editor gconf-editor
0.888889
dconf-editor set a value, but it was not used, and displayed as 0 (5900) in gconf
call/cc implementation?
I'm trying to find how call/cc is implemented. The best I've found is this Haskell snippet: callCC f = Cont $ \k -> runCont (f (\a -> Cont $ \_ -> k a)) k Although this is not as simple as I want due to the Cont and runCont. I've also found descriptions of what it does, although never as clear as actual code. So how is it implemented in its simplest form? I am tagging this with Scheme and Haskell as those are two languages I prefer.
call/cc is trivial to implement. The hard part is setting up the environment where it is possible to implement. We must first define a continuation-passing style (CPS) execution environment. In this environment, your functions (or function-like things) don't directly return values; instead, they are passed a function that represents the 'next step' in the computation - the 'continuation' - and they pass their result there. In Haskell, this looks like this: newtype Cont r a = Cont { runCont :: (a -> r) -> r } As you can see, a Cont monad action is really a function that takes a continuation (a -> r), passes a result a to the continuation, and gets back a final result of r, which it simply passes through to its caller (ie, a Cont monad action should tail call into the continuation). runCont just takes it out of the newtype wrapper - you could also think of it as invoking an action with some particular continuation, as in runCont someAction someContinuation. We can then turn this into a monad: instance Monad (Cont r) where return x = Cont $ \cc -> cc x (Cont f) (>>=) g = Cont $ \cc -> f (\r -> runCont (g r) cc) As you can see, return just gets a continuation cc, and passes its value to the continuation. (>>=) is a bit trickier, it has to invoke f with a continuation that then invokes g, gets the action back, and then passes the outer continuation to this new action. So given this framework, getting at the continuation is simple. We just want to invoke a function with its continuation twice. The tricky part is we need to rewrap this continuation in a new monadic action that throws out the existing continuation. So let's break it down a bit: -- Invoke a raw continuation with a given argument, throwing away our normal -- continuation gotoContinuation :: (a -> r) -> a -> Cont r x gotoContinuation continuation argument = Cont $ \_ -> continuation argument -- Duplicate the current continuation; wrap one up in an easy-to-use action, and -- the other stays the normal continuation for f callCC f = Cont $ \cc -> runCont (f (gotoContinuation cc)) cc Simple, no? In other languages like Scheme, the principle is the same, although it may be implemented as a compiler primitive; the reason we can do it in Haskell is because the continuation-passing was something we defined in Haskell, not at a lower level of the runtime. But the principle is the same - you need to have CPS first, and then call/cc is a trivial application of this execution model.
0.777778
Implementing a continuation-passing style (CPS)
How can I set Spotlight metadata to files?
I am looking for a command line utility (I need to use it in a script) that can set Spotlight metadata to files.
You can always use the command line tool xattr, which lists/reads/writes/erases the filesystem's extended attributes of a file. That's what spotlight uses to build it's index. Note that spotlight information keys are prefixed with com.apple.metadata: As quick example, to change the display name on spotlight of a file: xattr -w com.apple.metadata:kMDItemDisplayName MyNewFilename.txt ActualFile.txt to access xattr help, type on t: xattr -h
1
The command line tool xattr lists/reads/writes/erases the filesystem's extended attributes of a
What is output impedance of a pin?
When a datasheet mentions the output impedance of a pin so and so ohms. What exactly does it mean? Can anybody explain through a diagram how does it look like?
Simplified, its just the internal resistance of the output. An equivalent circuit would be just a resistor in series with the sourcing output pin. Any non-ideal source has some (parasitic/unwanted) internal resistance due to the physical layout of the source. In general it needs to be low compared to the load, because with increasing current, the voltage drop on the internal resistance increases and thus, the output voltage decreases. I keep talking about resistance but you asked about output impedance. Impedance = resistance + reactance Reactance is the opposition of a circuit element to a change of electric current or voltage, due to its inductance or capacitance. Since the output behavior is not entirely resistive, we talk about "output impedance".
0.833333
Impedance = resistance + reactance
House rules to make the cloister less of a game winning tile in Carcassonne?
In my experience, cloister tiles in Carcassonne are often "too lucky". If you draw a cloister tile in the beginning of the game, it will typically still require an investment of quite a bit of "meeple" time to obtain the full 9 points, which makes it a fair trade-off. However, after about half of the game, it's relatively likely that you can "parachute" a cloister tile in some spot and get 8 or 9 points immediately. This adds a lot of randomness to the game. What house rules work well to diminish this effect?
Knowing that cloisters can have this effect is half the battle. Rather than adding a house rule to a very popular game I would advise you to alter your strategy a bit to account for future cloisters that you may not control. Examples: Leave a good cloister spot next to an open road that you own. When considering placing a tile between two relatively equal spots determine if one or the other creates a better cloister opportunity. Keep track of how many have been played! If you get down to 10 tiles left and 4 of them are cloisters, make sure you have the meeples available to use them. Alternatively, keep your opponent from freeing his meeples from the board.
0.888889
Keep track of how many cloisters have been played
How do I grep for foo && !bar?
I want to output all the lines in my source code which contain the string foo but don't contain the string bar. I tried this: find . -name "*.[hc]pp" | xargs grep -n foo | grep -x bar However this doesn't work as I expected. How can I use grep in this way?
You want the -v flag, not the -x flag. Mnemonic: negative.
0.777778
-v flag, not -x flag
Why can't I clip vectors with 2 different projections?
I am using QGIS. I am trying to clip parcel data with a stream buffer. The two have different projections. Parcels are NAD83 State plane feet and streams are NAD83 State plane meters. I keep getting an error that says something like detected different projections, some data may not disply correctly. When it runs the clip the output file has no data in it. I have enabled on the fly projection.
For a successful clipping, it is necessary to have the datasets in the same projection. Jut rightclick on one of your layers, Save As ... and choose the CRS of the other one. On-the-fly reprojection is just for visualization of the data, and not helpful for clipping.
0.666667
Reprojection of data
AngularUI-Bootstrap's Typeahead Can't Read `length` Property of `undefined`
I am getting the following error when I attempt to get a typeahead values from AngularUI-Bootstrap, using a promise. TypeError: Cannot read property 'length' of undefined at http://localhost:8000/static/js/ui-bootstrap-tpls-0.6.0.min.js:1:37982 at i (http://localhost:8000/static/js/angular.min.js:79:437) at i (http://localhost:8000/static/js/angular.min.js:79:437) at http://localhost:8000/static/js/angular.min.js:80:485 at Object.e.$eval (http://localhost:8000/static/js/angular.min.js:92:272) at Object.e.$digest (http://localhost:8000/static/js/angular.min.js:90:142) at Object.e.$apply (http://localhost:8000/static/js/angular.min.js:92:431) at HTMLInputElement.Va.i (http://localhost:8000/static/js/angular.min.js:120:156) at HTMLInputElement.x.event.dispatch (http://localhost:8000/static/js/jquery-1.10.2.min.js:5:14129) at HTMLInputElement.v.handle (http://localhost:8000/static/js/jquery-1.10.2.min.js:5:10866) My HTML tag is: <input type="text" class="form-control" id="guestName" ng-model="name" typeahead="name for name in getTypeaheadValues($viewValue)"> With my getTypeaheadValues function doing the following: $scope.getTypeaheadValues = function($viewValue) { // return ['1','2','3','4']; $http({ method: 'GET', url: 'api/v1/person?name__icontains=' + $viewValue }).error(function ($data) { console.log("failed to fetch typeahead data"); }).success(function ($data) { var output = []; $data.objects.forEach(function (person) { output.push(person.name); }); console.log(output); return output; }); } I do not understand what AngularUI-Bootstrap is complaining about as being undefined. If I remove the comment on the top-most return the values show up fine. The console.log output in the success also return all the values I'm expecting in an array. What am I missing that would cause AngularUI-Bootstrap not see the returned array?
$scope.getTypeaheadValues = function($viewValue) { var someOutput="";//return something $http({ method: 'GET', url: 'api/v1/person?name__icontains=' + $viewValue }).error(function (data) { console.error(data); }).success(function (data) { console.log(data);//Do whatever you want }); return someOutput; } //The return statement is missing
0.888889
var someOutput=""
Using formatted code inside spoiler block?
Possible Duplicate: How can I put a whole code block in spoiler text? I know I can use the <code> tag and some other html tags inside a spoiler block, but the code is not formatted or highlighted. Is there a way to include formatted code inside a spoiler block?
Nope, everything in the spoiler block is treated as one paragraph. :-( You cannot use bullets either. I consider this a bug, the parser should treat it just like a blockquote, albeit one that is rendered with an extra class. In a blockquote you can use all the other formatting options still, provided you use one extra space in your indentations: Block quotes support bullets and code blocks: This is a bullet with a codeblock: # Python easter egg: import this (note that no highlighting is applied to blockquotes either). In a spoiler block (which only adds a ! exclamation mark) this doesn't work, but I feel it should: Block quotes support bullets and code blocks: * This is a bullet with a codeblock: # Python easter egg: import this Your only workaround is to use explicit HTML tags yourself. Markdown source for the above blocks are: Blockquote > Block quotes support bullets and code blocks: > > * This is a bullet *with* a codeblock: > > # Python easter egg: > import this Spoiler block >! Block quotes support bullets and code blocks: >! >! * This is a bullet *with* a codeblock: >! >! # Python easter egg: >! import this
0.888889
Block quotes support bullets and code blocks in a spoiler block
Unix C++: get time at a different zone
I'm trying to get the time in a different timezone (PST) using C++. #define PST (-8); char* Time::getSecondSystemTime() { time_t rawtime; struct tm * timeinfo; char buffer[80]; time(&rawtime); timeinfo = gmtime(&rawtime); timeinfo->tm_hour = timeinfo->tm_hour + PST; strftime(buffer, 80, "%I:%M %p", timeinfo); std::string temp = std::string(buffer); // to get rid of extra stuff std::string extraInfo = " Pacific Time ( US & Canada )"; temp.append(extraInfo); return (char*) (temp.c_str()); } The problem here is that when the GMT time is less than 8 hours (for example, right now, the time there is 3AM in the morning), subtracting 8 hours from it does not work! What is the proper way to get time at a different time zone in Unix?
Since you said "UNIX", this uses TZ, but, TZ=[what goes here] You need to find out [what goes here] on your system. It might be "America/LosAngeles" or one of several other strings for PST. If your system is POSIX: TZ=PST8PST is guaranteed to work. But it may not be optimal. Primitive non-production code assumes TZ is not currently in use. This is in C, not C++ since your tag was C: setenv("TZ", "PST8PST", 1); // set TZ tzset(); // recognize TZ time_t lt=time(NULL); //epoch seconds struct tm *p=localtime(&lt); // get local time struct tm char tmp[80]={0x0}; strftime(tmp, 80, "%c", p); // format time use format string, %c printf("time and date PST: %s\n", tmp); // display time and date // you may or may not want to remove the TZ variable at this point.
0.888889
TZ=What goes here?
XPATH Selecting by position returns incoherent results
I need some help with an issue I can't figure out. I have the following xml: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="prueba.xsl"?> <ficha> <titulo></titulo> <bloque> <texto></texto> <pregunta id="1" tipo="checkSN"> <texto>Acredita curso bienestar animal minimo 20 h</texto> </pregunta> <pregunta id="2" tipo="texto"> <texto>Sistemática inspección</texto> </pregunta> <grupo> <texto>trato adecuado enfermos</texto> <pregunta id="3" tipo="desplegableSNP"> <texto>Recetas correspondientes</texto> </pregunta> <pregunta id="4" tipo="multiple"> <texto>Disponen de comida y bebida</texto> </pregunta> </grupo> <grupo> <texto> Heridos/Enfermos </texto> <pregunta id="5" tipo="multiple"> <texto>Se aprecian heridos o enfermos momento inspeccion</texto> </pregunta> <pregunta id="6" tipo="multiple"> <texto>Separados del resto</texto> </pregunta> <pregunta id="7" tipo="multiple"> <texto>Disponen de comida y bebida</texto> </pregunta> <pregunta id="8" tipo="multiple"> <texto>Disponen de comida y bebida</texto> </pregunta> </grupo> </bloque> <bloque> <texto>Condiciones específicas de alojamiento y manejo</texto> </bloque> </ficha> And The folliwng XSL sheet: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head> <link rel="stylesheet" type="text/css" href="prueba.css" /> </head> <body> <h2><xsl:value-of select="/ficha/titulo"/></h2> <h3>1: <xsl:value-of select="//pregunta[1]/@id"/></h3> <h3>2: <xsl:value-of select="//pregunta[2]/@id"/></h3> <h3>3: <xsl:value-of select="//pregunta[3]/@id"/></h3> <h3>4: <xsl:value-of select="//pregunta[4]/@id"/></h3> <h3>5: <xsl:value-of select="//pregunta[5]/@id"/></h3> <h3>6: <xsl:value-of select="//pregunta[6]/@id"/></h3> <h3>7: <xsl:value-of select="//pregunta[7]/@id"/></h3> <h3>8: <xsl:value-of select="//pregunta[8]/@id"/></h3> <h3>c: <xsl:value-of select="count(//pregunta)"/></h3> </body> </html> </xsl:template> </xsl:stylesheet> When I load them I got this result: 1: 1 2: 2 3: 7 4: 8 5: 6: 7: 8: c: 8 I don't understand why it's ignoring some nodes . If I include new nodes or move them, it always shows 4 results, from node at position 5 to 8 it never shows anything. I need to use this type of selecting because it's from a Java application, the stylesheet is just for testing.
I can't fully explain why you're seeing the behaviour you are (I suspect it may be something to do with an odd 2d array being returned but that is just my own wild theory) but there does seem to be a simple workaround. If you use a foreach loop (which seems to fit what you need better anyway, although I could be wrong again!) it returns all of the values from the select, i.e. <xsl:for-each select="//pregunta"> <h3><xsl:value-of select="position()" /> : <xsl:value-of select="@id" /></h3> </xsl:for-each>
1
Foreach loop returns all of the values from the select
Natty freezes constantly after install
I've just installed 11.04 and now at random everything freezes. The keyboard responds but the only thing that seems to unlock it is a reisub. I never had this problem before and I've had this computer for almost a year. I'm using gnome 3 but it also happens when I'm using unity. Even if I don't have any programs running soon or later it freezes. I've seen some similar questions here like this and this but no solution.
I had a similar problem. It turns out in my case that the r8169 networking module was unstable. Uninstalling the vanilla r8169 module Using the Realtek proprietary r8168 module solved this for me. I have no problems with stability now.
1
Uninstalling the vanilla r8169 networking module
Verify guest order and set guest order state
I'm trying to implement an order confirmation module for guest accounts. I researched now for a couple hours but it seems that I can't find any solution to my problem. I need to verify if the email of a guest customer is actually valid. After the order is placed I observe the sales_order_place_after event and try to set the guest order to holded or a custom one like unconfirmed. Either way the state change gets overwritten by Magento. After that I want to send an email with a verification link. And then change the state back to pending. I think I can overwrite the basic email template for a new guest order. Is this correct? How can I set guest orders to a different state than the default "pending"? Thank you all very much in advance!
Just observe the sales_order_save_before event, find a correct condition (this is important) how to determine, you change the status for the correct orders (not every time, an order is saved) and set the status
0.777778
How to change the status for the correct orders?
Prerequisities to become an MD-PhD?
Officially, I am studying computer science. However, what I am actually doing is computational neuroscience. More over, the research I do is mostly medical research. I have noticed that there are programs for MD-PhDs. However, in most countries, there seems to be always some legal requirements one has to fulfill to enter such programs. These requirements are not given very clearly out in most cases. With an M.Sc in computer science, can I apply to such programs? More trickier question is would it be wise..? I mean, I could just go to a neuroscience program. However, I would be also really interested to help people with psychological, neurological, etc. issues (work in hospital), when having the MD title is a must?
Most of the "legal requirements" associated with MD-PhD programs are financing related. In general, such programs are usually sponsored and funded by national health ministries (or their equivalents). Therefore, it is preferred (or required) only to have legally qualified citizens participate in such programs. As for the choice of major, in general, computer science is not one of the usual entry points for MD-PhD programs, which tend to be more closely related to experimental programs and majors (e.g., chemistry, biochemistry, biology, bioengineering). That said, there is more of an emphasis nowadays on computational science in medicine, and more and more MD-PhD programs are expanding their scope to include bioinformatics and computational biology. But it is still definitely not a universal, and CS majors will be at something of a disadvantage.
1
"legal requirements" associated with MD-PhD programs are financing related .
Continuations in Clojure
I read somewhere where rich hickey said: "I think continuations might be neat in theory, but not in practice" I am not familiar with clojure. 1. Does clojure have continuations? 2. If no, dont you need continuations? I have seen a lot of good examples especially from this guy. What is the alternative? 3. If yes, is there a documentation?
A common use of continuations is in the implementation of control structures for: returning from a function, breaking from a loop, exception handling etc. Most languages (like Java, C++ etc) provide these features as part of the core language. Some languages don't (e.g: Scheme). Instead, these languages expose continuatiions as first class objects and let the programmer define new control structures. Thus Scheme should be looked upon as a programming language toolkit, not a complete language in itself. In Clojure, we almost never need to use continuations directly, because almost all the control structures are provided by the language/VM combination. Still, first class continuations can be a powerful tool in the hands of the competent programmer. Especially in Scheme, continuations are better than the equivalent counterparts in other languages (like the setjmp/longjmp pair in C). This article has more details on this. BTW, it will be interesting to know how Rich Hickey justifies his opinion about continuations. Any links for that?
1
Implementation of continuations as first class objects
What abilities can be blocked by sivir's/nocturne's spell shield?
Mainly, im wondering what ultimates would be blocked, and other spells that have long casts. But if you have a list that would be nice.
Spell shields block all activation of spells (Starts of channels included). They do not block DoTs during the effect. They do not break targeted channeled effects (Fiddle's drain as an example) They do block spells of any type as long as it's a targeted single-hit spell (Magical, Physical and On-Hit effects) (For Requiem, the shield can be cast to block the damage part post-channel) They do block ONE tick out of series of persistent damage abilities. (Panth's HSS, Kennens Maelstrom.) There are several things I'm still not sure of, such as how Viktor's CC field and Ultimate are affected, or how the shields reacts to on-hit effects.
1
Spell shields block all activation of spells
In-game rewards for game-related work?
The other GM in my group and I are both big fans of giving XP rewards for things done out of the game. Ex: We have an artist who will draw and design all sorts of stuff to "fluff out" our campaign. We noticed participation spiked when we offered rewards like this. Eventually, we even offered XP to our "scribe" for recording everything that happened each session. At the most, though, this gives bonus XP for up to two of our players. We do not plan to remove these bonuses, but want to be fair to all our players. What are some fun things your players can do out of game that you can reward as GM? The goal is to have them be engaged in our game even when we aren't playing.
The "Artist" and "Scribe" are quite useful the campaign, and I also agree with lisardggY's suggestions about transportation and centralized documentation to follow the game. That said, here are my additions: While the specific game escapes me (I believe it was a White Wolf book), they suggest offering XP to whomever brings snacks for the table. As a personal belief, if for some reason I'm not able to run my games in my home, I tend to offer a small bonus to the host of the game session. Fleshing the Backstory: Most of the players I encounter have their central theme designed more like a video game than actual people until they play for a while and get some momentum. Thus I have started offering rewards for people who come to game with meaningful data on their character. Stationary Supplies can be a very eroding stock. Anyone who consistently has pencils, erasers, especially blank char sheets, quick references, etc. Side note: Just make sure that the XP bonuses don't ramp up too quickly. In some games the balance gets upset quite quickly even with the smallest offerings if they happen regularly.
1
"Artist" and "Scribe" are quite useful in the campaign .
Why does SnCl2 occur despite the octet rule?
Shouldn't reaching an octet be any atom's "goal"? However, I've recently learned about cases that are either expanding octets, or have lesser than "enough" electrons for an octet abiding. e.g.: S in Sulfur hexafluoride (Expanding octet with a $\text{3d}$) Source B in Boron trifluoride (It's "hexet", instead of octet) Source However, both $\ce{SnCl2}$ and $\ce{SnCl4}$ are existent. The latter is explainable with octet, but not the former. Surprisingly, $\ce{SnCl2}$ is more stable! How? Why is the phenomenon happening? Dave pointed out that the octet nonabidingness is happening in the vapor phase. So I redirect the question to ask about the vapor phase; since that's what I'm looking for.
According to Theoretical and experimental studies of the electronic structure of SnCl2 by photoionization with synchrotron radiation AIP Conf. Proc. 258, 60 (1992) $\ce{SnCl2}$ has a molecular orbital structure as below (HOMO at the top) Sigma-antibonding: 36% Sn s, 22% Sn p, 41% Cl s Nonbonding 99% Cl p Nonbonding 99% Cl p Nonbonding 7% Sn p , 92% Cl p Nonbonding 3% Sn s, 6% Sn p , 90% Cl p Sigma bonding 14% Sn p, 83% Cl p Sigma bonding 48% Sn s, 6% Cl s 45% Cl p Nonbonding 3% Sn p, 96% Cl s Nonbonding 5% Sn s, 2% Sn p, 92% Cl s So overall it seems: There is a total bond order of only 1. Much of the Sn p and some Sn s electron density has been donated to Cl p orbitals. There is little mixing of Sn s and p orbitals expect in the antibonding orbital. additional references: A Symmetry Rule for Predicting Molecular Structures (This reference explains how, based upon second order Jahn Teller effect, the symmetry of molecular orbitals predicts geometry, for example bent vs linear, and says that the symmetry predicts bent for SnCl2) and Metal oxidation state effect in photoionization of gas‐phase metal halides (which further discusses the molecular orbitals of SnCl2 discussed above)
0.888889
Theoretical and experimental studies of the electronic structure of SnCl2 by photoionization with synchrotron radiation
What level are spells cast at if a warlock multiclasses as another caster?
The Pact Magic paragraph on page 164 of the Player's Handbook multiclassing section reads: you can use the spell slots you gain from the Spellcasting class feature to cast warlock spells you know. If I were to multiclass as a Warlock 5 / Rogue 3 Arcane Trickster and cast a Warlock spell using my Arcane Trickster's 1st level spell slot, would it be cast as a 3rd level spell? From the Warlock Spell Slots section on page 107 of the Player's Handbook: The table also shows what the level of these slots is: all of your spell slots are the same level. The proposed duplicate question appears to only address the issue of spell slot recovery, not casting.
It depends on which slot you use. If you cast using a warlock slot, the spell is cast at the level of the warlock slot. However, if you cast using your other class's slot, then it will be at the slot level you choose to burn. You can use either class to cast the spell provided that the spell is low enough level to fit in the slot used (you can't cast a 6th level spell in a 3rd level warlock slot). To answer your specific example: You can cast your arcane trickster spells with your warlock slots, they would be cast at 3rd level. However, if you try to cast a warlock spell using your arcane trickster slots, they will be cast at the level of the slot you use. Also, you can't cast a higher level spell than slot you have remaining (can't cast a 3rd level warlock spell in a 1st level AT slot).
0.888889
If you cast using a warlock slot, the spell is cast at the level of the slot you use .
High ping on games while streaming
I'm streaming with Elgato Capture Card to Twitch. I get high pings on games while streaming (1700kbps). How can I decrease pings while streaming? Here is my bandwidth:
You are almost completely saturating your upload bandwidth with the stream you're sending. Despite streaming out not using much of your download speed, you need plenty of bandwidth available in both directions to have reduced latency in games. As I see it, you've two options. Increase the available bandwidth on your upload speed. You can achieve this by either reducing the quality of your stream, or increasing the available upload speed. Purchase a router with Quality of Service (QoS), this will you to prioritise traffic. You need to set a lower priority on stream traffic, so the game latency is reduced. Ideally, I'd suggest you considered implementing both options, if you want the best performance for both the stream and the game. For what it's worth, I do think trying to stream at 1700kbps is way too high for an upload speed of 1.92Mbps. For best performance, I'd be reducing that to around half of your available upload bandwidth, i.e. 1000kbps.
1
Increase the available bandwidth on your upload speed
The Probability of Catching Criminals
I have been struggling with the following question and would greatly appreciate any help :) Suppose we have information about the supermarket purchases of 100 million people. Each person goes to the supermarket 100 times in a year and buys 10 of the 1000 items that the supermarket sells. We believe that a pair of criminals will buy exactly the same set of 10 items at some time during the year. If we search for pairs of people who have bought the same set of items, would we expect that any such people found were truly criminals? Assume our hypothesis to be that a pair of criminals will surely buy a set of 10 items in common at some time during the year. This is meant to be an illustration of Bonferroni's principle. Suppose there are no criminals and that everyone behaves at random. Would we find any pairs of people who appear to be criminals? We must initially find the expected number of pairs who buy the same 10 items per year. I'm not sure whether I do this correctly... Here is how I've been going about solving it: Number of possible pairs of people: $\binom{10^6}{2} = \frac{10^{12}}{2} = 5 \times 10^{11}$, using the fact that $\binom{n}{2} \approx \frac{n^2}{2}$, when $n$ is large. Number of possible 10-item selections: $\binom{10^3}{10} \approx 2.6 \times 10^{23}$ Probability of a customer buying 10 particular items at a point in time: $\frac{1}{2.6 \times 10^{23}}$ Probability of a customer buying 10 particular items at least once over the course of 100 periods in time: $\frac{100}{2.6 \times 10^{23}}$ Probability of a pair buying exactly the same 10 items (both at least once) over the course of 100 periods in time: $(\frac{100}{2.6 \times 10^{23}})^2 = (\frac{1}{2.6 \times 10^{21}})^2 = \frac{1}{6.76 \times 10^{42}}$ The expected number of pairs who buy the same 10 items per year is thus: $ 5 \times 10^{11} \times \frac{1}{6.76 \times 10^{42}} = \frac{5}{6.75 \times 10^{31}}$ Because the above number is so low if we do find a pair buying the same 10 items then, under our hypothesis, they are likely to be criminals and not a false positive case. I am just wondering whether my solution to the above is correct?
First of all, your calculations on the number of pairs of people are wrong. There are 100 000 000 people, that's ${10}^{8}$, which gives us $5 \times {10}^{15}$ pairs of people (using the formula you wrote). The probability of two people buying the same set of objects is ${1 \over 10^{23}}^2$ - because the same set has to be picked twice. At the end we would get $100 \times (5 \times 10^{15}) \times ({1 \over 10^{23}})^2 ≈ 5 \times (10^{17}) \times {1 \over 10^{46}} ≈ {5 \over 10^{29}} ≈ {1 \over 2\times10^{28}} ≈ {1 \over 10^{28}}$ (I dropped the 2.6 just to make the equation simpler) The main question here is: "If we search for pairs of people who have bought the same set of items, would we expect that any such people found were truly criminals?" The answer is yes, because: "The Bonferroni principle says that we may only detect terrorists by looking for events that are so rare that they are unlikely to occur in random data" and our event is very unlikly to happen.
1
The probability of two people buying the same set of objects is $1 over 10232$ .
What lightweight telephoto lens are available for Nikon bodies?
I'm looking for a lightweight telephoto lens for my Nikon D700 body, with a focal length around 300mm, good sharpness and AF. After several days with the 70-200 vrII handheld, I found this lens too big and heavy. I usually prefer the prime lenses, but all the good ~300mm prime I know weight 1.5kg or more. I will use it mostly for sport, wildlife and landscape. A bonus point if it is bright enough for a use in dark concert stages :) The only two lightweight options I considered for now are Nikon 70-300mm VR (750g, F5.6@300mm) Nikon 180mm (760g) + 1.4x TC (F4@250mm) Have you any recommandation on these possibilities ? e.g. with third party lenses. I'm in love with my 85mm 1.4G, but I have the feeling that I won't be able to get the same quality at 300mm without carrying expensive kilos of glasses.
This 300mm seems to be lightweight (755g), but definitely not cheap! http://www.bhphotovideo.com/c/product/1111442-REG/nikon_2223_af_s_nikkor_300mm_f_4e.html
0.666667
300mm is lightweight (755g) but not cheap
Combined ADC scaling and offset with variable input voltage ranges
I am trying to create a circuit which will allow me to scale and offset a voltage (be it AC or DC) to within the range of the Arduino ADC. The voltage could be anything between + and - 250V, but I also need to have good sensitivity over lower voltage ranges too. To this end I am looking at a circuit whereby you can vary the voltage range that it expects the input to be and amplify/attenuate it accordingly. How I will be making the decision and setting the different gains is for another topic for now. I am only interested in the scaling and offsetting at the moment. So far I have come up with this circuit: Which appears to do just what I want for the +/- 250V range. I don't know how "safe" this circuit is, and if I am endangering any of the components with the 250V or not. The graphs at the bottom are (left to right) the input voltage, the power consumption of the bottom 10M resistor, the voltage across the 100M resistor (which is simulating the Arduino ADC input) and the power consumption of the upper 10M resistor. Now, if I drop the input voltage to just +/- 2.5V and tweak the op-amp feedback resistor accordingly, for some reason the offset voltage the op-amp is adding jumps right up. I don't know for sure if this is the fault of the simulator I am using, or if it is really what will happen, as I haven't yet breadboarded this circuit (I guess that's the next stage). This is the output from the 2.5V version: You can see how the offset has jumped up and the output is clipping massively. If I drop the lower 10K resistor to the virtual ground offset voltage divider to just 3.3K it compensates, but that's not nice - I would like to just vary the one resistor. The op-amp is (will be) a 5V single supply rail-to-rail I/O one. The two diodes are to protect the input of the op-amp against over voltage - I don't know if this circuit strictly needs them, but I guess it doesn't hurt to have them there. Also, I don't know if the resistor values are quite what I want - I chose them to keep the power consumption right down and the impedance right up. I don't want them to impact the frequency response of the circuit more than I can help - the input waveform could be anything from DC up to around 500KHz or so, and I need that reproducing at the ADC end as faithfully as I can. (I know the Arduino can only really sample at lower speeds than that, but the Arduino is just for experimenting - the final system will use a dsPIC with 1.1Msps ADC). So, what can I do to A) get a more stable offset, B) allow the varying of the input sensitivity without nuking either the op-amp or the ADC, and C) make the circuit safe to connect to, for example, a European mains voltage?
Several comments: Add component designators to your schematic. It is difficult to talk about the circuit otherwise. You appear to be a little confused about resistor dividers. You have two resistor on the input, but only one is doing anything. The resistor to ground is just a load on the input but otherwise has no bearing on your circuit. It sortof looks like the two input resistors (component designators would definitely help) are meant to be a divider that didn't get hooked up right. Yes, you can use opamps for gains below 1, but you might as well use resistor dividers instead. Also keep in mind that at best opamps are specified as stable for unity gain magnitude, but not below. You would have to add your own compensation for that. Three resistors, one from the input voltage, one to ground, and one to the supply can be adjusted such that the input voltage range maps reasonably well to the 0-5V A/D range without any active parts. You can then use the opamp as a voltage buffer because the output of the resistor divider may not have low enough impedance. Instead of changing gains, I would just have a few different gain setups driving different A/D pins. As long as the voltages are properly clipped, they won't hurt being out of range. The full 220V signal may be out of range for the high sensitivity A/D input, so you ignore that and only use the low sensitivity reading. When the signal level is low, the high sensitivity input won't be clipped, so you can use that. Nothing needs to change except in the firmware, which decides which input to use for the particular magnitude of input signal. 500 kHz is a lot for the high value resistors you show. Those should work at 50 Hz, but at 1000 times higher frequency the parasitic capacitance will be significant compared to those resistances. Added: If whatever software you are using doesn't allow for component designators, use something that does. At least use that when drawing the schematic for other people to see. Simulators are overrated anyway. They have their uses, but all too often they seem to make the user forget he has a brain of his own. For a trivial circuit like yours, it would take longer to enter it into a simulator than to simply think it out. You can do a lot with a three-resistor divider as I mentioned above: This can't always exactly fill the 0-Vdd output range with the input signal. But even when it can't, there is usually a good enough solution. Generally the more you need to attenuate, the easier it is to get the output into the desired range. To analyze this circuit, note that by themselves R2 and R3 form a voltage divider of Vdd. This can be thought of as a voltage between Vdd and ground with a specific impedance (see Thevanin): Where R4 = R2 // R3. How you can see we have a simple two-resistor voltage divider. The divider gain is R4/(R1+R4) and the output impedance is R1//R4. From 7th grade math we know that whatever this circuit does to the input voltage can be described by: Vout = Vin(M) + B You can find M and B easily enough from the above equation from any two different points. In your case, Vdd = 5V, so you want the output to be symmetric around half that, or 2.5V. So at Vin=0 you want Vout=2.5. Two other obvious known points are the peaks of the input waveform. Let's pick the negative one, so at Vin=-250 Vout=0. Now M and B can be easily solved. If you want to find a exact solution, you can write the equations for M and B in terms of R1, R4, and V1. As long as V1 is more than 0 and less than Vdd, a exact solution is possible. From the simplified second schematic, it should be obvious that: M = R4/(R1 + R4) B = V1 * R1 / (R1 + R4) Note that this system is underconstrained as there are 3 unknowns and only 2 equations. The extra degree of freedom can be expressed as the final output impedance of Vout, which is R1//R4. You have enough here to write all the equations and solve them. That's no longer electronics but grade school arithmetic, so that's your job. Instead I'll take a less exact but more intuitive hack at it here. Let's say you want the output impedance to not exceed 10 kΩ. We know the attenuation will be high, so R1 will be significantly larger than R4. For simplicity, let's simply make R4 = 10 kΩ. That will make the output impedance a little less than 10 kΩ. You have a 500V input range and want a 5V output range, so the divider gain should be 1/100. Again to make things simple, we'll just make R1 = 100*R4 = 1MΩ. That actually results in a gain of 1/101, but a little margin is a good idea and you'd have to get 1% resistors as it is to guarantee the gain isn't more than 1/100. So far we have: R1 = 1 MΩ R4 = 10 kΩ At this high attenuation ratio, B pretty much equals V1, so let's just make V1 = 2.5V. Now we still need to get R2 and R3 from R4. From the values above, each should be 20 kΩ. However, we're making some approximations and it's good to allow for a little slop anyway, so I'd start with the next lower common value of 18 kΩ. Now you need to plug all that in and compute the output voltage at the peaks of the input voltage, taking into account inaccuracies in the resistors. I'll leave that as a exercise to you, but the values above are either good enough or pretty close for a starting point.
0.777778
Adding a resistor divider to your schematic
How to update an SQL column using a known perm link while appending a value from another column within the same table?
Larger view of the issue is here: http://i1268.photobucket.com/albums/jj572/LinuxOwner/question.png
Seems like all you want is something like? UPDATE banned SET evidence = 'http://path-to-something/'||name ;
0.888889
UPDATE banned SET evidence = 'http://path-to-something'
Creating a Bridged Network Connection in Terminal
Okay, I'm struggling a bit here. I'm not all that good with Terminal and sorting out network issues using it but I've managed to scrape by so far. Without using Internet Sharing (because controlling that via Terminal as per my question here doesn't actually seem to work in Yosemite) how can I share my internet connection from one interface (lets say en0) to another (again, lets say en1)? I kind of understand that Internet Sharing creates a bridge (usually called bridge100) and then uses bootpd (I think) to establish a DHCP server and NAT to route all traffic from 192.168.2.xxx (which is the bridged network) through to your primary network. How can I get the same result without using the Sharing pref pane?
Here is an interesting solution to share internet with a layer-2 bridge but without using NAT/DHCP (not required)/Internet Sharing Pref Panel at all: Create a shell script ethernet-bridge.sh in /usr/local/sbin with the following content: #! /bin/sh # ###################################### # coded by Nat! # 2013 Mulle kybernetiK # GPL command=${1:-start} shift proxyarp=${1:-no} shift start() { sysctl -w net.inet.ip.forwarding=1 sysctl -w net.inet.ip.fw.enable=1 if [ "$proxyarp" != "no" ] then sysctl -w net.link.ether.inet.proxyall=1 fi ifconfig bridge0 create ifconfig bridge0 addm en0 ifconfig bridge0 addm en1 ifconfig bridge0 up if [ $? -eq 0 ] then syslog -s "Ethernet Bridge is up" else syslog -s "Ethernet Bridge failure" fi } stop() { ifconfig bridge0 destroy sysctl -w net.inet.ip.forwarding=0 sysctl -w net.inet.ip.fw.enable=0 sysctl -w net.link.ether.inet.proxyall=0 syslog -s "Ethernet Bridge is down" } case "$command" in start*) start ;; stop*) stop ;; esac and make it executable: chmod 755 /usr/local/sbin/ethernet-bridge.sh Then put the following XML into /Library/LaunchDaemons as com.ethernet-bridge.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.ethernet-bridge.plist</string> <key>ProgramArguments</key> <array> <string>/usr/local/sbin/ethernet-bridge.sh</string> </array> <key>UserName</key> <string>root</string> <key>GroupName</key> <string>wheel</string> <key>RunAtLoad</key> <true/> <key>LaunchOnlyOnce</key> <true/> </dict> </plist> Then modify the file and load it: sudo chmod 644 /Library/LaunchDaemons/com.ethernet-bridge.plist sudo chown root:wheel /Library/LaunchDaemons/com.ethernet-bridge.plist sudo launchctl load /Library/LaunchDaemons/com.ethernet-bridge.plist The plist will enable the bridge mode while booting. Check with ifconfig -a if the bridge is visible. To stop the bridge mode just enter: sudo /usr/local/sbin/ethernet-bridge.sh stop To restart the bridge mode just enter: sudo /usr/local/sbin/ethernet-bridge.sh start Now set up the clients with a fixed IP/netmask/Gateway (the internal IP-address of the briding machine)/DNS or properly set up a DHCP server on the bridging machine. Additionally you have to set up a static route on your router to the network you provide Internet Sharing to (in your example (en1)). Until now the syslog messages don't work - I'll try to improve the script pertinently. A similar approach is outlined here, but I didn't get it to work in Yosemite
0.888889
Create a shell script ethernet-bridge.sh with NAT/DHCP (not required)/Internet Sharing Pref Panel
How to generate 4 unique digit each time form 1 to 12
i want to generate 4 unique digit each time from 1 to 12. For example: [1,3,4,6] or [1,3,10,6] or [1,2,3,4]... but not like [1,2,8,1] or [2,2,4,5] because in last two chunk 1 comes twice and so as 2 in second chunk. Again i need to generate those unique chunk of numbers randomly. Any help will be appreciated. Big thanks in advance...:)
In javascript random: function (min,max,l){ var arr = [],m = [],n = 0; if (max - min < l-1) return; for (var i=0; i<=(max-min); i++)m[i] = i + min; for (var i=0; i<l; i++) {n = Math.floor(Math.random()*(m.length)); arr[i]=m.splice(n,1);}; return arr; }
0.888889
javascript random: function
What is the best place to start Warhammer 40k?
I've got three omnibus books containing 9 total Warhammer 40,000 stories. Before I mention which ones I've got, which book would you recommend as a good place to start the series?
Just wanted to add that it's been suggested to start with the short story collection Let the Galaxy Burn as an introduction to the WH40k universe, and then follow your interests from there. I personally started with LtGB, then read Blood Ravens: The Dawn of War Omnibus, then from there on to Imperial Guard and Ultramarines novels. I did find it necessary at times to search online for background info that I was missing (e.g. the history and culture of the Eldar).
1
Short story collection Let the Galaxy Burn
How to efficiently delete elements from vector c++
I have a vector of pair of vectors(V1,V2) called pairV1V2 of the following form: (1,2,3),(938,462,4837) -> (V1,V2) (3,9,13),(938,0472,944) (81,84,93),(938,84,845) Then I need to retain the following: (1,2,3),(938,462,4837) -> (V1,V2) (3,9,13),(938,0472,944) (81,84,93),(84,845) I need to start scanning pairV1V2 from the beginning and where ever any two V1's are not equal, there I need to delete the intersecting elements from V2. I wrote the following code for doing same. However, my code turns out to be very inefficient as my vector pairV1V2 is big and it has many elements in V2 (about a billion). int main(int argc, char** argv) { std::vector<std::pair<std::vector<unsigned>, std::vector<unsigned> > > pairV1V2; std::vector<std::pair <std::vector<unsigned>,std::vector<unsigned> > >::iterator itm2,lm2=pairV1V2.end(); for(std::vector<std::pair <std::vector<unsigned>,std::vector<unsigned> > >::iterator itm=pairV1V2.begin(), lm=pairV1V2.end(); itm!=lm; ++itm) { //Outer values vector<unsigned> outerV1=(*itm).first; vector<unsigned> outerV2=(*itm).second; sort(outerV2.begin(), outerV2.end()); itm2=itm; itm2++; for(itm2;itm2!=lm2;++itm2) { vector<unsigned> innerV1=(*itm2).first; vector<unsigned> innerV2=(*itm2).second; vector<unsigned> setDiffV1; std::set_difference(innerV1.begin(), innerV1.end(), outerV1.begin(), outerV1.end(), std::inserter(setDiffV1, setDiffV1.end())); if(setDiffV1.size()==0) //check whether any two V1's are different { sort(innerV2.begin(), innerV2.end()); if((itm->second.size()!=0)&&(itm2->second.size()!=0)){ std::vector<unsigned> delIntersectingElem; std::set_intersection(outerV2.begin(),outerV2.end(),innerV2.begin(), innerV2.end(), std::back_inserter(delIntersectingElem)); if(delIntersectingElem.size()!=0) //if there are intersecting V2's { for(std::vector<unsigned>::iterator its=(itm2->second).begin(),ls=(itm2->second).end();its!=ls;) { //if *its is present in delIntersectingElem then delete it. if(!(std::find(delIntersectingElem.begin(), delIntersectingElem.end(), (*its)) == delIntersectingElem.end())) { (itm2->second).erase(its); //delete intersecting elements from inner v2 ls--; }else{ ++its; } } } } } } } return 0; } Can someone please help me in improving my present code -- it gives the correct answer (In the example I might have missed a few case for brevity-- but the code handles all of them) but is extremely slow (as diagonalised by perf). I'll be grateful if improvements are suggestion in my present piece of code. However, if the logic of the two codes are same, then a new algorithm is also acceptable
There's an underused STL algorithm called remove_if that allows you to efficiently (O(n)) remove all elements matching a predicate from a container. It is most useful if you have a vector or deque, because they have an expensive (O(n)) erase operation for an element "in the middle". However, you need to be aware that remove_if doesn't actually erase any element, it only moves all elements that do not match the predicate to the front of the range you specified. The canonical way to do an "erase_if" is therefore (in this example, all odd integers will be erased): std::vector ints = …; ints.erase(std::remove_if(begin(ints), end(ints), [](int i) { return i%2 != 0; }), end(ints)); Explanation: remove_if moves all ints not matching the predicate (i.e. the even ints in this example) to the front and returns an iterator one past the last of these elements. Then, we actually erase all elements starting with this one to the end of the vector using the range overload of vector<int>::erase. E.g., assume we have ints == {5,7,4,10,9,16,20,6}. remove_if will turn ints into {4,10,16,20,6,UNSPEC,UNSPEC,UNSPEC} where I used UNSPEC to denote any unspecified value, and it will also return an iterator pointing to the first UNSPEC element. Then, we erase all the elements with unspecified value and get {4,10,16,20,6}, the desired result. UPDATE: With respect to the previous answer, I want to point out that remove_if is stable, i.e. it will not change the order of the remaining elements.
0.888889
Remove_if removes all elements matching a predicate from a container
Should I turn the text on my poster to outlines before I print?
What would be the best practice for printing text based work from Illustrator, such as a poster? This is aimed at the final print quality of my workk. I am creating an advertisement which will be about A4 size to go into a newspaper. Would it be best to Create Outline all the text in the advert before I send the files off to be printed or will it not make much of a difference in terms of quality?
Customarily, you'd send a PDF/X-1a file with fonts embedded by simply saving that format (with crops and bleed), therefore outlining type would actually not always be a good thing. PDF/X-1a is often preferred because it is a self-contained format with fonts embedded and artwork flattened. This ensures the most accurate preproduction. If you are sending a .eps or .ai file, then outlining type is the best practice.
0.777778
Customarily, you'd send a PDF/X-1a file with fonts embedded .
No value for $TERM and no -T specified
I recently upgraded (with apt-get dist-upgrade) my Kubuntu and Lubuntu Linux boxes, and now every time I log into one of these machines, I get this message: tput: No value for $TERM and no -T specified Here is a screenshot of the exact message: This happened on both my Lubuntu machine and Kubuntu machine, and it wasn't a problem until after I upgraded; so I suspect that it was not user error. How can I fix this? UPDATE I have tracked this down to my .bashrc file, which is getting called by my .profile file. Though, the fact that my .bashrc file now runs when I do a GUI login whereas it didn't before I upgraded is a bit weird. And no, I haven't modified my .bashrc file or my .profile recently. Also, bash isn't my default shell. The problem is that I am calling tput in my .bashrc file to set up variables for use in adding color to the prompt. But at the (inappropriate) time when my .bashrc file now gets run, $TERM is not set. fgRed=$(tput setaf 1) ; fgGreen=$(tput setaf 2) ; fgBlue=$(tput setaf 4) fgMagenta=$(tput setaf 5) ; fgYellow=$(tput setaf 3) ; fgCyan=$(tput setaf 6) fgWhite=$(tput setaf 7) ; fgBlack=$(tput setaf 0) bgRed=$(tput setab 1) ; bgGreen=$(tput setab 2) ; bgBlue=$(tput setab 4) bgMagenta=$(tput setab 5) ; bgYellow=$(tput setab 3) ; bgCyan=$(tput setab 6) bgWhite=$(tput setab 7) ; bgBlack=$(tput setab 0) Updated question: How should I fix this? Should I set $TERM myself? Or should I just not set these variables if $TERM is not set? UPDATE 2 One solution I tried was to check whether $TERM was set. But this didn't seem to work; I still got the same error message. Here's the code: if [ ! "$TERM" = "" ]; then #Do stuff here fi So apparently $TERM was set, but tput still concluded it wasn't.
The error dialog is due to the fix of bug #678421, so it's my fault. ;) It tells you about errors due to some command(s) in one of your configuration files. If you scroll to the top, you can see which file is causing the error messages. Possibly Serg's answer is sufficient to get rid of the warning dialog. Edit: Would like to add a couple of things due to the updated question. Unlike before, /usr/sbin/lightdm-session is now run under bash (previously sh). That's why its sourcing of ~/.profile results in ~/.profile sourcing ~/.bashrc. Possibly this means that the default contents of ~/.profile ought to be changed. The easiest thing you can do to fix it is, as you suggested, to only call tput if $TERM is set.
0.888889
The error dialog is due to the fix of bug #678421 .
Adding Data to Multiple Tables Using Single Query
I want to add data to multiple tables using a single INSERT INTO query, can I do this? Please guide me and provide me syntax if this is possible.
This is not possible. The INSERT statement takes a single destination object as per the syntax (BOL reference): [ WITH <common_table_expression> [ ,...n ] ] INSERT { [ TOP ( expression ) [ PERCENT ] ] [ INTO ] { <object> | rowset_function_limited [ WITH ( <Table_Hint_Limited> [ ...n ] ) ] } { [ ( column_list ) ] [ <OUTPUT Clause> ] { VALUES ( { DEFAULT | NULL | expression } [ ,...n ] ) [ ,...n ] | derived_table | execute_statement | <dml_table_source> | DEFAULT VALUES } } } [;] Take note of the <object> placeholder on the 6th line of the syntax snippet. Is there a particular reason why you want to insert into two tables in one statement? Perhaps you are looking for both inserts to either succeed or fail as one? In that case, you would be looking at explicit transactions: begin tran; insert into dbo.YourTable1 ... insert into dbo.YourTable2 ... commit tran; Besides code brevity and atomicity, I wouldn't see any other reason that you'd want to combine multiple destination tables into a single INSERT statement.
1
Is there a particular reason why you want to insert into two tables in one statement?
How do I build lengthwise multi-platform stations?
In OpenTTD, it's possible to build multi-platform train stations side-by-side (pictured below as Parnpool Mines), and they would work as expected, allowing two trains to load/unload at that station at the same time. However, sometimes due to space constraints it would be more desirable to to build the two platforms lengthwise as shown below in Parnpool West. The signal-station combination pictured below, however, does not work, and I have not found one that does.
There isn't any solution that I can see after puzzling over the image for a while. The only ones that would work would be splitting them by two tiles instead of just one and using a bypass track to get around it, but that would mean you're going up to 2 tiles of width anyway, rendering the issue moot. The only workable idea that I can come up with is to set them as two different stations and use the "Non-stop" flag for the two different trains (train A to get it to ignore the first station, train B to get it to ignore the second station) but then if your trains happen to get out-of-order you're pretty much up crap creek. I guess the only real answer is that there is no answer.
1
Using a bypass track to get around the image isn't working .
Concise vector adding in Python?
I often do vector addition of Python lists. Example: I have two lists like these: a = [0.0, 1.0, 2.0] b = [3.0, 4.0, 5.0] I now want to add b to a to get the result a = [3.0, 5.0, 7.0]. Usually I end up doing like this: a[0] += b[0] a[1] += b[1] a[2] += b[2] Is there some efficient, standard way to do this with less typing? UPDATE: It can be assumed that the lists are of length 3 and contain floats.
list(map(lambda x:x[0]+x[1], zip(a,b)))
0.888889
list(map(lambda x:x[0]+x[1], zip(a,b))
Highcharts - Cannot set x-axes categories in column charts with negative values
Hi I have a column chart with negative values which is showing wrong x-axes categories value. I'm sending a pre-build JSON array from the server , but no matter what i can't get the x-axes categories to show the right values. Here is the code : var chart_data = JSON.parse(data).avg_range; console.log(chart_data.x_axes); var safety_chart_average = { chart: { type: 'column', renderTo: pattern + '-safety-mini-chart-section', spacingRight: 20, spacingLeft: 20, }, rangeSelector: { enabled: false }, navigator: { enabled: false }, scrollbar: { enabled: false }, credits: { enabled: false }, title: { text: "Avg Changes", marginBottom: -10 }, xAxis: { categories: chart_data.x_axes }, series: chart_data.prices }; This is what i'm getting The x-axes is showing wrong values, as you can see from the picture above. But console.log(chart_data.x_axes) gives ["Day 1", "Day 2", "Day 3"] which should be the correct x-axes label. Please let me know how can i fix this x-axes label error.
Highstock is containing all of Highcharts options. All you need is to change constructor. So in steps: include Highstock: <script scr="http://code.highcharts.com/stock/highstock.js"></script> when you need Highstock, call: new Highcharts.StockChart(options) when you need Highcharts, call: new Highcharts.Chart(options)
0.888889
Highstock is containing all of Highcharts options
Can a Floating Action Button morph be reverted?
There are two specific examples in the Android Floating Action Button guidelines that explain how the button can morph into either new buttons, or a toolbar. If the hallmark of the app is adding file types, a floating action button can morph into related actions after it is first touched. If a floating action button morphs into a toolbar, that toolbar should contain related actions. In this example, the button lets the user select the media type to add. After the button has morphed, how does the user revert back to the previous single button mode? As I understand it, the rest of the UI is not blocked after these buttons have morphed, so it's not clear how the user can hide the new buttons or revert the morphed shape if they decide not to go through with the new action. Update This is more commentary than anything else: I just took a look at Drive to find implementation examples and found an Bottom sheet instead of a FAB morph.
While the guidelines don't state anything about reverting the state of a Floating Action Menu triggered by a Floating Action Button, two patterns have become prominent in this use case, and rightly so: The Floating Action Menu in Inbox fades in a translucent white overlay over the rest of the content, drawing focus towards the menu. While the rest of the UI is not blocked, the overlay portrays it and disabled or unusable when the Floating Action Menu is in focus, a tap anywhere outside the menu causing it to lose focus and thus revert its state. This pattern has also been adopted by apps like Evernote and Cabinet The second pattern involves the Floating Action Button staying on as one of the items in the Floating Action Menu, changing its form to match that of a close button, portraying the close action concisely while not blocking the UI. Here's an excellent Gist and Gif of this implementation.
0.888889
The Floating Action Menu in Inbox fades in a translucent white overlay over the rest of the content, drawing focus towards the menu
Is it okay to vacuum a laptop keyboard?
Is it okay to vacuum a laptop keyboard? Would it cause any damage?
You can use vacuum cleaner, but make sure your laptop's keyboard doesn't have "pop off" keys that could possibly be sucked up by the vacuum. A can of compressed air will safely blow dust right out of the little crevices between your keys. You may want to read this article from LifeHacker.
1
Vacuum cleaner on your laptop's keyboard
Javascript pass onclick on child to parent
I have div (.upload-drop-zone, yellow zone at screenshot) with another div (.dropzone-width, blue zone) inside. <div class="upload-drop-zone dz-clickable" id="drop-zone-600"> <div class="dropzone-width">600 PX</div> </div> There is a javascript onclick event attached to .upload-drop-zone (when I click on it, it shows file chooser dialog). Event attached by third-party plugin, so I have no access to function which be called. The problem is that if I make click on .dropzone-width, click event did not pass to .upload-drop-zone so nothing happens instead of showing file chooser dialog. What can I do to fix it? P.S.: Sorry for bad english.
Try this via jquery: $(".dropzone-width").on("click", function(){ $("#drop-zone-600").trigger("click"); });
0.777778
Try using jquery: $("dropzone-width").
Why is the limit of this root the absolute value
Define $$ h_n (x) = x^{1 + {1 \over 2n - 1}}$$ for $x \in [-1,1]$. Why is $\lim_{n \to \infty} h_n(x) = |x|$? I know that for $C > 0$ it holds that $$ \lim_{n \to \infty} C^{1\over n} = 1$$ but I don't know why the other limit should hold. Especially not $$ \lim_{n \to \infty} C^{1\over n} = -1$$ if $C < 0$.
One can use the convention that $x^{p/q}$ ($p$ and $q$ integers, $q\ne0$) is well defined for any $x$ if the denominator $q$ is odd. Since $$ 1+\frac{1}{2n-1}=\frac{2n}{2n-1} $$ and $n$ is assumed to be a positive integer, we are in that situation. Moreover, the numerator is even and so $$ x^{2n/(2n-1)}=|x|^{2n/(2n-1)}. $$ Since $$ \lim_{n\to\infty}\frac{2n}{2n-1}=1 $$ you're done, because, for $a>0$, the function $t\mapsto a^t$ (defined for any real $t$) is continuous.
1
$xp/q$ is well defined for any $x$ if the numerator $q$ is odd
How many creatures should be in a draft deck?
How many creatures should the average, typical draft deck contain? Obviously this depends on a multitude of factors, including the kinds of creatures in your deck, the kinds of non-creatures you have available, and the overall composition of the block you're drafting. Nonetheless, what's a good baseline for the number of creatures in a draft deck? And how should I decide if I need to run more or fewer creatures than the baseline?
Creatures are what makes you win and what makes you lose games in Limited. Therefore I would consider the baseline types of spells for Limited not only creatures, but creatures + creature removals. Creatures with evasion are powerful in Limited, so sometimes the only solution to a sticky situation is a targeted removal. So, assuming a 23-17 distribution, you want a total of 23 creatures and creature removals as the baseline. Then you start replacing your worst creatures with, in this order: Non-creature bombs (such as equipments, token generators), Direct Damage (might already count as removal depending on card and environment) and finally, if you still have room, a little utility, such as mana fixing/acceleration, card drawing/searching, graveyard recycling, or cheap cantrips for thinning the deck. You probably shouldn't go below ca. 15 creatures + removals in most cases. There is nothing worse than sitting on a hand and battlefield full of utility and equipments and getting beaten to death by a 2/2.
0.666667
Creatures with evasion are powerful in Limited
How do I force a tight globe-valve water shutoff to fully close?
I tried to close off the water valve (a multi-twist globe-valve) leading to my back-yard water supply (the shutoff valve is inside the house) but it will not twist fully shut. Is it safe to give the screw a shot of WD-40 to loosen up the valve? Will that help? Note: the valve is not leaking so I don't want to replace it. I am just trying to shut off the water supply for the winter.
I agree with the spirit of Fiasco Labs' answer. But the truth is that if a valve is almost off (just a few drips) then careful "snugging" via a pair of channel-locks is the first thing your plumber would try. And it'll work... 61.4 percent of the time. Ok, it's not that scientific. But in my experience it'll work slightly more often than not. But if a good snugging doesn't help, then give up. Don't go for herculean twisting. That's when you make a bad situation worse.
0.888889
If a valve is almost off then careful "snugging" via a pair of channel-locks is the first thing your
What's the highest number of countries whose borders meet at a single point?
What is the maximum number of countries meeting at a single point on earth? Where is it? What are the countries?
I'm not sure how subterranean borders work, but if a country includes the land underground, then every border of every country meets at a point a the center of the Earth.
1
Subterranean borders work if a country includes the land underground .
Prove $[A,B^n] = nB^{n-1}[A,B]$
I am trying to show that $[A,B^n] = nB^{n-1}[A,B]$ where A and B are two Hermitian operators that commute with their commutator. However, I am running into a little problem and would like a hint of how to proceed. If A and B commute then $[A,B] = ABA^{-1}B^{-1} = e$ where e is the identity element of the group. $$\therefore AB=BA$$ $$n=1; [A,B^1] = (1)B^0[A,B] = e$$ This statement is certainly true. however moving on to $n = 2$ I find... $$[A,B^2] = AB^2A^{-1}B^{-2} = ABBA^{-1}B^{-1}B^{-1} = BBAA^{-1}B^{-1}B^{-1}$$ Where in the last step I have used the fact that A and B commute to rearange the terms. However, it is plain to see that this last term simply reduces to the identity as well and for the n = 2 case we have: $$[A,B^2] = e \ne 2B[A,B] = 2Be = 2B$$ Clearly I have assumed something I shouldn't have. The fact that there is a multiplicative factor of n implies I should be adding things, but I thought if I kept it as general as possible, the answer should just fall out naturally. I don't want an answer please, only guidance.
It seems that the question (v1) is caused by the fact that there are two different notions of the commutator: One for group theory: $$\tag{1} [A,B] ~:=~ ABA^{-1}B^{-1}$$ (or sometimes $[A,B] := A^{-1}B^{-1}AB$, depending on convention), which is relatively seldom used in physics. One for rings/associative algebras: $$\tag{2} [A,B]:=AB-BA,$$ which is the definition usually used in physics. (This latter definition (2) generalizes to a supercommutator in superalgebras.) The identity $$\tag{*} [A,B^n] ~=~ nB^{n-1}[A,B]$$ holds in the latter sense (2), if $[[A,B],B]=0$. (It is not necessary to demand $[A,[A,B]]=0$.) More generally, for a sufficiently well-behaved function $f$, we have $$\tag{**} [A,f(B)] ~=~ f^{\prime}(B)[A,B], $$ if $[[A,B],B]=0$. The group commutator (1) is dimensionless, which (among other things) makes the identity (*) unnatural to demand for group commutators.
0.666667
The commutator is dimensionless, which makes the identity (*) unnatural to demand for groups
How can I get a PieChart to be colored as I wish?
How to use the value of a funtion[label] to assign color to a piece of the pie? (edited after answer of kguler ) My dude is how to control the colors in ranges of a function of [labels] In this way I can show: 1.- the percentage of Data(labels), using pieces of pie and 2.- the value f of labels, with range colors (similar to TemperatureMap but customized) ------ Original Post ------ I want to use a "gradient" or "a reduce (5-6) list of colors"(similar to DarkRainbow with a little colors)? I was trying with ColorData and ColorDataFunction ( here you can see that I obtain errors with the same code as the reference doc ) but I have no succes!! percent = {12, 18, 24, 46} labels = {1, 9, 15, 22} f = {8, 7, 1, 4} PieChart[percent, ChartLabels -> labels, ImageSize -> 200, PlotLabel -> "Test-Grad", ChartStyle -> ColorData["TemperatureMap" {0, 8}]] PieChart[percent, ChartLabels -> labels, ImageSize -> 200, PlotLabel -> "Test-Comic", ChartStyle -> ColorData[9, "ColorList"]] In the image you can see any more about explanation:
E.g.: PieChart[{10, 20, 40}, ChartLabels -> {"Blah", "blah", "blahhh"}, ImageSize -> 200, PlotLabel -> "Test-Grad", ColorFunction -> ColorData["DarkRainbow"]] Note there is no color scheme called "gradient" - there is a class of schemes called gradients, you can use ColorData["Gradients"] to see the particular named schemes. If you want more control over colors assigned, point ColorFunction to your own function that does whatever is needed to the data and returns the appropriate color(s).
0.888889
ColorFunction - ColorData
Is "my going" correct, or should I use something else?
I want to say; If I go there, there will be a problem. Is it possible to say is as below; My going there will create a problem. Feel free to provide different examples. Thanks.
Yeah, that's be fine to say! You could also use: By going there, I'll create a problem. In going there, I'll create a problem. Sorry that this answer couldn't be more substantial, but yours worked just fine!
0.888889
How to create a problem in going there?
Using regular expressions to find img tags without an alt attribute
I am going through a large website (1600+ pages) to make it pass Priority 1 W3C WAI. As a result, things like image tags need to have alt attributes. What would be the regular expression for finding img tags without alt attributes? If possible, with a wee explanation so I can use to find other issues. I am in an office with Visual Web Developer 2008. The Edit >> Find dialogue can use regular expressions.
This is really tricky, because regular expressions are mostly about matching something that is there. With look-around trickery, you can do things like 'find A that is not preceded/followed by B', etc. But I think the most pragmatic solution for you wouldn't be that. My proposal relies a little bit on your existing code not doing too crazy things, and you might have to fine-tune it, but I think it's a good shot, if you really want to use a RegEx-search for your problem. So what I suggest would be to find all img tags, that can (but don't need to) have all valid attributes for an img-element. Whether that is an approach you can work with is for you to decide. Proposal: /<img\s*((src|align|border|height|hspace|ismap|longdesc|usemap|vspace|width|class|dir|lang|style|title|id)="[^"]"\s*)*\s*\/?>/ The current limitations are: It expects your attribute values to be delimited by double quotes, It doesn't take into account possible inline on*Event attributes, It doesn't find img elements with 'illegal' attributes.
0.888889
Using RegEx-search to find img tags
Jquery dropdown with image doesn't show
I am using the http://www.marghoobsuleman.com/blog/jquery-image-dropdown and it have no problem showing the dropdown but when I included the dropdown to a hidden div (which will add back later) the dropdown doesn't work properly. when you can click on "Please choose color" it have no problem showing, but when you "add more image" and click on another "Please choose color", the dropdown can't drop down. Please let me know what have I done wrong? <!doctype html> <head> <link rel="stylesheet" href="dd.css" /> <script src="jquery-1.7.1.min.js"></script> <script src="jquery.dd.min.js"></script> <script> $(document).ready(function(){ $(".colormenu").msDropDown(); var spotMax = 4; if($('.spot').size() >= spotMax) { $(obj).hide(); } $("#add").click(function(){ addSpot(this, spotMax); }); }); function addSpot(obj, sm) { var num = eval($('.spot').size()) + 1; var upload_area = $('#upload_area').html(); $('#spots').append('<div class="spot">'+upload_area+'</div>').find(".remove").click(function(){ $(this).parent().remove(); $('#add').show(); }); if($('.spot').size() >= sm) { $(obj).hide(); } } </script> </head> <body> <div id="spots"> <div> <input type="file" name="pic[]" /> <select name="color_id[]" class="colormenu" width="150" style="width:150px" > <option value="0">Please choose color</option> <option value="14" data-image="/img/color-code/14.jpg">Gold</option> <option value="15" data-image="/img/color-code/15.jpg">Beige</option> <option value="138" data-image="/img/color-code/138.jpg">Rose Gold</option> </select> </div> <div id="upload_area" style="display:none;"> <div style="height:8px;"> </div> <input type="file" name="pic[]" /> <select name="color_id[]" class="colormenu" width="150" style="width:150px"> <option value="0">Please choose color</option> <option value="14" data-image="/img/color-code/14.jpg">Gold</option> <option value="15" data-image="/img/color-code/15.jpg">Beige</option> </select> <a style="cursor:pointer;" class="remove">Remove this image</a> </div> <input type="button" name="add" id="add" value="Add more Image" /> </div>
Try add the msdropdown only on visible elements; then when you show items attach the plugin again. Code: $(document).ready(function () { $(".colormenu:visible").msDropDown(); var spotMax = 4; if ($('.spot').size() >= spotMax) { $(obj).hide(); } $("#add").click(function () { addSpot(this, spotMax); }); }); function addSpot(obj, sm) { var num = eval($('.spot').size()) + 1; var upload_area = $('#upload_area').html(); $('#spots').append('<div class="spot">' + upload_area + '</div>').find(".remove").click(function () { $(this).parent().remove(); $('#add').show(); }); if ($('.spot').size() >= sm) { $(obj).hide(); } $(".colormenu:visible").msDropDown(); } Demo: http://jsfiddle.net/Lz3aW/
0.833333
Add msdropdown only on visible elements
Result about Lebesgue measurable subset of $\mathbb{R}^2$ and horizontal/vertical slices
I am studying for my qualifying exam in Real Analysis (Measure Theory) and am stuck on the following practice problem: Let $E$ be a Lebesgue measurable subset of $\mathbb{R}^2$. Suppose that for every $x \in \mathbb{R}$, the vertical slice $E_x = \{ y \in \mathbb{R} : (x,y) \in E \}$ has positive Lebesgue measure. Prove that there is a subset $A$ of $\mathbb{R}$ of positive Lebesgue measure such that for all $y \in A$, the horizontal slice $E^y = \{ x \in \mathbb{R} : (x,y) \in E \}$ is uncountable. I first tried going about it by contradiction, but couldn't get that to work. Then I tried letting $A = \bigcup E_x$, but that didn't get me anywhere either. Any help is greatly appreciated!
Hint: Fubini's theorem applied to the indicator function of $E$.
0.888889
Fubini's theorem applied to the indicator function of $E$
Cross-Correlation to find the similartity of songs
I have been working on a problem where I am given two songs which are of the same category but there is a time difference between them. Eg. one song starts at x sec and other song starts at y sec. So my task is to find the x and y. The length of the two songs can vary but the content of the two songs will remain the same. Currently I am using cross-correlation using FFT for finding the offset between them but it is not giving me correct results. For making the length of signals same I am zero padding the signal which is shorter in length. Can someone guide me what I am doing wrong in this problem ? I really appreciate your responses. Thanks -- Thanks guys for replying.. I am doing in Python and using below algorithm for finding the offset: 1. Using librosa.load function to get the audio signals of both the songs. 2. Then I zero pad the shorter signal from last and make sure it is power of 2. 3. Find the FFT of the two signals using scipy library function of python.(spipy.fftpack.fft) 4. Once I get the fft , I take the cojugate of one of the signals. 5. Elementwise multiplication of the two fft signals 6. Doing ifft of the numpy array of the output signals after multiplication. 7. Finding the peak index of that array. P.S. The song length can be around 5-6 mins so I am sampling at the rate of 44.1Khz . So you can expect very large sample space. Also , the bitrate of the two songs can be different.(I am not sure that will effect it or not) Any idea if I am doing wrong? thanks
First of all, apply a normalized cross correlation, which is more robust to certain variations. MATLAB's xcorr function has an option to do that. Next, apply it in a sliding window fashion, where you apply the correlation as a running filter. Then, simply select the maximum peak.
0.888889
Apply a normalized cross correlation
To access button from another class which is in another page
My goal is to access the button and make the visibility to false from another class in vb.net Dim obj = New MyClass() obj.btnName.Visible = False But it is throwing error as "Object reference not set to an Instance"
Try to debug to see if your button has been initialized the time you access it, and i think it is not. This is probably your are using this button before the form or the page has been loaded. Since instantiating the button will happen in the initialization portion of your code. Try to initialize you class in protected void Page_Load(object sender, EventArgs e) { dim obj = new Myclass(); } and inside the New function in 'MyClass' class make sure your are initializing all the stuff you want to use.
0.333333
Initialize your button before the form or the page is loaded
What feats should a human rogue take to be stealthy?
I am helping a player to make a level 1 human trickster rogue in D&D 4e, but we cannot decide on a good feat. He is looking to be good at stealth both in and out of combat as well have good melee ability (planning on using a long dagger). What would be a good feat to take in order to get him to that point? A quick overview of the rest of the party: dragonborn warlord dwarf druid half-elf ranger human sorcerer the human rogue in question
The resource you need is Han Shot First: the Scoundrel's Guide. It's a handbook discussing all of the rogue build options. Also, the rules of hidden club are required reading. Mr Cellophane has stealth specific build options. With that said, a focus on stealth is commendable, though unnecessary. Before we discuss increasing stealth, make sure the rogue has the cunning stalker feat. That gives him CA when he's alone. When he's not alone, he can be flanking with the warlord, druid, or ranger. You'll want to see if anyone is interested in the teamwork benefits (particularly the druid) from silent shadows as well as the set of items in Mr. Cellophane. At level 1, this is tricky, but as he gets magic items, shadowflow armor is notable. He should buy footpads and camoflauged clothes with his starting money as non-magical stealth boosting options. Make sure he takes an appropriate background (Silent Hunter) and theme (Dead Rat Deserter, as being able to be tiny is amazing when sneaking) , especially as he won't be using a rapier.
0.888889
Han Shot First: the Scoundrel's Guide
Two different analytic curves cannot intersect in infinitely many points
A curve in Euclidean space $\mathbb{R}^n$, $n \geq 2$ is $analytic$ if the coordinates of its points $x= x_{1},...,x_{n}$ can be expressed as analytic functions of a real parameter $x_{i}=x_{i}(t)$, $i=1,...,n$ and $\alpha \leq t \leq \beta$ and the derivatives $x'(t_{0})$ do not simultaneously vanish for any $t_{0} \in [\alpha, \beta]$. I search for a proof of the following fact: If the set of intersection points of two analytic curves is infinite, then these curves coincide. Can we prove the same as above if we relax the condition that the coordinates are analytic to the condition that the coordinates belong to the class $C^{\infty}$? Edit: Thanks to below remark by Ramiro, to obtain the above implication, we have to assume that any two curves $K_{1}, K_{2}$ as in the question are such that $K_{1} \cap K_{2}$ is not another analytic curve. 2nd edit: As suggested Peter, we can reformulate our question as follows: Consider two immersed curves which are parameterized real analytically on compact intervals. If they have an infinite number of different intersection points, then their union is again a real analytic immersed curve.
What about $t \mapsto (t,t)$ and $t \mapsto (t+1,t+1)$ for $t \in [0,2]$? They have infinite intersection but do not coincide. On the positive side (following Peter´s answer and Noam´s comment), the set of $t$´s for which there is some $u$ such that $f(t)=g(u)$ is a finite union of points and intervals by the o-minimality of the structure involved.
0.777778
What about $t mapsto (t,t)$ and $t (t+1,t+1)$ for $t
PDF reader that functions within asymmetrical dual monitor configuration
My laptop is 40% of my typical reading surface -- with the other 60% being a larger, desk-bound monitor. Adobe Reader fails to use the entire size of the larger monitor -- cropping the PDF to about 2/3 the potential size. Sumatra PDF Reader avoids this problem, but Sumatra doesn't let me cut and paste from my PDFs. Is there a configuration or a PDF reader that lets me both a) fully enlarge the PDF to fill the larger screen and b) copy text found therein? I'm using the nVidia graphics chipset in the laptop.
Evince works fine here, but I run Linux with an Intel chip.
0.888889
Linux with an Intel chip
Create a block showing the latest of a certain content type
I am very new to drupal, so I already apologize if I ask something very simplistic... I have a site where I would like to add a new block to the front page of the website. This block would show the companies newest available training's. I created the sub-pages of the training's. My thought process was that I create the sub-pages, then create a new type of content (with the cck) where I can add the new sub-page node names and their links. I created the new content type with two fields. field_offeringlink and field_offeringtext. Where the the text would be the actuall promotional text and the link directing to the sub-page. After this I wanted to create a Block that I would place on the front page, showing these two fields. I couldn't figure out this part... So how do I make the bloody block show my fields? OR If you have a better idea for this whole shannanigan then I am welcome to ideas. My goal: Create a dynamic block on the front page, that shows all the latest training's. Under dynamic I mean, that we can add-remove the links from the admin/content menu. Thanks in advance!
This definitely sounds like a job for views. I could explain how to do this exactly BUT for your own learning you should install views and go through the documentation also as you will thank me in the long run for not explaining exactly how to do it. You do not need to do it the way you have started doing it already, Views will manage everything you have already tried to accomplish with listing articles. If you want a shortcut without going through the documentation, click this which will give you a thousand tutorials to do what you want to do.
0.777778
How to install views and go through documentation
Daydream with transparent background
I'm trying to implement a daydream service with a transparent background. I wrote the following code: public void onAttachedToWindow() { super.onAttachedToWindow(); setContentView(R.layout.mydream); getWindow().setBackgroundDrawable(new ColorDrawable(0)); . . . } But when I start up the daydream, the background is only transparent for 1 second. After that it turns to black background. Can anyone help me with this?
Luckily you can access the window of the DreamService. So what you can do in your DreamService class is the following: @Override public void onAttachedToWindow() { super.onAttachedToWindow(); setInteractive(true); setContentView(R.layout.dream_service); getWindow().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00FFFFFF"))); } Make sure your layout of the DreamService has a transparent background ;-)
1
How to access the DreamService window?
Images give 404 after changing default domain
Never encountered this issue before. So I've just moved a site for a client to another server and for some reason all images give me a 404 when I change the default domain in the database (siteurl and home). CSS, JS and other files are linked correctly - it seems there's something affecting the uploads folder but I can't pinpoint what it is. Any ideas?
You must update the URLs in the database. Here is a tool that you can use https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ You can download it, unzip and upload it to your server where you have to replace URLs and then you can run it. It's pretty simple. You have to enter old and new base URLs. You can also perform a dry run, check the changes and then go for live run.
0.888889
You must update URLs in the database
What's the deal with alignment languages?
In early D&D, there was the concept of an "alignment language." The original "little brown book" D&D says only: Law, Chaos and Neutrality also have common languages spoken by each respectively. The Holmes basic rules, which come between "brown book" and Moldvay say: Lawful good, lawful evil, chaotic good, chaotic evil, and neutrality also have common languages spoken by each respectively. One can attempt to communicate through the common tongue, language particular to a creature class, or one of the divisional languages (lawful good, etc.). While not understanding the language, creatures who speak a divisional tongue will recognize a hostile one and attack. Moldvay D&D says: Dungeons & Dragons, Basic Rules, page B11 Alignment Languages Each alignment has a secret language of passwords, hand signals, and other body motions. Player characters and intelligent monsters will always know their alignment languages. They will also recognize when another alignment language is being spoken, but will not understand it. Alignment languages are not written down, nor may they be learned unless a character changes alignment. When this happens, the character forgets the old alignment language and starts using the new one immediately. What? So much of Dungeons and Dragons was very generic "sword and sorcery" fantasy that these rules always stuck out to me as an extremely sore thumb, or like one of those snails that has been infected by a fungus and begins to pulsate in random colors. What the heck is going on here? So, alignment languages show up pretty early in D&D's history. Every intelligent being that is on the side of Law can communicate. Every intelligent being that has no particular feelings about Law can, too. If they experience a profound change in their feelings about this, they can no longer communicate with the people they used to. It isn't clear how much communication is possible in an alignment language, since Moldvay describes it as "passwords, hand signals, and other body motions." In AD&D 1E, though, there is no such limitation: Advanced Dungeons & Dragons, page 34 Character Languages In addition to the common tongue, all intelligent creatures able to converse in speech use special languages particular to their alignment. These alignment languages are: Chaotic Evil, Chaotic Good, Chaotic Neutral, lawful Evil, Lawful Good, Lawful Neutral, Neutral Evil, Neutral Good, and Neutrality. The alignment of your character will dictate which language he or she speaks, for only one alignment dialect can be used by a character (cf. CHARACTER CLASSES, The Assassin). If a character changes alignment, the previously known longuage is no longer able to be spoken by him or her. That cross-reference to the assassin class is there because assassins alone can learn the languages of other alignments. Probably not all of them, though, because now there are nine instead of three. In AD&D 2E, the alignment language seems to have been silently dropped, and never spoken of again as far as I know. When I was ten and played AD&D, the idea of alignment languages struck me as incomprehensible, and today even though I have come to love almost everything about basic and early-Advanced D&D, alignment languages still seem incomprehensible, weird, and unexplained. What I want to know is this: how were (or are) alignment languages put to use, described, and conceived of in actual play ? So far, my use of them has always been "pretend they do not exist." I am curious as to how others view and address them. Also: where did this bizarre idea come from? It smacks of being lifted from some fantasy book, but I can't recall ever reading anything like it.
In general in play they were ignored or just treated as an abstract language with no further comment. As to where they came from, here's an answer from Gary Gygax on Dragonsfoot! As D&D was being quantified and qualified by the publication of the supplemental rules booklets. I decided that Thieves' cant should not be the only secret language. Thus alignment languages come into play, the rational [sic] being they were akin to Hebrew for Jewish and Latin for Roman Catholic persons. I have since regretted the addition, as the non-cleric user would have only a limited vocabulary, and little cound [sic] be conveyed or understoon [sic] by the use of an alignment language between non-clerical users. If the DMs would have restricted the use of alignment languages--done mainly because I insisted on that as I should have--then the concept is vaible [sic]. In my view the secret societies of alignment would be pantheonic, known to the clerics of that belief system and special orders of laity only. The ordinary faithful would know only a few words, more or less for recognition. In other words, it was supposed to be more like religious languages, but wasn't really well thought through. It disappeared in Second Edition and was not missed.
0.833333
In general in play they were ignored or just treated as an abstract language .
does re-encrypting the same value with multiple keys reduce security
I found myself wondering today, how much security is lost if you take a plaintext - assume that its content, including any metadata is unknown to an attacker, for example it may be random data - and encrypt it with multiple keys (not chained) and give all resulting ciphertexts to an attacker, how much higher is the probability of an attacker discovering the plaintext, vs only having a single ciphertext. An example: Take plaintext $P_1$ and encrypt it with $K_1$, and send the resulting ciphertext $C_1$ to attacker $A_1$. In addition: take the same plaintext $P_1$ and, and encrypt it with $K_1$, giving $C_1$. Then take $P_1$ and encrypt it with $K_2$ giving $C_2$, then $K_n$ giving $C_n$ and send all $n$ ciphertexts to attacker $A_2$. How much more likely is attacker $A_2$ to discover the value of $P_1$, than $A_1$?
The "security" of an encryption scheme is commonly defined through a so called indistinguishability games, i.e. the attacker picks two messages of same length. You pick one of those two at random, encrypt it, and give it to the attacker. If the scheme is "secure", then the attacker's advantage of guessing which messages was encrypted should not be negligibly bigger than pure guessing, i.e. 1/2. This kind of security notion comes in different flavours like CPA, CCA1, and CCA2. If a private or public key encryption scheme is secure against CPA, CCA1, or CCA2, then it will also be secure against the same games, where instead of giving two messages, the attacker gives you two message vectors and you encrypted one of them. This is proven with a standard technique called hybrid argument, which basically shows that if you can win a game with vectors of messages, then you can also win it where the attacker only outputs two messages. Very roughly speaking you create a reduction, where your attacker guesses a position in the vector and inputs the challenge from the two message game. The probability of guessing the "correct" position in the vector is non-negligible if your vector is of polynomial length. There are plenty of books (e.g. the one by Katz & Lindell) or online resources that explain this in depth, so I won't reiterate it here. In short: If something is secure w.r.t. to for instance CPA, then it will also be secure if you obtain encrypted message vectors (or as you state where one message is encrypted under multiple different keys). The success-probability might change, but only by a very small (still negligible) amount, so nobody cares, since it's still secure w.r.t to the notion.
0.833333
"security" of an encryption scheme is commonly defined through indistinguishability games .
Why Have The System Builder Market Not Migrated to the BTX Form Factor from ATX yet?
I'm starting to build my first computer from the parts that I have purchased and a question that had been nagging me for the past few weeks was why the ATX form factor is still currently used when there is the newer BTX formfactor.
BTX was an Intel-driven formfactor oriented towards mass market manufacturers. Its primary promise was to reduce the number of system fans to One (Two counting the Power Supply). A single large fan at the back of the system would draw air through the CPU heatsink, and past memory and other components in front of that. It was introduced in 2005/06 when AMD Athlon 64 and x2's reigned in the custom builder performance arena. AMD motherboards could not be easily adapted to the BTX design because it assumed an Intel system architecture and attendant m/b layout. On top of that it offered nothing new for cooling add-in graphics adapters (such as all graphics NOT manufactured by Intel). Since it was primarily a single vendor solution for mass market manufacturers, it was only adopted for some mass produced systems while the ATX home builder and custom builder market continued unabated.
1
BTX was an Intel-driven formfactor oriented towards mass market manufacturers
How to implement Many to many relationship for USERS TABLE in ruby on rails without using any extra table?
I am a newbie to the Ruby on Rails but stuck at this interesting situation : I have three Models with me : User Company Project I want to relate them in the following way : Company has_many Users Users belong_to Company Implemented via company_id column in USERS table User.Company or Company.Users works fine. Project has_and_belongs_to_many Users Users has_and_belongs_to_many Project Implemented via has_and_belongs_to_many relation using in projetcs_users table Project.Users or User.Projects works fine. The real problem comes when I want them to join as following as well : Company belong_to Owners (:through => User) Owner has_one Company ---A company can have multiple owners but one user can own just one company. He can't be owner of multiple companies. ---A user may or may not be owner of a company but always belong to some company. ---A user cannot be part of two companies. Project has_one Project_manager (:through => User) Project_manager belongs_to Projects ---A Project can have just one Project_manager but one can be project manager of multiple projects. I am not able to figure out how the relationship should be defined in the Models. Also what should be the table structure for all three models. My objective is to achieve : Company.Owners It can be done by : @owner = User.find(Company.owner_id) Project.Project_manager It can be done by : @Project_manager = User.find(Project.project_manager_id) But don't want it that way to work !! Rest is working perfectly fine for me.
Here is the final output I am able to achieve : -----Models----- PROJECTS class Project < ActiveRecord::Base attr_accessible :name has_and_belongs_to_many :users belongs_to :project_manager, :class_name => "User" end USERS class User < ActiveRecord::Base attr_accessible :name, :project_id belongs_to :company belongs_to :owned_company, :class_name => "Company", :foreign_key => "owner_id" has_many :managed_projects, :class_name => "Project", :foreign_key => "project_manager_id" has_and_belongs_to_many :projects end COMPANIES class Company < ActiveRecord::Base attr_accessible :name has_many :users has_many :owners, :class_name => "User", :foreign_key => "owner_id" end -----Tables & Migrations----- PROJECTS class CreateProjects < ActiveRecord::Migration def change create_table :projects do |t| t.string :name t.integer :project_manager_id t.timestamps end end end USERS class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :name t.integer :project_id t.integer :owner_id t.timestamps end end end COMPANIES class CreateCompanies < ActiveRecord::Migration def change create_table :companies do |t| t.string :name t.timestamps end end end Projects - Users - Join Table class CreateTableProjectsUsers < ActiveRecord::Migration def self.up create_table :projects_users,:id => false do |t| t.integer :project_id t.integer :user_id end end def self.down drop_table :projects_users end end
1
PROJECTS class Project &lt
Is it copyright infringement by US copyright law if someone else modifies and uses my design?
My company is in a small town and there are not any graphic designers but we have enough business in the town and the surrounding area to support us. But because of the small town nature some business owners do not know all the laws. And since I am starting this from a career in architecture I am not quite clear on copyrights. So here is my problem. I created a sign that has an oval with scrolls and flowers in different colors on a field of turquoise. The client did not want to spend the money on a logo design so I said that I will just retain the rights so that she would have to come to me for the approval to use the logo on anything else. So anyway everything seems to be fine, I do her business cards and now all of a sudden I see a sign at the street. I quoted her on this job figuring in using the logo. Apparently this company did for much less and you can tell by the quality. But here is my problem. She had a jpeg that I allowed her to have so she could create her own fliers and I was ok with that since it would not have made me much if any money. Well I am looking at the sign that the other person did and all that was done is they made a longer oval since this sign is more rectangle and used a different font. And put this over the design that I did. To me this is copyright infringement since the client did not want to buy all the rights. But who do I address? The client or the person that did the sign?
Simply put, any copying of someone else's work is copyright infringement unless the copying is authorized by the owner of the work or the copying falls under a "fair use" exemption. What it's going to come down to here, however, is who owns the work. In a case of an employer-employee relationship, the owner of the work is usually the employer. In the case of a client-service relationship, the owner of the work needs to be specified in the contract. Lack of a contract is a bad idea for both parties as in practical terms it will become more difficult for either side to prove what the nature of the agreement was. Circumstantial evidence such as the fact the client paid you a sum of money and that the design appears to have been created specifically for the client may suggest, but not prove, that the nature of the agreement was that the client bought the rights to the design. Lack of a paper contract saying otherwise would be a bad thing if you wanted to pursue this further.
0.888889
Copyright infringement unless copying is authorized by the owner of the work or the copying falls under a "fair use" exemption
Why do some transformers hum less or not at all when lightly loaded?
It can be observed that large power transformers hum more under load. For example, when some devices are powered up, there is brief "twang" sound: a loud hum that quickly decays as the filter capacitors charge. Increased continuous hum from a transformer can indicate that the filter capacitors are leaking. This question isn't about why transformers hum, but why do they hum less, or hardly at all, when not loaded. How is the electro-mechanics playing itself out to reduce the hum? After all, the fluctuating magnetic fields are there whether or not there is a load on the secondary winding.
The humming is primarily caused by magnetic forces, which are proportional to current. Less loaded transformers have less current thru them, so hum less.
1
humming caused by magnetic forces, which are proportional to current
Show tooltip on invalid input in edit control
I have subclassed edit control to accept only floating numbers. I would like to pop a tooltip when user makes an invalid input. The behavior I target is like the one edit control with ES_NUMBER has : So far I was able to implement tracking tooltip and display it when user makes invalid input. However, the tooltip is misplaced. I have tried to use ScreenToClient and ClientToScreen to fix this but have failed. Here are the instructions for creating SCCE : 1) Create default Win32 project in Visual Studio. 2) Add the following includes in your stdafx.h, just under #include <windows.h> : #include <windowsx.h> #include <commctrl.h> #pragma comment( lib, "comctl32.lib") #pragma comment(linker, \ "\"/manifestdependency:type='Win32' "\ "name='Microsoft.Windows.Common-Controls' "\ "version='6.0.0.0' "\ "processorArchitecture='*' "\ "publicKeyToken='6595b64144ccf1df' "\ "language='*'\"") 3) Add these global variables: HWND g_hwndTT; TOOLINFO g_ti; 4) Here is a simple subclass procedure for edit controls ( just for testing purposes ) : LRESULT CALLBACK EditSubProc ( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData ) { switch (message) { case WM_CHAR: { POINT pt; if( ! isdigit( wParam ) ) // if not a number pop a tooltip! { if (GetCaretPos(&pt)) // here comes the problem { // coordinates are not good, so tooltip is misplaced ClientToScreen( hwnd, &pt ); /************************** EDIT #1 ****************************/ /******* If I delete this line x-coordinate is OK *************/ /*** y-coordinate should be little lower, but it is still OK **/ /**************************************************************/ ScreenToClient( GetParent(hwnd), &pt ); /************************* Edit #2 ****************************/ // this adjusts the y-coordinate, see the second edit RECT rcClientRect; Edit_GetRect( hwnd, &rcClientRect ); pt.y = rcClientRect.bottom; /**************************************************************/ SendMessage(g_hwndTT, TTM_TRACKACTIVATE, TRUE, (LPARAM)&g_ti); SendMessage(g_hwndTT, TTM_TRACKPOSITION, 0, MAKELPARAM(pt.x, pt.y)); } return FALSE; } else { SendMessage(g_hwndTT, TTM_TRACKACTIVATE, FALSE, (LPARAM)&g_ti); return ::DefSubclassProc( hwnd, message, wParam, lParam ); } } break; case WM_NCDESTROY: ::RemoveWindowSubclass( hwnd, EditSubProc, 0 ); return DefSubclassProc( hwnd, message, wParam, lParam); break; } return DefSubclassProc( hwnd, message, wParam, lParam); } 5) Add the following WM_CREATE handler : case WM_CREATE: { HWND hEdit = CreateWindowEx( 0, L"EDIT", L"edit", WS_CHILD | WS_VISIBLE | WS_BORDER | ES_CENTER, 150, 150, 100, 30, hWnd, (HMENU)1000, hInst, 0 ); // try with tooltip g_hwndTT = CreateWindow(TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_ALWAYSTIP | TTS_BALLOON, 0, 0, 0, 0, hWnd, NULL, hInst, NULL); if( !g_hwndTT ) MessageBeep(0); // just to signal error somehow g_ti.cbSize = sizeof(TOOLINFO); g_ti.uFlags = TTF_TRACK | TTF_ABSOLUTE; g_ti.hwnd = hWnd; g_ti.hinst = hInst; g_ti.lpszText = TEXT("Hi there"); if( ! SendMessage(g_hwndTT, TTM_ADDTOOL, 0, (LPARAM)&g_ti) ) MessageBeep(0); // just to have some error signal // subclass edit control SetWindowSubclass( hEdit, EditSubProc, 0, 0 ); } return 0L; 6) Initialize common controls in MyRegisterClass ( before return statement ) : // initialize common controls INITCOMMONCONTROLSEX iccex; iccex.dwSize = sizeof(INITCOMMONCONTROLSEX); iccex.dwICC = ICC_BAR_CLASSES | ICC_WIN95_CLASSES | ICC_TAB_CLASSES | ICC_TREEVIEW_CLASSES | ICC_STANDARD_CLASSES ; if( !InitCommonControlsEx(&iccex) ) MessageBeep(0); // signal error That's it, for the SSCCE. My questions are following : How can I properly position tooltip in my main window? How should I manipulate with caret coordinates? Is there a way for tooltip handle and toolinfo structure to not be global? Thank you for your time. Best regards. EDIT #1: I have managed to achieve quite an improvement by deleting ScreenToClient call in the subclass procedure. The x-coordinate is good, y-coordinate could be slightly lower. I still would like to remove global variables somehow... EDIT #2: I was able to adjust y-coordinate by using EM_GETRECT message and setting y-coordinate to the bottom of the formatting rectangle: RECT rcClientRect; Edit_GetRect( hwnd, &rcClientRect ); pt.y = rcClient.bottom; Now the end-result is much better. All that is left is to remove global variables... EDIT #3: It seems that I have cracked it! The solution is in EM_SHOWBALLOONTIP and EM_HIDEBALLOONTIP messages! Tooltip is placed at the caret position, ballon shape is the same as the one on the picture, and it auto-dismisses itself properly. And the best thing is that I do not need global variables! Here is my subclass procedure snippet: case WM_CHAR: { // whatever... This condition is for testing purpose only if( ! IsCharAlpha( wParam ) && IsCharAlphaNumeric( wParam ) ) { SendMessage(hwnd, EM_HIDEBALLOONTIP, 0, 0); return ::DefSubclassProc( hwnd, message, wParam, lParam ); } else { EDITBALLOONTIP ebt; ebt.cbStruct = sizeof( EDITBALLOONTIP ); ebt.pszText = L" Tooltip text! "; ebt.pszTitle = L" Tooltip title!!! "; ebt.ttiIcon = TTI_ERROR_LARGE; // tooltip icon SendMessage(hwnd, EM_SHOWBALLOONTIP, 0, (LPARAM)&ebt); return FALSE; } } break;
After further testing, I have decided to put this as an answer so others can clearly spot it. The solution is in using EM_SHOWBALLOONTIP and EM_HIDEBALLOONTIP messages. You do not need to create tooltip and associate it to an edit control! Therefore, all I need to do now is simply subclass edit control and everything works : LRESULT CALLBACK EditSubProc ( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData ) { switch (message) { case WM_CHAR: { if( ! isdigit( wParam ) ) // if not a number pop a tooltip! { EDITBALLOONTIP ebt; ebt.cbStruct = sizeof( EDITBALLOONTIP ); ebt.pszText = L" Tooltip text! "; ebt.pszTitle = L" Tooltip title!!! "; ebt.ttiIcon = TTI_ERROR_LARGE; // tooltip icon SendMessage(hwnd, EM_SHOWBALLOONTIP, 0, (LPARAM)&ebt); return FALSE; } else { SendMessage(hwnd, EM_HIDEBALLOONTIP, 0, 0); return ::DefSubclassProc( hwnd, message, wParam, lParam ); } } break; case WM_NCDESTROY: ::RemoveWindowSubclass( hwnd, EditSubProc, 0 ); return DefSubclassProc( hwnd, message, wParam, lParam); break; } return DefSubclassProc( hwnd, message, wParam, lParam); } That's it! Hopefully this answer will help someone too!
1
EM_SHOWBALLOONTIP
How do i measure the output voltage of lm35 with digital voltmeter?
I know this is a very stupid question. Lm35 has 3 pins: Vcc, Analog output voltage, Gnd. Is it ok to measure between analog output voltage and gnd? Im asking because Vcc and Gnd is a dc.
Yes you definitely can because the analog pin is set by the IC with respect to ground. You probably know this but if you are going to use a voltmeter, don't touch the leads of the LM35 with the voltmeter probes directly, because if you short it, you will experience the all too familiar smell of burning electronics.
1
When using a voltmeter, don't touch the leads of the LM35 directly
EXcel Web Access - web part Error
I asked this related question in stack overflow, Hence this forum is dedicated for sharepoint, Thought to ask here!! I got to know how to get the Excel using sharepoint Excel web access webpart. However I am getting an error "Excel Services is unable to process the request. Wait a few minutes and try performing this operation again!!" Even If I directly access the Excel from the document library also getting the same error!!
Would be nice if you could provide some log information, but double check: Excel Services is actually running on the farm. Check if you can run Get-SPExcelServiceApplication Check the Trusted File Location for Excel Services Check if your Web Application has a service connection to the Excel Services
1
Excel Services is running on the farm
Populate a JSON into a table in real time with JQUERY
I'm looking for a library which do this : Retrieve a JSON through an AJAX call Populate table with the JSON Update in real time the table with the JSON (call every x seconds) and only delete or hide the rows wich are deleted or insert the new rows. /Editing after first answer Ok i guess my first explanation was not good. Retrieving through jquery a json and build a table is good, i could do that, but my request was more on the other part. I'm looking for a library to display the result in a special way. Let me explain. Json request 1 send : 1;Tomato 2;Apple 3;Salad 4;Carot Json request 2 send : 1;Tomato 3;Salad 4;Carot 5;Potatoes I would like the second row disapear with a effect (fadeOut) and the rows below move Up. For the row 5, i just want a new row appears with a fade in. Is that more clear ? Is there any livrary existing doing this ? Thanks again I'm doing it in PHP, but i hope to write all this in JS. The user could just look the table and see the new rows appearing and the old rows deleting. Any ideas or am i supposed to write it from scratch ? Thanks a lots
First I would read this, but the code is actually really simple. On your front end, you'd have your table <table id="myTable"></table> Then you'd make your AJAX post within JQuery $.ajax({ url: "yourphpfile", data: <data you want your php file to read> success: function(data){ $('#myTable').html(data); } }); Your method in php would take in your posted data, it would create an HTML string of a table element, and then you'd set your table's innerHTML on the front end with .html() built into JQuery -- that way you never have to worry about showing/hiding, everytime you post, your given the table itself, so you just display exactly that, you can handle all the fancy stuff server side.
0.833333
JQuery .html() in JQuery
Trigger IP ban based on request of given file?
I run a website where "x.php" was known to have vulnerabilities. The vulnerability has been fixed and I don't have "x.php" on my site anymore. As such with major public vulnerabilities, it seems script kiddies around are running tools that hitting my site looking for "x.php" in the entire structure of the site - constantly, 24/7. This is wasted bandwidth, traffic and load that I don't really need. Is there a way to trigger a time-based (or permanent) ban to an IP address that tries to access "x.php" anywhere on my site? Perhaps I need a custom 404 PHP page that captures the fact that the request was for "x.php" and then that triggers the ban? How can I do that? Thanks! EDIT: I should add that part of hardening my site, I've started using ZBBlock: This php security script is designed to detect certain behaviors detrimental to websites, or known bad addresses attempting to access your site. It then will send the bad robot (usually) or hacker an authentic 403 FORBIDDEN page with a description of what the problem was. If the attacker persists, then they will be served up a permanently reccurring 503 OVERLOAD message with a 24 hour timeout. But ZBBlock doesn't do quite exactly what I want to do, it does help with other spam/script/hack blocking.
Recreate x.php and have it collect the IP address of anyone trying to reaching it. Then create (or modify) a .htaccess file that blocks them using Apache. The .htaccess file will look like this: order deny,allow deny from 123.123.123.123 deny from 353.345.345.345 Just keep appending to that file any IP address you want banned. The x.php might look like this: (untested) <?php $fp = fopen('.htaccess', 'w'); fwrite($fp, 'deny from ' . $_SERVER['REMOTE_ADDR'] . "\n"); fclose($fp); ?>
1
Recreate x.php and have it collect IP address of anyone trying to reach it
ASP.NET Entity Framework Filter results by currrent user
I am using Visual Studio Express 2013 and am creating simple CRUD pages using the Enitity Framework 6 I have also implemented the social login so I am logged in via google plus My problem is that I want to filter the results of a table to only show the results of the logged user. I can identify the logged user by calling this in the controller ViewBag.CurrentTestUserId = User.Identity.GetUserId(); and I can call this on my view page but I am struggling to filter the dataset below to show only the data for the logged in user // GET: /Test/ public ActionResult Index() { var tests = db.Tests.Include(t => t.AspNetUser); return View(tests.ToList());
Thank you so much for your answer. // GET: /Test/ public ActionResult Index() { var userId = User.Identity.GetUserId(); var tests = db.Tests.Where(t=>t.TestUser == userId); return View(tests.ToList()); } This works perfectly where Testuser is the column in my model that contains the id of the Asp logged user Regards
0.666667
GET: /Test/ public ActionResult Index
Spring security - Access to a controller method based on an attribute
I'm configuring Spring Security across all my controllers. I want some method executions to start only when "my system is enabled". This information is accessible from all over the controllers via a specific static method (I can make it non-static). My point is that I want to avoid making an explicit check in java code at the beginning of every method. How can I get there via Spring Security?
You can use SPEL (Spring Expression Language) in a security annotation. See http://static.springsource.org/spring-security/site/docs/3.0.x/reference/el-access.html
1
SPEL in a security annotation
Placing the grid along date tickmarks
I have the following data: x=strptime(20010101:20010110) y=1:10 z=data.frame(x,y) So my data is this: x y 1 2001-01-01 1 2 2001-01-02 2 3 2001-01-03 3 4 2001-01-04 4 5 2001-01-05 5 6 2001-01-06 6 7 2001-01-07 7 8 2001-01-08 8 9 2001-01-09 9 10 2001-01-10 10 When I create a plot in base using: plot(x,y) grid(NULL,NULL) My vertical grid does not align with the date tick marks. I know this seems like a pretty simple problem, but I have not found a solution to this anywhere. Is there a way to get the vertical grid to align with the date tick marks using base that does not require me to do this: abline(v=as.numeric(strptime(c(20010102,20010104,20010106,20010108,20010110),'%Y%m%d'))) I have a lot of plots with different dates and I would really like to automate this as much as possible, hopefully using base.
The function axis draws your axes, tick marks and labels, and returns the tick mark positions as a vector. Since you have Date data, you need to use axis.Date to do this, and then use abline to plot the grid: z=data.frame( x=seq(as.Date("2001-01-01"), by="+1 month", length.out=10) y=1:10 ) plot(y~x, data=z) abline(v=axis.Date(1, z$x), col="grey80")
1
The function axis draws axes, tick marks and labels and returns the tick mark positions as vector
Putting Linux processes on certain CPU cores
Possible Duplicate: How can I set the processor affinity of a process on Linux? Computer CPUs have many cores insde them nowadays. I have always wondered if there is a way to, when I start a process on the Linux command line, specify which particular core or cores that process might use? For example, can I start a massive grep task and say "use ALL of CPU2 for yourself". Or could I start a find task and say "never leave CPU3". Or maybe I could start a video decoding task and say "use whatever is available on CPU1 and CPU2" OR, is there no way to do this because it is not needed and the OS is doing this kind of stuff intelligently by itself (based on nice levels and general resource usage of the process etc) IfyouknowwhatImean
See the taskset utility. Should be exactly what you're looking for.
1
See taskset utility
Unreachable IP on local subnet
I have a network printer at 192.168.2.101 that I can reach just fine with other machines on my network (ping and access the printer web server). For some reason I can't access the printer from my Ubuntu machine--pings return host unreachable. I'm running Ubuntu 11.04 ifconfig eth1 Link encap:Ethernet HWaddr 38:59:f9:c4:52:a9 inet addr:192.168.2.11 Bcast:192.168.2.255 Mask:255.255.255.0 inet6 addr: fe80::3a59:f9ff:fec4:52a9/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:167828 errors:0 dropped:0 overruns:0 frame:2000398 TX packets:116132 errors:16 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:213283954 (213.2 MB) TX bytes:15552076 (15.5 MB) Interrupt:16 Edited Oct/20/2011 I've added the requested diagnostics below. Any hints in here? ip route show $ ip route show 192.168.2.0/24 dev eth1 proto kernel scope link src 192.168.2.11 metric 2 169.254.0.0/16 dev eth1 scope link metric 1000 default via 192.168.2.1 dev eth1 proto static traceroute $ ip route show 192.168.2.0/24 dev eth1 proto kernel scope link src 192.168.2.11 metric 2 169.254.0.0/16 dev eth1 scope link metric 1000 default via 192.168.2.1 dev eth1 proto static netstat $ netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1 0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 eth1 Edited Nov/2/2011 After a bit more digging it appears this might be an issue with MAC address translation. arp yeilds $ arp Address HWtype HWaddress Flags Mask Iface 192.168.2.101 (incomplete) eth1 192.168.2.1 ether 00:17:3f:90:cd:93 C eth1 I've tried adding a static entry, per this post Add static ARP entries when network is brought up, but the result is the same. Any thoughts?
I have the same problem today. Check the mac address of your Ubuntu machine and printer, they have a same mac address, so change your Ubuntu mac address to fix this problem.
1
Check the mac address of your Ubuntu machine and printer
What's the highest character level in Torchlight?
I was googling quite a lot for this question, but I couldn't find an answer. But what is the highest reachable character level in Torchlight?
The highest level attainable without the use of mods, is: 100. With the use of mods, you can reach level 999 (Link to the mod:LVL&SkillMod)
1
The highest level attainable without the use of mods, is 100 .
House rules to make the cloister less of a game winning tile in Carcassonne?
In my experience, cloister tiles in Carcassonne are often "too lucky". If you draw a cloister tile in the beginning of the game, it will typically still require an investment of quite a bit of "meeple" time to obtain the full 9 points, which makes it a fair trade-off. However, after about half of the game, it's relatively likely that you can "parachute" a cloister tile in some spot and get 8 or 9 points immediately. This adds a lot of randomness to the game. What house rules work well to diminish this effect?
You could borrow the "Abbey" idea from the Abbyes and Mayors expansion. Abbeys are special tiles (6 of them divided equally among all players) which you can play rather than drawing and playing a random tile. The abbey counts as a cloister for scoring and playing a meeple on, and has a solid edge, so that it ends a road, and walls off citys and farms that it borders. Abbeys can only be played in holes - spaces that have tiles on all four sides. The effect of this is that areas that are prime "gotcha" cloister locations at end game are a little less likely as they either get Abbeys dropped into them, or players shy away from letting such places appear. Without Abbeys and Mayors, you could allow each player once or twice a game, the option of playing a tile face down in a whole rather as an Abbey than as a normal play, and otherwise following the normal Abbey rules.
0.777778
Abbyes and Mayors expansion: "Abbey"
Litvaks/Yeshivish and Shulchan Aruch
I understand that non-Chasidic (Ashkenaz) haredim follow the Mishnah Berurah when it comes to Orach Chayim part of Shulchan Aruch. But Mishnah Berurah is only for Orach Chayim. What they do with other parts of S"A (Yoreh De'ah, Even Ha-Ezer, Chosen Mishpat) do they just follow Rema or later commentaries printed in standard S"A? I mean, Chabad Chasidim have S"A Baal HaTanya which contains Yoreh De'ah and Chosen Mishpat. I can recapitulate my question: do Litvaks/Yeshivish learn Mishnah Berurah and then Shulchan Aruch with commentaries for other parts of halacha?
First of all, there's no rule that all of the litvishe Ashkenazim have to follow the Mishna Berura. It was very well accepted, but deciding on each halacha is a very complicated matter, and on every page of the Dirshu or Oz VeHadar versions of the Mishna Berurah you can find places where later poskim have disagreed and where certain rulings of the Mishna Berurah have not been widely accepted. In fact, in the introrduction to the Oz VeHadar Aruch Hashulchan, it states that Rav Moshe Feinstein would often pasken like the Aruch Hashulchan over the Mihnah Berurah (though finding all of those places isn't so easy since he doesn't always quote them) and there's a teshuvah by Rav Yosef Eliyahu Henkin's grandson which says that he also thought the Aruch Hashulchan wins over the Mishna Berurah, (Shut Bnei Banim 2:8). But again, halacha is complicated and great poskim decide these things on a case by case basis. Having said all that, I think it should be clear the first source for an authoritative, litvish, late European commentary on Shulchan Aruch, the Aruch Hashulchan would be the answer, but the Chayei Adam and Kitzur Shulchan Aruch are used often as well, and are much easier to read. Of course, there are many issues, teshuvos, and poskim who have come afterwords, so seforim that are now popular include the Badei Hashulchan (and more recently Divrei Sofrim) on Y.D. and the Pischei Choshen (which isn't a commentary on Shulchan Aruch but still very thorough and widely accpeted as far as I've seen) on C.M. and dayanim studying Even Haezer often use the Otzar HaPoskim. Also, I should point out that the Lubavitcher Rebbe's Shulchan Aruch on Y.D. and C.M. especially are far from comprehensive
0.666667
halacha is complicated and great poskim decide on a case by case basis
Tools to run a background process command line in windows?
In linux we just need to append a & and that's all. What for windows?
There is no equivalent. You could install cygwin and do the same thing. Or you could make a service that runs your application : srvany or other tools will do this for you. Keep in mind that not all Windows applications will properly run in these ways.
1
Install cygwin and do the same thing