How to mount TV to basement wall under stairs?

Question: I have a 55" TV I'd like to mount on a basement wall, which is located under the stairs. The area under the stairs is actually accessible, and I've gone back there to see what's available. It looks like there are studs there, but they're only 2 1/4" x 1 1/2"? Here is a picture:

Here the sloping ceiling is the underbelly of the stairs.
Is there any way to mount this TV to this wall safely and securely? Sorry if this is an easy question, I'm a complete novice at this.
Edit: some more photos.
Here's the front of the wall:

Here's some better pics of the back of the wall:
Comment: A photo with some context would help. It's not at all clear what framing is available and what that piece of hardware is. Chances are you can go ahead and mount to those studs though. Worst case scenario you see some flexing and add some cross-braces to tie things together behind the wall.
Comment: @isherwood: ok I'll edit and add some more photos from both sides of the wall. That thing in the pic is actually a recessed speaker. Would it make sense to add some cross-braces beforehand? And do you have any links on how to do that?
Comment: So where's the TV going? And I still don't really have a wide enough view to see what I'm looking at. What's going on at the right edge of the photos? Is that another wall coming in at a 90?
Answer: As you can see there was apparently already a TV mounted there beforehand.

The person who installed the dual speaker assembly cut off one of the studs and this could be of some concern. You could try to anchor that stud to the side of the stair support to make the stud more secure. Alternatively you could screw a flat 2x4 down (shown as red outline) on top of the lower plate just under the speaker assembly. Then a second flat piece of 2x4 depicted in the yellow outline could be screwed to the added red piece and into the stub of the stud above. The stud may need to be shimmed out with an appropriate piece of wood cut to size. From your pictures this looks like it would clear the rear end of that one speaker. Do use screws to fasten the pieces as the pounding of nails with a hammer would likely blister the nails/screws that hold the drywall in place. Since the added 2x4 pieces are relatively small it would also be advisable to use some construction adhesive to glue the pieces together before screwing. Once set the glue will make the assembly much more solid.

So as long as you put the sturdy mounting screws for the TV bracket into the studs in a proper manner (i.e. predrill with the correct diameter pilot drill) to prevent splitting of the studs you should be good to go.
Comment: Thanks for the answer! Yes the previous owner had a TV mounted there, but I was concerned because the manual for the mount I have suggested drilling into 2x4 studs. I've never mounted a tv under the stairs like this.
Comment: Also, in your very helpful picture, what is the red piece attaching to? The piece of wood beneath the speaker, or the speaker itself?
Comment: The red outlined piece would be laid flat on top of the existing lower plate or header block that itself is laying flat under the speaker unit. You would not want to attach anything to that flimsy plastic speaker frame.


Querying highest value by keys from database

Question: With the following table:
+-------------+-----------+---------+
|  Parent_ID  |  Item_ID  |  Count  |
+-------------+-----------+---------+
|      1      |     1     |    1    |
|      1      |     1     |    5    |
|      1      |     1     |    4    |
|      1      |     2     |    7    |
|      1      |     2     |    2    |
|      2      |     1     |    2    |
|      2      |     1     |    3    |
|      2      |     2     |    2    |
|      2      |     2     |    4    |
+-------------+-----------+---------+

I would like to get the highest available count for given Parent_ID and Item_ID, like the following:
+-------------+-----------+---------+
|  Parent_ID  |  Item_ID  |  Count  |
+-------------+-----------+---------+
|      1      |     1     |    5    |
|      1      |     2     |    7    |
|      2      |     1     |    3    |
|      2      |     2     |    4    |
+-------------+-----------+---------+

How would I go about doing this using LINQ/SQL in C#? For example, I would like the highest item counts for parent id 1.  This would be something like:
int parentId = 1;
var counts = from c in database.Items where parentId == c.parentId
//this gets all counts from items for parent id 1, but I am just looking
//for the highest count per item for parent id 1

Answer: SELECT Parent_ID, Item_ID, MAX(Count)
FROM ...
GROUP BY Parent_Id, Item_ID

Answer: select parent_id,
       item_id,
       max(count) as count
from your_table
group by parent_id, item_id

Answer: Using LINQ2SQL I think you want something like:
var counts = database.Items.GroupBy(p => p.parentId).Max(p => p.Key);

Comment: He wants to group on the pair of parentID and childID (not just parentID), although that's not a significant change from this code.
Answer: To group by multiple fields, you can group using an anonymous object:
var counts = from item in database.Items
             group item by new { item.ParentId, item.ItemId } into itemGroup
             select new Item()
                    {
                        ParentId = itemGroup.Key.ParentId,
                        ItemId = itemGroup.Key.ItemId,
                        Count = itemGroup.Max(x => x.Count)
                    };


ubuntu boots up once after boot repair disk, never again

