Disable Cell Highlighting in a datagridview

Question: How to disable Cell Highlighting in a datagridview,
Highlighting should not happen even if I click on the cell.
Any thoughts please
Answer: The ForeColor/BackColor kludge wasn't working for me, because I had cells of different colors.  So for anyone in the same spot, I found a solution more akin to actually disabling the ability.
Set the SelectionChanged event to call a method that runs ClearSelection
private void datagridview_SelectionChanged(object sender, EventArgs e)
{
    this.datagridview.ClearSelection();
}

Comment: The question is [tag:vb.net]
Comment: Tiny modifications needed for vb.net but this works well. Thank you. I don't understand why there is not a simple property to turn on or off on the control.
Comment: I would expect that "ClearSelection()" fires the "SelectionChanged" - event again. ..... but it doesn't. Strange.
Answer: The only way I've found to "disable" highlighting is to set the SelectionBackColor and the SelectionForeColor in the DefaultCellStyle to the same as the BackColor and ForeColor, respectively.  You could probably do this programmatically on the form's Load event, but I've also done it in the designer.
Something like this:
Me.DataGridView1.DefaultCellStyle.SelectionBackColor = Me.DataGridView1.DefaultCellStyle.BackColor
Me.DataGridView1.DefaultCellStyle.SelectionForeColor = Me.DataGridView1.DefaultCellStyle.ForeColor

Comment: This doesn't work if some cells are in different colors then default backcolor.
Comment: If you loop through the rows, setting the colors, you can also set the selection-colors in the same loop. Then it works just fine. More generally, you can set the selection-colors any time you set the normal colors.
Comment: I really don't like that I have to use this, but it works well :)
Answer: Did a quick websearch to find out how to make a datagridview selection non-selectable & got this (web page) hit.
Calling ClearSelection on SelectionChanged can and does cause a double firing of the SelectionChanged event, at minimum.
The first event is when the cell/row is selected and, of course, the SelectionChanged event is fired.
The second firing is when ClearSelection is called as it causes (and logically so!) the selection of the datagridview to (again) changed (to no selection), thus firing SelectionChanged.
If you have more code than simply ClearSelection going on, as such I do, you'll want to suppress this event until after your code is done. Here's an example:
 private void dgvMyControl_SelectionChanged(object sender, EventArgs e)
{
  //suppresss the SelectionChanged event
  this.dgvMyControl.SelectionChanged -= dgvMyControl_SelectionChanged;

  //grab the selectedIndex, if needed, for use in your custom code
  // do your custom code here

  // finally, clear the selection & resume (reenable) the SelectionChanged event
  this.dgvMyControl.ClearSelection();
  this.dgvMyControl.SelectionChanged += dgvMyControl_SelectionChanged;
}

Answer: in vb speak:
Private Sub datagridview1_SelectionChanged(sender As Object, e As EventArgs) Handles datagridview1.SelectionChanged
        datagridview1.ClearSelection()
End Sub

Answer: The quickest way to do this to handle cells with different colours, without needing to refire any events, would be to do something like this:

private void dgvMyControl_SelectionChanged(object sender, EventArgs e)
{
    dgvMyControl.SelectedCells(0).Style.DefaultCellStyle.SelectionBackColor = dgvMyControl.SelectedCells(0).Style.DefaultCellStyle.BackColor

}

You will need to put in an iterator if you allow multiple selections

(EDIT)
actually, this needs to be done at time for data population. it doesn't appear to work in the on selection changed method. So after populating the data into the table, you need to iterate through the cells and change their selected background to match their normal background. Something like this (syntax may be a little off, I'm converting it from my vb code):
foreach (datarow r in dgv.rows)
{
  foreach (datacell c in r.cells)
  {
     c.Style.SelectionBackColor = c.Style.BackColor
  }
}

Answer: Messing around and this also works, as i only want to change the cell background colour in the 2nd column when a cell is clicked:
        Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick

    Dim row As Integer = DataGridView1.CurrentCellAddress.Y
    Dim column As Integer = DataGridView1.CurrentCellAddress.X

    If column = 1 Then
        Me.DataGridView1.CurrentCell.Selected = False
        DataGridView1.Item(column, row).Style.BackColor = SelectColour()
    End If

End Sub

Answer: Private Sub DataGridView1_SelectionChanged(sender As Object, e As System.EventArgs) Handles DataGridView1.SelectionChanged
    Me.DataGridView1.ClearSelection()
End Sub

That's it.
But if you still want to get clicked row/cell index or to access values:
Private Sub DataGridView1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseDown
    Dim _ht As DataGridView.HitTestInfo = Me.DataGridView1.HitTest(e.X, e.Y)
    If _ht.Type = DataGridViewHitTestType.Cell Then
        Me.DataGridView1.Rows(_ht.RowIndex).Cells(_ht.ColumnIndex).Value = _
        "RowIndex = " & _ht.RowIndex & ", " & "ColumnIndex = " & _ht.ColumnIndex
    End If
End Sub

Answer: Private Sub DGW2_DataBindingComplete(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewBindingCompleteEventArgs) Handles DGW2.DataBindingComplete
    Dim mygrid As DataGridView
    mygrid = CType(sender, DataGridView)
    mygrid.ClearSelection()
End Sub

Answer:
The answers I saw so far didn't give me exactly what I was looking for, but they showed me the right direction. In my case, after binding to a data source, the DGV selected and highlighted one cell, which I didn't want.
I wanted to highlight only if the user selected the complete row.
After a while I found the following solution, which is working fine for me:
private void datagridview_SelectionChanged(object sender, EventArgs e)
{
    var dgv = (DataGridView)sender;
    if (dgv.SelectedCells.Count == 1)
    {   // hide selection for the single cell
        dgv.DefaultCellStyle.SelectionBackColor = dgv.DefaultCellStyle.BackColor;
        dgv.DefaultCellStyle.SelectionForeColor = dgv.DefaultCellStyle.ForeColor;
    }
    else
    {   // show the selected cells
        dgv.DefaultCellStyle.SelectionBackColor = dgv.RowsDefaultCellStyle.SelectionBackColor;
        dgv.DefaultCellStyle.SelectionForeColor = dgv.RowsDefaultCellStyle.SelectionForeColor;
    };
}

Note: In my example, I have set the properties

MultiSelect = false, ReadOnly = true

because I am using the DGV just to display search results.
Answer: <DataGrid ItemsSource="{Binding Credits}" x:Name="Grid"
                          HorizontalAlignment="Left" RowBackground="Transparent">


Need a Linux command that takes much time

Question: Don't ask why, but I would like to know a linux command, besides la -laR, since that could not take that long according to where you are in the folder structure, that takes much time to complete.
Comment: @David: Didn't he tell you not to ask why? :P
Comment: It actually depends on your requirements... do you need this command to be doing something non-trivial while it's running? For instance, are you looking for something that will access the hard drive for a certain amount of time? Or rearrange values in RAM, or transmit continuous network traffic for that time? Or do you just want something that will not return for a certain amount of time? (That's `sleep`) And what exactly do you mean by "much time"? Some specific amount of time, or indeterminate-but-longer-than-X-seconds, or what?
Comment: Yes, and I wasn't asking why he needs it, I was asking what exactly he needs. There's a difference.
Comment: `sleep` was giving me strange results for some reason. Another option that I imagined up uses `ping`. e.g. `ping -c10 126.96.36.199`
Answer: sleep takes up however much time you pass to it.
Answer: dd if=/dev/zero of=/dev/null will run until your computer runs out of zeroes. :D
You can also make dd run for a finite amount of time, if you specify count or specify different values for if and/or of.
Or, if you want to do something useful, try badblocks -nvs /dev/sda, which will run a nondestructive read/write test on your first hard disk.
Comment: Careful, if you do run out of 0s write speed will slow down, as your HDD tries desperately to find an area with the right 0 configuration. It's easily fixable, though, just use another PC to connect and overwrite /dev/zero with their /dev/zero.
Comment: @Phoshi: good point; I think that's what sysadmins refer to as "zero installation" or "zero maintenance."
Comment: I've found that /dev/zero compresses beautifully, though.
Answer: You could also simply repeat a command forever.  For instance:
 $ while true ; do date ; done

Answer: updatedb this updates the locate database, so this is actually useful to run.
Answer: In Bash, the Korn shell and Z shell, you can use the SECONDS special variable if you want to delay for a certain time and avoid using an external tool such as sleep for some reason.
seconds=$SECONDS; while (( $SECONDS < seconds + 10 )); do :; done

or
SECONDS=0; while (( $SECONDS < 10 )); do :; done

The colon (:) is a no-op.
Comment: That's a hard way of doing 'sleep 10'?
Comment: Yes, as I thought I indicated.
Answer: well find can run for a long time especially if you want to do specific task. Here is one command:

find / -size 15c

This will seach for files that have exactly 15 characters (in file that is) and it will scan whole HDD for it. This can be slow but if you use state of art computer then you can use other commands that can run endlessly. We can use find command in a loop:

while true; do find / -size 15c; done

The bad side of this command is that you are using HDD for this and if you run it often it may shorten your HDD life (im not very much HW educated so search on google for more details).
My personal choice for this task would be creating a series of random characters (95 in his case) and print them using infinte loop with this command:

while true; do echo head -c 95 /dev/urandom | tr -dc A-Z-0-9-a-z; done

If you have slow pc then use sleep command to delay the output for 1s (in this case) and save up some cpu power:

while true; do echo head -c 95 /dev/urandom | tr -dc A-Z-0-9-a-z && sleep 1; done


Does the color of the refractive medium affect its index of refraction?

