summary
stringlengths 15
147
| text
stringlengths 1
19.3k
| answer
stringlengths 32
22.6k
| labels
float64 0.33
1
| answer_summary
stringlengths 5
164
|
---|---|---|---|---|
How to find the files in magento directory
|
I want to get the list of taxes to display on cart page..
The code that is using to display the tax is :
This block is showing tax information:
$this->renderTotals();
while this block is shwoing grand total:
<?php echo $this->renderTotals('footer'); ?>
But i need to made some changes... please tell me which file i have to look for so i can make the changes...
I tried all the files adn check the coding.. but no success...
Please help me....
|
The class for this block is defined in the file Mage/Checkout/Block/Cart/Totals.php
If you open this file you will find renderTotals() defined here. I think you are interested in making changes here. If yes, you can override this class and make your changes.
| 1 |
How to override renderTotals()?
|
Laravel 4 translation by country
|
I need help I'm working on a project that needs to translate the language of the site automactically depending on the country the user is from. I've never done this before so please any help would be wonderful.
|
This process is known as localization, also known as i18n. Laravel provides this functionality natively. Have a look at the official docs for instructions on getting started.
EDIT:
The developers of Laravel made a deliberate decision to not host a central localization repository for Laravel 4. You might snoop around to see whether other users have forked localized translations, but given the relative newness of Laravel 4, I doubt you'll see much out there. If you can't find the translation you need, you may want to make a fork of Laravel and build out your own localization file using en as a template.
| 0.888889 |
Localization is a native localization process for Laravel 4
|
Is there a general term for a single note or a chord?
|
Take a passage like this:
Fill in the blank: Each of these boxes denote a ______
Is there a single general term for these that's better than note or chord? Or maybe there's a term for "anything that has a duration" that also encompasses rests? It seems like enough of a fundamental concept that it should have a name.
|
For formal, technical purposes (e.g. when discussing musical audiation and other aspects of musical cognition) the terms "acoustic event" or "notated event" or "vertical event" is pretty much standard terminology within psychology of music for referring broadly to any individual single tone or simultaneosly experienced combination of tones (i.e. an individual chord) within a passage or composition. An acoustic event can also include a silence. Really useful all-inclusive terms, (though not yet in musicians' common parlance)!
So, I'd use the term "notated event" (or the more generalized "vertical event") to fill in the blank in the OP's question.
| 0.888889 |
acoustic event or "notated event" or "vertical event"
|
Control 8V H-Bridge with microcontroller
|
Good afternoon.
I've been trying to control an 8V H-Bridge (PMOS+NMOS) with a 4V microcontroller output signal. I thouth it would work but then i read that the PMOS source voltage had to be equal or smaller than the control voltage in the PMOS/NMOS gates. Does somebody know how to deal with this problem (without adding much more electronics)?
|
If you don't need to PWM very fast you can simply use a low-to-high logic level converter from the 4000 family (eg. CD40109B). Drive current is only a few mA so they'll not drive big MOSFETs fast.
There are plenty of gate-driver chips if you need to drive a big MOSFET fast (hundreds of mA or amperes of current drive to supply the gate charge fast), but they tend to be more expensive.
| 0.777778 |
Drive current is only a few mA .
|
Transform a Binary Search Tree into a Greater Sum Tree
|
Given a Binary Search Tree (where all nodes on the left child branch are less than the node), and all nodes to the right are greater/equal to the node), transform it into a Greater Sum Tree where each node contains sum of it together with all nodes greater than that node. Example diagram is here:
Looking for code review, optimizations and best practices.
public class GreaterSumTree implements Iterable {
private TreeNode root;
public GreaterSumTree(List<Integer> list) {
create(list);
}
private void create (List<Integer> items) {
root = new TreeNode(items.get(0));
final Queue<TreeNode> queue = new LinkedList<TreeNode>();
queue.add(root);
final int half = items.size() / 2;
for (int i = 0; i < half; i++) {
if (items.get(i) != null) {
final TreeNode current = queue.poll();
final int left = 2 * i + 1;
final int right = 2 * i + 2;
if (items.get(left) != null) {
current.left = new TreeNode(items.get(left));
queue.add(current.left);
}
if (right < items.size() && items.get(right) != null) {
current.right = new TreeNode(items.get(right));
queue.add(current.right);
}
}
}
}
public static class TreeNode {
private TreeNode left;
private int item;
private TreeNode right;
TreeNode(int item) {
this.item = item;
}
}
public static class IntObject {
private int sum;
}
/**
* Computes the greater sum, provided the tree is BST.
* If tree is not BST, then results are unpredictable.
*/
public void greaterSumTree() {
if (root == null) {
throw new IllegalArgumentException("root is null");
}
computeSum (root, new IntObject());
}
private void computeSum(TreeNode node, IntObject intObj) {
if (node != null) {
computeSum(node.right, intObj);
int temp = node.item;
node.item = intObj.sum;
intObj.sum = intObj.sum + temp;
computeSum(node.left, intObj);
}
}
/**
* Returns the preorder representation for the given tree.
*
* @return the iterator for preorder traversal
*/
@Override
public Iterator iterator () {
return new PreOrderItr();
}
private class PreOrderItr implements Iterator {
private final Stack<TreeNode> stack;
public PreOrderItr() {
stack = new Stack<TreeNode>();
stack.add(root);
}
@Override
public boolean hasNext() {
return !stack.isEmpty();
}
@Override
public Integer next() {
if (!hasNext()) throw new NoSuchElementException("No more nodes remain to iterate");
final TreeNode node = stack.pop();
if (node.right != null) stack.push(node.right);
if (node.left != null) stack.push(node.left);
return node.item;
}
@Override
public void remove() {
throw new UnsupportedOperationException("Invalid operation for pre-order iterator.");
}
}
}
Here is a test case:
public class GreaterSumTreeTest {
@Test
public void test() {
Integer[] a = {1, 2, 7, 11, 15, 29, 35};
GreaterSumTree greaterSumTree = new GreaterSumTree(Arrays.asList(a));
greaterSumTree.greaterSumTree();
int[] expected = {71, 87, 89, 72, 35, 42, 0};
int[] actual = new int[a.length];
int counter = 0;
Iterator itr = greaterSumTree.iterator();
while (itr.hasNext()) {
actual[counter++] = (Integer) itr.next();
}
assertTrue(Arrays.equals(expected, actual));
}
}
|
Compiler Warnings
Iterable is a raw type. References to generic type Iterable should be parameterized
This is very easy to fix. It's horrible that you haven't fixed it already. I'm sure that you know what generics is by now so I don't need to explain it to you. Whenever you see this warning, add generics!
Iterable --> Iterable<Integer>
Problem solved!
Then you can get rid of the (Integer) cast next to itr.next();
Why Binary Search Tree?
My first thought, once I understood the problem your solving was: Why on earth do you have the data as a Binary Search Tree? What does the tree have to do with anything?
If this was a question given to me at an interview, I would ask them this. Why a Binary Search Tree? The operations you're doing is totally unrelated to a tree. You could just as well perform this on a regular int[]. If there is a good reason for why it has to be a Binary Search Tree then please explain it to me.
Here's a simple implementation of how to perform this on a regular int[], without using a Binary Tree:
public static void main(String[] args) {
int[] input = new int[] { 1, 2, 7, 11, 15, 29, 35, 40 };
int[] expected = new int[] { 139, 137, 130, 119, 104, 75, 40, 0 };
transformToGreaterSum(input);
System.out.println(Arrays.toString(input));
System.out.println(Arrays.toString(expected));
}
private static void transformToGreaterSum(int[] input) {
int sum = 0;
for (int i = input.length - 1; i >= 0; i--) {
int prevSum = sum;
sum += input[i];
input[i] = prevSum;
}
}
Note that this is also \$O(n)\$ without using any extra space.
Broken Tree
I'd also like to point out that your actual search tree does not match your image. I found out by debugging your code that your actual search tree looks like this:
The fact that it looks like this, and the fact that your algorithm works at all, is just because your input is sorted: {1, 2, 7, 11, 15, 29, 35}.
Your tree is in fact not a correct Binary Search Tree. A correct tree could look like this:
Yes, that's still a tree. It just doesn't have any left nodes (it does have seven nodes left though, I didn't remove any). A child node that is bigger than its parent should be on the right, which makes this tree right. (I love the English language)
As if that was not enough, your int[] expected says:
int[] expected = {71, 87, 89, 72, 35, 42, 0};
But your image says:
119, 137, 75, 139, 130, 104, 0, 40
Given your description:
Given a BST, transform it into greater sum tree where each node contains sum of all nodes greater than that node. Diagram is here.
I would expect the node for 11 to get the value 15 + 29 + 35 + 40 = 119. I don't see 119 anywhere in your expected or actual result though...
Verifying a Binary Search Tree
As your question contains an incorrect tree and one of your comments below has an incorrect tree, I'd like to provide you with a method to verify a correct tree:
private static void verifyNode(TreeNode node) {
if (node.left != null) {
if (node.left.item >= node.item) {
throw new IllegalStateException("node.left >= node: " + node.left.item + " >= " + node.item);
}
verifyNode(node.left);
}
if (node.right != null) {
if (node.right.item <= node.item) {
throw new IllegalStateException("node.right <= node: " + node.right.item + " <= " + node.item);
}
verifyNode(node.right);
}
}
Just pass it your root node and it will verify your tree recursively. Note that there are two things this method does not verify, that are also a requirement for a Binary Search Tree:
There must be no duplicate nodes.
A unique path exists from the root to every other node.
Arrays and Lists
Speaking of int[] I wonder why your constructor takes a List<Integer> instead of an array: int[]. I don't think you gain anything by using a list.
The only thing you gain at the moment by using Integer rather than int is the possibility for this:
if (items.get(i) != null) {
As your input never contains null (and I see no reason why it should), I don't get the point of using that non-null check. I modified your code to use int[] instead and removed the non-null checks and all worked well still. It even got rid of some indentation steps and felt like a cleanup overall.
Iterate over what?
If you would have your Iterator as Iterator<TreeNode> instead of Iterator<Integer> you could use your iterator in your computeSum method as well as in your test method to fetch the results. This would make you have to modify your iterator implementation though (but as your tree is not a real binary search tree, it's quite broken already).
Or you could just ignore the tree structure and use arrays....
Summary
Given how many trees I've seen you implement, I really thought your code would be better than this. Your current code doesn't live up to your requirements, or your requirements are messed up. Additionally, the "raw type" mistake is a mistake one just should not make after having written just a few Java classes.
| 1 |
Why a Binary Search Tree is not a correct binary search tree?
|
Java ServiceLoader with multiple Classloaders
|
What are the best practices for using ServiceLoader in an Environment with multiple ClassLoaders? The documentation recommends to create and save a single service instance at initialization:
private static ServiceLoader<CodecSet> codecSetLoader = ServiceLoader.load(CodecSet.class);
This would initialize the ServiceLoader using the current context classloader. Now suppose this snippet is contained in a class loaded using a shared classloader in a web container and multiple web applications want to define their own service implementations. These would not get picked up in the above code, it might even be possible that the loader gets initialized using the first webapps context classloader and provide the wrong implementation to other users.
Always creating a new ServiceLoader seems wasteful performance wise since it has to enumerate and parse service files each time. Edit: This can even be a big performance problem as shown in this answer regarding java's XPath implementation.
How do other libraries handle this? Do they cache the implementations per classloader, do they reparse their configuration everytime or do they simply ignore this problem and only work for one classloader?
|
Have you tried using the two argument version so that you can specify which classloader to use? Ie, java.util.ServiceLoader.load(Class , ClassLoader)
| 0.333333 |
How to specify which classloader to use?
|
Is it better to go first or last in Vinci?
|
My son is convinced that it's best to go last in Vinci because you have the more complete information of seeing where other players have started their civilizations and you always get last turn (like having home field advantage in baseball). I see these 2 advantages, but I wonder if these outweigh the disadvantages such as not having first pick on civilizations, not being the first to go into decline, and perhaps other factors I haven't even considered (we're all new to the game). So:
Is it better to go first, last, in between, or is the game so well balanced that it hardly matters?
|
It will be difficult to measure, especially when you add in more than two players. Just examining two players for a moment here. It is usually more advantageous to go first during the first turn, because you get first race selection. After choosing your race, the new selection is revealed. If your opponent was only allowed a single turn, you could calculate the best move for every race before the revealed race, and determine the best move possible (after the new race is revealed, you can add it's best move into your calculations). If you only played one round, you will get the first attempt to take empty territory, and your opponent might have to attack you to take territory.
The exception to the above would be when a powerful race is revealed. This is less likely to happen when compared to the 6 starting revealed races.
An examination of the last turn is similar. The player who is going first has the opportunity to take any unclaimed regions (if any) before his opponent.
For the most part, this is a game of open information. Going first is an advantage in 2-player, because you could calculate your optimum move and your opponents optimum move that turn. In subsequent turns, you will get the first opportunity to go into decline. The only random events (race selection) favor the first player. In multiplayer though, who each person decides to attack has probably a greater effect on winning. If every player played optimally, I think the first player would still have the advantage most of the time, but that is a much more difficult question to solve.
| 1 |
It is more advantageous to go first during the first turn, because you get first race selection
|
How many wounds does a Rogue Trader character start with?
|
I do not seem to be able to see where in the RT core rulebook you can work out how many wounds a character starts with. During character creation there are modifiers to it, mostly through career path, but what exactly should the base figure be?
Based on the NPCs provided in the introductory campaign I would assume this figure would be around 20 to 25.
I would appreciate knowing what page actually states this.
|
Starting wounds depend on your homeworld, and can be found in the section starting on page 17 of the core rulebook.
For example, Deathworld characters start with (2 x Toughness) + (1d5 + 2)
| 1 |
Starting wounds depend on your homeworld
|
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.
|
Or you can always buy the book. Quantz did in fact write what many consider the definitive book on playing the baroque flute and since you are playing a piece written by him I don't see how you can go wrong following his advice.
Google 'Quantz on playing the flute.'
I quick note I do not have the quote handy but to paraphrase Quantz, "repeated passages should not be played with the same articulation each time. This is dull for the listener and shows a lack of imagination on the part of the performer."
| 0.888889 |
'Quantz on playing the baroque flute'
|
Myrrix java.io.IOException upon ingest when following the tutorial
|
I am attempting to follow the tutorial for evaluating Myrrix for my collaborative filtering needs:
http://myrrix.com/quick-start/
On my Windows 7 laptop, I am able to get the stand-alone java binary running. I can load the web interface on port 80. However, when I go to ingest the sample audioscrobber data I get the message:
Error 500 : /ingest
java.io.IOException: The temporary upload location [C:\Users\XXXXXX\AppData\Local\Temp\1372181071432-0\work\Tomcat\localhost\_\tmp] is not valid
at org.apache.catalina.connector.Request.parseParts(Request.java:2698)
at org.apache.catalina.connector.Request.getParts(Request.java:2640)
at org.apache.catalina.connector.RequestFacade.getParts(RequestFacade.java:1076)
at net.myrrix.web.servlets.IngestServlet.doPost(IngestServlet.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at net.myrrix.web.servlets.AbstractMyrrixServlet.service(AbstractMyrrixServlet.java:155)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1686)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I was hoping that it was just a matter of adding a "--localInputDir" directive to the command line would fix things. However, this seems unrelated to where the Tomcat server is trying to upload.
How do I modify the stand-alone binary so that I am able to successfully ingest sample data for training?
|
I have heard of this before but not been able to reproduce it. For some reason, the temp dir that Tomcat allocates is either not actually created, or not accessible.
You can try deleting that whole directory starting with "137..." to ensure that Tomcat makes another new one. Or try investigating this path to see if you can create and/or make accessible that temp dir.
This should be controlled by Tomcat's javax.servlet.context.tempdir system property. You could also try setting that to somewhere else like /tmp.
As far as I know it's some oddness with Tomcat and Windows, but it may be transient and fixable per above.
| 1 |
Tomcat's temp dir is not created, or not accessible
|
Recursive setTimeout in javascript
|
Is it possible to run this "indefinitely", without causing stack overflow or running out of memory?
function eternal(){
var time = recalculateTime();
doSomething();
setTimeout(eternal,time);
}
setTimeout(eternal,200000);
I'm not using setInterval, because the triggering time is variable.
|
That should be fine. Once setTimeout runs it will return from the eternal function before it's calls it again.
| 1 |
SetTimeout returns from the eternal function before it's calls again
|
What's going wrong when I reproject raster in EPSG:32115 in QGIS?
|
I wish to make a QGIS project with an orthoimagery layer and a vector layer of GPS points. I'm using QGIS 2.8.2, 64 bit, in Windows 7 on a Lenova t430 laptop. Raster is in EPSG: 32115 (mercator, NAD83, Eastern New York): I add that layer first. When I add a *.gpx layer, which is in EPSG4326 (Lat/Long) WGS84, the points display 1000 km south from where they should be. When I add the layers in the opposite order, the raster layer ends up way up in Canada somewhere. No amount of reprojecting of either layer seems to be helping. Do you have any suggestions?
|
The best way to find out which layer is correct, is to set the project CRS to EPSG:3857 with on-the-fly-reprojection enabled, then load a Google or Openstreetmap background via the OpenLayers plugin, then add your layers and check their layer CRS.
Then you see which layer ist placed on the right spot, and which might have a wrong CRS.
BTW this page http://gis.ny.gov/gateway/mg/2014/columbia/#sp notes that the data is in New York State Plane NAD 83 (2011), US Survey Feet , which is EPSG:2260 for Eastern New York. Sometimes QGIS misreads the units on guessing the CRS. You can use Set CRS for Layer to correct it.
| 1 |
Set CRS for Layer to EPSG:3857
|
Effects of nuclear explosions in space?
|
In the Honor Harrington universe, ship-to-ship combat takes two forms: missiles and direct energy weapons.
Missiles come in two forms - bomb-pumped lasers and contact nukes. Both use multi-megaton nuclear initiations to damage enemy ships.
While this sort of event on a planetary surface will obviously have lasting effects, what long-term effects could be expected in a vacuum environment, aside from the destructive force associated with the explosions themselves, and the resulting EMP? Especially, would there be lingering (or spreading) radiation?
|
Obviously intense EM rad close by but the intensity decreases as the root of distance from the point source so unless you were close, as others have said, normal space rad would be a greater threat. No debris either as all matter would be vaporized and ionized. Would prob be kind of like a ripple in the solar wind. Really it's far worse exploding one at ground level and creating all those isotopic by products with nowhere to go.
| 0.888889 |
EM rad close by but intensity decreases as root of distance from point source
|
How to search map address in custom post type?
|
I built a custom post type "shop" with Custom Post Type UI plugin and added a field "address" (Google Map type) with Advanced Custom Fields plugin.
From the response of WP_Query('post_type=shop');, I got the following:
$shop = WP_Query('post_type=shop');
while($shop->have_post()) {
$shop->the_post();
$location = get_field('map-location');
if($location != null) {
echo $location['address'];
}
}
Here I got a list of addresses. How do I search with this "address"? Let's say user wants to search shop that is in "London", how can I achieve this?
Thanks.
UPDATE
Sample result of searching "15":
筲箕灣東大街15號B地下
九龍觀塘偉業街103號振邦工業大廈地鋪
九龍土瓜灣旭日街一號 瑞英工業大廈第一期A座地下
|
You need a meta_query something like this:
$args = array(
'post_type' => 'shop',
'meta_query' => array(
array(
'key' => 'map-location',
'value' => 'London',
'compare' => 'LIKE' // the = operator might work depending on how your data is stored
),
)
);
Note: I am making some assumptions about how ACF stores data.
| 1 |
Meta_query: $args = array
|
Why would an incorrect password attempt take a lot longer to process than a correct one?
|
The most prominent place I've noticed this is when SSH-ing at work, but I feel like I've observed this behaviour elsewhere too.
When I try to log into Linux servers from my Windows desktop at work, I've noticed that if I mis-type my password, it takes a good 5 seconds or so before I get "Access Denied" back. Then when I type my password correctly, the login (along with welcome messages etc) is virtually instant.
Is there any logical reason for this, or would it be down to some odd configuration that's specific to the machines here at work?
|
This is some intended delay to prevent brute force attacks. A longer delay also prevents the attacker being able to guess the difference between username is wrong and password is wrong (hashing and checking the password takes noticeable longer time than checking the username).
| 1 |
A longer delay prevents the attacker being able to guess the difference between username and password is wrong
|
Combined gas law in an open atmosphere
|
The question was asked about pressure vs. Volume increasing in an ideal gas as temperature is increased. My question then is this. What is the formula to determine how much volume and pressure will increase as temperature is increased?
Let me frame the question this way. PV/T=P2V2/T2 this formula works for a controlled system where more than one of these values can be maintained. If we apply a known amount of heat, say n, to the atmosphere, what formula would be used to calculate volume and pressure as the temperature is increased?
|
Technically speaking, If you managed to create a planet with an ideal gas atmosphere, the atmosphere would just float away. Why?
One of the approximations of an ideal gas is
There are no attractive or repulsive forces between the molecules or the surroundings
This means that the gas wouldn't feel the force of gravity!
So if I had a jar of ideal gas, the pressure wouldn't increase as I went to a greater depth in the jar(It does increase in gasses too, just like it does in liquids).
I know this sounds strange but all it really means is that you cannot apply the ideal gas approximation to a system the size of our atmosphere. This approximation works well for small systems(A jar of ideal gas), because the effects of gravity are pretty negligible.
So to analyse effects of change in temperature on the whole atmosphere, you'll need a better model. Maybe considering the atmosphere a non-viscous fluid can help, I don't know. You should research on this.
Note that other approximations like the Van der Waals equation wouldn't help too because they too neglect the effect of gravity.
| 0.777778 |
How to apply an ideal gas approximation to a small system?
|
How do I turn off my Raspberry Pi?
|
Should I just pull the plug? Or is it best if I exit LXDE and any other running processes first?
|
I log into my Pi remotely and here is how I shut it down:
Execute the command: sudo shutdown -h now
Wait until the LEDs stop blinking on the Pi.
Wait an an additional 5 seconds for good measure (optional).
Switch off the powerstrip that the Pi power supply is plugged into.
Since I use a remote display, I don't necessarily see the final output of the Pi in the command window, which is why I use the activity lights. The non-blinking state of the LEDs is not an absolute indication of a complete successful shutdown but it has worked well enough for me. HTH
| 1 |
Shut down the Pi power supply
|
Heathrow Customs - "Arrivals from the EU" exit
|
At Heathrow, after collecting your baggage, there are three exits.
Green - nothing to declare
Red - something to declare (not sure of text)
Blue - arrivals from the EU
What is the blue one for? Is it if you have something to declare, and have come from an EU country? I saw no signage to tell me when I was there last week.
|
You're referring to the three customs exits at Heathrow Airport:
(photo: Diane Phillips)
Blue is for arrivals from the EU with nothing to declare. People who can use this queue will see a green stripe around their luggage tag. Yes, this is slightly confusing.
Green is for arrivals outside the EU with nothing to declare.
These are based on the country where your air journey originated.
Red is for arrivals from anywhere who need to make a customs declaration.
Taken from Heathrow Airport: UK Customs processes at Heathrow
The UK has significantly different procedures for admitting people from the EU and from outside the EU. Since Heathrow has the largest amount of international air traffic of any airport in the world, it's important to not make people wait any longer than necessary. Separating them here helps keep the queues moving faster.
| 1 |
Red is for arrivals from the EU with nothing to declare.
|
Regulator to window glass connection on Toyota Yaris
|
Is it possible to to repair or replace the plastic eyelets which connects the regulator the door glass glass?
|
You can buy the plastic clips on eBay from around £2($4) the pair. The plastic does not stick well enough, even with super glue. Not really a repairable item.
| 0.777778 |
The plastic clips can be bought on eBay from around £2($4)
|
Rename table in sqlite
|
I am trying to rename a table in my app's sqlite database. For that I am using the following command:
ourDatabase.rawQuery("ALTER TABLE " + oldName + " RENAME TO " + newName,
null);
where oldName is old name of the table, newName is the new name of table and ourDatabase is an instance of SQLiteDatabase. But this is not working.
What's the mistake ?
Thanks.
|
Try this:
ALTER TABLE orig_table_name RENAME TO tmp_table_name;
| 0.888889 |
ALTER TABLE orig_table_name
|
Single Sign On with SubDomains
|
Please I would like to know how to implement Single Sign On across subdomains running on a mixture of programming platforms, asp.net and php?
|
I know this is old but I thought I would answer this for others stumbling across this via google search.
For Single Sign On across platforms you probably want to implement a SAML based solution. SAML stands for Security Assertion Markup Language and is an XML based solution. On the side of things you can use an open source library that makes it easier called SimpleSAMLphp (simplesamlphp.org).
I'm not sure if the asp.net side of things has an open source library for you to use but since SAML is an open standard you should be able to do it with pure asp.net.
| 1 |
SimpleSamlphp.org is a SAML based solution .
|
Is catching DocumentException a good idea?
|
I have a utility method which reads an xml file and converts to string as below:
public static String readFile(String xmlFileName) throws IOException, DocumentException{
String xmlMsg = null;
Resource resource = null;
InputStream inputStream = null;
try{
resource = new ClassPathResource(xmlFileName);
inputStream = resource.getInputStream();
SAXReader reader = new SAXReader();
Document doc = reader.read( inputStream );
xmlMsg = doc.asXML();
}finally{
if(inputStream != null){
inputStream.close();
}
}
return xmlMsg;
}
Is it a bad idea if I catch the DocumentException in the above code and rethrow it as below:
public static String readFile(String xmlFileName) throws IOException, DocumentException{
String xmlMsg = null;
Resource resource = null;
InputStream inputStream = null;
try{
resource = new ClassPathResource(xmlFileName);
inputStream = resource.getInputStream();
SAXReader reader = new SAXReader();
Document doc = reader.read( inputStream );
xmlMsg = doc.asXML();
}catch (DocumentException e){
throw new DocumentException("some message");
}finally{
if(inputStream != null){
inputStream.close();
}
}
return xmlMsg;
}
So, is it a bad idea to leave the responsibility of handling the DocumentException to the caller?
|
No, leaving the caller to handle the Exception is fine - throw early catch late.
What I have a problem with is this:
}catch (DocumentException e){
throw new DocumentException("some message");
Why would you catch (DocumentException e) and then throw a new instance that strips out all useful information? You can simply not catch it in the first place and let it percolate up to someone who can handle it.
Also, use Java 7 try-with-resources rather than finally. So, you code should be:
public static String readFile(String xmlFileName) throws IOException, DocumentException {
try (final InputStream is = new ClassPathResource(xmlFileName).getInputStream()) {
final SAXReader reader = new SAXReader();
final Document doc = reader.read(inputStream);
return doc.asXML();
}
}
I have removed the variables that are declared as null then reassigned, I hate this practice and so do many other Java developers - get out of this habit. Declare things when you need them and assign them immediately. In a garbage collected language the principal of minimum scope is very important.
I have also changed it to return directly rather than storing the value for some reason.
| 0.777778 |
Why would you catch DocumentException e and then throw a new instance that strips out useful information?
|
Log In / Sign Up on Splash screen?
|
Is it common to include Login / Sign Up actions on an app's splash screen? Or is it more efficient to first have a Splash screen, and then follow with a dedicated Log In / Sign Up page?
|
SIGN-UP should be first and big, because you want to acquire new customers, Sign-in is for regulars, used to the interface (upper-right corner), they know exactly where it is and most probable a cookie is giving them access anyway.
A great example of this is Digital Ocean homepage
https://www.digitalocean.com/
| 1 |
Sign-in is for regulars, used to the interface (upper-right corner), they know exactly where it is and most probable a
|
Why would we need to ground an AC source?
|
I'm new to this field hence this weird question. Why would we need to ground an AC source? Why wouldn't it be enough to have just one pole to get an AC current going? I understand why it wouldn't work in DC case where current is flowing in one direction. However, in case of AC source where the current is not flowing anywhere but rather just oscillating back and forth it's not that clear to me why connecting load to only one pole wouldn't work?
|
Electric circuits are always a complete path, which is the very definition of circuit. In a DC circuit, current flows from one pole to another in a constant, direct manner. In an AC circuit, current also flows from one pole to another, but it changes voltage and direction many times per second. (With mains power, this is 50 or 60 times per second, depending on where you live.)
It's not correct to say that with an AC source "current is not flowing anywhere but rather just oscillating back and forth." Current is flowing, but it is changing direction rapidly.
Let's take a moment and do an analogy - mind you, not a great analogy, but one I think that may help. Take a band saw for example. There is a metal blade with teeth that is essentially a ring (a band, which is where the tool gets its name) wrapped around two drums. When you turn on the saw, the blade moves in one direction, and you pass material into the blade to cut. You can think of the band as direct current, always moving in one direction, making a complete circuit.
If you think of a hand saw, where you oscillate the blade back and forth, the analogy falls apart, because there is not a complete circuit. In order for electric current to flow, there must be a complete circuit. It may be that this sort of idea is what has confused you with regard to alternating current. Because it is possible to move a saw blade by only acting on it from one side, you might assume a similar effect could be achieved with electric current.
Instead, imagine that the blade must always be continuous, thus we're back to the band saw. This time, let's say the tool moves the blade up and down (like a jig saw) and the teeth on the blade are modified to cut in both directions. You can still pass material into the blade to cut, but you're always cutting with the same section of blade, assuming that the movement in each direction is the same. Each time the blade moves up, it has to stop and reverse direction. The same is true with the downward cut. Think of these momentary stops as the point at which the AC voltage source is at 0 volts (the zero crossing).
Unlike a battery, an AC voltage source is always changing the voltage potential of the two poles, in an equal and opposite manner. When one pole is at a positive voltage, the other pole (with respect to the first) is at a negative voltage. As the voltage of one pole changes, the other is mirroring it. Current flows from one to the other, always.
Now about that ground thing... When you consider an AC source and a load, you basically have two connections. One pole to one side of a load, and the other pole to the other side of the load. Neither pole is really ground, because they're both just opposite sides of the AC source. You can call one of them ground, but realize that doing so is just a reference. If you decide that pole "B" is "ground" then you're essentially saying all voltage measurements should be with respect to that pole. If you were to measure any part of the circuit with a voltmeter, you would connect the black probe to the wire you've labeled as "ground" and all readings would be based on that as a reference.
In most household electrical circuits and appliances, ground is actually a third wire. The two poles I mentioned earlier are called "hot" and "neutral" (black and white wires in the US), and "ground" is the bare copper wire (or often green). The purpose for this ground is safety. A simple appliance might have a metal enclosure, which is connected to ground. Hot and neutral enter the appliance to power it. If something were to go wrong, like a wire came loose inside, if the chassis were not grounded, touching it could result in an electric shock. Having the chassis grounded instead diverts current back to Earth ground, usually in a very abrupt manner, such that the circuit breaker trips and power is cut off.
Mind you, this is a simplified explanation, but I hope it helps you understand the basic concept of AC and to differentiate between what constitutes the wires of the circuit and ground both as a concept and a physical connection.
For more in-depth information about AC, check out this article at allaboutcircuits.com.
| 1 |
Electric circuits are always a complete path, which is the very definition of circuit .
|
Insufficient information to create shipping label(s) Magento Enterprise
|
I am using Magento Enterprise 1.14.0.1
I have Fedex Shiiping method activated and have entered in the information for production that was provided and confirmed by Fedex to be correct for the account ID, Meter, Password, and the key. I have sandbox set to no since the credentials are for production. I have a Max package weight set packaging set to "Your Packaging" and the "drop off" set to regular pickup as we have a driver that comes everyday.
My issue is when I click the button to create a shipment and then enter the total weight and then add the product and click the check box and add the product to the shipment. I then click OK and get an error message that says
Insufficient information to create shipping label(s). Please verify your Store Information and Shipping Settings.
I do not know what to check to fix this.
|
Magento requires the shipping information to be in the Shipping Settings.Your store also needs the phone number filled in, plus the store’s City, State (Region), Zip/postal, Country, and store name. Any of those missing may have caused the error you see. This solved for me. Check here
| 0.888889 |
Magento requires the shipping information to be in Shipping Settings
|
Hibernate does not allow an embedded object with an int field to be null?
|
Hibernate does not allow me to persist an object that contains an null embedded object with an integer field. For example, if I have a class called Thing that looks like this
@Entity
public class Thing {
@Id
public String id;
public Part part;
}
where Part is an embeddable class that looks like this
@Embeddable
public class Part {
public String a;
public int b;
}
then trying to persist a Thing object with a null Part causes Hibernate to throw an Exception. In particular, this code
Thing th = new Thing();
th.id = "thing.1";
th.part = null;
session.saveOrUpdate(th);
causes Hibernate to throw this Exception
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.ace.moab.api.jobs.Thing.part
My guess is that this is happening because Part is an embedded class and so Part.a and Part.b are simply columns in the Thing database table. Since the Thing.part is null Hibernate wants to set the Part.a and Part.b column values to null for the row for thing.1. However, Part.b is an integer and Hibernate will not allow integer columns in the database to be null. This is what causes the Exception, right?
So I am looking for workarounds for this problem. I noticed making Part.b an Integer instead of an int seems to work, but for reasons I won't bore you with this is not a good option for us. Thanks!
|
I found another workaround and thought I'd share it. Turns out that if you make the int column nullable then Hibernate doesn't throw the PropertyValueException.
@Column(nullable = true)
public int b;
This works for us because our hibernate enabled application is the only thing that touched the database and so we can guarantee that b is null only when the part is null. Although the null part suggestion and the use of the Integer wrapper type are great suggestions, due to lots of reasons I don't really have control over, setting the column to nullable works best for us. Thanks though and I hope this helps someone else.
| 0.333333 |
Hibernate doesn't throw PropertyValueException in int column
|
form save progress indication
|
In our app, when you save/submit a form, two things happen
submit button greys out(becomes disabled)
there's a progress bar running at the top of the page(similar to medium.com), which is an indicator used across the app for an ongoing action(not limited only to saving forms, since it's an SPA app)
Do you think it's clear enough for the user that things are being saved, or it would be better to add a loader directly associated with the form(inside the button for example)?
Here's what it looks like at the moment.
https://youtu.be/xzc7P8R751M
|
I had similar issue. Saveing was usualy 0.2s but in some cases it was takeing aprox 4-6s.
What was done:
- click green "save" button
- button goes gray with spinner and text "saving"
- when done buttons goes green with "done"
Progress bar is nice solution... but only when you are able to determine the end of process.
Your loading is overwhelming. But still it is good to show it if it takes time, maybe not so big. Also a lot of things happens in the top: yellow bar disappears, orange notify goes down and "loading" disappears - like in action movie:)
| 1 |
Saveing was usualy 0.2s but in some cases it was taking 4-6s
|
Database table structure for storing SSO information for FB or Google+
|
I have a web application that I would like to add single sign on capability using user's Facebook or Google+/Google App account.
I have a USERS table that stores users login information. All users are required to have a record in this table no matter if they signed up using FB or Google+.
I am trying to figure out the information that I need to store in the database in order to link USERS table records to FB or Google information.
Facebook documentation states:
the app should store the token in a database along with the user_id
to identify it.
So should I create a table called SSO_LOOKUP with following columns:
USER_ID // user's id that links to my USER table
PROVIDER_ID // user's FB or Google account id
PROVIDER_TYPE // indicates if it is Google, FB, Twitter, etc.
ACCESS_TOKEN
|
For SSO login definitely you need to have your user_id and some basic details which allow you to connect to FB or google
provider: "it will be either FB or Google or anything in future"
token: "This token we receive from FB and Google. In case of FB it
expires after 3 months or so where as it does not expire for google
as per my knowledge"
token_expired:" As In FB token expires after a time so you can have
this flag in place if you need to refresh it after that duration"
user_id: "This is your User id:
uniqueid: "This is the Unique ID which you will get from FB and Google.
That helps to identify your user in FB/Google"
These are the minimum fields you can add and these will even help you to scale your app. In the sense if you want to pull or push data from google and FB at that time Access_token and unique_id will help you.
Also incase you want to see some publish source then you can see some of the code on github e.g.
django-social-auth
For some details you can refer google documentation and Google OAuth2
Hope this will help.
| 0.888889 |
FB token expires after 3 months or so
|
How to show the integers have same cardinality as the natural numbers?
|
How would I show the following have a bijection. Which is one to one and onto ofcourse.
$\mathbb{Z}\rightarrow \mathbb{N}$
I know I need to find a function. But I do not see the pattern that makes integer go to natural. I already did this problem from natural to integer but now I want to see it done this way.
I have listed some numbers
$,..,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,..$
$1,2,3,4,5,6,7,8,9,10,11,12,13,14,.$
|
Your list has absolutely no pattern, because you're doing it "wrong", in the sense that you are not writing it in a way that a pattern emerges.
Of course there is no order preserving function, so writing both sets with their natural order will promise you that there is no reasonable pattern. Instead write the natural numbers, and then try to write the integers:
$$\begin{array}
& 1 & 2& 3& 4& 5& 6& 7& 8&\ldots\\
0 & 1& -1& 2& -2& 3& -3& 4&\ldots
\end{array}$$
This gives rise to a bijection from $\Bbb N$ onto $\Bbb Z$. Now just find its inverse.
(Note that it is in general easier to find "pattern" when $\Bbb N$ is the domain, because the list does not require you to go into two directions.)
| 0.666667 |
Write the natural numbers and then write the integers .
|
Preventing player passivity in GUMSHOE?
|
I really like the game worlds of the various GUMSHOE games I have (Fear Itself, Esoterrorists, Mutant City Blues) but haven't run it yet. My big concern is that I've seen the "ablative skill system" kind of mechanic work very poorly in other games - players hoard their "uses," or use them all and then sit on their hands during the latter part of the game session because they know they're not going to be able to succeed at anything and trying will just get them killed.
In GUMSHOE, your skills are a "pool" of points that you spend either for benefits or for adds to the dice when testing. You basically roll d6 + spend vs a difficulty, typically 4 for general stuff but often going higher. Fighting works the same way, so if you have a Scuffling pool of 8, once you've used them all, you know you won't live through any meaningful combat.
For those that have run GUMSHOE or similar ablative systems, do you find that happening, and what are ways to avoid it? I mean, I don't mind trying to capture the "downward spiral" but it risks characters just checking out if they don't think whatever plot is at hand is really worth all their lives. "Let's try to save her next session..."
|
It seems to me that there are a number of things that you could do to help ameliorate this sort of risk.
The first would be to allow ablative skills to regenerate more frequently rather than just at the start of a session. If you intend to have a couple of scenes in a session which require the same skills (such as a combat), allow the PCs to regenerate their skills between. This would allow for the drama of getting tired (running out of points) during a scene, without that scene affecting others. Depending on how finely tuned GUMSHOE is however, this could be unbalancing.
Another option would be to reward ingenuity, good tactics, good role-playing or heroism etc. with point pool replenishments after or even during the scene. Since it's more under your control, it should be less prone to unbalancing the game.
I have seen this sort of thing with players in card based systems like SAGA, but only with relatively new players. Once you've played SAGA for a while you realise that the best thing you can do with a hand of low cards is to play them and hope to draw better cards, so any solution to this problem is likely to involve players being encouraged to be more active, more inventive, more dramatic when they get down to fewer pool points.
I know my thoughts are rather general, since I haven't played GUMSHOE, but I hope they were useful nevertheless.
| 1 |
a number of things that you could do to help alleviate this sort of risk .
|
Double urn probability and multiple instances
|
I've got a probability problem based on the following problem.
I provided some scenarios which I need to solve but I'm thankful for any hints or links on how to solve just one of them or how to described this scenario (and/or solutions) in proper 'mathematical notaion'
The Problem:
An urn contains 10 balls numbered from 1 to 10, every number occurs excactly once.
Person A picks balls from the urne and distributes the balls randomly among 4 other persons, say persons B, C, D and E (it is not neccessary for every person to get the same amount of balls).
After the distribution process, person C picks $N$ ball(s) from its own urn, which holds another 10 balls, again numbered from 1 to 10.
What is the probability that person C received one or more balls from person A which have the same number as the ball(s) person C just picked from its own urn?
Some scenarios:
Scenario 1: Person C received one ball with nr.7. What is the probability that person C picks the ball with the same number (7) from its own urn?
Scenario 2: Person C received two balls with nr.7 and nr.8. What is the probability that person C picks the same two balls (7 and 8) from its own urn?
Scenario 3: Person C received two balls with nr.7 and nr.8. What is the probability that person C picks one ball from its own urn which number is either 7 or 8?
Scenario 4: Person C received one ball with nr.7. What is the probability that person C picks two balls of its own urn out of which one is ball nr.7?
Scenario 5: Person C received one ball with nr.7 and person D received three other balls, say balls 4, 5 and 6. What is the probability that person C picks one ball from its own urn which number is either 4, 5, 6 or 7? (Person C and person D are merged, they count as one)
|
For the general question, assuming picks are without replacement:
for each numbered ball picked by C from their own urn, the probability C did not get that numbered ball from A is $\displaystyle \frac34$ (i.e. it went to B, D or E),
so the probability of no matches is $\displaystyle \left(\frac34\right)^N$,
the probability of at least one match is $\displaystyle 1-\left(\frac34\right)^N$ and
the probability of $n$ matches is $\displaystyle {N \choose n}\frac{3^{N-n}}{4^N}$.
For the scenarios the numbered balls received by C from A are determined by the scenario, so:
if C picks one from ten balls, the probability it is number $7$ is $\dfrac{1}{10}$
if C picks two from ten balls, the probability they are numbers $7$ and $8$ is $\dfrac{1}{45}$
if C picks two from ten balls, the probability exactly one is number $7$ or $8$ is $\dfrac{16}{45}$, and the probability at least one is number $7$ or $8$ is $\dfrac{17}{45}$
if C picks two from ten balls, the probability one is number $7$ is $\dfrac{1}{5}$
if C picks one from ten balls, the probability it is numbers $4$, $5$, $6$ or $7$ is $\dfrac{2}{5}$
| 1 |
The probability of no matches is $displaystyle frac34$ if C picks one from ten balls .
|
When 'business' means a 'company', how do I use the word?
|
Business can sometimes mean company or firm. However, can it be used in the way company or firm are used?
For example, can I say:-
"He is the CEO of the business."
"It's a TV business."
"A business dealing with drugs."
|
You could say all of those things in certain contexts. It would depend on what went before and what came after.
| 1 |
What went before and what came after?
|
Is the Panamatic any good?
|
Is the Lenspen Panamatic of any real use for creating panoramic shots or is it a waste of money?
More product details
|
I've never used one, but as far as I can tell it's just a bubble level combined with a device to click through increments of 15 degrees or so.
If my job was shooting panoramas all day long then it might make the process a little less laborious, but if you're taking time of the composition, lighting and camera settings for your panorama then lining the shots up shouldn't take too much effort.
I normally line up landmarks against the focus points to ensure a consistent overlap. Spirit levels can be useful, but if you don't have one shoot the first and last image of the panorama as a test to check your tripod is level.
| 0.888889 |
lining up the shots should not take too much effort .
|
Informix Query Where Clause
|
Help All,
I am writing a query in Informix and have been stuck on the where clause. I have 2 CSQnames that I want to select and certain times and all others I want to show in between another time. My query ran perfectly until I added this specific where statement. If anyone can offer suggestions I would really appreciate it. I am getting a general error. In Informix since I am unable to put a if then statement in the where clause how would I rewrite my syntax? Thanks!
SELECT
(ccd.nodeid||"-"||ccd.sessionid||"-"||ccd.sessionseqnum) as sequenceID,
ccd.sessionid as sessionid,
ccd.sessionseqnum as sequencenum,
ccd.applicationName as AppName,
csqname as CSQName, ccd.flowout, ccd.conference,
CASE WHEN contacttype=1 THEN "Incoming"
WHEN contacttype=2 THEN "Outgoing"
WHEN contacttype=3 THEN "In House"
WHEN contacttype=4 THEN "Redirect In"
WHEN contacttype=5 THEN "Transfer In"
END as ContactType,
CASE WHEN contactdisposition = 1 THEN "Abandoned"
WHEN contactdisposition = 2 THEN "Handled"
WHEN contactdisposition = 4 THEN "Aborted"
WHEN contactdisposition >= 5 THEN "Rejected"
END as ContactDisposition,
CASE WHEN originatortype=1 THEN "Agent"
WHEN originatortype=2 THEN "Device"
ELSE "Unknown"
END as OriginatorType,
CASE WHEN destinationtype=1 THEN "Agent"
WHEN destinationtype=2 THEN "Device"
ELSE "Unknown"
END as DestinationType,
DATE(ccd.startdatetime) as date,
ccd.startdatetime as starttime,
ccd.enddatetime as endtime,
res.resourcename, ccd.transfer, ccd.redirect,
ccd.originatordn, ccd.destinationdn,
crd.queuetime/86400 as queuetime,
acd.talktime/86400 as TalkTime,
acd.holdtime/86400 as HoldTime,
acd.worktime/86400 as WorkTime
FROM contactcalldetail ccd
Left JOIN contactroutingdetail crd ON crd.sessionID = ccd.sessionID
AND crd.sessionSeqNum = ccd.sessionSeqNum
AND crd.nodeID = ccd.nodeID
AND crd.profileID = ccd.profileID
LEFT JOIN agentconnectiondetail acd ON acd.sessionID = ccd.sessionID
AND acd.sessionSeqNum = ccd.sessionSeqNum
AND acd.nodeID = ccd.nodeID
AND acd.profileID = ccd.profileID
LEFT JOIN resource res ON acd.resourceid = res.resourceid
left join contactqueuedetail cqd on cqd.sessionid=crd.sessionid
left join contactservicequeue csq on cqd.targetid= csq.recordid
WHERE (
ccd.startdatetime BETWEEN '2014-1-2 13:00:00' AND '2016-12-31 22:30:00'
AND (
if (csqname in ("CSQ_Emeriti" , "SOS-Emeriti")
AND EXTEND(ccd.startdatetime, HOUR TO second) > DATETIME(13:30:00) HOUR TO SECOND
AND EXTEND(ccd.startdatetime, HOUR TO second) < DATETIME(22:00:00) HOUR TO SECOND
)
or(csqname not in (“CSQ_Emeriti" , "SOS-Emeriti")
AND
EXTEND(ccd.startdatetime, HOUR TO second) > DATETIME(13:00:00) HOUR TO SECOND
AND EXTEND(ccd.startdatetime, HOUR TO second) < DATETIME(22:30:00) HOUR TO SECOND
)
)
AND WEEKDAY(ccd.startdatetime) BETWEEN 1 AND 5
AND (contacttype IN (1,4,5))
AND ccd.originatordn !='2155870700'
)
|
If the query is on Informix, if is not available in the WHERE clause of SQL Statement.
If I understood you correctly what you want is:
...
AND (
(
csqname in ("CSQ_Emeriti" , "SOS-Emeriti")
AND EXTEND(ccd.startdatetime, HOUR TO second) > DATETIME(13:30:00) HOUR TO SECOND
AND EXTEND(ccd.startdatetime, HOUR TO second) < DATETIME(22:00:00) HOUR TO SECOND
)
OR
(
csqname not in ("CSQ_Emeriti" , "SOS-Emeriti")
AND EXTEND(ccd.startdatetime, HOUR TO second) > DATETIME(13:00:00) HOUR TO SECOND
AND EXTEND(ccd.startdatetime, HOUR TO second) < DATETIME(22:30:00) HOUR TO SECOND
)
)
...
Keen regards.
| 0.777778 |
If the query is on Informix, if is not available in SQL Statement
|
Measuring Resistance of a Wire With an ADC
|
I'm trying to design a circuit which can measure small resistances down to 0.1 Ohm and a max. of 10 Ohms. I won't be measuring actual resistors but rather large coil of wires, upto 500 m (as you can imagine, these wires are quite thick).
Here's the circuit I came up with:
The circuit works by maintaining a constant current through the device under test, R2. With a current of 100 mA, R2 would develop a voltage between 10 mV to 50 mV.
I think in an ideal world this would work but in practice I may have a hard time measuring 0.1 Ohms with this - mainly due to the ADC. Let's assume the ADC is 10-bit with VREF of 5V. This translates to 5mV per step. If R2 = 0.1 and Iout = 100 mA, then the voltage present at the ADC would be 50 mV - but I'm not sure how buried under noise this would be.
My question is, should I increase the gain to, say, 50. If the gain is 50, then the voltage present at the ADC would be 500 mV - but the max. measurable resistance would be 1 Ohms. To measure 10 Ohms, I would need to lower the current to 10 mA instead of 100 mA. A way to do that would be use an FET to switch out R1 and connect a 20 Ohm resistor at Iout.
I don't need the circuit to measure the resistance precisely - a tolerance of +/- 10% is fine.
|
Please, don't use an LM324 if you want to do precision measurements.
Your opamp has a gain of 5, but you're not using that: Your output is the inverting input, where you have the same signal as the non-inverting, so that's gain x 1.
The best choice would be an instrumentation amplifier, where you connect the cable's ends to the two inputs. Use a series resistor to ground to create an offset, because InAmps can't go to the rails (at least the 3-opamp types can't). You can use that resistor as a sense resistor for the current source:
\$V_{IN}\$ sets the current of the current source: 100 mA/V. Suppose the cable's resistance is 5 Ω, then the InAmp will see a 500 mV difference on its input. A gain of 10 (gain resistor isn't shown; CircuitLab doesn't have a symbol for InAmps) will give you 5 V out, or 1 V/Ω. By changing \$V_{IN}\$ you can change the total gain. Note that Q1 may need a heatsink, especially if Vcc is rather high.
If you expect high resistances you can make a resistor divider with 1 precision resistor to Vref, and one to ground:
The voltage across the cable will be
\$ V_{CABLE} = \dfrac{R_{CABLE}}{R_{CABLE} + 2 R} V_{REF} \$
but if \$R_{CABLE}\$ << \$2 R\$ the voltage may be too low for an accurate measurement. A low value for \$R\$ helps, but will draw much current.
The MCP6N11 has Rail-to-Rail output and exists in different types for different gains, among which one for a gain of minimum 100.
edit
markrages comments that we don't need an InAmp, and he's right. Here's the solution with a differential amplifier using an opamp:
The gain is determined by R1 through R4, and if R1 = R3 and R2 = R4 will be
\$ G = \dfrac{R2}{R1}\$
An InAmp will give you more precision though, and it won't cost you an arm and a leg, so why not?
| 0.666667 |
InAmps can't go to the rails (at least the 3-opamp types cannot't)
|
Search predictions broken in Chrome - reinstall didn't solve the problem
|
I recently changed the default search engine to a custom google search URL (using baseUrl) with some additional parameters and removed all the rest of the search engines, and since then, the search predictions stopped working.
I even tried to reinstall Chrome but as soon as I resync, the problem is back!
Search predictions are just gone without option to fix!!
In IE changing the search provider allows specifying a prediction (suggestion) provider, In chrome, once you change the default search engine, you'll never be able to have predictions again!!
This is a terrible bug, I mean WTF!!!
Is there any workaround to that?
I posted a bug report a while ago but it seems no one looks at it. I'm about to give up on Chrome and go back to IE, the only good thing about Chrome is the Extension market and the AdBlocker (which I can find in IE as well). The perfrormance changes don't matter to me too much.
Thanks
|
Goto:
Stop sync and remove all of your
synced data.
After relaunching Chrome, the problem should be solved.
| 0.888889 |
Goto: Stop sync and remove all of your synced data
|
Is it okay to vacuum a laptop keyboard?
|
Is it okay to vacuum a laptop keyboard? Would it cause any damage?
|
There are small (usually USB-powered) vacuums that you can use that do not generate enough force, nor have large enough intakes, to suck the keys of the board.
Most laptops keyboards have pop-off keys and a normal vacuum will take those keys right off. Those that have what are sometimes called "chiclet" keys do not generally pop off and should be safe from this particular hazard.
However, a more serious problem is the static charge that the friction from the airflow will create. For this reason it is never recommended to use a normal vacuum for cleaning any computer, ever. Canned air does not create this problem, and there are special electronics vacuums that are properly grounded and use other special components that are much less likely to generate enough of a static charge to damage the sensitive electronic components in a computer. Even these electronics vacuums, though, have no protection against sucking keys off keyboards.
For these reasons, I would recommend against using a vacuum to clean any part of any computer. Canned air should be sufficient for your needs. It's also cheap.
| 0.888889 |
Canned air does not create static charge on keyboards .
|
Are mutliple database calls really significant with a network call for a web API?
|
At one of my employers, we worked on a REST (but it also applies to SOAP) API. The client, which is the application UI, would make calls over the web (LAN in typical production deployments) to the API. The API would make calls to the database.
One theme that recurs in our discussions is performance: some people on the team believe that you should not have multiple database calls (usually reads) from a single API call because of performance; you should optimize them so that each API call has only (exactly) one database call.
But is that really important? Consider that the UI has to make a network call to the API; that's pretty big (order of magnitude of milliseconds). Databases are optimized to keep things in memory and execute reads very, very quickly (eg. SQL Server loads and keeps everything in RAM and consumes almost all your free RAM if it can).
TLDR: Is it really significant to worry about multiple database calls when we are already making a network call over the LAN? If so, why?
To be clear, I'm talking about order of magnitude -- I know that it depends on specifics (machine hardware, choice of API and DB, etc.) If I have a call that takes O(milliseconds), does optimizing for DB calls that take an order of magnitude less, actually matter? Or is there more to the problem than this?
Edit: for posterity, I think it's quite ridiculous to make claims that we need to improve performance by combining database calls under these circumstances -- especially with a lack of profiling. However, it's not my decision whether we do this or not; I want to know what the rationale is behind thinking this is a correct way of optimizing web API calls.
|
We have a couple of applications which are very, very chatty. There is a database call for every. Single. Little. Thing. Serving reference data again and again and again is a major part of the workload on the system. All that scheduling of worker threads, acquiring and dropping locks, plan cache checking etc. adds up even if there is not actual disk IO. Contention is higher because transactions have to hold locks across multiple DB calls and so throughput is much lower than it could be. Those teams are now looking at having to buy new, very expensive DB servers because of this.
So, although the majority of the elapsed time in your system's current configuration is taken with REST API calls, ignoring performance at the DB level is storing problems for the future.
| 0.888889 |
Database call for every. Single. Little. Thing. Serving reference data
|
Who counters Jayce top lane besides Yorick?
|
I'm aware that Yorick and Cho'Gath are both good counters for Jayce (in Top Lane) but who else might be a good matchup and why?
|
My personal opinion, and this is from playing both champs in question, is dont pick Jax vs Jayce. Most Jax players Leap strike in, only to get knocked away immediately, and then a quick switch into ranged mode from Jayce takes down their health. If Jax uses a Counter Strike + Leap Strike combo for an instant stun, then he is open for +/- 20 seconds, and Jayce can just combo chain abilities to nuke him. Short of a Jax combo including Flash/Exhaust, Jayce should win the lane phase. Try Malphite/Lee instead.
| 1 |
Jax vs Jayce
|
How to prevent the "Too awesome to use" syndrome
|
When you give the player a rare but powerful item which can only be used once but is never really required to proceed, most players will not use it at all, because they are waiting for the perfect moment. But even when this moment comes, they will still be reluctant to use it, because there might be an even better moment later. So they keep hoarding it for a moment which will never come.
In the end, they will carry the item around until it is outclassed by other, more readily available resources, or even until the very end of the game. That means that such one-shot items don't provide any gameplay-value at all. They are simply too awesome to use.
What can you do to encourage the player to make use of their one-shot items and not hoard them?
|
Short Answer:
Have something more valuable than the item that the player can lose if they hesitate to use the item. EG You might use your single-use invincibility potion to save you from death in a game where death is permanent.
Long Answer:
I think the only games in which such an item can work are ones where there is some form of persistent punishment for failure: Things like permadeath, loss of money/exp/stats on death, limited lives before having to restart the game (that's pretty outdated, but whatever). So when the player gets stuck or comes up against a challenge that they are likely to fail, they have an incentive to skip part or all of this challenge using the super item.
You could look at a lot of old arcade shooters, where you where often given about 3 bombs to use per life and could not recover any more. Bombs where valuable, but not as valuable as lives. Players would never use them unless it was necessary, but they wouldn't hesitate if they thought it would prevent them from dying. The same principle can be applied to single-use items, as long as there is something more valuable that the use of such an item can protect.
In a lot of games, failure is not really penalized and therefore there is no reason to use rare resources. There is no reason to use limited resources to prevent the loss of a life when you have infinite lives. I suppose you could add a particular encounter to the game that forces the items use (like the Master Ball in pokemon), but that can fall into guide dang it territory.
Making the game more difficult is not a solution, as players will not have the item for the vast majority of their playtime. "If this is hard now, I should save the super-weapon for when it's even worse!"
EDIT: As zzzzBov points out below, you could also make the item itself disappear upon death. Which would certainly make players more likely to use it.
| 0.777778 |
How to use a single-use invincibility potion to prevent death?
|
Array Binding simple example doesn't work
|
I'm very new to xaml and I'm trying to understand the Binding issue. I have a problem with the Array Binding. I created this very simple example: I have a stack panel with three images. Each image has a RotationTransform. Each Angle is obtained by an array element (the array is a DependencyProperty called Rotations). This is the xaml simple file:
<StackPanel Orientation="Vertical">
<Image Source="/Assets/knife.png" Width="50" Height="100" Stretch="Uniform" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform Angle="{Binding ElementName=pageRoot, Path=Rotations[0], Mode=OneWay}"/>
</Image.RenderTransform>
</Image>
<Image Source="/Assets/fork.png" Width="50" Height="100" Stretch="Uniform" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform Angle="{Binding ElementName=pageRoot, Path=Rotations[1], Mode=OneWay}"/>
</Image.RenderTransform>
</Image>
<Image Source="/Assets/spoon.png" Width="50" Height="100" Stretch="Uniform" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform Angle="{Binding ElementName=pageRoot, Path=Rotations[2], Mode=OneWay}"/>
</Image.RenderTransform>
</Image>
<Button x:Name="actionButton" Content="Try Binding!"
Click="Op_Click"/>
</StackPanel>
And this is my c# class:
public sealed partial class MainPage : Page
{
public static readonly DependencyProperty RotationsProperty = DependencyProperty.Register("Rotations", typeof(double[]), typeof(MainPage),
new PropertyMetadata(new double[3]));
public double[] Rotations
{
get { return (double[])GetValue(RotationsProperty); }
set { SetValue(RotationsProperty, value); }
}
private void Op_Click(object sender, RoutedEventArgs e)
{
Rotations[0] = 180;
Rotations[1] = 130;
Rotations[2] = 350;
}
public MainPage()
{
this.InitializeComponent();
Rotations[0] = 20;
Rotations[1] = 90;
Rotations[2] = 180;
}
}
The binding works only the first time (at startup time). When I click on the button (changing the Rotations array) the binding doesn't work and it is completely ignored from my images.
This is a very simple example, so it's clear that I miss something concerning the Binding issue.
|
I guess the problem is that you change the value of the array entries, but you don't change the array itself, so 'SetValue' does not get called. You could try to set 'Rotations' to a new array.
this.Rotations = new double[] {180, 130, 350};
Edit: I tested your code with my changes and it worked. Another suggestion would be to write a setter method for the array entries and call 'SetValue' or (like suggested in the comments) use 'INotifyPropertyChanged' instead of a DependencyProperty.
| 0.888889 |
Setting 'Rotations' to new array
|
why ions and electrons are at different temperatures in plasma?
|
In plasma, collision rate among ions or electrons is much larger than the collision rate between ions and electrons. why is that so?
|
There are lots of different types of plasmas.
In a thermal plasma the electrons and ions will have the same temperature.
In a non-thermal plasma the discharge is driven by some external power supply e.g. capacitatively coupled RF, inductively coupled, pulsed DC E field etc.
In a non-thermal plasma the electrons generally have a higher temperature than the ions because the energy from the RF or E field couples with the electrons more efficiently. The electrons transfer energy to the gas to sustain the plasma.
Strictly speaking non-thermal plasmas are not at equilibrium and we cannot necessarily define a temperature, but temperature is generally a useful concept to use.
Collision rates are generally lower for electrons than ions, but not always (e.g. very low energy electrons and SF6 has huge collision rate).
The reason for the temperature difference is due partly to the driving energy being mostly coupled to the electrons and the partly because the energy is not rapidly transfered by collisions to the neutral gas and ions.
| 0.888889 |
In a thermal plasma the electrons and ions have the same temperature .
|
Get IP network range after reverse DNS?
|
For analytics purposes, I'm looking at large sets of IP addresses in server log files. I'm trying to perform reverse-DNS lookups to understand where traffic is coming from - e.g. what percentage of IPs resolve to corporations, schools, government, international etc.
Despite a bunch of optimizations, individually reverse-DNS'ing every IP address still appears to be fairly expensive though. So -
is there any way to obtain an entire range of IPs from a reverse-DNS?
If yes, this could greatly reduce the number of actual reverse-DNS lookups.
Example (numbers slightly obfuscated):
Log file contains a request from an IP 128.151.162.17
Reverse DNS resolves to 11.142.152.128.in-addr.arpa 21599 IN PTR alamo.ceas.rochester.edu
(So this is a visitor from Rochester University, rochester.edu)
Now, would it be safe to assume that all at least all IPs from 128.151.162.* will also resolve to rochester.edu?
What about 128.151.*.*? Is there a way to get the exact IP range?
|
You can generally get info about netblocks from whois (eg whois 128.151.162.17 refers to CIDR: 128.151.0.0/16), but you'll probably find that there's some variation in the format of the responses you get depending on which registry is involved, and also that whois servers are likely to cap the number of requests you can make. Also note that netblocks are typically nested with smaller ones inside larger ones, and so you may get info about multiple netblocks for one IP.
A DNS request packet can contain multiple requests, which may speed things up if you need to resolve a lot of requests, but the main techniques you need are to paralellise requests, and to cache responses.
| 1 |
How to get info about netblocks from whois?
|
EBS volume on AWS
|
I had an EBS volume of 30GB that was mounted as the rootfs for a ubuntu server. Due to space concerns I had to increase the size of the volume to 50. So I carried out the following steps:
Take a snapshot of the EBS volume.
Created a new EBS volume of 50GB.
Restored the snapshot to the new volume.
Power off my EC2 instance.
Unmounted my old volume and mounted my new volume.
Every thing works fine. But when I do a df -h I get this:
Filesystem Size Used Avail Use% Mounted on
rootfs 30G 27G 1.1G 97% /
devtmpfs 1.9G 112K 1.9G 1% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/xvde1 30G 27G 1.1G 97% /
And when I do fdisk -l I get this:
Disk /dev/xvde1: 53.7 GB, 53687091200 bytes.
Could some one help me with this?
|
Run this line to fix this issue!
resize2fs /dev/xvde1
| 0.777778 |
resize2fs /dev/xvde1
|
how to convert xml to database table
|
input:
Declare @OUT xml
select @OUT = N'
<row>
<kind>MainCat</kind>
<sortid>1</sortid>
<kind_id>1</kind_id>
<PPoet>حافظ</PPoet>
<MTitle>حافظ</MTitle>
<Row>1</Row>
</row>'
select T.X.value('@Kind', 'nvarchar(50)') as kind,
T.X.value('@sortid', 'int') as sortid
from @out.nodes('/row') as T(X)
this select return NULL!
|
Very close:
select
T.X.value('./kind[1]', 'nvarchar(50)') as kind,
T.X.value('./sortid[1]', 'int') as sortid
from @out.nodes('/row') as T(X);
| 0.777778 |
select T.X.value('./kind[1]', 'nvarchar(50)') as kind,
|
The number of row value expressions in the INSERT statement exceeds the maximum allowed number of 1000 row values
|
One of INSERT INTO script is written as following.
INSERT INTO tableName (Column1, Column2,....) VALUES (value1, Value2,...), (value1, Value2,...),....
Following is the error we are facing on parsing above insert statement
Msg 10738, Level 15, State 1, Line 1007
The number of row value expressions in the INSERT statement exceeds the maximum allowed number of 1000 row values.
My simple question is that, Can we change 1000 values limit ?
|
No. This hard-coded restriction exists for good reasons related to possible excessive query plan compilation time. You can workaround it by listing the VALUES clauses in a CTE, then INSERTing from the CTE, but I do not recommend it.
Break the INSERT statement up into VALUES clauses of <= 1,000 lines each as a workaround, or use an alternative data loading method such as bcp or BULK INSERT. The fundamental issue may be addressed in a future version of SQL Server. See also Martin Smith's great answer on Stack Overflow.
Not-recommended workaround:
DECLARE @T AS table (c1 int);
-- Error 10738
INSERT @T (c1)
VALUES
(1),
(2),
(3),
(4),
(5),
(6),
(7),
(8),
(9),
(10),
(11),
(12),
(13),
(14),
(15),
(16),
(17),
(18),
(19),
(20),
(21),
(22),
(23),
(24),
(25),
(26),
(27),
(28),
(29),
(30),
(31),
(32),
(33),
(34),
(35),
(36),
(37),
(38),
(39),
(40),
(41),
(42),
(43),
(44),
(45),
(46),
(47),
(48),
(49),
(50),
(51),
(52),
(53),
(54),
(55),
(56),
(57),
(58),
(59),
(60),
(61),
(62),
(63),
(64),
(65),
(66),
(67),
(68),
(69),
(70),
(71),
(72),
(73),
(74),
(75),
(76),
(77),
(78),
(79),
(80),
(81),
(82),
(83),
(84),
(85),
(86),
(87),
(88),
(89),
(90),
(91),
(92),
(93),
(94),
(95),
(96),
(97),
(98),
(99),
(100),
(101),
(102),
(103),
(104),
(105),
(106),
(107),
(108),
(109),
(110),
(111),
(112),
(113),
(114),
(115),
(116),
(117),
(118),
(119),
(120),
(121),
(122),
(123),
(124),
(125),
(126),
(127),
(128),
(129),
(130),
(131),
(132),
(133),
(134),
(135),
(136),
(137),
(138),
(139),
(140),
(141),
(142),
(143),
(144),
(145),
(146),
(147),
(148),
(149),
(150),
(151),
(152),
(153),
(154),
(155),
(156),
(157),
(158),
(159),
(160),
(161),
(162),
(163),
(164),
(165),
(166),
(167),
(168),
(169),
(170),
(171),
(172),
(173),
(174),
(175),
(176),
(177),
(178),
(179),
(180),
(181),
(182),
(183),
(184),
(185),
(186),
(187),
(188),
(189),
(190),
(191),
(192),
(193),
(194),
(195),
(196),
(197),
(198),
(199),
(200),
(201),
(202),
(203),
(204),
(205),
(206),
(207),
(208),
(209),
(210),
(211),
(212),
(213),
(214),
(215),
(216),
(217),
(218),
(219),
(220),
(221),
(222),
(223),
(224),
(225),
(226),
(227),
(228),
(229),
(230),
(231),
(232),
(233),
(234),
(235),
(236),
(237),
(238),
(239),
(240),
(241),
(242),
(243),
(244),
(245),
(246),
(247),
(248),
(249),
(250),
(251),
(252),
(253),
(254),
(255),
(256),
(257),
(258),
(259),
(260),
(261),
(262),
(263),
(264),
(265),
(266),
(267),
(268),
(269),
(270),
(271),
(272),
(273),
(274),
(275),
(276),
(277),
(278),
(279),
(280),
(281),
(282),
(283),
(284),
(285),
(286),
(287),
(288),
(289),
(290),
(291),
(292),
(293),
(294),
(295),
(296),
(297),
(298),
(299),
(300),
(301),
(302),
(303),
(304),
(305),
(306),
(307),
(308),
(309),
(310),
(311),
(312),
(313),
(314),
(315),
(316),
(317),
(318),
(319),
(320),
(321),
(322),
(323),
(324),
(325),
(326),
(327),
(328),
(329),
(330),
(331),
(332),
(333),
(334),
(335),
(336),
(337),
(338),
(339),
(340),
(341),
(342),
(343),
(344),
(345),
(346),
(347),
(348),
(349),
(350),
(351),
(352),
(353),
(354),
(355),
(356),
(357),
(358),
(359),
(360),
(361),
(362),
(363),
(364),
(365),
(366),
(367),
(368),
(369),
(370),
(371),
(372),
(373),
(374),
(375),
(376),
(377),
(378),
(379),
(380),
(381),
(382),
(383),
(384),
(385),
(386),
(387),
(388),
(389),
(390),
(391),
(392),
(393),
(394),
(395),
(396),
(397),
(398),
(399),
(400),
(401),
(402),
(403),
(404),
(405),
(406),
(407),
(408),
(409),
(410),
(411),
(412),
(413),
(414),
(415),
(416),
(417),
(418),
(419),
(420),
(421),
(422),
(423),
(424),
(425),
(426),
(427),
(428),
(429),
(430),
(431),
(432),
(433),
(434),
(435),
(436),
(437),
(438),
(439),
(440),
(441),
(442),
(443),
(444),
(445),
(446),
(447),
(448),
(449),
(450),
(451),
(452),
(453),
(454),
(455),
(456),
(457),
(458),
(459),
(460),
(461),
(462),
(463),
(464),
(465),
(466),
(467),
(468),
(469),
(470),
(471),
(472),
(473),
(474),
(475),
(476),
(477),
(478),
(479),
(480),
(481),
(482),
(483),
(484),
(485),
(486),
(487),
(488),
(489),
(490),
(491),
(492),
(493),
(494),
(495),
(496),
(497),
(498),
(499),
(500),
(501),
(502),
(503),
(504),
(505),
(506),
(507),
(508),
(509),
(510),
(511),
(512),
(513),
(514),
(515),
(516),
(517),
(518),
(519),
(520),
(521),
(522),
(523),
(524),
(525),
(526),
(527),
(528),
(529),
(530),
(531),
(532),
(533),
(534),
(535),
(536),
(537),
(538),
(539),
(540),
(541),
(542),
(543),
(544),
(545),
(546),
(547),
(548),
(549),
(550),
(551),
(552),
(553),
(554),
(555),
(556),
(557),
(558),
(559),
(560),
(561),
(562),
(563),
(564),
(565),
(566),
(567),
(568),
(569),
(570),
(571),
(572),
(573),
(574),
(575),
(576),
(577),
(578),
(579),
(580),
(581),
(582),
(583),
(584),
(585),
(586),
(587),
(588),
(589),
(590),
(591),
(592),
(593),
(594),
(595),
(596),
(597),
(598),
(599),
(600),
(601),
(602),
(603),
(604),
(605),
(606),
(607),
(608),
(609),
(610),
(611),
(612),
(613),
(614),
(615),
(616),
(617),
(618),
(619),
(620),
(621),
(622),
(623),
(624),
(625),
(626),
(627),
(628),
(629),
(630),
(631),
(632),
(633),
(634),
(635),
(636),
(637),
(638),
(639),
(640),
(641),
(642),
(643),
(644),
(645),
(646),
(647),
(648),
(649),
(650),
(651),
(652),
(653),
(654),
(655),
(656),
(657),
(658),
(659),
(660),
(661),
(662),
(663),
(664),
(665),
(666),
(667),
(668),
(669),
(670),
(671),
(672),
(673),
(674),
(675),
(676),
(677),
(678),
(679),
(680),
(681),
(682),
(683),
(684),
(685),
(686),
(687),
(688),
(689),
(690),
(691),
(692),
(693),
(694),
(695),
(696),
(697),
(698),
(699),
(700),
(701),
(702),
(703),
(704),
(705),
(706),
(707),
(708),
(709),
(710),
(711),
(712),
(713),
(714),
(715),
(716),
(717),
(718),
(719),
(720),
(721),
(722),
(723),
(724),
(725),
(726),
(727),
(728),
(729),
(730),
(731),
(732),
(733),
(734),
(735),
(736),
(737),
(738),
(739),
(740),
(741),
(742),
(743),
(744),
(745),
(746),
(747),
(748),
(749),
(750),
(751),
(752),
(753),
(754),
(755),
(756),
(757),
(758),
(759),
(760),
(761),
(762),
(763),
(764),
(765),
(766),
(767),
(768),
(769),
(770),
(771),
(772),
(773),
(774),
(775),
(776),
(777),
(778),
(779),
(780),
(781),
(782),
(783),
(784),
(785),
(786),
(787),
(788),
(789),
(790),
(791),
(792),
(793),
(794),
(795),
(796),
(797),
(798),
(799),
(800),
(801),
(802),
(803),
(804),
(805),
(806),
(807),
(808),
(809),
(810),
(811),
(812),
(813),
(814),
(815),
(816),
(817),
(818),
(819),
(820),
(821),
(822),
(823),
(824),
(825),
(826),
(827),
(828),
(829),
(830),
(831),
(832),
(833),
(834),
(835),
(836),
(837),
(838),
(839),
(840),
(841),
(842),
(843),
(844),
(845),
(846),
(847),
(848),
(849),
(850),
(851),
(852),
(853),
(854),
(855),
(856),
(857),
(858),
(859),
(860),
(861),
(862),
(863),
(864),
(865),
(866),
(867),
(868),
(869),
(870),
(871),
(872),
(873),
(874),
(875),
(876),
(877),
(878),
(879),
(880),
(881),
(882),
(883),
(884),
(885),
(886),
(887),
(888),
(889),
(890),
(891),
(892),
(893),
(894),
(895),
(896),
(897),
(898),
(899),
(900),
(901),
(902),
(903),
(904),
(905),
(906),
(907),
(908),
(909),
(910),
(911),
(912),
(913),
(914),
(915),
(916),
(917),
(918),
(919),
(920),
(921),
(922),
(923),
(924),
(925),
(926),
(927),
(928),
(929),
(930),
(931),
(932),
(933),
(934),
(935),
(936),
(937),
(938),
(939),
(940),
(941),
(942),
(943),
(944),
(945),
(946),
(947),
(948),
(949),
(950),
(951),
(952),
(953),
(954),
(955),
(956),
(957),
(958),
(959),
(960),
(961),
(962),
(963),
(964),
(965),
(966),
(967),
(968),
(969),
(970),
(971),
(972),
(973),
(974),
(975),
(976),
(977),
(978),
(979),
(980),
(981),
(982),
(983),
(984),
(985),
(986),
(987),
(988),
(989),
(990),
(991),
(992),
(993),
(994),
(995),
(996),
(997),
(998),
(999),
(1000),
(1001);
CTE workaround (no error, not recommended!):
DECLARE @T AS table (c1 int);
WITH CTE (c1) AS
(
SELECT V.v
FROM
(
VALUES
(1),
(2),
(3),
(4),
(5),
(6),
(7),
(8),
(9),
(10),
(11),
(12),
(13),
(14),
(15),
(16),
(17),
(18),
(19),
(20),
(21),
(22),
(23),
(24),
(25),
(26),
(27),
(28),
(29),
(30),
(31),
(32),
(33),
(34),
(35),
(36),
(37),
(38),
(39),
(40),
(41),
(42),
(43),
(44),
(45),
(46),
(47),
(48),
(49),
(50),
(51),
(52),
(53),
(54),
(55),
(56),
(57),
(58),
(59),
(60),
(61),
(62),
(63),
(64),
(65),
(66),
(67),
(68),
(69),
(70),
(71),
(72),
(73),
(74),
(75),
(76),
(77),
(78),
(79),
(80),
(81),
(82),
(83),
(84),
(85),
(86),
(87),
(88),
(89),
(90),
(91),
(92),
(93),
(94),
(95),
(96),
(97),
(98),
(99),
(100),
(101),
(102),
(103),
(104),
(105),
(106),
(107),
(108),
(109),
(110),
(111),
(112),
(113),
(114),
(115),
(116),
(117),
(118),
(119),
(120),
(121),
(122),
(123),
(124),
(125),
(126),
(127),
(128),
(129),
(130),
(131),
(132),
(133),
(134),
(135),
(136),
(137),
(138),
(139),
(140),
(141),
(142),
(143),
(144),
(145),
(146),
(147),
(148),
(149),
(150),
(151),
(152),
(153),
(154),
(155),
(156),
(157),
(158),
(159),
(160),
(161),
(162),
(163),
(164),
(165),
(166),
(167),
(168),
(169),
(170),
(171),
(172),
(173),
(174),
(175),
(176),
(177),
(178),
(179),
(180),
(181),
(182),
(183),
(184),
(185),
(186),
(187),
(188),
(189),
(190),
(191),
(192),
(193),
(194),
(195),
(196),
(197),
(198),
(199),
(200),
(201),
(202),
(203),
(204),
(205),
(206),
(207),
(208),
(209),
(210),
(211),
(212),
(213),
(214),
(215),
(216),
(217),
(218),
(219),
(220),
(221),
(222),
(223),
(224),
(225),
(226),
(227),
(228),
(229),
(230),
(231),
(232),
(233),
(234),
(235),
(236),
(237),
(238),
(239),
(240),
(241),
(242),
(243),
(244),
(245),
(246),
(247),
(248),
(249),
(250),
(251),
(252),
(253),
(254),
(255),
(256),
(257),
(258),
(259),
(260),
(261),
(262),
(263),
(264),
(265),
(266),
(267),
(268),
(269),
(270),
(271),
(272),
(273),
(274),
(275),
(276),
(277),
(278),
(279),
(280),
(281),
(282),
(283),
(284),
(285),
(286),
(287),
(288),
(289),
(290),
(291),
(292),
(293),
(294),
(295),
(296),
(297),
(298),
(299),
(300),
(301),
(302),
(303),
(304),
(305),
(306),
(307),
(308),
(309),
(310),
(311),
(312),
(313),
(314),
(315),
(316),
(317),
(318),
(319),
(320),
(321),
(322),
(323),
(324),
(325),
(326),
(327),
(328),
(329),
(330),
(331),
(332),
(333),
(334),
(335),
(336),
(337),
(338),
(339),
(340),
(341),
(342),
(343),
(344),
(345),
(346),
(347),
(348),
(349),
(350),
(351),
(352),
(353),
(354),
(355),
(356),
(357),
(358),
(359),
(360),
(361),
(362),
(363),
(364),
(365),
(366),
(367),
(368),
(369),
(370),
(371),
(372),
(373),
(374),
(375),
(376),
(377),
(378),
(379),
(380),
(381),
(382),
(383),
(384),
(385),
(386),
(387),
(388),
(389),
(390),
(391),
(392),
(393),
(394),
(395),
(396),
(397),
(398),
(399),
(400),
(401),
(402),
(403),
(404),
(405),
(406),
(407),
(408),
(409),
(410),
(411),
(412),
(413),
(414),
(415),
(416),
(417),
(418),
(419),
(420),
(421),
(422),
(423),
(424),
(425),
(426),
(427),
(428),
(429),
(430),
(431),
(432),
(433),
(434),
(435),
(436),
(437),
(438),
(439),
(440),
(441),
(442),
(443),
(444),
(445),
(446),
(447),
(448),
(449),
(450),
(451),
(452),
(453),
(454),
(455),
(456),
(457),
(458),
(459),
(460),
(461),
(462),
(463),
(464),
(465),
(466),
(467),
(468),
(469),
(470),
(471),
(472),
(473),
(474),
(475),
(476),
(477),
(478),
(479),
(480),
(481),
(482),
(483),
(484),
(485),
(486),
(487),
(488),
(489),
(490),
(491),
(492),
(493),
(494),
(495),
(496),
(497),
(498),
(499),
(500),
(501),
(502),
(503),
(504),
(505),
(506),
(507),
(508),
(509),
(510),
(511),
(512),
(513),
(514),
(515),
(516),
(517),
(518),
(519),
(520),
(521),
(522),
(523),
(524),
(525),
(526),
(527),
(528),
(529),
(530),
(531),
(532),
(533),
(534),
(535),
(536),
(537),
(538),
(539),
(540),
(541),
(542),
(543),
(544),
(545),
(546),
(547),
(548),
(549),
(550),
(551),
(552),
(553),
(554),
(555),
(556),
(557),
(558),
(559),
(560),
(561),
(562),
(563),
(564),
(565),
(566),
(567),
(568),
(569),
(570),
(571),
(572),
(573),
(574),
(575),
(576),
(577),
(578),
(579),
(580),
(581),
(582),
(583),
(584),
(585),
(586),
(587),
(588),
(589),
(590),
(591),
(592),
(593),
(594),
(595),
(596),
(597),
(598),
(599),
(600),
(601),
(602),
(603),
(604),
(605),
(606),
(607),
(608),
(609),
(610),
(611),
(612),
(613),
(614),
(615),
(616),
(617),
(618),
(619),
(620),
(621),
(622),
(623),
(624),
(625),
(626),
(627),
(628),
(629),
(630),
(631),
(632),
(633),
(634),
(635),
(636),
(637),
(638),
(639),
(640),
(641),
(642),
(643),
(644),
(645),
(646),
(647),
(648),
(649),
(650),
(651),
(652),
(653),
(654),
(655),
(656),
(657),
(658),
(659),
(660),
(661),
(662),
(663),
(664),
(665),
(666),
(667),
(668),
(669),
(670),
(671),
(672),
(673),
(674),
(675),
(676),
(677),
(678),
(679),
(680),
(681),
(682),
(683),
(684),
(685),
(686),
(687),
(688),
(689),
(690),
(691),
(692),
(693),
(694),
(695),
(696),
(697),
(698),
(699),
(700),
(701),
(702),
(703),
(704),
(705),
(706),
(707),
(708),
(709),
(710),
(711),
(712),
(713),
(714),
(715),
(716),
(717),
(718),
(719),
(720),
(721),
(722),
(723),
(724),
(725),
(726),
(727),
(728),
(729),
(730),
(731),
(732),
(733),
(734),
(735),
(736),
(737),
(738),
(739),
(740),
(741),
(742),
(743),
(744),
(745),
(746),
(747),
(748),
(749),
(750),
(751),
(752),
(753),
(754),
(755),
(756),
(757),
(758),
(759),
(760),
(761),
(762),
(763),
(764),
(765),
(766),
(767),
(768),
(769),
(770),
(771),
(772),
(773),
(774),
(775),
(776),
(777),
(778),
(779),
(780),
(781),
(782),
(783),
(784),
(785),
(786),
(787),
(788),
(789),
(790),
(791),
(792),
(793),
(794),
(795),
(796),
(797),
(798),
(799),
(800),
(801),
(802),
(803),
(804),
(805),
(806),
(807),
(808),
(809),
(810),
(811),
(812),
(813),
(814),
(815),
(816),
(817),
(818),
(819),
(820),
(821),
(822),
(823),
(824),
(825),
(826),
(827),
(828),
(829),
(830),
(831),
(832),
(833),
(834),
(835),
(836),
(837),
(838),
(839),
(840),
(841),
(842),
(843),
(844),
(845),
(846),
(847),
(848),
(849),
(850),
(851),
(852),
(853),
(854),
(855),
(856),
(857),
(858),
(859),
(860),
(861),
(862),
(863),
(864),
(865),
(866),
(867),
(868),
(869),
(870),
(871),
(872),
(873),
(874),
(875),
(876),
(877),
(878),
(879),
(880),
(881),
(882),
(883),
(884),
(885),
(886),
(887),
(888),
(889),
(890),
(891),
(892),
(893),
(894),
(895),
(896),
(897),
(898),
(899),
(900),
(901),
(902),
(903),
(904),
(905),
(906),
(907),
(908),
(909),
(910),
(911),
(912),
(913),
(914),
(915),
(916),
(917),
(918),
(919),
(920),
(921),
(922),
(923),
(924),
(925),
(926),
(927),
(928),
(929),
(930),
(931),
(932),
(933),
(934),
(935),
(936),
(937),
(938),
(939),
(940),
(941),
(942),
(943),
(944),
(945),
(946),
(947),
(948),
(949),
(950),
(951),
(952),
(953),
(954),
(955),
(956),
(957),
(958),
(959),
(960),
(961),
(962),
(963),
(964),
(965),
(966),
(967),
(968),
(969),
(970),
(971),
(972),
(973),
(974),
(975),
(976),
(977),
(978),
(979),
(980),
(981),
(982),
(983),
(984),
(985),
(986),
(987),
(988),
(989),
(990),
(991),
(992),
(993),
(994),
(995),
(996),
(997),
(998),
(999),
(1000),
(1001)
) AS V(v)
)
INSERT @T (c1)
SELECT c1
FROM CTE;
| 1 |
INSERT VALUES clauses in SQL Server
|
In what order are taxes applied
|
Lets say we have a product that costs 100$ (net price). This product has 3 taxes that must be applied to it: 2 percentage taxes (e.g. 17% and 20%) and one fixed amount tax (e.g. +10$).
My question is - what math is done in this case?
Are the percentage taxes applied on the net price and summed or the first one is calculated and then the second one is done with the price we get after applying the first? When is the fixed amount tax applied? After the other two or the other two are done with net+fixed tax?
|
This could be legislated to be different, but typically, the tax is applied on the net and summed.
$100 price
17% is $17
20% is $20
$10 flat tax
= $147
| 0.777778 |
$100 price 17% is $17 20% is $20 $10 flat tax = $147
|
CakePHP displayField usage
|
can you help me how to use CakePHP's displayField directive, I can not figure out how to use it...
so, in a model file, i have following code...
<?php
class Task extends AppModel {
var $name = 'Task';
var $displayField = 'projectName';
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(
'User' => array(
'className' => 'User',
'foreignKey' => 'user_id',
'conditions' => '',
'fields' => '',
'order' => ''
etc...
how can i use this, to display fied projectName in select form field?
thank you in advance!!!
|
You can basically do this (in controller):
$this->set('tasks', $this->Task->find('list'));
And make an input with name task_id, and make sure to force it to be a select box, so (in views):
echo $form->input('task_id', array('label' => 'youLabelHere', 'type' => 'select'));
displayField gives you a chance to choose which field will be used as a displayed option (one of) in the select box, if it's not provided in model the script will look for 'name' or 'title'.
If you wan't to display projects in the users forms (add, edit option) then your associations aren't right. Always make sure that there is an association (with good, conventional tables and keys names) between two model when you want to make a select box, Cake makes it as easy as can it gets.
| 1 |
Choose which field will be used as a displayed option in select box
|
Do any "pro-sumer" grade NAS boxes use hardware RAID?
|
Given the comments regarding the cost of true hardware RAID in some of my searches like here or here, it would appear that $500 solutions like Synology DS413, Netgear ReadyNAS Ultra 4, QNAP TS-419P must use software-based RAID. True? Are they using a hybrid hardware-software combo?
All manufacturers appear to offer some proprietary version of expandable RAID (Netgear X-RAID, Synology Hybrid RAID, etc). I believe these boxes run Linux inside, are these proven Linux software RAID algorithms that the manufacturers are branding, or truly proprietary? Any less reliable than tried-and-true RAID-1, 5, 10, etc?
I would just like to understand the internals of these machines a little better before trusting them with terabytes of important data. Thanks.
|
There's no point in re-inventing the wheel. I know that Synology and QNAP use mdadm (all bets are off with Netgear hardware). It's a tried and true solution, and in a NAS a huge cost saving and performance is OK. Given that new file systems like ZFS basically make hardware-level raid redundant, this is an OK thing.
The only time when it's not so great is for high throughput on heavy protocols like iSCSI. Then the challengine of pushing all that data, the iSCSI protocol and the RAIDing system will run the system to 100% CPU and 100% RAM easily.
| 1 |
Synology and QNAP use mdadm to make hardware-level raid redundant
|
Important non-technical course for programmers?
|
What kind of non-technical training course do you suggest for a programmer? Example could be public speaking course, presentation skill, English, business writing, or anything not related to programming or software engineering itself.
|
Personality Testing and Profiling
Understanding personalities, tendencies, and chemistry is important. It can help you understand how to be more productive individually and as a team.
Read more:
http://en.wikipedia.org/wiki/Personality_test
Myers-Briggs Type Indicator
Keirsey Temperament Sorter
DISC Profiles
| 0.888889 |
Personality Testing and Profiling Understanding personalities, tendencies and chemistry
|
Examples of RESTful Web Services for Browser Games
|
Can anyone point me towards examples of Browser Games / Browser Game Sites that use RESTful web services?
I have been convinced time and again that building web sites using RESTful principles is a good idea. And I agree. But I just can't wrap my head around what RESTful means when the service you're providing is just a single (or a few) games.
Any ideas or thoughts would be nice, but I'd also love to see some solid examples.
|
I think the network protocol is really irrelevant, each game uses its own protocol, REST or any other standard is only important if you need to interoperate with third party software - which game servers mostly do not.
For example, if you published the API, using REST might be a good idea. But otherwise, I don't see any reason to do so.
| 0.888889 |
REST or any other standard is important if you need to interoperate with third party software
|
Problem with passing control to Preference activity
|
i created application in that it will call preference from main activity based on menu option
it is done using Explicit intent but it not working . when clicking the menu item
calling activity
public boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
menu.add(0, Menu.FIRST+1, Menu.NONE, "Refresh");
menu.add(0, Menu.FIRST+3, Menu.NONE, "Set Preferences");
return true;
}
public boolean onOptionItemSelected(MenuItem item)
{
switch(item.getItemId())
{
case Menu.FIRST+1:
Intent intent =new Intent(this,userpreferences.class);
startActivityForResult(intent,this.USER_PREFERENCES);
return true;
case Menu.FIRST+3:
return true;
}
return false;
}
preference xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:key="AUTO_UPDATE" android:title="update automatically"
android:summary="update automatically" android:defaultValue="true" />
<ListPreference android:key="MINIMUM_MARK" android:title="minimum mark"
android:summary="enter the minimum mark of the student"
android:defaultValue="30" android:entries = "@array/minimumMarks"
android:entryValues="@array/minimum_mark_values"
android:dialogTitle="Check the minimum mark required" />
</PreferenceScreen>
Preference activity
package com.xml.parse;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class userpreferences extends PreferenceActivity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
some body plz tell me to do better or correct way
Regards,
Kariyachan
|
Do not use startActivityForResult() -- startActivity() is fine. Here is a sample project showing the use of an options menu item to open a PreferenceActivity.
| 0.833333 |
StartActivityForResult() is fine
|
Mark: outstanding (as in: not yet known)
|
I’m updating my tabular CV for an application and I’d like to include my master thesis even though it’s not yet finished (soon!) and marked. So I’d like to write that the mark is still outstanding but I fear that if I simply write
Master thesis: ‹topic›
Supervisor: ‹supervisor›
Mark: outstanding
this could be misconstrued to mean that the result is in, and that it’s outstanding (as in: spectacular). What can I say here instead? It should be as salient as possible, single word preferred. I specifically want to avoid writing half a sentence.
|
I would go for “pending” (or, longer, “still pending”).
| 0.888889 |
"pending" (or longer, "still pending")
|
weird positioning problem while rotating image in Javascript
|
I am running into a weird positioning issue while rotating an image wrapped into a div in JavaScript. When rotating the image by either 90 or 270 degrees, the image suddenly is 50px above and 50px to the right of its parent div. For 0 or 180 degrees it's just fine.
This is what I am doing:
<html>
<head>
<script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-1.6.2.js"></script>
</head>
<body>
<div id="crop_container" style="width:400px; height:400px; border:solid 1px;">
<img src="http://a8.sphotos.ak.fbcdn.net/hphotos-ak-snc6/249740_10150195623627623_506197622_7383520_7286937_n.jpg" style="display:block; position:relative; width:400px; height:400px;" />
</div>
<script language="JavaScript">
var $cropContainer = $("#crop_container");
var $cropImage = $("#crop_container img");
var degrees = 90;
$cropImage.css({"width":400, "height":300});
$cropContainer.css({"width":300, "height":400});
$cropImage.css({"-webkit-transform":"rotate("+degrees+"deg)","-moz-transform":"rotate("+degrees+"deg)"});
//$cropImage.css({"top":50, "right":50});
</script>
</body>
</html>
Now when you uncommect the last css adjustment line with a correction of 50px from top and right it works just fine, but I have no clue as to why this is happening?
Any advice would be greatly appreciated!
Thanks!
Joni
|
When you rotate a landscape image by 90 degrees into a portrait image it will keep it centered to it's original position. Since your width and height are 100 pixels apart from one another, the transform distributes the difference to the top and bottom, that's where your 50 pixels comes from.
| 1 |
rotate a landscape image by 90 degrees into a portrait image
|
Different water temperature in different faucets
|
I have my bathrooms remodeled and the temperature of the water is different in one bathroom than the other.
Even within the same bathroom, the bathtub is cooler than the water coming out of the sink.
Why could this be?
Thank you very much
|
Bathtub and shower valves have (and are required to have) anti-scald features which limit the temperature. Depending on the valve that may be somewhat adjustable - check the owners manual for it (look up on the web if you don't have one.)
I believe the reasoning is that a small child or invalid would not be able to get out of the tub, while it's assumed that they could pull their hands away from a sink. It is in response to actual burn incidents.
| 0.888889 |
Bathtub and shower valves have anti-scald features .
|
JQuery - Select exact class structure
|
I am working on some functionality for a website. I am designing, and I am kind of stuck on something small. I want to hide divs that contain an exact class structure.
For example, if I give it the class selector ".class1.class2.class3", it will ONLY hide elements that have exact class structure. What I am doing now would hide elements like ".class1.class2.class3.class4", and I don't want that.
Any help would be greatly appreciated!
|
In this particular case, you can use the .not() selector:
$('.class1.class2.class3:not(.class4)')
You can also do it with method chaining:
$('.class1.class2.class3').not('.class4')
Note that this doesn't necessarily select exactly .class1.class2.class3 with no other classes, it just prevents anything with class4 from being selected.
| 0.777778 |
.not() selector: $('.class1.class2.class3:not(.class4)'
|
Take quick notes without interrupting current activity
|
When I’m in the middle of something and get an idea, I want to note it down without interrupting what I’m doing.
Desired workflow: adding a note
I press a key (or a key combo).
(should work everywhere: while browsing, while writing, while watching a video, etc.)
A note window opens.
(just a single text field, no title/category/etc.)
(it must be empty)
(doesn’t have to be a GUI)
I enter my note.
I press, e.g. Enter to save the note.
(the window must close automatically)
Browsing notes
Just a simple list/table of all saved notes.
Especially not just text files which I’d have to open separately to read their content.
Should display the date/time when a note was saved.
Should offer a quick way to delete notes.
No need for editing notes.
Formal requirements
A solution must be FLOSS and run natively on GNU/Linux.
|
Sounds like a job for Emacs!
Install Emacs through your distribution's package manager.
Emacs comes with Remember Mode, which does pretty much what you want. (Note that there's a lot of complication in the Emacs Wiki that you don't care about, because it's for older versions of Emacs. Remember Mode is bundled since Emacs 23.)
To start taking a note, run the following shell command:
emacsclient -a "" -e "(let ((pop-up-frame-alist \`((window-system . x) (display . \"$DISPLAY\") ,@pop-up-frame-alist))) (remember-other-frame))"
(Having just -e "(remember-other-frame)" doesn't work if Emacs isn't already displaying a window due to a bad interaction between server mode and frame creation.)
You can add other frame parameters in that list, with the syntax (NAME . VALUE). For example, to set a smaller height:
emacsclient -a "" -e "(let ((pop-up-frame-alist \`((window-system . x) (display . \"$DISPLAY\") (height . 8) ,@pop-up-frame-alist))) (remember-other-frame))"
Bind that shell command to a key in your window manager or desktop environment; each has its own way of doing this, so I can't describe them all.
Emacs will start if it isn't already running, and a new Emacs window showing an empty file will pop up. When you've finished taking that note, press Ctrl+C twice. If you want to change that key binding, you can do it in your .emacs, for example to use Ctrl+Return, use this code:
(require 'remember)
(define-key remember-mode-map [C-return] 'remember-finalize)
If you want to save some text from another application, copy it to the clipboard and run this command (which you may want to bind to a key as well):
emacsclient -a "" -c -e "(remember-clipboard)"
With this command, you need to press Ctrl+C twice, then close the window.
The notes are saved in the file ~/.notes (each new note is appended to that file). A header containing ** followed by the current time is automatically added at the beginning of the note.
To browse the notes, just open ~/.notes in your favorite text editor (such as Emacs).
If you want to save the notes to a different file, add a line like this to your ~/.emacs:
(setq remember-data-file "/path/to/notes/file")
What Remember mode lacks out of the box is a really convenient way of deleting a single note. You can of course select the text and delete it. Here's a function to delete the current note, plus a bit of infrastructure to bind it to a key when browsing the notes file. Put this code in your ~/.emacs.
(defun remember-current-note-extent ()
(save-match-data
(save-excursion
(end-of-line)
(let ((beg (search-backward (concat "\n" remember-leader-text))))
(forward-char)
(cons beg
(if (search-forward (concat "\n" remember-leader-text) nil t)
(- (point) 1 (length remember-leader-text))
(point-max)))))))
(defun remember-mark-current-note ()
(interactive "@")
(let ((bounds (remember-current-note-extent)))
(set-mark (car bounds))
(goto-char (cdr bounds))))
(defun remember-delete-current-note ()
(interactive "@*")
(let ((bounds (remember-current-note-extent)))
(delete-region (car bounds) (cdr bounds))))
(defvar remember-notes-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c\C-d" 'remember-delete-current-note)
map)
"Keymap for Remember Notes mode.")
(define-derived-mode remember-notes-mode text-mode "Notes"
"Major mode to browse Remember notes.
\\{remember-notes-mode-map}"
(require 'remember))
(add-to-list 'auto-mode-alist '("/\\.notes\\'" . remember-notes-mode))
| 1 |
Remember Mode is bundled since Emacs 23.
|
Should you let users know if an email has been taken during registration validation?
|
In many web applications, email is required to be a unique field, and users aren't allowed to register an account if their email already exists in the database.
When performing validation on the registration form, you would presumably check if an email has been taken, and let the user know if it has since they can either pick a different one or try to reset their password.
However, if you are providing this feedback, it seems like malicious users could test to see if users exist in the database. Someone could plausibly test your site against leaked data from big-name hacks, and if the users are reusing their passwords across sites, then your site is potentially vulnerable.
The solution to this could be simply giving more generic feedback about what went wrong without specifically mentioning email, although that could be frustrating for the average user trying to sign up. And if your sign up form simply requires an email and password, it is still pretty obvious that if any error is encountered it is likely that the email already exists in the database.
What is the best way from a security perspective to handle informing a user that an email has already been taken upon registration?
|
If this is a concern (i.e. if the fact of a person's membership would be considered sensitive information), one solution is to process the registration normally from the user's perspective on the registration page, but send a different e-mail out that explains that an account already exists/gives details on resetting the existing account (or replacing it if applicable) rather than a confirmation e-mail to verify the address.
| 1 |
How to process the registration from the user's perspective on the registration page?
|
How do I reference (what is the syntax I have to use) to get the data of my Profile2 custom fields?
|
I have used the Profile2 module (D7) and created some custom fields for my users. One of those fields (for example) is "field_company" with the label "Company."
Now I am using a computed field (Company) on a content type (Games). When user creates a Game, I want my computed field Company to be computed/populated automatically, based on the "field_company" field I have set in my profile2.
I am trying to find how to get that information. This is as far I got, so far, but it doesn't work.
$entity_field[0]['value'] = "";
$name=$profile2->field_onoma[LANGUAGE_NONE][0]['value'];
$entity_field[0]['value'] = $name;
|
You should use the field_view_field() function. Have a look at the follwing page for more information:
http://coder1.com/articles/printing-or-rendering-node-field-or-profile2-field-drupal-7
| 1 |
Use field_view_field() function
|
Radio Waves reach in function of frequency
|
What is the relationship between the reach of a RF signal and its frequency?
What I mean is: If power is kept constant, should I use high or low frequency waves to get a better reach? Why?
|
In free space, it doesn't matter. The power per incident area of a propagating wave is inversely proportional to the square of the distance from the transmitter. This is true regardless of frequency.
Certain frequencies are reflected, refracted, absorbed, and scattered differently by different materials. There is no single monotonic relationship until you get to really high energies, like gamma rays and beyond. At these really high energies (high frequencies), the waves basically just blast thru any material in their way, with higher energies passing thru material with less attenutation. Up to below Xray frequencies, there is no single answer, and it depends on the material between the transmitter and receiver.
Diffraction effects can make low fequencies (long wavelengths) appear to bend around objects, but this actually occurs at all wavelengths. The "near" layer where diffraction effects occur scales with wavelength, so it appears to us at a fixed human scale that long wavelengths go "around" objects where short wavelengths don't, but that is due to our perception scale. On the scale of the earth, commercial AM radio frequencies around 1 MHz are low enough to diffract around the curvature of the earth to some extent making over the horizon AM reception possible. Commercial FM radio, being 100x shorter wavelength, exhibits this effect much less for the same size earth, so FM radio appears to us to be mostly occluded by the horizon.
| 0.777778 |
The power per incident area of a propagating wave is proportional to the square of the distance from the transmitter .
|
What were the first anime based on manga and light novels?
|
I know that original animes weren't based on light novels or mangas (see: this). However, I think there are some early shows that are based on mangas (Astro Boy for example, I think). What was the first anime based on a manga? Also, what was the first anime based on a light novel?
|
While not the most scientific method, one could generate a list of anime entries over at Anime News Network, sort it by order and see what is the earliest entry in their database that fits the criterion we're looking for. Here would be an example of such a list.
Obviously the service's database is most likely incomplete, but regardless, it is still an authoritative source for anime information, and given the size, and time range of the database, it can be trusted as a good estimation.
First anime based off of manga:
Astro Boy, 1963
First anime based off light novels:
Legend of the Galactic Heroes (OAV) 1988
Slayers (1995)
| 1 |
Anime News Network is a reliable source for anime information .
|
Is my interval training routine effective for mountain bike training?
|
During these winter months I am currently attending the gym 3 times a week. On each of the days I start my training on an exercise bike with the following:
5 minute warm up
30 minutes, 1 minute hard, 1 minute recovery
5 minute warm down
I am using a specific interval training setting on the bike. I preset the training to level 15, which is a high resistance and as much as I can take.
Hard is a cadence of between 80-90rpm high resistance. Recovery is a cadence of 60prm and the resistance backs off considerably, I imagine to approximately level 7.
My heart rate towards the end of the session reaches 170–190bpm, and I am working flat-out. I turn 30 in March, am 5' 8" and weigh approx 168lbs.
Does this training routine seem sensible for building strength and speed on the mountain? Should I be changing up the training with other types of bike training?
It is also worth noting that after the interval training I perform free weight strength training too.
|
I think there are several issues with your approach for improving power on bike:
doing the same workout stresses the same aerobic pathway, since there are several ways your body can burn fuel it is worth exercising all of them. This means doing intervals of different length with different rest periods. Example: 3x(12+6) min on and off. The on part is similar to what you can do for 1 hour and the off part is half of that. Another example: 3x(3+3) min on and off where the on part is what you can do for 5 minutes, off part is half of that.
the intervals do not seem to be anaerobic, because of the short recovery period( anaerobic intervals need longer recovery periods ). They are either Vo2Max intervals or Threshold. If they are Vo2Max I think the workout is too hard, usually accumulating 6 to 9 minutes at Vo2Max in a training session is too much, if they are threshold I don't think the approach is very good, better go with a longer interval period since threshold power can be usually sustained by riders for 30 to 60 minutes.
if you want to endure in long events/rides you need to do longer sessions to have the endurance
heart rate on an indoor trainer seems to be artificially high for me, I think it is because of the poor ventilation. Also power on the trainer is much lower then going outside, so pacing with heart rate on an indoor trainer seems to be a bad idea at least this is my experience. Suppose your 170bpm is upper tempo power, on an indoor trainer that might be actually upper endurance because of the artificial high heart rate.
for effective mountain biking you also need riding skills, these are not developed on a trainer.
I would try to look at the requirements of your specific events and target those, also try to do longer sessions on the trail to build the endurance needed to complete this events.
An alternate way is to get a generic mountain biking endurance plan and build on that, it won't be perfect but I think is much superior over what you have now.
Also, try to ride outside if possible, the workouts are better and you will enjoy the training much more.
| 1 |
Doing the same workout stresses the same aerobic pathway
|
How to echo/print attribute set name on frontend catalog page
|
Magento CE 1.9.0.1
I'm interested in echoing out the product attribute set name on the catalog/category pages. This sounds like a strange thing to do but we use Magento's attribute set in a unique way for classifying products.
I was attempting to pull it from the Mage::getModel('catalog/category') feature in my page template but was unsuccessful.
I also tried to pull the name with the following code:
$attributeSetModel = Mage::getModel("eav/entity_attribute_set");
$attributeSetModel->load($product->getAttributeSetId());
$attributeSetName = $attributeSetModel->getAttributeSetName();
echo "<p>" . $attributeSetName "</p>";
Is there a way to get the name to display with their products on the frontend catalog pages? Thanks in advance.
|
add the following code in your catalog/product/list.phtml
<?php
$attributeSetModel = Mage::getModel("eav/entity_attribute_set");
$attributeSetModel->load($_product->getAttributeSetId()); // $product is your product object
echo $attributeSetName = $attributeSetModel->getAttributeSetName();
?>
Note check your listing of products is in grid mode or list mode and add accordingly above code
| 0.888889 |
Add the following code in your catalog/product/list.phtml
|
Why is PWM used to control LEDs even when they're only used On or Off?
|
I've noticed on cars with LED tail lights that they have a flicker to them - I presume because they're PWM controlled.
But I've seen it on vehicles where brake lights and tail lights are separate luminaires, therefore are just on or off and do not have varying brightness. I understand that LEDs need to have current through them limited, but I don't see how PWM would achieve this?
Edit: bad phrasing - sorry. Better phrasing: why would the LEDs be flickering even though there is no apparent feature to allow changing of the brightness? Perhaps the brightness is factory set, or maybe there is a feedback circuit to keep brightness constant. But could there be any other reason?
Thoughts: because a vehicle's battery has a significantly different voltage across it when the engine is off or on, (12v vs 14.5v) perhaps there is a controlling PWM circuit that keeps brightness constant over a range of voltages. Saying that, I'm convinced that smart phone screen back-lights have some flicker to them even on full brightness, yet their Li-ion batteries' voltages are near constant.
|
Contrary to initial intuition, it's actually to increase the brightness.
LEDs can be driven at a constant current, or they can be driven with a pulsed current.
With constant current you have to limit the current to a relatively low value - for instance many common small LEDs are limited to a constant current of say 20mA. That gives good brightness for indication purposes, but it's not that great.
LEDs, when driven with pulsed current, can be driven with a considerably higher current - maybe 5 to 10 times as much, or even more. That could be say 100mA for what would normally be a 20mA LED. However, there are restrictions on what the pulses can be - typically with limits on the frequency and duty cycle - maybe as little as 1% duty.
The end result is that the higher current increases the perceived brightness of the LEDs, since more photons are being emitted when they are on, but at the cost of some flicker, which is only really noticed when the LEDs are in motion.
So you get more perceived brightness from smaller and cheaper LEDs without using more current (often less current) on average than if they were on constant.
| 0.888889 |
LEDs can be driven at a constant current, or with a pulsed current
|
FindProcessParameters for Fractional Brownian Motion Returns Error
|
I have the following data:
x={11.477, 5.9009, 3.77, 12.171, 9.7534, 12.905, 6.933, 4.6517, 7.601, \
3.5294, 13.086, 7.5675, -0.1665, 5.2741, 7.657, 12.536, 2.2046, \
3.0679, 10.777, 13.505, 15.199, 14.02, 10.36, 14.502, 22.701, 22.733, \
23.34, 22.694, 22.222, 19.866, 18.393, 11.18, 8.936, 12.689, 5.2338, \
4.6382, 9.5113, 4.2222, 4.8046, -0.2615, 26.651, 2.6889, 14.937, \
7.7831, 18.225, 23.549, 13.313, 9.3008, 3.6867, 12.954, 11.04, \
19.219, -3.3798, 13.351, 14.368, 13.044, 14.143, 21.393, 23.952, \
22.603, 14.976, 20.189, 23.61}
When executing FindProcessParameters as follows in Mathematica 10:
FindProcessParameters[x, FractionalBrownianMotionProcess[h]]
I get the following error:
FindProcessParameters::invproc: Estimated process parameter(s) yielded an invalid process. >
Any ideas on why?
|
In Version 9
FindProcessParameters[x, FractionalBrownianMotionProcess[h]]
returns {h -> -0.0257885} without an error message.
However, since h should be non-negative, this is an invalid result. In fact
ProcessParameterQ[FractionalBrownianMotionProcess[-0.0257885]]
gives the error message with and returns False:
In Version 10, rather than returning an invalid estimate FindProcessParameters returns with the "invalid process" message.
| 0.666667 |
FindProcessParameters returns h -> -0.0257885 without an error message
|
How to load a properties file in java without calling laod method separately
|
How to load a properties file in java without calling laod method separately
i want to load the file while instantiation of the properties object itself.
like i have pasted below but i am not able to succeed in it.
class test{
Properties configFile = new Properties(load(new FileInputStream("config.properties"));
}
|
Something along the lines of this:
class Test {
Properties configFile = new Properties() {{ load(new FileInputStream("config.properties")); }};
}
You are actually sub classing Properties here and using its initialization section.
load(..) might throw an Exception if so you would need to add a try { ... } catch () {}
| 0.888889 |
Class Test Properties configFile
|
6A Current Source
|
Hi I am designing a 6A current source. I know how to design a current source I am just looking for suggested materials that can handle the full 6A. The op amps and transistors that I have now are more on the milliamp side so I just am looking for something beefier.
|
You will want to use a switching regulator to avoid heat issues. There are many switching regulators on the market. You can hack together a circuit to make them regulate current.
However, there are specialized switching regulators that are meant for use as constant-current sources. These are often marketed as LED Drivers. If you simply look for these, you will find a wide selection of switching regulators that will satisfy your requirements without modification. This one looks perfect.
| 0.888889 |
You can hack together a circuit to make them regulate current
|
"going to" vs "will"
|
I know several questions were asked about the difference between "going to" and "will".
Based on several answers (see, for instance, here, here and here), I understood that "will" is more spontaneous and "going to" is used with more planned actions.
So, it seems that everything is pretty fine. However, in this question, Kosmonaut has an answer in which he states:
"Let's say that tomorrow you will walk your dog from 7 - 8 AM".
On the one hand, you probably planned to walk your dog long before and thus I should use "Let's say that tomorrow you're going to walk your dog from 7 - 8 am".
On the other hand, since I'm saying "let's say...", I'm deciding right now (thus, unplanned) that you will walk your dog. So, even though in this hypothetical situation you made a plan, I'm in a more spontaneous mood deciding right now that that's what you will do tomorrow, and, thus, I should use "will".
Which one (if any) of the above explanations is right?
|
Doing some research, I discovered that the spontaneous vs planned rule for "going to" and "will" is taught to ESL students, but not used otherwise. I did discover a few good rules of thumb that are decent guidelines and make sense to me (a native English speaker):
"Going to" is a kind of present tense, so use "going to" in situations where the
present is connected to the future.
Example:
I feel a drop - I bet it's going to rain.
I am going to walk to school because my bike has a flat tire.
Use "will" in writing and "going to" when speaking.
Use "will" when talking about the not-immediate future and "going to" for the immediate future.
Use "will" and "going to" interchangeably for making predictions.
If you are looking for a good explanation about when to use either form, I suggest you read this article, which explains how to teach the differences between "going to" and "will".
| 0.888889 |
Use spontaneous vs planned rule for "going to" and "will" in situations where present is connected to future
|
Does becoming martyr have an evolutionary advantage?
|
This is related to
How does "be altruist to those who are similar to you" evolve?
Altruism that is
Not reciprocal
Not familiar
has little explanation. One possible explanation is that the trait itself may correlate well with genetics. One great answer there is that often the cost of altruism is small anyway. It can explain why people vote. Here the expense is small anyway.
Still there seems to be some factors that are even bigger.
Let's take a look at people that die for their ideology. Christian martyrs, Muslim suicide bombers, or Communist guerilla fighters. They seem to get so little and well, die.
And that's pretty common. It seems pretty easy for a leader or pedagogue to rouse men to be soldiers. Of course, becoming a soldier is a pretty shitty job, yet most men don't mind.
These people make a huge sacrifice for the sake of their country, ideology, or people that are not even genetically related to them.
Why?
|
There isn an effect called "Indirect reciprocity" where individuals just give to everyone they meet without direct requirement of reciprocity.
This sort of benefit to others is common - hospitality to strangers, general politeness, good customer service all fall along these lines. You hope they will come back and benefit you again, but maybe they will tell someone else who will know you are a good community member.
It is only sustainable in a system where the cost/benefit ratio is less than the reputation benefit of the act. It sounds as if this is only good for public acts but if the benefit is transferred to a social entity that outlasts the individual (like your children, a relative's children, a religion or a corporation say), the result could still hold.
If you think about typical morality/ethics really it still makes sense to think that what we call altruism must still have a net positive benefit. If there is no benefit long term or to anyone, it really isn't useful or even good, its random. What we usually call altruism is usually some sort of reciprocal cooperation.
A soldier who dies in combat or someone who dies for their beliefs but everyone knows about it as a public statement benefits from their act indirectly. I don't think its altruism in the pure sense of the word. Defending the nation, ones' beliefs or whatever is, in its sense its own reward. Veterans come back from a war are hopefully respected for their work. Having a purple heart can be a good thing to show people. I'm not saying these people are adequately compensated for what they have been through, but just trying to draw a distinction between pure biological altruism and 'indirect reciprocity'.
Examples of Indirect reciprocity might be the use of tax money to build highways and build power and water infrastructure. Its important - its the glue that holds a nation or a group together. If you got punished for doing these things we wouldn't be hanging as a nation very long!
A martyr with no family at all who would benefit would still count as an altruism I think, but most acts of public piety and sacrifice do benefit the individual by reputation. Something to think about.
| 1 |
What we call altruism is usually some sort of reciprocal cooperation
|
A concise term for staking territorial claims
|
I'm looking for a word or phrase specifically used to refer to the act of placing a flag to claim new territory. I'm specifically referring to claiming land in the name of some sovereign, though a more general term will do.
|
Edit:
Due to tylerl's specification, I did a little bit of research, and actually, tylerl, "planting the flag" might just be the expression you're after. I saw it in a blog, :
“Planting the flag” usually means making a claim to something, usually territory or land. Throughout history men have “planted the flag” claiming ownership in the name of the king, queen, country, church, etc. marking the land as their own
In this Space Review edition, it referred to the time when Neil Armstrong reached the moon, as "planting a flag", and says it's "only the beginning".
I reckon it's correct usage.
| 1 |
"planting the flag" means making a claim to something, usually territory or land
|
Looking for story where weather control makes snow fall once in warm climate
|
I am looking for a very good story I read many years ago. The story was about a request to a politician that an old dying man would like to see snow fall before he died. The world now had weather control (maybe by controlling sunspots?) but he was in a warm climate (southern California?) and could not be moved and was near death. The man had been instrumental in the early days of weather control. I think the story starts by following the politician who decided to try to honor the man's request and passes a special bill thru the world legislature to make it happen. It then moves to a women (I think) in the weather service who needs to do something radical (in boats on the sun?) to make it happen. I think there were 3 vignettes but I'm forgetting one of them. The story ends with snow falling on 1 acre and the man gets to see the snow before he dies (which may occur at the end of the snowfall). Does anyone else recall this story and could provide title and author?
|
L Thomas's novelette "The Weather Man" (June 1962 Analog), - See more at: http://www.sf-encyclopedia.com/entry/weather_control#sthash.c6oiuviS.dpuf
| 1 |
L Thomas' "The Weather Man"
|
Is the intersection of two star-shaped sets star-shaped?
|
Is the intersection of two star-shaped sets star-shaped?
I don't think so but can't think of an example.
|
HINT: A star-shaped set is connected. A $+$ sign is star-shaped. Find a way to position two of them so that the intersection is a two-point set.
| 1 |
A star-shaped set is connected.
|
BJT switch connections
|
If an NPN BJT is being used as a switch, why is the load usually connected between +Vcc and collector? How is the performance affected if the load is connected between emitter and ground?
|
The normal configuration is called common emitter. It is characterized by a modest amount of voltage amplification, and a modest amount of current amplification. This means that, with a low voltage and a low current, the transistor can switch a higher voltage and higher current.
The configuration with the load in the emitter is called common collector, or emitter-follower. It is characterized by a high current amplification, but no (slightly less than 1) voltage amplification. This means that, with a very low current, the transistor can switch a much larger current. But the input voltage must be at least the load voltage.
In a lot of cases the common-emitter is more appropriate, but in power end-stages you will often find the emitter follower.
There is a third configuration, the common-base, which is characterized by high voltage amplification and low (slightly less than 1) current amplification. It is not used very often.
| 0.666667 |
The common emitter-follower is characterized by a high voltage amplification, but no (slightly less than 1) voltage
|
How do you decide when a paladin has fallen from grace in DnD 5e?
|
There does not seem to be a clear-cut way to determine when a paladin's actions have become egregious enough to justify them breaking their oath. Do a lot of minor slights eventually add up and cause an oath to be broken? Do they get some sort of warning like losing their laying on of hands ability?
|
My opinion is that, for the most part. it is when they break an obvious part of their oath (like using poison for example) or willing commit a truly evil act with no good end.
Though on specific part of oaths. I feel that there are exceptions that a specific paladin can have. I'll use an example I had from a character
Scandal: The character had a flaw/compulsion to be a dracophile from his dragon blood. So I said that to avoid falling from favor and becoming shunned by the people he protected, he could lie about that part of his personality.
I also said that as long as their act wasn't grievous and for a truly good end, he could avoid almost any provocation (for example: a Paladin that kills the corrupt king of a corrupt land wouldn't fall from grace)
To sum up: I focused on the idea that justice is to some extent more important than their oaths.
| 1 |
a specific paladin can have exceptions if they break an obvious part of their oath .
|
Ribbon javascript function reference
|
I was wondering whether there is somekind of reference available with the javascript methods called for each of the buttons in the ribbon. Question behind the question: I want to make a button on a wiki page which says "edit me", without the user having to go to the same button in the ribbon. Functionality should be exactly the same, but I need it on a different place. So what is the easiest way to find out which code the ootb "edit" button calls?
|
Here's a link that helped me out when I needed to find out what javascript function is bound to each ribbon button.
Basically, the steps you have to follow are (applies to sp2010, the might be slight differences in sp2013):
Find the id attribute of the ribbon button. eg. Ribbon.EditingTools.CPEditTab.Markup.Html.Menu.Html.EditSource-Menu16. Next go to 14 hive and under TEMPLATE\GLOBAL\XML\ find cmdui.xml file. This file contains definition for all ribbon buttons in SharePoint. Search in this file by word Ribbon.EditingTools.CPEditTab.Markup.Html.Menu.Html.EditSource
Consider the Command attribute (which, in the example, is equals to EditSource)
search this command among SharePoint javascript files. Common architecture of ribbon handler involves javascript "classes" which can handle particular command. Each class has canHandleCommand method. Search under 14\layouts using pattern *.js by word (in the example, “EditSource”). Find handleCommand method in the class and take note of the line number.
in browser find this line and set a breakpoint, then you can step into to find the exact code that will be called (in the example, RTE.RichTextEditor.editSource() ). This is the handler
| 0.777778 |
Find the id attribute of the ribbon button
|
How can I do some free design work?
|
I am a designer that wants to do some free design work for people, but the problem is, how do I find people to do free work for? Is there any place online?
The reason behind this is that I am good at this, but I don't have any clients, or any previous experience and I am a freelancer, so this would look good on my portfolio.
My skills are very vast and include : 3D, 2D animation, 3D modeling, motion design, stop motion animation,video editing, game design, level design, FluidSIM, illustration, unreal engine 4, graphics design, editorial design, web design and I also know HTML5, CSS, JavaScript and jQuery.
By free work, I mean that the clients don't have to pay a single penny for the work that I do.
|
Have you tried offering your services to your community? Places always in need of graphic designers include:
Religious communities (churches)
Community centres
Amateur theatre groups
Support groups (i.e. AA)
Schools
Immigration welcoming groups
Senior communities
Condominiums
By the way, you can always do these things without saying explicitly "hey, I am a graphic designer and I am looking for graphic design tasks". Just volunteer to do things that are graphic design by nature like posters, websites, flyers etc. As a bonus, you will get experience on how to handle clients: even if you do it for free people can get very demanding and opinionated.
Mind you, the more we offer or work for free the more people think our work is worth nothing. It is always good to give back to the community, but it is also important to educate the world. We do what we do for a living, not just for the love of it.
| 0.888889 |
How to do graphic design for free?
|
Should I always hibernate instead of shutting down?
|
I'm using Windows XP and I hate the long start up time when I shut down and then turn on my laptop. However if I hibernate instead of shutting down it starts up much faster. Are there any harmful effects / disadvantages if I always hibernate whenever I'm done for the day instead of shutting down?
|
Hibernation is a good thing, as long as you have the disk space to accomodate for the hiberfil.sys that gets created in the process. You can find it in the root of your C: drive if you are curious how big it is. You will need to have all hidden and system files visible.
Shutting down every now and again and restarting is still recommended. Not only will it allow those pesky (but required) updates to be installed, but will keep your system in tip top condition.
| 1 |
Hibernation is a good thing, as long as you have the disk space to accomodate for the hiberfil.
|
Optional argument to \item in enumitem list
|
I'm trying to set up a list environment for typesetting a problem set. I'd like to be able to input something like the following:
\begin{pset}
\item First solution.
\item[2.2] Second solution.
\end{pset}
and have it come out as:
Problem 1. First solution.
Problem 2 (2.2). Second solution
with the optional argument to \item being typeset in parentheses if it's present. I assume I should be able to \renewcommand{\makelabel} somehow, but I can't figure out how to do it. I can't get anything like the following to work:
\newcommand{\makepsetlabel}[1]{some if/then involving #1, checking if empty}
\newlist{pset}{enumerate}{1}
\setlist[pset]{
before={\renewcommand\makelabel[1]{\makepsetlabel{##1}}
}
What's the right way?
|
I would use a different command instead of \item:
\documentclass{article}
\usepackage{enumitem}
\newlist{pset}{enumerate}{1}
\setlist[pset]{
label=Problem \arabic*\protect\thispitem,
ref=\arabic*,
align=left
}
\newcommand{\pitem}[1][]{%
\if\relax\detokenize{#1}\relax
\def\thispitem{.}%
\else
\def\thispitem{ (#1).}%
\fi
\item}
\begin{document}
\begin{pset}
\pitem First
\pitem[2.2] Second
\end{pset}
\end{document}
In the label I add a command \thispitem (with \protect so enumitem doesn't interpret it when setting up the environment).
Then \pitem examines the presence of an optional argument and acts consequently: if none is specified, it just prints a period, otherwise a space, the parenthesized argument and the period.
| 0.888889 |
Using a different command instead of item
|
How to allow line breaks after forward slashes in ConTeXt?
|
I have a document containing many forward slashes (/). I noticed that ConTeXt does not allow breaks after /. For instance, if a text contains bear/rabbit/tiger, it will not place a break and the text will flow off the edge into the margins.
How can I create a special environment, inside of which, the rules for line breaking allows a line break after a /, if deemed necessary, with slightly higher or equal preference to what is given to a space?
|
The command \setbreakpoints is made for that. Setting \setbreakpoints [compound] enables a break point after /, +, (, ) and -. For more information see ConTeXt wiki Composed words.
Example:
\setuplayout [width=4cm]
\starttext
Lorem/ipsum/dolor/sit/amet,/consectetur/adipisicing/elit,/sed/%
do/eiusmod/tempor/incididunt/ut/labore/et/dolore/magna/aliqua.
\setbreakpoints [compound]
\blank
Lorem/ipsum/dolor/sit/amet,/consectetur/adipisicing/elit,/sed/%
do/eiusmod/tempor/incididunt/ut/labore/et/dolore/magna/aliqua.
\stoptext
| 0.777778 |
Setting setbreakpoints [compound] enables a break point after /, +, (, ) and
|
What does mathematics have to do with programming?
|
I just started a diploma in software development. Right now we're starting out with basic Java and such (so right from the bottom you might say) - which is fine, I have no programming experience apart from knowing how to do "Hello World" in Java.
I keep hearing that mathematics is pertinent to coding, but how is it so? What general examples would show how mathematics and programming go together, or are reliant on one another?
I apologize of my question is vague, I'm barely starting to get a rough idea of the kind of world I'm stepping into as a code monkey student...
|
Ok, I'm probably going to get a ton of down-votes for this, but programming and maths are two completely unrelated things. Someone can be an amazing developer knowing only the basics like addition, multiplication and basic logical operations.
Most of the developers will not solve a single equation during their professional career, and things like big O notation can be grasped in non mathematical way as well. You just think about the stuff, imagine bits flipped in your head, and voila, you can tell what kind of big O the stuff is, if someone explains what log and power is.
Sometimes math can make it simple, or it can make you feel proud that you proved something, since you can extend the meaning of programming to a mathematical domain via naming it discrete maths and such, but learning a lot of differential equations and integrals, and how to prove that, is IMHO not exactly the best idea what to do if you want to succeed as a programmer.
At least I haven't touched the maths for 10 years, I had arguments with my math professors all the time, and when I needed a math for realtime rendering, I learned everything from programmers side of view, without any proving any theorems, and for me it was simple and easy to grasp compared to all the stuff math professors where putting in our heads with a comment of "you can't be a good programmer if you don't know the math". Sure you can, easy!
I now know the mathematical stuff, so that I can talk with math-background programmers with all the log's differentials and stuff, but only for the reason so that they wouldn't faint. Because that stuff is useless 99.9% of the time, and when it is, it can be learned 1000x more effectively from programmers viewpoint.
Heck, programmers need at least 5 years to master a programming language+frameworks+best practices. Why on earth they should learn how to prove the theorems? Math student's do the math stuff, programmers get that stuff running, that's how it should work.
| 0.777778 |
Programming and maths are two completely unrelated things
|
LED as 230V AC indicator
|
Answers to other questions here (e.g. 1) show capacitors used to drop AC voltages to levels suitable for a LED. I've seen much simpler circuits such as the one below
simulate this circuit – Schematic created using CircuitLab
Assuming it's in a suitable enclosure, are there significant drawbacks or dangers to this circuit compared to others?
|
The types of AC powered LED drivers I've seen use a capacitor to drop the voltage/limit the current and to that extent it uses less "real" power.
The circuit you've drawn will (for normal 1.8V LEDs) pretty much dissipate 1W so it will get a little warm.
I guess the inability to pack some punch is the main drawback. The current into the LED is about 8mA every positive cycle so you don't get much light out compared to the heat.
I don't think there are any dangers (other than those you excluded)
| 0.888889 |
AC powered LED drivers use a capacitor to drop the voltage/limit the current
|
Quick and dirty way to run a process more than once
|
I am looking for very simple bash script that would allow me to launch a process a few times. What's essential to me is that after the processes terminate, everything will clean up automatically.
Intended usage:
bash multiplerun.sh 5 executable.sh parameters_to_executable
I could probably write it myself, but it would take me so long that I've decided to ask experts; I'm very little skilled at using *ix systems.
EDIT: Oh, and I forgot to add that I want to run them in parallel - running them one after another is pretty straightforward.
|
If you have GNU Parallel http://www.gnu.org/software/parallel/ installed you can do this:
seq 5 | parallel -N0 executable.sh parameters_to_executable
You can install GNU Parallel simply by:
wget http://git.savannah.gnu.org/cgit/parallel.git/plain/src/parallel
chmod 755 parallel
cp parallel sem
Watch the intro videos for GNU Parallel to learn more:
https://www.youtube.com/playlist?list=PL284C9FF2488BC6D1
| 1 |
How to install GNU Parallel?
|
Magento SendMail with attachment
|
I have been working on a custom extension and I need a function to send the generated CSV file. Can you please let me know what might be the possible error in it.
protected function _sendCSV($filename, $subject, $last_update, $now) {
$template_id = "svm_export_email";
$email_template = Mage::getModel('core/email_template')->loadDefault($template_id)->setSubject($subject." [".$now."]");
$template_variables = array(
'file_name' => $filename,
'last_update' => $last_update,
'now' =>$now,
);
$email_template->getProcessedTemplate($template_variables);
$sender = array('My Team' => Mage::getStoreConfig('trans_email/ident_general/email'));
$email_template->setFrom($sender);
$file = Mage::getBaseDir('var') . DS .'SVM'. DS .date('Y'). DS .date('m'). DS .$filename;
$attachment = $email_template->getMail()->createAttachment(file_get_contents($file));
$attachment->filename = $filename;
try {
$email_template->send('[email protected]','My Gmail');
} catch (Exception $e) {
Mage::log($e->getMessage(), NULL, self::LOG);
return false;
}
Mage::log($filename." File sent through mail", NULL, self::LOG);
return true;
}
I am getting the following error on invoking the function:
exception 'Exception' with message 'This letter cannot be sent.' in /my/magento/root/app/code/core/Mage/Core/Model/Email/Template.php:398
Thanks!
|
Check the createAttachment function from the file lib/Zend/Mail.php. See the function from below:
public function createAttachment($body,
$mimeType = Zend_Mime::TYPE_OCTETSTREAM,
$disposition = Zend_Mime::DISPOSITION_ATTACHMENT,
$encoding = Zend_Mime::ENCODING_BASE64,
$filename = null)
{
$mp = new Zend_Mime_Part($body);
$mp->encoding = $encoding;
$mp->type = $mimeType;
$mp->disposition = $disposition;
$mp->filename = $filename;
$this->addAttachment($mp);
return $mp;
}
We have to pass the extra parameters to the function. See example at http://stackoverflow.com/questions/17164077/magento-send-transactional-email-with-pdf-attachment
| 0.777778 |
Check createAttachment function from file lib/Zend/Mail.php
|
Javascript looping behaviour
|
The alltones array contains all the possible notes in music scale.
var alltones = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" ];
I want to take the user's input of a tone, and then construct a list that contains certain elements of the array.
Say I start at alltones[5] or "F", and want to take every second element of the array from that point and put it into my list, until I get back around to "F". The array is more like a circle than straight list. I'm a little unsure of how the array operates once the loop reaches the last element.
Do I approach the problem by generating a new array, based on the users input. Or is there a way that JavaScript knows to loop back to the start of an array once it reaches the end such that it treats the array like a circle?
An example:
User input = F
The output that I am seeking is to count (every two items) from F until we get back around the array to F
so the desired output would be => F G A B C# D#
|
There isn't an existing Array method to do what you want, but one is easily defined using Array.prototype.slice and Array.prototype.concat:
// move i elements from the start of the array to the end of the array
Array.prototype.lcycle = function(i) {
var xs = this.slice(0,i);
var ys = this.slice(i);
return ys.concat(xs)
};
// move i elements from the end of the array to the start of the array
Array.prototype.rcycle = function(i) {
var xs = this.slice(0,-i);
var ys = this.slice(-i);
return ys.concat(xs);
};
And then you can use lcycle and rcycle as normal array methods:
>>> alltones.lcycle(3)
[ "D#" , "E" , "F" , "F#" , "G" , "G#" , "A" , "A#" , "B" , "C" , "C#" , "D" ]
>>> alltones.rcycle(4)
[ "G#" , "A" , "A#" , "B" , "C" , "C#" , "D" , "D#" , "E" , "F" , "F#" , "G" ]
Note that both of these methods return a new array. If you wanted to mutate the original array, you could define similar methods using Array.prototype.splice.
// move i elements from the start of the array to the end of the array, mutating the original array
Array.prototype.lcycle_m = function(i) {
var args = this.splice(0,i);
args.unshift(0);
args.unshift(this.length);
this.splice.apply(this, args);
};
// move i elements from the end of the array to the start of the array, mutating the original array
Array.prototype.rcycle_m = function(i) {
var args = this.splice(-i);
args.unshift(0);
args.unshift(0);
this.splice.apply(this, args);
};
And again, you can can use lcycle_m and rcycle_m as normal array methods:
>>> alltones.lcycle_m(3)
>>> alltones
[ "D#" , "E" , "F" , "F#" , "G" , "G#" , "A" , "A#" , "B" , "C" , "C#" , "D" ]
>>> alltones.rcycle_m(3)
>>> alltones
[ "C" , "C#" , "D" , "D#" , "E" , "F" , "F#" , "G" , "G#" , "A" , "A#" , "B" ]
| 0.666667 |
Array.prototype.splice: move i elements from start to end of array
|
Gaussian blur - convolution algorithm
|
My program uses graphics convolution, an algorithm that processes pixels to make them round, soft and blurred. This particular algorithm is well-known, but its slowing down the operation of the whole program.
Can you suggest any improvements of this algorithm? I tried following from here, especially "ultimate solution" all the way to the bottom of that page, hoping to reduce the number of for loops one within another, but it did not work.
import perceptron.DoubleBuffer.ImageRenderContext;
import util.ColorUtility;
import java.awt.image.DataBuffer;
public final class Convolution {
DoubleBuffer buffer;
int[] d;
int s, h, e;
int[] temp;
/**
* Constructs new Convolution using the convolution degree and DoubleBuffer as input parameters.
*
* @param std
* @param b
*/
public Convolution(int std, DoubleBuffer b) {
s = 2 * std;
h = s / 2;
e = 256 / h;
d = new int[s];
buffer = b;
for (int i = 0; i < s; i++) {
d[i] = (int) (256 * gaussian(i - s / 2, std));
}
temp = new int[b.buffer.W * b.buffer.H];
}
/**
* Optimized power function. Poor quality?
*/
public static double power(final double a, final double b) {
final long tmp = (Double.doubleToLongBits(a) >> 32);
final long tmp2 = (long) (b * (tmp - 1072632447) + 1072632447);
return Double.longBitsToDouble(tmp2 << 32);
}
/**
* Optimized exponent function with little benefit.
*/
public static double exponent(double val) {
final long tmp = (long) (1512775 * val + (1072693248 - 60801));
return Double.longBitsToDouble(tmp << 32);
}
/**
* Calculate the Gaussian for blurring.
*
* @param x
* @param sigma
* @return
*/
static double gaussian(float x, float sigma) {
return exponent(-.5 * (x * x) / (sigma * sigma)) / (sigma * 2.506628);
//return exponent(-.5 * pow(x / sigma, 2)) / (sigma * sqrt(2 * PI));
//return exp(-.5 * pow(x / sigma, 2)) / (sigma * sqrt(2 * PI)); // actual equation
}
/**
* Process the loaded buffer (image).
*
* @param amount
*/
public void operate(int amount) {
ImageRenderContext source = buffer.output;
DataBuffer sourcebuffer = buffer.output.data_buffer;
DataBuffer destbuffer = buffer.buffer.data_buffer;
if (buffer.convolution != 0) {
int W = buffer.output.W;
int H = buffer.output.H;
int Hp = H - h;
// Do X blur
int i = 0;
for (int y = 0; y < H; y++) {
for (int x = 0; x < W; x++) {
int Y = 0, G = 0;
for (int k = 0; k < s; k++) {
int c = source.get_color_for_convolution.getColor(x + k - h << 8, y << 8);
int w = d[k];
Y += w * (c & 0xff00ff);
G += w * (c & 0x00ff00);
}
temp[i++] = (0xff00ff00 & Y | 0x00ff0000 & G) >> 8;
}
}
// Do Y blur
i = 0;
int notamount = 256 - amount;
for (int y = 0; y < h; y++) {
for (int x = 0; x < W; x++) {
int Y = 0, G = 0;
for (int k = 0; k < s; k++) {
int y2 = (y - h + k + H) % H;
int c = temp[x + W * (y2)];
int w = d[k];
Y += w * (c & 0xff00ff);
G += w * (c & 0x00ff00);
}
int c1 = (0xff00ff00 & Y | 0x00ff0000 & G) >> 8;
int c2 = sourcebuffer.getElem(i) << 1;
int r = ((c2 >> 16) & 0x1fe) - ((c1 >> 16) & 0xff);
int g = ((c2 >> 8) & 0x1fe) - ((c1 >> 8) & 0xff);
int b = ((c2) & 0x1fe) - ((c1) & 0xff);
r = r < 0 ? 0 : r > 0xff ? 0xff : r;
g = g < 0 ? 0 : g > 0xff ? 0xff : g;
b = b < 0 ? 0 : b > 0xff ? 0xff : b;
c2 = (r << 16) | (g << 8) | (b);
c2 = ColorUtility.average(c1, amount, c2, notamount);
destbuffer.setElem(i++, c2);
}
}
for (int y = h; y < Hp; y++) {
for (int x = 0; x < W; x++) {
int Y = 0, G = 0;
for (int k = 0; k < s; k++) {
int c = temp[x + W * (y - h + k)];
int w = d[k];
Y += w * (c & 0xff00ff);
G += w * (c & 0x00ff00);
}
int c1 = (0xff00ff00 & Y | 0x00ff0000 & G) >> 8;
int c2 = sourcebuffer.getElem(i) << 1;
int r = ((c2 >> 16) & 0x1fe) - ((c1 >> 16) & 0xff);
int g = ((c2 >> 8) & 0x1fe) - ((c1 >> 8) & 0xff);
int b = ((c2) & 0x1fe) - ((c1) & 0xff);
r = r < 0 ? 0 : r > 0xff ? 0xff : r;
g = g < 0 ? 0 : g > 0xff ? 0xff : g;
b = b < 0 ? 0 : b > 0xff ? 0xff : b;
c2 = (r << 16) | (g << 8) | (b);
c2 = ColorUtility.average(c1, amount, c2, notamount);
destbuffer.setElem(i++, c2);
}
}
for (int y = Hp; y < H; y++) {
for (int x = 0; x < W; x++) {
int Y = 0, G = 0;
for (int k = 0; k < s; k++) {
int y2 = y - h + k;
if (y2 < 0) {
y2 = 0;
else if (y2 >= H) {
y2 = H - 1;
}
int c = temp[x + W * (y2)];
int w = d[k];
Y += w * (c & 0xff00ff);
G += w * (c & 0x00ff00);
}
int c1 = (0xff00ff00 & Y | 0x00ff0000 & G) >> 8;
int c2 = sourcebuffer.getElem(i) << 1;
int r = ((c2 >> 16) & 0x1fe) - ((c1 >> 16) & 0xff);
int g = ((c2 >> 8) & 0x1fe) - ((c1 >> 8) & 0xff);
int b = ((c2) & 0x1fe) - ((c1) & 0xff);
r = r < 0 ? 0 : r > 0xff ? 0xff : r;
g = g < 0 ? 0 : g > 0xff ? 0xff : g;
b = b < 0 ? 0 : b > 0xff ? 0xff : b;
c2 = (r << 16) | (g << 8) | (b);
c2 = ColorUtility.average(c1, amount, c2, notamount);
destbuffer.setElem(i++, c2);
}
}
} else {
buffer.buffer.data_buffer = buffer.output.data_buffer;
}
}
}
|
Naming naming naming
Your code is very intimidating - it is filled with single letter variable and members (s,h,e,d...). Those which are not single letter are generic and unhelpful (temp, buffer, notamount...). This makes your code very unreadable.
You also use a lot of literal numbers (2, 256, 1072632447, 60801...) which make no sense to a person who is not familiar with your algorithm. Use constants to make your code more readable.
Your comments are also not useful for someone to read and understand your code.
If you want a serious code review, you must make your code readable, break large methods (operate) into smaller ones, etc.
| 0.888889 |
Naming naming naming Your code is very intimidating
|
Making Simple IF Statements Shorter
|
If we assume we have this little snippet of code:
string str = "checked";
bool test1;
if (str == "checked")
{
test1 = true;
}
else
{
test1 = false;
}
Is it bad practice to change a simple statement like this to the following?:
bool test2 = (str == "checked");
Because they work exactly the same, and work as required, so I can't imagine how it would be. However, as a young, inexperienced programmer I am not aware of whether such a thing is frowned upon or not. Can anyone tell me, if this is NOT ok, why not?
The following test program:
using System;
public class Test
{
public static void Main()
{
string str = "checked";
bool test1;
if (str == "checked")
{
test1 = true;
}
else
{
test1 = false;
}
bool test2 = (str == "checked");
bool test3 = (str != "checked");
Console.WriteLine(test1.ToString());
Console.WriteLine(test2.ToString());
Console.WriteLine(test3.ToString());
}
}
Outputs:
True
True
False
Any insight etc is appreciated.
|
Is it bad practice to change a simple statement like this to the following?:
bool test2 = (str == "checked");
No, it's good practice. To me, the longer code:
if (str == "checked")
{
test1 = true;
}
else
{
test1 = false;
}
indicates that the programmer doesn't understand Boolean expressions. The shorter form is much clearer. Similarly, don't write:
if (boolean-expression) {
return true;
} else {
return false;
}
Just write return boolean-expression;
| 1 |
Is it bad practice to change a simple statement like this to a: bool test2?
|
Bottom bracket bearing Issues
|
Been having some bottom bracket (BB) woes. Noticed a click on the top of the left pedal stroke decided to re-grease the BB. Took it apart cleaned everything re-greased, put it back together.
Roll forward a week.
Notice my cranks sticking here and there, gets progressively worse on the ride. Get it home and off the bike notice my bike has turned into a rain-stick (this provided no calming effect)
Que another strip down of the BB.
Upon inspection, I found all the bearing on the non lockring side of the where out of the cage, which now would no longer hold them. I pinched the cages with pilers to secure the ball bearings back in place. Re-greased repacked.
Lifted my bike out today for my cycle to work jingle-jingle; LOOSE BEARING!
Cycle to work was sub 3miles so risked it.
Want to take care of this ASAP, so my questions are:
1. I figure I am over-tighting the bottom bracket, causing the damage to the cage, however what else could cause?
BB info:
Campagnolo Italian threaded
plastic sleeve is in two parts, the smaller part pushes into the
other.
2 caged bearings from memory 8/9 bearings in each cage.
Two screw in cones one locking.
here is a pics of my spindle:
Brev whatever that means
2. What size bearing does an Italian threaded BB take?
|
Note that most bottom brackets don't use a cage. Rather you get enough loose balls to fill the race, gob some grease into the race of the cup, press the balls into the grease, and install. The cage should not be necessary to hold the balls in place.
In your case you may want to consider replacing the cups, bearings, and shaft with a cartridge -- much less to go wrong.
| 0.666667 |
Replace cups, bearings, and shaft with cartridge
|
Are there any commercially available crystals in the sub 32 kHz range?
|
I'm looking for a low power clocking solution and it looks like crystals bottom out at 32 kHz. Are there any low power (nA) solutions (crystals/ceramic resonators/custom transistor oscillator circuitry) that operate on nanoAmps of power in the single digit kHz range or lower?
EDIT
I wanted to summarize the facts from the answers below as well as my own research:
Crystals do not commercially exist lower than the standard 32 kHz flavor, due to size/resonance constraints of the quartz used internally (thanks to Olin Lathrop)
For a 32 kHz clock solution in the 100s of nA range, this oscillator IC could be used (thanks to stevenvh)
For lower frequencies (but not necessarily nA current consumption) many silicon oscillators, frequency synthesizers, PLLs, or real time clocks include internal clock divider circuitry and can be used to generate clocks as "slow" as 1 Hz.
So there is no solution which satisfies both of the constraints of sub-32 kHz & sub-\$\mu\$A operation, but individual solutions that will satisfy one or the other.
|
Some manufacturers refer to 100kHz ~ 1.8432MHz as "very low frequency". Below 100kHz you'll find only a few specific values like 77.5kHz for (DCF77 receivers) and of course the 32.768kHz watch crystal. You won't find standard crystals below 10kHz.
Nothing lost, by the way. They won't help you meeting your low power requirements, anyway. A crystal needs a certain power to maintain its oscillation, and if you look at the datasheets you'll often see drive levels in the order of 1mW.
The lowest power microcontroller application using a crystal I designed was an MSP430 running at 32.768kHz, and that used 3\$\mu\$A, a thousand times your requirements.
This oscillator still uses 300nA, that's 0.3\$\mu\$A.
| 0.333333 |
100kHz 1.8432MHz is "very low frequency"
|
Bug in my C code to reverse words in a string
|
I was practicing some programming problems and tried to code the popular "reverse words in a string" problem.
I tried to come up with my own code in C. I am able to partially get it right. That is, "hello world" becomes "world olleh". I am wondering what the bug is here. I think somewhere I am creating an off by 1 bug.
As much as possible, I wanted to do it without using library functions. I searched here for this problem & found many solutions, but I'd like to know why my solution doesn't work.
Here is the code:
#include <stdio.h>
#include <string.h>
void reverse(char*, int);
int main(int argc, char **argv)
{
char st[]= "hello world";
int len = strlen(st);
int i=0,j=0;
reverse(st,len-1); // Reverse the entire string. hello world => dlrow olleh
while(st[j]){ //Loop till end of the string
if ( *(st+j) == ' ' || *(st+j) == '\0' ) { //if you hit a blank space or the end of the string
reverse(st+i,j-1); // reverse the string starting at position i till position before the blank space i.e j-1
i=++j; //new i & j are 1 position to the right of old j
}
else {
j++; //if a chacacter is found, move to next position
}
}
printf("%s",st);
return 0;
}
void reverse(char *s, int n)
{
char *end = s+n; //end is a pointer to an address which is n addresses from the starting address
char tmp;
while (end>s) //perform swap
{
tmp = *end;
*end = *s;
*s = tmp;
end--;
s++;
}
}
Thank you!
UPDATE: Based on @Daniel Fischer's answer, here is the correct implementation : http://ideone.com/TYw1k
|
I think that you want to reverse words in a string, not reverse the whole string and then rereverse single words. So, delete first reverse and then apply suggested changes above.
#include <stdio.h>
#include <string.h>
void reverse(char*, int);
int main(int argc, char **argv)
{
char st[]= "hello world";
int i=0, j=0;
while(st[j]){ //Loop till end of the string
if ( st[j] == ' ') { //if you hit a blank space or the end of the string
reverse(&st[i], j - i - 1); // reverse the string starting at position i till position before the blank space i.e j-1
i = ++j; //new i & j are 1 position to the right of old j
}
else {
j++; //if a chacacter is found, move to next position
}
}
reverse(&st[i], j - i - 1);
printf("%s\n",st);
return 0;
}
void reverse(char *s, int n)
{
char *end = s + n; //end is a pointer to an address which is n addresses from the starting address
char tmp;
while (end > s) //perform swap
{
tmp = *end;
*end = *s;
*s = tmp;
end--;
s++;
}
}
Take care when input string would be '\0' or something like ' Hello world'. Above code doesn't managed this kind of situations. Think about it!
| 0.888889 |
Reverse words in a string
|
Another instructor is pushing me out of the classroom right after my class ends
|
I am a graduate student in math in my final year, and for several years have been teaching at my department as a lecturer. This semester, in the same lecture hall there is another lecture that starts 20 minutes after my class ends. It's taught by another instructor from my department. I usually have many students coming to office hours and there are also students asking questions immediately after lecture. Due to other activities, I cannot have office hours right after the lecture this semester and can only stay for about 15 minutes to answer questions.
Many times in the past I had a similar situation and never had any issues with it. This semester the instructor who is teaching right after often arrives 20-15 minutes before her class starts and tells me immediately that I have to go with my students somewhere else.
I make sure to leave the blackboard clean and take all my stuff away from the instructor's desk before she arrives, but I do believe that I have a right to stay in the classroom after my lecture for at least 5-10 minutes. There is no vacant classroom around, and I don't have time to go with students to my office, which is in a different building.
Last time the instructor told me in front of my students that I don't understand "simple things" and that I am "playing games". When I was talking to one of my students, she stood very close to us and clearly demonstrated that she wanted us out. I tried to explain her that I couldn't go anywhere else due to my time constraints, but she didn't want to listen to me. I really don't understand what "simple" things she meant and what "games" I am playing.
We leave the board clean. She doesn't need to set up a projector. She can still talk to her students before her class starts, if she wants to (even though it seems like her students don't ask her any questions before their class). So, I don't see how I cause any disruption.
I had met this woman many times before this semester, but we never talked. I didn't see her talking to other instructors/students much, and she seems to be quite reserved and a bit neurotic. She doesn't want to have any conversation with me regarding the issue.
I felt really offended after last class when she said those things to me in front of my students. What would you do in my case?
Added later: There are no official rules regarding classroom occupancy between classes. Instructors are supposed to use common sense and be reasonable. For me using 50% of the break time seems reasonable to answer questions after lecture seems reasonable. I agree that for some people it may not.
I don't block the entrance to the classroom. A few students from the next class who come earlier always go ahead and take their seats as soon as my students start leaving the room. I also had one of the students from the next class listening to my explanation to one of those after-class questions and asking me further questions before their class (which is the same class as I am teaching, just a different section). Maybe the instructor got jealous, I don't know.
The entrance to the classroom is from its front (not back), so I do stay in the front. But it is a big lecture hall, and there is a plenty of space in front of the room (the board itself consists of 8 huge panels).
Also, during my career as a grad.student who is also teaching for the department, I have had several observations from experienced professors who are considered to be great teachers at the department and are in charge of undergraduate teaching policy. In my evaluations the fact that there are always several students approaching me with questions after class considered as very positive, meaning that students find me approachable.
Thank you everyone for answers.
|
If I were in your situation, I would ask the other professor for a reason and explain that I wanted to make an announcement to my students at the next lecture. If the response is "because I want you out" then I would politely explain that I would announce to the students that we could only remain for 10 minutes after class after which time we would all need to be out of the room.
No need to make it confrontational. I find that if you offer to help people solve a problem that helps reduce tension. If this professor doesn't actually have a problem then offering to help solve a problem will be a non-confrontational way of pointing that out.
This worked for me last semester. We only had 15 minutes between classes and my course was taught in a computer lab. Quite often students had questions about projects they were working on and already had their code pulled up on their screen. Unfortunately the students from the following course would be filing in and because their course required them to have access to code on a particular machine (shared drives wouldn't work) they needed particular seats which my students were still occupying.
In my case, the professor after me simply explained why he needed the room and at the next lecture I explained to my students why they needed to exit within 5 minutes of the end of class. Everyone understood, no tension, no confrontation.
| 1 |
How to make an announcement to my students at the next lecture?
|
passing data from javascript to php using Jquery
|
Maybe this question has been asked before but I am struggling in doing this. I have got a php file which does not include any piece of php code (might be in the future),it includes just javascript and some html. What I want to do is clicking a button in this php file to send some amount of data to another php file.
put it this way..
1-I have got a saveProfile function in a.php and a button is calling this function
function saveProfile (){
var variableD = 'sample data';
$.post("dbConn.php", { js: variableD});
}
2-I have got another php which is called dbConn.php that receives data and stores in a database table.
I have found so many examples. I have applied them but it still does not work and is driving me nuts. I am a java programmer but new in php.
Any help is appreciated.give me some clean sample code or if you see any mistake please kindly warn me. Thanks to all in advance...
Regards.
Ozlem.
|
Thanks for all the answers. I have solved the problem. The data had being passes but I was not able to handle it properly. I just add a dummy code to test it.It worked. I will upload the code after I have finished.Thanks to all.
| 0.777778 |
The data had been passed but I was not able to handle it properly
|
How to Add Dictionary<String,String> Data in SolrNet
|
I want to add record with Solr.net I am getting Error.
The remote server returned an error: (400) Bad Request.
my code is like this.
In Schema file
field name="id" type="int" indexed="true" stored="true" required="true" /><br>
field name="Tags" type="string" indexed="true" stored="true" multiValued="true"/>
In my class
public class ProductTest2
{
[SolrUniqueKey("id")]
public int Id { get; set; }
[SolrField("Tags")]
public Dictionary<string, string> Tags { get; set; }
}
Code where I want to add new Rows
solr.Add(new ProductTest2()
{
Id = i,
Tags = new Dictionary<string, string> { { Convert.ToString(dt.Rows[i]["Filter1_ID"]), Convert.ToString(dt.Rows[i]["Filter1"]) } }
}
solr.Commit();
When I execute this code its showing error. But if I Remove the Dictionary Type and add another type then working fine. please suggest me what type I should give for Dictionary.
currently i have used type="string".
Thanks in Advance.
Ashutosh
9818842034
|
SolrNet supports mapping dictionaries to dynamic fields. In this case, the parameter of [SolrField] is a prefix for the field name. This is explained in more detail in the SolrNet wiki.
If you want to use a multivalued field instead of a dynamic field to store dictionaries, it may be possible by implementing ISolrDocumentPropertyVisitor. It's not trivial to do so, though, and I don't think it's a good idea anyway.
| 0.777778 |
SolrNet supports mapping dictionaries to dynamic fields
|
How do you give cells in a TableView a unique reference
|
I'm still very new to iOS development, so bear with me.
I've got a TableView using static cells to contain options (click to check), I am able to select the cells fine. I'd like to assign a value (identifier) to each cell, so that when a cell is selected or de-selected I can add/remove it from an array. Then, once the editing has finished, use the references stored in the array to update the respective CoreData attributes.
My google skills have failed me today, so a push in the right direction would be very much appreciated.
Thanks.
|
You don't need to hold a reference to each cell. The data source should be a mirror of what is showing on the screen. You can know what should be removed added by using:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
or when you deselect it:
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
With NSIndexPath you can then know what has been selected/deselected:
| 1 |
Data source should be a mirror of what is showing on the screen
|
How to enable or disable services?
|
I read about how to enable and disable services in Ubuntu and it seems that there are different possibilities to manage them.
The first method I found is update-rc.d to add new services to startup, which aims on the /etc/init.d folder and its contents.
The other one I found is to edit .conf files in the /etc/init folder.
What's the recommended way to enable / disable / add services and why?
Could you please give a short bulletproof step by step example on how to add a service in Ubuntu and enable and disable it?
|
Try using sysv-rc-conf
sudo apt-get install sysv-rc-conf
and to start managing the services, execute
sudo sysv-rc-conf
Which will bring up interactive window like this
You can further navigate through pages using Ctrl+n for next page and Ctrl+p for previous page .You can enable and disable services by selecting SPACE on desired runlevels.
Another alternate would be Jobs-Admin by installing through
sudo apt-get install jobs-admin
Which also provides GUI like this
For showing more jobs , you have to tick the Show Protected Jobs from its menu.
And third option would be chkconfig,
sudo apt-get install chkconfig
It can be used via CLI chkconfig, showing list of On/Off jobs.
Also we can view system services using chkconfig –list
Services can be turned on using
chkconfig <service> on
Services can be turned off using
chkconfig <service> off
And we can even add our own service, using a proper init script with proper headings.
chkconfig --add <service>
And another option can be referred here update-rc.d , explained briefly here.
Note that for Ubuntu Server 12.04, update-rc.d is used instead of chkconfig.
| 0.888889 |
sudo apt-get install sysv-rc-conf
|
What is meant by the expression "living in darkness"?
|
At my church (Calvary Chapel) we have guest speakers from time to time. Many of them mention the same phrase "living in darkness", refering to the time before they were saved.
Are there Biblical (or more specifically New Testament) references to this concept and a description of what it entails or is it just a relative and subjective phrase coined by man?
|
Variants of the phrase appear several times in 1 John
1 John 1:5-6 (ESV)
5 This is the message we have heard from him and proclaim to you, that God is light, and in him is no darkness at all. 6 If we say we have fellowship with him while we walk in darkness, we lie and do not practice the truth.
1 John 2:9-11 (ESV)
9 Whoever says he is in the light and hates his brother is still in darkness. 10 Whoever loves his brother abides in the light, and in him there is no cause for stumbling. 11 But whoever hates his brother is in the darkness and walks in the darkness, and does not know where he is going, because the darkness has blinded his eyes.
Darkness is contrasted with the picture of God as light, and describes living in sin without knowing or seeing God.
| 1 |
1 John 1:5-6 (ESV) 5
|
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?
|
As several people have already recommended I think "Eisenhorn" is a fantastic Warhammer 40k book and is a pretty good place to start.
I also really enjoyed the Word Bearers series, which begins with "Dark Apostle", if you would like to dig into the corrupt world of Chaos Space Marines.
Over on my blog I have actually made a list of suggestions for new readers, which you might want to check out: Suggestions for new 40k Readers
| 0.833333 |
"Eisenhorn" is a fantastic Warhammer 40k book .
|
Does anybody use an external battery for iPhone?
|
Do external batteries for iPhones work well?
I have an iPhone 4S
For example, is it true that I can charge up to 6 times my iphone with this product?
|
Yes - and most people I know fit into strongly preferring a rechargeable solution when they use the device regularly to extend power on the go.
Those that use the device occasionally or on long trips seem to gravitate to an inexpensive sled for AA batteries and carry a mix of expensive lithium cells and typical non-rechargeable cells.
| 1 |
AA batteries are rechargeable
|
Should the public website be inside the VPN, with its associated private website?
|
On the near future I will have a WordPress blog, public and visible to anyone, that has a members area. This members area accesses some private data on a special database with financial data, so this kind of info should only be viewable to customers of the site.
The private site will be running inside a VPN on a business LAN and a little server, and I wonder if hosting that private part together with the public site would be a good idea.
In fact, due to WordPress vulnerabilities (it is a desired target right now) I think that if an attacker gains access to the WP site and that's inside the VPN, then he would be able to attack "from inside" and eventually he could even access to the private site and its data.
Wouldn't it be more appropiate to have the public site outside, on a VPS for example? The members area would be accessed through a secure protocol (HTPPS), and I wonder if there are some recommendations on this subject.
|
The first question is whether the public and private sites actually have to be run together. Ideally they would be run separately, with the public site on an external server and the private site on a server in the LAN.
If they have to be run on the same server then the risk of the private data being compromised is the same regardless of whether it is hosted externally or internally. The question is whether the compromised server can be used to access data and systems unrelated to the site. In order to protect against this you want to host the server in a DMZ if you host it internally.
| 0.777778 |
Public and private sites have to be run separately if they are run on the same server
|
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?
|
Clojure (or rather clojure.contrib.monads) has a continuation monad; here's an article that describes its usage and motivation.
| 0.666667 |
Clojure.contrib.monads
|
Sodium Bisulfate vs Sodium Bisulfite
|
I'm wanting to do a follow up to this Q&A in the cooking stack regarding browning avocados. I specifically want to expand my experiment to to include the options in Wayfaring Stranger's Answer. Unfortunately, I managed to get the wrong stuff, and shipping rules make exchanging it problematic.
I am the proud owner of $500~\mathrm{g}$ of sodium bisulfate ($\ce{NaHSO4}$), instead of sodium bisulfite ($\ce{NaHSO3}$).
Dammit Jim! I'm a cook not a chemist!
What I have learned is that that both compounds are used as food additives towards the same end, and that my stuff has a slightly higher LD50. That's it.
Can anyone advise as to substituting my compound for the other? I'm not interested in tasty guacamole at this point, I'm really only looking at browning. If I'm trying to more or less duplicate the more successful experiments of the University of Florida, should I start with the same ratios? Or more or less of the additive? I can get sodium metabisulfite (also an anti-oxidant food additive) locally, if that would be a better option.
EDIT: So far, answers have all been consistent in that I have a half-kilo of white powder that is useless to me. I will make a trip to the wine-making shop and acquire some sodium metabisulfite. That still leaves me with the question of how much? The University of Florida got the results I'd like to duplicate with $30~\mathrm{mg}$ of sodium bisulfite per $100~\mathrm{g}$ of avocado. Should I start with the same ratio of sodium metabisulfite?
|
Sodium bisulphate (NaHSO4): an acid
Sodium bisulphiTe (NaHSO3): an antioxidant
Sodium metabisulphiTe (Na2S2O5): another antioxidant
In short, bisulphate and bisulphite are not interchangeable, but bisulphite and metabisulphite are.
Sodium metabisulphite is prepared from sodium bisulphite via dehydration, as in this equation:
$$\ce{2 NaHSO3 -> Na2S2O5 + H2O }$$
It's reversible in aqueous solution. The assumption that 30 mg of metabisulphite contain the same amount of sulphite as 30 mg of bisulphite is OK, the error is small, about 10 %. The correct amount would be 27 mg of metabisulphite.
You'd ask yourself if pasteurization (75 deg. C, 30 seconds) would work to deactivate the polyphenoloxidase without affecting flavour too much.
I'd also suggest searching Pubmed (it's a decent alternative to commercial citation databases) for such keywords as "polyphenol oxidase" (that's the enzyme that causes browning), "inhibition" and "sulfite".
If you want hands-on answers I'd suggest going to the library and get (via interlibrary loan) a copy of this paper: Plant Foods Hum Nutr. 1995, 47, 245-56, "The control of polyphenol oxidase activity in fruits and vegetables. A study of the interactions between the chemical compounds used and heat treatment."
From the abstract: ... Interactions between the use of ascorbic acid,
citric acid, EDTA, sodium metabisulphite and heat treatment (70
degrees C for 2 min) in the control of PPO activity were studied in
avocado ..., banana ..., apple ..., pear ..., peach ..., potato ...,
eggplant ..., mushroom ... and
hearts-of-palm ... . The results demonstrated that
PPO of avocado and eggplant was most resistant to inhibition by the
methods used. ... The results indicated that,
with the exception of PPO from avocado, the most adequate alternative
method to substitute for the use of SO2 in the control of PPO was a
combination of ascorbic acid, citric acid and heat treatment.
This shows that how to get on top of browning while still having a presentable product is a tough problem and an active area of research. Also, avocado seems a specially hard case.
| 0.888889 |
Sodium bisulphiTe and metabisulphite are not interchangeable, but are reversible .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.