Question: i have a toshiba satellite l15w-b1302.  i followed various instructions for making linux work on my computer even though it came with windows 8.1.  i wiped windows and installed ubuntu.  when i power up, it doesn't see any bootable operating system.  when i use boot repair, i get one shot. then something happens and it won't boot to anything unless i run boot repair again.
i've searched other threads for information, but boot up seems to be excessively technical with the help presuming knowlege i don't have.  if anyone knows what the problem may be, can you help me through it presuming i know very little?
Comment: Post the link to the Create BootInfo summary report. Is part of Boot-Repair:
https://help.ubuntu.com/community/Boot-Info
Answer: As someone else answered, disable secure boot... Also I would create a LiveUSB boot drive with either MBR/UEFI or GPT/UEFI with Rufus when building from an Ubuntu ISO.
When that's finished, press the Window Key on the keyboard (or click the window/start button), and type "recovery opt" and hit enter. Select Advanced Startup, the system will boot into a console, select 'Use a device' or 'boot to a device' and you should see your UEFI USB boot disk you just created if its plugged in... make sure you are using USB 3.0 port and not the USB 2.0 port and reboot to your UEFI thumb drive, and install Ubuntu. The Ubuntu install script will detect your are booting in UEFI mode and install Ubuntu/Grub boot loader as UEFI compatible. Legacy Bios mode on these Toshiba Satellite series (L15W) do not work very well at all.
When doing this, Windows will still want to be the primary bootloader, so you have to keep going into Win 10, then recovery console, and then booting from device, choosing Ubuntu, every time you want to use Ubuntu until you change the order in which boot loader is attempted to load first by Toshiba.
You can use this software to switch GRUB2 to be loaded before the Windows boot manager:
http://www.easyuefi.com/index-us.html
But this is the least of your worries. These Toshiba series (L15W) have hard freezes in Linux at seemingly random times (all distro's I have installed have the same issue, either debian based or rpm based, so it most likely is a kernel issue with how it deals with the Toshiba-wmi and Toshiba_ACPI kernel modules in Linux). I posted a temporary work around in a few posts today, hoping others who own these same series of Toshiba laptops will report the bug as well when (not if) they run into it.
(I have had 3 replacements with the vendor so far because of this issue, and they all have had this issue, I can't seem to find anyone out there that can get this laptop to work in Linux without hard freezes/lockups, without setting up CPU thermal triggers to lower the CPU frequency.. (Linux cannot turn on the chassis fan inside, let alone even find it. Works fine in Windows 10 though).
Answer: I own a Toshiba Satellite L15W-B1302 currently running Ubuntu 15.04, using Gnome. I had a lot of issues installing Ubuntu on my laptop until I found that I needed to uncheck secure boot in BIOS. Before I did this, the only time it would boot was from the liveUSB I was using to install. At first I tried to dual boot and figured this might be the issue, then I wiped windows 8.1 completely (after saving the recovery disk on another thumb drive). That's when I found a thread (I didn't save it as I as using the live version at the time) that told me to turn off secure boot. Hope this helps.
Comment: Very long winded way to say "turn off secure boot".
Comment: Us newbies need lots of information about stuff. A lot of replies I see from others who "know more" generally think the person asking questions knows all the things about linux, except what they are asking. I was in the same boat as he, doing the same things, so added extraneous information that might answer future questions. That is all.


Using for-while or some other sequence functions

Question: user> (for [n '(9) d '(2 3 5 7) :while (not= 0 (mod n d))] n)

It gives me,
user> (9)

And if I change the sequence in the list like this,
user> (for [n '(9) d '(2 5 3 7) :while (not= 0 (mod n d))] n)

Then it gives me,
user> (9 9)

Actually, I'm trying to get an empty list, if the integer n is divisible by any integer of sequence d; otherwise n. So, the question is, is there any seq function, or a combination of few, that can do the trick? Or do I have to use loop-recurr, or recursion, thing whatsoever?
Comment: Hi @AdeelAnsari, i think  '(n) is not an integer but a sequence with one integer, Are you right with this notion?
Comment: Yes, here it's a `seq`. Actually, `integer` is not allowed there in the `for` function. Sorry about that. I mean it can be a number if some function is fine with that.
Answer: I think that the function you are looking for is filter.

Returns a lazy sequence of the items in coll for which (pred item)
  returns true. pred must be free of side-effects.

The following function, divisible-by-fn, returns the number in the seq that is divisible by n
(defn divisible-by-fn [your-integer your-seq]
  (filter #(zero? (mod your-integer %))your-seq))
(divisible-by-fn 9 '(2 5 3 7))
=>(3)

... but, in case, you need to get an empty list, if the integer n is divisible by any integer, d, in the seq; otherwise n, then
(defn your-fn [your-integer your-seq]
(if-not (not-any? #(zero? (mod your-integer %))your-seq)
 ()
 your-integer)
)
(your-fn 9 '(2 5 3 7))
=> ()
(your-fn 11 '(2 5 3 7))
=> 11

Comment: I love this. Wait a while, let me try.
Comment: I suppose, I can't use this, `(filter #(zero? (mod your-integer %))your-seq)` as an argument to `recur`; because its a lazy sequence. Am I correct?
Comment: I've used the (next ..) function as argument on recur function, so it's clear that you can use lazy sequences inside recur or loop functions, no problem with this!


How to get Visual Studio Intellisense to discover an inherited subclass?

Question: I have a scenario where Visual Studio (2012) Intellisense is failing to recognize a subclass which is defined in an inherited class. It's probably best demonstrated with a simple example:
public class Shape {

    public class SubShape {
    }

}

public class Circle : Shape {
}

So I have a Shape class with a SubShape subclass, and Circle which inherits from Shape.
If I then try to instantiate an instance of SubShape with new Circle.SubShape(), I get no results from Visual Studio's Intellisense after new Circle.. Everything builds correctly with no syntax errors.
If I reference the class from the base class with new Shape.SubShape(), the Intellisense works. It works as well if I initially leave off the new keyword -- so typing Circle. presents me with SubShape as an option.
I'm using Visual Studio 2012, version 11.0.61030.00 Update 4.
Update: I have ReSharper disabled, but if I turn it on and choose to use ReSharper's Intellisense instead of Visual Studio's, everything works as expected.
Comment: Just disabled it and it looks like it is a ReSharper feature :(. I'll test with VS2013 Ultimate when I get home and see whether it exists there
Comment: Have you tried with 2013? I have 2013 (Professional) and Resharper and it works as you describe here. Not sure whether it is Reharper or VS2013 doing it though
Comment: Thanks! Can you try disabling ReSharper and see if it still works? I think you can do it easily through the Tools -> Options -> ReSharper dialog, on 2012 anyway. If I turn ReSharper on and choose to use ReSharper's Intellisense intead of VS's, it works for me as well... so in 2012 it seems to be a Visual Studio bug that ReSharper fixes.
Comment: Just tested, it is the Resharper's feature.
Comment: CodeRush also has this feature :)
Comment: This is no accident.  Whatever poor sap is going to maintain your code some day will lose clumps of head-hair trying to find that class back.  He'll look at Circle.cs and have no hope of finding it there.  There is no point in avoiding the true name of the class, inheriting it doesn't change it in any way.
Answer: It's probably an Intellisense bug (very minor), also happens in VS2010.
Oddly enough, declaring a variable do has Intellisense, that is both
Shape.SubShape s;
Circle.SubShape s;

when typed, will list Subshape after dot.


Install HDF (Hierarchical Data Format) and P3DFFT

Question: How do I install HDF(Hierarchical Data Format) and P3DFFT in ubuntu?
Comment: You don't *install* a data format. You install software that *use* or *understand* a certain data-format.
Comment: Hello to AU.  Please review [how to ask a good question](https://askubuntu.com/help/how-to-ask) and edit your question accordingly. Quote: _Have you thoroughly searched for an answer before asking your question? Sharing your research helps everyone. Tell us what you found and why it didn't meet your needs. This demonstrates that you've taken the time to try to help yourself, it saves us from reiterating obvious answers, and above all, it helps you get a more specific and relevant answer!_
Answer: HDF-related packages are presented in the official Ubuntu repository.
In order to install these you'll likely need to enable the Universe repository first with
sudo add-apt-repository universe.
About P3DFFT you should read its documentation on official web-site.


Build Record Root Directory in Jenkins

Question: I am working on jenkins.All my build information is stored in build record root directory.But I am having 3 users with their individual jobs and all the build information is been written into my Build Record Root Directory.Is It possible to have a seperate Build Record Root Directory for individual users so that the user can see only their job build information.
Answer: The following post describes step by step how to change Jenkins Workspaces and Build Directory Locations.

Build Record Root Directory in Jenkins


Compass: from 359 to 0 degrees

Question: I am trying to move a robot using a compass. We use the compass to make the robot move in straight line, it uses 2 wheels and they move a bit different.
So we set a value between 0 and 359 as direction, and then check the current direction, calculate the error and fix it. Like error = current_direction - actual direction.
The problem is that if for example our init direction is 90 degrees and our robot is at 45, the error will be 45 and it will fix it. If it is 0, the error will be 90 and it will fix it. The problem is that if it moves a bit more than 0 and it goes for example to 359, the error will be -269 so instead of moving 90 in one direction it will move -269 in the other.
I use the sign of the error to decide which wheel to move to fix the direction.
any idea how to fix it?
Answer: <code>if (error > 180) {
   error -= 360;
}

if (error < -180) {
   error += 360;
}
</code>
Comment: I've once had a robot that could get so confused that we had to change those `if`s to `while`s :D
Comment: @Jakub Hampl: Did you name it Dizzybot? :D
Answer: if your error is greater than 180°, you should rack it from 360 and invert the sign. Doing so, you can be sure your robot will always move in the shortest direction.
Answer: If your error is > than 180 degree simply switch your correction algorithm to calculate the correction by moving in the opposite direction. A simple if-else statement should do.
Answer: I don't know much about NXT and Mindstorm, but basically it is a common problem in circular motions. You could simply use two different coordinate systems and translate between each other, thats the most elegant way. Otherwise you could subtract 360 from your error, if the sign is negative, but that's a hack and not an elegant way to solve the problem ;-)
Comment: I was thinking in terms of CPU speed and all that comes with it. Although I'm not very familiar with the architecture, I wouldn't think that NXT has a quad-core i5 @ 2.8GHz, right? I'd guess the speed would be in tens of MHz, hundreds at the max. Yes, that's more than my computer had twenty years ago, but you still have to take performance seriously under such constraints.
Comment: Hmmm, polar coordinates? Elegant, but I'd think it might be slower to calculate (esp. on an embedded platform).
Comment: Yes, you could be right, since embedded things are mostly highly hacked things, but I don't think NXT is _such embedded_ ;-)

Compass: from 359 to 0 degrees


2 accordions side by side

Question: I want to create 2 different accordions as 2 buttons side by side of each other. How do I add 2 accordions to work as separate accordions? Here is my jQuery
jQuery(document).ready(function($) {
$( ".accordion" ).accordion({
  heightStyle: "content"
});
$( ".accordion" ).accordion({
    collapsible : true, active : 'none'
});
return false;
});

Comment: Those jquery queries both target all elements with the accordian class. You probably want to use either ID selection or give the two different elements different classes.
Answer: You would want to use unique selectors. Give them an ID an initialize them separately.
jQuery(document).ready(function($) {
  $( "#accordion1" ).accordion({
    heightStyle: "content"
  });
  $( "#accordion2" ).accordion({
    collapsible : true, active : 'none'
  });
  return false;
});

2 accordions side by side


How do I extend the 32-bit limitation in coldfusion?

Question: We've been using bit operations to offer users the ability to customize the sections of a report. Each section has a bit value, and the sum of all the sections that the user chooses to include is the user's preference. We can then use bit operations to determine which sections to display on the user's report.
However, ColdFusion bit operations are limited to 32-bit numbers, and the number of sections on our report may soon exceed this limitation. We'd like to develop a method to perform bit operations with 64-bit numbers and higher. Is there any built-in way to accomplish this in CF? If not, how can we go about accomplishing this manually? (i.e. breaking the 64 bit number into 2 separate 32 bit numbers, performing the bit operations, and joining it back together)
Answer: You could perhaps use a BigInteger instead?
Comment: But - to clarify - you don't need to do it "in Java" (ie: make a Java class to do it), you can do it from CFML, just calling your BigInteger object's methods.
Comment: So I would do all the bitwise operations in Java rather than CF?
Comment: Yes, you must use the [java bitwise methods](http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#and%28java.math.BigInteger%29) because the CF versions of those functions will throw overflow errors with larger integers.


What are classes and why use more than one (C#)?

Question: I am studying C#. As far as I understand, classes are where everything is happening. However, I have never used one more than one class in a script, nor do I know the actual definition of a class. So why have more than one class in a script and what is the definition of a class?
Comment: most systems are more than just a simple script that does one thing from start to end... if you don't need more than one class: fine, don't use more than one class
Comment: Do have a look at the .NET framework(s) and you will see many classes that are useful. Do not call c# code a 'script'!
Answer: A type that is defined as a class is a reference type. At run time, when you declare a variable of a reference type, the variable contains the value null until you explicitly create an instance of the class by using the new operator, or assign it an object of a compatible type that may have been created elsewhere:
<code>MyClass mc = new MyClass();
//Declaring another object of the same type, assigning it the value of the first object.
MyClass mc2 = mc;
</code>
That is great explaining from the C# guide by Microsoft.
You can read more from here
Answer: Classes serve two main purposes:

encapsulation - putting code into different locations rather than just having one great big pile of random methods
object orientation - having instances of classes (or value-types, in some cases) that represent a logical object (or value); you typically have many different concepts in a system, and many instances of each concept - for example, you might have a class to represent a "user", a class to represent an "order", etc (rather than just having a great big pile of random bytes as the data)


Reactive: Caching service response for few hours

Question: So my application would call below expensive HTTP service multiple times (simultaneously by multiple threads with same as well as different Ids for every client request to my application).
Mono<Foo> response = myService.fetch(id);

I would like to cache the response (in-memory) for few hours, and then only on next client request make only one call to refresh the cache.
Approach 1:
Mono<Foo> cachedResponse = Mono.empty();

public Mono<Foo> get(String id){
   return cachedResponse.switchIfEmpty(Mono.defer(()->
    {
       cachedResponse = myService.fetch(id).cache(Duration.ofHours(4));
       return cachedResponse;
    }));
}

is following approach OK? Specifically since multiple threads could call get method with same id. Also, when the cache is invalidated after 4 hours, would it make cachedResponse Mono empty for switchIfEmpty to work correctly?
Approach 2:
I could use some caching solution to store cache for few hours. e.g.
Foo getFromCacheSolution(String id);

and then,
public Mono<Foo> get(String id){
   Foo cachedFoo = getFromCacheSolution(id);
   if(cachedFoo != null){
      return Mono.just(cachedFoo);
   }
   else{
      return myService.fetch(id).doOnNext(value->storeToCacheSolution(id, value)); //line 7
   }
}

The problem with this solution is that line 7 would be called multiple times resulting in multiple calls to expensive fetch service (for example if 3 threads enter into get method with id 123 and cachedFoo is null). Making method synchronized may not help as line 7 would complete instantaneously.
One work-around would be to store Mono in the cache solution instead of Foo (not sure if that's a good idea or not):
Mono<Foo> getFromCacheSolution(String id); //returns cached or empty Mono

and then,
public Mono<Foo> get(String id){
   return getFromCacheSolution(id).switchIfEmpty(Mono.defer(()->
    {
       cachedResponse = myService.fetch(id).doOnNext(value->storeToCacheSolution(id, value));
       return cachedResponse;
    }));
}

Any recommendations or better alternatives?
Comment: I like the second solution more but maybe [caching helper](https://projectreactor.io/docs/extra/snapshot/api/reactor/cache/CacheMono.html) from reactor-extra project could help here?
Answer: Your question consists of two parts: about caching and about exclusive locking for calls with same parameters.

Caching.
Your second approach is good for in-memory cache. Alternatively you could use CacheMono from the reactor-extra
Mono<Foo> myFoo =
        CacheMono.lookup(key -> Mono.justOrEmpty(myCache.getIfPresent(key))
                .map(Signal::next), id)
                .onCacheMissResume(() -> myService.fetch(id))
                .andWriteWith((key, signal) -> Mono.fromRunnable(() ->
                        Optional.ofNullable(signal.get())
                                .ifPresent(value -> myCache.put(key, value))));

Exclusive locking for calls with same parameters.
Usually we should avoid any locking in the reactive world. But if you really need it, your lock should be nonblocking. I don't know any library, but you could find some ideas and links with examples in this question thread


Describe the automorphism group of $\operatorname{Aut}(\mathbb{Z}/9\mathbb{Z})$.

Question: a)Describe the automorphism group of $\operatorname{Aut}(\mathbb{Z}/9\mathbb{Z})$.
b) Prove that if a Group G has the trivial center then $|\operatorname{Aut}(G)| \geq |G|$.
My attempt:
a) Clearly, $\mathbb{Z}/9\mathbb{Z}$ is a cyclic group.
We know that the automorphism group of the cyclic group of order n is isomorphic to $(\mathbb{Z}/9\mathbb{Z})^{*}$, and an abelian group of order $\phi(n)$.
This implies $\operatorname{Aut}(\mathbb{Z}/9\mathbb{Z})$ is isomorphic to $(\mathbb{Z}/9\mathbb{Z})^{*}$.
Let $G=(\mathbb{Z}/9\mathbb{Z})^{*}$ and $|G|=\phi(9)=6$. By classification of order of 6 group, we have $G$ is isomorphic to $\mathbb{Z}/6\mathbb{Z}$ because $G$ is abelian and hence it is cyclic.
b)We know that $\operatorname{Inn}(G) \simeq G/Z(G)$, where $Z(G)$ denote the center of G.
Since $Z(G)=\{e\}$, then $\operatorname{Inn}(G) \simeq G$, and we know that $\operatorname{Inn}(G)$ is a normal subgroup of $\operatorname{Aut}(G)$.
This implies $|\operatorname{Inn}(G)| \leq |\operatorname{Aut}(G)|$, i.e, $|G| \leq |\operatorname{Aut}(G)|$.
Is both part of the question correct? This is first time for me to study this topic. Please suggest me any improvement in this solution. Many thanks in advance.
Comment: Please ask only one question per post. Having multiple questions in the same post is discouraged and such posts may be closed, see [meta](https://math.meta.stackexchange.com/q/6464).
Answer: Both answers are correct. Well done!
The intuition behind $(b)$ is that your group is maximally unabelian so conjugation gives for every choice of element a new inner automorphism.


How to retrieve an entity in JPA by table name at runtime?

Question: Is it possible to determine the entity class name by a native table name of an entity?
Some part of legacy code does only have a String value of the table (CUSM_LANGUAGE in this example), and I need to find the entity class name (LanguageEntity)
<code>@Entity
@Table(name = "CUSM_LANGUAGE")
public class LanguageEntity implements java.io.Serializable {
    private static final long serialVersionUID = 1L;
    @Column(name = "LANG_DESCRIPTION")
    private String description = null;
    ....
</code>
Answer: I guess it strongly depends on JPA which you're using.
In JPA 2.0 you have class: http://docs.oracle.com/javaee/6/api/javax/persistence/EntityManagerFactory.html
This class has getMetamodel() method which I expect to contains all information about your database.
In Metamodel (http://docs.oracle.com/javaee/6/api/javax/persistence/metamodel/Metamodel.html) you have getEntities() that's how we get: EntityType
I'm not sure how get from EntityType information about table it is using. But even it's not directly possible (which I doubt) you can do it as described below.
Because you have legacy code I expect you have JPA < 2.0 which doesn't have this getMetamodel method. That's why informations you can get about entities strongly depends on specific JPA you're using.
However if you have bunch of classes you care about (and you can create this list easily) you can create index on your own:
<code>String tableNameOfEntityClass = LanguageEntity.class.getAnnotation(Table.class).name();
</code>
So you can put all classes you care to list and then create map with key tableName and value refering class.
Of course it's not very useful without Metamodel which I described above because as well you can create ready map instead of List with entity classes.
Comment: This looks promising! I have legacy code, but I'm plugging in JPA 2.1
Comment: Could you share what you've found? or did you simply do this as I told you?
Comment: I got this working with your tip on the MetaModel, but I'm not succeeding in getting the exact table name. I have another post running for this.(http://stackoverflow.com/questions/21630213/code-example-to-retrieve-table-name-for-an-entity-in-jpa-in-runtime) Once completed, i will share the solution.


Parametrize set of unordered points in 3d space

Question: Let's assume that we have some set of points in 3d space sampled from some arbitrary surface, without self intersections and mostly flat. Is it possible to get any parametrization over this set of points?  And if it is - how?
My first idea was to find a plane (Maybe through PCA), or more sophisticated smooth surface which approximate this set of points, project each of these points on this fitted plane/surface and get corresponding parameters. But maybe there is better solutions for this problem.
Thanks for any help.
Comment: some type of [linear regression](https://en.wikipedia.org/wiki/Linear_regression) would help find the parameters
Answer: You could try natural neighbour interpolation or Sibson coordinates for this. These coordinates are based on a Voronoi tessellation of the points.
The coordinates have been extended to an approach where the points lie on some surface in this publication.


Issues when installing Ubuntu

Question: I am trying to install Ubuntu to a new Server.
Installation of Ubuntu 12.04 LTS 64-bit desktop didn't report any faults. However, the system cannot boot after installation. The screen stopped when filled with purple, and then USB power and VGA signal lost.
<code>Installation of Ubuntu 12.04 LTS 64bit server: cannot enter the installation program.
Errors reported:
udevd[355]: timeout: killing /sbin/modprobe -bc pci:XXXXXXXXXXXXXXXXXX
then kernel panic of the installation program.
</code>
Any suggestions? Thanks.
Comment: Welcome to AskUbuntu! You said that installation doesn't report errors then said that it reports. Please try recovery mode if you can and post outcome to the question body. Note that we need exact given messages to help.
Comment: I tried twice. The first version I installed is desktop version, which didn't report any error during installation. However, it failed to boot after that. So I switched to the server version, and it failed on the installation program. There may be hardware problems on the system, since I have been told just now that the server is using an alpha version of Intel's hardware.
Answer: did you try to disable acpi or acpi ext in the advance settings? Sounds most likely like it is a video-usb conflict.

Issues when installing Ubuntu


Android replace double quotes with one quote

Question: The string output is "data", "data1", "data2", "data3"
i want it to replace " with ' so the string output will be 'data', 'data1', 'data2', 'data3'
Thanks :)
Answer: use String class replaceAll method
Syntax: public String replaceAll (String regularExpression, String replacement)
In your case
String str = "data", "data1", "data2", "data3";
str = str.replaceAll("\"", "'");
System.out.println(str);

Then you will get output as
'data','data1','data2','data3'

From Android API, replaceAll says

Matches for regularExpression within this string with the given replacement.
If the same regular expression is to be used for multiple operations, it may be more efficient to reuse a compiled Pattern.
Answer: simply use String class to make this happen like:
String s = "data";
        String replace = s.replace( "\"",  "'");
        System.out.println(replace);

Answer:
Method 1:  Using String replaceALL
 String myInput = "\"data1\",\"data2\",\"data3\",\"data4\",\"data5\"";
 String myOutput = myInput.replaceAll("\"", "'");
 System.out.println("My Output with Single Quotes is : " +myOutput);

Output:
My Output with Single Quotes is : 'data1','data2','data3','data4','data5'

Method 2: Using Pattern.compile
 import java.util.regex.Pattern;
 String myInput = "\"data1\",\"data2\",\"data3\",\"data4\",\"data5\"";
 String myOutputWithRegEX = Pattern.compile("\"").matcher(myInput).replaceAll("'");
 System.out.println("My Output with Single Quotes is : " +myOutputWithRegEX);

Method 3: Using Apache Commons as defined in the link below:
http://commons.apache.org/proper/commons-lang/javadocs/api-z.1/org/apache/commons/lang3/StringUtils.html#replace(java.lang.String, java.lang.String, java.lang.String)


count total duplicates in js array

Question: I'm looping through all classnames in my html body.
I'd like to store the classname with textSize value. Each time there is a duplicate value for a given classname, I want to increment its textSize.
$("*").each(function() {
    classname = $(this).get(0).className;
    myarray.push({"className" : classname, "textSize" : 5});

Here, I attempt to sort the classnames, then get a count for each duplicate:
myarray.sort();
var current = null;
var dupCount = 0;

for (var i = 0; i < myarray.length-1; i++) {
    if (myarray[i]["className"] !== "") {
        if (myarray.indexOf(myarray[i]["className"]) == -1) {
            log(myarray[i]["className"]);
        }
        else {
            log("DUP");
            myarray[i]["textSize"] = myarray[i]["textSize"] += 5;
            dupCount++;
        }
    }
}

log(myarray[i]["className"]);, shown in the image below, clearly shows duplicates:

Yet, log("DUP"); is never called once. Why is that?
Moreover, why doesn't myarray.sort(); sort them alphabetically? If it did that, I could just do if (myarray[i]["className"] === myarray[i++]["className"]) { to check if the value equals the next value in the array. But sort doesn't work.

Edit:
So when looping through, I should be able to alter the css per classname, right?
for(var classname in classes) {
    console.log(classes[classname].textSize);
    var $val = $(classes[classname]);
    $val.css({
        "color" : "blue",
        "fontSize": $val.textSize+"px"
    });
}

This doesn't work even though console.log(classes[classname].textSize); gives text sizes per element
Answer: Try using an object instead of an array, using class names as the keys:
var classes = {};

$("*").each(function() {
    var classname = $(this).get(0).className;
    var c = classes[classname] ||
        (classes[classname] = { className: classname, textSize: 0 });
    c.textSize += 5;
});

for(var classname in classes) {
    console.log(classes[classname]);
}

Remember that any element can have multiple classes.  If you want to account for that, you'll have to split up the class names:
$("*").each(function() {
    var classnames = $(this).get(0).className.split(' ');
    for(var i=0; i<classnames.length; i++) {
        var classname = classnames[i];
        var c = classes[classname] ||
            (classes[classname] = { className: classname, textSize: 0 });
        c.textSize += 5;
    }
});

See this demonstration: http://jsfiddle.net/FSBhv/
UPDATE: the OP clarified that he wants to set the text size on the elements based on the number of elements that have that class.  Doing that will take a slightly different approach (we'll actually have to store the elements):
var eltsByClass = {};

$("*").each(function() {
    var $this = $(this);
    $this.get(0).className.split(' ').forEach(function(cname) {
        var c = eltsByClass[cname] ||
            (eltsByClass[cname] = []);
        c.push($this.get(0));
    });
});

for(var cname in eltsByClass) {
    var elts = eltsByClass[cname];
    $(elts).css('font-size', (elts.length + 1) * 5 + 'px');
}

Comment: Ethan, can you help me understand what is going on here? `var c = classes[classname] || (classes[classname] = { className: classname, textSize: 0 });`
Comment: Sure.  `classes` is an object that contains a record (another object) for each class name found.  Either the record already exists (`classes[classname]` is truthy, and `c` gets set to that), or it hasn't been created yet, in which case we create and assign it in the same step: `classes[classname] = { className: classname, textSize: 0 }`.
Comment: Okay thanks! I've updated above. I'm trying to set css on the class names. The more frequently they occur, the more the textsize gets incremented for that classname. For some reason, the css isn't being set
Comment: Oh, sorry, that part wasn't clear to me.  That's a slightly harder problem: you have to count them all first and THEN set their size.  I'll update my answer.
Answer: myarray.indexOf(myarray[i]["className"]) is a problem.
You know that myarray contains only objects, but you're asking for the position of a string within that list. That's never going to return anything but -1.
Consider using a second array to store the frequency count, instead of trying to do both with myarray.
var frequency = {};

myarray.forEach(function (i) {
  frequency[i.className] = frequency[i.className] || 0
  frequency[i.className]++;
}

Comment: And what happens when I have `...`? :)
Answer: Store your data in an object, not an Array. And it can be simplified as:
var classes = {};

$("*").each(function() {
    var classname = $(this).get(0).className;
    classes[classname] = (classes[classname] || 0) + 5;
});

for(var classname in classes) {
    console.log(classname + " textSize:" + classes[classname]);
}

Comment: `$(this).get(0).className` vs `this.className`?
Answer: This will hely you to sort array alphabetically based on classname
    var myarray=[];
$("*").each(function()
{
    classname = $(this).get(0).className;
    myarray.push({"className" : classname, "textSize" : 5});
});

function compare(a,b)
{
  if (a.className  b.className)
    return 1;
  return 0;
}

myarray.sort(compare);

count total duplicates in js array


thread doesnot update referenced variable

Question: #include<iostream>
#include<vector>
#include<cstdlib>
#include<thread>
#include<array>
#include<iterator>
#include<algorithm>
#include<functional>
#include<numeric>//accumulate

int sum_of_digits(int num, int sum = 0) {
    //calculate sum of digits recursively till the sum is single digit
    if (num == 0) {
        if (sum / 10 == 0)
            return sum;
        return sum_of_digits(sum);
    }
    return sum_of_digits(num / 10, sum + num % 10);
}

template<typename T, typename Iterator>
int sum_of_digits(Iterator begin, Iterator end) {
    //not for array temp workout
    T copy(std::distance(begin,end));
    std::copy(begin, end, copy.begin());
    std::for_each(copy.begin(), copy.end(), [](int& i) {i = sum_of_digits(i); });
    return  sum_of_digits(std::accumulate(begin, end, 0));
}

template<typename T, typename Iterator>
void sum_of_digits(Iterator begin, Iterator end, int& sum) {
    sum = sum_of_digits<T, Iterator>(begin, end);
}

template<typename T>
int series_computation(const T& container) {
    return sum_of_digits<T, typename T::const_iterator>(container.begin(), container.end());
}

#define MIN_THREAD 4
#define DEBUGG
template<typename T>
int parallel_computation(const T& container, const int min_el) {

    if (container.size() < min_el) {
#ifdef DEBUGG
        std::cout << "no multithreading" << std::endl;
#endif
        return series_computation<T>(container);
    }

    const unsigned int total_el = container.size();
    const unsigned int assumed_thread = total_el / min_el;
    const unsigned hardwarethread = std::thread::hardware_concurrency();
    const unsigned int thread_count = std::min<unsigned int>(hardwarethread == 0 ? MIN_THREAD : hardwarethread, assumed_thread) - 1;//one thread is main thread
    const unsigned int el_per_thread = total_el / thread_count;

#ifdef DEBUGG
    std::cout << "thread count: " << thread_count << "  element per thread: " << el_per_thread << std::endl;
#endif

    std::vector<std::thread> threads;
    threads.reserve(thread_count);
    using result_type = std::vector<int>;
    result_type results(thread_count);
    results.reserve(thread_count);
    auto it_start = container.begin();

    for (int i = 0; i < thread_count; i++) {
        auto it_end = it_start;
        std::advance(it_end, el_per_thread);
        threads.push_back(std::thread([&]() {sum_of_digits<T, typename T::const_iterator>(it_start, it_end, std::ref(results[i])); }));
        //threads.push_back( std::thread{ sum_of_digits<T,typename T::const_iterator>, it_start, it_end, std::ref(results[i]) });
        it_start = it_end;
        std::cout << "iterator " << i << std::endl;
    }

    results[thread_count - 1] = sum_of_digits<T, typename T::const_iterator>(it_start, container.end());
    std::for_each(threads.begin(), threads.end(), std::mem_fn(&std::thread::join));

    return series_computation<T>(results);

}

#define SIZE 1000
int main() {
    std::vector<int> array(SIZE);
    for (auto& curr : array) {
        curr = std::rand();
    }
    for (auto& curr : array) {
        //std::cout <<curr<< std::endl;
    }

    int series_val = series_computation<std::vector<int>>(array);
    std::cout << "series val: " << series_val << std::endl;

    int parallel_val = parallel_computation<std::vector<int>>(array, 25);
    std::cout << "parallel val: " << parallel_val << std::endl;

    return 0;
}

I am trying to calculate the sum of digits(recursive) of a randomly generated vector using std::thread but in the results vector only the result of the last element(i.e main thread) is stored and the child thread doesnot update the referenced results[i].
What is causing this behaviour?
Also, inside the for loop of parallel_combination, this code works
threads.push_back(std::thread([&]() {sum_of_digits<T, typename T::const_iterator>(it_start, it_end, std::ref(results[i])); }));

but this doesnot and the error is:  Error: '<function-style-cast>': cannot convert from 'initializer list' to 'std::thread'.
What's wrong with the below one?
threads.push_back( std::thread{ sum_of_digits<T,typename T::const_iterator>, it_start, it_end, std::ref(results[i]) });

Comment: Are you aware that you usually don't need to specify template arguments in function calls? For example `series_computation>(array)` should just be `series_computation(array)`. The template argument can be deduced from the function argument. With the explicit arguments I find my myself needing to check that the types are given correctly all the time when reading your code.
Comment: On an unrelated note, when you create the vector `results` you set the size of the vector. Then you `reserve` the same size which makes no sense.
Comment: @user17732522
in the second case, by saying `it works` i mean the code runs but doesnot update results while in the second code of second case, it just doesnot compile.Sorry for confusion.
Yeah, you are correct about the second problem. I changed the func name and it worked.
Answer: Your code has a data race here:
threads.push_back(std::thread([&]() {sum_of_digits<T, typename T::const_iterator>(it_start, it_end, std::ref(results[i])); }));
it_start = it_end;

The lambda uses it_start and then without any synchronization you immediately modify it in the main thread. Capture it_start and it_end by-copy. Also std::ref is pointless there. You are not passing a reference to the std::thread constructor, but just to a normal direct function call. Also, as I mentioned in the comments, template arguments in a function call can be deduced:
threads.push_back(std::thread([it_start,it_end,&results](){
    sum_of_digits(it_start, it_end, results[i]); }));
it_start = it_end;

threads.push_back( std::thread{ sum_of_digits<T,typename T::const_iterator>, it_start, it_end, std::ref(results[i]) });

fails, because there are two function templates of which sum_of_digits<T,typename T::const_iterator> could be a specialization. It is impossible to pass overload sets to functions and since there is no way to deduce which one you mean, it will fail.

There are some smaller issues in the code, e.g. pointless reserve after resizing/construction of vectors or
std::for_each(threads.begin(), threads.end(), std::mem_fn(&std::thread::join));

which is not guaranteed to work, because taking the address of a member function of a standard library function has unspecified behavior. Instead just use a loop:
for(auto& t : threads) {
    t.join();
}

and possibly some others.


StarUML defining interface methods and attributes in the interface icon?

Question: I'm just using StarUML to create my UML Class diagram and something is bothering me. I create an interface representation, which is a circle, however, there is no room to add which methods and attributes the interface defines. Is this normal UML practice?
If not, how do you know (say a class implements this interface and has 4 methods defined) which of the 4 methods came from the interface and which didnt?
Solved:
Ok just incase someone else has this problem- there are two notations, both are possible in StarUML but only one explicitly (the dot notation). To create the <> notation, enter the name as <> IInterface_Name and then draw a realisation line between the implementing classes. Be sure to manually delete the old (wrong) relationship you had by right clicking the class, collection editor and then relations.
Answer: It is very simple:

If you need just show method of interface - right click on interface and un-select Format/Suppress operation (see blue circle on picture)
If you need to display instead of circle just squared form of interface (on my picture it is ISome) use Format/Stereotype Display/Decoration (see red circle on picture bellow)
Comment: Thanks, i found another way- just to show the non-dot notation method, along with a realisation association
Comment: Thanks, I had the same issue and didn't know you could change the shape.  However it won't let me add any method declarations to the Interface. I've tried 'Add > Operation' but it just does nothing. How did you add the Operation2 to your ISome?
I'm using v2.0.0 mac.
Comment: DOH! You already answered that in point 1. I hadn't unticked Suppress Operations. Serious case of RTFSO.
Comment: Coming a bit too late to the party but wondered if it is possible to make it default interface to be drawn in squared <> shape... This should be standard no? I was surprised to see circle for interface
Comment: @Ewoks may be I don't get you question right, but if mean "Can I change <> onto smthng else" - then yes, you can. It is called stereotype. For some reason StarUML allows modify it for regular classes, but Interfaces are displayed with fixed
Comment: on your screenshot I see it under menu as circle, and next to it,not covered ISome with Operation2(), is how I would expect interface to be represented by default (instead of default circle that StarUML offers)
Comment: @Ewoks - yes, go to Menu\Tools\Options, select Environment\Specific View and scroll to "Interface View". For my version I can see "Show Stereotype = Icon" (or whatever you select)


Prove that for even $n$ and $x<-1$, $\sum_{k=0}^n\frac{x^k}{k!}>0$

Question:
Prove that, for even $n$ and $x<-1$, $\sum_{k=0}^n\frac{x^k}{k!}>0$

I have thought of making this factorisation:
$$x^n\left(\left(\sum_{k=0}^{\frac{n+2}{2}}\frac{1}{\left(n-2k\right)!}\frac{1}{x^{2k}}\right)+\left(\sum_{k=1}^{\frac{n-2}{2}}\frac{1}{\left(n-\left(2k+1\right)\right)!}\frac{1}{x^{2k+1}}\right)\right)$$
Since $x^n$ is positive, then if the parenthesis is positive, the sum must also be positive.
I have tried to find a lower bound and see how it behaves:
$$\left(\sum_{k=0}^{\frac{n+2}{2}}\frac{1}{\left(n\right)!}\frac{1}{x^{2k}}\right)+\left(\sum_{k=1}^{\frac{n-2}{2}}\frac{1}{x^{2k+1}}\right)<\left(\sum_{k=0}^{\frac{n+2}{2}}\frac{1}{\left(n-2k\right)!}\frac{1}{x^{2k}}\right)+\left(\sum_{k=1}^{\frac{n-2}{2}}\frac{1}{\left(n-\left(2k+1\right)\right)!}\frac{1}{x^{2k+1}}\right)$$
But the left sums sum to a negative number, close to zero past $-3$, but really low close to $-1$, so it doesn't actually work.
Any hints please? Thank you very much!
I have deleted the other post because of an error I have made and for the sake of a better explanation and a clearer presentation.
Mr. Eric Towers suggested in the other post that:

$$\sum_{k=0}^\infty \frac{x^k}{k!} = \mathrm{e}^x  \text{,}$$
  which is positive for all $x$, including $x<−1$. For $x<0$, this is an alternating series, where every even indexed term is positive. This means that the even indexed partial sums, which are the sums you ask about, are greater than $e^x>0$, so are positive.

I see that
$$\lim_{n\to\infty}\sum_{k=0}^{\frac{n+2}{2}}\frac{x^{2k}}{(2k)!}>e^x=\lim_{n\to\infty}\left[\sum_{k=0}^{\frac{n+2}{2}}\frac{x^{2k}}{(2k)!}+\sum_{k=1}^{\frac{n-2}{2}}\frac{x^{2k+1}}{(2k+1)!}\right]$$
but I don't see how it holds for finite $n$.
Comment: You might want to leave a comment to that effect with the other question. Someone spent time writing a suggestion for you there.
Comment: @copper.hat done, thank you.
Comment: Follow Eric's suggestion and consider cases ${|x| \over n} \le 1$ and $>1$ separately.
Answer: By Taylor's theorem with Lagrange remainder
$$
\sum\limits_{k = 0}^{2n} {\frac{{x^k }}{{k!}}}  = e^x  - \frac{{x^{2n + 1} }}{{(2n+1)!}}e^\xi   = e^x  + \frac{{\left| x \right|^{2n + 1} }}{{(2n+1)!}}e^\xi   > 0,
$$
where $x<\xi<0$ is a suitable number.
Comment: @W-t-P Yes you are :) Write $$
e^x  = \sum\limits_{k = 0}^{2n} {\frac{{x^k }}{{k!}}}  + \frac{{x^{2n + 1} }}{{(2n + 1)!}}e^\xi
$$ and re-arrange it.
Comment: I cannot see where the minus sign in the remainder term comes from; am I missing anything?
Comment: Thank you, Gary!


Integration with respect to an increasing integrator

Question: Could someone help me solve this question, please!
Let
$~~~ \alpha(x) = \begin{cases}
x & ,0 < x \leq 1 \\
2 + x & , 1 < x \leq 2
\end{cases}$
Compute $\int_{0}^{2} x ~d\alpha(x)$
I tried to solve it like this, but I'm not sure
$\int_{0}^{2} x~d\alpha(x) = \int_{0}^{1} x~d\alpha(x) + \int_{1}^{2} x~d\alpha(x) \\ ~~~~~~~~~~~~~~~~~~~= \int_{0}^{1} xdx + \int_{1}^{2} x d(2+x)$
Comment: Welcome to MSE. Your question is phrased as an isolated problem, without any further information or context. This does not match [many users' quality standards](http://goo.gl/mLWc8), so it may attract downvotes, or closed. To prevent that, please [edit] the question. [This](http://goo.gl/PlJyVQ) will help you recognise and resolve the issues. Concretely: please provide context, and include your work and thoughts on the problem. These changes can help in formulating more appropriate answers.
Answer: I'll assume that the integral is a Riemann-Stieltjes integral. We can use integration by parts, which states that if either $\int_a^b f(x) \mathrm{d}g(x)$ or $\int_a^b g(x) \mathrm{d}f(x)$ exists then the other one exists as well and
$$\int_a^b f(x) \mathrm{d}g(x)+\int_a^b g(x) \mathrm{d}f(x)=f(b)g(b)-f(a)g(a)$$
In your case, the other integral is much easier:
$$\int_0^2 \alpha(x)\mathrm{d}x=\int_0^1 x\mathrm{d}x+\int_1^2 (x+2)\mathrm{d}x=\frac{1}{2}+\frac{7}{2}=4$$
Which means that
$$\int_0^2 x\mathrm{d}\alpha(x)=4\cdot2-0\cdot0-4=\color{red}{4}$$
Comment: I think you are right. I made 2 edits here in your answer, sorry. Can you check them? Also, maybe it would be good to explicitly mention what is f(x) and what is g(x).
Comment: @peter.petrov Thank you for your edit. At the end, it should be $0\cdot0$, because $\alpha(0)=0$. $f$ and $g$ are just 2 generic functions.
Comment: Thank you very much, I appreciate that
@Botond
Comment: @Botond

Excuse me mr.Botond

I have another question if you have time, Please!

I tried to solve it in another way, by using the **Mean Value Theorem of the Integral**

Since $\alpha$ is increasing and $f(x) = x$ is continuous on $[0,2]$, then $\exists ~ c \in (0,2)$ s.t. $\int_{0}^{2} xd\alpha(x) = f(c)[\alpha(b) - \alpha(b)]$

I took $c = 1$ and got the result equal 4

,but is there any clue that proves that I can take $c=1$ from the beginning ?
I mean, it's just a guess no more no less
Comment: @IyadWalweel I don't think there is a general method to find the value of $c$ in an application of the MVT.
Comment: @Botond yes, I didn't find any method to find such c. Anyway, I will adopt your solution, Thank you again
Answer: $d(2+x) = d(x)$ so there's no problem here.
This integral is just  $\int_{0}^{2} x ~d(x)$
Do you know how to compute this one?
Comment: First of all, thank you, I appreciate that.
Yeah, I know how to compute this integral of course
the problem was that there are a lot of theorems that I fail to conclude a helpful result of them to solve this question.
Comment: @IyadWalweel This is not correct, because $\alpha$ is not differentiable at $x=1$ (it has a jump discontinuity).


Power-leveling in Neverwinter

Question: I was playing with a character to NeverWinter but left the game in level 16. Now I want to play with a friend who is in level 40. I want to rise level 40 as soon as possible. What is the best way for power-leveling?
I have heard that there are foundry quests for that but I can't identify them in the foundry quest list.
Answer: You can get a 25% experience buff by invoking at least twice each day.  That works for all forms of leveling:

Killing things
Quests (having a friend power level you here is a good idea)
Leadership tasks
Invoking XP gains

Additional tip for leveling a new character: Get 2 gold from an old character and buy the white quality control wizard companion.  It will nuke anything and everything out of your way up to around level 10, and is a decent companion until at least level 20.
UPDATE
With the introduction of alliances, you can level extremely quickly by running the hardest heroic encounters (HE's) in a stronghold. You can easily gain 4-5 levels in a 30 minute HE session and earn some nice treasure to boot.
Slot the best Azure enchantments you can get your hands on in Utility slots for a nice XP bonus.
Answer: Have your friend run though the areas you have access to. you will lose the XP for kills but completing quests is more important. So just have the powerful friend kill low level enemies and you focus on quest objectives.
Comment: Definitely doesn't take long to run through quests, which is the bulk of the experience earning. Don't forget to invoke a few times daily, too. The first invoke is worth a standard quest reward for your level, the second half, the third a quarter. It's good, free experience that adjusts to your level.

Power-leveling in Neverwinter


Process data with JavaScript after AJAX call (CakePHP 2.6.x)

Question: I want to fetch data from a controller method and return the data as JSON string, so JavaScript can process it.
I performed all the steps so Cake can handle JSON as described here.
AJAX call in view:
$.ajax({
     url: '/cake/workers/getWorkersAsJSON.json',
     async: true,
     success: function(data) {
        console.log("data: " + data);
     }
});

Controller method:
public function getWorkersAsJSON() {
    $workers = ClassRegistry::init("Worker")->find('list', array( 'order' => array('fullname' => 'asc'), 'conditions' => array('Worker.partner_id' => '6')));
    $this->set('_serialize', array('workers'));
}

I expected the data in the data variable of JavaScript but this is always null.
When I add return json_encode($workers); to the controller, then I get the data but I don't think that this is the idea behind this whole setup.
What do I have to do so JavaScript gets the data?
Answer: Add $this->set(compact('workers')) to the action. Currently you are only setting _serialize which indicates which var to serialize but not passing the $workers var itself to the view.


How to do GET request with parameters in UWP?

Question: <code>using Flurl.Http;
dataMapperSurvey = "url"
var responseJString = await dataMapperSurvey.WithHeader("AUTH_TOKEN", "335351").GetStringAsync();
</code>
Here I'm try to hit the url  with that specific Auth_token porvided in header.
If I check the response in Postman with POST I get an exception and If I do GET I get proper Response.
I don't know how to do GET request here, Can anyone Help?
Comment: That looks correct to me. Is it throwing an exception? If so please post those details.
Comment: It's Server side error with code - 500, which comes only when I POST, and all works well when I do a GET.
Comment: I assure you your code sample is doing a GET, not a POST. 500 can mean lots of things. Is the server-side code yours or a 3rd-party API?
Comment: It's mine, but it works when I check it through Postman with a GET request.
Comment: How to do GET request with parameters in UWP?
Comment: Sorry, just getting back to this. Is the server app .NET, such as Web API or MVC?
Answer: You've stated that you are receiving a 500 response (usually akin to an unhandled exception) from your own code on the server. This is where you should be focusing your debugging efforts, not on the client side. Assuming you web app is some flavor of ASP.NET that you can run locally in Visual Studio, here's how I'd approach it:

Debug your web app. Either put a breakpoint in the controller or break on all unhandled exceptions.
Investigate the exception details when you call the API with Flurl. Handle the exception and return a 400 (bad request) or something more appropriate, or if it's NOT a bad request, fix the code to handle it correctly.
If it's still unclear why Flurl call behaves differently than Postman, inspect the request from the server (headers, body, etc) and determine what's different.


How to restart game on same character?

Question: Ok so I'm replaying borderlands 2 on true vault hunter and I see that it says 'fast forward' after I do a couple missions. I click it (stupid decision) now I've fast forwarded the game when I wanted to re play it. Is there any way to restart my game on the same character?
I'm using a mac if it helps.
Comment: If you can play online, you could join a game at the start of True Vault Hunter mode and replay the missions with them.
Comment: aren't there an option to restart playtrough when you load a character ?
Answer: There is no way to revert the fast forward on the same character. Unless you're willing to grind through Normal again, you're stuck.
You will have another opportunity to do those quests in Ultimate Vault Hunter Mode, though, if you have purchased any level-cap-increasing DLC.

How to restart game on same character?


Steam doesn't recognize installed game

Question: I have an issue. I've been playing Total War Warhammer just fine and today when i "launched" the game the install window popped up. In short steam doesn't recognize this game. Just this game, my other games are fine. I even launched Total War Shogun 2 which is from the same company and i had no issue.
What i have tried so far:

The files of the game are still there were i left them
Deleting the download cache (failed)
Placing the Total War Warhammer file in another location and have
steam search that folder for possible games (failed)
There is no option for me to verify the integrity of cache since
steam doesn't see the game as an installed game

I don't know what else there is to do beside having to reinstall 30GB+ of files.
Comment: When Steam downloads a game, it actually checks which files it already has for that game and verifies them before requesting missing or invalid files. If the game files are actually correct, then the "download" stage will happen very quickly because all Steam has to do is verify the files that are there are correct.
Comment: Finally: Total War forums suggests there's some kind of free new content for Warhammer that's [available at some point today](https://forums.totalwar.com/discussion/190035/grombrindal-available-for-everyone-january-19-2017) (Jan 19th). It's not clear from the forums whether this has been released yet, but if it has it could be related to your issue somehow.
Comment: I made an edit to my post, i added a 4th bullet point to your suggestion raveturned, but thanks for the reply
Comment: Also: have you tried verifying the game cache for that game? See the Steam knowledgebase article for how to do this [here](https://support.steampowered.com/kb_article.php?ref=2037-QEUH-3335&l=english).
Answer: Matter solved, it's as Ravturned said. I had to "reinstall" it. What I did was go with the steps of the reinstallation.

Install the game.
Picked the folder (for the installation process) where my actual game located
Steam checked if there were any files of the game in that location
It found them, SOLVED

Steam doesn't recognize installed game


htaccess rewriting string.string to argument

Question: I've waste a few hours trying but can't get it working.
I have a /MyFolder folder with index.php and page.php
On the index I want to link to /MyFolder/Bibi.Bobo that would in real call /MyFolder/page.php?a=Bibi.Bobo
I can change the bibi/bobo separator if that's what cause the error.
I have tested on an online rewrite checher something working but it make my server into error500
RewriteRule ^MyFolder/([0-9a-z]+).([0-9a-z]+)$ /MyFolder/page.php?a=$1.$2 [QSA,NC]

-> /MyFolder/bibi.bobo devient ainsi /MyFolder/page.php?a=bibi.bobo
I would like to avoid the page.php to not create an infinite loop so I've tried:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^MyFolder/([0-9a-z]+).([0-9a-z]+)
RewriteRule /MyFolder/page.php?a=%1.%2 [QSA,NC]

But doesn't work neither.
Anyone could help solve this with a few explanations why my finding doesn't work ?
Thanks
Answer: I'd say this should work:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^MyFolder/page\.php
RewriteRule ^MyFolder/([0-9a-z]+)\.([0-9a-z]+)$ /MyFolder/page.php?a=$1.$2 [L,QSA,NC]

You could also modify your amtching pattern such that it does not use specifically definend character sets:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^MyFolder/page\.php
RewriteRule ^MyFolder/([^.]+)\.(.+)$ /MyFolder/page.php?a=$1.$2 [L,QSA,NC]

Note that obviously there must nor exist a file or folder called like the pattern you try to match...
If you get an http status 500, then you should check your http servers error log file to see what error actually occurred.
Comment: Works perfecty ! Seems I didn't escaped the '.' then ? \. Still a problem anyway, doesn't work with MyFolder/bébé.bobo dues to accents, I guess they don't match ?
Comment: ok it works with ([0-9áéíóúñÁÉÍÓÚÑäëïöüÄËÏÖÜçÇA-Za-z-]+)\.([0-9áéíóúñÁÉÍÓÚÑäëïöüÄËÏÖÜçÇA-Za-z-]+) but not really nice lol ! Many thanks arkascha !!!
Comment: Sure, those accented characters are _not_ contained in the character set you exclusively defined in your pattern. Question is if you actually _have_ to define such a set... I added such a variant to the answer.
Comment: Thanks, your last pattern works perfectly !! You saved my day, many thanks !
Comment: Glad I could be of help. And I am thankful for my reward in form of you upvoting or accepting the answer :-) Have fun!


How to loop through all object of the same type?

Question: For a project I want to check if a String is the same as a String attribute in one of my objects.
For example, I have 3 item object:
Item spotion = new Item("small potion", 5, 0, 0, 0, 0, 0);
Item mpotion = new Item("medium potion", 20, 0, 0, 0, 0, 0);
Item lpotion = new Item("large potion", 35, 0, 0, 0, 0, 0);

I would then want to check if
String s = spotion;

would equal any of the Item's name (first attribute);
Would there be any way to do this without creating an ArrayList of items to loop through but instead just see how many items there are and loop on when created?
Comment: `item.name.equals("some string")`
Comment: Possible duplicate of [How do I compare strings in Java?](https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java)
Comment: You need a public field or getter in the `Item` class to get to that first attribute.
Comment: I already have a getter the problem is that I don't know how I would setup a loop for the Items without having to creating an ArrayList where it can loop through.
Comment: You can use streams: `long count = Stream.of(spotion, mpotion, lpotion).filter(item -> item.name.equals(s)).count()`
Answer: To loop through the objects you would have to put them into an array first, like this:
Item[] items = new Item[] {
    new Item("small potion", 5, 0, 0, 0, 0, 0),
    new Item("medium potion", 20, 0, 0, 0, 0, 0),
    new Item("large potion", 35, 0, 0, 0, 0, 0),
}

Then you'd be able to loop through the array using the plain old for loop:
for(int i = 0; i < items.length; i++){
    //your code here
}

Or the enhanced for loop:
for(Item item : items){
    //your code here
}

To compare the variable all you'd have to do is compare the appropriate variable using equals:
if(item.yourVariable.equals(string)){
    //your code here
}

You can't compare the String directly to your object unless you override its toString method. Instead, you'll have to compare the desired property.
Comment: Just as a side note: When instantiating and assigning arrays directly to a variable the `new Item[]` can be omitted, else a good answer +1 :)


How to create small public/private keys using openssl and php?

Question: I need to create a public/private key, but I don't need big keys, I try to use the follow code:
<?php
$config = array('private_key_bits' => 128);
$res = openssl_pkey_new($config);
?>

but I get this warning:
Warning: openssl_pkey_new(): private key length is too short; it needs to be at least 384 bits, not 64

Do I have to change something? (config files, modules etc etc?)
Comment: Not needing big keys and needing small keys are two different things. Why not just use a bigger key? :)
Comment: @deceze I have to save it in a cookie :-) I need a small key
Comment: are you using the key for something that needs to be encrypted (ie needs to be kept secure)?
Comment: @MD-Tech sure, in mysql I have encypted data(users table), then I have a table where I put all the logged users, in this table I saved the ID and the password (to let the users decrypt his information) BUT i can put a plain password on this table, so I have created a pair of key private/public and encrupted that password with the public so the users with his private keywords can decrypt it and get the ORIGINAL password to decrypt the information on the users table. With this system I avoid the problem of storing a key to crypt/decrypt in the php files directly.
Comment: the problem is that a key of that size will provide no security other than a tiny portion of obfuscation as the key will be breakable in minutes. If you need to keep the data secure a key of that length is pointless. I think there is probably a much better way to do what you are trying to achieve but I have to work out what it is you are trying to achieve in my head before I can suggest a solution
Comment: @MD-Tech a 128 bi key is breakable in minutes? I think is not possible because most of SSL certificate works with 128 bit.
As I told you, I generate private and public keys, I save the encrypted password (with the public key) and then I decrypt it with private key. This solution is good (to me) because I do not save the key on the DB or in a PHP file, so if someone will see the script, will never see password/keys or other eprsnal infos
Comment: sorry miniutes was hyperbole (was pushing the point) key length for secure applications should be over 1024 these days because shorter keys are breakable in relatively short time scales:
"As of 2003 RSA Security claims that 1024-bit RSA keys are equivalent in strength to 80-bit symmetric keys, 2048-bit RSA keys to 112-bit symmetric keys and 3072-bit RSA keys to 128-bit symmetric keys. RSA claims that 1024-bit keys are likely to become crackable some time between 2006 and 2010 and that 2048-bit keys are sufficient until 2030."
if you do need to use this method just surpress the warning in php
Comment: @MD-Tech however it is pointless because suppose we develop a login page that send ENCRYPTED user/password, then the other pages that check if the users is logged HOW can they decrypt the informations that are stored on the db without saving the keyword to decrypt somewhere? If i use AES and then save the key in a php file or in a config file is pointless. "my system" prevent the storing of the plain passwords..I don't know any other system.
Comment: @MD-Tech The problem should be if someone can see the php files, if the server is not very secure with this kind of system nobody can read the password in php files nor mysql
Comment: normally you dont encrypt passwords you hash them and compare hashes because your users might not want you to (potentially) know their password as they commonly use it for other systems since a hash is deterministically unidirectional it is the better solution.
Comment: @MD-Tech yes, for passwords no problem, but, what do you do if you need to encrypt email? credit card? address or other personal information? the problem is there because if someone can read the db/php files can copy all, so I must to prevent this kind of situation
Comment: as I didnt know (I'm well away from web development currently!) I looked up the size limits on a cookie and they are 4kb each and you can create upto 20 per domain you should have space for a 1024 bit key even if you do have to use a dictionary lookup system between the cookies
Comment: @MD-Tech yes I know that limit, I will investigate if this solution is good or not. if you have any advice ley me know, thanks.
Answer: Upgraded to answer:
as I didnt know (I'm well away from web development currently!) I looked up the size limits on a cookie and they are 4kb each and you can create upto 20 per domain you should have space for a 1024 bit key even if you do have to use a dictionary lookup system between the cookies.
Also please make sure that the private key is sent using an ssl connection otherwise someone can intercept the private key and all your work will have been in vain


Shortcut to open a browser with a switch, such as -ssb or -kiosk

Question: I'd like to ask how to create a clickable shortcut in a folder (or desktop) to open a browser with a switch, pointing to a specific webpage.
Below example refers to open a webpage in a Single Site Browser (-ssb). But this could also be in kiosk-mode, such as using the -kiosk switch
In Windows, you right-click anywhere, on the desktop or in a folder to create a shortcut and type the following:
"C:\Program Files\Mozilla Firefox\firefox.exe" -ssb https://askubuntu.com/questions/ask"
Q: How does the corresponding step by step procedure looks like in Ubuntu (>18.04) ?

I have tried below
In other posts it is referred to a shortcut to firefox, but this necessary needs to live in the application folder, such as this post: How to create desktop shortcut for Firefox 79 on Ubuntu 20.04
And I am not permitted to drag and drop

"Drag and Drop is not supported / an invalid drag type was used"

when dragging the little keylock left of the address bar (https://askubuntu.com/questions/ask) in Firefox to a folder within Documents folder
How to create a desktop shortcut to a website
Below is promising but refer to a short-cut key, but very easy way of doing it How do i create a keyboard shortcut to open a chrome app?
Answer: You can write a simple line script for that purpose.

Create a file (name it whatever you want to and where ever you want)
#!/bin/bash

 # You can add "-kiosk" flag after firefox to open the window in kiosk mode
 firefox "https://www.askubuntu.com"  #(add any URL you want)

Give execute permissions with chmod +x filename
Then right click on file then --> properties --> permissions --> and tick on Allow executing file as a program
Then go to Open With tab and select Run Software as the default application to open the file with.

Now, you can click twice on the file to directly open link you desire in firefox
Comment: did exactly as above, (copy and paste your code into a new file and did 2, 3, 4), just get a spinning wheel in Ubuntu 20.10. Can you check on your side, and potentially corrent your answer, please.
Comment: Are you using ".sh" as an extension? If yes, remove it. If it still doesn't work remove the 'exec' command from the code.
Comment: strange, doesn't work, its a completely new install of Ubuntu 20.10, so no tampering/settings with bash etc.  I have -rwxrwxr-x  rights on the file which I call "test", created with touch and edited with nano.
Comment: Have you tried removing 'exec' command from the code and then running it(by double-clicking on it)? Or copy and paste code once again, I have made a couple of changes. And it still works on my machine.
Comment: from firefox --help  ...   I see an option ...   firefox --new-Window
Answer: Solution for your dock or application launcher (a .desktop file)
Option 1: Replacing the existing Firefox launcher
This method gives you the option to launch kiosk mode the same way you can launch private browsing - by right-clicking the icon on the dock or the application launcher and choosing a separate option there.

Copy the current desktop file (probably from /usr/share/applications/firefox.desktop) to ~/.local/share/applications/firefox.desktop.
Open it with a text editor.
Add this section to the end of the file:

[Desktop Action new-kiosk-window]
Name=Open a Kiosk Mode Window
Exec=firefox -kiosk

Find this line in the file:

Actions=new-window;new-private-window;

and replace it with
Actions=new-window;new-private-window;new-kiosk-window;

Save & exit. Log out of OS, log in.

Option 2: Adding an alternative Firefox kiosk launcher
Same as above, but:

Rename the file to /.local/share/applications/firefox_kiosk.desktop instead of having the same name.
Change the Name= and Description= to something you want and the Exec= line to firefox -kiosk instead of other changes to the firefox_kiosk.desktop file. If you want, you can also change the Icon=.


How do I deal with a joist in the way of where I need to run a pipe?

Question: I'm in the process of installing central vac lines (2" OD) in a finished house, and I am trying to run a line into the upstairs hallway. I have removed drywall in the garage below and drilled a hole down using an installer's bit, and found the hallway wall is sitting directly over top of a joist.

This is an ideal location as it is the only spot that allows me to reach every upstairs room. Any further and I have to open up walls on inside spaces, which I want to avoid.
There's a not-as-ideal alternative on a nearby adjacent wall (about 3' away) that would allow me to come down between joists, but the hose only reaches halfway into one of the bathrooms, so I'd prefer the original location if possible.
Is there a safe way to make this work? The challenge is that I will have to drill through a bit more of the joist to fit the 2" pipe in (as I already inadvertently did..).

Couple more images:

Full

Full

EDIT 2013-05-07:
I drilled a second pilot hole right at the edge of the bottom plate, and decided I had enough room to come in on an angle with a 2" hole saw. The "notch" on the 2x8 isn't any deeper than 1/4", you can actually still see the original pilot hole where I came through the joist (the groove nearest the camera). I'll need to use some flex pipe to hook this up because of the angle, but that is no big deal.

Do I still need to sister another 2x8 to this? How significantly is this really affecting the strength of the joist?

EDIT 2013-05-10
Got it done, using 2" ID flex pipe (typically used to hook up those under-cabinet vacuum sweep inlets). Thanks everyone.
Comment: A 2" notch on that size joist seems questionable...but I'll defer to the experts.
Comment: You can notch out enough of the top to put a 90 in without structural issues.  Are you able to do this or does it have to be a straight line down?
Comment: What's on the other side of that wall? Closet? Room? Hall?
Comment: nice. i would not.
Comment: Very nice.  I knew it would make it.  No bracing needed.
Comment: Looks good! Nothing additional needed there!
Answer: My answer is to cut your two inch hole as close to your drywall as possible.  In the picture you went right down the middle and barely hit the joist.  Methinks that you could drill right along the side and have to barely notch out the joist below.  Might not even have to notch all the way through it.  No reason for vac lines to have to be centered in your wall.  Use the notch guidelines I found to help further.

Notches in floor joists may occur in the top or bottom of the member but may not be located in the middle third of the span.
A notch may not exceed one-sixth of the depth of the joist except at the very end where it may be one-fourth of the joist depth.
The length of joist notches cannot exceed one-third of the depth of the member.
Holes bored in joists must not be larger than one-third the depth of the joists.
Holes cannot be located within two inches of the top or bottom edge of the member, or to any other hole located in the member.
Holes cannot be located within 2" of any notch.

Below is a helpful chart that provides actual notch and hole size limitations for 2x4, 2x6, 2x8, 2x10 and 2x12 joists. It should be noted that limitations on the allowable notching and boring of wood joist are meant to retain the structural and functional integrity of the member.
Comment: I doubt that a notch is suitable without additional reinforcement. Assuming that's a 2x8 or 2x10 joist, cutting a large enough notch to get a 2" elbow fitting in there is going to be way more than 1/6 the depth. Plus from the pictures it looks like it's in the middle of the span anyway.
Comment: An alternative is to call your city's permit department, tell them your joist size and tell them the notch size you want to cut, and see if it passes local code.
Comment: Nothing wrong with adding supports for the notch too.  The pipe will go out one side.  Can brace the other side.
Comment: Henry's point is well taken.  The table indicates the notch most likely would be egregious.  The brace would need to be substantial to meet code - might as well sister on a joist and make the rest of the task quiet easy., certainly less futzy.
Comment: The fact is that the pipe should not go right down the middle of the joist - meaning sticking out on both side.  He might be OK.  It will be close.  If not it is easy to brace or sister one side.
Comment: The only detail here is I wouldn't have to notch all the way though: I just need to remove about 1/2" to 3/4" of the width of the beam on one side, like this: http://i.imgur.com/X9hpql3.png. Then if the regular vac pipe doesn't flex enough, I could use a piece of 2" flex hose. @DMoore your chart deals with notching all the way though, how about only partially? Do I need to sister for this, and how long does the sistered beam need to be?
Comment: OK, based on your additional photos I'm a little more comfortable with the notch, since it seems likely that you're not in the middle 1/3 of the span. Do your best to keep the notch to less than 1/6 of the cross section. Since you can, I would also install a sister joist for the portion of the span that's accessible (*before* you cut the notch). It's not the end of the world if you can't sister the entire span, but gets as much overlap as possible.
Comment: Good pictures.  That is a very very easy joist to sister.  Probably be cheaper than a brace too.
Comment: I would at least use a partial wood bracing if doing a partial notch.  At least a 3 foot piece.
Answer: EDIT 2013-05-06 Afternoon:
Great new photo taken in the garage showing the joist layout.
In a nutshell, there is really nothing to worry about ... provided ...
A) the obstructing joist is not carrying a huge amount of weight from say a waterbed or massive safe
B) the joist is not carrying a huge amount of cantilevered weight (out to the left in the photo).
So ...
Given the new picture showing it is approximately a 4ft span, it'll be really easy.
I'd ...
1) Cut out a 12" or so section of the obstructing joist.
2) Use a large pair of vise-grips to pull any newly exposed nails through the subflooring.
3) Drill the 2-1/4" or 2-1/2" hole through the subfloor and the bottom plate of the hallway wall.
4) Install the vacuum pipe and fittings and wall receptacle at this point, before sistering on a new joist.
5) Cut a new two-by joist about 48" long to reach from the lap-joint near the I-beam to the wall support.  It should cut long enough to loosely butt at the lap joint and also sit on top of the double top-plate of the wall for 2"-6".
6) Use a skillsaw free-hand to rip about 1/2" off the width of this new joist.  For example, if its a 2x8, rip it from being 7-1/2" wide to 7" or 6-3/4" wide. This will make installation quite a bit easier.
7) Dry fit the new joist. Trim some if necessary so as to make it easy to maneuver the joist into place.
8) If the vacuum pipe is keeping the new joist from laying flat against the obstructing joist, you can cut some lengths of 1x2" or 3/4" plywood to place in between the two joists.
9) Optionally apply some construction adhesive (I would not)
10) Use 2-1/2" or 2-3/4" sheet rock screws to secure the new and old joists.
END OF EDIT 2013-05-06 Afternoon
EDIT 2013-05-06 Morning:  Good to know they are indeed parallel.  As a work around, perhaps the mfr/vendor sells a flexible coupling for situations like this, or perhaps a length of 2" ID thick-walled vinyl hose would work, or a length cut from a shop-vac hose of fortuitous diameter.  In any case, it would involve cutting an oval passage through the subfloor and the hallway wall's bottom plate by cutting two 'overlapping' holes, perhaps 1-1/2" dia, and 'cleaning up the sides of the oval with a sawzall or keyhole saw or chisel.
This flex-splice approach may or may not be feasible.  Being a work-around, like the notch+elbow method, there is a good chance that something unforeseen will come up that will prevent completion ... so I still favor a direct approach, such as sister+section or sister+chisel described below.
If you do choose the notch+elbow method, I'd suggest a 45 rather than a 90.  Also, when laying out the location of the hole, I'd take into account the OD of the female ends of any nearby fittings such as the elbow to the wall receptacle.  With the notch+elbow approach you might encounter nails under the bottom plate that were used to nail the subfloor onto the top of the floor joists.
Regardless of approach,  I'd reach into the cavity of the hallway wall with a putty knife to probe between the drywall and the bottom plate to check for drywall screws that the hole-saw would encounter.
Looking forward to additional photos.
END OF EDIT 2013-05-06 Morning
If the hallway wall is indeed running parallel to the floor joists, then I'm surprised that the joist underneath the hallway way is not doubled up.  But then maybe the hallway wall is just a few feet long, or maybe it's actually an extra joist.   I first would confirm the orientation by drilling a second pilot hole.
Assuming they are parallel, my inclination would be to first add an auxiliary joist on the non-problematic side, then use a sawzall with a long blade to cut out a complete section of obstructing joist (say 8" wide) to make room for the 2" OD pipe.  Some additional wide angle photos would help give a sense if this would be a feasible solution. If it is feasible, then depending on various aspects, I might cut out the 8" section first because it would be easier.  Another approach would be add the auxiliary joist, then drill the pipe hole from above from inside the hallway wall through the hallway wall's bottom plate, then on a step ladder in the garage, use a sharp 1-1/2" to 2" wide chisel to chisel out an adequate trough down the face of the obstructing joist.
The process of adding an auxiliary joist (which, by the way, does not need to run the full length of the existing joist) is called sistering.  With a skill saw, cut new two-by to length, then rip about 1/2" off it's width over the full length.  Dry-fit the auxiliary joist, apply construction adhesive, clamp in place, screw together with 3-1/2" sheet rock or deck screws, pre-drilling on the insertion side so that the screws will draw together the 2 two-bys.  The 2 two-bys will total about 3" in thickness.  Use 3-1/2" screws and angle them for a superior and clean looking job. If you are really good with a hammer, you could clamp and nail the two joists together with 16d bright common, but I'd use 16d galvy commons for their extra grip.  A pneumatic nail gun won't draw together the 2 two-bys.
If I was working alone, I'd screw or nail a couple lengths of one-by on the bottom side of the joists and perpendicular to the joists to hold the auxiliary joist in place once I lifted it up into place and applied the clamps.   I'd let the one-bys protrude about 3" beyond the obstructing joist into the bay that is going to receive the auxiliary joist.  I'd use three clamps, one on either end to hold the joist in place, and one to keep close to where I was screwing.
I'd be happy to go into more details. If I understand it correctly, the joist-photo is taken from inside your garage, looking up at the floor joists.  If you could take and post a couple more photos, it would be helpful, in particular:
1) A wide-angle photo shot from the level of the garage floor looking directly up at the proposed location.  This one should show as much of the joist layout as possible.
2) Photos of the 'other side' of the obstructing joist that show any potential issues with sistering an auxiliary joist on that side.
3) Photos that show how the obstructing joist is supported.
It would also be helpful to know the length and width of the obstructing joist.
Comment: I'm quite sure it's parallel, and that I've drawn the joist location correctly. The joists are supported on steel I-beams at both ends. I think the joist isn't doubled because this is a non-load bearing wall and it just happened to work out in this spot. My house is a bit strange because everything is offset: the edge of the garage is below the middle of the upstairs hallway, and there is 20% of another bedroom above the garage. This is not a great pic but I happen to have it available: http://i.imgur.com/9QDKVkI.jpg. I'll edit the post with a better one when I get home.
Comment: Also minor note, I will have to drill the 2" hole from the bottom, as I don't have a way to get a hole saw in the wall and drill down (nor do I have high hopes that would work well anyway -- a flex bit would be needed, which puts pressure on the drill bit, and hole saws tend to bind if you don't hold them straight).
Comment: Better pictures added to OP
Answer: Do you have unobstructed access all the way to the supports at the end of the adjacent joist bays? If so, you could slide in 2 new full-length joists. You might have to open up the ceiling at the other end to install joist hangers.
With 2 new joists in place you could notch your existing joist as big as you need.
Overkill, I realize. But sometimes overkill is the simplest solution.
Comment: Nope, ~half the joist goes beyond the back of the garage and is over finished ceiling, hanging on a header joist which I assume is sitting on top of another I-beam.
Comment: what I meant by unobstructed was no horizontal wires or plumbing through the joists farther back.  if not,  you might be able to insertr a new joist  by turning it 90 degrees so it lays flat,  slide it in and turn it upright.
Answer: In you picture of the drywall, there appears to be a door to the left. What's on the other side of that wall? Is is a closet? Cut a hole through the wall in to the closet and run you vac line down through the floor. Build a plywood or drywall box around it.
Comment: Actually that is definitely an option, though I'd prefer to keep it in the walls if possible.