Question: Does the color of the refractive medium affect its index of refraction? I want to determine the refractive index of different colors of jello. By keeping as many controlled variables as possible (brand, concentration, volume) and by using a monochromatic light (like a Green or red laser) to measure the angles of incidence and refraction, am I expected to get different results for refractive index, depending only on the color of the medium?
Comment: The dye used to color the gelatin may well have some (likely small) effect on either the density of the gelatin or more directly on the index of refraction. I'd bet more on the first than the second, but have fun!
Answer: Rule One: Have Fun. Now, on to the optics.
The refractive index is a bulk property of the material which means you cannot affect it with tiny amounts of things like food colorants. You can affect it with bulk constituents, like by adding sugar to water; in fact there is a handy little gizmo called a refractometer which is used by winemakers to tell how much sugar there is in a sample of grape juice, by measuring its refractive index against a scale that you can read by looking into an eyepiece on the end of the thingie. It would be a good idea to get you a pocket refractometer, with which to take measurements and impress your friends at parties.
Anyway, the bulk constituents of the jell-o that will determine its refractive index are water, sugar, and the gelling compound (which is probably pectin).
There will be wavelengths of light which get absorbed by the colorants in the jell-o at the same time they are being refracted by the water/sugar/pectin mix. To make the jell-o look reddish, green and blue have to be absorbed, and this means that the spectrum produced by a prism made of colored jell-o will contain noticeable gaps.
Which brings us to another way to have big fun with colored jell-o: Note that to tint the jell-o different shades of color, you add a mixture of colorants that absorb different wavelengths of light, and then you adjust their proportions until you get the right shade. If your jell-o contains a mix of colorants, then there will be several gaps in the spectrum, and the overall "dimness" of the gap is proportional to the amount of that particular colorant in the jell-o.
And guess what! There is another gizmo called a spectrometer which, like the refractometer, has an eyepiece through which you look to see the whole spectrum of light entering the thingie. These are easy to build (DIY tutorials & inexpensive kits are available on-line) and some of these can be used with a cell phone app to prepare actual charts of the spectra.
So... Now go have fun!


What is the point of stars in Mario Kart 8?

Question: Not that stars that you get at the end of the races. But you can get up to 6 stars (I believe) and they show up in the upper left portion of the screen. What do those do?
Comment: That's 'favoriting', and you can favorite a course by pressing the `+` button on the gamepad.
Answer: They are used to mark 'favorites' in MKTV. If you completed a race that was particularly eventful that you want to save for later, mark it as a favorite by starring it at the end of the race. It makes it a lot easier to find the ones you want to keep, rather than going through all your recent races.
You can keep up to 6 favorite races at a time, and can edit or remove these favorites in MKTV.


How much UV light should I block when shading my greenhouse?

Question: I have a home greenhouse attached to our home. I was thinking about removing the existing shade cloth and replacing it with sunblock film on the upper glass panels. I grow a variety of foliage plants and it is partially shaded by trees as well. Most of these products block 99 percent of the UV light. Does this matter and what percent sun block should it get? I now have about 40 per cent blocked plus the trees. I live in the Atlanta, Georgia area.
Answer: Your plants need the UV light, so blocking 99% of it will be too much. You should stay at around 50-60%.
Answer: Where I used to work, we raised mostly bedding plants in a nursery about 50 miles north of Atlanta, Georgia (putting us a little north of the 34th parallel). We covered our greenhouse with shade cloth at the spring equinox and removed it at the autumn equinox. I don't have a record of how much light we blocked, but it was probably about 40%.


Phaser login/signup form

Question: I am developing a game in phaser but I am newbie yet. I want to create a login/signup/fb form in the main screen of the game. I did a html form in the index.html of phaser, but I have some doubts. How could I achieve the communication between the html and the scenes of phaser? I created global variables, but I think that is not a good practice.
Are there any options to use a state from html like MyGame.MainPage.startGame()?
This is the js script of the index, the function is associated to login button:
<code>function login(){
    user = check_user_in_db();
    if(user){   //If the login is correct
        variable.startGame();
    }
}
</code>
This is the MainPage scene of Phaser:
<code>/*********************NAMESPACE********************/
var MyGame = MyGame || {};
/**************************************************/

/******************INIT APP SCENE******************/
MyGame.MainPage = function(game)
{
    variable = this;
};

MyGame.MainPage.prototype =
{
    init: function()
    {

    }, // init

    preload: function()
    {
       //load Sprites
    }, //preload

    create: function()
    {
       //create Buttons
    }, // create

    shutdown: function()
    {

    }, // shutdown

    startGame: function(){
        this.state.start("Menu", true, false);
    }
};
</code>
Answer: You can try this Phaser plugin
https://github.com/orange-games/phaser-input
Comment: Thanks!! Yes, finally I did it with it

Phaser login/signup form


How did we beat the light?

Question: We observe that the universe is 13.8 billion years old, give or take a little.  We can say this because we observe and measure the fact that distant galaxies and the CMB are that far away from us, therefore we're seeing that far into the past.  But since only light can travel at lightspeed, how did WE get here (wherever "here" is) before the light from those distant galaxies, or from the CMB?  This has always puzzled me.
Comment: We were already here, we didn't have to come from somewhere else.
Comment: You should have a look at "inflation" and the expanding universe.
Comment: I suspect that you should read https://physics.stackexchange.com/q/136860/123208
Comment: _the CMB are that far away from us_ **Incorrect**. CMB is everywhere - relictic photons has filled ALL universe, including our location and others. Simply because BigBang energy with a cooling universe was spread as photons, which we have now as CMB. Why didn't you wonder that any explosion shock waves  scatters all particles and debris around explosion scene/volume ? Same phenomena here. BigBang is explosion, which dragged energy /  photons / mass (now galaxies) with it.
Answer: This like this, there was a small balloon, there is no galaxy on the balloon now it have free dense particles moving around. Then the balloon suddenly expands and the particles become diluted. Now that the balloon is big and the particles are diluted the galaxies start to form. On this big balloon two galaxies are formed which are far from each other. Once they are formed, light starts to leave the first galaxy to move toward the second one. The light gets to the second one after many many years because the balloon is big.
So the answer to your question "how did WE get here? " I should say that we were formed here and the other galaxy was formed over there. we were always here.
Answer: Actually, in modern cosmology we calculate the age of the Universe, using Einstein's General Theory of Relativity, by assuming a suitable metric and computing the age of that model Universe. Thus, the age that you compute depends on the metric that you choose. Now, professional cosmologists have done the hard work to arrive at the number $13.787_{0.020}^{0.020}$~Gyr, by using the currently accepted $\lambda$-cold-dark-matter concordance cosmology model. This is an expanding universe - hence the cosmological cosntant $\lambda$ - with luminous (baryonic) matter and dark matter.
As explained here, computing the age of the model Universe depends on various parameters, the most important for this purpose are the three fractional contributions of various forms of energy to the current energy density of the universe, $\Omega_m$ for matter, $\Omega_r$ for radiation, and $\Omega_\lambda$ for the cosmological constant (which causes the expansion of space in the model), and the Hubble parameter $H$ which describes the expansion rate of the universe. The age of the universe is then,
$$ t = \int_0^{z = +\infty} \frac{dz}{H(z)}$$
where $z$ is the cosmological redshift and, where $H(z')$ depends on the cosmological parameters from above for the FLRW metric which is the foundation of the $\lambda$-CDM model.
For some historical context, in the early 1900's, a synthesis of cosmology occurred: Einstein's theory of gravity allowed for rigorous modeling of the universe, observations began to show that the Universe is full of lots of galaxies, and Hubble showed that these galaxies are receding from each other - the traditional interpretation of this is that the universe is expanding. Through the foundational works of Lemaitre, Friedman, and the 100 years of study following by thousands of others, cosmology is more a precision science than ever before. These models are "big bang" models which assume the universe begins from a singularity and expands thereafter. So, this means that the "big bang" occurred at every point all the time, in the very earliest moments of the Universe (on a distance scale smaller than we can even theoretically probe), and the Universe expanded from that initially low entropy, high temperature state to the increasingly high entropy, low temperature state we see today.
So, when we observe a very very very far away galaxy to have a distance greater than $14$ Gyr, we may be puzzled, and indeed this was a problem called the cosmic age problem. Nowadays, most cosmologists believe that this problem is solved, by interpreting data concerning the expansion of the Universe: the Universe's expansion is accelerating, which explains why the relative distance of some objects can appear to be greater than the cosmic horizon (and why the recession velocity can appear to be greater than the speed of light). See here for a better explanation.
I'm not a cosmologist, so I hope I haven't said anything too imprecise. :)
Answer: The galaxies were formed after the inflation which means at the time of formation the distance between the galaxies were already huge.

How did we beat the light?


Effective concatenation

