Can't access R.class from Unity Android project

Question: I'm have an Android library that I'm now building a Unity3D plugin for. The Android library performs reflection on the R.Styleable class to retrieve data on a 'declare-styleable' resource to achieve something similar to this.
The first step is the following:
Field[] fields = Class.forName( context.getPackageName() + ".R$styleable" ).getFields();

The above line executes no problem when the library is run as part of a native Android project in Eclipse. However, when run through a Unity Android app, it throws a NoClassDefFoundError.
(same happens if you replace ".R&$styleable" with simply ".R" above).
I've read many accounts that Unity does not generate a R.class file. Is this true? I know that a R.java file is generated in Unity's "StagingArea/gen" folder, at least. If so, is there no other way to dynamically access resources in a Unity Android project than through Context.getResources()?
Answer: You can try below code.
final R.drawable drawableResources = new R.drawable();
        final Class<R.drawable> c = R.drawable.class;
        final Field[] fields = c.getDeclaredFields();
        int resourceId;
        for (Field field : fields) {
            try {
                resourceId = field.getInt(drawableResources);
                //TODO do something
            } catch (Exception e) {
                continue;
            }
        }


To enable Bluetooth adapter in Lenovo G50-30 in 14.04

Question: I know this thread Enable bluetooth on lenovo ideapad y480.
I recall having problems with the Wifi connection with this laptop, similar thread here.
Now, I noticed that I get the error no bluetooth adapters found when trying to connect to the laptop my bluetooth devices.
This laptop has bluetooth adapter so the thing is in software.
lsusb does not give the following but not bluetooth adapter
Bus 001 Device 006: ID 0cf3:3004 Atheros Communications, Inc.
Bus 001 Device 005: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 001 Device 004: ID 5986:0652 Acer, Inc
Bus 001 Device 003: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 001 Device 062: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-I9300 Phone [Galaxy S III], GT-P7500 [Galaxy Tab 10.1]
Bus 001 Device 064: ID 046e:52cf Behavior Tech. Computer Corp.
Bus 001 Device 002: ID 8087:07e6 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

My kernel is the newest Linux 3.16.7-ctk11.
Outputs from Jyjyc's commands which I had to run now in Debian 8.1, since I do not have the latest Ubuntu anymore on this disk.
The command uname -r gives 3.16.0-4-amd64.
The lsusb gives still the same as above.
The command lspci gives
00:00.0 Host bridge: Intel Corporation Atom Processor Z36xxx/Z37xxx Series SoC Transaction Register (rev 0e)
00:02.0 VGA compatible controller: Intel Corporation Atom Processor Z36xxx/Z37xxx Series Graphics & Display (rev 0e)
00:13.0 SATA controller: Intel Corporation Device 0f23 (rev 0e)
00:1a.0 Encryption controller: Intel Corporation Atom Processor Z36xxx/Z37xxx Series Trusted Execution Engine (rev 0e)
00:1b.0 Audio device: Intel Corporation Atom Processor Z36xxx/Z37xxx Series High Definition Audio Controller (rev 0e)
00:1c.0 PCI bridge: Intel Corporation Device 0f48 (rev 0e)
00:1c.2 PCI bridge: Intel Corporation Device 0f4c (rev 0e)
00:1c.3 PCI bridge: Intel Corporation Device 0f4e (rev 0e)
00:1d.0 USB controller: Intel Corporation Atom Processor Z36xxx/Z37xxx Series USB EHCI (rev 0e)
00:1f.0 ISA bridge: Intel Corporation Atom Processor Z36xxx/Z37xxx Series Power Control Unit (rev 0e)
00:1f.3 SMBus: Intel Corporation Device 0f12 (rev 0e)
02:00.0 Network controller: Qualcomm Atheros QCA9565 / AR9565 Wireless Network Adapter (rev 01)
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 10)

The command lsmod | egrep -i 'blue|bt|rfcomm' gives
btusb                  29721  0
bluetooth             374429  2 ath3k,btusb
6lowpan_iphc           16588  1 bluetooth
rfkill                 18867  4 cfg80211,bluetooth
crc16                  12343  2 ext4,bluetooth
usbcore               195340  7 ath3k,btusb,uvcvideo,rtsx_usb,usb_storage,ehci_hcd,ehci_pci

How can you force enable bluetooth in 14.04?
Comment: What is your kernel version? `uname -r`?
Comment: And please give output of `dmesg | grep -i blue`
Comment: Please provide output for `dmesg | egrep -i 'blue|firm'`
Comment: @Masi Why do you provide information other than you are asked to provide?
Comment: I provided information what was asked but he removed his answer. I provided thr info in debian because I have it now only with me.
Answer: Do and install Bluetooth control manager blueman
sudo apt-get install blueman

Problem not in drivers but in controlling bluetooth.


How to detect that macro is already used in current scope?

Question: I would like to make a macro-like object that can detect its use in the current scope and behave differently in such a case. For example, consider the following fragment of code
#define FOO /* expand to printf("first time\n"); or printf("not a first time\n"); */

{
   FOO // prints "first time"

   FOO // prints "not a first time"

   {
       FOO // prints "first time"

       FOO // prints "not a first time"
   }

   FOO // prints "not a first time"
}

Is it possible to make this with macro or any other language element in C++?

For people curious why I need this: I would like to make an easily copy-pastable macro FOO that I can put everywhere to get time spent in code fragment between two occurrences of it.
For example:
FOO // initialize timer
// code fragment 1
FOO // print the time spent in code fragment 1
// code fragment 2
FOO // print the time spent in code fragment 2
// code fragment 3
FOO // print the time spent in code fragment 3

