I'm designing my first drupal theme and I'm not very well experienced in this kind of stuffs. I tried to add some jQuery to my design so I saved this code into a .js file and add it to my theme.info file:  $(document).ready( function() {     $("button").click(function() {         $("button").hide();     }; };   It should work properly but it didn't. After some searching, find out for avoiding conflicts I should use drupal's function instead of $(document).ready so I did:  (function ($) {             $("button").click(function(){                 $("button").hide();     }); })(jQuery);   but it doesn't work out. And again, by googling I find out something named behaviors. Actually I can't understand what is it but after using examples as a pattern an overwriting my code into it, my issue fixed:  (function ($) {     Drupal.behaviors.exampleModule = {         attach: function (context, settings) {             $("button").click(function(){                 $("#navigation").hide();     });         }     } })(jQuery);   So my question is: What is drupal behaviors?  I read some articles about it but couldn't understand it well.  Also some examples will appreciated.
I read about Drupal behaviors today, and I tried writing the following code.  (function ($) {    Drupal.behaviors.mymodule = {     attach: function (context, settings) {       $('#mymodule_id', context).change(function () {         alert('Handler for .change() called.');       });     }   };  }(jQuery));    Is Drupal.behaviors.mymodule the namespace? What are the context and settings parameters passed to the Drupal behavior? Is this the equivalent of document.ready()?   Can I attach any number of functions?  Can I define JavaScript functions which will be called somewhere?
Show that $\frac 1{1+x+y^{-1}}+\frac1{1+y+z^{-1}}+\frac1{1+z+x^{-1}}=1$ if $xyz=1$ "Always on Top" Windows with Java In Java, is there a way to have a window that is "Always on top" regardless if the user switches focus to another application?  I've searched the web, and all of the solutions lean to some sort of JNI interface with native bindings.  Truly this can't be the only way to do it?.. or is it? Show that the LU decomposition of matrices of the form $\left[\begin{smallmatrix}0& x\\0 & y\end{smallmatrix}\right]$ is not unique How can I show that every matrix of the form $\begin{bmatrix}0&amp; x\\0 &amp; y\end{bmatrix}$ has an $LU$ factorization and that even if $L$ is unit lower triangular there is not a unique factorization?  I am completely stuck. Any ideas would be greatly appreciated A movie about artificial intelligence gone rogue I'm trying to continue the numbering of examples in enumerate environments in beamer. For example, I'd like one slide to feature   Foo Bar   and the next slide   Zip Yadda   My strategy so far has been to define a counter that saves the enumerate counter at the end of the first environment and can then be queried to set the enumerate counter at the start of the second enumerate environment. (This is essentially the proposal also found at )  That works wonderfully so long as I don't try to uncover elements of the slide sequentially. The problem, of course, is that as each of the pdf-pages that make up the slide is created, the counter is advanced. Here's a MWE.  \documentclass{beamer}  \setbeamercovered{highly dynamic}  \newcounter{saveenumi} \newcommand{\seti}{\setcounter{saveenumi}{\value{enumi}}} \newcommand{\conti}{\setcounter{enumi}{\value{saveenumi}}}   \begin{document}  \begin{frame}[&lt;+-&gt;]   \begin{enumerate}   \item foo   \item bar%     \seti   \end{enumerate} \end{frame}  \begin{frame}[&lt;+-&gt;]   \begin{enumerate}     \conti   \item zip   \item yadda%     \seti   \end{enumerate} \end{frame}  \end{document}   As the second slide is progressively uncovered (pages 3 and 4 of the resulting PDF), the counter at the beginning of the enumerate environment is advanced each time. So page 3 of the PDF has the right numbering, (3) and (4) respectively, while the fully revealed page has the wrong numbering. Pictures follow:   on one of the slides    on the following one In Thor: The Dark World, Odin and Loki are discussing Loki's actions during The Avengers.  Loki argues that he would have ruled Earth as &quot;a benevolent god&quot;, and Odin replies:  Odin: We are not gods! We are born, we live, we die, just as humans do.  Now that's pretty definitive.  And Loki's snarky reply (&quot;Give or take five thousand years...&quot;) would seem to confirm that Asgardians have a limited lifespan, and will eventually die of old age.1  And we know that Asgardians can die in battle, because we've seen it happen over and over with supporting characters and Asgardian soldiers. Now, I've always been more of a fan of Thor stories (like Jason Aaron's Thor: God of Thunder arc) in which Thor and the Asgardians are gods.  Straight-up, genuine, higher-level-of-existence gods, not von-Däniken-esque wannabes playing on the tired old notion of magic just being super-advanced science.  BUT, despite my preferences, this exchange would seem to confirm once and for all that in the MCU, the Asgardians are not gods, but rather were mistaken for gods because of their ram-horns full of awesome-sauce and their magnificent bulging pecks. But wait!  Watch that movie for about 30 seconds longer and we come across this exchange:  Thor: She is ill. Odin: She is mortal. Illness is their defining trait.  Wait, what?  I thought Asgardians weren't immortal?  They can die in battle, and they naturally die of old age.  In my book, that makes them long-lived, but entirely &quot;mortal&quot;.  Surely Odin isn't splitting a hair so fine as to say that resistance to disease alone makes one &quot;immortal&quot;? So, if the Asgardians of the MCU aren't actually gods (grumblegrumblegrumble...), and they can't live forever (or even particularly long in a cosmic sense), and they can be killed in battle, in what sense are they &quot;immortal&quot; at all?  1 Fun fact: adjusted for a roughly 5,000 year lifespan, 1,048-year-old Loki is currently in the tail-end of his rebellious teenage phase. I have a database with millions of phone numbers with free-for-all formatting. Ie, the UI does not enforce any constraints and the users are typing in whatever they want.  What I'm looking for is a Java API that can make a best-effort to convert these into a consistent format. Ideally, the API would take the free text value and a country code and produce a valid international phone number or throw an exception.  For example, a phone number in the system might look like any of the following:  (555) 478-1123 555-478-1123     555.478.1123 5554781123   Given the country of US, the API would produce the value "+1 (555) 478-1123" for all these. The exact format does not matter, as long as it's consistent.  There are also numbers in the system without area codes, such as "478-1123". In that case, I would expect a NoAreaCodeException, or something similar.  There could also be data such as "abc", which should also throw exceptions.  Of course, there are countless variations of the examples I have posted, as well as the enormous complication of international phone numbers, which have quite complicated validation rules. This is why I would not consider rolling my own.  Has anyone seen such an API? Is there a gender-neutral word for "aunts and uncles"/"parents' siblings"? Something very odd is happening here.   I have a query that looks like this.  SELECT CAST(FT.DOP AS SMALLINT) FROM TRACKING_DATA WHERE date &gt; @mydate and identifier = 0000000000   When run as a raw query it returns data just fine.  When i place it in a stored procedure that alters the where clause it throws this error.  Msg 244, Level 16, State 2, Procedure myprocedure, Line 107 [Batch Start Line 2] The conversion of the varchar value '58629' overflowed an INT2 column. Use a larger integer column.   So here is the oddity. I go through all the possible data for that where clause with a query like this.  SELECT DISTINCT DOP FROM TRACKING_DATA where identifier = 000000000000   and  SELECT DISTINCT CAST(DOP AS smallint) FROM TRACKING_DATA where identifier = 000000000000   And this is what i get back.  17 12 9 19 8 14 6 16 11 13 7 10 0 18 5 15 4   Nowhere does it have anything remotely too large for a SMALLINT. So i thought, ok maybe its a non-printable ASCII character. But i can't find any.  I'm a little perplexed at the moment. It runs find as a raw query, explodes as a procedure and all possible data based on the where is valid. My only suspicion is that the query plan is doing something odd with filtering or maybe runs with different validation when run as a procedure. Create model from XYZ data points I'm trying to create a 3D heat map model out of data that I have from a csv file. I have a few thousand data points with XYZ coordinates.  I'm able to import the data into blender as a point cloud with , however I would like to create a model with solid faces. Is there a way when importing the data to somehow join the points to create faces instead of generating thousands of separate points?  Currently, this what I have in terms of point cloud  The end product would look something like this (minus the texture) and obviously the model wouldn't be as regular as this one  Any help is greatly appreciated! How to check if a row exists in MySQL? (i.e. check if an email exists in MySQL) I would appreciate if someone could help me write the mathematical equation for the seasonal ARIMA (2,1,0) x (0,2,2) period 12. I'm a little confused with how to go about this. I would prefer an equation involving $Y_t , e_t, θ$ and $Θ$. Help with packages in java - import does not work I'm a C++ developer - not a java developer, but have to get this code working...  I have 2 public classes that will be used by another product.  I used the package directive in each of the java files.    package com.company.thing;  class MyClass ...   When I try to compile a test app that uses that I add   import com.company.thing.*;   The javac compiler fails with errors about com.company does not exist.  (even if I compile it in the same directory as the class files I just made a package of)  I am sure I am doing something bone-headed and silly.  I've read the  pages and tried to set up a directory structure like /com/company/thing  etc, but either I have totally screwed it all up or am missing something else.  EDIT thanks for the suggestions - I had tried the classpath previously.  It does not help.  I tried compiling   javac -classpath &lt;parent&gt; client.java    and the result is:  package com.company does not exist   I have the code I want to import (the two java files) in \com\company\product.  I compile those fine.  (they contain MyClass) I even made a jar file for them.  I copied the jar file up to the parent directory.  I then did (in the parent directory with the client java file)   javac -cp &lt;jarfile&gt; *.java   the result is:  cannot access MyClass bad class file: MyClass.class(:MyClass.class) class file contains wrong class: com.company.product.MyClass Please remove or make sure it appears in the correct subdirectory of the classpath.   EDIT  I got the client code to compile and run if I used the fully qualified name for MyClass and compiled it in the parent directory.  I am totally confused now.    compiled with no classpath set - just   javac *.java    in the parent directory - and it worked fine.  I can get a test app to compile, but that is not going to cut it when i have to integrate it into the production code.  Still looking for help.  EDIT:  Finally - not sure why it didn't work before - but I cleaned up all the files all over the directory structure and now it works.    Thanks Why can't I import a SVG file from Adobe Illustrator or Inkscape? See my edit below, this is not totally a duplicate of   My reverse-search function in the CLI is broken and I don't know how to fix it back...  When I hit ctrl+r and search a command I did earlier, find it then press the right arrow key to use it, the output is broken. Here is an example:  # I reverse-searched the word "test" then pressed right arrow yoshiji@x1carbon:~/path/to/git/folder (master) $ch)`test': rake test #                                              ^^^^^^^^^^ weird output #                                                     ^ cursor right there   It also "shifts" my cursor to a different position. If I press enter, the right command is executed (rake test in this case) so it means the text displayed is not the same as what is actually executed.  I know this is most-likely related to my PS1 export in my ~/.bashrc, so here are the last lines of this file:  # Git branch in prompt. git_branch() {   branch=$(__git_ps1 2&gt; /dev/null)   if [ "$branch" = " (master)" ]; then      echo -e "\033[33m${branch}\033[00m" # yellow   elif [ "$branch" = "" ]; then      echo -e "\033[90m (no git)\033[00m" # red   else      echo -e "\033[32m${branch}\033[00m" # green   fi } PS1='\u@\h:\w$(git_branch) \$ '   This is something I wrote to displays the git branch in orange (if master branch) or else in green (or no git in gray).  Do you guys have any idea on what is causing this weird behavior?    Edit: This is a different problem from the  in the way that I am using echo -e "some string" to return a string having color+name of the git branch from the function git_branch(). Using echo -e does not escape the characters \[ and \] (try it yourself in your CLI: echo -e "\[\033[33m\]test").  Ideally, I would like to keep those conditional colors based on the branch's presence &amp; name (gray if no branch, orange if master, else green). Insert missing dates within table I have a table with a column for ID, Date and Frequency of occurrence for that particular date and ID.  ID    date          Frequency 1     2014-05-18      5 1     2014-05-19      4 1     2014-05-20      25 2     2014-05-20      7 3     2014-05-18      4 3     2014-05-20      1 4     2014-05-18      6   I'm looking to insert the dates for each ID that aren't currently there (assuming that the date ranges from 2014-05-18 to 2014-05-20) and add a value of 0 in Frequency for those.  For example, you can see that  ID 1 has an observation for all three dates;  ID 2 is missing 2014-05-18 and 2014-05-19;   ID 3 is missing 2014-05-19;   ID 4 is missing 2014-05-19 and 2014-05-20.  Therefore, the output should look like this  ID    date          Frequency 1     2014-05-18      5 1     2014-05-19      4 1     2014-05-20      25 2     2014-05-18      0 2     2014-05-19      0 2     2014-05-20      7 3     2014-05-18      4 3     2014-05-19      0 3     2014-05-20      1 4     2014-05-18      6 4     2014-05-19      0 4     2014-05-20      0   I've attempted the following from . However, that will only add dates with 0 Frequency that aren't present throughout the entire table instead of on an ID level.   DECLARE @s DATE = '20140518', @e DATE = '20140520';  SELECT c.date, Frequency = COALESCE(a.Frequency,0) FROM dbo.Calendar AS c LEFT OUTER JOIN dbo.table AS a ON c.date = s.[date] WHERE c.d &gt;= @s AND c.d &lt; DATEADD(DAY, 1, @e); I noticed that if I run ls -F on a directory, some of the entries have a * or a @ after them.   spuder@ubuntu:~$ ls -F /sbin acpi_available*   getpcaps*           lvmconf*                 ntfscp*        start-stop-daemon* agetty*           getty*              lvmdiskscan@             ntfslabel*     status@ alsa*             halt@               lvmdump*                 ntfsresize*    stop@ alsactl*          hdparm*             lvmsadc@      spuder@ubuntu:~$ ls -F ~ daq-0.6.1/  examples.desktop       noname-cache.lib  snort-2.9.1/   Templates/ Desktop/    jpgraph-1.27.1/        noname.sch        snortfiles/    Ubuntu One/ Documents/     According to the ls man pages   spuder@ubuntu:~$ man ls ... -F, --classify   append indicator (one of */=&gt;@|) to entries ...   I'm guessing that @ means symbolic link,     What do these other indicators mean ( */=&gt;@| )  ? Starting with the episode "Crossroads Part II" the      final five Cylons begin to hear Bob Dylan's "All Along the Watchtower" in their heads.   Have the creators/writers ever stated why they picked that song in particular and what it might mean to the story? Asking feedback/rating for a mobile app? Fig.1: A typical prompt, asking user for feedback/rating in iOS Background Any serious smartphone users must have seen a message similar to Fig.1 above at least once. Variations of such prompt include: &quot;Please give us 5 star ratings if you love this app!&quot;, &quot;Rate us :)&quot;, &quot;Your rating helps improve this app!&quot;, etc. Basically, Fig.1 asks user to leave a (nice) feedback/rating for the app on its AppStore(or equivalents).  The Shorter Question  When and how often should a mobile app user be asked to leave a feedback/ratings?   The Longer Question #1. Which User-statistics? What are the significant user's behavioral statistics that should be based on to generate Fig.1? For example:  Number of runs since install/reinstall of the application Time elapsed since current application run Time elapsed since first application run Time elapsed since first application install Certain events (e.g. after certain number of stages are cleared for a game app)  #2. When to Ask? If multiple user-statistics are chosen to be calculated to generate Fig.1, specifically how should the user-statistics satisfy the condition of the event? For example:  Form a unified equation (e.g. X^2+Y^2=Z^2) with all significant user-statistics partaken fairly to trigger the event. Create (multiple of) &quot;absolute&quot; event triggers (e.g. every 10th app run; elapsing 2 hours since current application run). Both of the two. Generate Fig.1 whichever comes true first. Neither of the two. &quot;There's a better way!&quot;  #3. How often? What would be the optimal min/max frequency of Fig.1 generation? By optimal, I mean users are not to be bothered too much, yet developers gain maximum output of great feedbacks from users? #4. &quot;Don't bother me again :(&quot; Should users have an option to opt-out from receiving Fig.1 at all? #5. Universal User-statistics for All Mobile Apps? Should apps under different categories be based on different user-statistics? There are significant differences in size and type of user-statistics in apps under different categories. For example, a &quot;Flashlight&quot; app is not typically run for one hour straight, while a music/movie streaming app may be run for over one hour. #6. &quot;This app does not need more feedback.&quot; Should every app of all kinds of user base ask this message? If any, should any mobile app stop generating Fig.1 when target conditions are met (e.g. downloads count, active user count, feedback count)? #7. Feedback/Rating Before Deletion Should users be asked to leave a feedback before deleting as seen in Fig.2 below? Users are more likely to leave very critical review on app deletion, but this kind of feedback will be very helpful for the developers to strengthen their app's weakness for next version release.                                                                                                 Fig.2: Asking user for rating before app deletion My internet connection is very slow. I suspect someone in the network is using a BitTorrent client which takes huge amount of bandwidth.  Is there a way to detect who is using my bandwidth (network sniffing tools etc)?  I should have pointed out that I have no access to the router, what I am looking for is a way of detecting someone's MAC/IP if she uses Bittorrent.