Question: How can I concatenate two sequences of lists (either lists of lists or vectors of lists) in constant time (independent of their size)?
Comment: https://emacs.stackexchange.com/tags/elisp/info
Comment: Please consider removing the last paragraph, as it solicits primarily opinion-based answers.
Answer: I'm not sure you can avoid some size dependent time cost as you'll need to iterate over one list or the other to join them together. If you know your new list is shorter than the list you are adding to then you can just push them to the front:
(let ((l '(4 5 6 7))
      (n '(2 3)))
  (cl-map 'nil (lambda (x) (push x l)) n)
  l) ==> (3 2 4 5 6 7)

That said I tend to favour the dash functions and just -concat:
(let ((l '(4 5 6 7))
      (n '(2 3)))
          (-concat n l)))

which according to disassemble ends up with almost the same byte code but probably because it can optimise the simple example.
Comment: @JAre: do you have specific ordering requirements? One common idiom is to build up a list with push and then finally nreverse the list at the end. You could always track start and end points for each list in some sort of structure and then manually tweak the list with setcdr but then you might start to question your data structures and what you are trying to achieve.
Comment: Currently I'm using `nconc`. It should only iterate over the first list (A) to find its cdr. So it adds the long resulting list (B) to the tail of the short one (A). Then I set the variable that points to (B) to (A). The problem with this approach is that it mess up the order.  I want (A) to be (B)s tail. Maybe there is a way to save (B) tail in a separate variable - add (A) to it and set  (B) tail to (A) tail ?

Effective concatenation


Diskbased to in memory tables sql server 2016 ram requirement

Question: I am planning to migrate my tables to memory optimized tables. Currently, I have a total of 250 gigabytes database size on disk. If I migrate this to in memory tables, how much physical RAM will I need?
Answer: Start with the Books Online page on estimating memory requirements for in-memory OLTP. It goes into deep detail, and here's just a snippet:

When there is an active workload, additional memory is needed to account for row versioning and various operations. How much memory is needed in practice depends on the workload, but to be safe the recommendation is to start with two times the expected size of memory-optimized tables and indexes, and observe what are the memory requirements in practice. The overhead for row versioning always depends on the characteristics of the workload - especially long-running transactions increase the overhead. For most workloads using larger databases (e.g., >100GB), overhead tends to be limited (25% or less).

Keep in mind that that's only for the in-memory OLTP data - not your query workspace, buffer pool for other objects, AG log caching, etc.
Answer: The answer (of course) is "it depends".
Part of what it depends on is:
 1. what other features SQL Server you might consider using. For instance, using the temporal feature with memory-optimized tables requires addtional memory, etc.
 2. if you will be adding additional indexes (SQL 2017 now supports hundreds of indexes per memory-optimized table). A singe nonclustered index on a memory-optimized table does not support both ascending and descending queries, so you might have to add more indexes than are required for your on-disk workload.
 3. if your current data/indexes use any form of compression, i.e. row/page/columnstore
Also, have you done a POC that proves your workload will benefit from migrating to memory-optimized tables?


Book about extremely overpopulated world where caring was a liability

Question: I am looking for a book about an extremely overpopulated world where caring was a liability. It's a love story of how these two people manage to care for each other in that world. It's also about ruthlessness really. I'm trying to find the author and/or the title. There were also outsiders that weren't part of the main system that was featured somehow. I think it was so overpopulated that they had to sleep in shifts.
Comment: You should attempt to add more info and some of the stuff doesn't seem pertinent. Like maybe you should get rid of " ....where caring was a liability" or clear it up a little. Because it seemed a bit confusing.
Comment: Possible dupe: http://scifi.stackexchange.com/questions/12631/identify-story-overpopulation-problem-causes-people-to-live-one-day-a-week
Comment: This could almost be Harry Harrison's "Make Room, Make Room" (1966) (cf. Soylent Green). There were a few 'haves' and many more 'have nots', but I recall no 'outsiders'.
Answer: This sounds like Philip Jose Farmer's noted short story "The Sliced-Crosswise Only-On-Tuesday World", which he later used as the inspiration for his "Dayworld" series. Both are about a future in which everyone sleeps in stasis except one day a week as a solution to overpopulation. The original short story is a thwarted romance between two people who live on different days. I don't remember reading the novel, but according to Wikipedia it features a group of outsiders trying to change the system.
Answer: This sounds like The Dosadi Experiment by Frank Herbert.

"She'd been taught by loving parents (who'd concealed their love
  behind exquisite cruelty)".
Comment: Maybe you should tell where the quote came from, is it your quote or is it from the book.
Comment: Based on Wikipedia, it is a cruel world with overpopulation and one where two people find their way together, not sure about the rest. http://en.wikipedia.org/wiki/The_Dosadi_Experiment


Primary Chatroom Name Polling

Question: Please, add a new option as answer (Don't Repeat.. So, please read all answers first). The answer with largest vote would be chosen (this can be checked from time to time in the end of each month). Please, participate.
Comment: I'm unconvinced we need a change of name. What benefit would accrue from doing so?
Comment: [What](http://meta.scifi.stackexchange.com/questions/751/what-should-we-call-our-chatroom)? [This](http://meta.scifi.stackexchange.com/questions/2533/why-is-the-name-of-main-chat-room-mos-eisley?lq=1) [again](http://meta.scifi.stackexchange.com/questions/1173/do-we-like-the-name-of-our-chatroom)?
Comment: @DVK - He wasn't terribly polite about those people who voted for the status quo "*Voting for existing one would be your Inertia. Think Again*"
Comment: Seriously, why all the hate at Sachin??? He asked a valid question, and you can't use the excuse "on Meta downvotes are about disagreeing" **because the question didn't express an opinion to disagree with** (he even posted "Mos Eisley" as the answer). And the question is perfectly valid since the topic was clearly discussed and broached by several users in the chatroom yesterday.
Comment: @DVK: 1. Not everybody is a chat completionist, and so if there was discussion about maybe changing the name, that should have been mentioned or linked in the question. 2. Implicit in the question is the idea that the chat name should be changed. I downvoted because I don't think we need a name change. If you could link the relevant transcripts, I'd consider reversing my vote.
Comment: @DVK - I didn't like the suggestion either, which was a happy coincidence :-)
Comment: @Richard Believe in democracy... Mos Eisley is also an option.
Comment: @Wikis - site population changed. Opinions changed. It's perfectly valid to re-poll the names as a new question, since the answers on old ones may no longer be valid.
Comment: @DVK: nice of you to stand up for Sachin but I don't think it was a personal issue at all. There was no reference to the recent chat conversation so it seemed like one user was suggesting a name change (again) without any justification. But, as alexwlchan mentioned, with the context some downvotes might be reversed.
Comment: @Richard - ever heard "vote for the post, not the user"?
Comment: Note that the "results" of this poll are highly suspect since many peoples' votes have probably been reversed:  http://meta.scifi.stackexchange.com/a/5359/4167
Comment: @Ward not reversed, but wiped, right (me too)? So basically any answer of Sachin's, including the status quo, could have had any number of additional down votes (or up votes, I guess, although that seems less likely for this question).
Comment: @alexwlchan - that's my point. The question did NOT imply that the name needs to be changed, and as proof, the same user posted the current name as one of the options as an answer (and alluded to in immediate comment). So if you don't want name changed, the correct action is to **upvote that answer**, not to downvote the question.
Comment: @Richard Those words aren't gunpoint. One can still vote it.
Comment: @DVK: That wasn't the impression I got from reading the question, but I see your point.
Answer: Mos Eisley
................................
Comment: Voting for existing one would be your Inertia. Think Again.
Answer: In the previous poll, The Ansible was the runner-up.
Interestingly, it's now the highest voted with a mighty +4.
Comment: [Ansible is taken](http://ansible.uk/).
Answer: TARDIS
..............................
Comment: Love it! This chatroom is bigger on the inside than the outside...
Answer: Delphic Expanse
..............................
Answer: Time Vortex
.............................
Answer: I'd prefer something vaguely sci-fi/fantasy sounding, but generic enough to not be tied to a specific universe:
The Void
Comment: And it may also be where our one-winged angel in the banner is going to/coming from
Answer: Hogwarts
..............................
Answer: Gallifrey
..............................
Answer: S.H.I.E.L.D.
..............................
Answer: Skynet
.................................
Answer: I don't think the chatroom name should be changed. But if it was to change, my favorite proposal is
The Dirac
The Dirac is a communication medium in James Blish's series Cities in Flight. It is nowhere as well-known as Ursula K. Le Guin's ansible (I don't remember any other author calling their communication device a Dirac), but it's more appropriate: an ansible is a point-to-point communication device, like a personal messaging system, whereas the Dirac instantly broadcasts all messages all over the universe, like a chatroom.
Comment: @DVK If you want no change, downvote the question and upvote the [Mos Eisley answer](http://meta.scifi.stackexchange.com/a/5330).
Comment: Shuldn't this be split into 2 separate answers? I want to upvote the "no change" part, and downvote "Dirac" because I think that there are names I like better.
Comment: agree on #2, fully disagree on #1. The question did NOT advocate for **changing** the name, just asked what it should be in a neutral way.
Answer: USS Enterprise
..............................
Answer: Death Star
..............................
Comment: My Fav. If Star Wars is popular here, this popular weapon should be the choice.
Answer: I think it needs to be something that conveys "chat room".
Ten Forward was the alt name.
Answer: The Billiards Club
Answer: The Three Broomsticks
Comment: If anything, it should be "Hog's Head"
Answer:
Rivendell

or

Imladris

(the Last Homely House :-D )
Answer: I like what Mos Eisley conveys, but here's a suggestion that's closer to something real:
Stan Lee's back porch
Because who wouldn't want to share a beer with Stan Lee on his back porch and talk about SciFi.
Comment: @DVK Not every user is a Star Wars fan.
Comment: Well... I wouldn't :) So it's not as obvious as you think. Also, not every site user is a comics fan.
Comment: I would say it should be ontopic, but I'm not always supported by "close anything but simple trivia and story-ID question" brigades, so don't use my opinion as basis :)
Comment: @DVK You don't have to be a comics fan to appreciate the creative mind of Stan Lee. Likewise, you don't have to be a rap fan (as I am not) to appreciate the poetic nature of Eminem's lyrics (as i do).
Comment: true, but there's a lot more people who know what Mos Eisley is than who recognize the name of Stan Lee.
Comment: @DVK I challenge that. Stan Lee, especially today with the Marvel franchise as used by Disney, is far more well known than he was in decades past. The name of an obscure Star Wars town is something that I think only SW fans would know.
Comment: Do Marvel films actually mention his name in any reasonably prominent way that an average film goer would notice?
Comment: @DVK At least half the articles about/announcing those films start with a line like "Adaptation of Stan Lee's ..." He also tends to cameo in them.
Comment: Maybe the problem here is that you just don't care for beer ;)
Comment: @DVK So I guess we've both surmised that Stan Lee is primarily only known by comics fans and Mos Eisley primarily by SW fans. The question now is who has more fans. Comics, in total, or SW? Is that on-topic on the main site?
Comment: @DVK After drafting, it seems off-topic. [I posted to chat.](http://chat.stackexchange.com/transcript/message/19340261#19340261)

Primary Chatroom Name Polling


How can you insert a custom symbol?

Question: How can you use a custom symbol for either dot density or proportional symbol maps in QGIS? Is there a way to import a symbol of your own such as a drawing or image that you can create or download from somewhere else?
Comment: Can you indicate what software you are using?
Answer: So in QGIS, you can import a symbol in the XML form. However, right now there's not really a way to store images in XML. If you have a windows computer, you can try http://www.stylusstudio.com/download...FQ3nnAodqlgAGQ
http://www.minipdf.com/scan2word/png-to-xml.html
But it's difficult for Mac users. Sorry that I can't be more helpful.
Answer: Assuming you are using arcgis, you can go into properties/symbology tab/ and select the symbol you want to change, then click the properties button, and go to the 'type' dropdown and select 'picture marker symbol', and navigate to your selected image

How can you insert a custom symbol?


drilling and putting a wall plug into spackle, taped up dry wall

Question: hi i recently tried to put up some curtain rails and unfortunately whilst drilling have put a much larger hole and made a mess of the wall, now i need that same area to put the curtain rails on, can i put spackle into the large hole together with the path/tape and then redrill into the hole with a wall plug? will it be stable? thanks for the answers in advance i presume its an insanely novice question
Answer: Only the lightest of curtains should be hung with hollow-wall anchors in the first place, even if you use togglers (anchors with mechanically-deployed wings). Screw-in or expanding drive-in anchors are almost guaranteed to fail after a short time, and heavy or frequently manipulated curtains should be mounted into framing.
To your question, if you fill the hole well with setting-type joint compound, which is much harder and stronger than "spackle" (a rather vague term leaving much room for confusion), and then you carefully drill for a toggle anchor, you'll probably be ok.
Answer: Spackle is just a cosmetic fix; you do not want to put any weight on it.
You should repair the wall with a small piece of drywall, or use toggle bolts to secure your curtain rod. They need larger holes anyway, so you wouldn't necessarily need to repair anything.


use taxonomy term for reservations how to prevent overlapping

Question: I have a drupal site where reservations are available. We use fullcalendar module to visualize the room reservations. For a reservation the user needs to add a new content. The content uses taxonomy terms as rooms. Now I'd like to achive that once the user creates a new booking content and chooses the room, when it is not available, the user should be warned. I mostly use rules and i am a bit unexperienced with drupal, now I'm trying to learn.
Answer: There are a number of ways to achieve the booking features in Drupal, try comparing here: Comparison of Booking System modules
One way that comes to mind for your specific case is using Flag module because you can set a Flag to be global, once an entity is marked as "occupied" that status is valid across the site. It's well integrated with Views and Rules, so you could probably do a lot there.
Another way might be to use Views Entity reference display for the Field widget when the user is creating a reservation. The Views would make sure to exclude all the terms for the Vocabulary that are already being used, so only "free" terms would show up when creating a new booking.


Copy all child pages to another parent

Question: Is it possible in confluence to copy all child pages to another parent page?
Answer: You can use the Copy Page Tree Plugin available from Atlassian Marketplace. It can copy page hierarchies within the same space as well as to other spaces. I'm the author of that plugin in case you have follow up questions.
Answer: With the copy space plugin you can copy pages from one to another space.
You can't copy pages within one space, as the page name has to be unique within a space.
Answer: You could also use the Confluence CLI
Answer: I created a small script for copying Confluence page with all children, labels and attachments.

Copy all child pages to another parent


Red-shifting due to emitting gravitational waves

Question: Light waves exert their own gravitational pull and must be emitting gravitational waves, losing energy in the process. Does this mean that light becomes red-shifted as it travels even without the effects of universal expansion?
Answer: This does not directly answer your question about redshift, but does clarify some points: Do photons and cosmic rays radiate energy through gravitational waves? If not, why not?. A key point here is that the photon must be accelerated for it to emit a gravitational wave, a photon simply travelling through empty space from another star to earth would not be accelerated (due to no massive bodies around) and therefore would not emit any gravitational waves.
In essence, if the photon does emit a gravitational wave, due to passing near a massive object, then yes it would lose energy and therefore be redshifted. The amount would likely be immeasurable I would assume (though I cannot prove it).
Answer: First we must clarify:

gravitational waves can be created by constantly changing gravitational fields, like two oscillating neutron stars.
photons do have gravitational effects, because they have energy
gravitational effects are because of stress-energy
photons energy comes from their frequency, E=h*f
a simple mass does not emit gravitational waves, like the earth, or at least not so big to have any effect.
a traveling photon does not emit gravitational waves.
gravitational waves are not the same as the effects of gravity (bending of spacetime), because gravitational waves are traveling gravitational fields, independently from the emitter
a gravitational wave is a traveling change in the bending of spacetime, so like a traveling gravitational field
a simple mass that has gravitational effects, like bending spacetime, does not emit gravitational waves (it needs to be rotating very fast around another mass, like two neutron stars rotating).

A simple mass like that will not lose energy by creating a gravitational field, and bending spacetime.
That is why a traveling photon will not lose energy by creating a gravitational field and bending spacetime locally where it is.
Photons get redshifted because the ones coming from far away galaxies that are receding, are in places where space expands, and the photons travel in expanding space that is why they get redshifted, getting bigger wavelength.


How many navigation categories are ideal for a website?

Question: I'm working on restructuring the navigation for an insurance company and was curious if there are best practices when it comes to the amount of second-level categories displayed. For instance, say you clicked on "Auto Insurance" from the homepage, what would be the ideal amount of navigation categories listed in that Auto section?
Answer: The only best practice would be "as much as you need, as little as you can".
Information Architecture is a quite complex discipline, and getting it right is a quite hard task even for specialist in that area.
About your question,  it's impossible to answer it here, but basically you need to start writing down all the pages you have, then group them logically using taxonomies and hierarchies, then start connecting them, following the paths just as any user would do.
You'll find out that MOST OF THE TIMES, 1 sub-level is enough. However, I have seen 3 and 4 levels deep navigations that worked exactly as expected, so again: as much as you need, as little as you can
Finally, the only thing you u need to do after this is.... test, test, test
Answer: Flat and deep hierarchies can both work well; only user testing will give you anything close to a definitive answer. Kathryn Whitenton's article is typical of many, and she summarises the options thus:

Flat hierarchies tend to work well if you have distinct, recognizable categories, because people don't have to click through as many levels. When users know what they want, simply get out of the way and let them find it.
But there are exceptions to every rule. In some situations, there are simply too many categories to show them all at one level. In other cases, showing specific topics too soon will just confuse your audience, and users will understand your offerings much better if you include some intermediate category pages to establish context.
Observing your users—via usability testing, analytics, and search logs—can help you understand what problems your audience needs to solve, and how familiar users are with your content. This background knowledge is essential to achieving the right balance between a breadth and depth in your hierarchy.


what is the difference between werthers soft and chewy candies

Question: What is the difference between Werthers soft caramels and chewy caramels? I have also seen "soft and chewy". Are those different than those other two?
Answer: The company website has a clear explanation of its products, which include hard caramels, soft caramels, and chewy caramels.  I think "hard" is self-explanatory.  Soft appear to be the texture of filled chocolates or caramels...easy to bite through.  "Chewy" are stickier and stretchier.  I don't see a "soft and chewy" product on their website, but it is possible I've missed it.


Cognos copying between servers

Question: Is it possible to copy objects (cubes, reports, setup) from one cognos 8 installation to another? For instance if a software consultancy company were to develop a cognos solution for a client then would the consultancy need to do everything on the client's servers directly, or can they develop it on their own server and send everything to the client when it's finished?
Answer: I believe your question has 2 answers. One answer for content, one answer for server configuration:
1) In regards to content (reports, models), as an administrator you can export content from your Cognos 8 installation. You can do this at the folder, package level or even the entire content store. The export function creates an archive file that can then be imported on the target installation. Documentation for this can be found in the Administration and Security Guide (Part 5).
2) In regards to setup/configuration, most server configuration is handled by the Cognos Configuration application which you run from the server. This is your server configuration tool and controls things such as URI's for the different C8 server components, pointers to the content store, email notification setup, etc. The Cognos Configuration contains an option under the File menu to Export the configuration as an XML file, which can then be used on the target installation.
Answer: In most organizations, you'll have a set of Cognos environments, for example :

Development (this is where BI content authors create models, reports, etc)
QA (this is were testers validate that the BI content is accurate)
Production (where real end users consume the BI content)

A BI Lifecycle Management tool like MotioCI can make promoting content between multiple Cognos environments far easier (and repeatable / traceable).  For example, here's a short video which demonstrates the process :
http://www.motio.com/products/ci/video/labelingAndPromotingBiContent.do

Cognos copying between servers


LibGDX: Is there a maximum amount of vertices for a PolygonShape?

Question: When you use PolygonShape.set(Vector2[] vertices), is there a limit of vertices of the array which is passed to the method?
Answer: Calling set on com.badlogic.gdx.physics.box2d.PolygonShape calls set on org.jbox2d.collision.shapes.PolygonShape, which does check the Settings.maxPolygonVertices (see PolygonShape source).
Thus, unless you've set org.jbox2d.common.Settings.maxPolygonVertices to something yourself, the number of vertices needs to be between 3 and 8 (inclusive) as the default is set to
/**
 * The maximum number of vertices on a convex polygon.
 */
public static int maxPolygonVertices = 8;

Be careful about changing that number as it has an impact on performance.
Answer: Method that you mentioned looks like this:
public void set (Vector2[] vertices) {
    Vec2[] v = new org.jbox2d.common.Vec2[vertices.length];
    for (int i = 0; i < v.length; i++) {
        v[i] = new Vec2(vertices[i].x, vertices[i].y);
    }
    shape.set(v, v.length);
}

Other methods in PolygonShape and her parent - Shape don't have the length limits too. I'm 100% sure that PolygonShape has no limit of vertices :_)


Tv cable, safe to cut?

Question: I have long ends of to cable coming out of baseboards in several rooms. Is it safe to cut off? Cable is no longer used in the house.
Answer: I push the cable back into the wall or floor until just the connector is sticking out.  You may not want cable right now, but never say never - you might want high speed internet or have a tenant or a next homeowner.  I know cable will install it for "free" but it's not really free, it costs you some discounts/rebates for an installer to come.
Answer: Yes, but I'd suggest re-routing them just in case someone does want to use cable/internet later.
And if your going to have the walls open anyway, now is a perfect time to install CAT6a Ethernet cable for your home network!

Tv cable, safe to cut?


Which Open Inventor is in Petrel & Ocean 2012.1?

Question: I know Petrel & Ocean 2012.1 release is right around the corner. Hence I am wondering which version of Open Inventor will be used, and where I can find more information about it.
Answer: Petrel 2012.1 will be based on Open Inventor 9.0
** Full documentation of OIV 9.0
oivdoc90.vsg3d.com
** Release notes, explaining what's new :
oivdoc90.vsg3d.com/content/open-inventor-90
In particular please read the section related to .NET API Specific
** Compatibility Notes (.NET specific)
oivdoc90.vsg3d.com/node/22246#NETAPI
oivdoc90.vsg3d.com/node/18333#NETAssemblies
** New behaviour of Dispose and exceptions
oivdoc86.vsg3d.com/content/release-notes-86#OpenInventor.NET
Dispose method (since OIV 8.6) raises an exception if the node is still referenced in the
scene graph. To avoid it, you should first disconnect the node from the children list of the
parent.
This new Dispose will also recursively visit the scene graph and call dispose on each node.
It was not the case in OIV 8.1 (Petrel 2011)
You may also find interesting to read the release notes of all versions between 8.1 and 9.0
to find out what's new between OIV 8.1 (Petrel 2011) and OIV 9.0
8.5 (January 2011) : oivdoc90.vsg3d.com/node/18773
8.6 (June 2011) : oivdoc90.vsg3d.com/node/18867
You may also find interesting to read the compatibility notes of all versions
8.5 : oivdoc90.vsg3d.com/node/18333
8.6 : oivdoc90.vsg3d.com/node/18867
Answer: Ocean for Petrel 2012.1 will be shipped with Open Inventor 184.108.40.206.
Please be sure to check the Open Inventor Compatibility Notes for version 9.0 and earlier, if you happened to call any Open Inventor APIs directly, because there might be changes needed in your code.
And just a reminder that Open Inventor license is included in the Ocean for Petrel license, but can only be used in the context of Ocean for Petrel. Please contact the Open Inventor vendor, VSG, if a stand-alone version of Open Inventor is required.
More information about Open Inventor licensing, new features and known issues is provided in the Ocean for Petrel 2012.1 Release Notes, which will be distributed with the release.


Is there  "Schur-Weyl duality" for infinite dimensional unitary group?

Question: To what extent does the relation between the diagonal representation of $SU(n)$ in $(\mathbb{C}^n)^{\otimes k}$ and representations of the symmetric group $S_k$ remain valid when instead of the group $SU(n)$ we take the general unitary group $U(\mathcal{H})$ ($\mathcal{H}$ is some separable Hilbert space) and its diagonal representation in $\mathcal{H}^{\otimes k}$? In particular is it true that irreducible representations of of $U(\mathcal{H})$ in $\mathcal{H}^{\otimes k}$ correspond to young diagrams of $S_k$ just like in the finite dimensional case? Is it possible to get any irreducible representation of $U(\mathcal{H})$ by considering decompositions of $\mathcal{H}^{\otimes k}$ for sufficiently big $k$?
Comment: I think this question is a great one, and I hope you get useful answers. +1. As a category and representation theorist, I would comment on one way to think about the question.  Namely, there is a category that I've seen called "GL(t)", although perhaps "SU(t)" is a better name, which is essentially the free category with some part of Schur-Weyl duality. Namely, you take the free symmetric monoidal category on a dualizable generator, and you impose the condition that its dimension is some scalar $t$, and then Karoubi-complete. When $t$ is transcendental, this category is semisimple. When ...
Comment: ... $t$ is an integer, this category has morphisms all of whose partial traces (after composing with anything) are zero, but that are not themselves zero, and on modding out by such morphisms you recover the category of finite-dimensional representations of GL(|t|). Anyway, the category does still have a Schur-Weyl theorem, in that the $n$th power of the generator decomposes exactly as is given by the Schur functors for $S_n$. So in some sense your question is whether this category can be modeled in terms of part of the representation theory of $U(H)$ $\otimes$-generated by $H$.
Comment: Of course, I should also mention that everything I know about GL(t) I learned from @Noah Snyder.
Comment: Thanks Theo for your comment. Unfortunately I have a very little background in category theory so I cannot understand the details. Yet, it is good to know that there are connections of this kind. As for myself, I got interested in this problem because of physics. For my purposes it would be sufficient if $\mathcal{H}^{\otimes k}$ would decompose "nicely" onto irreducible components just like in the finite dimensional case.
Comment: +1. I doubt duality exists for U(H), usually people work with limit of U(n), n->inf and consider this as an "correct" analog of U(n) for finite n. By the way what are irreps of U(H) ? As a Hilbert space H^k = H , so I am afraid some trouble like that will happen with representations constructed from H^k.
Comment: Theo, certainly it'd be U(t) not SU(t), because you haven't killed a determinant.
Comment: @Noah: Yes, of course.  GL = U, not SU.
Answer: The answer to all of your questions is yes. This is a theorem announced by Kirillov in
Kirillov, A. A. Representations of the infinite-dimensional unitary group. Dokl. Akad. Nauk. SSSR, 1973, 212, 288-290
and proved by Olshanski in
Olshanski, G. I. Unitary representations of the infinite-dimensional classical groups $U(p,\infty)$, $SO_0(p,\infty )$, $Sp(p,\infty)$, and of the corresponding motion groups. Funktsional. Anal. i Prilozhen., 1978, 12, 32-44, 96
Edit: This answer applies to continuous unitary representations of $U(\mathcal{H})$, where the latter group is equipped with the strong operator topology (which is the usual topology on this group). However, if you are only interested in representations on a separable Hilbert space, the continuity assumption can be dropped, as is shown in arXiv:1109.1200.
Comment: I should have also mentioned that the direct limit of the finite-dimensional groups is dense in $U(\mathcal{H})$.
Comment: As I wrote in my answer, the paper you cite are not about the whole unitary group. As for the results, see the quotation from Olhanski himself in my answer.
Comment: Meanwhile, indeed, for the subgroup considered by Kirillov, there is a relation of the requested kind.
Comment: @Todor But restriction and extension does not mean equvivalence of irreps. I mean when you restrict irrep you can get reducible, as well as, when you extend non-equiv. irreps. you can get equiv reps. As far as I remember it is always emphasized that the two groups: 1) U(H) and 2) limit U(n) has very different rep. theory. – Alexander Chervov
Comment: I am not sure I understand your comment. Every representation of the infinite-dimensional unitary group restricts to a representation of the direct limit of finite-dimenssional unitary groups and conversely, each of the representations they consider extends to one of the full unitary group.
Comment: @Todor why dense ? In what topology ? direct limit - operators of the form 1+K , K - finite-dim. you cannot approximate $e^{ia} Id$ by this operators if we speak about norm-topology.
Comment: @Alexander: Todor speaks about the strong operator topology. Finite-dimensional perturbations of identity are dense because a basic open set only "names" finitely many vectors.

Anyway, as he proved in the paper he links to, continuity assumptions can be dropped when one considers representations on a separable space.
Answer: As far as I know, there is no representation theory for the group $U(H)$, it is in a way "too big". However there is a rich representation theory for its subgroups admitting some kind of approximation by finite dimensional groups, in particular for the inductive limit group $U(\infty )$. For the latter, I quote the paper http://annals.math.princeton.edu/wp-content/uploads/annals-v161-n3-p05.pdf
by Borodin and Olshanski:
"It is worth noting that the similarity of theories for the two groups $S(\infty )$
and $U(\infty )$ seems to be a striking phenomenon. In addition, as mentioned
above, this can be traced in the geometric construction of the 'natural' representations
and in probabilistic properties of the corresponding point processes.
At present we cannot completely explain the nature of this parallelism (it looks
quite different from the well-known classical connection between the representations
of the groups S(n) and U(N))".
Thus, at the present state of this theory, the answer to your question seems negative.
EDIT. For the subgroup of unitary operators differing from $I$ by compact ones, the answer is positive. See the papers referred to in Todor Tsankov's answer.
Answer: Thank you Anatoly and Tador for your answers - they pointed to the very useful references. Despite to what Anatoly Claims in his answer there is a very rich representation theory  of $U(\mathcal{H})$ (not only for separable Hilbert spaces). I am not an expert in this field but as far as I can tell the paper by DOUG PICKRELL: http://www.ams.org/journals/proc/1988-102-02/S0002-9939-1988-0921009-X/S0002-9939-1988-0921009-X.pdf answers nearly all my questions. It stands that all separable representations (ie. representations in separable Hilbert space) of $U(\mathcal{H})$ ($\mathcal{H}$ - separable) decompose onto irreducible components that correspond to irreducibles that are taken "naivly" from some $\mathcal{H}^{\otimes k}$. It seams that this theory was known for $U(\infty)$ but in this paper author handled the disturbing "Galkin Algebra". I only wonder what happens to the determinant representation of $U(n)$ if we go to $\infty$ limit?
Comment: @Michal Thank you for the reference, which is important also for my understanding of the subject.
Comment: It seems like *this* should be the accepted answer? Since there was some back-and-forth debate between the other two, and neither got as far as answering the question as this Pickrell paper does. Or have I misunderstood something?


Django custom template tag being cached

Question: I won't be offended if you just send a link to where this has already been answered.  I haven't found an answer to this.
I'm working on a site where a cached template loader is enabled.  They have a custom template tag that they call on many pages, and one of the values passed to this tag is the unique article ID of the page that called it.  The problem is that the cached template loader seems to be caching the values too, so even though each page is passing its article ID to the tag, the tag is using the cached article ID.
Is there a way to disable the cached template loader for a single template tag?
Here is some code if it's helpful:
This is the cached template loader setting:
TEMPLATE_LOADERS = (
    ('django.template.loaders.cached.Loader', (
        'django.template.loaders.filesystem.Loader',
        'django.template.loaders.app_directories.Loader',
    )),
)

When I comment out this setting and restart the server, the issue goes away, so I know it has "something" to do with caching.
That doc linked above also talks about making sure template tags are thread-safe.  Is this because of how the template gets stored in the cache?  What I take from that note about thread-safety is that values passed to template tags shouldn't be assigned to the node itself, but to the render_context.  Am I on the right track?
Here is a sample of what my code is doing:
Calling the tag on page 1:
{% my_tag article_id="{{object.article_id}}" %}

Calling the tag on page 2:
{% my_tag article_id="{{object.article_id}}" %}

In both of the above cases, object.article_id is a template variable that contains the article ID for the page calling the template tag.
Below is the template tag code (simplified).
@register.tag(name="my_tag")
def do_my_tag(parser, token):

    article_id = None
    values = token.split_contents()
    kwargs = get_kwargs(values[1:])

    if "article_id" in kwargs:
        article_id = kwargs["id"]

    return DoMyTagNode(article_id)

class DoMyTagNode(template.Node):

    def __init__(self, article_id):
        self.article_id = article_id
        self.template = get_template('path/to/template.html')

    def render(self, context):
        article_id = Template(self.article_id).render(context)

        context.update({ 'article_id': article_id })

        return render_to_string(self.template, context)

Any help would be greatly appreciated!
Answer: You shouldn't use the django.template.loaders.cached.Loader in development since it means changes to your html files aren't picked up, requiring you to restart the server. That's most likely your issue since you haven't really provided much more.
The cached loader isn't caching the output of your templates, it's caching the templates from the filesystem. They will still behave as normal as without the loader so that's not your issue. The loader doesn't cache the output of your custom tag.

Django custom template tag being cached


Do workflows in PWA kick off when you save project?

Question: Are workflows supposed to kick off whenever you edit then save information in PWA?  All my projects seem (from Logging) only to ever get workflows run when you create the project or manually "Change or Restart Workflow."   I would expect that the workflows would run whenever a change to PWA occurs, and that the workflow would start in the same stage that it was in when the edits started.   Is that the behavior?  Why is it not kicking off on a save?
Answer: In my experience, I've not seen the type of behavior that you are describing, which is more typical of a standard SharePoint workflow. Project Server workflows are basically manual workflows that you push forward to the next stage as you see fit. A typical scenario is a project lifecycle. Moving to the next stage is a deliberate action that you take when needed.
Let me know if this makes sense or if I misunderstood your question. For anyone else, please let me know if I'm mistaken on this, as it would improve my feelings towards PWA.


"At this time" vs. "at that time" vs. "at the point of time"

Question: What is the difference between "at this time", "at that time" and "at the point of time"? In what cases should we use these phrases? Could you give me examples?
Comment: *At the point of time* is not idiomatic; we say *At **this/that** point **in** time* or *At **the** point in time **when***.
Comment: At the time ...
Answer: They're all just roundabout ways of saying things we usually do in a single word...

at this time = now
at that time = then
at the point of time = when

I don't much like at the point of time. Obviously, I normally use when anyway, but it's usually at the point in time if I have to use the longer form. Except in "scientific" contexts like at the point of time T (that's almost 7000 of them in Google Books). I don't mind that usage so much, but I really don't like this type

One, therefore, arrives at the position where, if there were successive partial losses which are unrepaired at the point of time when the cover terminates, the measure of indemnity has to be assessed by reference to the depreciation at that time.

Here's a chart showing that in has been standard usage for decades...

The shift in preference is far more marked than the chart would suggest. The vast majority of modern usages are that "scientific" context. Most of the rest are (like my fully-quoted example) legal contexts.
Unless you're writing scientific or legal texts, my advice is don't use any of these long-winded phrasings. And if you have to refer to the point, it's in time unless you're talking about a specific time T on a graph.
Answer: From here:
at this time = right now.
at that time = in the future/past.
at the point of time is not really idiomatic, but looks like it might mean a very specific moment.
Answer: "At this time" seems to be an overused qualifier for public officials. One often sees it in the news. In most cases it's totally unnecessary.
Answer: "At this point in time" and its relatives have been so mindlessly over-used, especially by government functionaries in England, that the late Gavin Lyall mocked the tendency in The Crocus List, one of his too-few Harry Maxim novels:
George snorted.  "Not with that old blatherskite in command.  And that's why I don't want to become too official at this point..." Since he found it difficult to be unofficial without sounding more official than usual, he almost added "in time" but stopped himself, in time.
Generally speaking you'll be better-off if you follow FumbleFingers's advice:  substitute "now", "then", or "when" as appropriate.  Your writing will be crisper and more readable.
Answer: The phrases "at that point in time" or "at that point of time" are both redundancies. You add zero information by using them. "At that time" or "at that point" are all the information needed. John Dean was one of the first people to use "point in time" during his testimony at the Watergate hearings. I'd give him a pass on its use, since he was under tremendous stress. But there's no reason to use extra words that convey no information. I admit that I'm a former editor who believes that shorter sentences are important for readability. Whether you talk or write, you want the listener or reader to pay attention. Adding useless words is always counter to goals of a speaker or writer.


Sitecore SXA Search - external sites

Question: Does Sitecore SXA out-of-the-box search functionality have option to include external (non-sitecore hosted) sites to include in search result?
Comment: No, there is no such way.
Answer: You can read details on SXA search configuration in the online documentation here: https://doc.sitecore.net/sitecore_experience_accelerator/setting_up_and_configuring/setting_up/sxa_search
The relevant piece for your question is:

SXA supports both Lucene and Solr search engines. The search engines
  are used for searching in the content databases, as well as for
  searching in a number of operational databases that Sitecore uses for
  collecting analytics data, test data, and so on.

SXA Search is index-based, therefore it will only crawl what is in the indexes.

Sitecore SXA Search - external sites


Can SSD performance degrade when one partition is low on space but, as a whole, SSD has ample free space

Question: Will SSD read/write performance decrease for a partition that is low on space if the drive itself has ample free space?
Comment: Unless dealing with thousands of small files, it should not slow down at all.
Comment: @FrankThomas I think what you have written may be misinterpreted - the partitioning is a software abstraction - the ssd sees itself as a block device and will move data arround at the block level and will reallocate blocks regardless of how full a partition is.  Also, as a disk fills up there is less space to wear level and an SSD may indeed slow down.
Answer: No, it can't.
The firmware of the SSD knows nothing about partitions. It only knows
about and manages sectors.
Partitions are handled by the operating system (and the BIOS).
If your disk is slowing down, check its SMART attributes to verify its
health. If you don't already have a product for it, use
Speccy, which will also analyze
the variables and mark each one as Good or not.
Include a screenshot of the SMART attributes in your post,
if you want us to have a look.
Comment: Just a note that Speccy's publisher has a history of some insecure/shady practices (you might still want to use it, but be informed): https://en.wikipedia.org/wiki/CCleaner#Critical_reception
Answer: There are circumstances that can slow down a SSD besides availability of erased pages that do not by definition mean any kind of damage or malfunctioning. For example 'static' data at some point will require more effort and time to be read even though modern SSD's patrol and refresh such data upon reaching a certain threshold.
But since there's no static relation between LBA sectors and physical NAND memory, the SSD does not care about free space within the partition, if it even had any concept of it, which it has not. While we regard the partition a linear array of LBA sectors it is actually spread over the SSD. As long as the SSD 'remembers' where each of the sectors are, we (the operating system) can treat the partition as an area on a drive.
In other words, assume 100 GB partition (1) and a 140 GB partition (2) on a 240 GB SSD. Then assume partition (1) has 15 % free space while partition (2) has 50% free space. We also assume the SSD is aware of the sectors that aren't in use as the operating system TRIMs deleted sectors so it can pro-actively erase those.
This means overall SSD has 35% space available to store new data which is a very healthy amount, even for partition (1) which itself has only 15% free space available from the perspective of the file system.
Then we also need to consider there is likely more 'free space' due to overprovisioning by the SSD firmware: Even if you'd fill the SSD up 100% it needs some working space, somewhat similar to a slider puzzle. BTW, this does not mean I encourage anyone to fill up the SSD fully. The more 'free space' the smoother the SSD will function as it will make wear leveling easier and will help the SSD have an amount of erased and ready to go blocks available.

Of course there is the 'normal' wear that will eventually degrade any SSD.


How to develop telerik report viewer using .net framework 3.5?

Question: I am developing application which is integrated with  sharepoint 2010 webpart using .net
framework 3.5,I need to build telerik report viewer dynamically via c# code.I have created new asp.net project with framework 3.5 but I could not add reference of Telerik.Reporting.dll and Telerik.Reporting.WebForms.dll.It is possible if the project framework is 4.0 but sharepoint 2010 does not supports framework 4.0 i(we cannot include framework 4.0 dlls into wsp) file.How can I use report viewer in .net framework 3.5 with sharepoint 2010 support  and include those .net framework dlls into wsp file?
Let me know which version of telerik report viewer supports .net framework 3.5 and where can I get it.
Note: I am using latest release(2013 Q3) of report viewer.
Regards,
RanjithKumar.G
Answer: Telerik Repoting has not supported .NET Framework 2.0 - 3.5 since the Q2 2013 version (http://blogs.telerik.com/telerikreportingteam/posts/13-01-21/telerik-reporting-to-drop-.net2.x-.net3.0-vs2005-and-vs2008-support-in-q2-2013). You may download an older version 220.127.116.11 for example.


MW3 keeps freezing in an online game

Question: My MW3 keeps freezing in the middle of an online game. The disc is perfect and my internet connection is good, anyone know what is happening?
Answer: Even with a perfect-seeming disc and a good connection, it still sounds like you could be expriencing a broad range of issues. This Call of Duty Forum post is a really good place to try continuing troubleshooting your problem. The OP has a series of tests that they tried. (They still don't know what's happening, but they've at least eliminated all the major possibilities.) As another poster in that thread points out, once you've eliminated all major possibilities, you may want to contact a Sony Customer Support representative.
Let us know what you find out! The more solutions on the web, the better!

MW3 keeps freezing in an online game


Is there a way to find out the list of users who logged into an EC2 instance

Question: Is there a way to find out the list of users who logged into a Linux EC2 instance (e.g IP, time ..) for audit purposes.
Comment: You wouldn't happen to know what operating system this is, would you?
Comment: Could you provide some more details to your question about what your requirements are? Do you want historical logon info? Only active connections? etc.
Comment: Looks like this is on its way to being closed due to lack of information. I'd suggest editing your question to include more info on the operating system(s) involved. If the question has already been closed by that point, you can flag it and request that it be re-opened.
Comment: historical info not necessarily active connections
Comment: @ErikA - I had mentioned that this was for a Linux instance, wasn't that clear to you? Its just weird that someone would mark this as closed :(
Answer: Assuming this is a linux instance, the w shell commmand will show users that are currently logged in.
To see the last time someone logged in, use the lastlog command.
If you want a full accounting of all user logins, you'll need to grep through /var/log/auth.log.
Answer: Try last
Also, man last, man whois, man who
This all assumes you're talking about UNIX interactive logons at the OS level.  If you're talking about anything else (like application logons, management console logons, you'll need to be more specific).


Are Minkowski and Schwarzschild spacetimes diffeomorphic?

Question: Another mathematical question, arising from GR. Some days ago I wrote, in an answer to 1, that they are. Then @magma commented they are not. He promised a proof, but none appeared. After magma's comment I have some doubts about my intuition and I would like to see a proof, in one sense or the other, or at least a reliable reference.
Comment: Intuitively, they can't be. Minkowski space has a trivial second homotopy group ($\pi_2=0$), while Schwarzchild spacetime has an entire line excluded (the singularity's worldline) and therefore $\pi_2=\mathbb Z$
Comment: Are they even homeomorphic? Naively, it seems to me that Schwarzschild is topologically $\mathbb{R}^2 \times S^2$, while Minkowski's just $\mathbb{R}^4$. Isn't this true?
Comment: Hi Elio, it's a pleasure finding you here. I am travelling, I am in Frankfurt airport. My final destination is the Max Planck Institute in Laipzieg.
Comment: Hi Elio, I finally managed to answer enumaris question :-) My argument is basically the same used here
Comment: @Valter Moretti Hi Valter, it's a pleasure for me too, and it was a
surprise. As to your answer and the others', I suspected that the
catch was in S^2. I see that in KS spacetime the spheres cannot be
shrunk to a point. However can't clearly see how things go in
Minkowski. What troubles me is that r=0 is a regular line in the
manifold, but a coordinate singularity. So I can't see what happens.
As you're reading, did you see my question about diagonalizing
Boyer-Lindkquist metric?
Comment: Dear Elio, sorry I am impossibly busy: I cannot discuss complicated issues. I will try to come back to your question later. Ciao, Valter
Answer: They aren't. That is because Kruskal-Schwartzschild is diffeomorphic to $S^2 \times R^2$, while Minkowski is $R^4$. This  is roughly  similar to the difference between a 2D  cylinder $S^1\times R$  and $R^2$.
The formal reason is that pointed out by G. Golfetti in a comment above: the second homotopy groups are different, as is expected by the presence of the factor $S^2$. In M. space you can shrink two-spheres continuously into points, in K-S space you cannot: when you encounter the bifurcation surface (the 2D event horizon) you cannot go further and you pass from the right wedge to the left wedge. The standard global Kruskal coordinates map K-S manifold to $S^2\times R^2$. There is no way to make vanishing the radial coordinate. It would vanish on the singularity, but it does not belong to the manifold. At the center of the manifold it takes the Schwarzshild radius value which  is strictly positive. There is no center of those spheres. Similar coordinates can be defined on Minkowski spacetime but they are not global since they do not cover the set $r=0$ which is part of the manifold.
Comment: Valter I gave an answer along these same lines elsewhere. But I would like to see if we are really on the same wavelength. Given KS coord. {$T,X,\phi,\theta$},could you please specify which pair maps to $S^2$ and which one maps to $R^2$ ?
Comment: Dear Magma I am at a conference now. I will try to specify my answer when I am  home again. I think that I referred to partially different coordinates and my radial coordinate is a coordinate smoothly matching the Schwarzschild coordinate $r$. However, everything can be recast using the coordinates you point out. The first couple maps to $R^2$ and the second one to $S^2$ (up to a small set...)
Comment: Great Valter, that is exactly what I thought! When you can , I would certainly appreciate if you could tell me which other coordinates were you originally thinking about


elements in the product of subgroups in $S_4$

Question: Let $N:=\{e,(1\,2)(3\,4),(1\,3)(2\,4),(1\,4)(2\,3)\}$ be the normal subgroup of $S_4$ and $H:=\langle(1\,2\,3\,4)\rangle$ be the cyclic subgroup of $S_4$ generated by $(1\,2\,3\,4)$. Using the Second Isomporphism Theorem, how do I easily find the elements of $HN$? I know that $|HN|=\frac{|H||N|}{|H\cap N|}=\frac{4\cdot4}{2}=8$, but how can I actually find those 8 elements without brute force?
Answer: I don't know how you expect to find the eight elements without making a computation, but the second isomorphism theorem does give you a way to be efficient. Using the isomorphism $HN/N\cong H/H\cap N$ you get that the distinct cosets in $HN/N$ are
$N$ and $(1234)N$. Now, compute the elements in these cosets.
Comment: I found the elements of $H/(N\cap H)$ but those aren't necessarily the elements of $HN/N$, they are just isomorphic. How do I find the isomorphism mapping between the two groups?
Comment: The map $H\to HN/N$, $h\mapsto hN $ is subjective. So...


UITableViewCell expand on click

Question: Lets say we have a custom UITableViewCell
So whenever I click custom button on cell.. it should expand to the some extent (you can say 40 height more...) and when i click again to the same custom button it should collapse to the previous height.
Developer's please guide me.. how can I achieve this task
Comment: NOTE: If you want the expanded area to contain new clickable cells (rows) (rather than just expanded space for the clicked cell), see [gcamp's answer](http://stackoverflow.com/a/7253288/199364). It starts with a set of *sections* that are closed; click on a section header to open that section,showing its cells.
Answer: I'm not going to say anything here to contradict the accepted answer considering it is perfectly correct. However, I am going to go into more detail on how to accomplish this. If you don't want to read through all this and are more interested in playing with the source code in a working project, I've uploaded an example project to GitHub.
The basic idea is is to have a condition inside of the method -tableView: heightForRowAtIndexPath: that determines whether or not the current cell should be expanded. This will be triggered by calling begin/end updates on the table from within -tableView: didSelectRowAtIndexPath: In this example, I'll show how to make a table view that allows for one cell to be expanded at a time.
The first thing that you'll need to do is declare a reference to an NSIndexPath object. You can do this however you want, but I recommend using a property declaration like this:
@property (strong, nonatomic) NSIndexPath *expandedIndexPath;

NOTE: You do not need to create this index path inside viewDidLoad, or any other similar method. The fact that the index is initially nil will only mean that the table will not initially have an expanded row. If you would rather the table start off with a row of your choice expanded, you could add something like this to your viewDidLoad method:
NSInteger row = 1;
NSInteger section = 2;
self.expandedIndexPath = [NSIndexPath indexPathForRow:row inSection:section];

The next step is to head on over to your UITableViewDelegate method -tableView: didSelectRowAtIndexPath: to add the logic to alter the expanded cell index based on the users selection. The idea here is to check the index path that has just been selected against the index path stored inside the expandedIndexPath variable. If the two are a match, then we know that the user is trying to deselect the expanded cell in which case, we set the variable to nil. Otherwise, we set the expandedIndexPath variable to the index that was just selected. This is all done between calls to beginUpdates/endUpdates, to allow the table view to automatically handle the transition animation.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView beginUpdates]; // tell the table you're about to start making changes

    // If the index path of the currently expanded cell is the same as the index that
    // has just been tapped set the expanded index to nil so that there aren't any
    // expanded cells, otherwise, set the expanded index to the index that has just
    // been selected.
    if ([indexPath compare:self.expandedIndexPath] == NSOrderedSame) {
        self.expandedIndexPath = nil;
    } else {
        self.expandedIndexPath = indexPath;
    }

    [tableView endUpdates]; // tell the table you're done making your changes
}

Then the final step is in another UITableViewDelegate method -tableView: heightForRowAtIndexPath:. This method will be called after you've triggered beginUpdates once for each index path that the table determines needs updating. This is where you'll compare the expandedIndexPath against the index path that is currently being reevaluated.
If the two index paths are the same, then this is the cell that you wish to be expanded, otherwise it's height should be normal. I used the values 100 and 44, but you can use what ever suits your needs.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Compares the index path for the current cell to the index path stored in the expanded
    // index path variable. If the two match, return a height of 100 points, otherwise return
    // a height of 44 points.
    if ([indexPath compare:self.expandedIndexPath] == NSOrderedSame) {
        return 100.0; // Expanded height
    }
    return 44.0; // Normal height
}

Comment: Could you please explain how table view handles animation in new version where is nothing between `beginUpdates` and `endUpdates`? Thanks
Answer: Implement heightForRowAtIndexPath to calculate the right height.  Then in the code for your button, force the table to reevaluate each cell's height with beginUpdates plus endUpdates:
[self.tableView beginUpdates];
[self.tableView endUpdates];

Changes to the tableview cells' heights will automatically be calculated with heightForRowAtIndexPath and the changes will be animated too.
In fact, instead of a button on your cell that does this, you might even just make selecting the cell do this in didSelectRowAtIndexPath.
Answer: Instead of using [tableView beginUpdates] and [tableView endUpdates] , I'm using the [tableView reloadRowsAtIndexPath:... withRowAnimation:...] method inside the didSelectRowAtIndexPath method.
I prefer this, because  I had some problems with elements that should show, when I expand my UITableViewCell, when I used the begin & end updates methods. Another point is that you can choose between some animations like: Top, Bottom, Left, Right...
Comment: Great insight about better control on the animations!
Answer: I have created an open source library for this. You just implement collapse and expand delegates in your code and voilà! you can also perform any drawings and animations. check out this.
Comment: project could be improved if you subclassed the tableview cells instead of using viewWithTag
Comment: HVTableView has a new update. it's now provided on cocoapods as well.
Answer: I've made a reusable component that will do exactly what you're talking about. It's pretty easy to use, and there's a demo project.
GCRetractableSectionController on GitHub.
Comment: This is exactly what I needed. A UITableview inside a UITableviewCell. Perfect. Thanks. :)
Comment: For me also, this was perfect solution - I was wondering how I could have the expanded area contain additional clickable cell rows, rather than just be a single cell.
Answer: This is Mick's answer but for Swift 4. (IndexPath replaces NSIndexPath, which comes with an empty IndexPath as nil would crash Swift. Also, you can compare two instances of IndexPath using ==)
Declare the expandedIndexPath property.
var expandedIndexPath = IndexPath()

Optional viewDidLoad part.
expandedIndexPath = IndexPath(row: 1, section: 2)

Then the didSelectRow part.
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    tableView.beginUpdates()

    if indexPath == expandedIndexPath {
        expandedIndexPath = IndexPath()
    } else {
        expandedIndexPath = indexPath
    }

    tableView.endUpdates()
}

Then the heightForRow part.
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    if indexPath == expandedIndexPath {
        return 100
    }

    return 44
}

Answer: I used Gcamp's source code and made my own version.
1) In a loadView method initialize a mutable array where you will save expanded or non-expanded states of your sections. It is critical to save expanded statuses in a separate array, that is not destroyed while table view scrolls (for instance if you store it in a headerView it will be redrawn and forget weather it was expanded or not). In my case it is _sectionStatuses array.
- (void)loadView
{
     // At the beginning all sections are expanded
    _sectionStates = [NSMutableArray arrayWithCapacity:self.tableView.numberOfSections];
    for (int i = 0; i < self.tableView.numberOfSections; i++) {
        _sectionStates[i] = [NSNumber numberWithBool:YES];
    }
}

2) Create a custom headerView for a section with a button for expanding. Delegate an action from a button in your headerView to your TableViewController using delegation pattern. You can find suitable images in Gcamp's source code.
3) Create an action to remove or add rows. Here _foldersArray is my structure, that contains all the data. My section's headerView - MCExpandableAccountHeaderView knows it's own section number - I transfer it there when I create header views for each section. It is critical to transfer it to this method, since you have to know which section is now expanded or stretched.
- (void)expandClicked:(MCAccountHeaderView *)sender
{
MCExpandableAccountHeaderView *expandableAccountHeaderView = (MCExpandableAccountHeaderView*)sender;

// Finding a section, where a button was tapped
NSInteger section = expandableAccountHeaderView.section;

// Number of rows, that must be in a section when it is expanded
NSUInteger contentCount = [_foldersArray[section - 1][@"folders"] count];

// Change a saved status of a section
BOOL expanded = [_sectionStates[section] boolValue];
expanded = ! expanded;
expandableAccountHeaderView.expanded = expanded;
_sectionStates[section] = [NSNumber numberWithBool:expanded];

// Animation in a table
[self.tableView beginUpdates];

NSMutableArray* modifiedIndexPaths = [[NSMutableArray alloc] init];
for (NSUInteger i = 0; i < contentCount; i++) {
    NSIndexPath* indexPath = [NSIndexPath indexPathForRow:i inSection:section];
    [modifiedIndexPaths addObject:indexPath];
}

if (expandableAccountHeaderView.expanded) [self.tableView insertRowsAtIndexPaths:modifiedIndexPaths withRowAnimation:UITableViewRowAnimationFade];
else [self.tableView deleteRowsAtIndexPaths:modifiedIndexPaths withRowAnimation:UITableViewRowAnimationFade];

[self.tableView endUpdates];

// Scroll to the top of current expanded section
if (expandableAccountHeaderView.expanded) [self.tableView scrollToRowAtIndexPath:INDEX_PATH(0, section) atScrollPosition:UITableViewScrollPositionTop animated:YES];
}