Comment: Why do you need this?
Comment: Why should the third print "first time", even though two other uses are in scope? BTW: Make sure you understand what a so-called XY Problem is!
Comment: @UlrichEckhardt because it is in a new more nested scope denoted by `{` and `}`
Comment: [What is the XY problem?](https://meta.stackexchange.com/q/66377/409109)
Comment: @AyxanHaqverdili I added an explanation of my use case for it.
Comment: Macro expansion is token substitution.  It's not terribly sophisticated, even though some rather amazing macros have been created.  What is being asked for here is beyond the scope of what token substitution can do with the preprocessor.  (There are other preprocessors that are more capable, but that is probably outside the scope of the question.)
Comment: What do you mean by "time spent in code fragment between two occurrences of it"? As in milliseconds?
Comment: @AyxanHaqverdili Yes, it may be in milliseconds or any other unit of measurement (clocks, seconds).
Answer: You can create a scoped timer class:
#include <chrono>
#include <iostream>
#include <thread>

class ScopedTimer {
    using clock = std::chrono::steady_clock;
    std::chrono::time_point<clock> _begin;

public:
    ScopedTimer() : _begin{ clock::now() }
    {}

    ScopedTimer(ScopedTimer const&) = delete;
    ScopedTimer& operator=(ScopedTimer const&) = delete;

    void print_duration() {
        using namespace std::chrono;
        auto const duration = duration_cast<milliseconds>(clock::now() - _begin);
        std::cout << "Duration: " << duration.count() << '\n';
    }
};

int main() {
    ScopedTimer timer{};
    std::this_thread::sleep_for(std::chrono::seconds(1));
    timer.print_duration();
    std::this_thread::sleep_for(std::chrono::seconds(1));
    timer.print_duration();
}

Comment: Unfortunately, it is not enough for me. I would like not to only measure time spent in scope but in different fragments of code inside the same scope.
Comment: @user create more scopes around the area you're measuring?
Comment: This is a problem since sometimes these areas may contain variable declarations, so mindless copy-pasting of timer scopes can break the code. This is a drawback for my use case as I want to be able to quickly insert/remove measurement code without spending more time than a single paste operation on it.
Comment: @user How about a `print_duration` method? see the update
Comment: It is a nice implementation of the timer, but I need a bit different thing. Sorry, maybe my later explanation of the use case for timing made you think that my issue is with timing, but it is actually about fast copy-pasting of measurement code. It is too cumbersome to think each time that I need to put `ScopedTimer timer{};` for the timer initialization or `timer.print_duration();` for printing. Instead of these two functions, I would like to use something like `Timer::initialize_or_print()`.
Comment: @user I doubt such a thing is possible. Just make `ScopedTimer` a no-op in release mode, and place it at the top of all scopes. Then you call `print_duration` without thinking about the timer.
Answer: C Preprocessor macros are often discouraged. Although in your case, you are using them to reduce the repetition of printf("first time\n"); and reducing repetition in code is a good thing. Assuming that we only want to consider macro-based solutions, this is what I would do:
#define FOO_FIRST printf("first time\n");
#define FOO_ADDITIONAL printf("not a first time\n");
{
   FOO_FIRST // prints "first time"
   FOO_ADDITIONAL // prints "not a first time"
   {
       FOO_FIRST // prints "first time"
       FOO_ADDITIONAL // prints "not a first time"
   }
   FOO_ADDITIONAL // prints "not a first time"
}

Your originally-posted solution was trying to use a single FOO for both FOO_FIRST and FOO_ADDITIONAL, as a "convenience" to the macro-user. My suggestion is to resist the urge to crease such a "convenience", because what it really does is hide the fact that it is doing something different depending on which expansion it is. Don't hide that fact from the macro-user -- in my opinion, it's not a good thing to have the macro-user using a macro "without thinking". Instead, programmers should be thinking about the effects of the code that they write, and the resultant code is more readable when the usage of two separate macro names makes it clear that the programmer is doing two separate actions.
Using macros to reduce repetition is justifiable; using macros to obscure the programmer's intent is something I wouldn't do.
In your reply to one of the other potential solutions, you indicated that you wanted a macro to have an effect something like a context-sensitive function that was named Initialize_Or_Print(). This fact is an indication that you are going down the wrong road. Programming constructs should have single, clear purposes. Whenever you start to get the feeling that you are needing to cram too many separate purposes into one construct (Initialize_Or_Print_Or_SpawnNewPlayer_Or_BoilWater() is the direction you're headed), it's probably a bad thing and should be factored into separate pieces.
Comment: Unfortunately, it doesn't answer the question because I would like to have a single macro FOO to be able to copy-paste it without thinking is it the first occurrence of it in the scope or no.
Comment: I totally agree with your thoughts about providing such macro FOO for external users if it has multiple intents since it makes code harder to read and analyze. However, my use scenario is a bit different: I will be the only user of such macro to identify performance bottlenecks in the code. After such bottleneck is found, I will remove all occurrences of it (it will be extremely simple to replace `FOO` by empty space), so it will not even go into version control and no other people will ever see it.
Answer: How about this one?
#define FOO(block) /* The code section to time */ \
do{                                               \
    /* code for start of timing */                \
    { block }                                     \
    /* code for end of timing */                  \
while(0);                                         \

Comment: This may break if `block` contains variable declarations
Answer: You can make a macro that modifies each time. (at least in gcc and I believe in msvc too):
// (only tried in gcc)
#define FLIPFLOP  (__COUNTER__ % 2)

#define FOO std::cout <<(!FLIPFLOP ? "flip\n":"flop\n");

#include <iostream>
int main()
{
  FOO
  FOO
  FOO
  FOO
}

but you can't by nature make the preprocessor depend on source code block scope, since what { or } actually means is only determined later by the parser. The preprocessor knows nothing about it.
There are various proposals for "compiletime programming" for example http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2320r0.pdf, but whether they will address this type of use, I don't really know
Answer: #define FOO  { if(!foo_check) std::cout << "first time" << std::endl; else std::cout << "not a first time" << std::endl; foo_check=!foo_check; };

pretty obvious, i'd say, with the caveat to define
bool foo_check=false;

at the right level, for example at the start of the function, at start of main or as global variable for a file scope.
Said so, I use a timer class as per @Ayxan Haqverdili answer.
Comment: It seems to flip again at the third occurrence of FOO, so it will print "first time" again even if it is actually not
Comment: Yes, the example at the end of question made me think he wanted to alternate the printf. it could be corrected setting foo_check=true instead of !foo_check inside the macro. But you have also to redefine foo_check inside the blocks, to reset the behaviour in the blocks.
Answer: Building on ...an answer that was deleted while I was typing this. You can get the timer behavior you want via RAII and macro expansion:
BuildConfig.hpp

//...
#ifdef _DEBUG
#  undef PROFILE_BUILD
#else
#  define PROFILE_BUILD
#endif

#define TOKEN_PASTE_SIMPLE(x, y) x##y
#define TOKEN_PASTE(x, y) TOKEN_PASTE_SIMPLE(x, y)
#define TOKEN_STRINGIZE_SIMPLE(x) #x
#define TOKEN_STRINGIZE(x) TOKEN_STRINGIZE_SIMPLE(x)
//...

ProfileLogScope.hpp
#pragma once

#include <chrono>
#include <string>

class ProfileLogScope {
public:
    explicit ProfileLogScope(const char* scopeName) noexcept;
    ~ProfileLogScope() noexcept;

    ProfileLogScope() = delete;
    ProfileLogScope(const ProfileLogScope&) = delete;
    ProfileLogScope(ProfileLogScope&&) = delete;
    ProfileLogScope& operator=(const ProfileLogScope&) = delete;
    ProfileLogScope& operator=(ProfileLogScope&&) = delete;

protected:
private:
    using time_point_t = std::chrono::time_point<std::chrono::steady_clock>;

    const char* _scope_name = nullptr;
    time_point_t _time_at_creation{};
};

#if defined PROFILE_LOG_SCOPE || defined PROFILE_LOG_SCOPE_FUNCTION
    #undef PROFILE_LOG_SCOPE
    #undef PROFILE_LOG_SCOPE_FUNCTION
#endif
#ifdef PROFILE_BUILD
    #define PROFILE_LOG_SCOPE(tag_str) ProfileLogScope TOKEN_PASTE(plscope_, __LINE__)(tag_str)
    #define PROFILE_LOG_SCOPE_FUNCTION() PROFILE_LOG_SCOPE(__FUNCSIG__)
#else
    #define PROFILE_LOG_SCOPE(tag_str)
    #define PROFILE_LOG_SCOPE_FUNCTION()
#endif

ProfileLogScope.cpp
#include "ProfileLogScope.hpp"

#include <iostream>
#include <ostream>
#include <iomanip>
#include <sstream>

ProfileLogScope::ProfileLogScope(const char* scopeName) noexcept
: _scope_name(scopeName)
, _time_at_creation(std::chrono::steady_clock::now()) {
    /* DO NOTHING */
}

ProfileLogScope::~ProfileLogScope() noexcept {
    const auto now = std::chrono::steady_clock::now();
    const auto elapsedTime = (now - _time_at_creation);
    std::cout << "ProfileLogScope " << _scope_name << " took " << elapsedTime.count() << " nanoseconds.\n";
}

Usage

void Foo();

int main() {
   PROFILE_LOG_SCOPE_FUNCTION()
   {
        PROFILE_LOG_SCOPE("Algorithm 1");
   }

   Foo();
}

void Foo() {
    PROFILE_LOG_SCOPE_FUNCTION();
    //...
}

The macros expand to unique-per-line variable names and are no-ops when explicitly not in a profiling mode.
When C++20's std::source_location becomes available, this will become a lot less messy. See Jason Turner's video on the topic: https://www.youtube.com/watch?v=TAS85xmNDEc


How does the Steam Marketplace work?

Question: After the Trading Card update, I noticed an option that said "sell", and discovered the Steam Market. I was wondering, how does this work? When I clicked "Sell," it took me to a page asking me for the money I receive and the money the buyer pays.
Is the Steam Market an auctioning feature to auction Steam items? Is it a way to simply sell items?
Comment: Cynical response: It's basically a way for Valve to capitalize on their new *Steam Trading Cards* thing.  They take a cut from every card or item transaction made through the market.
Answer: Yes, it is a place to buy and sell virtual items.  At this time, only some in-game items (including TF2 keys, the primary "currency" used in Steam trading) and trading cards can be bought and sold - you cannot buy/sell copies of games in your inventory.
Items are sold for a fixed price, chosen by the seller (it is not an auction).  You can buy items from the market using the money in your Steam Wallet, or with paypal/credit card.  When you sell an item, the money gets put in your Steam Wallet. There is no way to move that money to, say, your Paypal; it can only be used on Steam.
Valve and the company behind the game each get a percentage of the final sale price, depending on the game (generally 5% for Valve, 10% for the game's creators, minimum one cent each); the seller gets the rest (That is why there are two input boxes, one for "Buyer Pays" and one for "You Receive")
You must have Steam Guard enabled to use the Market.
You can learn more at the Steam Community Market FAQ.

How does the Steam Marketplace work?


Compact function spaces

Question: Consider an operarator $A: D(A) \subset X \to X$ generating an analytic semigroup $e^{At}$ of negative type and define as usual (for example see  [Pazy]) the negative powers $(-A)^\theta$ for $0< \theta < 1$.
Consider the following set
$$K_M=\{u \in C([0,T];H) : |u|_{C^\beta([0,T];H)}+ \sup_{t\leq T} |u(t)|_{D(-A)^\theta} \leq M\}$$
Then why is it compact by Ascoli Arzelà?
Comment: I don't think that's true. For example, if $A=-\mathrm{id}$, then $K_M$ contains all constant functions for which the constant has norm $\leq M/2$. This set is homeomorphic to the unit ball in $H$, hence not compact (unless $H$ is finite-dimensional).
Comment: I think this set is compact if and only if the embedding $D((-A)^\theta)\hookrightarrow H$ is compact.
Comment: The condition $D -A^\theta$ Compactly embedded into H is it true for A=-laplacian right?
Comment: That depends on the domain. Not for $H=L^2(\mathbb{R}^d)$, but it is true for $H=L^2(\Omega)$ with a bounded domain $\Omega$.
Comment: Where can I find some references on these embeddings?
Comment: I think Brezis' book on Sobolev spaces and partial differential equations could be a good start.
Answer: Let $p\colon H\to [0,\infty]$ be lower semicontinuous. For $M>0$ the set
$$
K=\{u\in C([0,T];H):\lvert u\rvert_{C^\beta([0,T];H)}+\sup_{t\leq T}p(u(t))\leq M\}
$$
is compact if and only if $\{\xi\in H\mid p(\xi)\leq M\}$ is compact:
By the Arzela-Ascoli theorem the set $K$ is compact if and only if it is closed, equicontinuous and for every $t\in [0,T]$ the set $\{u(t): u\in K\}$ is compact. The set $K$ is closed because $u\mapsto \lvert u\rvert_{C^\beta([0,T];H)}+\sup_{t\leq T}p(u(t))$ is lower semicontinuous and equicontinuous because of the bound on the Hölder seminorm. Finally, $\{u(t):u\in K\}=\{\xi\in H\mid p(\xi)\leq M\}$. On the one hand, if $u\in K$, then $p(u(t))\leq M$ by definition. On the other hand, if $\xi\in H$ with $p(\xi)\leq M$, then the constant function $s\mapsto \xi$ belongs to $K$.
Now in the specific case when $p(\xi)=(\lVert \xi\rVert^2+\lVert A\xi\rVert^2)^{1/2}$ for some closed operator $A$ (and $p(\xi)=\infty$ if $\xi\notin D(A)$) this means that $K$ is compact if and only if the embedding $(D(A),\lVert\cdot\rVert_A)\hookrightarrow H$ is compact if and only if $(1+A^\ast A)^{-1}$ is compact.
Comment: Thanks you very Much !

Compact function spaces


How to prove $G$ is not Hamiltonian?

Question: A connected graph $G$ of order $n=2k+1$ has $k+1$ vertices of degree 2, no two of which are adjacent, while the remaining $k$ vertices have degree 3 or more. Show that $G$ is not Hamiltonian.
Answer: If there is a Hamiltonian cycle, any edge of $G$ which is incident with a vertex of degree $2$ must be in the cycle, right? If $G$ has $2k+1$ vertices, how many edges will a Hamiltonian cycle have?

How to prove $G$ is not Hamiltonian?


How to resize these images in CSS?

Question: My boss is having me update the company website since I know a little code, but I'm having trouble making the images bigger. This is the html code on the page:

Copper Busbar - In Stock and Ready for Immediate Shipment

Cut to Length

Bent and Drilled to Your Specs

Custom Fabrication

                    In Stock Item & Ready to Ship

For Instant Quote - Open the Chat Below

                        Or Email Us at
                        email@example.com

            Or Call Us at
                        918-665-6888

And here is the CSS script:
/*************
 community Page CSS
 ************/
/* Contact Form */
.wpcf7 input[type="text"],
.wpcf7 input[type="email"],
.wpcf7 input[type="tel"],
.wpcf7 textarea
{
    background-color: #fff;
    border: 2px solid #2F3396;
    color: #000;
    width: 90%;
}

.site-header {
    display: none;
}

.flexslider {
max-width: 600px;
margin: 0 auto 60px !important;
}

.site-inner {
    padding: 0px !important;
    max-width: 3000px !important;
}

a {
    border-bottom: none !important;
    text-decoration: none !important;
}

 .communityMobileContainer {
    display: none;
}

 .communityContainer {
    width: 100%;
    margin:  0;
    padding: 0px 0px 0px 0px;
    overflow: hidden;
}

.apartmentInnerWrapper {
    width: 85%;
    display: block;
    margin-left: auto;
    margin-right: auto;
    overflow: hidden;
    padding: 10px 0px 20px 0px;
}

/*********************
    Community Header
 *********************/

.apartmentBanner {
    width: 100%;
    overflow: hidden;
    display: block;
    margin-left: auto;
    margin-right: auto;
    padding: 10px 0;
}

.topBanner {
    background-color: #2F3396;
    height: 100px;/*F8C800*/
}

.bottomBanner {
    background-color: #C1D0D3;
    width: 100%;
    padding: 5px 0;
    /*position: relative;
    top: -40px;*/
}

.bottomBanner a {
    color: #2F3396 !important;
}

.apartmentPets,
.apartmentBannerMap,
.apartmentBannerPrice {
    float: left;
    width: 33%;
    text-align: center;
    font-weight: 600;
    font-size: 16px;
    color: #fff;
}

.apartmentPets1,
.apartmentBannerMap1 {
    float: left;
    width: 25%;
    text-align: center;
    font-weight: 600;
    font-size: 16px;
    color: #fff;
}

.apartmentBannerPrice1 {
    float: left;
    width: 50%;
    text-align: center;
    font-weight: 600;
    font-size: 16px;
    color: #fff;
}

.apartmentPets a {
    color: #fff;
}

.communityViewMap a {
    color: #fff;
}

.talkSection > a{
    padding-top: 10px !important;
    color: #C1D0D3;
    font-size: 30px;
}

.talkSection  > a:hover {
color: #fff;
}

.talkSection .powerFuseBottom {
position: relative;
top: -29px;
}

.apartmentBannerMap {
    padding-top: 4px;
}

 .talkPerson  {
    font-size: 18px !important;
font-weight: 600 !important;
padding: 5px 10px 5px 0px !important;
border: 0 !important;
top: 0px !important;
color: #c3251d;
text-decoration: underline !important;
}

.communityViewMap .talkPerson  {
font-size: 18px !important;
font-weight: 600 !important;
padding: 5px 10px 5px 0px !important;
border: 0 !important;
top: 0px !important;
color: #2F3396;
text-decoration: none !important;
}

 a:hover {
    color: #000;
    cursor: pointer;
}

.apartmentPets {
    padding-top: 4px;
}

/* End Banner */

.rightProduct .partsTitle {
    margin: 10px 0 0px;
    font-size: 24px;
    font-weight: 400;
}

.learnAboutFact {
    margin: 10px 0 0px;
    font-size: 32px;
    font-weight: 400;
    color: #2F3396;
    text-align: center;
    display: block;
}

/* Product Desciption */

.communityContainer .categoryTitle {
    font-size: 30px;
    font-weight: 600;
    text-decoration: none;
    color: #2F3396;
    margin: 0px;
}

.communityContainer .categoryFuseTitle {
    font-size: 26px;
    font-weight: 600;
    text-decoration: none;
    color: #2F3396;
    margin: 0px;
    padding: 35px 0 20px;
}

.communityContainer .leftProduct {
    padding: 3px 12px;
    width: 45%;
    float: left;
    overflow: hidden;
}

.communityContainer .leftProduct img {
    display: block;
    margin-left: auto;
    margin-right: auto;
    margin-top: 50px;
}

.communityContainer .rightProduct {
    padding: 3px 12px;
    width: 53%;
    float: right;
    overflow: hidden;

}

.fuseDescriptionP {
    font-size: 22px;
    font-weight: 500;
    color: #000;
    margin-bottom: 0px;
}

.fuseDescriptionP p {
    margin-bottom: 0px;
}

.contactUsBanner{
    text-align: center;
    font-size: 22px;
    font-weight: 500;
    color: #000;
}

.contactUsBanner a {
    padding: 10px 15px;
    color: #000;
}

.contactUsBanner a:hover {
    color: #2F3396;
}

/* End Product Description */

 .communityContainer .communityHeader {
    padding: 2px 12px 0 0;
    margin: 0 0 0 0;
    width: 100%;
    float: left;
    text-align: left;
}

 .communityContainer .communityHeader .communityTitle {
    font-size: 30px;
    font-weight: 600;
    text-decoration: none;
    color: #2F3396;
}

.communityContainer .fuseDescription p {
    font-size: 16px;
}

/*********************
Community Description Section
 *********************/

.communityContainer .fuseDescription{
    width: 100%;
    overflow: hidden;
    padding: 0px 10px 5px 0px;
}

.communityContainer .fuseDescription myimages {
    width: 400px;
    height: 300px;
}

.communityContainer .fuseDescription span {
    font-size: 20px;
    font-weight: 400;
    position: relative;
    top: -15px;
    padding: 0 0 0 15px;
}

.communityContainer .fuseDescription .chatLink {
    font-size: 24px;
    font-style: italic;
    font-weight:600;
    margin-bottom: 2px;
}

.communityContainer .fuseDescription p{
    font-size: 16px;
}

.communityDescriptionHalf {
    float: left;
    width: 48%;
    padding: 0px 4px;
}

.communityDescriptionThird {
    float: left;
    width: 32%;
    padding: 0px 4px;
}

.communityDescription .communityPlansTitle {
    padding: 3px 0 20px 0px;
    width: 100%;
    display: block;
    clear: left;
}

.communityPlansDataLeft,
.communityPlansDataRight {
    width: 48%;
    float: left;
    font-size: 16px;
    font-weight: 400;
    padding: 0 10px!important;
}

.communityPlansInfo h4{
    font-size: 24px;
    color: #004c71;
    margin: 5px 0 2px 0 !important;
    padding: 0 10px!important;
    font-weight: 700;
    text-align: center;
}

.communityPlansInfo p {
    font-size: 18px;
    margin: 0px 0 4px 0 !important;
    padding: 0 10px!important;
    font-weight: 600;
    color: #000;
}

/* Footer */

.footer-widgets {
    padding: 0px;
    background-color: #C1D0D3;
}

.footer-widgets .wrap {
    padding: 0px;
    margin: 0px;
    max-width: 3000px;
    color: #fff;
}

.footer-widgets .wrap a {
    padding: 0px;
    margin: 0px;
    max-width: 3000px;
    color: #fff;
}

.footer-widgets-1 {
    width: 100%;
    float: left;
    padding: 20px 4%;
    text-align: center;
    margin: 0px;
    font-size: 22px;
    color: #2F3396;
}

.footer-widgets-1 p {
    margin-top: 5px;
    margin-bottom: 20px;
}

.footer-widgets-1 .widgettitle {
    text-align: center;
    color: #2F3396;

}

.footer-widgets-2 {
    width: 50%;
    float: left;
    padding: 20px 4% 0px;
    margin: 0px;
    font-size: 18px;
    color: #2F3396;
}
.footer-widgets-2 .widgettitle {
    color: #2F3396;
}

.footer-widgets-1 a:hover,
.footer-widgets-2 a:hover {
    color: #000;
}

.footer-widgets-3{
    width: 20%;
    float: left;
    padding: 20px 4% 0px;
    margin: 0px;
    font-size: 18px;
}

.footer-widgets-3 .widgettitle {
    color: #2F3396;
}

.footer-widgets .widget {
    margin-bottom: 10px;
}

.widgettitle {
    text-align: center;
    padding-top: 10px;
    margin-bottom: 10px;
    font-size: 32px;
}

.site-footer {
    background-color: #23282D;
    color: #fff;
}

.site-footer a {
    color: #fff;
}

/*********************
      Mobile CSS
 *********************/

@media (max-width: 1000px) {

.communityContainer .communityPhone {
    text-align: center;
    width: 100%;
    padding: 12px 0;
    clear: both;
}

.footer-widgets-1,
.footer-widgets-2,
.footer-widgets-3{
    width: 100%;
    clear: left;
    text-align: center;
}

.widgettitle {
    text-align: center !important;
    padding-top: 20px;
}

.communityContainer .communityUrl {
   text-align: center;
    width: 100%;
    padding: 12px 0;
    clear: both;

}

}

@media (max-width: 800px) {

.apartmentInnerWrapper {
    width: 100%;
    padding-top: 25px;
}

.topBanner {
    height: 190px;
}

.apartmentPets,
.apartmentBannerPrice,
.apartmentBannerMap {
    clear: left;
    width: 100%;
    text-align: center;
    font-weight: 600;
    font-size: 18px;
}

.communityDescriptionHalf {
    clear: left;
    width: 100%;
}

.communityDescriptionThird {
    clear: left;
    width: 100%;
}

.communityContainer .leftProduct {
    clear: both;
    width: 100%;
}

.communityContainer .rightProduct {
    clear: both;
    width: 100%;
    padding: 0 0 25px 0;
}

 .communityContainer .communityHeader {
    width: 100%;
}

.communityContainer .communityHeader .communityBuilder {
    padding: 6px 3px;
}

}

@media (max-width: 700px) {

 .communityMobileContainer {
    display: inline-block!important;
}

 .communityContainer {
    display:  important;
}

#communityPlansAll {
 width: 100%;
 max-width: 500px;
 margin: 2px auto 2px auto;
}

/*********************
      End Mobile CSS
 *********************/

}

/*******************
*******************
Fuse Category Page
*******************
*******************/

.allAgentsWrapper {
    width: 100%;
    padding: 0 0 75px;
    overflow: hidden;
}

.allAgentsWrapper .allAgents {
    width: 100%;
    margin: 0 auto;
    max-width: 1000px;
    overflow: hidden;
    padding: 40px 0;
    list-style: none;
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;

    -webkit-flex-flow: row wrap;
    justify-content: space-around;
}

.singleAgent {
    padding: 20px 10px;
    width: 200px;
    height: auto;
}

.singleAgent .bpTitle{
    text-align: center;
    font-size: 16px;
    padding-bottom: 0px;
    margin-bottom: 0px;
    margin-top: 7px;
    color: #606060;
    font-family: Oswald,Tahoma,Arial,sans-serif;
}

.singleAgent .bpImg {
    width: 100%;
    height: auto;
    border: 1px solid #f6f6f6;
}

.singleAgent .fuseImageWrapper {
    overflow: hidden;
    min-height: 144px;
}

.singleAgent .bpDesc p {
    font-size: 12px;
    font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif;
    line-height: 17px;
    text-align: justify;
    font-size: 12px;
    margin-top: 5px;
    margin-bottom: 5px;
}

.singleAgent .AgentTop {
    width: 100%;
    padding: 5px 0;
}

.singleAgent .AgentTop .leftTop {
    float: left;
    width: 50%;
    margin: 0;
    padding: 5px 0;
}
.singleAgent .AgentTop .rightTop {
    float: right;
    width: 50%;
    margin: 0;
    padding: 5px 0;
}

.singleAgent .bpPrice {
    font-size: 16px;
    text-align: center;
    padding: 5px 0 0;
    letter-spacing: 1px;
    font-family: Oswald,Tahoma,Arial,sans-serif;
}

.singleAgent .bpLink {
    padding: 7px 11px;
    float: right;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    font-weight: 400;
    text-decoration: none;
    background-color: #faab37;
    border-radius: 0;
    font-family: Oswald,Tahoma,Arial,sans-serif;
    text-shadow: 1px 1px rgba(0,0,0,.25);
    border: 0;
    outline: 0;
     -moz-transition: all .2s ease-in;
    -o-transition: all .2s ease-in;
    -webkit-transition: all .2s ease-in;
    transition: all .2s ease-in;
}

.singleAgent .bpLink:hover {
    background-color: #000;
}

.singleAgent .bpIcons {
    list-style: none;
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-flow: row wrap;
    justify-content: center;
}

.singleAgent .bpIcon i {
    font-size: 18px;
    padding: 0 5px;
}

/* Single Agent Page */

.singleWrapper .topImage {
    padding: 15px;
}

.singleWrapper .topSection {
    padding: 5px 15px 15px;
}

.singleWrapper .topSection .bpTitle {
    padding: 5px 0;
}

.singleWrapper .topSection .bpDesc {
    padding: 5px 0 15px;
}

.singleWrapper .topSection .bpLink {
    float: left;
    padding: 7px 11px;
    margin-top: 10px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    font-weight: 400;
    text-decoration: none;
    background-color: #faab37;
    border-radius: 0;
    font-family: Oswald,Tahoma,Arial,sans-serif;
    text-shadow: 1px 1px rgba(0,0,0,.25);
    border: 0;
    outline: 0;
     -moz-transition: all .2s ease-in;
    -o-transition: all .2s ease-in;
    -webkit-transition: all .2s ease-in;
    transition: all .2s ease-in;
}

.singleWrapper .topSection .bpPrice {
    margin-left: 10px;
    float: left ;
    color: #606060;
    font-size: 20px;
    padding: 16px 0 0;
    letter-spacing: 1px;
    font-family: Oswald,Tahoma,Arial,sans-serif;
}

.singleWrapper .leftImage {
    max-width: 300px;
}

.singleWrapper .rightSection {
    max-width: 500px;
}

.singleWrapper .bpIcon i {
    font-size: 22px;
    padding: 0 5px 15px;
}

I tried adding this bit of code to the Community Description Section on the CSS file to see if it would work but it didn't.
.communityContainer .fuseDescription myimages {
    width: 400px;
    height: 300px;
}

Basically I'm flummoxed. Any help would be appreciated.
Here is a link to the page:
https://efuses.com/copperbusbar/
The two images in question are underneath the words Custom Fabrication.
Thanks!
Answer: I am inferring that since you have 2 images, you want to align them next to each other and have them occupy roughly half of the available space each. So a solution could be:
.communityContainer .fuseDescription img { display: inline-block; width: 49%; height: auto; }

First, you need a selector that correctly references and overwrites the current context, hence the 2 classes and an element. Then, displaying the images as inline-blocks allows them to respect the width and height specifications in all browsers. A width of 49% makes sure they both fit in a row snugly without pressing the outer margins. Height auto insures they keep their original proportion and don't get skewed.
Your error was the myimages selector which doesn't really exist in CSS, except if you wanted to specify the class name .myimages which would have also worked. The difference in approaches when using percentages vs pixels is the fact that the percentages adapt to the screen real estate available in varying contexts and browser sizes.
There are some other more advanced solutions based on the CSS grid specification that do the same trick for a variable amount of images on one "line" but I'm guessing you don't need that sort of complexity to solve this particular issue. :)
Comment: Thank you for the quick response! I added the bit of code to the CSS and tweaked the html. The images are still the same size though. How would I make them bigger? Am I putting the CSS bit in the wrong spot?
Comment: There's an error in your HTML there. The `.fuseDescription` should be a `` not an `` so the full HTML becomes: `  ` (you don't need the ``, you can scrap it). Did it do the trick? Also, please add the full absolute URL of the image, or a relative path to the `src` properties: so either `https://efuses.com/wp-content/...rest of URL` or `/wp-content/...rest of URL`, not `efuses.com/wp-content/...`.
Comment: No. But it made the image of the truck bigger. So I think we're getting closer!

How to resize these images in CSS?


Is paralellizability a topological invariant (Invariant under homemorphism)

Question: This  MO  post  is  a  motivation to  ask:

Is paralellizability  a  topological invariant (Invariant under homeomorphism)?
Answer: No. You can cook up counterexamples in high dimensions via surgery theory. The relevant paper here is Milnor, "Microbundles and differentiable structures", available here. The theorem you want is Corollary 6.4; as a corollary of this, Milnor gives an example of a (noncompact) smooth parallelizable manifold that carries a different, non-parallelizable differentiable structure.
You should be able to find closed examples using this corollary, but I don't know any off the top of my head.
Comment: thank you for your very helpful  answer.


Are unique items always found in the same place?

Question: Are the unique (purple) items in Kingdoms of Amalur: Reckoning always found in the same place? I just found an awesome sword in a nondescript chest while on my way to a quest, and I'm wondering if it would always be found there. If not I'm wondering if there is a chance to find similar high-level items in all chests in the game.
Answer: Yes, it is possible to find purple items in all random nondescript chests and even dropped by complete scrub enemies. No, they are not in fixed locations... with the caveat below.
To go into a little more detail on how this works (at least on the PC version), it seems like the contents of a chest are randomized the first time you enter a zone or dungeon. At that point, you can save and reload, or run around the world and come back as much as you want, but that chest is always going to have the same contents. If there was a certain purple item in there, there will always be a certain purple item in there (for that character). If there wasn't, there won't be.
However, if you save your game before entering the dungeon for the first time, and then run in and open a chest, you'll find that if you reload to your save and then once again run into the dungeon and loot the chest, the contents will be different. Again, this is because the contents are randomized the first time you enter the dungeon. Maybe the chest had a purple the first time but not the second. Or maybe two different purples. Or no purples at all.
Enemy loot drops, on the other hand, seem to be completely random. You can kill an enemy and he'll drop a purple item, then reload your game and do it again, and he will drop something totally different.
Comment: I think there are occasional exceptions - certain bosses drop items that I *think* are always there - they have stats or story bits that seem to match with the boss' backstory.  There are also one or two places in the game where I've found an item that seemed like it would always spawn there - the grave of some warrior had that particular warrior's helmet, for instance.
Comment: I've seen some set items where that might have been the case. Not sure I've seen it for purples though. But you may be right.
Answer: I have found the same purple item in a chest before and after dying / reloading my game, but IIRC creature levels are generated when you enter some areas - I'd assume that it's possible that items use a similar system.


React reading data form the server

Question: I am getting an error from strapi backend data when I fetch particular data into the front end react app I get an error when I log the data into the browser console I see my data in the browser console.
query GetPromoProducts {
    allStrapiProduct(filter: {promo: {eq: true}}) {
      edges {
        node {
          strapiId
          name
          variants {
            images {
              url
            }
          }
        }
      }
    }
  }
`)

const [selectedSlides, setSelectedSlides] = useState(0)

console.log(data);

var slides =  [];

data.allStrapiProduct.edges.map(({node}) => {
  console.log(node.variants[0].images[0]);
})

Comment: Add null checking via [Optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) and more `console.log`s. One of your rows has empty data somewhere.
Answer: Debugging
To debug the server side, use optional chaining and console.log to work your way up to the object's that returning null.
Not sure what the exact code looks like, based on question.
const myQuery = graphql`
  query GetPromoProducts {
    allStrapiProduct(filter: { promo: { eq: true } }) {
      edges {
        node {
          strapiId
          name
          variants {
            images {
              url
            }
          }
        }
      }
    }
  }
`;

const Component = () => {
  const [selectedSlides, setSelectedSlides] = useState(0);

  console.log(data);

  data.allStrapiProduct.edges.map(({ node }) => {
    // For this case, use optional chaining to work your way up the tree
    console.log(node);
    console.log(node?.variants);
    console.log(node?.variants?.[0]);
    console.log(node?.variants?.[0]?.images);
    console.log(node?.variants?.[0]?.images?.[0]);
  });
};

To stop right at the area this happens:
data.allStrapiProduct.edges.map(({ node }) => {
  if (!node?.variants?.[0]?.images?.length) {
    console.log(node);
    console.log(node?.variants);
    console.log(node?.variants?.[0]);
    console.log(node?.variants?.[0]?.images);
    console.log(node?.variants?.[0]?.images?.[0]);
    throw "Required data missing";
  }
});

Resilient React with GraphQL
GraphQL structured data may be typed, but unless the fields are required, you have to handle null.
To make the client-side code more robust, you can use Array.prototype.filter() to skip objects with no images, or - as in this example - make components handle the case where data is missing. It's entirely up to how you want the frontend app to render it.
I haven't tested this code, so take it as "pseudo-JSX" to demonstrate handling empty graphql response fields.
const ProductVariant = ({ variant }) => {
  if (!variant) return null;

  return (

      {variant?.images?.map?.((image, idx) => (

      ))}

  );
};

const ProductVariants = ({ variants }) => {
  if (!variants?.length > 0) return null;

  return (

Variants

        {variants?.map?.((variant, idx) => (
          <ProductVariant variant={variant} key={idx} />
        ))}

  );
};

const Products = () => {
  const [selectedSlides, setSelectedSlides] = useState(0);

  console.log(data);

  const products = data.allStrapiProduct.edges.map(({ node }) => {
    // Handle as you deem fit
  });

  return (

Here is a list of products

        {products?.map?.((product, idx) => {
          return (

              {product?.variants?.length > 1 && (
                <ProductVariants variants={variants} />
              )}

          );
        })}

  );
};

React reading data form the server


Checking whether the solution is correct or not and if correct then the bounds which would make it more strong claim

Question:
During a month with $30$ days a baseball team plays at least a game a day; but no more than $45$ games. Show that there must be a period of some number of consecutive days during which the team must play exactly $14$ games.

My Solution:Let the number of games played on day $i$ be $g_i$. Then, the total number of games played starting on day $m$, and ending on day $n$ is
$$
g_m+g_{m+1}+\cdots+g_n .
$$
Now, define s, to be the total number of games played during the first i days. That is,
$$
\begin{array}{l}
s_1=g_1 \\
s_2=g_1+g_2 \\
\vdots \\
s_{30}=g_1+g_2+\cdots+g_{30}
\end{array}
$$
Now, note that
$$
\begin{aligned}
g_m+g_{m+1}+\cdots+g_n &=\left(g_1+\cdots+g_n\right)-\left(g_1+\cdots g_{m-1}\right) \\
&=s_n-s_{m-1}
\end{aligned}
$$
Therefore, we need to show that is that $s_n-s_{m-1}$ takes on the value $14$ for some $m$ and $n$ between $1$ and $30$ . What we're given is that the total number of games played on all thirty days is no more than $45$ , which tells is that each $s_i$ is at most $45$. Furthermore, we're told that the team plays at least a game a day, which means that $s_1, s_2, \ldots, s_{30}$ are distinct integers between $1$ and $45$ . The $s_i$ are going to be the pigeons in this question.
Now, let our pigeonholes be the following sets:
$$
\begin{array}{l}
\{1,15\},\{2,16\}, \ldots\{14,28\} \\
\{29,43\},\{30,44\},\{31,45\} \\
\{32\},\{33\} \ldots\{42\}
\end{array}
$$
We're picking $30$ numbers $s_1, s_2, \ldots, s_{30}$ out of the set $\{1,2, \ldots, 45\}$. Counting, we see that that we have exactly $14+3+11=28$ pigeonholes, Therefore, some two of the $s_i$ are going to be in the same pigeonhole. By our definition, a pair of numbers in a pigeonhole differ by exactly 14 - this means well have an $s_i$ and $s_j$ such that $s_j-s_i=14$. But as noted above, this mean that the total number of games played on days $i+1, i+2, \ldots, j$ is exactly $14$, as required.

If my solution seems right then , can we say that this problem is not having optimal values , that is we can have atmost $57$ games rather than $45$ since then we would be having the $30$ pigeons and $29$ holes ? Or we can have atmost $x$ games where $x$ lies between $1$ to $29$ isnt ? Not only $14$ isnt ? Atmost $30$ one not true for always and above $30$ too
Comment: I think you are right
Comment: Thanks ....Vezen
Answer: I have not found a flaw in your proof.  However, the following proof motivates the choice of the numbers $30, 45, 14$.
Let $x_i$ be the number of games that have been played by the $i$th day of the month.  Since at least one game is played each day and a total of $45$ games are played over the course of the month,
$$1 \leq x_1 < x_2 < x_3 < \ldots < x_{30} = 45$$
Define a new sequence by $y_i = x_i + 14$.  Since the $x_i$ are distinct, so are the $y_i$.  Moreover,
$$15 \leq y_1 < y_2 < y_3 < \ldots < y_{30} = 59$$
Taking the union of the two sequences gives $60$ integers between $1$ and $59$ inclusive, so there must be some $x_i$ and $y_j$ such that $x_i = y_j$, where $j < i$.  Since $x_i - y_j = 0, x_i - (x_j + 14) = 0$, so $x_i = x_j + 14$.  Thus, there is a stretch of days in which the team plays exactly $14$ games, namely $x_{j + 1}, x_{j + 2}, \ldots, x_i$.
Comment: If already we pick 15,29 then we have nothing left to prove otherwise if those two not picked together (one of those two may be picked) then also we are guranteed that there would exist two element in same hole isnt ? In my proof , so all fine isnt ?
Comment: Which ones may you tell i will explain ?
Comment: Yeah but whats the problem ? This whole proof of mine tells that in the case1: where 15,29 are both not selected (one maybe) ,then there exist other two which gives difference 14 , and in the case 2 : where 15,29 occurs both we have nothing to left to prove ? And these two are the only cases possible except if both are not selected which must have a hole pair by php
Comment: Thanks finally saw the edited version thanks for telling the motivation for 14 . And yeah can you once also tell if the optimal bounds are right of mine?
Comment: Your approach works for any number up to and including $57$.  It seems to me that the number $14$ was motivated by the desire to use the proof I gave.
Comment: I see thanks for explaining


Add custom html to choicefield label in django

Question: I am struggling with a requirement now, I want to add an image to choice field label and I really dont have a clue how to do it. I am using django form wizard to render the form.
Here is the image which shows what I want to achieve :

And here is what I have got right now ( to make the radio buttons inline, I know it could be achieved through css):

Here is the forms.py:
from django import forms
from django.utils.translation import gettext as _

CHOICES=[('0','Pay by card'), ('1','Invoice')]

class PaymentForm(forms.Form):
    title = 'payment'
    payment_method = forms.ChoiceField(label = _("Payment Options"), choices=CHOICES, widget=forms.RadioSelect(), required = True)

I am rendering using wizard form:
 {{ wizard.form.payment_method.label_tag }}
                                {{ wizard.form.payment_method|safe }}
                                {{ wizard.form.payment.errors}}

Anyone has any suggestion for this apart from custom widget?
Comment: Depends on how you render your form. If you use form.as_p() or similiar build in function, you would have to override this behaviour. You can also do your form manually in html. https://docs.djangoproject.com/en/dev/topics/forms/
Comment: I just edited my question.
Answer: Without a widget:
from django.utils.safestring import mark_safe
CHOICES=[('0', mark_safe('Pay by card ')),
         ('1', mark_safe('Invoice '))
]

Credit: setting help_text for each choice in a RadioSelect
Answer: In your template do something like :
 {% for choice in wizard.form.payment_method.choices %}
    {{ choice.0 }} {# value #} {{ choice.1 }} {# value #}
    {% if choice.0 == PAYMENT_BY_PAYPAL %}
     ...
    {% endif %}
 {% endfor %}

You can also write :
  {% for key, value in wizard.form.payment_method.choices %}
    {% if key == PAYMENT_BY_PAYPAL %}
     ...
    {% endif %}
 {% endfor %}

Comment: Yes, me too, see above.
Comment: Is PAYMENT_BY_PAYPAL, the key name? Which is '0' in my question?
Comment: Yes, in your case it is '0' the other one is '1'.
Answer: 1) Shortly (but i'm not sure) call a function where 'Pay by card' and return all ... that you need.
2) You can make somthing like @Gahbu said
3)Long [Better, i think, but untested :( ]:
Make a renderer:
from myapp.my_widgets import CardsRadioFieldRenderer

CARD_CHOICE = '0'

CHOICES=[(CARD_CHOICE,'Pay by card'), ('1','Invoice')]

class PaymentForm(forms.Form):
    title = 'payment'
    payment_method = forms.ChoiceField(label = _("Payment Options"), choices=CHOICES,widget=forms.RadioSelect(renderer=CardsRadioFieldRenderer), required = True)

# myapp/my_widgets.py

class CardRadioInput(RadioInput):
    def __init__(self, name, value, attrs, choice, index):
        self.name, self.value = name, value
        self.attrs = attrs
        choice_value = force_text(choice[0])
        self.choice_value = choice_value
        if choice_value == CARD_CHOICE:
            choice_label = force_text(self.get_html_for_card_choice())
        else:
            choice_label = force_text(choice[1])
        self.choice_label = choice_label
        self.index = index

   def get_html_for_card_choice(self):
        #some logic to get the images tags ( )
        return text

class CardsRadioFieldRenderer(RadioFieldRenderer):
    def __getitem__(self, idx):
        choice = self.choices[idx] # Let the IndexError propogate
        return CardRadioInput(self.name, self.value, self.attrs.copy(), choice, idx)

Comment: Well, even I am not sure if point 1 could be achieved, but Gahbu's solution is not working for me right now, and I kept the point 3 as the last option, I was just not sure if there is any simple solution to achieve this, so thought of posting it here.
Answer: If you want to tweak it from the template, you need to use the "safe" which tells Jinja not to escape it. like below
{{ some_object.some_property|safe }}

Yet if you want to use it inside your python code while defining the form/modelform just use mark_safe as below.
mark_up = 'this is a link'
choices = list()
choices.append(('some_id', mark_safe(mark_up)))
self.fields['some_field'].choices = choices


Can you use a Legendary in a Gym Battle?

Question: I know you cannot place a Legendary Pokemon in a Gym to defend is, and I do know that you can use a Legendary to fight a Raid Boss.
But I hear some people saying that you also cannot use a Legendary to attack a Gym. Does anyone know if that is true?
Comment: Is this not something incredibly easy to test?
Comment: @Frank U couldn't test it. I only have 3 Gyms in my neighbourhood (rural) and all of them are from my team at the moment. Blue is on vacation I guess. But somebody said you couldn't and somebody else said you could use them. So it was confusing.
Comment: Why is my question getting minned, for me it is avalid question. I did reseach and Legendary are not like normal pokemon.:- S
Answer: Yes, you can use Legendary Pokémon in raid and gym battles
Niantic Updates

While Legendary Pokémon will help them take on the toughest Raid Bosses and Gym Battles, they're not willing to leave their Trainer's side, so they can't be left to defend Gyms.
Answer: Yes, it is perfectly possible to do this. I just used an Articuno to attack a gym, myself.

You can also use multiples of the same legendary in a gym battle. The most extreme case is shown in this video:

The trainer uses a team of 6 Articuno to attack a gym.
Comment: Did you win though?
Comment: @n_palum yeah, Articuno did work (the defending Pokémon had pretty low CP, though, to be fair)
Comment: I now also have an Articuno. Now i also tried it out on an Gym, and the attacking idd worked. :-)
Answer: Yes, you can use legendary Pokémon to attack Gyms.


Execute Stored Procedure from Stored Procedure w/ dynamic SQL capturing output

Question: Inside a stored procedure (A) I need to call a stored procedure (X) inside a specific database and capture the output. X returns a single value.
From what I understand I need to provide the DB name of X to the stored procedure in A and I need to use dynamic SQL to build the query on execution targeting the desired database.
What am unable to figure out is how to capture output from X in A to work with the result.
Comment: You should be able to do this using `sp_executesql` something like `EXEC sp_executesql N'EXEC @rtn = ' + @db + N'.dbo.[your_stored_procedure] @output OUTPUT', N'@rtn AS INT, @output AS INT OUTPUT', @yourlocalvar1 = @rtn, @yourlocalvar2 = @output`, this is just off the top of my head, might need some adjustment.
Answer: You could use sp_executesql to dynamically call your nested Stored Procedure.
DECLARE @db AS SYSNAME
DECLARE @return_value AS INT
DECLARE @output_value AS INT
DECLARE @sql AS NVARCHAR(MAX)

-- Set your DB name
SET @db = N'mydb'

/*
Use sp_executesql to dynamically pass in the db and stored procedure
to execute while also defining the values and assigning to local variables.
*/
SET @sql = N'EXEC @rtn = ' + @db + '.dbo.[your_stored_procedure] @output OUTPUT'
EXEC sp_executesql @sql
   , N'@rtn AS INT, @output AS INT OUTPUT'
   , @return_value = @rtn
   , @output_value = @output OUTPUT

Comment: Thanks, your answer lead me to a working implementation!
Answer: Adding to the above answer, following is the way to call stored procedures dynamically by passing parameters.
    DECLARE @SpName VARCHAR(1000)
    SELECT @SpName = DeleteLiveSP FROM dbo.ArchivalInfo (NOLOCK) WHERE TableName = @TableName

    DECLARE @SqlString nvarchar(2000)
    DECLARE @ParamDef nvarchar(2000)

    SET @SqlString = N'exec '+@SpName + ' @CriteriaParam'
    SET @ParamDef = N'@CriteriaParam XML'

    EXECUTE sp_executesql @SqlString ,@ParamDef, @CriteriaParam = @Criteria


Android application consuming WCF/RESTful service

Question: I have a WCF RESTful application I wrote based off of WcfRestContrib and hosting in iis7.5, which passes a pdf as a byte[]. I'm trying to figure out how, and what the best way would be, to consume this service in an Android application. I believe I took care of all the Java/WCF interop issues because the service is used by an outside company that uses java. But I don't see to many examples out there. I've read that I'm going to have to make a method that passes JSON instead XML, but otherwise I believe it should be usable for an Android app. I'm not seeing too many examples of Android apps that consume RESTful services, is this not the preferred method for Android?
I seen a couple articles (http://romenlaw.blogspot.com/2008/08/consuming-web-services-from-android.html) but most seem kind of old, though they still may be useful. I'm just curious how any experts out there would suggest I handle such a project, I can create another kind of service if need be. I just want to be able to load pdf's from a service based on some parameters. Security is a concern, but not mandatory at this stage. Service currently uses basic auth and is on a https.
Any thoughts? Suggestions?
Answer: While also adressing your security concernt, you could use an HttpsURLConnection and then use getInputStream() from that to put it in a bytearray using read().
Comment: I see what you're suggesting, I'm just not very familiar with java yet. I really need to build from example on the Android side, as I become more familiar with Eclipse. But you think that the service will suffice for an Android project?
Comment: Yea, it should be just fine. There's enough components in android to put something together that will interact succesfully with your web service. Alot of the networking stuff in android was built with REST in mind. REST is what google is all about with their webapps.
Comment: That's what I figured, thinking REST would be the way to go since they promote the technology. I just don't see any examples to build from really. Since I'm somewhat new to Java even, it would be nice to see something similar.
Comment: This is one of my favorite videos from Google I/O to watch: http://www.youtube.com/watch?v=xHXn3Kg2IQE . It talks at a high level how to develope RESTful apps for android. It should give a great starting point.
Comment: Wow, very good video. this is what I'm looking for, as far as becoming familiar with best practices on Android. There's a lot to consider conceptually.


Folders and Tagging pattern for a shared files?

Question: I'm developing a user interface for an enterprise product that has programs that are created, run, and shared by members of an organization (i.e. a company).
I want users to be able to easily find and programs that other team members have created. We're incorporating filtered search and attribute based tags (i.e. tagging programs by type) in our retrieval model but the idea of shared folder or tagging system has come up as a way to help users organize files.
My concern is that shared folder and tagging systems can become messy. Each member may have there own convention for naming folders and tags. For the system to remain organized, the org has to come up with a best practice for naming these folders/tags.
Are there any examples for shared folder/tagging systems that are sustainable? I'm currently looking at 3 models; shared folders, shared tags, and client side folders (i.e. everyone has their own folder system for organizing shared programs). All three look potentially messy.

Thanks for reading my question!
Answer: I will likely answer with more information later, but I am working on a quite similar problem. I would suggest looking at the following resources, which offer extended discussions of the issues you seek to solve:
Everything Is Miscellaneous: The Power of the New Digital Disorder by David Weinberger
Keeping Found Things Found: The Study and Practice of Personal Information Management by William Jones
Hopefully this will get you started along a good path.
Comment: Good resources. You'll have to add some high-level take aways for this to pass the answer quality test.


Formulating an LP problem with vectors

Question: We have $m$ vectors $v_1,v_2,\dots,v_m\in\mathbb{R}^n$ and $m$ numbers $t_1,t_2,\dots,t_m\in\mathbb{R}$ and we want to find a vector $y\in\mathbb{R}^n$ such that

$$|v_i^Ty-t_i|\leq D$$

for $i=1,\dots,m$ and $D\in\mathbb{R}$ as small as possible.
How do I formulate this as an LP problem of the form
min $c^Tx$
under the condition that $Ax\leq b$,
$x\in\mathbb{R}^n$?
I still find it rather difficult to formulate an LP problem, so maybe you can help me?
Edit: can you tell me explicitly what $c,A,x,b$ are?
Comment: Tony, same $D$ for all constraints or different $D$ for each constraint? @arthur and I understood this differently
Comment: @gt6989b same D for all, what did you have?
Comment: I think I've misunderstood the problem. $D$ is the variable to be minimized while meeting the constraints which can be translated to
$$-D \le v_i^Ty-t_i\leq D$$
The cost function to minimize is $D$. The $y_i = y_{i,1} - y_{i,2}$ is still required for $y\in\mathbb{R}^n$.
Comment: @arthur That's okay. If you edit your answer I can give you the bounty
Comment: @TonyStrong I'm not bothered about the points. I'll write up a new answer and delete the old one.cheers.
Comment: @arthur thanks mate
Comment: @gt6989b if you make your answer complete I can give you the bounty since arthur doesnt need the points
Answer: $D$ is a variable to be minimized while meeting the constraints which can be translated to
$$-D \le v_i^Ty-t_i\leq D\ \ ,\ D \ge 0\ ,\ y\in\mathbb{R}^n$$
The cost function to minimize is $D$.
Linear programming minimizes/maximizes $F = c^Tx$ where $Ax \le b$ and $x \ge 0$. $x$ is bounded on one side. The $y$ vector in the above problem is not bounded.Each $y_i$ variable needs to be duplicated with $y_{i,1} \ge 0$ and  $y_{i,2} \ge 0$ s.t. $y_i = y_{i,1} - y_{i,2}$.
$x = [y_{i,1}^T,y_{i,2}^T,D]^T $ the unknowns. $x \ge 0$. A column vector with all $y_{i,1}$ first then all $y_{i,2}$, $D$ is the last variable.
The constraints need to be written in the form:
$$v_i^Ty-D\leq t_i$$
$$-v_i^Ty -D \le -t_i$$
Substituting $y_i = y_{i,1} - y_{i,2}$.
$$v_i^Ty_{.,1} - v_i^Ty_{.,2}-D\leq t_i$$
$$-v_i^Ty_{.,1} + v_i^Ty_{.,2} -D \le -t_i$$
Each row of $A$ and $b$ represent one inequality constraint.
$$A_r = [v_i^T , -v_i^T, -1]\ ,\ b_r = t_i$$
$$A_{r+1} = [-v_i^T, v_i^T, -1]\ ,\ b_{r+1} = -t_i$$
$c$ is the cost. $F_{min}=c^Tx$ is the cost function that will be minimized.
$c^T = [0\dots0,1]$ i.e. $c$ selects $D$ as the cost.
The solution $x$ gives the values of $D$ and all $y_{i,[1,2]}$ then $y_i = y_{i,1} - y_{i,2}$.
LPSolve simplifies matters by allowing unbounded (free) variables and allowing the use of $\le,=,\ge$.

Formulating an LP problem with vectors


How do I replace switch/outlet to GFCI/switch combination?

Question: I am having a problem switching a switch/outlet combo to a GFCI/switch combo. The GFCI switch provides power to a bathroom fan and light that are not protected.
I have wired the GFCI/switch as shown in the photo and when I test the GFCI using the test/reset buttons, the GFCI works properly. When I test the outlet with Gardner Bender tester, I receive a "correct" indicator. However, when I press the Gardner Bender test button, I receive "hot/new rev" indication and the GFCI outlet does not trip. Suggestions?
Comment: What is the model of the GFCI unit I haven't seen one quite like that , are the 2 back connections back stabs or hard wired for the switch. With the switch wired to the line side if that is the switch the device on the switched leg is not protected. Move the switch connection to the load side and it will probably work.
Comment: The model is GFSW1-KW. The wires for the switch are hard wired into the device. The box only has one wire (blue) going to the light.
Comment: How certain are you that your incoming green wire really is grounded? The GFCI's test would work even if it wasn't...
Comment: Ok so it is the GFCI outlet that is not tripping when you press the test on the GB tester.
Comment: 3-light GFCI testers will not work if the ground is not good.   They steal ground to induce a ground fault.   No device can cause a ground fault if it's only attached to hot and neutral.  The steel conduit is a valid grounding path, so look for broken conduit or a noncontinuous path for grounding wires, however that is done.   Do not count on the screws grounding the yoke of the receptacle to the steel box.
Answer: My suspicion: an open ground
This is based on two factors:

Your three-lamp tester is unable to trip the GFCI, but the GFCI tests OK.  This is because the internal TEST button doesn't rely on the ground (it goes load-hot to line-neutral or vice versa), but the three-lamp tester's TEST button is connected hot-to-ground, and thus requires a solid ground connection to work.
Pushing the TEST button on your tester yields a "hot/neutral reverse" indication despite it testing correctly initially -- the "correct" indication is due to capacitive coupling between neutral and ground providing a current path "home" for the current through the right-hand lamp.

I'd check to make sure the green wire is securely connected to the box in your case; if it is, then the problem's upstream somewhere as it appears this receptacle was wired using conduit (note the locknut and fitting at the bottom of the box).  If you can't find it still -- call in an electrician, as they should have better tools (such as an earth fault analyzer/loop impedance tester) that can be applied to the problem.


Method to read a XML

Question: i created a method to read a xml file but it doesn't work twice, i have to place the pointer at start of the file but I didn't found how.
using Microsoft.AnalysisServices.AdomdClient;
using System.Diagnostics;

namespace WindowsFormsApplication1
{

    class Class {
    private System.Xml.XmlReader XML_File;
    public void DebugXML()
        {
            this.XML_File.Read();
            while (!this.XML_File.EOF)
            {
                Debug.WriteLine(this.XML_File.ReadOuterXml());
            }
        }

 public Class()
        {
            AdomdConnection conn = new AdomdConnection("Data Source=MyComputer;InitialCatalog=Database");
            conn.Open();
            AdomdCommand cmd = new AdomdCommand("Select Hierarchize([Projects].[Project Branch].Levels(1).Members) DIMENSION PROPERTIES PARENT_UNIQUE_NAME, HIERARCHY_UNIQUE_NAME, CUSTOM_ROLLUP, UNARY_OPERATOR, KEY0 ON 0, Hierarchize({{{[Period Calculations].[Period].&[0]}, {[Period Calculations].[Period].&[1]}, {[Period Calculations].[Period].&[2]}, {[Period Calculations].[Period].&[3]}, {[Period Calculations].[Period].&[4]}, {[Period Calculations].[Period].&[5]}}}) DIMENSION PROPERTIES PARENT_UNIQUE_NAME, HIERARCHY_UNIQUE_NAME, CUSTOM_ROLLUP, UNARY_OPERATOR, KEY0 ON 1 FROM [ProjectControl] WHERE ([Measures].[WIP]) CELL PROPERTIES BACK_COLOR, CELL_ORDINAL, FORE_COLOR, FONT_NAME, FONT_SIZE, FONT_FLAGS, FORMAT_STRING, VALUE, FORMATTED_VALUE, UPDATEABLE", conn);
            CellSet Cellules = cmd.ExecuteCellSet();
            this.XML_File = cmd.ExecuteXmlReader();
            DebugXML();
            DebugXML();
            conn.Close();
        }
}

Comment: You haven't told us the type of `XML_File`, or why you need to keep it open in the class instead of reading it separately each time.
Comment: `XmlReader` is a forward-only reader. You'll need to use some other construct if you want to read it multiple times.
Comment: System.Xml.XmlReader XML_File;
Answer: Also, look at the Microsoft Support Article - How to read XML file by using Visual C# which has the following example.
using System;
using System.Xml;

namespace ReadXMLfromFile
{
    ///
    /// Summary description for Class1.
    ///
    class Class1
    {
        static void Main(string[] args)
        {
            XmlTextReader reader = new XmlTextReader ("books.xml");
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element: // The node is an element.
                        Console.Write("<" + reader.Name);
                        Console.WriteLine(">");
                        break;
                    case XmlNodeType.Text: //Display the text in each element.
                        Console.WriteLine (reader.Value);
                        break;
                    case XmlNodeType.EndElement: //Display the end of the element.
                        Console.Write("</" + reader.Name);
                        Console.WriteLine(">");
                        break;
                }
            }
            Console.ReadLine();
        }
    }
}

Answer: if you execute your code twice, the second time you'll an exception telling you that the file is opened by anothe process.
So that means that you didn't ... close it. So close it !
Comment: Sure, I tried it but behind that is a heavy query so i would like to avoid execute it each time.
Comment: ?? what do you mean ? what do you want to do ? what's the link between your question and this "heavy query" you got a be more specific
Comment: I precised my question, and to be more specific, I use a web service to retrieve data from a Cube (Analysis Services) and I would like to stock the XML or the Celldata somewhere I can access in my MainApplication.
Comment: then save your xml file on the disk and read this file (use a XmlWriter)

Method to read a XML


using AngularJS slider for getting date input as range

Question: I am working with AngularJs and AngularMaterials and i want the user in my application to define the date input as a range in something in the following format(2016-01-01T00:00:00). How can a AngularJS slider be modified to be used for date inputs?
Comment: have you tried any code? Please provide the example you have tried.
Comment: @AgamBanga https://jsfiddle.net/ajdno6gc/
Comment: seems like there is some js error in your fiddle
Comment: @AgamBanga this is the code which i want to modify to create a slider for fetching range of date in the format as mentioned above. https://codepen.io/anon/pen/avGJGp?editors=1010
Comment: Please check if the answer works for you
Comment: @AgamBanga thanks but to an extent. As i want to get a date range
(2009-01-01---2015-01-01) which is not happening. also currently only the month value is changing not the day and year. is there a way to change them in a way which is easier to understand for the user too?
Comment: Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/144264/discussion-between-rehan-and-agam-banga).
Comment: check this https://jsfiddle.net/agamb/954eve2L/1618/   let me know if it works for you
Comment: Does it work for you?
Comment: @AgamBanga it would be better if you could please edit your answer to the latest version which is more appropriate to the question
Answer: I have added an example on jsfiddle
HTML

            <rzslider  rz-slider-model="slider.minValue"
          rz-slider-high="slider.maxValue"
          rz-slider-options="slider.options"></rzslider>

JAVASCRIPT
var app = angular.module('rzSliderDemo', ['rzModule', 'ui.bootstrap']);

app.controller('MainCtrl', function ($scope, $rootScope, $timeout, $modal) {
var date1 = new Date(2017, 3, 1);
var date2 = new Date();
var day;
var dateArray = [date1];
while(date1 <= date2) {
    day = date1.getDate()
    date1 = new Date(date1.setDate(++day));
    dateArray.push(date1);
}
$scope.slider = {
   minValue: dateArray[0],
  maxValue: dateArray[dateArray.length-1],
  value: dateArray[0], // or new Date(2016, 7, 10) is you want to use different instances
  options: {
    stepsArray: dateArray,
    translate: function(date) {
      if (date != null)
        return date.toISOString();
      return '';
    }
  }
};
});

Comment: Could see this link?https://stackoverflow.com/questions/45350964/make-32-hrs-range-in-rzslider-in-angular-js
Comment: It seems some things have changed in jsfiddle since this was posted and the original now gets angular module errors, I made a fixed version here: https://jsfiddle.net/8x6wfa3n/
Comment: Hi @EduardoWada, i have updated the link provided. Thanks for informing. :)


What are the subgroups of $\mathbb{Z}_{5}^\ast \times \mathbb{Z}_{4}^\ast$? I think I count $5$ of them.

Question: What are the subgroups of $\mathbb{Z}_{5}^\ast \times \mathbb{Z}_{4}^\ast$? I think I count $5$ of them I think? Thank you for anyone that puts the time in to help!
Comment: Ok. There are 3 subgroups of order 4, 3 subgroups of order 2; making a total of 8, including the whole group and the trivial group.
Comment: You forgot a few. How many of each order did you find?
Comment: Lets see the subgroup of order $1$ is the identity, and the subgroup of order $20$ is the whole group. Then there is subgroups of order 2, 4, 5, and 10 right? Hmmm then if that is the case it appears that there is more then 5.
Comment: Hold on, ${\mathbb Z}_5^* \times {\mathbb Z}_4^*$ has only 8 elements, so something is wrong. Are you thinking of ${\mathbb Z}_5 \times {\mathbb Z}_4$ maybe? Also has more than 5 subgroups, though.
Comment: Whoops. Thanks. I still mean $\mathbb{Z}_{4}^\ast \times \mathbb{Z}_{5}^\ast$. My bad. I would still like to list the subgroups so the identity and whole group itself still work.
Comment: Can I ask you one more question? Since $\mathbb{Z}_{4}^\ast \times \mathbb{Z}_{5}^\ast$ is isomorphic to $\mathbb{Z}_{20}^\ast$ which is isomorphic to $e^{\frac{2 \pi i}{20}}$, would there still be $8$ subgroups of the group $Gal(L/\mathbb{Q})$?
Comment: I feel I'm missing some context here. What is $L$? Of course, ${\mathbb Z}_{20}^*$ has 8 subgroups as well.
Answer: As @Ian posted nicely $$\mathbb Z_5^*\times\mathbb Z_4^*\cong\mathbb Z_4\times\mathbb Z_2$$ Now think about the latter group. If $H\leq \mathbb Z_4\times\mathbb Z_2=G$ then $|H|=1,~2,~4,~\text{or}~~8$ according to Lagrange's theorem and this fact that $|\mathbb Z_4\times\mathbb Z_2|=8$. Since we are working with easy groups so we can list all elements of $G$ as follows:
$$(0_{\mathbb Z_4},0_{\mathbb Z_2}),~~(1_{\mathbb Z_4},0_{\mathbb Z_2}),~~(2_{\mathbb Z_4},0_{\mathbb Z_2}),~~(3_{\mathbb Z_4},0_{\mathbb Z_2})\\
(0_{\mathbb Z_4},1_{\mathbb Z_2}),~~ (1_{\mathbb Z_4},1_{\mathbb Z_2}),~~(2_{\mathbb Z_4},1_{\mathbb Z_2}),~~(3_{\mathbb Z_4},1_{\mathbb Z_2})$$ Clearly some subgroups of $G$ is the cyclic ones, but we should care about this point that some of them may be generated twice. For example: $$H_1=\langle(0,0)\rangle=\langle0_G\rangle\\H_2=\langle(1,0)\rangle=\{(1,0),(2,0),(3,0),(0,0)\}\cong\mathbb Z_4\\ H_3=\langle(2,0)\rangle=\{(2,0),(0,0)\}\cong\mathbb Z_2\\ H_4=\langle(3,0)\rangle=\{(3,0),(2,0),(1,0),(0,0)\}\cong\mathbb Z_4\\ H_5=\langle(0,1)\rangle=\{(0,1),(0,0)\}\cong\mathbb Z_2 $$  Using GAP (in particular, AllSubgroups and StructureDescription), possible isomorphism types of subgroups of $G$ are:
1, C2, C2 x C2, C4, C4 x C2

Comment: Nice work! +1 for groups!
Answer: $(\mathbb Z/5\mathbb Z)^\times\cong\mathbb Z/4\mathbb Z$. $(\mathbb Z/4\mathbb Z)^\times\cong \mathbb Z/2\mathbb Z$.


Uniform integrability when $\forall g \in \mathcal{L}^1$ there is always an $|f_n|>|g|$

Question: Suppose we have a sequence of measurable $f_n:X\rightarrow \mathbb{C}$ with the property that for every $g\in \mathcal{L}^1$, there is an $N$ such that $|f_N|>|g|$.
Can such a sequence be uniformly integrable?
Answer: Assume that the sequence is UI and choose $\delta$ so that for all $n$ we have $\int_E f_n < 1$ for all $E$ with measure at most $\delta$. Let $A$ be any set of measure $m \leq \delta$.
Take $g_n := n 1_A$. By assumption we can find a sequence $n_k$ such that $|f_{n_k}| > k 1_A$.
But then $\int f_{n_k} >  k m > 1$ for $k$ large enough.
Thus if $X$ has sets of arbitrarily small positive measure, the sequence $f_n$ cannot be UI.
What if $X$ does not have any sets of positive measure smaller than some $m$? Then the definition of UI says for all $\epsilon > 0$ there is $\delta > 0$ such that $\int_E f_n < \epsilon$ when $E$ has measure at most $\delta$. Well, take $\delta = m$, then any set of measure at most $\delta$ has measure zero and $\int_E f_n = 0$. On such spaces all subsets of $L^1$ are UI, including your sequence $f_n$.
Answer: Assume that for all integrable function $g$, there exists $N$ such that for all $x$, $\left\lvert f_n\left(x\right)\right\rvert \gt \left\lvert g\left(x\right)\right\rvert$.
Then the sequence $\left(f_n\right)_{n\geqslant 1}$ is not even bounded in $\mathbb L^1$ hence not uniformly integrable. Indeed, the assumption implies that for each integrable function $g$,
$$
\int\left\lvert g\left(x\right)\right\rvert\mathrm d\mu\left(x\right)  \leqslant \sup_{n\geqslant 1}\int\left\lvert f_n\left(x\right)\right\rvert\mathrm d\mu\left(x\right).
$$
But $\int\left\lvert g\left(x\right)\right\rvert\mathrm d\mu\left(x\right) $ can be arbitrarily large.


How can I cut email addresses with sed?

Question: I have the following emails.txt with:
email@example.com
email@example.com
firstname.lastname@example.com;es
firstname.lastname@example.com
email@example.com
@pepito.com

And a sed command to get
sed -n -r '/\w+@\w+\.\w+((\.\w+)*)?/p' emails.txt

email@example.com
firstname.lastname@example.com

But, it keeps displaying email with more than one .com
I don't want these emails :
firstname.lastname@example.com
email@example.com;es
firstname.lastname@example.com
@pepito.com

I'm stuck here and I have no clue about how to get it.
Comment: What emails do you want? Only those that are `email@example.com`? Why do you want `@pepito.com`? How about `firstname.lastname@example.com`? Are you trying to match only addresses whose domain is `foo.com` and nothing else?
Comment: Yes I just want the emails with email@example.com, I don't want pepito cuz doesn't match with email@example.com, but my command display email@example.com etc
Answer: With sed, you could do:
$ sed -nr '/^[^@]+@[^.]+\.com\s*$/p' file
email@example.com
firstname.lastname@example.com

The regex looks for one or more non-@ characters at the beginning of the line, then a @, then one or more non-. characters followed by .com and then 0 or more whitespace.

Other choices:

Perl
perl -ne 'print if /^[^@]+@[^.]+\.com\s*$/' file

GNU grep
grep -P '^[^@]+@[^.]+\.com\s*$' file

POSIX grep
grep -E '^[^@]+@[^.]+\.com\s*$' file

awk
awk '$0~/^[^@]+@[^.]+\.com\s*$/' file

Comment: There may not wihitespace at the end, but \r.
Comment: I would use egrep instead.
Comment: @Pilot6 not a problem, `\s` matches `\r` as well.
Comment: @Pilot6 sure, or various other tools. You can use the same regex on all of them. Just don't use `egrep`, that's been deprecated in favor of `grep -E` (see `man grep`).
Comment: I did not know that. I always use egrep, but I know that -E is same.
Comment: Where did you find that it was depreciated? When?
Comment: @Pilot6 many years now. It still works but it might stop doing so at any time. `egrep` is a link to `grep` on most systems still but there's no guarantee that it will continue to be so. Just read the first few lines of `man grep` or see [here](http://linux.die.net/man/1/grep) (second paragraph of the description)
Comment: @terdon major typo in your regex..
Comment: @AvinashRaj that comment would have been more useful had you actually told me where the typo was.
Comment: I edited already... see the revisions.
Comment: @AvinashRaj oh,  man! Sorry, I was on mobile and couldn't see that you had edited so I was wondering why you hadn't fixed it instead of leaving a cryptic comment. Of course,  it turns out you had! Thanks and sorry for missing it.
Comment: No, need for sorry. You're my guru...
Answer: I would use something like this :
sed -n -r '/\w+@\w+\.com$/p' emails.txt

email@example.com
email@example.com

It will retrieve every email in format firstname.lastname@example.com
In case you need something more "universal" and not only .com but also .fr or .uk you can use :
sed -n -r '/\w+@\w+\.\w+$/p' emails.txt

This will retrieve every email in format firstname.lastname@example.com
Comment: I would take this one I understand this one much better thank you man.
Comment: So feel free to accept this answer if it actually answers and solves your problem... ;)
Answer: The expression ((\.\w+)*)? matches additional sequences of the form .xyz after the first domain. If you want to match only those addresses with a single domain, then you can enforce that by replacing it with $ or (more robustly) \s*$
sed -n -r '/\w+@\w+\.\w+\s*$/p' emails.txt

to require that there is nothing (except possibly whitespace) between the first domain and the end of the line.

How can I cut email addresses with sed?


Placing a chest so it faces a specific direction

Question: How can I place this chest in a 180 degree angle on the Y axis?
/summon FallingSand ~ ~ ~2
{
    Block:"minecraft:chest",Time:1,TileEntityData:
    {
        Items:[
        {
            id:"minecraft:stained_glass",Damage:4,Slot:11,Count:1,tag:
            {
                CanPlaceOn:["minecraft:iron_block"]
            }
        },
        {
            id:"minecraft:stained_glass",Damage:3,Slot:13,Count:1,tag:
            {
                CanPlaceOn:["minecraft:iron_block"]
            }
        },
        {
            id:"minecraft:stained_glass",Damage:1,Slot:15,Count:1,tag:
            {
                CanPlaceOn:["minecraft:iron_block"]
            }
        }
    ]}
}

I tired changing it like how I do with other blocks, but it did not work.
Comment: With the `/setblock` command, the chest will face away from whatever block is next to it. Hopefully you can make it work in that way. I am doing some more research for you now.
Comment: [This](https://bugs.mojang.com/browse/MC-31365) could help you.
Answer: The Data tag for FallingSand states the Damage value of the block, and in the case of chests, determines the directional facing. You can find various values for chest facing here.
/summon FallingSand ~ ~ ~2 {Block:"minecraft:chest",Data:3,Time:1,TileEntityData:{Items:[{id:"minecraft:stained_glass",Damage:4,Slot:11,Count:1,tag:{CanPlaceOn:["minecraft:iron_block"]}},{id:"minecraft:stained_glass",Damage:3,Slot:13,Count:1,tag:{CanPlaceOn:["minecraft:iron_block"]}},{id:"minecraft:stained_glass",Damage:1,Slot:15,Count:1,tag:{CanPlaceOn:["minecraft:iron_block"]}}]}}


Can´t save to directory with Bitmap.Save()

Question: I can´t seem to manage saving a bitmap to a file.
This is my code:
FileInfo lInfo = new FileInfo("C:/Content/save/map.png");
Debug.WriteLine(lInfo.FullName);
using (var m = new MemoryStream())
{
     save.Save(m, ImageFormat.Png);
     var img = Image.FromStream(m);
     //TEST
     if (System.IO.Directory.Exists("C:/Content/save/map.png"))
        img.Save("C:/Content/save/map.png");
     else
        Debug.WriteLine("directory does not exist");
     img.Dispose();
     }

save is
save = CreateNonIndexedImage(Bitmap.FromFile("Content/save/map.png"));

The directory does exist but my code can´t access it.
picture of directory: http://puu.sh/6VLhD.png
Comment: At a guess your user does not have permissions to write to this folder. Normally, UAC will have to be invoked to write to a folder outside of your user area.
Answer: Problem :  You are providing file path to the Directory.Exists() method.
Solution :  You need to provide the Directory path to the Directory.Exists() method.
From MSDN : Directory.Exists()

Determines whether the given path refers to an existing directory on
  disk.

Replace This:
if (System.IO.Directory.Exists("C:/Content/save/map.png"))

With This:
if (System.IO.Directory.Exists("C:/Content/save"))


A question about to isomorphic of two groups

Question: (A) Show that $(\Bbb Z/5\Bbb Z)^\times$ is isomorphic to $(\Bbb Z/10\Bbb Z)^\times$
(B) $(\Bbb Z/8\Bbb Z)^\times$ is not isomorphic to $(\Bbb Z/10\Bbb Z)^\times$.
For (A) since these groups are cyclic hence isomorphic exist between these groups
Am I  right?
I don't have idea about (B)
Comment: What is $x$?${}{}$  Are you using $x$ to designate $\times$?  I mean, are you trying to ask, e.g. whether $(\mathbb Z/5)^\times \cong (\mathbb Z/10)^\times$?
Comment: yes that is right
Answer: In $(\Bbb Z/8\Bbb Z)^{\times}=\{1,3,5,7\}$ any element $x$ verify $x^2=1$. But in $(\Bbb Z/10\Bbb Z)^{\times}$, $3^2=9\neq 1$.


Two different views and a link

Question: I am working on a web page where a data entry can be viewed in two different ways: a table view or an interactive view.
Also, there should be a link that takes the user to a "compare" page.
I am trying to come  up with the UI layout and this is my current plan with 3 clickable icons:

download bmml source – Wireframes created with Balsamiq Mockups
Clicking on the first two icons would change "Data" section to the selected view, and the rightmost icon would take the user to the "compare" page.
However, I feel like the "compare" button doing something completely different from the other two while being side-by-side is not an intuitive design. What is the best way to go about this?

Add labels beneath the buttons saying "table view", "interactive view" and "compare" to convey that the rightmost button does something different?
Keep the "view" buttons and add a "Compare" textual link beneath them?
Add a toggle switch between the "view" icons?
Others?

Note: This is just one section of the page. There are stuff above and below so I want to keep the UI contained within the two rectangular boxes for the overall layout consistency.
Comment: Can you clarify how the compare option works? Because it's a different mechanic from the view options, so it may only require more space to convey the idea of difference, but it may not be enough. What does the user see on screen on each selected option?
Comment: @PatomaS The compare page is a separate page where the user can select data entries for a side-by-side comparison and graphs and similar stuff, with the current entry pre-selected.
Comment: Ok, so I'm visualizing two windows or two areas on the screen, a left column with controls and something else, and a right area with the data. My answer works with that, plus I added a bit more once you sent the comment.
Answer: Definitely not the toggle switch — it is designed for mutually exclusive options, by introducing it you will be telling user there is no other option than the two.
I personally dislike the labels, as they are often redundant once the icon idea is clear to the user.
"Compare" is too non-explanatory and could mean anything in terms of UI, for example, GitHub code comparison frames.
I would simply add another icon with table and graph, combined.

P.s. I've moved toggles to the data component, because unless "Some stuff" means other operational controls, toggles are too detached from the content they call up.
Answer: I would combine options 1 and 3, add labels and change from two view icons to one.
Add labels for clarity, that always work and is always helpful and if there are only two view modes, alternating between them is a good solution to save screen space, leave more room for the labels and help the user.
On the data side, inform the user, using text and icon, which view mode is being used.
If you go for the option with one button to toggle view, there is no much need to isolate the "compare" button since both would be doing different actions and there will only be two. If you decide to use an option with three buttons, then you have to separate the different one from the other two to convey easier the idea of different kind actions; you can do that with mere space, background colour, a vertical line, a combination of the mentioned ones and, most probably, in some other ways.

Two different views and a link


rewrite URL with multiple parameters using .htaccess

Question: What I want to achieve?

www.example.com/list/1/2

my .htacess file
RewriteRule ^list/([0-9a-zA-Z]+) list.php?id=$1&p=$2 [NC,L]

How can I fix that?
Comment: Possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](https://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained)
Answer: Try:
RewriteRule ^list/([0-9a-zA-Z]+)/([0-9a-zA-Z]+) list.php?id=$1&p=$2 [NC,L]


In a tournament $n$ players take part in a series of duels

Question: I've recently been thinking about this problem and I think I solved it correctly. However, I was using a rather peculiar method with lots of algebra. I'll post my solution as an answer below. Is there a better (or just different) way of solving this problem?
Problem
In a tournament $n$ players take part in a series of duels in which both players have equal chances of winning. After each duel the winner plays against the player, that hasn't played for the longest time (or in the beginning someone that hasn't played yet). The first player to beat all other players in consecutive duels wins the tournament. What is the probability that a player wins the tournament given that he takes part in the first duel?
An example with $n=3$
Alice and Bob start and Colin sits out first.
Alice beats Bob, Colin beats Alice, Bob beats Colin, Bob beats Alice. Bob wins the tournament.
Here Alice, Bob and Colin had winning probabilities $\frac{5}{14}$, $\frac{5}{14}$, $\frac{4}{14}$ respectively.
EDIT: Only 3 days left for the bounty. We don't want those points to disappear into nirvana, do we? :(
Answer: My solution, based on setting up a matrix equation and then using the adjugate matrix to find the essential entries of the inverse matrix.

(or click https://i.stack.imgur.com/PSvKd.png if it's too small)
So apparently a formula for the probability that the first player wins the whole tournament is
$$p(n)=\frac{2^{n+1}(2^{n-1}+1)^{n}}{2^{n+2}(2^{n-1}+1)^{n}+(2^{n+1}+4)^{n}-(4^{n}+4)\cdot2^{n^{2}-n}-2^{n^{2}+2}}$$
e.g.
$p(1)=1$, $p(2)=\frac{1}{2}$, $p(3)=\frac{5}{14}$, $p(4)=\frac{81}{298}$
EDIT:
Here's an explanation of the initial formulas above.
In the following table the cell at row $i$ and column $j$ represents the state in which you stand at the $i$th position in the queue and the person in front has already won $j$ duels in a row. Let's call that state $s_{i,j}$. Let the probability of winning starting at state $s_{i,j}$ be $q_{i,j}$. Then $q_{i,1}=p_i$, which I had defined above.
Note, that I have duplicated the nth row for convenience.

Now, each blue arrow represents either outcome of the next duel which both occur with probability $1/2$. From the diagram you can see that you can only win if you reach the $1$ in the rightmost column.
We have $q_{2,1}=\frac{1}{2} q_{1,1} + \frac{1}{2} q_{n,2}$ and $q_{n,2}=\frac{1}{2} q_{n-1,1} + \frac{1}{2} q_{n-1,3}$ etc.
So indeed $$q_{2,1}=\frac{1}{2} q_{1,1} + \frac{1}{4} q_{n-1,1} + ... + \frac{1}{2^{n-2}} q_{3,1}$$
which is the first of my formulas. The others are found similarly.
Comment: Considering that the question is "What is the probability that a player who takes part in the first duel wins the tournament?", I think your probabilities need to be doubled, other than for p(1).
Comment: Your solution seems pretty solid-- I tried to come up with something without reading yours, and went down the same road
Comment: @CalvinLin Good point. I could have phrased the question better. I meant to ask for the probability that a player wins the tournament given that he takes part in the first duel.
Answer: Here's is an answer using a slightly different approach.
We denote the $n$ players with $player_1$ to $player_n$ according to the order of their duels. So the first duel is between $player_1$ and $player_2$, the next duel is the winner of the first duel with $player_3$ until finally $player_n$ has his chance to win the game.
Let's denote with $p_k$ the probability that the $k$-th player win's, i.e. he is the first who wins $n-1$ consecutive duels against all other players.

The idea for the Ansatz below is that the structure of the binary decision tree for $player_k$ is essentially the same as for $player_{k+1}$ with a shift of one duel and this holds for all players $player_k$ with $2\leq k\leq n-1$.

For $player_1$ and $player_2$ the decision tree is symmetric, so we have $p_1=p_2$.

For $player_k$ and $player_{k+1}$ the following is valid
  \begin{align*}
p_1&=p_2\tag{1}\\
p_k&=\left(1+\frac{1}{2^{n-1}}\right)p_{k+1}\qquad2\leq k \leq n-1\tag{2}
\end{align*}

The equation in $(2)$ tells us, that $p_{k}$ is essentially equal to $p_{k+1}$ with the advantage, that a run of $n-1$ consecutive duels was already done by $player_k$. Thereby correspond $n-1$ consecutive duels to the factor $\frac{1}{2^{n-1}}$ and this path of length $n-1$ in the binary decision tree is weighted with the sum of all probabilities of the nodes in the tree where $player_{k+1}$ resides. This corresponds to the multiplication with $p_{k+1}$.

This Ansatz gives us following system of equations:
\begin{align*}
p_1+p_2+\dots+p_n&=1\tag{3}\\
p_1&=p_2\tag{4}\\
p_k&=p_n\left(1+\frac{1}{2^{n-1}}\right)^{n-k}\qquad 2\leq k \leq n-1\tag{5}
\end{align*}
Note: Please observe how the probabilities $p_k$ are built from $p_n$. If we know the stopping probability of $player_n$ and the proportion of probabilites between two consecutive players we know the probability for all players. So $(5)$ gives us a proper insight into the behaviour of the game.

Now substituting $(4)$ and $(5)$ in $(3)$ gives

\begin{align*}
p_n=\frac{1}{1+\left(1+\frac{1}{2^{n-1}}\right)^{n-2}+\sum_{k=2}^{n-1}\left(1+\frac{1}{2^{n-1}}\right)^{n-k}}\qquad (n\geq2)
\end{align*}

If we use $q_n:=1+\frac{1}{2^{n-1}}$ as shorthand we get after some simplifications

\begin{align*}
p_n&=\frac{1}{1+q_n^{n-2}+\sum_{k=2}^{n-1}q_n^{n-k}}\\
&=\frac{1}{2^{n-1}}\left(\frac{1}{2q_n^{n-1}-q_n^{n-2}-1}\right)\qquad (n\geq2)\\
\end{align*}

Since $p_k=q_n^{n-k}p_n$ we finally get for $n\geq 2$

\begin{align*}
p_1&=p_2\\
p_k&=\frac{1}{2^{n-1}}\left(\frac{\left(1+\frac{1}{2^{n-1}}\right)^{n-k}}
{\left(1+\frac{1}{2^{n-2}}\right)\left(1+\frac{1}{2^{n-1}}\right)^{n-2}-1}\right)\qquad(2\leq k\leq n)\tag{6}\\
\end{align*}

Note: Setting $k=2$ in $(6)$ gives the probability for $player_1$ resp. $player_2$ to win, which corresponds to the value $p(n)$ in the answer from alex.
Comment: Nice! This is exactly what I was looking for. Your solution also gives the winning probabilities for the other players, which is amazing :) I am, however, still confused about equation (2). Could you try explaining it to me with a bit more detail? Thanks!
Comment: @Alex: First of all thanks a lot for the bounty! I'm sorry, but at the time I have no better explanation than the rather phenomenological reasoning I'v stated in the answer. I found the relation $(2)$ empirically, based upon three aspects. At first the values for $n=3,4$ with the help of your matrix! Then a concise knowledge of the binary decision tree for $n=3$ as verification for it (based upon regular expressions and derived generating functions). Regrettably for $n>3$ the things become far too complex to describe it in the same way.
Comment: @Alex: (continued) (which was one of my approaches, namely fully implementing the game and trying to analyse the tree structure). And the third and very important aspect were *your* equations, which already contain this information! Consider your stated equations $p2=rhs$ and $p3=rhs$. Now transform the first one into $p2-\frac{p3}{2^{n-2}}=\dots$ and the second into $2p_3-p_2=\dots$ ... You see, what I mean? Maybe you could provide a better explanation of $(2)$?!?! :) Best regards!
Comment: Oh, nice observation. Our formulas are indeed equivalent! You avoided the whole matrix thing with that transformation :) I added a picture to aid in understanding my formulas. By the way, the case for $n=3$ was in one of my exams this summer; I think this generalization resulted in a fun question :D
Comment: @Alex: Nice picture, with the formulas below it points out the connection of our answers. :) But, I think that these transition probabilities are limiting (cumulative) probabilities, already adding the probabilities of (structurally) different pathes of the decision tree. So, presumably we won't get a deeper insight of formula $(2)$ from this representation.