ActiveMQ consumer level timeout

Question: I trying to create a consumer level timeout in Active MQ (version 5.15.0). Consider one message is picked by a consumer but not able to acknowledge so in that case i want consumer to timeout so that same message can be picked by other consumer listening to broker.
My Producer code where I am setting two consumer listener:
public class JmsMessageListenerAckExample {
  public static void main(String[] args) throws URISyntaxException, Exception {
    Connection connection = null;
    try {
      // Producer
      ConnectionFactory factory = createActiveMQConnectionFactory();
      connection = factory.createConnection();
      Session session = connection.createSession(false,
          Session.CLIENT_ACKNOWLEDGE);
      Queue queue = session.createQueue("customerQueue");
      String payload = "Important Task";
      Message msg = session.createTextMessage(payload);
      MessageProducer producer = session.createProducer(queue);

      System.out.println("Sending text '" + payload + "'");
      producer.send(msg);

      // Consumer
      MessageConsumer consumer1 = session.createConsumer(queue);
      consumer1.setMessageListener(
          new AckMessageListener(false, "consumer1"));
      Thread.sleep(1000);
      System.out.println("Creating new message listener to acknowledge");
      producer.send(msg);
      MessageConsumer consumer2 = session.createConsumer(queue);
      consumer2.setMessageListener(
          new AckMessageListener(true, "consumer2"));
      connection.start();

      Thread.sleep(3000);
      session.close();
    } finally {
      if (connection != null) {
        connection.close();
      }
    }
  }