4) It is also important to return correct number or rows in a section depending on wheather it is expanded or not.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
     BOOL expanded = [_sectionStates[section] boolValue];

     return expanded ? [_foldersArray[section - 1][@"folders"] count] : 0;
}

Answer: initialize iSelectedIndex = -1; and declare
UITableView *urTableView;

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

return 10;    //Section count

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

return 3; //row count

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if(cell == nil)
{
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

}

[cell.textLabel setText:[NSString stringWithFormat:@"sec:%d,row:%d",indexPath.section,indexPath.row]];

return cell;

}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{

// adding a label with the tap gesture to the header in each section

headerLabel = [[UILabel alloc]init];

headerLabel.tag = section;

headerLabel.userInteractionEnabled = YES;

headerLabel.backgroundColor = [UIColor greenColor];

headerLabel.text = [NSString stringWithFormat:@"Header No.%d",section];

headerLabel.frame = CGRectMake(0, 0, tableView.tableHeaderView.frame.size.width, tableView.tableHeaderView.frame.size.height);

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(gestureTapped:)];

[headerLabel addGestureRecognizer:tapGesture];

return headerLabel;

}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

return 50.0; //adjust the height as you need

}

- (void)gestureTapped:(UITapGestureRecognizer *)sender{

UIView *theSuperview = self.view; // whatever view contains

CGPoint touchPointInSuperview = [sender locationInView:theSuperview];

UIView *touchedView = [theSuperview hitTest:touchPointInSuperview withEvent:nil];

if([touchedView isKindOfClass:[UILabel class]])
{

    if (iSelectedIndex != touchedView.tag) { //if new header is selected , need to expand

        iSelectedIndex = touchedView.tag;

    }else{   // if the header is already expanded , need to collapse

        iSelectedIndex = -1;

    }

    [urTableView beginUpdates];

    [urTableView endUpdates];

}

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

// Show or hide cell

float height = 0.0;

if (indexPath.section == iSelectedIndex) {

    height = 44.0; // Show the cell - adjust the height as you need

}

return height;

}

