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 is range measured in League of Legends?
I know different games use different techniques and units of measurement. In Starcraft II one range for attack is about the width of one zergling. In Guild Wars the range is some fraction of the compass or aggro range (Spears have ~0.7x aggro range, longbows ~1.2x) Most (or all?) meelee champions in LoL have an attack range of 125. The attack radius for range champions differs quite a bit, e.g. 425 for Urgot, 510 for Twisted Fate and 550 for Heimerdinger. I wonder how is range exactly measured in League of Legends?
I can't tell you exactly how much a unit is on the screen, there are however quite a few ways to get an idea of what different range represent. A "distance unit" is a predefined distance on the field of justice. Range and speed are calculated from this unit. Movement speed Movement speed is the amount of "distance units" you travel in one second Spell range There are many spells with many different ranges. To get an idea of the range it represents, put you mouse over the spell and a circle will show you the range it represents. Here is an example for Kassadin's null sphere with a range of 700 : Auto-attack range There isn't anything that can show you directly the range you have. You have to get use to it and compare it with your spells range to get a good idea. To get an idea of what 125 represents, Nunu's consume has a range of 125 :
1
How much a unit is on the screen
Seperation of drawing and logic in games
I'm a developer that's just now starting to mess around with game development. I'm a .Net guy, so I've messed with XNA and am now playing around with Cocos2d for the iPhone. My question really is more general though. Let's say I'm building a simple Pong game. I'd have a Ball class and a Paddle class. Coming from the business world development, my first instinct is to not have any drawing or input handling code in either of these classes. //pseudo code class Ball { Vector2D position; Vector2D velocity; Color color; void Move(){} } Nothing in the ball class handles input, or deals with drawing. I'd then have another class, my Game class, or my Scene.m (in Cocos2D) which would new up the Ball, and during the game loop, it would manipulate the ball as needed. The thing is though, in many tutorials for both XNA and Cocos2D, I see a pattern like this: //pseudo code class Ball : SomeUpdatableComponent { Vector2D position; Vector2D velocity; Color color; void Update(){} void Draw(){} void HandleInput(){} } My question is, is this right? Is this the pattern that people use in game development? It somehow goes against everything I'm used to, to have my Ball class do everything. Furthermore, in this second example, where my Ball knows how to move around, how would I handle collision detection with the Paddle? Would the Ball need to have knowledge of the Paddle? In my first example, the Game class would have references to both the Ball and the Paddle, and then ship both of those off to some CollisionDetection manager or something, but how do I deal with the complexity of various components, if each individual component does everything themselves? (I hope I'm making sense.....)
From my experience in development, there is no right or wrong way to do things, unless there is an accepted practice in the group you work with. I have met with opposition from developers who are averse to separating out behaviors, skins etc. And I am sure they will say the same about my reservation to writing a class that includes everything under the sun. Remember you have to not only write it, but be able to read your code tomorrow and at a future date, debug it and possibly build on it in the next iteration. You should choose a path that works for you (and team). Picking a route that others use (and is counter-intuitive to you) will slow you down.
0.333333
Choosing a path that works for you (and team)
Using Force.com Site for Customer Portal. Can Customer Portal Login page URL be hidden/deactivated? in lieu of the Site URL
We launched our Customer Portal first without Force.com Sites. Then after a couple of months we deployed a Force.com site to be the front end of the portal. The issue i am having is that some customers continue to access the portal through the Customer Portal URL which causes issues with some VF pages and custom links once they are logged in. My question, Is there anyway to prevent users from logging in using the Customer Portal Login URL and force them to use the Force.com Site login page?
no but you can inject Javascript via the Customer Portal Header to redirect the user to your Force.com Site. https://help.salesforce.com/htviewhelpdoc?err=1&id=customer_portal_enabling_features_settings.htm&siteLang=en_US
0.888889
Javascript via Customer Portal Header to redirect user to Force.com Site
What largest websites are written in php?
What are some of the largest and most popular websites in the world written in php? I know 1 - this is wikipedia, tell please another large website.
I would take a look at the graph on this site which displays some of the worlds largest websites and shows what they are built on http://royal.pingdom.com/2007/08/22/what-nine-of-the-world%E2%80%99s-largest-websites-are-running-on/ And one other list which is pretty similar http://blog.richardknop.com/2010/03/some-really-large-php-websites/
1
graph on royal.pingdom.com/2007/08/22/what-nine-of-the-world%E2%
Java final variables changes at the execution time
I don't know the reason fo that. Maybe you could help me So code here creating a frame with 8 sliders. public class MyFrame extends JFrame { ImagePanel imagePanel; final int Minimum = 0; final int Maximum = 10; final int NumberOfSpheres = 8; final int NumberOfScales = 10; MyRandomAccessFile file; final String[] s = {"Друзья и Окружение", "Отношения", "Карьера и Бизнес", "Финансы", "Духовность и Творчество", "Личностный Рост", "Яркость Жизни", "Здоровье и Спорт"}; private final Color[] colors = {Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.BLUE, Color.PINK, Color.MAGENTA, Color.DARK_GRAY}; private final int[] array = {1, 0, 0, 0, 0, 0, 0, 0}; public MyFrame () { setTitle("Wheel Of Life"); MySlider[] sliders = new MySlider[NumberOfSpheres]; JButton saveButton = new JButton("Save"); MyActionListener listener1 = new MyActionListener(); saveButton.addActionListener(listener1); file = new MyRandomAccessFile(); //String s3 = "0 0 0 0 0 0 0 0"; //array = stringToIntArray(s3); array[1] = 4; JLabel[] labels = new JLabel[NumberOfSpheres]; imagePanel = new ImagePanel(colors, array); System.out.println(array[1]); JPanel mainPanel = new JPanel(); JPanel[] sliderPanels = new JPanel[NumberOfSpheres]; JPanel mainSliderPanel = new JPanel(new GridLayout(4, 2, 20, 20)); MyChangeListener listener = new MyChangeListener(); for (int i = 0; i < NumberOfSpheres; i++) { sliders[i] = new MySlider(s[i]); sliders[i].addChangeListener(listener); labels[i] = new JLabel(s[i]); labels[i].setForeground(colors[i]); labels[i].setFont(new Font("Droid Sans", Font.BOLD, 20)); sliderPanels[i] = new JPanel(); sliders[i].setMinimum(Minimum); sliders[i].setMaximum(Maximum); System.out.print(array[i]); sliders[i].setValue(4); sliders[i].setMajorTickSpacing(1); sliders[i].setMinorTickSpacing((int) 0.1); sliders[i].setPaintLabels(true); sliders[i].setPaintTicks(true); sliderPanels[i].setLayout(new GridLayout(2, 1, 5, 5)); sliderPanels[i].add(sliders[i]); sliderPanels[i].add(labels[i]); mainSliderPanel.add(sliderPanels[i]); } mainPanel.setLayout(new BorderLayout()); mainPanel.add(imagePanel, BorderLayout.CENTER); mainPanel.add(mainSliderPanel, BorderLayout.EAST); mainPanel.add(saveButton, BorderLayout.SOUTH); add(mainPanel); } And the output is this 4 99999999 How can final variable change its value at the execution time, what the hell??? Actual value of variable is depend on value that I writing at sliders[i].setValue(4); But I don't know how exactly... And I tried to set a watchpoint for this variable... Doesn't working. One time its zero and next time program stop in this for loop value is 9, 4 or whatever...
When declaring a variable final in Java its like are saying that the name wont be reassigned something else. Doesn't mean that the contents won't be mutable. The contents of Arrays and Objects in general can be modified. final List<String> list = new ArrayList<String>(); list.add("foo");//ok list.add("bar");//ok list.remove(0);//ok list = new ArrayList<String>(); //should cause compile error
0.888889
Variable final declaration in Java
What is the difference, if any, between 'art', 'the arts', and 'Art'?
In answer to this question, there was some discussion about whether these two sentences are equivalent: Art nurtures the soul. The arts nurture the soul. Are they equivalent? 'The arts' is a common but woolly term and 'art' is notoriously difficult to pin down. Oxforddictionaries.com gives the following definitions: art [mass noun] the expression or application of human creative skill and imagination, typically in a visual form such as painting or sculpture, producing works to be appreciated primarily for their beauty or emotional power (the arts) the various branches of creative activity, such as painting, music, literature, and dance What practical differences in usage are there (if any)? Also, does Art (capital A) have a special meaning distinct from art (lower case a)?
The arts refers to literature, fine arts and performing arts. The term art usually means fine arts, but can also refer to technique and creativity.
1
The arts refers to literature, fine arts and performing arts
Removing a javscript from homepage
i am trying to remove the validation.js script from my home page as it is not need here. I am using this code in my page.xml <cms_index_index> <reference name="head"> <action method="removeItem"><script>prototype/validation.js</script></action> </reference> </cms_index_index> But the script is still being loaded. What am i doing wrong? Thanks
Try like this: <cms_index_index> <reference name="head"> <action method="removeItem"> <type>js</type> <script>prototype/validation.js</script> </action> </reference> </cms_index_index> The removeItem method receives 2 parameters. The type of the resource and the name of the resource. You were missing the type.
1
RemoveItem method receives 2 parameters
Are there English equivalents to the Japanese saying, “There’s a god who puts you down as well as a god who picks you up”?
There is an old Japanese saying, “捨てる神あれば、拾う神あり-Suterukami areba hirou kami ari,” meaning “There’s a god who puts you down as well as a god who picks up you.” In other words, “In this world, some people help you, and some people harm you” or “Fortune and misfortune come alternately.” For example, when you are fired from an IT company, and then hired by its rival company with a higher salary three months later, your peers will say to you “You're a lucky man. There’s a god who throws you away as well as a god who picks you up.” I’m curious to know if there are similar sayings in English to “Suterukami areba hirou kami ari.”
To translate this expression, you need to cope with the very different attitudes towards divinity of Japanese and 'Western' culture. When a Japanese expression talks about the kami, it's in a different atmosphere than when an English expression talks about God. There are many kami, they come and go. The Japanese expression suggests that there are many powers in the world and that different ones are influential at different times. The monotheistic view is very different: there's one deity. It's very different for the one and only deity to dish out varying results than for random encounters with different kami to result in different outcomes. Thus, you might want to stick to expressions that don't involve God, but rather talk about fate, or luck, or use the passive. I think you're better off avoiding divinity altogether, as you lose a lot more translation quality by referencing the very different divinity than you gain by maintaining the reference to divinity at all.
1
When a Japanese expression talks about the kami, it's in a different atmosphere than when an English expression speaks about God
Removing the spaces between words
Is there any way to remove spaces from in between the words in a text? Something like \RemoveSpaces{This is my sentence.} which will be converted to Thisismysentence.
\makeatletter \def\RemoveSpaces#1{\zap@space#1 \@empty} \makeatother
0.888889
Makeatletter defRemoveSpaces#1 @empty makeatother
Single entry with multiples pages
I search how to have a entry with multiple pages if the product created has multiples colors. Indeed, i work on a product website and my client want to have the possibility to define a product in different color but he wants one channel in admin but several pages in front-end. And in search system, he wants to find only one product :-( There is a possibility (module, add-on, custom field) to have a system in admin when it's activate it's create multiple pages but with only one channel. I hope someone'll understand what i try to do :-) Thanks.
This is perfectly feasible in EE without any add-ons. Since EE doesn't really have a concept of pages, a single channel entry can appear at multiple URIs no problem - You'll just need to use some logic in your template to show the right entry. There are lots of different ways to approach this, but let's say you want your URIs to be: /products/widget-A/in/blue /products/widget-A/in/red /products/widget-B/in/blue /products/widget-B/in/red You could use a category or custom field to define the colours and then pipe the values through to a channel entries query. For example, with categories, your products/index template could look a bit like this (also using Low Seg2Cat to get the cat ID here): {exp:channel:entries channel="products" disable="member_data|pagination" dynamic="no" category="{segment_4_category_id}" url_title="{segment_2}" limit="1" } <h1>{title}</h1> {/exp:channel:entries} You could do the same thing with a custom field, such as checkboxes or radio buttons and the search parameter. Just be a little bit careful that you don't pipe URI segments directly into a channel entries tag as this could be a (minor) security risk (exposing private entries etc if you're not careful). I would usually use Stash to pre-screen/normalise any incoming segments to prevent this.
0.666667
How to show a channel entry at multiple URIs?
Preventing Superscript from being interpreted as Power when using Ctrl+^ shortcut?
I have very strong desire to use superscript as the index of the variable. However, it looks like that the Mathematica automatically recognize the superscript as the power and I got message that my variable with superscript is 'protected'. Could you help me to make the superscript used as the index of the variable instead of power? UPDATE (16-June-2015): This question is being reopened and a bounty is being awarded on this. Previous answers are very good, however the bounty is to be awarded on an answer which solve this specific problem: How to change the behaviour of Ctrl+^ keybinding so that it produces Superscript instead of Power.
When I asked people about this before, they wrote up: Displaying index as subscript on output: e.g. C[i] -> C_i with Notation[...] or Interpretation[..]? As with the other answers, this focuses on only output. But uses an Interpretation instead of just changing the functions themselves. You should just be able to copy/paste the code to try it out. To change from subscripts to superscripts for your code, it should just be a copy/replace. As for why you shouldn't use subscripts/superscripts, it took me a while to figure it out, but basically it is because $x_i$ is not a symbol. Try to call FullForm on $x_i$ to get Subscript[x,i] which is tough to work with.
0.777778
How to change from subscripts to superscripts?
Good travel games for two players, especially for playing on trains?
I would be interested to hear if anyone had recommendations for 2-player games that are particularly suitable for playing while travelling on trains. (I ask this as someone who mostly enjoys games like Carcassonne, Power Grid, Agricola, Pandemic, etc. around the table at home.) To be specific, the things that I think are important properties for these games are: Needing minimal table space. Most trains have a small table you could use, but not much more. Being quiet to play, so that other passengers won't be disturbed. For example, I imagine that games that involve repeatedly rolling dice wouldn't be appreciated. Packing down small, so that they don't take up much luggage space. Not requiring batteries or a power socket. (I appreciate that an iPhone or a Nintendo DS for each player might be a good solution more generally, but it's not what I'm after in this case.) Not being so delicate to arrange that motion from the train will unduly disrupt the play. I think it would be best to recommend one game (or class of games) per answer, if that's appropriate, and explain why you think it's particularly suitable. (Incidentally, I've read the guidance on good questions about game recommendations and hope this question meets the criteria.) Update: Thanks for so many excellent suggestions - we certainly won't be short of games for our next long train journey :) Update 2: Unfortunately, I can't really playtest this many great games in any reasonable time period, so I'm going to accept the top-voted answer (Cribbage) and try out the others as soon as I can. Thanks again...
How about any of the myriad "travel-size" games, such as chess, checkers, othello, scrabble, etc?
1
How about any of the myriad "travel-size" games?
Trigger IP ban based on request of given file?
I run a website where "x.php" was known to have vulnerabilities. The vulnerability has been fixed and I don't have "x.php" on my site anymore. As such with major public vulnerabilities, it seems script kiddies around are running tools that hitting my site looking for "x.php" in the entire structure of the site - constantly, 24/7. This is wasted bandwidth, traffic and load that I don't really need. Is there a way to trigger a time-based (or permanent) ban to an IP address that tries to access "x.php" anywhere on my site? Perhaps I need a custom 404 PHP page that captures the fact that the request was for "x.php" and then that triggers the ban? How can I do that? Thanks! EDIT: I should add that part of hardening my site, I've started using ZBBlock: This php security script is designed to detect certain behaviors detrimental to websites, or known bad addresses attempting to access your site. It then will send the bad robot (usually) or hacker an authentic 403 FORBIDDEN page with a description of what the problem was. If the attacker persists, then they will be served up a permanently reccurring 503 OVERLOAD message with a 24 hour timeout. But ZBBlock doesn't do quite exactly what I want to do, it does help with other spam/script/hack blocking.
The PHP code that John Conde posted does not work. It replaces the entire .htaccess file as an undesirable result. The PHP below would be a good replacement for his PHP and I have tested it. <?php $ipdeny = 'deny from ' . $_SERVER['REMOTE_ADDR']; file_put_contents('.htaccess', $ipdeny . PHP_EOL, FILE_APPEND); ?>
1
John Conde posted a .htaccess file
Parsing a Text to only see specific data
I have the following text lines: .add 7971 [Player: Sunfire (Account: 11309) X: 5839.623047 Y: 600.437439 Z: 650.839722 Map: 571 Selected player: Llubia (GUID: 19369)] .add 43956 [Player: Sunfire (Account: 11309) X: 5277.887695 Y: 2862.181641 Z: 446.735931 Map: 571 Selected none: (GUID: 0)] .add 43956 [Player: Sunfire (Account: 11309) X: 5281.407715 Y: 2864.844482 Z: 446.735931 Map: 571 Selected player: Staticbaby (GUID: 19826)] .add 43956 [Player: Sunfire (Account: 11309) X: 5231.464844 Y: 1437.029175 Z: 648.498535 Map: 571 Selected player: Sunfire (GUID: 15295)] .add 44077 [Player: Sunfire (Account: 11309) X: 5231.464844 Y: 1437.029175 Z: 648.498535 Map: 571 Selected player: Sunfire (GUID: 15295)] .add 49285 [Player: Sunfire (Account: 11309) X: 16225.323242 Y: 16252.759766 Z: 12.790466 Map: 1 Selected none: (GUID: 0)] .add 44115 175 [Player: Elmasguapo (Account: 11309) X: 1659.845093 Y: -4198.589844 Z: 56.382870 Map: 1 Selected none: (GUID: 0)] .add 34078 [Player: Sunfire (Account: 11309) X: 16227.969727 Y: 16280.081055 Z: 13.175169 Map: 1 Selected none: (GUID: 0)] .add |cffffffff|Hitem:41427:0:0:0:0:0:0:0:80|h[Fuego de Artificio de Dalaran]|h|r 50 [Player: Sunfire (Account: 11309) X: 16221.392578 Y: 16260.944336 Z: 13.255954 Map: 1 Selected none: (GUID: 0)] .add |cffffffff|Hitem:45932:0:0:0:0:0:0:0:80|h[Gelatina Negra]|h|r [Player: Sunfire (Account: 11309) X: 5874.347168 Y: 679.056763 Z: 167.483719 Map: 571 Selected player: Assasins (GUID: 19438)] .add |cffffffff|Hitem:45932:0:0:0:0:0:0:0:80|h[Gelatina Negra]|h|r [Player: Sunfire (Account: 11309) X: 5873.767090 Y: 679.386841 Z: 167.435257 Map: 571 Selected player: Assasins (GUID: 19438)] .add |cffffffff|Hitem:45932:0:0:0:0:0:0:0:80|h[Gelatina Negra]|h|r [Player: Sunfire (Account: 11309) X: 16226.880859 Y: 16247.247070 Z: 12.286857 Map: 1 Selected player: Irmtarget (GUID: 18521)] .add |cffffffff|Hitem:45932:0:0:0:0:0:0:0:80|h[Gelatina Negra]|h|r [Player: Sunfire (Account: 11309) X: 16229.297852 Y: 16251.202148 Z: 13.081388 Map: 1 Selected player: Irmtarget (GUID: 18521)] .add 41600 2 [Player: Sunfire (Account: 11309) X: 16223.138672 Y: 16250.496094 Z: 12.431313 Map: 1 Selected player: Eifreen (GUID: 20341)] .add 41600 1 [Player: Sunfire (Account: 11309) X: 16223.138672 Y: 16250.496094 Z: 12.431313 Map: 1 Selected player: Eifreen (GUID: 20341)] .add 40516 [Player: Sunfire (Account: 11309) X: 16223.138672 Y: 16250.496094 Z: 12.431313 Map: 1 Selected player: Eifreen (GUID: 20341)] .add 44661 [Player: Sunfire (Account: 11309) X: 16223.138672 Y: 16250.496094 Z: 12.431313 Map: 1 Selected player: Eifreen (GUID: 20341)] .add 40518 [Player: Sunfire (Account: 11309) X: 16223.138672 Y: 16250.496094 Z: 12.431313 Map: 1 Selected player: Eifreen (GUID: 20341)] .add 44005 [Player: Sunfire (Account: 11309) X: 16223.138672 Y: 16250.496094 Z: 12.431313 Map: 1 Selected player: Eifreen (GUID: 20341)] .add 45867 [Player: Sunfire (Account: 11309) X: 16223.138672 Y: 16250.496094 Z: 12.431313 Map: 1 Selected player: Eifreen (GUID: 20341)] .add 45316 [Player: Sunfire (Account: 11309) X: 16223.138672 Y: 16250.496094 Z: 12.431313 Map: 1 Selected player: Eifreen (GUID: 20341)] And I want to parse it so it outputs something like this: Line 1 For example - 7971 Llubia Line 3 For example - 43956 Staticbaby Line 9 For Example - 45932 Assassins And so on.. This is done in the terminal with commands like cut, grep, cat, etc.. UPDATE: Here is the whole file: http://paste2.org/p/1744102 to parse in that way. UPDATE2: Please forgive me if I do not accept an answer just yet. Am waiting for the bounty option to appear since for me, stuff like this deserve a bounty. So I will add a bounty and give it to the correct answer or answers.
This can be what you want? grep -v 'Selected none' input-file | awk '$2+0 > 0 { print $2, $(NF-2) }'
0.777778
grep -v 'Selected none' input-file
DAO recordset effiency
I have a form that consists of about 60 fields that all update when choosing a different customer from a drop down. I feel like my current way is not the best way as it takes about 30 seconds to update when changing customers. Currently I have: Private Sub ClientSelection_AfterUpdate() On Error GoTo errhandler Dim dbTemp As DAO.Database Dim rsTemp As DAO.Recordset Dim strSQL As String DoCmd.Hourglass True sYear = Me.YearSelection.Value Me.CustomerID = Me.CustomerSelection.Column(0) CustomerID = Mid(Me.CustomerID.Value, 2, 36) Set dbTemp = CurrentDb() Set rsTemp = dbTemp.OpenRecordset("SELECT Field1 FROM Table where CustomerID = '" & CustomerID & "' and MonthYear = #01/01/" & sYear & "#") Set rsTemp2 = dbTemp.OpenRecordset("SELECT Field1 FROM Table where CustomerID = '" & CustomerID & "' and MonthYear = #02/01/" & sYear & "#") Me.JanCharges.Value = rsTemp("Charges") Me.FebCharges.Value = rsTemp2("Charges") rsTemp.Close rsTemp2.Close Set rsTemp = Nothing Set rsTemp2 = Nothing Set dbTemp = Nothing Exit_ClientSelection_AfterUpdate: Exit Sub errhandler: MsgBox "Error " & Err.Number & ": " & Err.Description & " in " & _ VBE.ActiveCodePane.CodeModule, vbOKOnly, "Error" Resume Exit_ClientSelection_AfterUpdate End Sub Both of these commands basically happen 60 times (5 categories consisting of 12 fields(months)). Then even further down I close all the recordsets and set them to Nothing. All of this works just takes a little longer than I want. What is a more efficient to accomplish this?
Disclaimer: I don't know much about DAO. I typically use ADODB. The expensive part of this code is opening and closing the recordset repeatedly. So, instead of opening and closing it every time this is triggered, open it once when the form is first loaded. Private dbTemp As DAO.Something 'I don't know the right type Private rsTemp As DAO.Recordset Private rsTemp2 As DAO.Recordset Private Sub Form_Load() ' code to open the entire recordset without a filter End Sub Private Sub Form_Unload() ' code to close and dispose of the recordsets End Sub Of course, now you don't have the specific record you're looking for when the event fires. You can use the Find and FindNext methods to filter the entire recordset down to what you need in the event procedure. https://msdn.microsoft.com/EN-US/library/office/ff194787.aspx Of course, this is if I can't talk you into switching to ADODB for your purposes here. It supports parameterized queries, which (in theory) should execute a bit faster. This is because, to the best of my knowledge, DAO requests all of the data and then filters it down in memory on the local machine. An ADODB parameterized query allows for the plan to be cached and only returns the results of the statement. Dim rst As ADODB.Recordset Dim cmd as ADODB.Command Const sql as String = _ "SELECT Field1 " & _ "FROM Table " & _ "WHERE CustomerID = ? and MonthYear = ?" With cmd .CommandType = adCmdText .CommandText = sql .Parameters.Append .CreateParameter(...) .Parameters.Append .CreateParameter(...) Set rst = .Execute End With ' some code to set january's value cmd.Parameters(1).Value = feburaryDate Set rst = cmd.Execute ' some code to set february's value Note how we simply pass the query a new value, instead of duplicating all of the query text? This is just one of ADODB's benefits. One other, rather minor note. I bet this code is all through your code base. MsgBox "Error " & Err.Number & ": " & Err.Description & " in " & _ VBE.ActiveCodePane.CodeModule, vbOKOnly, "Error" It's well worth extracting the logic into a dedicated module or class to standardize your error handling UI.
0.666667
ADODB is a parameterized query that allows for the query to be cached
What happens when we call pg_dump while users are still using the system?
We have a web application with PostgreSQL as our database and use celery background tasks for somewhat complex task. At the very beginning of this complex task we take a backup of the database using pg_dump. I was wondering about the state of this sql dump if the users are still using the system. Could it cause any inconsistencies ? Also, I would like to know if pg_dump is the best choice for taking backups in this case. Of course as the database grows the backup takes a lot of time which slows the overall process. Thanks.
I was wondering about the state of this sql dump if the users are still using the system pg_dump relies on PostgreSQL's MVCC support to ask PostgreSQL to take a snapshot of the database state at a given point in time. Changes made by concurrent transactions after the point where pg_dump gets its snapshot do not affect pg_dump, whether they're committed or not. There are a few things that aren't necessarily consistent, like sequences, which continue to increase while pg_dump is running. But applications have to be prepared for gaps in sequences anyway, so this isn't considered to be a problem. Also, I would like to know if pg_dump is the best choice for taking backups in this case No, you're way better off using WAL archiving and PITR for your purpose. Look into PgBarman and read the docs on continuous archiving. You should still take logical dumps for disaster recovery, but it need not be an all-the-time thing.
0.888889
pg_dump takes snapshot of database state at a given point in time
Can only access one of the router's web portal and the Internet
On both wired and wireless connections, I can only access one of 192.168.1.1 (the router web portal) and the general Internet. Which "mode" my devices are in is seemingly random. This has persisted so far for 5 days (since I began using this network). When connected to the Internet, I can go to 192.168.102.1 and I see a landing page for "mikrotik routeros", but I cannot go to 192.168.1.1. When connected to the router but not the Internet, 192.168.1.1 yields the router web portal, and 192.168.102.1 is inaccessible. Attempted solutions Upgrading router firmware Resetting router to factory settings Rebooting devices Fiddling with router settings (changing wireless security modes, removing wireless security, etc) Upgrading wireless drivers on computers Some data Affects BlackBerry, Windows, Android and Ubuntu devices All devices work properly on other networks Devices may switch modes if they have been offline for a long time (eg: overnight), but restarting a device has no effect Router is TP-Link TL-WR740N v4 Router firmware DD-WRT v24-sp2 (04/18/14) std - build 23919 Both wired and wireless connections are affected, but not necessarily simultaneously I don't know anything about networking, but here's some info that seems helpful taken from my Ubuntu laptop. With internet access (wired in this case, but it varies): ~ $ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.102.1 0.0.0.0 UG 0 0 0 eth0 192.168.102.0 0.0.0.0 255.255.254.0 U 1 0 0 eth0 ~ $ ifconfig eth0 Link encap:Ethernet HWaddr 54:ee:75:0c:02:80 inet addr:192.168.103.232 Bcast:192.168.103.255 Mask:255.255.254.0 inet6 addr: fe80::56ee:75ff:fe0c:280/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3273 errors:0 dropped:0 overruns:0 frame:0 TX packets:3035 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2276482 (2.2 MB) TX bytes:517732 (517.7 KB) Interrupt:20 Memory:f0500000-f0520000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:4315 errors:0 dropped:0 overruns:0 frame:0 TX packets:4315 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:342880 (342.8 KB) TX bytes:342880 (342.8 KB) With "router access" (wireless in this case, but it varies): ~ $ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0 192.168.1.0 0.0.0.0 255.255.255.0 U 9 0 0 wlan0 ~ $ ifconfig eth0 Link encap:Ethernet HWaddr 54:ee:75:0c:02:80 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:9422 errors:0 dropped:0 overruns:0 frame:0 TX packets:7545 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:6216683 (6.2 MB) TX bytes:1399280 (1.3 MB) Interrupt:20 Memory:f0500000-f0520000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:4446 errors:0 dropped:0 overruns:0 frame:0 TX packets:4446 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:353415 (353.4 KB) TX bytes:353415 (353.4 KB) wlan0 Link encap:Ethernet HWaddr e8:2a:ea:60:31:4b inet addr:192.168.1.105 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::ea2a:eaff:fe60:314b/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:77013 errors:0 dropped:0 overruns:0 frame:0 TX packets:49506 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:25275438 (25.2 MB) TX bytes:30355132 (30.3 MB) With both (wired with wireless turned on): ~ $ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.102.1 0.0.0.0 UG 0 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 9 0 0 wlan0 192.168.102.0 0.0.0.0 255.255.254.0 U 1 0 0 eth0
The fact that your are getting assigned IPs on two different subnets implies you have two DHCP servers on the directly attached network. Usually, I'd recommend using something like dhcp_probe -f eth0 or roguechecker to find out which IPs on your network are serving DHCP but you already know which they are. Namely, 192.168.1.1 and 192.168.102.1. You have two options to get internet connectivity AND be able to connect to the 192.168.1.0 network at the same time. Both will require disabling or removing the DHCP server on 192.168.1.1 and letting 192.168.102.1 assign you an IP for internet access. Methods follow: 1) Add a static routing entry to the linux box that tells it that 192.168.1.0 is directly attached. route add -net 192.168.1.0/24 wlan0 should work for this. 2) Add a static routing entry to the router that tells it 192.168.1.0 is directly attached. This would be specific to your router/firmware, but since you're running DD-WRT you can easily find the information on adding a static route. As a note, your gateway should be 0.0.0.0 for directly connected nets.
0.777778
How to connect to 192.168.1.0 network at the same time
How can I look up which server an application is running on?
A lot of times I will get a URL for an application that has some sort of problem. In order to fix it I need to find out what server it's running on which usually involves running around and asking a few people. Is there some way that I can look this up from the command line? I tried NSLOOKUP but I think it only gives me the name server.
Find it in your CMDB :-) It is the best general answer. If your response is "What's that?" or "We don't have one", it's time to start building it - as voretaq7 said. If the answers are all only in other people's heads, start writing their answers down.
0.888889
What's the best general answer?
Plotting two functions with dependent input function
I have defined a function: myJ2[n_] := 1/n* Total[RandomVariate[NormalDistribution[0, 1], n]^2] This is basically an approximation to the gaussian integral. I want to plot this and the error graph (difference between the approximation and the exact value) at the same time. Using a random variable makes this difficult. I tried this: DiscretePlot[{myJ2[n], 1 - myJ2[n]}, {n, 1, 1000}, Filling -> None, Joined -> True] However, this is not quite correct, since the myJ2 function is called twice and hence gives different values due to the randomness. I improved this by using: DiscretePlot[{x, 1 - x} /. x -> myJ2[n], {n, 1, 1000}, Filling -> None, Joined -> True, PlotStyle -> {Red, Blue}] This gives me the correct values but both in the same color. How can I get both the function and the error function displayed in two graphs or with two different colors? Thanks Charly
You don't need to call your function twice : data = Table[myJ2[n], {n, 1, 1000}]; ListPlot[{Transpose[{Range[1000], data}], Transpose[{Range[1000], 1 - data}]}, Filling -> None, Joined -> True]
1
Call function twice
How can I build a switching circuit that scales several 12v signals down to <5v?
Let me start off by saying that I know just enough about electronics to be dangerous (how to solder, follow a simple schematic, and check for connectivity problems and usually figure out what each wire is for). I've installed a cruise control kit in my car, and I want to use a set of Honda steering wheel controls instead of the stock controls from the kit. The cruise kit controls are expecting 12 volts, but I'm not comfortable running any more than 5 volts through the small steering wheel wires next to the airbag wiring. I'd prefer even less, like 2-3 volts. So I need to build a switching circuit that will provide the 12 volt signals to the cruise kit. I was thinking of keeping it solid-state, since I don't know of any relays that will switch on 2-3 volts. However, if there's a good reason to use relays then I can. Here's a rough drawing of what I need: How can I get started with this project?
Why exactly are you concerned about 12V on those wires? Its perfectly fine and doesn't represent any more or less danger than 5V would, or even GND honestly.
0.777778
Why are you concerned about 12V on the wire?
How can I detect a power outage with a microcontroller?
I have the following power supply configuration: AC MAINS -> UPS -> 24V POWER SUPPLY -> 5V VOLTAGE REGULATOR -> PCB (microcontroller). What's the best solution to detect the power outage on the mains with the microcontroller? I also need to detect the zero-crossing so that I can control the speed of an AC motor.
Since you also need the zero-crossing you'll get the power outage detection virtually for free. Best is to use an optocoupler to detect zero-crossings. Put the mains voltage via high resistance resistors to the input of the optocoupler. Vishay's SFH6206 has two LEDs in anti-parallel, so it works over the full cycle of the mains voltage. If the input voltage is high enough the output transistor is switched on, and the collector is at a low level. Around the zero crossing, however, the input voltage is too low to activate the output transistor and its collector will be pulled high. So you get a positive pulse at every zero crossing. The pulse width depends on the LEDs' current. Never mind if it's more than 10% duty cycle (1ms at 50Hz). It will be symmetrical about the actual zero-crossing, so the exact point is in the middle of the pulse. To detect power outages you (re)start a timer on every zero-crossing, with a timeout at 2.5 half cycles. Best practice is to let the pulse generate an interrupt. As long as the power is present the timer will be restarted every half cycle and never time out. Upon a power outage however, it will timeout after a bit longer than a cycle, and you can take the appropriate action. (The timeout value is longer than 2 half cycles, so that a spike on 1 zero-crossing causing a missed pulse won't give you a false warning.) If you create a software timer it won't cost you anything, but you can also use a retriggerable monostable multivibrator (MMV), for instance with an LM555. note: depending on your mains voltage and the resistor type you may need to place two resistors in series for the optocoupler, because the high voltage may cause a single resistor to breakdown. For 230V AC I've used three 1206 resistors in series for this. Q &amp; A time! (from comments, this is extra, in case you want more) Q: And the input LEDs of the optocoupler will work at 230V? The datasheet states that the forward voltage is 1.65V. A: Like for a common diode the voltage over a LED is more or less constant, no matter what your supply voltage is. The mandatory series resistor will take the voltage difference between power supply and LED voltage. The answers to this question explain how to calculate the resistor's value. Extreme example: a 10 000V power supply for a 2V LED. Voltage over the resistor: 10 000V - 2V = 9 998V. You want 20mA? Then the resistor is \$\frac{9 998V}{20mA}\$ = 499.9k\$\Omega\$. That's 500k, that's even reasonable. Yet, you can't use an ordinary resistor here. Why not? Firstly, a common 1/4W PTH resistor is rated at 250V, and will definitely breakdown at 10 000V, so you'll have to use 40 resistors in series to distribute the high voltage. Secondly, and worse, the power that the resistor would have to dissipate is \$P = V \times I = 9 998V \times 20mA = 199.96W\$, a lot more than the rated 1/4W. So to cope with the power we'll even need 800 resistors. OK, 10kV is extreme, but the example shows that you can use any voltage for a LED, so 230V is also possible. It's just a matter of using enough and the right type of resistors. Q: How does the reverse voltage affect the lifetime of the LEDs? A: The second, anti-parallel LED takes care of that by ensuring that the reverse voltage over the other LED can't become higher than its own forward voltage. And that's a good thing, because a reverse voltage of 325V\$_P\$ would kill any LED (most likely explode), just like any signal diode, by the way. The best way to protect it is a diode in anti-parallel. Q: Won't the resistors dissipate a lot of heat? A: Well, let's see. If we assume 1mA through the resistors and ignore the LED voltage, we have \$P = V \times I = 230V_{RMS} \times 1mA = 230mW\$, so even a 1206 can handle that. And remember, we're using more than 1 resistor, so we're safe if we can work with 1mA (The SFH6206 has a high CTR \$-\$ Current Transfer Ratio).
1
How does the reverse voltage affect the lifetime of the LEDs?
Bulk exporting/archiving collections in Lightroom
Is there any way to export images from my collections, where the images are automatically placed into a folder tree that mimics their collections? I'm not comfortable with having all that organization data locked away in Lightroom -- I switch computers a lot and oftentimes data sidecars like Lightroom's DB get lost in the shuffle. I'd like to export all my images into folders that can then be fed into Crashplan, etc. Ideally I want it to archive only images in each collection that match a Smart search criteria, like 4+ stars. jF's Collection Publisher plugin looks nice but it has its own collection tree that must be maintained separately. This solution is not DRY (Don't Repeat Yourself) enough for me: I don't want to maintain two separate hierarchies of collections. EDIT: To clarify, let's assume I have images sorted in collections as such: &lt; Collection root &gt; |- California | |- Surfers | |- Hipsters | |- Beaches |- Holland |- Windmills |- Stroopwaffels |- Coffeeshops |- Grachten I am looking for something that exports images into a folder tree identical to the one above, without any extra maintenance or work. So JPG or TIFF files would be exported/published to: /Users/tom/Photography/California/Surfers /Users/tom/Photography/California/Hipsters /Users/tom/Photography/California/Beaches /Users/tom/Photography/Holland/Windmills /Users/tom/Photography/Holland/Stroopwaffels /Users/tom/Photography/Holland/Coffeeshops /Users/tom/Photography/Holland/Grachten In accordance with the collections they live in in LR. jF's plugin is nice but it works from its own collection tree, which makes it unsuitable for this kind of request.
I'm not sure exactly what you mean by "mimics their collections," but I do something similar to what you're describing in my Dropbox and Aperture exports. (Dropbox for off-site backup, Aperture for intelligent iDevice sharing. Yes, I bought Aperture just to make iTunes happy. You're welcome, Apple.) I use Jeffrey Friedl's Folder Publisher plugin, rather than the Collection Publisher. I chose it because what I'm interested in is mirroring the on-disk folder structure as represented in LR's Folders pane, but using Smart Collections to select which photos get published. Like you, I choose not to mirror my low-rated photos to the export sets, for example, a perfect job for Smart Collections. If you use the built-in Hard Drive publish service instead, you get a flat folder of images, with name collisions resolved rather brutally. For some reason, photo names don't always survive a trip through the Folder Publisher intact. If I have a 1.jpg in two different folders, they seem to get a unique number appended anyway, even though it isn't actually necessary. I suspect this is a limitation of the Lightroom programming API. There are a lot of such areas, where the limits of Adobe's own needs for the API get reflected into the API, so that Adobe's limitations become your limitations. That problem doesn't really bother me, though, since the name of a photo file is of minimal concern. If I ever had to rebuild my Lightroom library from a Dropbox snapshot (shudder) I'd be much more interested in the folder structure and the photo metadata, both of which the Folder Publisher plugin preserves. About the only metadata you lose are things like virtual copies and stacks. Obviously you're also baking photo adjustments (DNG + XMP) into JPEGs when doing this. You should have a separate "real" backup. I consider my Dropbox export to be a "my house burned down and then my city was hit by an asteroid and then it slid into an abyss" sort of backup. As for the Aperture export, photo names, the distinction between multiple JPEGs and virtual copies, and stacking is of no concern whatsoever. Another option you can look into is LR/TreeExporter. I used to use it, but it hasn't been updated since the LR3 days, and at the time I started using it, the jf Folder Publisher plugin hadn't been created yet. Jeffrey is more responsive, and I like the way the plugin works better besides.
0.888889
Aperture is a "mimics their collections" plugin, not the Collection Publisher.
What is the difference between Cajun and Creole cuisine?
What is the difference between Cajun and Creole cuisine?
Both Cajun and Creole cuisines originate from French/European influence but there's a specific difference between them - Cajun is French 'provincial' cuisine adapted by local workers for and with local ingredients. Creole is French 'aristocratic' cuisine as practised in the better off households of the south and mimicking the influences of higher quality French/European cuisine but still having local Cajun influence using higher quality but still local ingredients. Both cuisines have French, Spanish, Portuguese, Italian (European) influences, reflecting the previous occupants of the southern territories as well as African and Native American influences.
1
Cajun is French 'provincial' cuisine adapted by local workers for and with local ingredients
Forwarding mail to different mail system in Postfix
I have an e-mail server powered by Postfix. Aside from traditional e-mail accounts on my server, I want to maintain some accounts whose only role is to forward all incoming mail to differnet address on different mail system. For example. I own domain example.com and I set account with address [email protected] on my server. And I want this one account to forward all incoming messages to mailbox in different mail system, in domain that does not belong to me [email protected]. I know, that i can add an entry in in my virtual_alias_maps lookup table. [email protected] [email protected] But I'm worried that to deliver message, Postfix will use original envelope sender address. It's okay if sender is from domain example.com that belongs to me, but otherwise stranger.net server may classify this message as a spam. Is there some way, to alter envelope sender on delivery ? Are smtp_generic_maps ment for this ? If so, is it okay, that my server sends an e-mail using specific envelope sender, and then something else in message being forwarded ? How else to deal with such problem ?
As you seem to be well aware, in a situation like yours, setting the return path to something that you control, is definitely important. As to how to do that, it should be as easy as simply reinjecting the email into postfix with the modified return path. You can look into how to make postfix deliver your email to this command: | sendmail -f [email protected] [email protected] I am just not sure if you can do that in the virtual_alias_maps table.
0.888889
How to set the return path to something that you control?
Are there any Christian denominations that incorporate Odinism?
Are there any Christian denominations or specific churches that incorporate Odinism or Odinistic cultural traditions? Perhaps, as a way to show that the original religion of northern Europe was not to be destroyed but reveled through Christ? For example, Odinists state: The calendar in use by Odinists in this country today is based on some of the festivals most widely celebrated by our ancestors, especially those which have survived as part of our people's folklore. Many church festivals have incorporated elements of heathen customs; and it is now our task to 're-paganise' them. http://www.odinistfellowship.co.uk/
We don't know as much about the German religion as the Greek and Roman ones, because the Germans used less permanent materials in their society, and didn't really write things down. What we have regarding them now is whatever Romans and Greeks decided to write down, and whatever elements were, as you pointed out, incorpated into the culture after Christianization. "Odinism" is polytheistic, while Christianity is ruthlessly monotheistic. At most a Christian could believe that the German gods were demons misleading people, or angels whose message was misunderstood. Most just say they were idols, or, for those like C. S. Lewis and G. K. Chesterton, saw the myths as factually false, but true in that they revealed a need of the human heart, a need that was fulfilled by Christ. Just as a boy might daydream about what his future wife might be like, and then later on in life meet her in reality, so the pagan myth makers were daydreaming about their Bridegroom, who they met Him for real by the Incarnation. For more detail regarding this, I highly, highly, recommend reading G. K. Chesterton's The Everlasting Man, especially the chapter "Man and Mythologies," which is one of the best essays he has ever written. You can find it here: http://www.cse.dmu.ac.uk/~mward/gkc/books/everlasting_man.html#chap-I-v* There are many elements of German belief in our society that were incorpated into culture practiced by later Christians. For example, our English weekday calendar, except for Saturday (who is a Roman god), are all Anglo-Saxon deities. The name "Easter" refers to the Old English name for the month of April, who was a fertility goddess (just as April is itself named after the Greek fertility goddess Aphrodite). Santa Clause might be based on an Old Norse legend involving Odin/Wodin. Just because things were pagan, doesn't make them wrong per se, because paganism is the religion of humanity, or at least of a fallen humanity. When Christ came, He didn't come to reject all of paganism, for that would be to reject humanity. Rather, He, and the Church, took what was good, and rejected what was bad, based on the doctrines of faith, just as the Israelites savaged the spoils from Egypt. The spoils weren't wrong and evil per se, they were just in the hands of the pagans and the evildoers. Think about it. The New Testament is written in common Greek, a language created by pagans and used by pagans. Do you really think the Apostles should have rejected the pagan language just because it was pagan? Christi pax. *Here's an audio recording: https://archive.org/details/EverlastingMan (pick Book I, Chapter V). I got all this from this website ultimately: http://www.cse.dmu.ac.uk/~mward/gkc/books/index.html
1
"Odinism" is polytheistic, while Christianity is ruthlessly monotheistic
Which achievements are missable if sharing Skylanders between multiple profiles?
Since purchasing Skylanders with my son and realizing you can't have different profiles on each character, I've also noticed some achievements are not unlocking depending on who first used the Skylander and who it is tied to. In short, all the Skylanders appears to be tied to my profile, but it's preventing some achievements from unlocking on my son's profile. They aren't just the achievements described with (primary profile), as most have unlocked for both of us while playing separately. So far I've noticed that the following achievements won't unlock once a Skylander is tied to someone: Fashion Stylist - Have your Skylander equip a hat for the first time. (primary profile) Hello!! Skylander - The first time you put your Skylander on the Portal of Power. (primary profile) What other achievements are tied to a Skylander unlocked by a specific person?
To get 100% percent in the game, you can both take ownership of all the Skylanders you have.
1
To get 100% in the game, you can both take ownership of all the Skylanders you have.
Loading and unloading "chunks" of tiles in a 2d tile engine with 2d camera
I am making a 2d tile based game in C# and XNA 4.0. I am having trouble loading and unloading "chunks" of tiles(blocks). The whole world is randomly generated and is infinate on both axis. How would I go about loading and unloading chunks of tile data in the camera's view? A pastebin to the pastebin links(I still have the 2 link cap): http://pastebin.com/9PYr8cvC
Find out how large your screen is and only render tiles that fall within that range. You might need a camera object to keep track of this data and some sort of x &amp; y offset variables to keep track of movement around the world. if(tile is inside of the window) render;
1
How large your screen is and only render tiles that fall within that range
ifpackageloaded question
why when i comment \usepackage{geometry} i get error? \documentclass{book} \usepackage{geometry} \makeatletter \@ifpackageloaded{geometry} { % i the package was loaded \newcommand*{\qw}{\itshape} % this is enabled, else is not enabled. }{} \makeatother \begin{document} \qw hallo \end{document}
I think what you want is \documentclass{book} \usepackage{geometry} \makeatletter \@ifpackageloaded{geometry} { \newcommand*{\qw}{\itshape} % this is enabled }{ \newcommand*{\qw}{\bfseries} % this is enabled? } \makeatother \begin{document} \qw hallo \end{document} The \@ifpackageloaded takes two arguments: what to do if the package is loaded or not. Your \if doesn't really do anything. Edit: The question seems to have changed Now the problem is that if the package is not loaded, then the macro \qw does not get defined. Something like this might be what you want \documentclass{book} \usepackage{geometry} \makeatletter \@ifpackageloaded{geometry} { \newcommand*{\qw}{\itshape} % this is enabled }{ \newcommand*{\qw}{} % this is enabled? } \makeatother \begin{document} \qw hallo \end{document}
0.777778
What to do if the package is not loaded?
Move Box2d object on touch of button?
I have a player box2d object on screen, who should be controlled by two buttons, one left, and one right. When you press the right button, the player should move right, but when you press the left button, the player should immediatly stop moving right and move left. This should also happen vice versa. I tried to do this to move right, b2Vec2 impulse(4, 0); body->ApplyLinearImpulse(impulse, body->GetWorldCenter()); and this to move left b2Vec2 impulse(4, 0); body->ApplyLinearImpulse(impulse, body->GetWorldCenter()); This works, but when I press right and then left, the player doesn't immediatly go left, but continues right for a while, and then goes left. How do I make sure this doesn't happen?
set the body's linearVelocity to b2Vec2_zero before applying the new force – LearnCocos2D yesterday
0.888889
Set the linearVelocity to b2Vec2_zero before applying the new force .
Other ways to increment a variable in JavaScript
Possible Duplicate: Why avoid increment (&ldquo;++&rdquo;) and decrement (&ldquo;--&rdquo;) operators in JavaScript? I'm a big fan of Douglas Crockford and his excellent book, JavaScript: The Good Parts. I also use his JSLint tool on an hourly basis before checking in any code to our repository, as is good sense. One thing I've noticed when running code through JSLint is its insistence that the ++ increment operator is somehow evil. I know I can turn certain rules off, but that's cheating ;). Crockford mentions his dislike on page 112 of JS: TGP... In my own practice, I observed that when I used ++ and --, my code tended to be too tight, too tricky, too cryptic. So, as a matter of discipline, I don't use them any more. I think that as a result, my coding style has become cleaner. That's all very lovely, but he doesn't give any examples of the way he codes them now. I assume he's doing something like... var i; i = 0; i = i + 1; Again, great, but I've got a few basic 'for loops' in my JS code, as I imagine many people have, and I've always used the standard syntax... for (i = 0; i &lt; myArray.length; i++) { // Loop Stuff } Am I missing something? What's the cleanest and/or best way to increment/decrement?
In C/C++ this is important, especially with arbitrary iterators and pre/post increment semantics. Also, random access vs forward-iterators. In Javascript it's more about aesthetics than anything else. Unless you're dealing with strings. "1"+1 is "11". I would say that ++i is an idiom that's worth being consistent with. JSLint is wrong.
1
++i is an idiom that's worth being consistent with
Applying OO patterns and principles to plugin development
I'm busy writing my first plugin, using PHP 5.3.5. I come from a C# environment, and I must say I'm more than happy with the level of support for good, solid OOP techniques in PHP. However, I'm a little uncertain how to structure a plugin using classes. I have a plugin class that takes care of hook registration in its constructor, and some worker classes like a mail queue and mailer, but I have one or two non-class scripts, mostly for forms, that I don't quite know how to neatly fit into classes. What resources are their I can consult for guidance on this aspect of my OO plugin? The plugin is for mass mailing, i.e. mailing to all subscribers, on schedule etc. It registers a custom post type for mail templates, with add new and edit capabilities, and it adds its own menu to the bottom of the admin menu, currently with two submenu pages: 'settings' and 'send mail'. It also adds an 'opt out' option to the user profile page, but that's quite tidy and easy to include the main plugin class.
class Plugin{ static public function Construct(){ static $single_call = false; // Enable calling this just once if($single_call) return; // Skip double hooking add_filter('the_content', array(__CLASS__, 'TheContent')); $single_call = true; // Block future calls } /** * @internal */ static private function ContentModifier($content){ return $content; } // All actions/filters must be public, internal methods can stay private static public function TheContent($content){ return self::ContentModifier($content); } } Plugin::Construct(); // Single Call Create static classes for plugins. Actions/Filters must be public. And, as you use PHP 5.3+, consider Closures where you need single-use hard to remove actions/filters. add_filter('the_content', function($content){ return $content; }); I come from C++, welcome to PHP!
0.777778
static public function Construct()
How do I find wiper refills for my 2008 Nissan Frontier?
I never had any trouble finding wiper blade refills for my 1998 Honda Accord or 2000 Toyota Echo. They were inexpensive because all you bought was the rubber part of the blade. The steel strips to reinforce them were retained from the original wipers. When my 2008 Nissan Frontier passenger wiper blade edge separated from the rest of the wiper I started looking for a replacement. Refills I found claiming to be for my Frontier were usually refills for an after-market replacement arm assembly and did not fit my stock wipers. I did finally find a Trico refill for my passenger side (18-240, narrow profile) but their recommended driver's side refill (24-240) is the same profile but needs to be wider (9mm vs 7mm??) Local auto parts stores all say they stopped carrying OEM refills. I could get a new wiper arm but years ago when I did that I regretted the poor quality of the replacement and the way it never quite fit the window as well.
The aftermarket industry is moving away from refills so it is only going to get harder to find them. I would suggest using beam blades instead. In my experience they preform better and look nicer since they take up less space. Here is an image showing a Neo Form blade next to a traditional blade:
1
Neo Form blades in aftermarket
How to configure GRUB to load Windows 7 Install in UEFI mode
I have a Dual-Boot USB I created with Multisystem for booting into PartedMagic, Ubuntu 11.10 &amp; Windows 7 Install. Problem is Windows 7 says it cant install on a GPT partition. Googled, and found that I need an UEFI system (on ASUS H67M-PRO, supports UEFI BIOS, so this shouln't be the problem). I also need to have the correct efi files. I find efi files in my USB, so I think thats fine. But I think the files might not be loaded or something? So I am thinking, do I need to do something special to boot into the UEFI installer for Windows 7 or something? For that I need to configure the GRUB on the USB? How?
You need to reinstall the system and make sure that you boot the Ubuntu install media in EFI mode. This will prompt it to create the EFI system partition ( if you tell it to use the entire disk ) and install the EFI version of grub.
0.888889
reinstall the system and make sure that you boot the Ubuntu install media in EFI mode
How to access beans from the applicationContext.xml in my service layer.
How to access beans from the applicationContext.xml in my service layer. I am working on a Spring Web MVC project and that issue is that my service layer needs a URL, User ID and Password to do a web post to a server to save my data. I dont want to hardcode the URL, User ID and password in the Java Code of the Service Layer so I would like to put them into the applicationContent.xml file but I dont know how to access them from the service layer. Can someone please help me out with this.. example code would be great.
If your service is already a Spring managed bean, it should be trivial: Add 3 properties to your service class (url, userId and password) along with their corresponding setters. Then you can set the values via your context: &lt;bean id="yourService" class="xxx.yyy.zz.YourService"&gt; &lt;property name="url" value="http://someurl.com"/&gt; &lt;property name="userId" value="username"/&gt; &lt;property name="password" value="passwd"/&gt; &lt;/bean&gt;
0.666667
Add url, userId and password to your service class
Results with and without interaction
I'm working on an analysis with another person. First we did a logistic regression with study group and variable X. They were both significant. Then we added the interaction between study group and X only the study group and the interaction were significant. Actually, there are 3 groups and only one of the groups and one of the group*X interactions is significant. I am having a hard time to convince this person that we should not present the odds ratios for X from the first analysis that do not account for this interaction. This person thinks that we can show the results of the first analysis AND then the second analysis. I think this is misleading and will confuse people. I am not the best at explaining things (as you can tell), so any help with how to argue my point would be appreciated.
Showing both models is fairly common in some disciplines. In those disciplines showing only the model with the interactions can cause confusion, rather than the other way around. So I don't think your client is necessarily wrong.
0.555556
Showing both models is fairly common in some disciplines
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?
Players should use an item when either (1) they can replace the item for a cost which is lower than the cost averted by using it, or (2) the cost of not having the item available later will be greater than the cost of using it immediately. I don't like it when games punish the player for conserving resources in any fashion beyond the fact that players naturally don't benefit from things they don't use. I also dislike it when games arbitrarily confiscate conserved items. Instead of doing such things, games should try to convey to the player the idea that if an item will be needed, it will be possible to replace it, though perhaps at the cost of having to do some otherwise-unnecessary side missions. If the player can, given time, earn an unbounded amount of in-game currency, an item might be sold in the "arcana" section of a shop where e.g. the first MagicWhatzit costs $1,000; the second costs $1,200; the third, $1,500, etc. rising at a rate which is noticeable but not overly frightening. Such rules could encourage reasonable conservation without encouraging excessive hoarding, since players could have a sense that if they can avoid using a MagicWhatzit, they can avoid having to run a 10-minute side mission to get another one, but if running a ten-minute side mission would be easier than getting by without a MagicWhatzit, then they should use it. This ties in with an economic principle, which has real-world consequences as well: if one wants people to perceive a resource as having a significant but not limitless cost, they must actually pay the cost if they use the resource. If squandering a resource will mean that a players has to spend some of their real-world time running a not-terribly-exciting side mission to get it back, players will have an incentive not to squander it. If the game were to let the player skip the busy-work, that incentive would vanish. While it may seem that an ideal game should avoid giving the player busy-work, such busy-work may encouraging sensible resource management in a way that can improve a player's overall enjoyment and satisfaction.
1
Players should use an item when they can replace it for a cost which is lower than the cost averted by using it .
Get phones on all members in a customer group
I am working on a custom Magento extension. I am working around the Adminhtml part and i've created a custom form there. Here is the form code: &lt;?php class VivasIndustries_SmsNotification_Block_Adminhtml_Sms_Sendmass_Edit_Form extends Mage_Adminhtml_Block_Widget_Form { public function _prepareLayout() { $ExtensionPath = Mage::getModuleDir('js', 'VivasIndustries_SmsNotification'); $head = $this-&gt;getLayout()-&gt;getBlock('head'); $head-&gt;addJs('jquery.js'); $head-&gt;addJs('vivas.js'); return parent::_prepareLayout(); } protected function _prepareForm() { $form = new Varien_Data_Form(array( 'id' =&gt; 'edit_form', 'action' =&gt; $this-&gt;getUrl('*/*/save', array('id' =&gt; $this-&gt;getRequest()-&gt;getParam('id'))), 'method' =&gt; 'post', )); $fieldset = $form-&gt;addFieldset('edit_form', array('legend'=&gt;Mage::helper('smsnotification')-&gt;__('SMS Information'))); $CustomerGroups = Mage::getResourceModel('customer/group_collection')-&gt;toOptionArray(); $smsprice_value = Mage::getStoreConfig('vivas/smsprice/smsprice_value'); $smsprice_tag = Mage::getStoreConfig('vivas/smsprice/smsprice_tag'); $customerArray=array(); foreach($CustomerGroups as $each){ $count=Mage::getResourceModel('customer/customer_collection') -&gt;addAttributeToFilter('group_id',$each['value'])-&gt;getSize(); $SMSPrice = $count * $smsprice_value; $customerArray[]=array('value'=&gt; $each['value'],'label'=&gt; $each['label'].' - ('.$count.' Members) - ('.$SMSPrice.' '.$smsprice_tag.')'); } $CustomerGroups = array_merge(array('' =&gt; ''), $customerArray); $fieldset-&gt;addField('customergroups', 'select', array( 'name' =&gt; 'customergroups', 'label' =&gt; Mage::helper('smsnotification')-&gt;__('Customer Group'), 'class' =&gt; 'required-entry', 'after_element_html' =&gt; '&lt;br&gt;&lt;small&gt;If customer group is not selected the SMS will be sended&lt;br&gt; to all store members!&lt;/small&gt;', 'values' =&gt; $CustomerGroups ) ); $fieldset-&gt;addField('smstext', 'textarea', array( 'label' =&gt; Mage::helper('smsnotification')-&gt;__('SMS Text'), 'class' =&gt; 'required-entry', 'required' =&gt; true, 'name' =&gt; 'smstext', 'onclick' =&gt; "", 'onkeyup' =&gt; "CheckLetterSize(this)", 'after_element_html' =&gt; '&lt;br&gt;&lt;b style="color:brown;"&gt;&lt;span id="charNum"&gt;&lt;/span&gt;&lt;span id="charNum1"&gt;&lt;/span&gt;&lt;/b&gt;&lt;br&gt;&lt;small&gt;SMS text must &lt;b&gt;NOT&lt;/b&gt; be longer then 160 characters!&lt;/small&gt;', 'tabindex' =&gt; 1 )); if ( Mage::getSingleton('adminhtml/session')-&gt;getsmsnotificationData() ) { $form-&gt;setValues(Mage::getSingleton('adminhtml/session')-&gt;getsmsnotificationData()); Mage::getSingleton('adminhtml/session')-&gt;setsmsnotificationData(null); } elseif ( Mage::registry('smsnotification_data') ) { $form-&gt;setValues(Mage::registry('smsnotification_data')-&gt;getData()); } // Add these two lines $form-&gt;setUseContainer(true); $this-&gt;setForm($form); //// return parent::_prepareForm(); } } Here is the code that i have in my save action: $groupId = $this-&gt;getRequest()-&gt;getPost('customergroups', ''); if (!empty($groupId)) { //Get customers from a group $customers = Mage::getModel('customer/customer') -&gt;getCollection() -&gt;addAttributeToSelect('*') -&gt;addFieldToFilter('group_id', $groupId); } else { //Get all customers $customers = Mage::getModel('customer/customer') -&gt;getCollection() -&gt;addAttributeToSelect('*'); } This code is supposed to give me the group id when i press the submit button. But i have to get all the phones of these members in array like that: $phones = array($phone); How can i get all the phone numbers and make them in array?
The easiest way (just example): $phones = array(); foreach($customers as $customer) { if($customer-&gt;getPhone()) $phones[] = $customer-&gt;getPhone(); } Because collection is object with objects (function _getItems() return array of objects, if i remember right).
0.888889
$phones = array(); foreach = $customer
How to make animated buttons in a menu with Cocos2d?
How do I make animated menus with cocos2d, I just want to animate the buttons and not the entire scene. Effects I look for is flipping buttons (like the back of the button is the next menu), buttons that retract once selected and re appear with new button. Basically what I ask for is cool effects between menu transitions.
Create a FiniteAction from a Sequence and make the sprite asociated to the button play it on touch. Use the different classes available for different effects. For the back-to-back you need two buttons, one drawn on top of the other with different priorities. Make one do a FlipY while the other does a flipY reverse and change the drawing priority. Retract is just a Scale or Skew effect.
0.888889
Create a FiniteAction from a Sequence and play it on touch
How are potions made?
Where does majority of the energy for the magical effect of a potion comes from? Does it all comes from the brewer? Or does most of it comes from the ingredients? I know JKR said that you have to use magic at some part of the process of brewing (hence no muggle potion brewers) [what about a squib?] If brewer provides all of the energy then why aren't NEWT students magically exhausted after every potion class? Hermione successfully brewed batch of Polyjuice Potion (a very potent NEWT level potion) in first semester of her second year, and while brewing it was very time-consuming and required a lot of concentration she never showed any signs of exhaustion as far as I remember.
"As there is little foolish wand-waving here, many of you will hardly believe this is magic. I don't expect you will really understand the beauty of the softly simmering cauldron with its shimmering fumes, the delicate power of liquids that creep through human veins, bewitching the mind, ensnaring the senses.... I can teach you how to bottle fame, brew glory, even stopper death -- if you aren't as big a bunch of dunderheads as I usually have to teach." (Severus Snape to First Years, HP and Philosopher's Stone, CHAPTER EIGHT "THE POTIONS MASTER") In Chemistry (which potion-making is a clear magical equivalent of), there's a concept of catalyst. A catalyst is a chemical which facilitates a given chemical reaction, without actually being consumed as part of it. Usually a fairly small amount of catalyst is enough to affect the reaction. It seems to me, based on what small info was provided in the books/interviews, that magic in brewing the potions is strongly equivalent to the catalist in a chemical reaction. It aids the potion-making, but isn't there to provide "energy" to it. This is confirmed by the fact that you tend to boil your cauldrons in Potions using fire - this is what would have provided the energy. "I suppose you added the porcupine quills before taking the cauldron off the fire?" (same source). This pretty much answers your main question - the majority of the energy comes from the fire, as is frequently the case with chemical reactions. But some of it can come from the ingredients themselves when reacting. As such, it seems unlikely that magic involved in making potions is in need of being especially energy-draining, even if it may be somewhat tricky or complicated.
1
How to bottle fame, brew glory, even stopper death?
Adding Properties to User Profile and Displaying in List
I have a site that I am migrating to WordPress, and I have a need to add properties that each of the users can edit (e.g., Address, City, State, Business Name, etc), along with some properties that Administrators can edit (IsActive, CanEmail) that wouldn't be displayed to the user. In addition, I need to be able to display the properties in a table (similar to how the plugin, "Members List", displays, but with the custom fields displaying as well. Given these requirements, I had attempted to use a combination of "Cimy User Extra Fields" and "Members List", but the members list grid did not have an option to display the extra fields created by the other plugin. How would you recommend I approach this? EDIT: So I guess the crux of my question is, what is the preferred method to add properties to the User?
To answer the first part of your question, I have just put my class TTT_User_Profile_Addon on GitHub. The class offers a simple interface to add a field to a profile page. I have added an example for a checkbox subclass and some code to initialize it per functions.php. This works in a plugin too, of course. There are some build in placeholders, but you can add your own. Separate filters for the markup and input values make extending the class easier. You can set custom capabilities for showing and saving the fields per constructor call. The whole work is reduced to a simple init function: add_action( 'init', 'ttt_init_profile_addons' ); /** * Registers the extra fields for the user profile editor. */ function ttt_init_profile_addons() { $GLOBALS['ttt_show_profile'] = new TTT_User_Profile_Checkbox( array ( 'name' =&gt; 'ttt_show_profile' , 'label' =&gt; 'Show a short profile box on my posts.' , 'th' =&gt; '' , 'td' =&gt; '&lt;input type="checkbox" name="%name%" id="%id%" %checked% /&gt; %label%' , 'cap_show' =&gt; 'edit_posts' , 'cap_save' =&gt; 'edit_users' ) ); // add more fields here … } Adding the values to the member table is something I still have on my todo list … Oh, and I should probably mention another class to replace or extend the default contact fields: TTT_Contactfields. This may be a case of OOP overdone. :)
0.777778
Adding a field to a profile page
Programmatically and efficiently create a graphical ripple effect?
I was developing tower of defence game for a long time. It was about to complete but I have to create ripple effect for one of the weapon that I have used. First question I want to ask is that is it feasible to use ripple effect for such purpose? Because suddenly fps goes down. I have created ripple effect for live wallpaper. But I don't know how to create it for normal game activity. I was not able to understand many things from it. If any one has some knowledge on this then please provide. Edit : I include the image for ripple effect that I think I have to use for weapon fire. Also I include code that I use to create ripple effect. Similar code with some changes I used to create live wallpaper and it work perfectly. But in normal game activity I don't able to find my mistake. So please guide on this @Override public Engine onCreateEngine(EngineOptions pEngineOptions) { return new org.andengine.engine.Engine(pEngineOptions) { private boolean mRenderTextureInitialized; private RenderTexture mRenderTexture; private UncoloredSprite mRenderTextureSprite; @Override public void onDrawFrame(final GLState pGLState) throws InterruptedException { final boolean firstFrame = !this.mRenderTextureInitialized; if (firstFrame) { this.initRenderTextures(pGLState); this.mRenderTextureInitialized = true; } final int surfaceWidth = this.mCamera.getSurfaceWidth(); final int surfaceHeight = this.mCamera.getSurfaceHeight(); this.mRenderTexture.begin(pGLState); { /* Draw current frame. */ super.onDrawFrame(pGLState); } this.mRenderTexture.end(pGLState); /* Draw rendered texture with custom shader. */ { pGLState.pushProjectionGLMatrix(); pGLState.orthoProjectionGLMatrixf(0, surfaceWidth, 0, surfaceHeight, -1, 1); { this.mRenderTextureSprite .onDraw(pGLState, this.mCamera); } pGLState.popProjectionGLMatrix(); } } private void initRenderTextures(final GLState pGLState) { final int surfaceWidth = this.mCamera.getSurfaceWidth(); final int surfaceHeight = this.mCamera.getSurfaceHeight(); this.mRenderTexture = new RenderTexture(RippleEffectDemo.this .getEngine().getTextureManager(), surfaceWidth, surfaceHeight); this.mRenderTexture.init(pGLState); final ITextureRegion renderTextureTextureRegion = TextureRegionFactory .extractFromTexture(this.mRenderTexture); this.mRenderTextureSprite = new UncoloredSprite(0, 0, renderTextureTextureRegion, RippleEffectDemo.this .getEngine().getVertexBufferObjectManager()) { @Override protected void preDraw(final GLState pGLState, final Camera pCamera) { this.setShaderProgram(RippleShaderProgram.getInstance()); super.preDraw(pGLState, pCamera); if (mCurrentWaveLength &gt; 25) mCurrentWaveLength -= 25; else mCurrentWaveLength = 0; float currentTime = -0.001f * mCurrentWaveLength; float aliveTimer = (float) mCurrentWaveLength / (float) mWaveLength; GLES20.glUniform4f( RippleShaderProgram.sUniformResolution, (float) SCREEN_WIDTH, (float) SCREEN_HEIGHT, RippleEffectDemo.this.mDropCenterX, RippleEffectDemo.this.mDropCenterY); GLES20.glUniform2f(RippleShaderProgram.sUniformTime, currentTime, aliveTimer); } }; } }; } @Override public void onCreateResources() { this.mBitmapTextureAtlas = new BitmapTextureAtlas( this.getTextureManager(), 512, 512); this.mBackgroundTextureRegion = BitmapTextureAtlasTextureRegionFactory .createFromAsset(this.mBitmapTextureAtlas, this, "badge_large.png", 0, 0); this.mBitmapTextureAtlas.load(); this.getShaderProgramManager().loadShaderProgram( RippleShaderProgram.getInstance()); } @Override public Scene onCreateScene() { final Scene scene = new Scene(); final int centerX = (int) ((CAMERA_WIDTH - this.mBackgroundTextureRegion .getWidth()) / 2); final int centerY = (int) ((CAMERA_HEIGHT - this.mBackgroundTextureRegion .getHeight()) / 2); backgroundSprite = new Sprite(centerX, centerY, this.mBackgroundTextureRegion, this.getEngine() .getVertexBufferObjectManager()); scene.attachChild(backgroundSprite); scene.setOnSceneTouchListener(this); return scene; } protected void onTap(final int pX, final int pY) { // we do not support multiple wave if (0 == mCurrentWaveLength) { // so skip wave, if it is active mCurrentWaveLength = mWaveLength; this.mDropCenterX = (float) pX; this.mDropCenterY = (float) pY; } } @Override public void onClick(final ClickDetector pClickDetector, final int pPointerID, final float pSceneX, final float pSceneY) { } @Override public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) { if (pSceneTouchEvent.isActionDown()) { onTap((int) pSceneTouchEvent.getX(), (int) pSceneTouchEvent.getY()); return true; } this.mDropCenterX = pSceneTouchEvent.getMotionEvent().getX() / this.mCamera.getSurfaceWidth(); this.mDropCenterY = pSceneTouchEvent.getMotionEvent().getY() / this.mCamera.getSurfaceHeight(); return true; } public static class RippleShaderProgram extends ShaderProgram { private static RippleShaderProgram INSTANCE; public static final String VERTEXSHADER = "uniform mat4 " + ShaderProgramConstants.UNIFORM_MODELVIEWPROJECTIONMATRIX + ";\n" + "attribute vec4 " + ShaderProgramConstants.ATTRIBUTE_POSITION + ";\n" + "attribute vec2 " + ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES + ";\n" + "varying vec2 " + ShaderProgramConstants.VARYING_TEXTURECOORDINATES + ";\n" + "void main() {\n" + " " + ShaderProgramConstants.VARYING_TEXTURECOORDINATES + " = " + ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES + ";\n" + " gl_Position = " + ShaderProgramConstants.UNIFORM_MODELVIEWPROJECTIONMATRIX + " * " + ShaderProgramConstants.ATTRIBUTE_POSITION + ";\n" + "}"; // private static final String UNIFORM_TOUCH_COORDS = "touchCoords"; private static final String UNIFORM_RESOLUTION = "resolution"; private static final String UNIFORM_TIME = "time"; public static final String FRAGMENTSHADER = "precision mediump float;\n" + "uniform sampler2D " + ShaderProgramConstants.UNIFORM_TEXTURE_0 + ";\n" + "varying mediump vec2 " + ShaderProgramConstants.VARYING_TEXTURECOORDINATES + ";\n" + "uniform vec4 " + RippleShaderProgram.UNIFORM_RESOLUTION + ";\n" + "uniform vec2 " + RippleShaderProgram.UNIFORM_TIME + ";\n" + "void main() {\n" + " vec2 tap = " + RippleShaderProgram.UNIFORM_RESOLUTION + ".zw;\n" + " tap.x = " + RippleShaderProgram.UNIFORM_RESOLUTION + ".x - tap.x;\n" + " vec2 tPos = -1.0 + 2.0 * tap.xy / " + RippleShaderProgram.UNIFORM_RESOLUTION + ".xy;\n" + " vec2 cPos = -1.0 + 2.0 * gl_FragCoord.xy / " + RippleShaderProgram.UNIFORM_RESOLUTION + ".xy;\n" + " cPos = cPos + tPos;\n" + " float cLength = length(cPos);\n" + " float radius = 18.0 * " + RippleShaderProgram.UNIFORM_TIME + ".y;\n" + " float amplitude = 0.05 * " + RippleShaderProgram.UNIFORM_TIME + ".y;\n" + " vec2 uv = gl_FragCoord.xy/" + RippleShaderProgram.UNIFORM_RESOLUTION + ".xy" + "+(cPos/cLength)*cos(cLength*radius-" + RippleShaderProgram.UNIFORM_TIME + ".x *4.0)*amplitude;\n" + " vec3 col = texture2D(" + ShaderProgramConstants.UNIFORM_TEXTURE_0 + ",uv).xyz;\n" + " gl_FragColor = vec4(col,1.0); \n" + // color "}"; // =========================================================== // Fields // =========================================================== public static int sUniformModelViewPositionMatrixLocation = ShaderProgramConstants.LOCATION_INVALID; public static int sUniformTexture0Location = ShaderProgramConstants.LOCATION_INVALID; public static int sUniformResolution = ShaderProgramConstants.LOCATION_INVALID; public static int sUniformTime = ShaderProgramConstants.LOCATION_INVALID; // =========================================================== // Constructors // =========================================================== private RippleShaderProgram() { super(RippleShaderProgram.VERTEXSHADER, RippleShaderProgram.FRAGMENTSHADER); } public static RippleShaderProgram getInstance() { if (RippleShaderProgram.INSTANCE == null) { RippleShaderProgram.INSTANCE = new RippleShaderProgram(); } return RippleShaderProgram.INSTANCE; } @Override protected void link(final GLState pGLState) throws ShaderProgramLinkException { GLES20.glBindAttribLocation(this.mProgramID, ShaderProgramConstants.ATTRIBUTE_POSITION_LOCATION, ShaderProgramConstants.ATTRIBUTE_POSITION); GLES20.glBindAttribLocation( this.mProgramID, ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES_LOCATION, ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES); super.link(pGLState); RippleShaderProgram.sUniformModelViewPositionMatrixLocation = this .getUniformLocation(ShaderProgramConstants.UNIFORM_MODELVIEWPROJECTIONMATRIX); RippleShaderProgram.sUniformTexture0Location = this .getUniformLocation(ShaderProgramConstants.UNIFORM_TEXTURE_0); RippleShaderProgram.sUniformResolution = this .getUniformLocation(RippleShaderProgram.UNIFORM_RESOLUTION); RippleShaderProgram.sUniformTime = this .getUniformLocation(RippleShaderProgram.UNIFORM_TIME); } @Override public void bind(final GLState pGLState, final VertexBufferObjectAttributes pVertexBufferObjectAttributes) { GLES20.glDisableVertexAttribArray(ShaderProgramConstants.ATTRIBUTE_COLOR_LOCATION); super.bind(pGLState, pVertexBufferObjectAttributes); GLES20.glUniformMatrix4fv( RippleShaderProgram.sUniformModelViewPositionMatrixLocation, 1, false, pGLState.getModelViewProjectionGLMatrix(), 0); GLES20.glUniform1i(RippleShaderProgram.sUniformTexture0Location, 0); } @Override public void unbind(final GLState pGLState) throws ShaderProgramException { GLES20.glEnableVertexAttribArray(ShaderProgramConstants.ATTRIBUTE_COLOR_LOCATION); super.unbind(pGLState); } }
After hard working I found working code for the ripple effect. I have to say thanks to genius guy named thepi for his effort. The link for correct working code : http://www.andengine.org/forums/gles1/ripple-effect-t10598.html I here posted because I think lot other user can get benefit from it and also want to say thank to the people who have tried for this.
0.888889
working code for the ripple effect
Modifying a calculated column gives different errors
I have site column with the following formula: [AmountLeftToPay]/([AmountAssigned]-[AmountReleased]) The problem is the division by zero, sometimes it shows on list items #DIV/0! So I wanted to do the following: =IF([AmountAssigned]-[AmountReleased]=0; 0; [AmountLeftToPay]/([AmountAssigned]-[AmountReleased])) And it shows me the same error in all lists where its used. is not supported. /apps/xx/xx/Lists/Budgets : The formula contains a syntax error or is not supported. If I change ; with commas, The formula contains a syntax error or is not supported. so I got no clue
You have to write formula like =IF(ISERROR([Column1]/[Column2]),"NA",[Column1]/[Column2]) Returns NA when the value is an error Hope it helps Regards, Dhaval
0.666667
Formula like =IF(ISERROR([Column1]/[Columbn2]), "NA" Returns NA
Is there anyway to stack or merge .hdf files in R Studio?
I would like to be able to merge, mosaic, or stack several .hdf files. Does anyone know the package or library i should be looking for the tool to do this?
First, you are using R. R Studio is just an IDE for R so in the future please make this an R question. I will warn you that working with HDF files in R is a pain. In theory GDAL supports HDF5 so one could use readGDAL in the rgdal package. Depending on the source of the data readGDAL has a high fail rate making it less than reliable. Historically, there is a "hdf5" package available but it has some odd dependencies, is a bit clunky and not available for the current version of R. You would have to back version R and then download a supported version of the package. I would recommend using "rhdf5" which is available on Bioconductor. There is some slight overhead in installing it but is quite easy with a few lines of code. The bioLite script allows for access to Bioconductor and management of packages. If in windows, run R as administrator. This installs bioLite and rhdf5 source("http://bioconductor.org/biocLite.R") biocLite("rhdf5") Once you have the data read into R you can coerce into your preferred spatial class and perform whatever operation you wish. I do have to say that R does not seem like the ideal software for this task. For a mosaic operation on a number of HDF files I would use a utility to convert the data into a different image format and the use a GIS software (e.g., GRASS, QGIS...) to mosaic the images. GRASS does support HDF and seems like a sensible alternative. You may be able to do this in QGIS using the GRASS utilities. Here is an example of working with HDF files in R. http://www.r-bloggers.com/working-with-hdf-files-in-r-example-pathfinder-sst-data/
1
R Studio is just an IDE for R so please make this an R question
What is the best way for a user to select an item by unique identifier?
My team and I are building a mobile app where the user will need to input a human-readable unique identifier (the serial number) of a single unit of inventory. Our system tracks the serial numbers that the user can access. We have considered three possible input modes: 1. We show the user the entire list of serial numbers they can access and allow him to select one from the list (like how a select element would work on an HTML page). Pros: The user doesn't have to type anything in. The user can't enter an invalid serial number. Cons: The list is likely to be overwhelmingly large. The serial numbers usually have the same format and are often sequential, so it might be hard to read the list. Data usage for downloading the entire list of serial numbers 2. We allow the user to start entering the serial number in a text input and have an auto-suggest drop-down with a filtered list of serial numbers the user can access. Pros: The user doesn't have to type in a complete serial number. The user is unlikely to enter an invalid serial number. Smaller list to choose from than Option 1. Cons: The serial numbers usually have the same format and are often sequential, so it might be hard to read the list. Auto-suggest may have limited value since the unit has a barcode that we could read. Data usage for downloading a sizable list of serial numbers 3. We require the entire serial number to be entered, and once we recognize the correct number of characters, we validate the serial number against the user's accessible list and show feedback. Pros: The unit has a barcode that we could read, so this has the potential to be simpler than an auto-suggest or select-from-list paradigm. Simpler implementation Significantly reduced data usage vs. Option 1 and Option 2 Cons: The unit has multiple barcodes, so it might take a couple of tries for the user to capture the correct one. Typing manually would be tedious if the camera is unavailable or barcode scanner isn't working for whatever reason (lighting, etc.) Which of these three is the best approach? Is there a better approach than what we have considered?
Let's face it, serial numbers weren't meant to be consumed by humans. Can you imagine going to the grocery store and waiting for someone to manually enter each and every bar code number for all your items? In your situation I think option 3 is your best bet but I don't see why you couldn't combine option 3 with option 2. If the bar code scanner is failing for any reason the user can at least get auto-complete help while falling back to entering the string of digits manually. Don't prevent the user from entering an invalid number but do provide instant feedback when the input string isn't valid.
1
Can you imagine going to grocery store waiting for someone to manually enter each and every bar code number for all your items?
dynamic call of functions and generator function (python)
The following code only prints "good". Why the generator function is not executed? I noticed with pdb that after executing 'handlers1' the script reaches the line with f1's definition but then does not get inside the function. Conversely, it's returned 'GeneratorExit: None'. class foo: def f0(self, s): print s def f1(self, s): print "not " + s yield 1 def run(self): handlers={0 : self.f0, 1 : self.f1} handlers[0]('good') handlers[1]('good') bar = foo() bar.run() Why this happens? Is it possible to call generator functions in a similar dynamic way?
You need to call next or the code in the generator won't run at all. class foo: def f0(self, s): print s def f1(self, s): print "not " + s yield 1 def run(self): handlers={0 : self.f0, 1 : self.f1} handlers[0]('good') handlers[1]('good').next() bar = foo() bar.run() That prints "good" then "not good".
0.777778
Code in the generator won't run at all
Grinding sound during cold start?
I have a 2009 Honda Accord. Over the past several months, I've noticed a grinding sound immediately after cold-starting the engine. It only lasts for a fraction of a second, doesn't continue once the engine is running, and doesn't happen if I shut the engine off and start it again a few minutes later. A little background: The car has 92,000 miles on it. I've noticed that it burns oil pretty quickly, so I keep an eye on it and make sure to add more if needed. Most recently, I got an oil change with a high mileage synthetic, but that has not solved the issue. Does anyone know what this could be? Is it a big deal? I'm obviously worried about damaging the engine. Is this a major thing? Or is it something I can live with, provided I don't mind the frightening noise that occurs on startup. Any help you can give is greatly appreciated!
I have a Honda accord 2008, I notice the grinding nose at initial start, after car was sits for a few hours, cold weather or hot, still makes the grinding noise as engine starts up for a couple of seconds but not all the times. I agree with the previous answer of " slow disengagement of the motor starter" I went to few Honda dealers in orange county CA, they all said; haven't heard of this problem before. I was recommended to leave the car for over night for a diagnostic checkup but because of the inconvenience and $100+ charges I haven't done it yet. On the issue of oil consuming, it's a recall. I took to the dealer and the problem was fixed.
0.888889
Honda accord 2008 grinding nose at initial start
PHP and MySQL calendar issue
I'm writing trying to build a calendar right from scratch. I'm using the function written by David Walsh (see link) and it's great. He does a query for each day's cell. But, I'm afraid that when the script's gonna have to run 30 queries in each render, it's gonna be sloooow. So, I was trying to think in another logic, for example, make a big query from X date to Y date at the begining of the script and then, at each day, check if that particular day has an event in the previous query. But I have no idea of how to do this... So, if anyone can help, please shout! Thanks.
Instead of /* keep going with days.... */ for($list_day = 1; $list_day &lt;= $days_in_month; $list_day++): $calendar.= '&lt;td class="calendar-day"&gt;'; /* add in the day number */ $calendar.= '&lt;div class="day-number"&gt;'.$list_day.'&lt;/div&gt;'; /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !! IF MATCHES FOUND, PRINT THEM !! **/ $calendar.= str_repeat('&lt;p&gt;&amp;nbsp;&lt;/p&gt;',2); $calendar.= '&lt;/td&gt;'; if($running_day == 6): $calendar.= '&lt;/tr&gt;'; if(($day_counter+1) != $days_in_month): $calendar.= '&lt;tr class="calendar-row"&gt;'; endif; $running_day = -1; $days_in_this_week = 0; endif; $days_in_this_week++; $running_day++; $day_counter++; endfor; do /** QUERY THE DATABASE FOR AN ENTRY FOR THE PERIOD !! IF MATCHES FOUND, STORE THEM !! **/ $entries = getEntriesFromDB($month,$year); /* keep going with days.... */ for($list_day = 1; $list_day &lt;= $days_in_month; $list_day++): $calendar.= '&lt;td class="calendar-day"&gt;'; /* add in the day number */ $calendar.= '&lt;div class="day-number"&gt;'.$list_day.'&lt;/div&gt;'; if ($entries[$list_day]): /** ADD THE ENTRIES FOR THE DAY!! **/ endif; $calendar.= str_repeat('&lt;p&gt;&amp;nbsp;&lt;/p&gt;',2); $calendar.= '&lt;/td&gt;'; if($running_day == 6): $calendar.= '&lt;/tr&gt;'; if(($day_counter+1) != $days_in_month): $calendar.= '&lt;tr class="calendar-row"&gt;'; endif; $running_day = -1; $days_in_this_week = 0; endif; $days_in_this_week++; $running_day++; $day_counter++; endfor; More seriously, in the first case you'd have a query like SELECT date,event from entries where date = $date and now you'd have SELECT date,event from entries where date between $date_minus_one_month and $date Then store the results in an associative array, indexed by days.
1
SELECT date,event from entries where date = $date
Path Variable Not Working
I tried everything, but I still can't get my Path working: This is my PATH: This is my environment variables: My java bin folder contains java.exe @David Wallace Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved. C:\Users\Andy\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup>echo %PATH% c:\Program Files (x86)\Intel\iCLS Client\;c:\Program Files\Intel\iCLS Client\;C: \WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\Window sPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64;C:\Program Files\Intel\Intel(R) Manage ment Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Com ponents\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\D AL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Pro gram Files (x86)\Windows Live\Shared C:\Users\Andy\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup>
I solved it. Instead of using a GUI to set the path, I used: Path = %PATH%;C:\Program Files\Java\jdk1.7.0_45\bin
0.666667
Path = %PATH%;C:Program FilesJavajdk1.7.0_45
Most effective way to increase programmer salary besides just doing your job?
If you have the time and resources, what would be the most effective way to increase your salary as a full-time programmer, outside of just doing your job? By "salary" here, I mean salary (adjusted for location cost-of-living) coming from a single programming job.
There is a ceiling that most companies are not willing to go beyond for a straight programmer. You have to take on management/leadership roles if you want to pass that ceiling.
1
You have to take on management/leadership roles if you want to pass that ceiling.
Would it be a problem if all Amazon links were converted to affiliate links?
I'm thinking that one way Jeff and the Stack Overflow team could squeeze some extra money out of this site would be to automatically convert all Amazon links posted here into affiliate links, e.g. Stick "tag=codinghorror-20" (or more likely a new site-specific tag) onto every Amazon link. This would bring in some additional revenue every time someone purchased a book via a link on this site. They could do similar things with other links as well. Amazon's simply the most obvious choice. So my question is, would anyone have a problem with this? I know I wouldn't mind, but I don't know how other people would react. What does everyone think? Is this a horrible idea, a great idea, a waste of time?
@pbh The only place I could see this being a problem is when somebody posts their OWN affiliate link and gets it transformed into a SO affiliate link. Otherwise, I think it's a good idea, and maybe you could just transform the links not already affiliated. I actually think that everyone else's affiliate links should already be filtered out (though I doubt that they currently are). I think it's extremely uncool to post affiliate links on someone else's site, especially someone else's commercial site.
1
@pbh The only place I could see this being a problem is when someone posts their OWN affiliate link
Asterisk for Small Business - Where to Start?
I have been in IT for a long time now doing software development and some system/server administration, but all mostly software-related services. I would like to help set up a small business (~50 employees) with Asterisk, but I am not very familiar with how the whole T1, data/voice channels, etc work. I have set up a personal Asterisk server (functional), but have not done so with a pipe like a T1 (which sounds more complex than residential cable/DSL). Are there any resources out there to help me understand what may be needed of me to help set this business up with Asterisk and re-use their existing T1 pipe? Any help would be greatly appreciated.
Solid answer by @Bittrance already. My main highlights for a new to all this 'VoIP guy for a small office' would be: Server setup: Consider buying an appliance with a nice GUI. Several vendors make 'Asterix bundled with hardware' packages, like the "Asterisk Appliance 50" or "Trixbox". If not an appliance, then at least consider a nice virtual machine / server software image (OS + Asterix + Addons + GUI) like AsteriskNOW, Trixbox, etc. Upstream connection: You can use an IP based telephony service provider, i.e. send SIP VoIP data over the T1 to your telephony service provider. This is where much of the business innovation, low telephony rates etc can be had. In a good design, you want QoS on the upstream (T1) line, to guarantee good voice quality in all conditions. You can use a traditional telephony service provider, and use ISDN/2, ISDN/30, or multiple analog lines to connect to your upstream service provider. This is very reliable, time-proven, and doesn't have any QoS needs as you are not mixing data and voice on the same physical circuit. QoS: "Quality of Service (QoS) is the biggest design issue. QoS, at very high level, refers to the ability to prioritize data flows though shared pipes, i.e. make sure voice traffic gets priority over computer data. How to best implement QoS in a given network is very dependent on what equipment is being used. In a few cases, the simplest/cheapest QoS solution is to just use 2 physical circuits -- one for data, and another for voice. For example, some small offices use a new high-speed FiOS package for Internet connectivity/data, and an old T1 or something for voice uplink. The most cost-effective option will depend on what is being offered in your area, and the QoS capabilities of your existing firewall/router. You should go for QoS on your internal network too. That's not so hard; the common solution is setting up dedicated VLANs for voice and data, and using the QoS implementations in your (managed Cisco) switch. Some really cheap installations use 2 switches, one dump ~30 USD switch for data/PCs, and another dumb switch for SIP phones exclusively. That works too, but is inelegant and can lead to lots of cable runs. Phones: Read some reviews, and get good SIP phones for your office. Sound quality differs substantially between models (mostly due to different microphones &amp; speakers). A SIP phone is basically a micro-computer. It needs an IP address (DHCP), it must be registered with Asterix, from time to time you might want to update the phone firmware, etc. Plan how you will administrate this.
1
How to best implement QoS in a given network is very dependent on what equipment is being used
Setting text of UITextField from caller view
I have a barcode scanner on one view, and after the user has scanned the barcode, the app takes them to another view (BoilerDetails) where the barcode text field has been pre-filled. I understand that the viewcontroller is null when it hasn't come into view and I can'tchange the UITextField text directly. This so far has given me an error.. How can I fix this? BarcodeScannerViewController.m BoilerDetailsViewController *viewCtrl = [[BoilerDetailsViewController alloc] initWithNibName:nil bundle:nil]; [viewCtrl setBarcode:strBarcode]; [self.navigationController pushViewController:viewCtrl animated:YES]; BoilerDetailsViewController.h @interface BoilerDetailsViewController : SubViewControllerBase @property (retain, nonatomic) NSString *barcode; @property (retain, nonatomic) IBOutlet UITextField *barcodeField; - (void)setBarcode:(NSString*)strBarcode; @end BoilerDetailsViewController.m -(void)setBarcode:(NSString *)strBarcode { self.barcode = strBarcode; } - (void)viewDidLoad { [super viewDidLoad]; [_barcodeField setText:self.barcode]; // Do any additional setup after loading the view from its nib. }
you just have to synthesize the barcode and in ViewDidload just write this code [_barcodeField setText:barcode]; and good to Go.
0.888889
BarcodeField setText:barcode
two-way connection between SharePoint list and wiki page?
I received an unusual request and I'm trying to figure out if it's possible: store data in a custom list to be used for a report output the formatted data to page let users edit the page page must have "track changes" or "page history" functionality (here's the kicker) edits made to the page should automatically appear in the list items I think that I could write a custom program that would output the list data to a wiki page. However, if changes were made to the wiki page, they wouldn't be reflected in the original list. Can this be done, and if so, how?
If the user really want to go this route. You need to use an event receiver associated with the pages library. On item updated you should parse the page html. Another option is to edit wiki page layout and add a data sheet (but in this case the data will be tabular)
0.888889
How to parse page html
What maintains quark spin alignments in baryons?
What maintains quark spin alignments in baryons? The $uud$ proton and $udd$ neutron are both spin 1/2, implying that two of their spin 1/2 quarks are always parallel and the other is always opposed. In contrast, the $\Delta^+$ particle (which like the proton is $uud$) and the $\Delta^0$ particle (which like the neutron is $udd$) are both spin 3/2, implying presumably that the same principle keeps their internal quark spins all parallel. What principle keeps trios of quarks aligned or anti-aligned in such specific ways?
The question is "what maintains the orientation". What maintains it is simply the angular momentum conservation. If the total angular momentum has $J^2=j(j+1)\hbar^2$ for $j=1/2$ or $j=3/2$, it obviously can't change because the whole vector $\vec J$ (including its length) is conserved. An up-spin may not spontaneously change to a down-spin and there is no value in between. The quantum mechanical problem for the bound state of quarks has, much like similar problems for atoms, some solutions with various values of the spin. Just like in atomic physics, the symmetry or antisymmetry of the orbital part of the wave function is correlated with the wave function for the spins, and therefore with the total spin, in various ways to guarantee that the overall wave function is antisymmetric. Some of these solutions have $j=1/2$, others have $j=3/2$. There are no other values of spins one may get by combining three $j=1/2$ spins.
0.666667
What maintains the orientation?
Why did my sweet potato hash turn soggy when frying in a non-stick pan, and crispy in a cast iron?
I was making a sweet potato hash for pizza topping the other night, and tried to fry the first batch in a non-stick pan. The hash never crisped up and was soggy, so I ended up mashing it instead. The next batch I fried in my seasoned cast iron, and it crisped up like a good hash. Does anyone know why this happened? To me, it doesn't make a lot of sense if both the pans were equivalently hot with the same amount of oil to fry in. The hash in the non-stick pan also seemed to absorb more oil, but again, not sure why. Details: I used a similar amount of bacon fat to fry both batches in The hash was seasoned with garlic, salt and various spices (no onion) Similar heating levels, preheated both pans No lids were used The non-stick pan is a nice Teflon coated Calphalon, and has pretty good heat retention; I use it for stir fry successfully
The theories that have come out in comments are most likely right on. Cast iron is special in how well it retains heat. Give cast iron ample preheating time, and you can drop in cold food without a significant drop in the temperature of the pan. That equals crispy. Even a pretty good and heavy non-stick pan is not going to give sweet potatoes the kind of crisp you can achieve with cast iron. You mention higher sides in the non-stick pan. That alone probably wouldn't make much of a difference, but considering that you're already seeing a greater drop in temperature as you put in the potatoes, the higher sides would hold in more moisture in the cooler pan. That is not a friend of crispiness. You say that you preheated both pans to about the same temperature. I actually hope your memory is a little off on that :) One of the great joys of cooking with cast iron is that you can and usually should pre-heat it to a quite high temperature without damaging the pan. Teflon, on the other hand, should never be preheated beyond a very moderate temperature for a very short time. Some people go so far as to say that you shouldn't preheat it all. So if your beginning temperatures were about the same in the pans, they shouldn't have been. After you put in the potatoes, forget about it. You'll never get the same kind of crispy sear with a teflon pan as you will with cast iron, even if you don't know how to best exploit the advantages of cast iron.
1
Cast iron is special in how well it retains heat
How long should the hot water last during a shower?
Given a 40 gallon natural gas water heater, and a shower head with a flow rate of 2.5 gallons per minute. How long should the shower be able to maintain 105°F water temperature? Assume the average cold water supply temperature is 58.7°F. The tank will be set at 140°F, to avoid Legionella. The tank recovery is typical of a natural gas heater, so it can recover its volume in an hour (40 gph in this case).
Model the water heater as a continuously stirred tank reactor (CSTR), so it is always at a uniform temperature. Assume the recovery time is not dependent on temperature and completely accounts for insulation losses and the like. Neglect losses in pipes and assume the operator controls the shower temperature to 105°F perfectly. Taking the stopping criterion from the question, the shower is over when the water in the tank becomes 105°F. The recovery rate raises 140 gallons of water by 81.3°F in one hour. We'll say this is a constant heat input of 9118 W. The key is that a constant-temperature shower removes a constant rate of heat from the tank, that which is associated with raising 2.5 gpm of water from 58.7°F to 105°F. This is 16986.5 W. The difference is 7868.5 W. With constant heat, you don't need any complicated integrals. The time for the tank to drop from 140°F to 105°F is 1568 s or 26 minutes. The (maybe counterintuitive) fact that the variable flow rate from the water heater does not influence the rate of heat removal from the water heater comes from the fact that the incoming cold water is the same temperature at the shower and at the water heater. Note that, because does not appear in the expression for , is now a constant.
1
Model the water heater as a continuously stirred tank reactor
Puddle under passenger side of car/ A/C blowing hot air
I have a 1999 Mazda 626. I drove 5hrs the other day from WA to OR. Traffic was horrible and it was blistering hot. I had my A/C going most of the time, although at one point it started blowing hot air so I switched to having the windows open. I got to my husband's house, came back out 20 minutes later and there was a huge puddle on the pavement on the passenger side. I wanted to check it, but we were running really late so I didn't touch it. Didn't use the A/C for the rest of the day, no more puddles. I have to make the drive again this week and am worried. Is something wrong with my A/C?
Water under the passenger side of the car is normal when running your A/C. The evaporator which is inside the car is located under the dash on the passenger side. When it cools the air, water condensates off of it, the water drips down into a catch basin, then goes through a tube which drains on that side of the car. What is not normal is that your A/C was not cooling properly. My suggestion is that your refrigerant is low, so is not cooling up to snuff. It only has to cool the air down past the dew point and it will draw water out of the air, even though it isn't really cold enough to cool the inside of the cabin. If you or your husband feels comfortable in doing this, there are ways you can check the refrigerant in your vehicle. I like the AC Pro Recharge Kit because it takes into account temperature variation which is needed to ensure you have the proper amount of refrigerant in your system. Since your system is pulling water out of the air, it is working to an extent. It just isn't doing a very good job of it. It is fairly easy to accomplish, so I wouldn't have any fear of doing it. If you do not feel comfortable doing it, you'll need to take the vehicle to a place which can service your car for you.
1
Water under the passenger side of the car is normal when running your A/C
Knowing C++, how long does it take to learn Java?
I am a competent C++ developer. I understand and use polymorphism, templates, the STL, and I have a solid grasp of how streams work. For all practical purposes, I've done no Java development. I'm sure some of you were in a similar situation at one point when you had to learn Java. How long did it take you to become a competent Java programmer?
I think that learning the language is not difficult. In fact, I used to be a full time C++ developer, and at some point I started writing Java code. But the thing is that I don't remember ever learning Java, so I guess I just figured it as I went. I've been doing full time Java for a long time now. If you are well familiar with C++, you may want to read a list of the major differences (e.g., everything is dynamically-bound) and then start practicing on an environment (just download Eclipse). The small differences are the main thing you would have to get adjusted to. Now that Java supports generics, one of the major switching pains is gone. Multiple inheritance, while not supported, is not a big deal if you get used to interfaces, and in fact having interfaces rather than abstract classes with PVFs improves readability. To me Java is a nice and friendly and relaxing sandboxed version of C++. I don't have to worry about GPFs, I don't have to worry about memory leaks, I don't have to worry about messing with pointers. However, don't let that confuse you, there are still plenty of opportunities to screw up royally, and they're sometimes even nastier to detect. Just take the leap. If you have the instinct, it shouldn't be a problem.
1
Java is a nice and relaxing sandboxed version of C++
Control Fields vs Heap "Mock" Fields for Branching Trigger Behavior
I've seen solutions that talk about adding control fields to allow for clever trigger branching in problems like this. I know that works, but it annoys me (feels architecturally wrong) to create such fields if it can be avoided. I've also seen solutions that have to do with using static variables for a similar purpose, but I have found occasions where one global flag is not good enough because I need the flag per record. I've tried both out and I think I want something in the middle. Something like this: global without sharing class HeapControl { private static Map&lt;Id, Set&lt;String&gt;&gt; recordTags = new Map&lt;Id, Set&lt;String&gt;&gt;(); public static void AddRecordTag(Id rowId, String tag) { if (recordTags.containsKey(rowId)) { Set&lt;String&gt; tagsForThisRow = recordTags.get(rowId); if (!tagsForThisRow.contains(tag)) { tagsForThisRow.add(tag); } } else { recordTags.put(rowId, new Set&lt;String&gt; { tag }); } } public static boolean IsRecordTagged(Id rowId, String tag) { if (recordTags.containsKey(rowId)) { Set&lt;String&gt; tagsForThisRow = recordTags.get(rowId); if (tagsForThisRow.contains(tag)) { return true; } } return false; } @IsTest public static void HeapDemo() { Account a = new Account(Name = 'Testing'); insert a; HeapControl.AddRecordTag(a.Id, 'Control-Field-Name-1'); a.Name = 'Testing2'; update a; // A trigger that fired on Account Update could check the HeapControl for the record like this system.assert(HeapControl.IsRecordTagged(a.Id, 'Control-Field-Name-1')); } } I'd like a pro-con analysis of using real control fields vs mock control fields on the heap (doesn't have to be my code, anything along the lines of static Map&lt;Id, ...&gt;, if you know of a field-tested version of this code please share). In my not-yet-field-tested opinion, the control field concept evolved out of a workflow world, but once you decide to drop down to triggers the heap will serve you better--at least you don't have to create control fields for every little trigger branch. I apologize this isn't standard Q&amp;A format--but this issue has been burning in my mind for months now and I think there are a lot of Salesforce developers (writing business process triggers in particular) that wrestle with this regularly. Thanks in advance for sharing your wisdom and experience!
At the outset, the way I look at it, the first line of the question is a bit of an apples with oranges comparison, i.e. use of Control Fields in a Workflow - Trigger distributed situation Vs in a Trigger only scenario. Analysing this problem in parts may help answer each of the two facets, one at a time. One - the interplay of Workflows and Triggers to implement Business Logic. It is up for debate how logic should be distributed, if not all of it can be accomplished in a trigger. Should workflows be used to implement as much is feasible, and only the absolute can't do's must live in a trigger. In my opinion yes, unless the resulting complexity is insanely great. Using declarative features provisioned by the platform allows for taking advantage of any of the forthcoming features of the platform, for eg. cross object workflows precluded the needs for at least some of those early-days cross object triggers. If you need to straddle logic across workflows and triggers, the 'heap' is the database, and control fields end up becoming the 'static' heap variables. This is the only situation in which, in my opinion, control fields may be advocated. The other facet is the use cases for use of control fields - If the resulting complexity of a distributed operation is too great, or if all of it can only be implemented in a trigger, than static 'heap' variables make the most sense, I can't see the needs for any entity specific control variables, although there may be a limited case for User level control fields, particularly in cases, where doing so may prove more efficient to streamline data integration / migration processes. Immediate Implications Just talking a little bit about your other question that led to this thread, you are looking at the use of Control Field to distribute logic between a trigger and a workflow vs customising the input using Visualforce, so you can clearly demarcate the source of the change. Going down a VisualForce route (which I have done for cases like OpportunityContactRoles, where triggers / workflows are not possible) means investing in a test class besides the cost of maintainability and the danger of subverting any new features that become available in out of the box page layouts, eg. inline editing that came to PageLayouts, and it was some time, before that became available in Visualforce. Declarative should always be the preferable approach, unless there are really strong motivations for going custom, as more often than not, it ends up being more expensive in the long run (the cost of maintainability, test classes and deployment inclusive)
0.888889
Use of Control Fields in a Trigger only scenario
Roots of this third degree polynomial
I've got the following polynomial $$ x^3-6x^2-2x+40 $$ and I want to find its roots. The only option I see at the moment is to compute all the divisors of $40$ and their inverse, and manually check if it's result is $0$. This works, because $4$ is a zero and now we can divide the polynomial by the factor $x-4$, resulting in a second degree polynomial (which is easier to solve). I was wondering if there's any other method/idea to manually find the roots of this polynomial?
Your method, which starts by employing the Rational Root Theorem and then (implicitly) Factor Theorem and polynomial long division is the most elementary method and probably the quickest. Of course, it only works in certain cases. You can save a bit of work in the division step by using synthetic division. There is a general cubic solution, but it's very tedious, and not worth it in this case. Approximate (iterative) methods like Newton-Raphson may also be used, and they're quicker than the general cubic solution, but they don't give exact roots. Of course, if the values you get are "suspiciously" close to integers, you can just test the integers to see if they're indeed the roots the method is converging toward and short-cut the process.
1
Calculate Root Theorem and polynomial long division .
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?
The story I remember is definitely ‘The Weather Man’ by Theodore L. Thomas (synopsis). Printed in Isaac Asimov Presents The Great SF Stories 24 (1962)
1
The Weather Man by Theodore L. Thomas
iptables -P FORWARD DROP, good or bad?
Is dropping all FORWARD packets bad? What are they used for? Why would I want to block them or keep them open? (I fully understand INPUT and OUTPUT)
The FORWARD chain is used to manage packets that are being routed through the machine. If the machine is a router then dropping all packets in the FORWARD chain would be bad. If it's not a router then you can drop packets in the FORWARD chain (if they ever get there).
0.777778
If the machine is a router then dropping packets in the FORWARD chain
How to find inter-country buses in Europe?
I was traveling from Zurich to Frankfurt, and when I asked a tourist information, the guy advised that the best way is train. I took the train, and when arrived in Frankfurt, I found that there is a German company having bus from Zurich to Frankfurt with 1/3 of the train price. The problem is that bus companies are small and not-connected. On the other hand, such small companies have website mainly in their local languages (not English). As a result, it is difficult for a foreigner to find the best option for bus from a country to another; particularly, as they operate from small stations rather than a big united terminal (as one can go and ask for options). Are there resources (e.g., websites) for searching all bus routes around Europe?
In many countries, there are only one or two companies offering long-distance busses and Eurolines would be the only one with a regular network of international busses. So the first things to check is the national transport company and Eurolines. But there are more and more alternatives and in my experience it seems especially true for Germany. I don't know how comprehensive their coverage is but Rome2rio does include several of them and has two different solutions for this particular journey.
0.888889
Rome2rio has two different solutions for long-distance busses
Can an iphone/android cell phone communicate with RFID?
Is it possible for a cell phone to communicate with an RFID chip? I'm looking for a low-powered solution to turn a device on/off wirelessly, using a cell phone. Example: phone sends signal to RFID chip, circuit board switches on. It really looks like Bluetooth will take too much battery, as this will be a portable device. Any suggestions ?
No, not 'out of the box'. Some phones have a NFC (near-field communication) capability, which could be used if your device is NFC enabled. Note that although similar, NFC and RFID are not compatible. To use NFC, you'd have to write an app for your phone to interface with your device. Because of this, and because there are no IOS/iDevices with NFC capability, you're limited to Android. For iPhone, the only option would be a commercial RFID add-on hardware and accompanying software. What kind of 'interface' are you looking for? If you are looking for something that activates by close proximity, Bluetooth might not be suitable.
1
NFC (near-field communication) capability if device is NFC enabled
How can I edit symlinks?
My basic understanding of a symlink is as a special file, a file that contains a string path to another file. The kernel's VFS abstracts a lot of that away but is there any reason why symlinks seem to be impossible to edit? In other words: Can I edit a symlink? If not, why not? I do understand that there are various ways of replacing symlinks (two alternatives are currently in the answers section) but it would be interesting to get an explanation on why replacement seems to be the only way to deal with symlinks. Why can't you just change where they point?
Given that -f just does a silent replacement, you can do an atomic replacement with mv: ln -s /location/to/link linkname # ... ln -s /location/to/link2 newlink mv newlink linkname linkname is accessible throughout the process.
0.777778
atomic replacement with mv
Excel VBA App stops spontaneously with message "Code execution has been halted"
From what I can see on the web, this is a fairly common complaint, but answers seem to be rarer. The problem is this: We have a number of Excel VBA apps which work perfectly on a number of users' machines. However on one machine they stop on certain lines of code. It is always the same lines, but those lines seem to have nothing in common with one another. If you press F5 (run) after the halt, the app continues, so it's almost like a break point has been added. We've tried selecting 'remove all breaks' from the menu and even adding a break and removing it again. We've had this issue with single apps before and we've 'bodged' it by cutting code out of modules, compiling and then pasting it back in etc. The problem now seems to relate to Excel itself rather than a single .xls, so we're a little unsure how to manage this. Any help would be gratefully received :) Thanks, Philip Whittington
I have came across this issue few times during the development of one complex Excel VBA app. Sometimes Excel started to break VBA object quite randomly. And the only remedy was to reboot machine. After reboot, Excel usually started to act normally. Soon I have found out that possible solution to this issue is to hit CTRL+Break once when macro is NOT running. Maybe this can help to you too.
0.833333
Excel VBA issue
Non Removable Presta Extension
Just got a pair of tubular Vittoria Rally road tyres. They look perfect but the problem is that the valve is 42mm which is no good for my new awesome 50mm rims. Above all the valve core is not removable so the extenders I've got with them are useless. The question is if there's any mean to extend the valves up to 60-80mm in this situation or should I return it back to the shop? Thank you in advance for your advised.
I also would recommend finding tubes with valves of the correct length. However, if that fails, I've had success using a presta to schrader adapter. Often with shorter valves, there won't be enough room to attach a pump head, but there will be enough to attach an adapter, which you can then use a pump that works with schrader valves. Most pumps have the ability to do both now. I'm not sure if this will work in your situation, since you say you have 50mm rims and 42mm valves which to me would mean that there would be no part of the valve protruding from the rim.
0.888889
a presta to schrader adapter can be used with shorter valves
"Files" can't be resized
I am not able to change the size of my nautilus window. It is now small. What should I do to restore it to normal size?
Use Alt and Middle Click and drag to change it's size.
1
Use Alt and Middle Click and drag to change size
Removing oil filter from Lincoln Mark VIII
I've had two different Lincoln Mark VIIIs - one 1993, and currently one 1996 LSC. Both are "first generation" ('93-'96) Mark VIIIs, but I'm fairly certain this will also apply to "second generation" ('97-'98) models. The problem is that the oil filter is in one of the most inconvenient places ever conceivable. Usually, with relatively little trouble, I can get my arm in well enough to unscrew and pull the filter off. But, when it comes to actually getting the filter out from the confined space that is its home, there always seems to be some form of creative contortionism required and I can never seem to remember how it is I got the thing out the last time. Is there any "easy way" to go about doing this? Is there some trick or special technique I might be missing out on?
I have not had the pleasure of working on this model, and the service software I have doesn't give me a good picture of the situation. However, here are a couple of approaches to problematic oil filters (same applies to other parts as well): Does turning the wheel all the way (or part way) in one direction or the other cause the steering linkage to move out of the way? (I have found evidence that a hard right may work for this specific model). Can you access the filter from above? A number of components are surprisingly accessible from the top side of the engine, even if they are pretty far down. Does removing the driver side wheel (and associated wheel well trim) provide better access? If so, it's a matter of whether removing the wheel is more trouble than it's worth. Please verify if the hard right turn is true for this model.
1
Does turning the wheel all the way (or part way) in one direction cause steering linkage to move out of the way?
Etiquette for posting civil and informative comments
Sometimes I leave a comment like "Stack Overflow is not your personal research assistant," but am accused of being rude. How can I craft a comment that is seen as civil to the community and instructive to the OP? What tone should I strike in comments? What are some examples of bad comments and their better replacements?
Assume that the person you are replying to is not intentionally clueless/lazy. Answer them the way you'd want someone to answer you if you accidentally posted something that sounded clueless/lazy (even though you know you're not like that IRL). Assume the best of them, not the worst. Civillity = respect + benefit of doubt So you don't have to get florid, just refrain from answering as though the OP is annoying you on purpose.
1
Assume that the person you are replying to is not intentionally clueless/lazy
Does War Stomp exhaust me before I am the defender?
This question is related to the World of Warcraft Trading Card Game. I have a Hunter, no allies out, and in my hand is a Frost Trap. My opponent attacks with Himul Longstrider, who has War Stomp. He wants to target my hero with the War Stomp power. Will my hero be exhausted before I am able to pay the cost of Frost Trap? Put another way, does War Stomp exhaust my hero before my hero is "defending," thus preventing me from paying its cost by exhausting my hero?
Yes. According to answers on the wowtcg.com forums, War Stomp triggers in two different places, depending on whether the character with War Stomp is attacking or defending. If attacking, then War Stomp triggers at the beginning of the Attack Window, just after the attacker exhausts for that attack. Since this happens before the Protect Point, you can exhaust a protector before they can protect with it. If defending, then War Stomp triggers at the beginning of the Defend Window, just after the Protect Point. You cannot use War Stomp while defending to stop the current attack, but you can exhaust another character to stop them from attacking that turn." The upshot of this is that when you are attacked by an ally with War Stomp, the attacker can exhaust your hero before the Protect Point, when you are still just the proposed defender. Since you're not yet the defender, you can't respond by exhausting your hero to pay Frost Trap's cost.
1
War Stomp triggers in two different places depending on whether the character is attacking or defending.
How can I create and retrieve default billing address programatically?
Our site imports customers from external data sources. Part of this import is creating a default billing address from external data if none exists. I have followed advice from other questions, as wells as tutorials, all of which seem to say the same thing for creating/saving a default billing address. This seems to work at least partially. // $c is the customer $data_source = array( 'street' =&gt; '', 'city' =&gt; '', 'postcode' =&gt; '', ); $a = $c-&gt;getPrimaryBillingAddress(); // Create a new default billing if none found if (!$a) { $a = Mage::getModel("customer/address"); $a-&gt;setCustomerId($c-&gt;getId()) -&gt;setIsDefaultBilling('1') -&gt;setSaveInAddressBook('1'); } foreach ($data_source as $k =&gt; $d) $a-&gt;setData($k, $d); $a-&gt;save(); After this code has been run, the address is visible on the customer's page in the backend and is marked as the default billing. However, the following time data is fetched from our external source and the code is run, the address that was saved is not retrieved (getPrimaryBillingAddress returns false). This results in a new address being created every time this code is run. The exception is when a customer has a default billing address set by magento. In this case, getPrimaryBillingAddress correctly finds the address and the address data is updated and saved. How can I programatically create a default billing address in such a way that I can retrieve it with $customer-&gt;getPrimaryBillingAddress()? UPDATE After receiving a possible answer, I have adjusted to code to set customer's default_billing. The main problem persists with the changes. $a = $c-&gt;getPrimaryBillingAddress(); // Create a new default billing if none found if (!$a) { $a = Mage::getModel("customer/address"); $a-&gt;setCustomerId($c-&gt;getId()) // &lt;-- variations of customer/customerID -&gt;setCustomer($c) // don't seem to affect -&gt;setIsDefaultBilling('1') -&gt;setSaveInAddressBook('1') -&gt;save(); // &lt;--- SAVE SO WE CAN ACCESS ID $c-&gt;addAddress($a) // &lt;--| -&gt;setDefaultBilling($a-&gt;getId()) // &lt;--+ SAVE default_billing IN CUSTOMER -&gt;save(); // &lt;--| } foreach ($data_source as $k =&gt; $d) $a-&gt;setData($k, $d); $a-&gt;save(); // ---------------- SUBSEQUENT RUNS -------------- $c-&gt;getDefaultBilling(); // null $c-&gt;getPrimaryBillingAddress(); // false References Variations on this method for creating/setting a customer default address were found at these locations: SO - Magento : Add customer default billing address Programatically create customer and order in Magento with full blown One Page Checkout process under the hood
You need to set it the other way around. The default_billing for the customer. $customerId = 1234; // Customer id $data = array(); // Address data $customer = Mage::getModel('customer/customer'); // Load customer $customer-&gt;load($customerId); // Get current address $address = $customer-&gt;getPrimaryBillingAddress(); // Do we add a new address $isNewAddress = false; if (!$address) { $address = Mage::getModel('customer/address'); $address-&gt;setCustomer($customer); $isNewAddress = true; } // Append data $address-&gt;addData($data); $address-&gt;save(); if ($isNewAddress) { // Add address to customer and save $customer-&gt;addAddress($address) -&gt;setDefaultBilling($address-&gt;getId()) -&gt;save(); }
1
The default_billing for the customer
uniformly continuous functions and measures
Consider a sequence of measures for which $\int f \, \mathrm{d}\mu_{n} \to \int f \, \mathrm{d}\mu$ for all uniformly continuous functions $f$. Is it true that $\mu_n \to \mu$ strongly?
Consider $\mu_n$ an approximation to the identity; e.g. $$\mu_n = \frac n 2 \chi_{[-1/n, 1/n]} \lambda$$ for $\lambda$ the Lebesgue measure. Then $\int f\ d\mu_n \to \int f\ d\delta = f(0)$ for all continuous $f$; but $\mu_n({0})=0\to0\ne1=\delta({0})$.
0.888889
Consider $mu_n$ an approximation to the identity
Isn’t the FAQ label obsolete by now?
Don’t get me wrong in the beginning of reading this. I really mean the label and not the content of FAQ. The content is very useful if its’ made the right way (as here on ux.se), but there are plenty of examples where it isn’t. The real question concerns the label which is a convention I’d like to challenge. History In 1647 Matthew Hopkins wrote The Discovery of Witches which were introduced as "Certain Queries answered" and had the form of a list of Question and Answer, even if the topic is inappropriate by today’s standards. The label FAQ origins from the early 1980s mailing lists where NASA hoped to get new users read the old mail conversations, which were not the case. Instead the same questions were answered again and again and the need for FAQ was born. The acronym FAQ was invented by Eugene Miya and FAQ were later used in mail on a weekly basis at first and later on as a daily mail. Today FAQ is more frequently used to refer to the list, and a text consisting of questions and their answers is often called an FAQ regardless of whether the questions are actually frequently asked, if they are asked at all.[1] Problem Acronyms are generally bad, since it excludes those who do not know the meaning. They either have to search for the acronym, if they are interested, or just ignore it. If a label is ignored, there is not much use of it and an entire section of valid content is lost by bad labeling. However, it is a very strong web convention which might lead to confusion over time for experienced users. Also the original meaning have changed (see quote), which also implies that the label would be wrong. Question Isn’t the FAQ label obsolete by now? and if so How do we relabel it to suit both experienced and new users? Edit: I’d really like to know why we can or cannot change the label FAQ. Current answer does not meet that criterion. [1] http://en.wikipedia.org/wiki/FAQ
My own view of the topic is that the label FAQ is obsolete, for a number of reasons. To begin with, it’s an acronym which is bad in itself since new users of the web doesn't immediately get what it means. This means that a whole section, which could be useful, is lost altogether. Second it is not always frequently asked questions, but questions that content providers would like the users to read. In those cases it is more accurate to label the FAQ as help. Still, I'm part of a minority, both when it comes to answers and votes on this topic. The following graph (a snapshot from march 22nd) makes it clear to me that it isn't as easy as I first thought. The User Experience Stackexchange community is strongly against relabeling FAQ to something else. My second question "How do we relabel it to suit both experienced and new users?" were answered by Hillier. His answer was to look at the some of the worlds leading websites such as Google, Facebook and Twitter, who doesn't use FAQ but just help. Their help content is extensive and not always in the Question and Answer form, thus it isn't a real FAQ section. If one are going to change the label, one could use double coding, using both the suggested "help" and the acronym "faq" together. Then new user would know what help is, and the more experienced user would know that the help section is in a form of frequently asked questions. Like the following: NOTE: This is just an example and not a real suggestion of change to this site. If I would like to have a discussion of this sites' FAQ-label I would post it on meta.
1
How do we relabel FAQ to someone else?
If you attempt to predict a Roulette wheel $n$ times, what's the probability you'll get $5$ in a row at some point?
I'm talking about a Roulette wheel with $38$ equally probable outcomes. Someone mentioned that he guessed the correct number five times in a row, and said that this was surprising because the probability of this happening was $$\left(\frac{1}{38}\right)^5$$ This is true if you only play the game $5$ times. However, if you play it more than $5$ times there's a higher (should be much higher?) probability that you'll get $5$ in a row at some point. I was thinking about how surprised this person should be at their streak of $m$ correct guesses given that they play $n$ games, each with probability $p$ of success. It makes intuitive sense that their surprise should be proportional to $1/q$ (or maybe $\log(1/q)$ since $1$ in a billion doesn't surprise you $10$ times more than $1$ in $100$ million), where $q$ is the probability that they get at least one streak of $m$ correct guesses at some point in their $n$ games. So, with the Roulette example I was thinking about, $p=1/38$ and $m=5$. I tried to find an explicit formula for $q$ in terms of $n$, and encountered some difficulty, because of the non-independence of "getting a streak in the first five tries" and "getting a streak in tries $2$ through $6$" (if the first is a failure, it's much more likely that the second will be too). In summary, two questions: How do I find the probability that you get $5$ correct guesses in a row at some point if you play $n$ games of Roulette? More generally, what is the probability that you get $m$ successes at some point in a series of $n$ events, each with probability $p$ of success? The variables satisfy $\,\,\,m,n \in \mathbb{N}$, $\,\,\,m\leq n$, $\,\,\,p \in \mathbb{R}$, $\,\,\,0 \leq p \leq 1$. If we write the answer to the second question as a function $q(m,n,p)$, then we can say that $q$ should be increasing with $n$, decreasing with $m$, and increasing with $p$. It should equal $p^n$ when $m=n$ and should equal $1$ when $p=1$ and $0$ when $p=0$. I feel as though this should be a basic probability problem, but I'm having trouble solving it. Maybe some kind of recursive approach would work? Given $q(n,m,p)$, I think I could write $q(n+1,m,p)$ using the probability that the last $m-1$ results are all successes ...
You have a six-state system. State 1: Not on a run. Either you haven't started, or the last guess was wrong. State 2: The last guess was correct. State 3: The last two guesses were correct. State 4: The last three guesses were correct. State 5: The last four guesses were correct. State 6: You have a 5-in-a-row. The transition matrix is $$A=\left(\begin{array}{cccccc} 1-p&amp;p&amp;0&amp;0&amp;0&amp;0\\ 1-p&amp;0&amp;p&amp;0&amp;0&amp;0\\ 1-p&amp;0&amp;0&amp;p&amp;0&amp;0\\ 1-p&amp;0&amp;0&amp;0&amp;p&amp;0\\ 1-p&amp;0&amp;0&amp;0&amp;0&amp;p\\ 0&amp;0&amp;0&amp;0&amp;0&amp;1 \end{array}\right)$$ The initial vector is $\vec{v}=(1,0,0,0,0,0)$ To find the probabilities after $n$ rounds, calculate $\vec{v}A^n$
1
State 1: Not on a run, or the last guess was wrong
conditional probability - 2 different tests done
Question: A medical research team wanted to evaluate a screening method proposed for Alzheimer's disease. The method was evaluated on 450 patients randomly selected patients with Alzheimers (in 436 cases, the screening was positive). Moreover, the method was also done on 500 patients without the disease and returned positive for 5 out of the 500. 7.7% of all Canadians over the age of 65 have Alzhiemers. Find the probability that a Canadian over the age of 65 has Alzhiemers given the test was positive. It seems that the test returns a 96.8% chance of success given that the patient has alzhiemers and a .01% chance of success given the patient DOESN'T have alzhiemers. So I used bayes theorem for this one, so that I would find A = Alzhiemers Positive = Positive test result given the patient actually had alzhiemers Positive2 = Positive test result given the patient doesn't have alzhiemers $$P(A | Positive) = \frac{P(Positive|A)(A)}{P(Positive|A)(A) + P(Positive2|A)(A)}$$ $$= \frac{(.968)(.077)}{(.968)(.077) + (.01)(.077)}$$ $$= approx. .98$$ Did i do this correctly? As in was i supposed to even use bayes theorem for this problem? ahh seems like i multiplied the probability of positive test result given the person doesn't have alzhiemers with the probability of all canadians who do have alzheimers. Thanks guys.
Where you have $$\frac{P(Positive|A)(A)}{P(Positive|A)(A) + P(Positive2|A)(A)}$$ you should probably have $$\frac{P(Positive|A)P(A)}{P(Positive|A)P(A) + P(Positive2|\text{not }A)P(\text{not }A)}$$ which would give a rather smaller result. Yes you should use Bayes' theorem, and it is this smaller result which is apparently particularly counter-intuitive to medical students (and law students).
0.666667
If you have $$fracP(Positive|A)(A)P (Posesitive
Cyclic group of order $6$ defined by generators $a^2=b^3=a^{-1}b^{-1}ab=e$.
The cyclic group of order $6$ is the group defined by the generators $a,b$ and relations $a^2=b^3=a^{-1}b^{-1}ab=e.$ For this problem I am assuming that it must be $a,b \neq e$. I will show the $a^ib^j$ are distinct for $i=0,1$ and $j=0,1,2$. If $i=0$, $b^0=e,b,b^2$ are distinct. We know order of $b$ is not $2$ as $b^3=e$ as the order of an element divides powers that make $b$ the identity, this would mean $2\mid 3$ a contradiction. For $i=1$, $$ab^i=ab^k \rightarrow b^i=b^k \rightarrow i\equiv k \mod{3}$$ but as $0\leq i,k &lt; 3$, $i=k$ so $a,ab,ab^2$ are distinct. So we have that $G \supseteq \{e,a,b,b^2,ab,ab^2\}.$ So $$G=\left&lt;a,b\right&gt; =\{ a^{n_1}b^{n_2}\cdots a^{n_r}b^{n_{r+1}}\mid n_i \in \mathbb{Z}\}$$ and as $a^{-1}b^{-1}ab=e$, $ab=ba$ and so we can write $G$ as $$G=\{a^nb^m \mid n,m \in \mathbb{Z}.$$ We then also have by $a^{-1}b^{-1}ab=e$ that $$a^{-1}b=ba^{-1},\,a^{-1}b^{-1}=b^{-1}a^{-1},\,ab^{-1}=b^{-1}a$$ and so any $$a^nb^m=a\cdots a\cdot b\cdots b =b^ma^n$$ as we can commute the elements to get $b^ma^n$ so $G$ is abelian. To show there are exactly $6$ elements, if we pick any $a^nb^m \in G$, we can assume that $0\leq n\leq 1$ and $0\leq m \leq 2$ and then this element is already accounted for above so $$G=\{e,a,b,b^2,ab,ab^2\}.$$ As $G$ is a finite abelian group of order $6$, $G$ can be written uniquely up to permutation as a direct sum of $\mathbb{Z}_{p_i^{k_i}}$'s where the $p_i$ are prime but there is only one way to do this for $6=2\cdot3$ so this means $$G\cong \mathbb{Z}_2\oplus\mathbb{Z}_3\cong\mathbb{Z}_6$$ as $\gcd(2,3)=1$. I am just wondering of nicer ways to argue this in the case I would need to do this on an exam. Also if everything looks correct too.
Your arguments work just fine, but we can do a bit better. Let's define $$G=\langle a,b\mid a^2=b^3=a^{-1}b^{-1}ab=e\rangle.$$ As you noted, $a^{-1}b^{-1}ab=e$ if and only if $ab=ba.$ Hence, $a$ and $b$ commute, and so since $G$ is generated by $a$ and $b,$ then it follows immediately that $G$ is an abelian group, and in particular $$G=\{a^mb^n\mid m,n\in\Bbb Z\}.$$ Since $a^2=e$ and $b^3=e,$ then we can conclude that $$G=\{e,a,b,ab,b^2,ab^2\}.$$ At this point, there are a few ways we can proceed: Show that $e,a,b,ab,b^2,ab^2$ are distinct, then note that the abelian group of order $6$ is cyclic. Show that $e,a,b,ab,b^2,ab^2$ are distinct, then apply Structure Theorem for Finite Abelian groups, as you did, together with the fact that $\gcd(2,3)=1,$ so that $G$ is cyclic. Show that $e,a,b,ab,b^2,ab^2$ are distinct, then demonstrate an element of $G$ of order $6.$ Show that $H:=\langle a\rangle\cong\Bbb Z_2,$ $K:=\langle b\rangle\cong\Bbb Z_3,$ and that $H\cap K=\{e\},$ so since $H,K$ are normal subgroups of $G$ (since $G$ abelian) and $HK:=\{hk\mid h\in H,k\in K\}=G,$ then $G\cong H\times K.$ (Have you seen this result before?) Thus, $G\cong\Bbb Z_2\times\Bbb Z_3\cong\Bbb Z_6.$ That last is arguably the simplest. It suffices to show that $a\ne e,$ $b\ne e,$ $b^2\ne e,$ $a\ne b,$ and $a\ne b^2.$
1
Using Structure Theorem for Abelian groups
Can you demonstrate in Python how to post an ad to Facebook's ads API?
I have found it very challenging to write a Python script to post ads to Facebook in Python. In particular, I want to post ads that show up in mobile news feeds. Can you provide boilerplate code to post one ad, that I can expand on? My goal is to write a fuller Python script post thousands of ads to Facebook. Most parts of the ads are the same, but they vary base on gender, interest, or device in some specific way.
This https://github.com/facebook/fbconsole/blob/master/src/fbconsole.py was a great starting point for me when I did what I needed to do with Facebook, although I did not do ads with it.
1
How do I do Facebook?
Is there a way to limit the range of the range pattern in awk?
I am trying to use the awk range pattern to find all SQL select statements in a group of files, inspired by this stackoverflow answer. From the awk manual: The pattern1, pattern2 form of an expression is called a range pattern. It matches all input records starting with a record that matches pattern1, and continuing until a record that matches pattern2, inclusive. My initial attempt was awk '/select/,/from/' * where * in this case just represents a large number of varied files. This returned several false hits on HTML select tags, so I refined my command to awk '/[^&lt;]select[^&gt;]/,/from/' * which seems to have eliminated most of those hits. However, I still get some false hits from occurrences of the word "select" in a comment, and those hits produce very many lines of noise each before they eventually hit a "from" or the end of the file. What I would like is for the range pattern not to register a match if there are more than, say, 10 lines between the "select" and the "from". My question is: Can I make the range pattern fail to match if the number of lines between the match of pattern1 and the match of pattern2 exceeds a given threshold, and if so, how?
You can expand the /pattern1/,/pattern2/ condition as much as you want, by adding a {} block after to be performed when this occurs: See for example how we print those numbers being between 50 and 70, but just the first 5 matches of each block: $ seq 200 | awk '/50/,/70/ {if ($0~/50/) {c=0}; if (c++ &lt;= 5) print}' 50 51 52 53 54 55 150 151 152 153 154 155 In your case, you may want to say something like this, that will print the first 10 lines that were matched. awk '/[^&lt;]select[^&gt;]/,/from/ {if (c++ &lt;= 10) print}' * A more complex solution would consist in storing all this output and then printing it at the END block. This way, you can control the block itself instead of just a specific line. I would do this storing the data in an array, etc.
1
Adding a block after to be performed when this occurs
Remove numbers in bibliography
I want to remove the numbers in the bibliography. For example: FERREIRA, L. P. (Org.). O fonoaudiólogo e a escola. São Paulo: Summus, 1991. without number. I am trying \bibitem [] {Askey}, but [] appears in the document. Can someone tell me how this is done? \documentclass{article} \begin{document} Resultados obtidos foram utilizado: Askey (1985),$^{\cite{Askey}}$ \begin{thebibliography}{99} \bibitem [] {Askey} ASKEY, R.; WILSON, J. \emph{Some Basic Hypergeometric Polynomial that Generalize Jacobi Polynomial}. Memoirs of the American Mathematical Society, v. 54, p. 1-55, 1985. \end{document}
The answer really depends on how you have set up your document and how you create your bibliogrphy etc (are you using bibtex, biblatex, ...?). Any way one solution, which may or may not be appropriate is to add the following to your preamble: \makeatletter \def\thebibliography#1{% \c@chapter\z@ \c@section\z@\let\chaptername\relax \section*{References}\list {}{\settowidth\labelwidth{}\leftmargin\labelwidth \advance\leftmargin\labelsep \itemsep\z@\parsep\z@\topsep\z@\parskip\z@ \usecounter{enumi}} \def\newblock{\hskip .11em plus .33em minus .07em} \sloppy\clubpenalty4000\widowpenalty4000 \sfcode`\.=1000\relax} \makeatletter Actually, this solution makes the bibliography more compact, which you mightn't like. Another solution, that it closer is spirit to what you tried, is to modify \bibitem. If you look at the definition of \bibitem (using, for example, \show), you will see that it calls \@bibtem and this is where the \item command comes from. Hence, you can get what you want with the following: \makeatletter \def\@bibitem#1{\item[]% \if@filesw\immediate\write\@auxout{\string \bibcite {#1}{\the\value{\@listctr }}}\fi\ignorespaces} \makeatletter The difference between these two approaches is the indentation of the bibliography entries. The first attempt produces whereas the second gives you The first approach is the more robust and the second may have unintended side-effects, not least because it doesn't cater for the optional argument that \bibitem accepts.
1
The answer really depends on how you have set up your document
How to determine directions of vectors of an electromagnetic wave
I did an exercise which probably is quite popular, in which you draw an electromagnetic wave and prove that it should propagate at the speed of light $1 \over \sqrt {\mu_0\epsilon_0}$ using Farday's law and Ampere's law. Basically if this is the wave: Let's say the E-field (red) is in the X direction, the B-Field (blue) is in the Y direction, and the velocity of the wave is in the Z direction. You take for example for ampere's law a surface in the ZY plane with a length L equal to the amplitude of the wave, and a width equal to $\lambda\over 4$ You do a similar thing with Faraday's law and you get the speed of light, assuming you know that the E-field and B-field propagate in this manner. I got the right answer but I wondered about this: Let's say I only had the E-field and I know the wave propagates at the speed of light, I assume this is enough information to draw the B-field at each point. But how will I know the direction? Both Faraday's law and Ampere's law say you need a closed loop integral and the rules I've been taught say you go over the loop in a clockwise direction for example and take the normal to the surface according to the right hand rule etc. But clockwise and counter-clockwise direction don't really give me much information in this case, so how can I determine the direction of the B-field if I only have the E-field?
$ {\bf E} \times {\bf B}$ (which is the Poynting vector multiplied by $\mu_0$) should be in the direction of wave motion. I you want an aide-memoire, if you imagine taking a screwdriver and turning a (standard) screw in the direction of ${\bf E}$ towards ${\bf B}$, then the wave should be travelling in the direction that the screw is driven (either in or out).
1
aide-memoire: if you imagine turning a screw in the direction of $bf E times
How to plan for the future when installing a new roof?
We're hiring a contractor to take off the existing roof, repair/replace any rotted sheathing and rafters, and install a new roof. We've also asked that they add a new plumbing vent stack for a new bathroom we'll add later, a bathroom exhaust vent, a whirlybird to vent the attic, a dryer vent, and supports in case we want to install a roof deck later. This is a 4 floor row house with shallow pitch roof in mid-Atlantic US. There's a 6" to 3' pitched attic area with r30 batts on the ceiling joists. Also have HVAC compressor on roof and unit in attic. What else should we think about along these lines? Green roof supports? Solar panel mounts? Additional insulation? What should we prepare for now, or at least consider?
One thing to think of too is your bracing inside of your attic. There is nothing wrong with going above and beyond the code when it comes to bracing your roof. If you have noticed some sag spots in your roof you might want to think about this as well. Also, have the roofers use aluminum on your vallies. (if you have any) Many leaks happen in these areas because of poor application of tar paper before the shingles are put on.
1
Bracing inside of your attic
Custom Alert Box Shows up Incorrectly
I am using slayeroffice's custom alert box, slayeroffice(period)com/code/custom_alert/. (Can't post more than two links) On my browser it shows up like this. The alert box is the blue one in the middle of the screen. http://i.stack.imgur.com/u1TEz.png On my local it shows up like this, I highlighted the alert box. I wish i could image link this. It works on the same version version of browser but one of them is on local. http://i.stack.imgur.com/0xehV.png What am I doing wrong? Here's my code integrated with slayeroffice's code. &lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test1.aspx.cs" Inherits="Test1" %&gt; &lt;%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head runat="server"&gt; &lt;title&gt;Untitled Page&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; function showPopUp(){ setTimeout(function() {alert("Warning");}, 5000); } function delayer(){ showPopUp(); } // constants to define the title of the alert and button text. var ALERT_TITLE = "Oops!"; var ALERT_BUTTON_TEXT = "Ok"; // over-ride the alert method only if this a newer browser. // Older browser will see standard alerts if(document.getElementById) { window.alert = function(txt) { createCustomAlert(txt); //overrides alert method } } function createCustomAlert(txt) { // shortcut reference to the document object d = document; // if the modalContainer object already exists in the DOM, bail out. if(d.getElementById("modalContainer")) return; // create the modalContainer div as a child of the BODY element mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div")); mObj.id = "modalContainer"; // make sure its as tall as it needs to be to overlay all the content on the page mObj.style.height = document.documentElement.scrollHeight + "px"; // create the DIV that will be the alert alertObj = mObj.appendChild(d.createElement("div")); alertObj.id = "alertBox"; // MSIE doesnt treat position:fixed correctly, so this compensates for positioning the alert if(false) alertObj.style.top = document.documentElement.scrollTop + "px"; // center the alert box alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px"; // create an H1 element as the title bar h1 = alertObj.appendChild(d.createElement("h1")); h1.appendChild(d.createTextNode(ALERT_TITLE)); // create a paragraph element to contain the txt argument msg = alertObj.appendChild(d.createElement("p")); msg.innerHTML = txt; // create an anchor element to use as the confirmation button. btn = alertObj.appendChild(d.createElement("a")); btn.id = "closeBtn"; btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT)); btn.href = "#"; // set up the onclick event to remove the alert when the anchor is clicked btn.onclick = function() { removeCustomAlert();return false; } } // removes the custom alert from the DOM function removeCustomAlert() { document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer")); } &lt;/script&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &amp;nbsp;&lt;/div&gt; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="delayer();return false;" /&gt;&amp;nbsp; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;
You are missing the styles: &lt;style type="text/css"&gt; #modalContainer { background-color:transparent; position:absolute; width:100%; height:100%; top:0px; left:0px; z-index:10000; background-image:url(tp.png); /* required by MSIE to prevent actions on lower z-index elements */ } #alertBox { position:relative; width:300px; min-height:100px; margin-top:50px; border:2px solid #000; background-color:#F2F5F6; background-image:url(alert.png); background-repeat:no-repeat; background-position:20px 30px; } #modalContainer &gt; #alertBox { position:fixed; } #alertBox h1 { margin:0; font:bold 0.9em verdana,arial; background-color:#78919B; color:#FFF; border-bottom:1px solid #000; padding:2px 0 2px 5px; } #alertBox p { font:0.7em verdana,arial; height:50px; padding-left:5px; margin-left:55px; } #alertBox #closeBtn { display:block; position:relative; margin:5px auto; padding:3px; border:2px solid #000; width:70px; font:0.7em verdana,arial; text-transform:uppercase; text-align:center; color:#FFF; background-color:#78919B; text-decoration:none; } &lt;/style&gt;
0.888889
MSIE required to prevent actions on lower z-index elements
How to get <img> src from CDATA in RSS?
I am fetching data from RSS feed with Magpie. $rss[description] contains CDATA with html elements: &lt;![CDATA[ &lt;div&gt; &lt;a href='url'&gt; &lt;img src='img_url' alt='aaa' title='bbb' border='0' width='116' height='116'&gt; &lt;/a&gt; &lt;/div&gt;]]&gt; Some other text How can I fetch "img_url" from this? Is preg_match() the only way? Maybe I can use simpleXML?
CDATA you have is a string containing HTML. So first treat it as text, but since this text is meant to contain HTML, parse this text using solution appropriate for parsing HTML. In other words: use appropriate tool (HTML parser) for the job (parsing HTML). There are already existing solutions for parsing HTML in PHP - eg. see answers to this questions: How to parse and process HTML with PHP? Robust, Mature HTML Parser for PHP. So, basically, you already are able to get the HTML string from your XML. Now parse the HTML and get source of the image using some of the solutions mentioned above. Using preg_match() for parsing HTML is not a good idea, as it would need to be very complex to do a simple thing HTML parser is suitable for.
1
How to parse and process HTML with PHP
Group texting with Iphone users, my texts get delayed until theirs all stop
I have an S4 with the latest software update (though this has been a problem for a long time before too). And when I am in a group text with Iphone users, it seems that my outgoing texts get stuck in limbo until all of theirs is through. Sometimes several minutes, so I am always behind in the conversation. Is there a fix?
Even I own a galaxy s4 and I know that the latest update has been so terrible. I don't think that Samsung is anyway going to push any updates for this but follow the solution below. You can wipe the cache partition from the recovery mode. (Shut down and reopen by pressing menu, power and volume button at once) then scroll down using volume button to wipe cache partition and power button to confirm. Reboot the device. Very important go to developer options and switch off all the animations. Follow some more from. http://www.androidpit.com/galaxy-s4-lollipop-problems-and-how-to-fix-them
1
How to wipe cache partition from the recovery mode
How do I deal with a slow and undedicated colleague in the team?
I have been working on a new project. The project works like this: The end user can access a webapp using a link and he can add multiple systems on his network and manage that particular systems details. My part involves the front end and the webserver, which is done in python. My python actually communicates with another project which is entirely done in c &amp; c++. The c/c++ project is the main app which does all the functionality. My python sends the user request to it and displays the response from it to the user. I am very familiar with my work and I will finish it soon. Since that's not much work in it. And I am a person who loves to work. I spends most of the time in office and only go home when I feel sleepy. The c/c++ app is managed by another colleague who has 5+ year experience and can do things much faster than me, but he never does it. May be he doesn't like to do it. His app crashes often when my python communicate with it or returns wrong values. It's full of bugs. Since my app depends on it, I am having a hard time building it. Instead of fixing the bugs, he asks me to slow down my work. He asks me to tell manager that my work needs a lot of time. He is asking me to fool the manager and even forcing me to work slowly like him. During project meeting, when manager asks him about the bugs he says that he fixed everything and it works fine. Since he is my colleague, I couldn't tell anything to the manager. I obviously need to have a good relationship with my colleagues more than my manager, since most of the time we will be with our colleagues, not with the manager. I am not able to tell the manager anything regarding this, since if manager asks him why, then he may think I complained about him to the manager. And he keeps on lying in the meeting. And since he fixes the bug slowly, it even slows down my work. Now I thought of working on the front-end part of my app and finishing it off so that in the mean time he can make his project stable. Now he is asking me to tell the manager that my front end part require a lot of work and I may need more and more time, simply so that he can drag the project down. And the sad thing is our actual manager has gone to the US, so we have a temporary manager and this guy doesn't know about the project much, so the c,c++ just fools him. Can anyone suggest me how I deal with this? I wanted to finish off the project soon. How can I make him work even by maintaining a good relationship with him? Responses to comments: If he's really deliberately misleading the company, you should report him to management. I am new to this company and the other guy has been there for many years. And I have just started knowing my colleagues. If I directly go and complaint him, I don't think so I can make good relationship with my other colleagues. Even he has the power to mislead them. I am not telling he is a bad guy, he can do the work, but he is not doing it. Doesn't your company have any kind of bug tracking system ? Here actual bug tracking system isn't there. The company tries to finish off the project as soon as possible and gives it to the QA. And then fixes the bugs reported by QA. This is why companies should give employees stock / options or some sort of ownership. That way you can literally tell the guy "You are costing me monetary growth... don't you want to make money also?". The company has the stock options they have given me a 2500 share, mostly he too would have got some more. Seniority does deserve some benefit of a doubt. You really need to speak to him first and try to understand the problem. He may be out of his depth, you may be able to help him, there could easily be variables you are unaware of. It may be hard now, but you could easily make the situation a lot worse by jumping the gun. I even does it, first his app wasn't handling multiple requests at a time, he was using a queue to handle the requests I sent to him. I even suggested to him some of my ideas on it. He said he already had these ideas, and will be executing them. His explanations was: "Everything require certain time to do and this is a project which may need two years to complete and we are asked to finish it in two months". I used to have a hard time coding during first few weeks because of this bug. But now he fixed it. But he is using a single queue for a user requests and that is now slowing down the app, since it processes one request at a time. What is QA doing this whole time? Why aren't they reporting/confirming the status of the project(s)? The manager is the person who decides when to give to the QA. As of now it has not yet given to QA. He said we should give it by this month end.
As others have mentioned, behaving professionally is the single most important thing for your long-term career. And honestly, as long as you behave professionally, you'll be in pretty good shape, no matter how those around you behave. In this situation, there are a couple of considerations you need to take into account. First, you need to understand that you are responsible for your program working to the desired specifications, by the given deadline. If your program interoperates with someone else's program, you are also responsible for making sure that that other program also works by the same deadline. To put this differently: If the other person misses their deadline, then you have also missed your deadline, even if your own part of the project was on time. In management terms, this is called owning the inputs. You have correctly noted that when your colleague declares in a meeting that his program's bugs are fixed, that you can't immediately declare him as incorrect to the manager (your manager would see that as "throwing your co-worker under the bus"; a very bad career move). Others, on the other hand, have pointed out that it is unprofessional not to declare the true state of the project to the manager. Both sides are completely correct. So if it's bad to contradict your colleague in front of the manager, and it's also bad to not contradict him, then what do you do? The answer is actually pretty simple: You need to talk to your colleague well before the meeting with the manager, and let them know that at the upcoming meeting you're going to need to tell the manager about the troubles you've been having with their program, and that it's impacting your ability to deliver your side of the project on time, and whether there's anything you can do to help them address the troubles you've been having. You need to have this conversation at least two full days before the meeting where you will tell the manager, and preferably a full week in advance. In most cases, just telling your colleague that you're going to have to list their program as a risk at a particular meeting will get them motivated to address the problems you're having, and you never have to talk to the manager at all. In others, where the problems are more schedule-driven, the colleague will often agree with you, and the two of you can go to the manager together. I've never had a colleague who didn't either fix things up for me quickly or else agree with my concerns, when expressed this way. But if it did happen, by giving your colleague advance warning you'd still be in a better position when talking to the manager. Since you talked to your colleague and tried to work out a solution on your own, and warned them well in advance that you would need to raise the issue at this meeting, your colleague won't be surprised when they do, and the manager won't think that you're simply trying to shift the blame. Do please remember that when you express your concerns, either to the colleague or to the manager, that your concerns are about your colleague's program which is returning bad data (or whatever else it's doing); these are measurable things which can be verified and fixed. Your concerns are not about your colleague being slow or undedicated; these are not measurable things, which may or may not be true, and which are unlikely to be fixed by bringing them up in a meeting in front of the boss.
0.888889
What do you do to behaving professionally?
What is an orbital boundary surface?
Could anybody explain the following statement: "The boundary surface is a common way to represent atomic orbitals, incorporating the volume in which there is about a 90 percent probability of finding the electron at any given time. I don't understand what does the author means starting from "incorporating the volume.."
It means that the boundary surface is a closed surface or set of closed surfaces, such that there is a 90% chance that an electron is interior of the closed surface and a 10% chance that the electron is exterior of the closed surface. A better way of specifying how an orbital is represented is "equal probability boundary surface" which further specifies that each point on the surface must have any equal electron probablity density, and the surface must be a closed surface or set of closed surfaces with a 90% (or other percent) chance of containing the electron at a given time. Without the "equal probability" statement there are infinite different boundary surfaces for each orbital (infinite different ways to enclose 90% of the probability density).
0.777778
The boundary surface is a closed surface or set of closed surfaces
Moving data to shared group in already launched app
My app is already on the App Store, but now I'm creating an Apple Watch Extension which also means storing data in a Shared Group. How do I go about moving the data from where it's currently stored (Core Data &amp; UserDefaults) for the customers that have already downloaded my app, the first time they launch the new update? What's the most efficient and least resource intensive way of doing this, and only doing it for old users the first time they open the new update?
I had a similar issues, only with user defaults though. All I did was that when the app launches it looks in the shared group location first and if it fails it looks in the old location and then moves it to the new location. That means that it only has to check multiple locations the first time
1
When app launches it looks in the shared group location first and then moves it to the new location
Is lots of red juice normal when making sous-vide steak?
So I made a 1lb hanger steak via sous-vide the other day and cooked it for 45 minutes at 130F. After I seared in a cast iron pan, I took the meat off of the pan and let it sit for a few minutes and then sliced it up(against the grain) into smaller portions. I noticed a lot of red juice in the plate as I was slicing it up but after I put it on a plate and it was sitting at the table, the meat almost ended up swimming in red juice. When I order medium rare steak at a restaurant and it comes out pre-sliced, I don't usually notice this much red juice. Is this normal? UPDATE: Found this great article explaining what was going on: http://www.seriouseats.com/2009/12/how-to-have-juicy-meats-steaks-the-food-lab-the-importance-of-resting-grilling.html#continued He has another article about sous vide ( http://www.seriouseats.com/2010/03/how-to-sous-vide-steak.html ) where he claims that you don't need to let the meat rest after searing. This is the one that originally led me to not need to rest the steak. Looks like there is some resting that is required. Will post up with results next time I make some steak.
Pretty much...yes, but you can fix it!. When you properly sous vide or very slow cook anything, you'll retain more of the myoglobin color because of the even cooking that often doesn't go above 140 at all. So a properly cooked steak like this will retain much more of its red colored myoglobin. Simply put, the meat will have more red juices to release! (Its a great, great thing about sous vide.) As @Ronald mentions, the other thing is the resting of the meat. It's an important step as the muscle fibers relax after the heat is off and hold juices better then. An often misstep for the home cook is they allow a hot piece of meat to rest on a flat, solid surface. This causes the bottom of the meat to steam against the board, open the fibers in the meat more, and release the juices on to the board. Rest your meat on a raised baking rack so that it has air circulation all around it. After a short rest - for most steak 10 minutes is fine, then you can cut into the steak. Use a very sharp knife to slice. The meat here is essentially a sponge and you don't want to compress it and squeeze out the juices. A dull knife will do this and you'll lose more juice on the cutting board again. Use a sharp knife and apply steady, even, but light pressure while slicing - let the edge do the work (if it won't, sharpen the knife more).
1
When properly sous vide or very slow cook anything, you'll retain more of its red colored myoglobin color
Creating DotPlots
I've been struggling to create a DotPlot like the one shown in Cleveland's The Elements of Graphing Data. Using the following dataset data = Sort[{#, WolframAlpha[ StringJoin["Number of native speakers ", #], {{"Result", 1}, "ComputableData"}]} &amp; /@ {"Mandarin", "French", "English", "Spanish", "German", "Hindi", "Malay", "Arabic", "Portuguese", "Russian", "Korean", "Italian", "Cantonese", "Telugu", "Urdu"}, #1[[2]] &lt; #2[[2]] &amp;] What is the best approach to replicate this chart with its two axis, dot, dashed lines , etc?
It is a Chart so one may want to use BarChart: (* speakers are stored with [people] units so we have to get rid of it, I'm also deleting Malavian since there is no data now*) sorted = MapAt[QuantityMagnitude, #, {2}] &amp; /@SortBy[data, #[[2]] &amp;] // Rest len = Length[sorted] mark[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := {Black, AbsolutePointSize@7, Point[{Scaled[{0, -.02}, {xmax, ymax}]}]} topt = Table[{i, 2^i}, {i, 0, 9}]; BarChart[Log[2, sorted[[ ;; , 2]]/10^6], ChartLabels -&gt; sorted[[ ;; , 1]], BarOrigin -&gt; Left, BarSpacing -&gt; Large, GridLines -&gt; {None, Range@len}, GridLinesStyle -&gt; Dotted, ChartElementFunction -&gt; mark, Frame -&gt; {{False, True}, {True, True}}, AxesOrigin -&gt; {0, -1}, FrameTicks -&gt; {{False, False}, {Automatic, topt}}]
1
BarChart is a Chart so we have to get rid of it
Finding residue of function
I'm trying to find the residue of $$z \cos\left(\frac{1}{z}\right)$$ at $z=0$. This is how I did it: $\cos(z)=\sum_{n=0}^\infty \frac{(-1)^n}{(2n)!}z^{2n}$. $\\$ Then $\cos(\frac{1}{z})=\sum_{n=0}^\infty \frac{(-1)^n}{(2n)!}z^{2n-1}$. $\\$ Finally, $z\cos(z)=\sum_{n=0}^\infty \frac{(-1)^n}{(2n)!}z^{2n}$, which is where I started. I thought the residue would by $0$ because there are no negative powers, but it's supposed to be $-\frac{1}{2}$. Did I do something incorrectly?
The residue is the coefficient of the $z^{-1}$ term in the Laurent Series. As you probably already know: $$\cos z \equiv 1 - \frac{z^2}{2!} + \frac{z^4}{4!} - \frac{z^6}{6!} \pm \cdots $$ It follows that $$\cos\left(z^{-1}\right) \equiv 1 - \frac{z^{-2}}{2!} + \frac{z^{-4}}{4!} - \frac{z^{-6}}{6!} \pm \cdots $$ Finally, multiplying through by $z$ gives: $$z\cos\left(z^{-1}\right) \equiv z - \frac{z^{-1}}{2!} + \frac{z^{-3}}{4!} - \frac{z^{-5}}{6!} \pm \cdots $$ The coefficient of $z^{-1}$ is $-\frac{1}{2!} = -\frac{1}{2}$.
0.777778
The coefficient of the $z-1$ term in the Laurent Series
Failed to allocate memory - What is it trying to say?
In my early days of programming I often used to get memory related fatal errors in the following format: Fatal error: Allowed memory size of &lt;some big number&gt; bytes exhausted (tried to allocate &lt;some small number&gt; bytes) in /path/to/filename.php on line &lt;some line number&gt; I'm a little embarrassed to state that even though I have figured out how to solve them and take steps to avoid them altogether, I'm still not quite sure what exactly does the message translate to in simple words. For example, if I get a message such as: Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 4000 bytes) in ........ on line 34 As things stand at the moment, I assume it to be stating that the script consumes 67108864 bytes of data, but only 4000 bytes are available during runtime. Am I right in my assumption? If not, what's the correct interpretation?
Your program has 67108864 bytes (~67MB) available to it at runtime, all of which it has filled. The specific allocation which took the total memory usage from &lt;67MB to >67MB was an allocation of 4000 bytes, which happened within the expression on line 34. Basically, you're using too much memory, and all the interpreter can give you to help is the specific allocation which broke the camel's back. It could have been a one byte allocation, all that matters is that it took you over your memory limit.
0.888889
The specific allocation which took the total memory usage from &lt;67MB to >67MB
How to install Ubuntu 14.04 alongside the same existing OS in laptop?
I already have Ubuntu 14.04 installed on my laptop. But it's not working properly. I've a related thread here. I urgently require an audio/video cutter like ffmpeg, avconv etc. to be installed which isn't happening in the current system. So, the need to install a fresh one where I will install the cutter. I want to install again the same OS but where! For that please look at my existing hard disk in my laptop. See, I've Windows on sda2 &amp; sda3. But it's not working any more &amp; so I'm interested to delete sda2 &amp; install the new Ubuntu 14.04 there. But I need 3 partitions for the new installation. If I delete sda2, then can I install Ubuntu 14.04 by creating 3 partitions? I'm doubtful as already there is 1 extended &amp; 3 primary. So, if I delete one primary (sda2), then how to get the 3 partitions as logical partitions can't be made inside primary!! Another method: Just now something striked my mind. Shall I create only root (or boot even required) partition on sda2 &amp; use the other partitions (/home etc) from the existing ones?
Why would you need 3 partitions? You only need one. Either sda2 or sda3 are big enough for a normal installation. The new installation normally will overwrite your boot sector, if you don't want that make sure to deselect that option. In that case you will have to boot in the old 14.04 and run update-grub for it to find the new 14.04 and add it to the grub menu.
1
Why would you need 3 partitions?
Do you start writing GUI class first or reverse?
I want to write my first Java program, for example Phonebook, and I wonder what to do first. My question is should I write GUI classes first or util classes first? I am database developer and want to know best practice in building program.
This is a fairly straightforward project where I'd say it's not that important. On many projects though it's not going to be immediately clear exactly how you want the GUI to look and operate, and once you make it someone may ask you to change it. It's good to make quick mockups of the GUI so you or whoever is in charge can come to a concrete decision on what it should look like and then this will give help you see some of the correletive pieces of data you'll need to track that you might not have noticed had you started with the data design. More importantly, you do NOT want your data design to drive your user interface. Relatively speaking, I believe fixing poor GUI implementations is far easier than fixing poor data implementations. So I definitely vote for starting with the GUI. And I'm more of a database guy myself, just fyi.
1
Fixing poor GUI implementations is far easier than fixing poor data implementations
"Hirable" or "hireable"
What is the correct adjective form of the word hire? I have seen references to both hireable and hirable. I checked using Google's Ngram viewer book search and it appears that both have been in use since the 1800s with hirable becoming a bit more popular in the past decade or so:
This is starting to become a bit of a hoary old chestnut. Since OP has already established that both forms are and have been in widespread use for some time, what does it mean to ask "which is correct"? In this particular case, although the NGram doesn't really make it clear, hirable really is becoming increasingly common. So by one standard, that's the spelling of the future, and is therefore arguably 'more correct'. On the other hand, hireable was clearly the more prevalent form in the past - certainly in various linguistic subsets (in fact, it's still the preferred British usage, though that is changing even as I write). So arguably few people would seriously criticise anyone for using a more 'traditional' form. In short, I think this question steers dangerously close to breaching FAQ guidelines which specify that questions should preferably admit of a single clear-cut answer which most competent speakers can agree on.
1
What does it mean to ask "which is correct"?
When to use a runabout or a shuttle in a mission?
In TNG and DS9, we often see the use of shuttles and runabouts. What is the deciding factor of which one to use? How come we only see one use of a runabout in TNG? Is it only about the crew size on board? Yet shuttles have been shown to carry quite a number of people too? Is it speed?
The difference between a runabout and a shuttlecraft is a matter of size and capability. Most of the time, their duties were interchangeable so either ship could be used. With the ability to customize ships in the Federation, there are numerous designs for shuttlecraft which includes vehicles such as the Delta Flyer (VOY) or the Captain's Yacht, Cousteau (TNG). Shuttlecraft were small ships assigned to starships, used primarily in cargo transportation, short trips for species which experience transporter difficulties or anxiety, or movement through electromagnetic phenomenon which might disrupt or challenge transporter technologies. Shuttlecraft had to be fit during the TOS period with technologies to allow them to be used with warp drives. By the TNG series, shuttlecraft came standard with relatively short-hop warp capacities (some light years allowing them to be used as exploration vehicles). There were many different classes of shuttlecraft depending on the duties being carried out. Runabouts were slightly larger than shuttlecraft but smaller than starships. Runabouts were warp-capable, had personal transporters and usually had a crew of four personnel. Properly fitted, they could function as transports, scientific vehicles or medical evacuation vehicles. Runabouts were used primarily on space stations such as Deep Space Nine (DS9) as a means of travel between the Federation, Cardassian and Bajoran sectors of space. Runabout specifications included deflectors and phaser arrays. But they were not meant to sustain much damage, despite the fact they could be used in combat.
1
Runabouts were small ships assigned to starships .
Replacing the thermocouple for a multimeter?
I bought a no-name but decent multimeter, and it came with a thermocouple. Let's say I broke it in some way. Can I just replace it with any other thermocouple, or is each thermocouple calibrated for one specific model of a multimeter? I have been looking at thermocouples, eg on eBay, e.g. this one. They write some specs but they don't write which multimeter it fits with? So does any thermocouple fit with any multimeter (or digital thermometer)?
In general any thermocouple can be used with any meter that handles thermocouples as long as they are compatible. That means that a K type thermocouple must be paired with a meter that is calibrated for K type thermocouples. K type thermocouples are the most common so it is very likely that your meter can handle the one you looked at on Ebay which is a K type. However there are much cheaper K types available than that one which is specified for very high tempertures. As far as calibration goes, there are standard tables of thermocouple voltage versus temperature for each type of thermocouple. This is possible because each type of thermocouple uses the same composition of wires. Thus your multimeter would have been designed to use the table for K type thermocouples. The actual accuracy you can achieve is determined by the specified accuracy of the thermocouple and how well the meter conforms to the standard table values which are nonlinear.
0.777778
K type thermocouples are the most common so it is very likely that your meter can handle the one you looked at on Ebay which
It was a pun! from the Dead parrot sketch
In Monty Python's Dead parrot sketch when John Cleese returns to pet shop from the railway station in Bolton, he's having this dialog with Michael Palin: J.C.: I understand this is Bolton. M.P.: Yes. J.C.: But you told me it was Ipswich! M.P.: It was a pun! Then Cleese turns back and starts to look around like crazy. Why would he do that? I thought a pun was a kind of word joke.
Here is the dialogue I found. (source) In the dialogue, C refers to customer (J.C. in OP's question), O refers to the pet shop owner (M.P.), C: I understand this IS Bolton. O: (still with the fake mustache) Yes? C: You told me it was Ipswitch! O: ...It was a pun. C: (pause) A PUN?!? O: No, no...not a pun...What's that thing that spells the same backwards as forwards? C: (Long pause) A palindrome...? O: Yeah, that's it! C: It's not a palindrome! The palindrome of "Bolton" would be "Notlob"!! It don't work!! O: Well, what do you want? C: I'm not prepared to pursue my line of inquiry any longer as I think this is getting too silly! Sergeant-Major: Quite agree, quite agree, too silly, far too silly... You're right that a pun plays on the different possible meanings. But in this dialogue, it seems like M.P. (O) has a problem with his word choice, or he is trying to act so.
1
What's that thing that spells the same backwards as forwards?
Need to notify users that the form has recently been edited?
We have a list page where users see a list of data and can select one to edit. The data opens up in an editable form. Here is the scenario: User 1: Loads the list of data and selects to edit form 'ABC' User 2: Loads the list of data and hangs out for a bit User 1: Updates form 'ABC' to be 'CDE' and submits their update User 2: Clicks to edit form 'ABC' as it was displayed on the list - but the form is now 'CDE' and opens as such. The question is should I let the user know that the form they are about to edit was recently changed? Is this more confusing than it is helpful? Will expecting to load 'ABC' and actually loading 'CDE' confuse the user? What happens if it wasn't a re-name of the form but a deletion of the form? Then what should load?
(ring, ring) "Hi Liz" "Oh, hey Emma" "Listen, I'm at the pub on Kingsland Road, but I can't find you or anyone else" "Oh... sorry Emma, forgot to tell you, the party has moved to the other side of town" How things should really work There's a famous concept in programming called MVC, which stands for Model-View-Controller. The controller is irrelevant now, so I'll omit it, only discussing model and views: There's always one model which represents the data or what needs to be persisted (stored). Then there are views - what the user see. Sometimes a user sees two views of the same data (think of a list of bars next to pins on a map), sometimes many users see each a view of the same model. We assume that a user can edit the view, and the role of the MVC framework is ensure that once 1 view is updated all other views update as well. With websites, there are quite a lot of layers between the model (which is stored and served by the server) and the view (which the user sees on their client browser), so it took us quite a few decades that get this update mechanism working on the web. Early internet technology was based on the pull model - users had to perform an action, which would send a request to the server that holds the data and the server would respond with the data. So to get updates, users had to press or do something. Nowadays, the need for a push model (the server pushes data the the clients, without them asking for it) is in high demand, and modern web technologies accommodate such need. One example is you may be looking at a question on this site, and suddenly get a notification that someone left a comment to one of your answers to another question - the notification just shows, even if you were just looking. My point is, that with correct implementation using modern technology, whenever item X has changed, anyone watching it should be notified. One common problem in UX is that people got so used to dated technology that they take bad usability and how things work (or how things don't work) as a norm. Should you show it to the users. I honestly can't think of a single argument why not. The most obvious reason to show it to users is that status of the system should be obvious to users. If something changes, and it doesn't reflect on the screen somehow, than the system status is no longer communicated to the user correctly. Just consider someone spending 10 minutes to edit a form, only to get a message it was already deleted by the time they finish. It's a bit like the following phone conversation at the top of this post. To summarise - you should always let the user know that the version they are looking at is no longer up-to-date. How you handle the various scenario (edited or deleted, for example) has to do with the business logic and the system in question. To give one example, it happens sometimes that whilst you answer a question on this site, the original or the moderators delete it. Immediately you get a notification saying "This post has been delete, no answers will be accepted" and the "Answer" button becomes disabled. As no one has an idea what you'd like to do next, they keep you on the screen, but you can't do much on it other than going elsewhere. Not all systems work that way. In many systems deleting an entity doesn't actually deletes it - it simply marks it as deleted and doesn't show anywhere; this open doors to alternative handling option.
0.888889
How to show the status of the system to users
Is there an "Appending \let"?
After \def\MyText{\textbf{My Text}} \let\MySaved\MyText \MySaved and \MyText have the same \meaning. What I would like to have further down in the document is % \MyText = \textbf{My Text} \def\MyText{\textit{More Text}} \let\MySaved{\MySaved \MyText} % \MySaved = \textbf{My Text} \textit{More Text} but obviously \let does not allow a group of tokens in the second argument. Is there any way to append like this with the same specific (non-)expansion properties \let has?
\def with \expandafter help: \expandafter\def\expandafter\MySaved\expandafter{\MySaved \MyText} If you are using LaTeX (\textbf, \textit, ...), then \g@addto@macro can be used: \makeatletter \g@addto@macro\MySaved{\MyText} \makeatother Or if you need complete expansion: \edef\MySaved{\MySaved \MyText} But that might break fragile stuff, thus LaTeX provides \protected@edef: \makeatletter \protected@edef\MySaved{\MySaved \MyText} \makeatother Or if \Mysaved and \MyText should be expanded once exactly, e-TeX's \unexpanded helps: \edef\MySaved{% \unexpanded\expandafter{\MySaved}% \unexpanded\expandafter{\MyText}% } The same can be achieved by token registers in vanilla TeX: \toks0\expandafter{\MySaved} \toks2\expandafter{\MyText} \edef\MySaved{\the\toks0 \the\toks2}
1
protected@edefMySavedMyText makeatother