  private static ActiveMQConnectionFactory createActiveMQConnectionFactory() {
    // Create a connection factory.
    final ActiveMQConnectionFactory connectionFactory =
        new ActiveMQConnectionFactory("tcp://localhost:61616");

    // Pass the username and password.
    connectionFactory.setUserName("user");
    connectionFactory.setPassword("user");
    return connectionFactory;
  }
}

This is my consumer listener:
public class AckMessageListener implements MessageListener {
  private boolean acknowledge;
  private String consumerName;

  public AckMessageListener(boolean acknowledge, String consumerName) {
    this.acknowledge = acknowledge;
    this.consumerName = consumerName;
  }

  public void onMessage(Message message) {
    boolean terminate = !acknowledge;
    try {

      System.out.println("ConsumerName="+consumerName+", Acknowledge="+acknowledge);
      if (acknowledge) {
        try {
          message.acknowledge();
        } catch (JMSException e1) {
          e1.printStackTrace();
        }
      }

      System.out.println(message);
    } catch (InterruptedException e) {
      e.printStackTrace();
    } finally {
      if (terminate) {
        Thread.currentThread().interrupt();
      }
    }
  }
}

I want to simulate in a way that consumer1 listen to message but does not acknowledge so that it timeout i am trying to release the thread, I am expecting my consumer2 to pick it up and give acknowledgement to the message so that message get moved from "Messages Enqueued" state to "Messages Dequeued" state in broker but my consumer2 is not able to receive any message events.
Is there something i am doing wrong. How do I achieve consumer level timeout with Active MQ?
Comment: This should be a good read for you https://www.pmichaels.net/2016/10/13/acknowledging-a-message-in-active-mq/
Answer: One way of handling this would be to use transactions (http://activemq.apache.org/how-do-transactions-work.html). You call commit() on success, rollback() on failure or if session is closed before calling the commit() then re delivery will occur (http://activemq.apache.org/message-redelivery-and-dlq-handling.html).
Comment: Ok I misunderstood the question. I thought you wanted to preserve the message in case if your consumer 1 dies while processing a message, and then you want consumer 2 to pick that up. But it seems you want to rollback from one consumer and want second consumer to pick up the message. I don't know if there is an ActiveMQ (neat) way of doing this. ActiveMQ is reattempting delivery (in round robin fashion). I am not sure what is your end goal but would sending a copy of same message to both consumers work for you? If yes, you can use composite destinations for that.
Comment: Even with transacted session and doing rollback still same consumer is picking the message. Is there any other configuration that I need to set?

ActiveMQ consumer level timeout


Can there be more than four types of polygons meeting at a vertex?

Question: Can there be more than four different types of polygons meeting at a vertex? How?
(The polygons must be convex, regular and different)
There are two ways to fit 5 regular polygons around a vertex, what are they?
(The polygons must be regular, they may not be of different types)
Comment: There are two distinct arrangements for one of the sets of five.
Comment: @MarkBennet What are they?
Comment: If you have three equilateral triangles and two squares you can have the squares adjacent or not. There is one arrangement of four triangles and a hexagon.
Comment: Wod there not be another arrangement of five consisting of four triangles and a pentagon?
Answer: If you are in the Euclidean plane, start with a circle and divide it into $n$ equal pieces using radii from the centre. Each piece can be completed as a polygon with as many additional sides as you choose, approximating the circumference of the circle.
Obviously these are not regular. A square has a right-angle at a vertex, and if you have five different regular polygons meeting at a vertex, four of them will have four sides or more, so will not fit as the total is already more than four right-angles.
In fact you can't fit four different regular polygons either - a triangle and a hexagon make  straight line and a square plus a pentagon are more than a straight line - so the four smallest angles don't do it.
Comment: I've added more to the question, but regardless, thank you.
Answer: If they don't need to be regular, then you can have any number of polygons meeting at a vertex. In this case, the angle at a given vertex can be as small as one wants to, and therefore there can be as many meeting at a given vertex as one desires.
If they have to be regular, but they need not be different from each other, I guess the maximum is 6. The smallest angle between two adjoining sides in a regular polygon is 60 (in a triangle). Therefore you can fit 6 in 360º.
If they have to be regular and different from each other, I think the maximum is 3. You can use a triangle (60º) a square (90º) and a pentagon (108º), and there will be 102º left, which is smaller than needed to fit an hexagon (120º).
Answer: The answer strongly depends on what are the rules to follow. What is your intended setup?
Shall your derived polyhedron be convex, or does it not need to? Or would you truely intend to speek of polyhedra, or would euclidean or even hyperbolic tilings be allowed as well? Are those "types of polygons" intended to be distinguished by shape, or maybe only by colour?
--- rk
Comment: Edited my question c:


Calling a web service from a scheduled task in Kentico 9

Question: I am working on a scheduled task in Kentico and I need the task to call methods that exist in a separate web service. I'd like to know if it's possible or not and how to do that.
Answer: When connecting and interacting with web services there are no extraordinary steps that you have to take. There is a sample service present in  CMSPages/WebService.asmx. that you can use as a reference to creating your own web service and you are free to add your own "asmx" handlers as you would to any other .NET application. Kentico is in the end a standard .NET application and you can create those without any problems.
Additionally I would recommend to using Web API 2.0 instead of the old asmx handlers. In order to see how you can create such web service you can check documentation which contains an example.


Perl - CGI::Application - Create session variables from database

Question: I have a bunch of configuration variables stored within a database, key value pairs accessable via the following query:
select * from conf_table;

I want to load these key/value pairs into a CGI::Applicaiton session. At the moment this is manually done (so not from database, but hardcoded) via
$self->session->param( NAME => VALUE );

For a bunch of key value pairs. Is there a more sensible way do to this with DBI and some form of loop?
Thanks
Comment: what kind of database?
Comment: It's an Oracle database, I can connect to it via DBI, I'm essentially asking how to do this with DBI (the most sensible way to do so) and how to assign the results to CGI::App::Sessions, again the most sensible way.
Answer: You mean something like this?
my $sth = $dbh->prepare("select key, value from mytable");
$sth->execute;
$sth->bind_columns(\(my ($key, $value)));
while ($sth->fetch) {
  $self->session->param($key => $value);
}

Comment: This seems to be exactly what I'm looking for. Thanks
Answer: DBI has some convenience methods that make this sort of work simpler. Try selectall_arrayref:
my $configs = $dbh->selectall_arrayref(
    'SELECT * FROM conf_table',
    { Slice => {} }, # make each row a hash
);
$self->session->param($_->{key} => $_->{value}) for @$configs;