Comment: Just don't post a lot of code. Try to explain it. :)
Comment: It works perfectly! Thank's a lot. Many hours trying to find this solution.
Answer: For me it works to use:

on UITableViewDelegate
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    print("Did select row: \(indexPath.row).")

    tableView.beginUpdates()
    tableView.endUpdates()
}

on selectable/expandable UITableViewCell
override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
   configStyle(selected)
}

Important! tableView.rowHeight is .automatic  and UITableViewCell is constraint to enable automatic height calculation, i.e. its height constraint are clearly defined like constraint to top/bottom or height constraints added or label intrinsic content size is used.
Answer: To add to 0x7fffffff's answer, I found I needed an extra condition in the if statement within didSelectRowAtIndexPath - thus:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

   [tableView beginUpdates];

   if (self.expandedIndexPath && [indexPath compare:self.expandedIndexPath] == NSOrderedSame) {
       self.expandedIndexPath = nil;
   } else {
       self.expandedIndexPath = indexPath;
   }

   [tableView endUpdates];

}

Answer: Following this medium article on how to expand the cells based on the tap of a button and setting the numbersOfLine for a specific label, I was able to perform the animation using
tableView.beginUpdates()
tableView.performBatchUpdates({
  cell.description.numberOfLines = !expanded ? 0 : 3
}, completion: nil)
tableView.endUpdates()

Notice performBatchUpdates is only available in iOS 11⬆

UITableViewCell expand on click


Why won't my USB headset work OTG with my Honor 6x?

Question: I'm using an Honor 6x running EMUI 5.0. I bought an OTG cable recently, a female USB to male Micro-USB to use with this phone. I've connected a mouse and keyboard, and those worked fine. But, when I connect my Razer Kraken 7.1 USB headset, I get no audio or any sign a device is even connected. Is there a way to get my headset to work?
Answer: The lack of answer suggests this probably isn't worth pursuing, it probably depends upon phone, headset, and operating system. Another way this works out is with my LG G3 phone, Logitech A-0374A USB headset, and Android 6, with OTG cable: I get media sound through the headphone, but on phone calls neither the headphone nor the microphone is recognised, the phone's speaker and mic are used instead. I've looked at a couple of other places where this is discussed, with no resolution.


SSH into Ubuntu 12.10 from a remote computer

Question: I am trying to login to my Ubuntu 12.10 desktop remotely. I have the SSH server installed and it works fine when I am on the same network as the Ubuntu desktop. However, I am unable to connect remotely from anywhere. This is my first time setting up my own SSH server.
Comment: By remotely I assume you mean from the web? First off you would either need to know what the external facing IP is of the Ubuntu server and you would need to forward all SSH traffic on whatever port you are connecting from and listening to, (Usually port 22), to the Ubuntu machine on your router. \ Bear in mind most ISP's set up dynamic IP's for most non-business users so your IP can and will change. You would either need to speak to them about a static IP, or constantly check your IP before SSH'ing in.
Comment: Yes, I do mean from the web.
Answer: Here is what I do,

Set up port forwarding on your router, you really don't need to change the ssh port on the ubuntu box, just forward port X from the router to port 22 on the box.
Set up dynamic dns on your router if possible.  It will allow you to type "ssh firstname.lastname@example.com:port"  Look here for basics on dynamic dns.
Answer: You will need to forward the port in your router.
go here http://www.canyouseeme.org/ port 22 is the default for ssh. Though I recommend changing it for security sake.
If this can "see" 22 then it is setup for internet connection.
You may also need to set an iptables rule.
Comment: It does successfully see port 22. Which ip address am I supposed to use to connect remotely? The one I got from ifconfig or the one from canyouseeme.org. I just used the one from canyouseeme.org and it connected from a computer that is not on the same network.


How can I drop columns with zero variance from a numpy array?

Question: So using the following example:
import numpy as np
X = np.array([[1,10,np.nan,0],[2,10,np.nan,0],[3,10,np.nan,0]])

I can drop the all-NaN or all-0 columns like so:
 X = X[:,~np.all(np.isnan(X), axis=0)]
 X = X[:,~np.all(X==0, axis=0)]

I would also like to drop the zero variance columns, is there a good way to do so using the same concise notation?
Thanks!
Answer: You can.
import numpy as np

X[:, np.var(X, axis=0) != 0]

array([[ 1., nan],
       [ 2., nan],
       [ 3., nan]])

This calculates the variance of each column (axis=0) and then returns the ones not equal to 0.