text:
Q: Why is the notation for irrational number not mainstream? In everywhere you see the symbol for the set of rational number as $\mathbb{Q}$
However, to find actual symbol to denote the set of irrational number is difficult. Most people usually denote it as $\Bbb{R}\backslash\Bbb{Q}$
But recently I saw someone using $\mathbb{I}$ to denote irrational numbers. I like it and wish for it to be more mainstream.
Will $\mathbb{I}$ ever catch on?

A: Strictly speaking "will this notation I like ever catch on?" Is inappropriate for this site. But we can still weigh the pros and cons of the suggestion and mention any variants we know.
Cons:

*

*Introduces yet another symbol to memorize

*weak improvement over the obvious alternative

*Rarely do you talk enough about irrationals collectively  to warrant special notation

*Already sometimes used for idealizers in ring theory.

*Similar to notation for the unit interval that I've seen.

*Breaks a pattern of using blackboard bold for familiar sets with algebraic structure

Pros:
1. You write one symbol instead of two with a backslash
So basically I think you're finding yourself in the position of the guy on Shark Tank pitching the product that solves a problem nobody has.
Variants:
None I've seen.


text:
Q: Can you override NSDateFormatter 12 vs 24 hour time format without using a custom dateFormat I want to convert a Date as a display string in the user's time zone, but I want to use 24 hour time format rather than 12 hour time format.
I know I can do that by explicitly setting a custom dateFormat string, but that loses the benefit of letting the system generate strings that conform to the user's locale setting.
NSNumberFormatter has settings that let you change aspects of the conversion, like the decimal separator.
Is there a setting for NSDateFormatter that will let me switch between 12 and 24 hour format without having to resort to a completely custom format?

A: DateFormatter has the dateFormat(fromTemplate:options:locale:) method. Use this to get a proper 24-hour format based on the user's locale.
let fmt = DateFormatter.dateFormat(fromTemplate: "Hms", options: 0, locale: Locale.current)

Though this seems to return HH:mm:ss for most locales. Only 85 of the 739 available locales return something other than HH:mm:ss.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Geodesics of the $\mathbb{S}^n$ are great circles I am trying to show that the geodesics of $\mathbb{S}^n$ are the great circles, as an exercise for my introductory Riemannian geometry class. I don't really know how to go about this. I suppose that using the geodesic equation would be too complicated so I am trying to use the fact that if $M$ is a submanifold of $\mathbb{R}^N$, $c$ a smooth curve on $M$, and $X$ a vector field along $c$, then the covariant derivative along $c$ $\frac{D}{dt}X=(\frac{dX}{dt})^T$, where $(\frac{dX}{dt})^T$ is the tangent part of the usual derivative in $\mathbb{R}^N$.
Could anyone provide a hint on how to proceed? Thanks


text:
Q: next() is not returning the request after validation in node js I was Building a E-commerce website, for that to validate a user, I used express-validator to validate the the following attributes,
exports.validateSignupRequest = [
    check('firstName')
    .notEmpty()
    .withMessage('Firstname is Requied'),
    check('lastName')
    .notEmpty()
    .withMessage('Lastname is Requied'),
    check('email')
    .isEmail()
    .withMessage('Valid email is Requied'),
    check('password')
    .isLength({min: 6})
    .withMessage('Password must be atleast 6 Characters long')
];

for validating the request, I wrote the following function
exports.isRequestValidated = (req, res, next) => {
    const errors = validationResult(req);
    if(errors.array().length > 0){
        return res.status(400).json({ error: errors.array()[0].msg })
    }
    next();
}

But the problem is next() is not returning any response to the path
router.post('/signup', validateSignupRequest, isRequestValidated, signup);

In controller file I wrote, Something Went wrong for, if code has any error
_user.save((error,data) => {
            //if input has any error, else not upto standards then throw the error message
            if(error){
                return res.status(400).json({
                    message: 'Something Went Wrong'
                });
            }

Eventhough All of my attributes are properly upto the standards, I'm getting
Postman output asPostman Output
How can I get rid off this?


text:
Q: Was age a motivating factor in George Lucas changing Anakin in "Return of the Jedi" from being an old man to a young man?
Straight to the point.
First, this is not a duplicate of this thread regarding the change of Anakin's "Force Ghost" from one actor to another in Return of the Jedi. This is specifically about the presented age of Anakin's "Force Ghost" and I am not seeking deep evidence of age-ism in any way; just evidence of age of the character being a motivating factor.
Now, I have read all of the reasoning I have been able to consume on why Anakin's "Force Ghost" was changed from Sebastian Shaw to Hayden Christen at the end of Return of the Jedi but none seems to address an issue I see: Was age a primary motivating factor in redoing the "Force Ghost" from being an older version of Anakin versus a younger version of Anakin.
Darth Vader is old and decrepit and evil… But Anakin Skywalker is young and brave and beautiful… Seems quite patronizing and even makes his redemption at the end of Return of the Jedi seem fake. He found good in him when he was Darth Vader and saw the Emperor killing his son and turned on the Emperor to save the future.
To me, Luke being young and his father being old—and a ghost—makes sense. Luke never fully went "dark" and his father is the one who ultimately ensured he would stay in light. Yes, Anakin was Darth Vader for a good chunk of his adult life… But still… The ending where Luke see's his father as some kid who is younger than him? It's just odd.
Was age a role in George Lucas's desire to do this so Anakin would look young and cool to the merchandise buying youth of today?
More details.
This question and answer thread was spurred by this recent question:

*

*Unless they were clairvoyant, how were audiences expected to recognize who was the third Force ghost/spirit at the end of "Return of the Jedi?"
And this question and answer thread:

*

*What was George Lucas' reasoning for changing Anakin's head?
First the first question about recognition is quite fair: Seeing a young man appear out of nowhere after watching an old Darth Vader die is just cognitively hard to understand unless you have watched the prequels.
And the second question was simply about changing Anakin's head to make his appearance as a "Force Ghost" more consistent with the prequels.
But this question is something different about this whole Sebastian Shaw versus Hayden Christensen switcheroo: Was any of this based on simple audience pandering towards age? Meaning, George Lucas clearly geared the prequels towards kids—far more than the original trilogy—but to me this Anakin "Force Ghost" thing really irks me.
I mean, I understand the bass-ackwards logic that Anakin was only a Jedi for a certain period of his life and then became Sith in the later part of it. But to me it seems the story of redemption is actually lost. Vader/Anakin could not fight age or the decay of his already dysfunctional body. And in an act of love for his son, he killed a great source of evil that destroyed his life, family and threatened to destroy the future. To me, in the end… When Darth Vader was unmasked as an old, dying man that old dying man was redeemed. His spirit as a Jedi was validated by that final act. Thus his  "Force Ghost" being old makes sense.
UPDATE: FWIW, Star Wars concept artist Iain McCaig in Art of Star Wars: The Force Awakens presented some ideas that messed around with the concept of what Anakin's "Force Ghost" was meant to represent in The Force Awakens:

'When you light a candle, you also cast a shadow.' That inspired me to
  propose, for the first time, that Anakin's ghost could come back […]
  If we see Anakin Skywalker, because he does flow back and forth
  between Darth Vader and Anakin, let's see him as a character with a
  dark and light side. The reason Luke is this whole new entity is
  because he was the first to acknowledge his own dark side — that it
  was not separate from him.

The ideas were ultimately discarded, but to me it shows that they idea that young Anakin is simply the "good" version because that is before he turned "bad" is actually not as solid an idea as some would imply. They just wanted a teen-heartthrob young guy to tie the concepts of the prequels to the original trilogy.

A: This ties in quite heavily with a key change that Lucas wanted to make now that his "6 episode" film series was completed, exploring the shift between Anakin as a boy/man and Anakin as Vader.
Dave Filoni, the maker of Star Wars: The Clone Wars stated (in the interview below) that he discussed this issue with George Lucas and that the thinking was that Anakin would have reverted to the last good iteration of his personality, washing away the bad old man.

"It doesn't make sense mythologically for him to maintain the guise of
  the old man afterward in the Force, because he was never good. He was never balanced when he was that person. When he was the wicked old man. So he had to shed that skin like everything else. He then appears as a young man".

So the answer to your main question is yes, there was a definite desire to portray Anakin as a younger man, specifically to demonstrate the change in his character and the reversion to his (good) younger self from the "wicked" older man he'd been a few scenes ago.


text:
Q: Nested Cluster in pydot I want to arrange the nodes in such a manner that there are 2 clusters A and B.
B has further 2 clusters C and D.
For the same i wrote the below program in which i am adding 2 clusters inside one and then adding cluster B as a subgraph in main graph.
However the nested boxes do not appear. Can someone tell me what am i doing wrong ?
import pydot

def draw( ListA , ListB , ListC , filename ):
    graph = pydot.Dot(graph_type='digraph',fontsize = 50  )
    List_nodesA = []
    List_nodesB = []
    List_nodesC = []
    cluster1 = pydot.Cluster( "A" , color = ".3 .5 .7"  )
    cluster2 = pydot.Cluster( "D" , color = ".6 .5 .2"  )
    cluster3 = pydot.Cluster( "C" , color = ".7 .5 .9" )
    cluster4 = pydot.Cluster( "B" )
    for item in ListA:
        List_nodesA.append(pydot.Node(str( item ) , shape = "circle", style="filled", fillcolor="0.5 0.4 0.9" ))
    for item in ListB:
        List_nodesB.append(pydot.Node(str( item ) , shape = "circle", style="filled", fillcolor="orange"))
    for item in ListC:
        List_nodesC.append(pydot.Node(str( item ) , shape = "circle", style="filled", fillcolor="green"))

    for node in List_nodesA:
        cluster1.add_node( node )

    graph.add_subgraph( cluster1 )
    for node in List_nodesB:
        cluster2.add_node( node )  # create cluster D
    cluster4.add_subgraph( cluster2 ) # add it to B

    for node in List_nodesC:
        cluster3.add_node( node ) # create cluster C
    cluster4.add_subgraph( cluster3 ) # add it to B

    graph.add_subgraph( cluster4 )
    for vertex1 in List_nodesA:
        for vertex2 in List_nodesB:
            graph.add_edge( pydot.Edge( vertex1 , vertex2 , len=1.5 ) )

    graph.write(filename,prog = 'neato',format = 'png')

draw( [1,2] , [3,4] , [5,6] , "graph.png" )

A: Neato does not support clusters, as it uses a spring model where node placement is very dynamic. If you replace neato engine with dot engine, your clusters will appear correcly.


text:
Q: marshal c struct to c# Does any body can marshal this part of c/c++ code in c# please?
typedef struct
{
    BYTE    bCommandCode;
    BYTE    bParameterCode;

    struct
    {
        DWORD   dwSize;
        LPBYTE  lpbBody;
    }
    Data;
}
COMMAND, *LPCOMMAND;

thanks a lot

A: First off, declare the above struct as a managed struct - something like:
    [StructLayout(LayoutKind.Sequential)]
    struct SomeStruct
    {
        byte bCommandCode;
        byte bParameterCode;

        SomeOtherStruct otherStruct;

        Data Data;
    }

    struct SomeOtherStruct
    {
        uint dwSize;
        byte lpBody;
    }

    struct Data
    {
    }

Though you may have to use the MarshalAs attribute here and there to ensure it's actually marshalling them as their proper types. If you want to then read this struct from memory for example, you could do something like:
        var bytes = ReadBytes(address, Marshal.SizeOf(typeof(SomeStruct)), isRelative);

        fixed (byte* b = bytes)
            return (T) Marshal.PtrToStructure(new IntPtr(b), typeof (SomeStruct));

I am assuming you want to read your struct from memory and marshal it into a managed struct, because otherwise you wouldn't even need the Marshal at all. Also, make sure to compile the above code with /unsafe enabled.

A: //01. Declare 'Command' structure
public struct Command
{
    public byte CommandCode;
    public byte ParameterCode;
    public struct Data
    {
        public uint Size;
        public IntPtr Body;
    }
    public Data SendData;
}

//02. Create & assign an instance of 'Command' structure
//Create body array
byte[] body = { 0x33, 0x32, 0x34, 0x31, 0x30 };

//Get IntPtr from byte[] (Reference: http://stackoverflow.com/questions/537573/how-to-get-intptr-from-byte-in-c-sharp)
GCHandle pinnedArray = GCHandle.Alloc(body, GCHandleType.Pinned);
IntPtr pointer = pinnedArray.AddrOfPinnedObject();

//Create command instance
var command = new CardReaderLib.Command
                  {
                      CommandCode = 0x30,
                      ParameterCode = 0x30,
                      SendData = {
                          Size = (uint) body.Length,
                          Body = pointer
                      }
                  };

//do your stuff

if (pinnedArray.IsAllocated)
    pinnedArray.Free();


text:
Q: SQL Server MDX query parameter I am very new to MDX query. I am trying to pass a parameter through my query. It is giving me this SQL error:

Query preparation failed.
The function expects a tuple expression for the 5 argument.
A tuple set expression was used.

The query is:
SELECT
{
[Measures].[DENOMINATOR]
,[Measures].[NUMERATOR]
,[Measures].[Goal]
}
ON COLUMNS,
NON EMPTY
(
 [Dim Indicator].[Indicator Set].[Indicator Set].ALLMEMBERS
 ,[Dim Indicator].[Indicator Group].[Indicator Group].ALLMEMBERS
 ,[Dim Indicator].[Indicator Name].[Indicator Name].ALLMEMBERS
)
ON ROWS
FROM [Dummy-Dashboard]

--Parameter Queries goes here

WHERE
(
    strtoset(@DimGenderGenderID)
 )

A: If you need to test you query with parameter you will need to use XMLA for that. Please see below example for xmla:
    <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
      <Body>
        <Execute xmlns="urn:schemas-microsoft-com:xml-analysis">
          <Command>
            <Statement>
              Your code in here
            </Statement>
          </Command>
          <Properties>
            <PropertyList xmlns="urn:schemas-microsoft-com:xml-analysis">
              <DataSourceInfo>Provider=MSOLAP;Data Source=local;</DataSourceInfo>
              <Catalog>CubeName</Catalog>
              <Format>Tabular</Format>
              <Content>Data</Content>
              <Timeout>0</Timeout>
            </PropertyList>
          </Properties>
          <Parameters xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:schemas-microsoft-com:xml-analysis">
            <Parameter>
              <Name>ParameterName</Name>
              <Value xsi:type="xsd:string">ParameterValue</Value>
            </Parameter>
          </Parameters>
        </Execute>
      </Body>
    </Envelope>


text:
Q: Web service API for DRMAA on SGE Does anyone know of any project to expose the DRMAA API (job scheduling and maintenance API) from SGE (Sun Grid Engine) as a web service API? A RESTful API would be best.

A: I do not think there are any web service API for SGE. I found drmaa-python pretty easy implementing in python script that can be called from server side scripts like PHP.

A: There is nothing like this available at the moment, but:
The Open Grid Forum started a new standardization activity to define how DRMAAv2 can be exposed as RESTful API. The specification draft is publicly available.
Since more and more people ask for such a remote interface, implementations might be available pretty soon. They are most likely to be announced by the OGF OCCI working group, so follow them if you are still interested.
Mapping such an implementation to the DRMAAv1 library in GridEngine should be relatively straightforward.


text:
Q: WSS/BPOS Is there an easy way to copy site-collections? Quite often I use site collections per calender year. They contain team sites with task lists and datawebsites(multipage meetingsites). When you copy the individual websites they do exactly what I want, keep the tasks and empty the datasites. Both are in the same site collection. So I thought if I can copy the site collection than it will save a lot of time. Any ideas, to do it the easy way?

A: To be able to create a site collection from a template, that template needs to be available at farm level (you should see it as an option in the create site collection page under app management). Saving a site as a template will save it at the site collection level. This article describes how to make your template a site collection template:
http://blog.gavin-adams.com/2007/07/03/creating-site-collection-templates/

A: If you save the root of the site collection as a template (STP file) I think it saves the subsites (your meeting workspaces).


text:
Q: jQuery Validation Engine not working Trying to use the jQuery validation engine for 1 text field. For some reason It's not doing anything. I don't any errors to work off. If anyone see's something missing or out of place, I'd appreciate it.`
<!DOCTYPE html>
<html>
<head>

<meta charset="UTF-8" />

 <script src='jquery-1.11.0.min.js'></script>
<script src="jQuery-Validation-Engine-master/js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
<script src="jQuery-Validation-Engine-master/js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>

<link rel="stylesheet" href="jQuery-Validation-Engine-master/css/validationEngine.jquery.css" type="text/css"/>

</head>
<body>

<form id="formID" name="myForm" method="post" action="submit.action">

     <input class="validate[required]" type="text" id="agree" name="agree"/>
     <button type="button" value="Save" id="Save" onclick="clicked();">Submit Survey</button>

</form>

<script type="text/javascript">

  function clicked() {
        if (confirm('Are you sure you want to submit?')) {
            $("#form.id").validationEngine();

        } else {
            return false;
        }
    }

 </script>
</body>
</html>`

A: You should initialize validationEngine like so and not in a onclick function:
$(document).ready(function(){
    $("#formID").validationEngine();
});

A: Your selector is wrong
change:
$("#form.id").validationEngine();

$("#form.id") --> refers to element with id form and class id
to:
$("#formID").validationEngine();

Read # id selector


text:
Q: Validator Does Not Show Errors At Blade I have a Controller method like this:
use Validator;
public function insert(Request $request)
{
    $data = Validator::make(request()->all(),[
        'title' => 'required',
        'name' => 'required|alpha_num',
        'activation' => 'nullable',
        'cachable' => 'nullable'
    ])->validated();

    $wallet = new Wallet();
    $wallet->title = $data['title'];
    $wallet->name = $data['name'];

    if (!empty($data['activation'])) {
        $wallet->is_active = 1;
    } else {
        $wallet->is_active = 0;
    }

    if (!empty($data['cachable'])) {
        $wallet->is_cachable = 1;
    } else {
        $wallet->is_cachable = 0;
    }

    $wallet->save();

    return redirect(url('admin/wallets/index'));
}

And then I tried showing errors like this:
@error("name")

{{$message}}

@enderror

But the problem is, it does not print any error when I fill the form incorrectly.
So how to fix this and show errors properly?
Here is the form itself, however it submits data to the DB correctly:
<form action="{{ route('insertWallet') }}" method="POST" enctype="multipart/form-data">
    @csrf

    Title

    <input type="text" id="title-shop" name="title" class="form-control" value="" autofocus>

    @error("title")

{{$message}}

    @enderror

    Name

    <input type="text" id="title-shop" name="name" class="form-control" value="" autofocus>

    @error("name")

{{$message}}

    @enderror

    <input class="form-check-input" type="checkbox" name="cachable" value="cashable" id="cacheStatus">

      With Cash

    <input class="form-check-input" type="checkbox" name="activaton" value="active" id="activationStatus">

      Be Active

    <button class="btn btn-success">Submit</button>
</form>

A: check the official documentation here
add the following code
if($data->fails()){
     return redirect(url('admin/wallets/index'))->withErrors($data)->withInput();
}

And after that save your data in your database

A: You are not returning any errors, you are just redirecting back to the view without any data.
Your fix would be to have your validator as this:
$data = Validator::validate(request()->all(),[
    'title' => 'required',
    'name' => 'required|alpha_num',
    'activation' => 'nullable',
    'cachable' => 'nullable'
]);

See that I have changed Validator::make to Validator::validate. As the documentation states:

If the validation rules pass, your code will keep executing normally; however, if validation fails, an exception will be thrown and the proper error response will automatically be sent back to the user.

If validation fails during a traditional HTTP request, a redirect response to the previous URL will be generated. If the incoming request is an XHR request, a JSON response containing the validation error messages will be returned.

So, if your validation passes, it will save all the validated data into $data, as you did with ->validated() (but you don't have to write it here), and if it fails, it will automatically throw an Exception, in this case ValidationException, so Laravel will automatically handle it and redirect back with to the same URL and with the errors. So it now should work...
This is the Validator::validate source code and this is the validate source code for the validator validate method.


text:
Q: IDictionary.Item returns wrong type I have an issue with the IDictionary.Item return type. Here is the code:
Class SomeClass Implements IComparer(Of C)

Private ReadOnly cache As IDictionary = New Dictionary(Of C, T)

Public Function compare(ByVal chr1 As C, ByVal chr2 As C) As Integer Implements IComparer(Of C).Compare
                Dim fit1 As T = Me.fit(chr1)
                Dim fit2 As T = Me.fit(chr2)
                Dim ret As Integer = fit1.CompareTo(fit2)
                Return ret
            End Function

Public Overridable Function fit(ByVal chr As C) As T
                Dim fits As T = Me.cache.Item(chr)  '<----- Here it fails
                If fits Is Nothing Then    '<------ False, because fits == 0.0
                    fits = fitnessFunc.calculate(chr)
                    Me.cache.Add(chr, fits)
                End If
                Return fits
            End Function
End Class

My cache is empty. MSDN says that IDictionary.Item returns the element with the specified key, or Nothing if the key does not exist. However, my fits type is Double and it equals 0.0 for unknown reason, though it must be Nothing. I am a bit puzzled, how can I do make it work properly? Help is very much appreciated.

A: double is a "value type" (rather then the common "reference type"s). It means that it cannot be Nothing, and when you expect it to be Nothing it will actually be its default value (which is 0.0 in double).
The same is correct also for all the primitive types (int, long, char...) and for Structure types.

A: If the dictionary contains value types or even reference types that are Nothing or nullable types that are Nothing, IDictionary.Item has no way of telling you whether an item was found in the cache or whether just the type's default value was returned because the key was not found.
Better use the TryGetValue method of the dictionary:
Dim fits As T
If cache.TryGetValue(chr, fits) Then
    ' We found an item in the cache
Else
    ' We must calculate the missing item and add it to the cache
End If

Note: The second parameter of TryGetValue is ByRef and returns the found item if available.


text:
Q: Deriving Typeable for Text.PrettyPrint.Doc I have an AST type that I want to derive as Typeable, so that I can do Scrap-your-boilerplate generic traversals of it.
However, the tree is annotated with messages in the Doc type of the Text.PrettyPrint library from the pretty package. To derive Typeable, there needs to be a typeable instance of Doc.
Here's what I've tried and failed:
deriving instance Data P.Doc
deriving instance Typeable P.Doc

gives this error:
Can't make a derived instance of `Data P.Doc':
  The data constructors of `P.Doc' are not all in scope
    so you cannot derive an instance for it
In the stand-alone deriving instance for `Data P.Doc'

Or, I try to derive my own instance:
instance Typeable P.Doc where
    typeRep v = typeRep $ show v

which gives this error:
 `typeRep' is not a (visible) method of class `Typeable'

Am I doing something wrong? Is there a standard way to derive typeable for types given in other libraries?
The thing is, the instance isn't super important. I know that there aren't any parts of my AST stored recursively within a Doc value. But GHC complains if I don't have that instance.


text:
Q: Azure Application Insights Custom Cloud_RoleName initializer declarative method doesnt work I have been following this article for adding cloud_RoleName to my web-app (https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/azure-monitor/app/app-map.md#net), I just tried this with a very simple ASP.net web-app. I created a class library for telemetry and referenced it with my Web-App and made sure Instrumentation Key is used. Now when I initialize the custom TELEMETRY class programmatically i.e.  (Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.TelemetryInitializers.Add(new ExtendedIDTelemetryInitializer())) .. It works very well and no issues at all. Telemetry gets sent to my Azure App Insights Resource with my custom CLOUD_ROLENAME but samething if I try to add it declaratively i.e. adding the INITIALIZE code to ApplicationInsights.config file, it DOESNT WORK :( nothing is reported with my CUSTOM cloud_RoleName to Azure App insights, any help with this? I want to go the DECLARATIVE route instead of programmatic as I need to send this code to a third party product and they cant make changes to the STARTUP event to add it. Not sure why DECLRATIVE is Not working any help? my ApplicationInsights.config file looks like this . Any help?<Add Type="KSTelemetry.Telemetry.MyTelemetryInitializer,KSTelemetry"/>

A: if you were using asp.net core application, then declarative config via ApplicationInsights.config is not supported. Adding TelemetryInitializers must be done by adding it to the DI container as shown in below link
https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core#adding-telemetryinitializers


text:
Q: Use of moment generating function (MGF) for derivng closed form expression for pairwise error probability of space-time code Would anyone recommend some resources on the use of the Moment Generating Function for deriving closed form expressions for the pairwise error probability of a given space-time modulation system?
Thanks


text:
Q: How to echo a dynamic html snippet based on a MySQL databse with PHP? I'm trying to create an image gallery with a for loop iterated by a counter of database rows.
To make it more clear: for each row in the table, get only the id(primary index) number and the image link from the server (not all the info in the row). With that information, echo an HTML image tag with the link inside the 'src=' and the id inside the 'alt='.
Two problems here:
1- the id number of the first row isn't zero.
2- I don't have a clue on how to get the total number of rows and to fetch only those two informations (id and img source).
That way, I could subtract the total number of rows minus the id number of the first row and using it to put an end on the loop.
So how to echo this dynamic html snippet based on my databse with PHP?
My code:
<?php

$link = mysqli_connect('localhost','user','pass','db');
$result = mysqli_query($link, "SELECT * FROM `table`");
$rows = mysqli_num_rows($result);

/* free result set */
mysqli_free_result($result);

$caption = mysqli_query($link, "SELECT ");

for($i=0; $i < $rows; $i++) {
    echo "";
}

?>

A: You need to use sql functions to iterate through the dataset results.  Replace your for loop... replacing 'image_url_column' and 'id_number_column' with the name of your actual columns in your db:
while ($row = while ($row = mysqli_fetch_assoc($caption)){){
    echo "";
}

A: *

*You can use the count function of MySql to achieve the total number of rows.

*also you can do this via mysqli_num_rows() function of mysql.

Code:
<?php

$link = mysqli_connect('localhost','user','pass','db');

$caption = mysqli_query($link, "SELECT id, img, count(id) as total from table");
echo
//$rows = mysqli_num_rows($result);
while($rows = mysqli_fetch_assoc($caption)){
    echo "";
    echo "Total Rows: ".$rows[total];
}

?>

A: This is a really easy task.
First we fetch the data from the database using mysqli_query to do the query.
Then we use mysqli_fetch_array to get an array so then we can loop through it and echo each item.
After that, we mysqli_num_rows to get the total number of rows returned and increment it by 1 so it is not zero.

NOTE: Since you are going to increment the id to avoid getting a '0', don't to forget to minus '1' if you intend to use that id for some server-side purpose.

$result = mysqli_query($link, "SELECT * FROM `table`"); //query sql
$result_array=mysqli_fetch_array($result, MYSQLI_ASSOC);//return array from the query
$count = mysqli_num_rows($result);                      //get numbers of rows received

foreach($result as $row){ //do a foreach loop which is really simple
    echo ""; //echo data from the array, + 1 to "$row['id_column_name_from_db']" so that 'alt=' doesn't start from '0'.
    }
echo $count;


text:
Q: Can't update to 11.04 from 10.10. Update Manager and Terminal not working? I re-installed ubuntu 10.10 a few days ago after It messed up trying to upgrade to 11.04. I want to ultimately get it to 11.10, but now it won't even attempt an upgrade and I get this error message:
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/maverick-updates/universe/binary-i386/Packages.gz  404  Not Found [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/maverick-updates/multiverse/binary-i386/Packages.gz  404  Not Found [IP: 91.189.91.13 80]

E: Some index files failed to download, they have been ignored, or old ones used instead.

I have no idea what I should do next. I don't have a blank disc or a burner to download 11.10 manually. Since I'm new, I can't post the entire error code since there are so many hyperlinks.

A: It seems that your internet connection is not working properly so when you try to upgrade from terminal error message is there that "failed to fetch http:\***".
There are many reasons for it. one of the reason could be that you are behind some proxy server. If so you can add proxy to work on your computer by

*

*Go to system settings

*find Network setting

*in that you will find proxy server

*chech for manual proxy

*Insert your proxy settings (IP address  :  port no). add this proxy server for all type of connection like http, ftp, https

*click on apply system wide

Now try upgrading your system by following command
sudo apt-get upgrade

A: As you said you r new to this, it is worth mentioning that to install a latest ubuntu on to your system you will not require any blank disk or disk burner. Installing ubuntu is very simple what you will need is just a pen-drive.

*

*Download latest version of ubuntu from here.(download .iso file)

latest ubuntu version

*Next you will need a software which will make your pen-drive bootable.

Download universal USB installer

*Run Universal usb installer

*select version of your ubuntu

*browse where you have downloaded ubuntu .iso file

*Next select pen-drive and click on create.
this will make your pendrive bootable to install ubuntu.

Change the Boot priorities from BIOS to first boot option as USB-drive. Boot from from pendrive, done with your installation.


text:
Q: Cabal problems installing music-suite I am trying to install music-suite for use with Haskell via cabal. Following the instructions, here http://music-suite.github.io/docs/ref/ , which suggest downloading Lilypond, I entered cabal install lilypond and downloaded it successfully.
Problems began when I tried to install music-suite via cabal. Here is what happened:
mm$ cabal install music-suite
clang: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument]
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: music-suite-1.9.0 (user goal)
[__1] trying: musicxml2-1.9.0 (dependency of music-suite)
[__2] trying: base-4.11.1.0/installed-4.1... (dependency of musicxml2)
[__3] trying: music-score-1.9.0 (dependency of music-suite)
[__4] trying: vector-space-points-0.2.1.2 (dependency of music-score)
[__5] next goal: transformers (dependency of music-score)
[__5] rejecting: transformers-0.5.5.0/installed-0.5..., transformers-0.5.6.2,
transformers-0.5.5.0, transformers-0.5.4.0, transformers-0.5.2.0,
transformers-0.5.1.0, transformers-0.5.0.1, transformers-0.5.0.0 (conflict:
music-score => transformers>=0.4.3.0 && <0.5)
[__5] rejecting: transformers-0.4.3.0 (conflict:
base==4.11.1.0/installed-4.1..., transformers => base>=2 && <4.9)
[__5] rejecting: transformers-0.4.2.0, transformers-0.4.1.0,
transformers-0.3.0.0, transformers-0.2.2.1, transformers-0.2.1.0,
transformers-0.2.0.0, transformers-0.1.4.0, transformers-0.1.3.0,
transformers-0.1.1.0, transformers-0.1.0.1, transformers-0.0.1.0,
transformers-0.0.0.0, transformers-0.5.6.1, transformers-0.5.6.0,
transformers-0.5.3.1, transformers-0.5.3.0, transformers-0.5.0.2,
transformers-0.4.0.0, transformers-0.2.2.0, transformers-0.1.0.0 (conflict:
music-score => transformers>=0.4.3.0 && <0.5)
[__5] fail (backjumping, conflict set: base, music-score, transformers)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: music-score, base, transformers,
music-suite, musicxml2, vector-space-points

What exactly has gone wrong? How can I resolve this problem?
I tried to install it via stack, but this message came up:
Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for music-suite-1.9.0:
abcnotation must match ==1.9.0, but the stack configuration has no specified version  (latest matching version
            is 1.9.0)
lilypond must match ==1.9.0, but the stack configuration has no specified version  (latest matching version
         is 1.9.0)
music-articulation must match ==1.9.0, but the stack configuration has no specified version  (latest matching
                   version is 1.9.0)
music-dynamics must match ==1.9.0, but the stack configuration has no specified version  (latest matching version
               is 1.9.0)
music-dynamics-literal must match ==1.9.0, but the stack configuration has no specified version  (latest matching
                       version is 1.9.0)
music-parts must match ==1.9.0, but the stack configuration has no specified version  (latest matching version
            is 1.9.0)
music-pitch must match ==1.9.0, but the stack configuration has no specified version  (latest matching version
            is 1.9.0)
music-pitch-literal must match ==1.9.0, but the stack configuration has no specified version  (latest matching
                    version is 1.9.0)
music-preludes must match ==1.9.0, but the stack configuration has no specified version  (latest matching version
               is 1.9.0)
music-score must match ==1.9.0, but the stack configuration has no specified version  (latest matching version
            is 1.9.0)
musicxml2 must match ==1.9.0, but the stack configuration has no specified version  (latest matching version
          is 1.9.0)
needed since music-suite is a build target.

Some different approaches to resolving this:

  * Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working build
configuration. This can be convenient when dealing with many complicated constraint errors, but results may be
unpredictable.

  * Recommended action: try adding the following to your extra-deps
in /Users/mm/.stack/global-project/stack.yaml:

- abcnotation-1.9.0
- lilypond-1.9.0
- music-articulation-1.9.0
- music-dynamics-1.9.0
- music-dynamics-literal-1.9.0
- music-parts-1.9.0
- music-pitch-1.9.0
- music-pitch-literal-1.9.0
- music-preludes-1.9.0
- music-score-1.9.0
- musicxml2-1.9.0

I had added all these dependencies (which are also listed here http://hackage.haskell.org/package/music-suite-1.9.0/dependencies), however
I receive The same package name is used in multiple local packagesbase-orphans used in:
- PLIndex "base-orphans-0.8"
- PLIndex "base-orphans-0.3.3" when I type stack install music-suite at the terminal.
When I remove one of these dependencies, I get a message asking for them to be restored, and I also get the following errors:
Error: While constructing the build plan, the following exceptions were encountered:
 In the dependencies for cassava-0.4.4.0:
base-4.12.0.0 from stack configuration does not match >=4.5 && <4.9  (latest matching version is 4.8.2.0)
 needed due to music-suite-1.9.0 -> cassava-0.4.4.0

  In the dependencies for comonad-4.3:
base-4.12.0.0 from stack configuration does not match >=0 && <0
 needed due to music-suite-1.9.0 -> comonad-4.3

 In the dependencies for directory-1.2.7.1:
base-4.12.0.0 from stack configuration does not match >=4.5 && <4.11  (latest matching version is 4.10.1.0)
 needed due to music-suite-1.9.0 -> directory-1.2.7.1

 In the dependencies for monadplus-1.4.2:
base-4.12.0.0 from stack configuration does not match >=4 && <4.11  (latest matching version is 4.10.1.0)
 needed due to music-suite-1.9.0 -> monadplus-1.4.2

 In the dependencies for music-score-1.9.0:
base-orphans-0.8 from stack configuration does not match >=0.1 && <0.4  (latest matching version is 0.3.3)
 needed due to music-suite-1.9.0 -> music-score-1.9.0

 In the dependencies for process-1.2.3.0:
base-4.12.0.0 from stack configuration does not match >=4.4 && <4.9  (latest matching version is 4.8.2.0)
 needed due to music-suite-1.9.0 -> process-1.2.3.0

 In the dependencies for transformers-0.4.3.0:
base-4.12.0.0 from stack configuration does not match >=2 && <4.9  (latest matching version is 4.8.2.0)
 needed due to music-suite-1.9.0 -> transformers-0.4.3.0

 In the dependencies for vector-space-points-0.2.1.2:
base-4.12.0.0 from stack configuration does not match >=4.0 && <4.12  (latest matching version is 4.11.1.0)
 needed due to music-suite-1.9.0 -> vector-space-points-0.2.1.2

 Some different approaches to resolving this:

   * Set 'allow-newer: true' to ignore all version constraints and build anyway.

   * Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working build
configuration. This can be convenient when dealing with many complicated constraint errors, but results may be
unpredictable.

A: The payload in your cabal error is here (I have editorialized a bit, replacing some very repetitive stuff with <...>):
[__5] next goal: transformers (dependency of music-score)
[__5] rejecting: transformers-0.5.5.0, <...> (conflict: music-score => transformers>=0.4.3.0 && <0.5)
[__5] rejecting: transformers-0.4.3.0 (conflict: base==4.11.1.0/installed-4.1..., transformers => base>=2 && <4.9)
[__5] rejecting: transformers-0.4.2.0, <...> (conflict: music-score => transformers>=0.4.3.0 && <0.5)

Lines 2 and 4 together say that, of all the possible available versions of the transformers package, only version 0.4.3.0 meets the version bounds in music-core's constraints. Line 3 says that transformers-0.4.3.0 demands base <4.9, and your version of base is too new to meet that constraint.
So far so good, just standard constraint solving, and a summary of what has gone wrong in the constraint set cabal sees. Now for some high-level interpretation that cabal isn't qualified to give you.
base is the deepest, most hard-wired library; it comes with GHC and can't be replaced, so your only choice for changing base versions is installing a different version of GHC. There is, unfortunately, no principled connection between base version number and GHC version number, though there is a table here. Consulting that table, we see that GHC 7.10.3 was the last one to ship a base version under 4.9.
Therefore, to get past this problem and on to the next problem, you should install a version of GHC which is at least as old as 7.10.3, and then tell cabal to use it when performing its constraint solving. This latter you can do either by making the new (old) GHC be the first one on your PATH, or by using cabal's -w flag to specify exactly which compiler to use, as in:
cabal install music-suite -w ghc-7.10.3

A: The problem is that music-suite hasn't been updated for some years and can't be directly built with the latest GHC releases.
Hopefully, we can use "stack" which is a tool that allows you to specify which GHC and which packages to use. However I haven't been able to find a build plan working with the music-suite packages on Hackage, so let's build them from sources:
1) Install stack (instructions are on https://haskellstack.org)
2) Optional: create a new package with stack new mypackage (or you can use your own package)
3) In your package folder, create or edit the "stack.yaml" file so that it contains:
resolver: lts-13.8

packages:
- .
- music-suite
- music-parts
- music-score
- music-articulation
- music-pitch
- music-dynamics
- lilypond
- musicxml2
- monadplus

extra-deps:
- average-0.6.1
- prettify-1.0
- data-interval-1.3.0
- extended-reals-0.2.3.0
- positive-0.4.1
- type-unary-0.3.2
- vector-space-points-0.2.1.2
- applicative-numbers-0.1.3
- ty-0.1.7
- reverse-apply-2.0.1
- roman-numerals-0.5.1.5

allow-newer: true

ghc-options:
   "music-score": -XUndecidableInstances

4) In your package folder, fetch and fix music-suite with the following commands:
git clone https://github.com/music-suite/lilypond
git clone https://github.com/music-suite/music-suite
git clone https://github.com/music-suite/music-score
git clone https://github.com/music-suite/music-dynamics
git clone https://github.com/music-suite/music-parts
git clone https://github.com/music-suite/music-pitch
git clone https://github.com/music-suite/music-articulation
git clone https://github.com/music-suite/musicxml2
git clone https://github.com/hanshoglund/monadplus

echo "instance Semigroup (Partial a b) where (<>) = mplus" >> monadplus/src/Control/Monad/Plus.hs

echo "instance Semigroup RhythmContext where (<>) = mappend" >> music-score/src/Music/Score/Internal/Quantize.hs
echo "instance Semigroup CrescDim where (<>) = mappend" >> music-score/src/Music/Score/Export/DynamicNotation.hs
echo "instance Semigroup DynamicNotation where (<>) = mappend" >> music-score/src/Music/Score/Export/DynamicNotation.hs
echo "instance Semigroup Slur where (<>) = mappend" >> music-score/src/Music/Score/Export/ArticulationNotation.hs
echo "instance Semigroup Mark where (<>) = mappend" >> music-score/src/Music/Score/Export/ArticulationNotation.hs
echo "instance Semigroup ArticulationNotation where (<>) = mappend" >> music-score/src/Music/Score/Export/ArticulationNotation.hs
echo "instance Semigroup (ScScore a) where (<>) = mappend" >> music-score/src/Music/Score/Export/SuperCollider.hs
echo "instance Semigroup SystemBar where (<>) = mappend" >> music-score/src/Music/Score/Export2/StandardNotation.hs
echo "instance Semigroup StaffInfo where (<>) = mappend" >> music-score/src/Music/Score/Export2/StandardNotation.hs
echo "instance Semigroup Chord where (<>) = mappend" >> music-score/src/Music/Score/Export2/StandardNotation.hs
echo "instance Semigroup MovementInfo where (<>) = mappend" >> music-score/src/Music/Score/Export2/StandardNotation.hs
echo "instance Semigroup WorkInfo where (<>) = mappend" >> music-score/src/Music/Score/Export2/StandardNotation.hs

5) Now you can build the whole thing with stack build

A simpler solution would be to ask for the release of newer music-suite packages on Hackage.


text:
Q: Laravel Mysql statement like fcm topic condition I'm trying to make my own topics system similar to fcm on mysql.The table is simply this:
user_id  topic_name

In fcm for example:
'topic1' in topics && 'topic2' in topics or ('topic3' in topics)

means select the user, which is subscribed to topic1 and topic2 or is subscribed to topic3.
In mysql I have no idea how to do this,basically it's based on all equavelnt user_ids but on different conditions on topic_name but using whereIn and whereNotIn and stuff it's not possible I'm really confused.

A: I suspect that you want aggregation and a having clause:
select user_id
from mytable
where topic_name in ('topic1', 'topic2', 'topic3')
group by user_id
having count(*) = 3

This brings users that have the three topics listed in the where clause.


text:
Q: How to create a indicator that loops through date and unique client ID? The data structure is as follows:
Cli_ID   M_YR    trans-Date     First_Trans
1004525 Oct 17  30-Oct-17   20-Sep-17
1004570 Oct 17  02-Oct-17   30-Aug-17
1004570 Oct 17  05-Oct-17   30-Aug-17
1004570 Oct 17  10-Oct-17   30-Aug-17
1004570 Oct 17  11-Oct-17   30-Aug-17
1004570 Oct 17  12-Oct-17   30-Aug-17
1004570 Oct 17  13-Oct-17   30-Aug-17
1004570 Oct 17  17-Oct-17   30-Aug-17
1004570 Oct 17  19-Oct-17   30-Aug-17
1004570 Oct 17  23-Oct-17   30-Aug-17
1004570 Oct 17  24-Oct-17   30-Aug-17
1004570 Oct 17  25-Oct-17   30-Aug-17
1143578 Oct 17  13-Oct-17   07-Sep-17
1143578 Oct 17  18-Oct-17   07-Sep-17
1143578 Oct 17  19-Oct-17   07-Sep-17

I need to identify all clients who have had at least one transaction per month. I am thinking, based on their first transaction date, calculate how many month they should have had at least one transaction for (Count_month) (eg., if client first transaction is Sept 2017, so from October 2017 to June 2019, the number of month they need to have at least one transaction in is 21).
And then create another counter to loop through each M_YR (month, year), and add 1 if a unique client had a transaction in a given Month-year (Count_client)...(eg., if client had at least one transaction a month from October 2017 to June 2019, the counter would be 21)
If I compare these two variables (Count_client and Count_month), if Count_client < Count_month then i will know this client did not have at least one transaction per month.
Does this method work? is there an easier way to do this? I feel this is probably not the simplest solution but I am currently out of ideas..

A: To calculate the number of months between first transaction and present date you can use:
compute Months_since_1st = datediff($time, First_Trans, "months").

(the $Time expression will use present date in calculation - you can replace that with any other date).
To calculate the number of months that had any transaction:
dataset name orig.
* identifying every month/year that had transactions - per client.
dataset declare agg1.
aggregate out=agg1 /break=Cli_ID M_YR /n=n.
dataset activate agg1.
* counting them for each client.
dataset declare agg2.
aggregate out=agg2 /break=Cli_ID /Nmonths_with_transactions=n.
* attaching the results back to original data.
dataset activate orig.
match files /file = * /table = agg2 / by Cli_ID.


text:
Q: Debugging in Eclipse pydev I am debugging this code in Eclipse the code below.
import wx

class MyFrame(wx.Frame):

    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title=title, size=(200,100))

        self.Show()
        bar = 'tt'
        car = 'aa'
        self.ss = 5
        bttn = wx.Button(self, -1, pos=(30,10), size=(120,30))
        bttn.Bind(wx.EVT_BUTTON, self.pr)

But the problem is its not showing the self.ss global inside. its only showing car and bar. Anybody any suggestion please. Badly stuck in this problem. Thank you


text:
Q: Gradient Descent inequality lemma Does anybody know how could i prove this inequality?
Consider a sequence of vectors $v_1,v_2...v_T$ and an update equation of the form $w^{t+1}= w^t - \eta \cdot v_t$ with $w^1=0$.
Show that:
$$\sum_{t=1}^T \langle w^t - w^*,v_t\rangle  \le {||w^*||^2 \over 2\eta} + {\eta\over2}\sum_{t=1}^T||v_t||^2$$
where $w^*$ is any vector, $\eta$ is the learning rate and the $\langle \cdots \rangle$ is the dot product.
I am really having problems in proving this inequality.
Do you have any suggestions?
Thank you

A: Here is (I think) the standard proof: for any $t\geq 1$, notice that
\begin{align}
\|w_{t+1}-w^*\|^2&=\|w_t-\eta v_t-w^*\|^2\\
&=\|w_t-w^*\|^2+\eta^2\|v_t\|^2-2\eta\langle w_t-w^*,v_t\rangle.
\end{align}
Rearranging gives
\begin{equation}
\langle w_t-w^*,v_t\rangle = \frac{\|w_t-w^*\|^2}{2\eta}+\frac{\eta\|v_t\|^2}{2}-\frac{\|w_{t+1}-w^*\|^2}{2\eta}.
\end{equation}
Summing from $t=1$ to $T$, we obtain by telescoping that
\begin{equation}
\sum_{t=1}^T\langle w_t-w^*,v_t\rangle=\frac{\|w_1-w^*\|^2}{2\eta}+\frac{\eta\sum_{t=1}^T\|v_t\|^2}{2}-\frac{\|w_{T+1}-w^*\|^2}{2\eta}.
\end{equation}
As $w_1=0$ and the last term is nonpositive, we deduce
\begin{equation}
\sum_{t=1}^T\langle w_t-w^*,v_t\rangle\leq \frac{\|w^*\|^2}{2\eta}+\frac{\eta\sum_{t=1}^T\|v_t\|^2}{2},
\end{equation}
as desired.


text:
Q: How to read file from server using python I want to read a json file from my server:103.227.176.29 but got an error"invalid literal for int() with base 10: '103.227.176.29" and I don't know how to fix it.
What can I do to fix this problem?
from contextlib     import closing
from fabric.network import connect
user = 'cortekr1_cuong'
password = '12345678'
host = '103.227.176.29'
port = '3306'
remote_file = '/RBICloudv1/static/json/vietnamprovince/vn.json'
with closing(connect(user, password, host, port)) as ssh, \
     closing(ssh.open_sftp()) as sftp, \
     closing(sftp.open(remote_file)) as file:
    for line in file:
      print(line)

A: Password is not a parameter, so you're trying to pass the host as the port, which it's not a number
https://docs.fabfile.org/en/1.12.1/api/core/network.html#fabric.network.connect
By the way, port 3306 is commonly used for mysql, not an sftp server


text:
Q: React-Native / Navigation : I want to detect wether the user is navigating backward between pushed screens If I'm moving forward, pushing the same component/screen with different data, I'm able to detect wether the screen is mounting, and then trigger an action within a useEffect.
When it comes to navigating back through the previous screens, seems like I'm not able to detect that the component / screen is changing.
I tried 2 different approaches:

*

*I was not able to assign any action top the back arrow without overriding the native back arrow with a custom component and then assigning the action to onPress  ( I don't want this solution )

*A better approach was to assign the navigation index as a dependency to a useEffect and then trigger the action when it changes. It works for navigating forward but not backward.
I think this is something very common (e.g navigating between profiles on LinkedIn). Are there other approaches I should try ?
Here's some piece of code :
 const navIndex = useRef(0);

  useNavigationState((state) => {
    return (navIndex.current = state.index);
  });

 useEffect(() => {
    console.log('Current navigation index : ', navIndex.current);
  }, [navIndex]);

A: I think the way I used useNavigationState was not ideal.
Instead, this seems to work :
  const state = useNavigationState(state => state);

  useEffect(() => {

    console.log('Navigation state : ', state);

  }, [state]);


text:
Q: Print inside a star pattern? Is there a way in this code that I can print some input inside the equilateral triangle?
I've tried several way but it seems to be not working. It just prints on all whitespaces.
h=int(input("Enter Height: "))
for r in range(1, h+1):
    for c in range(1, 2*h):
        if r==h or r+c==h+1 or c-r==h-1:
            print("*", end="")
        else:
            print(end =" ")
    print()

the output now is this:

and i want to print inside:

example:

A: That should be a good starting point for you:
h=int(input("Enter Height: "))
characters = iter("word")
for r in range(1, h+1):
    for c in range(1, 2*h):
        if r==h or r+c==h+1 or c-r==h-1:
            print("*", end="")
        elif r==(h*2)//3 and c > h+2-r and c < h-2+r:
            try:
                print(next(characters), end="")
            except StopIteration:
                print(end = " ")
        else:
            print(end =" ")
    print()

You need to compute the range in which it is okay to print your word, and print it there. In order to keep track of the characters that you already printed, you can use an iterator as I did on the second line here.
I have used arbitrary values here for limiting the range. I think you can figure the rest out on your own easily enough.


text:
Q: StoreKit's SKStoreProductViewController leaving space between the nav bar and the view? I have this subclass of UIViewController that shows a SKStoreProductViewController.  This view controller was originally created for iOS 5 and is NOT using auto-layout.
My problem is that when the SKStoreProductViewController is presented, there's a space between the nav bar and the actual content... if you scroll the view, the segmented control (Details/Reviews/Related) floats below the nav bar (see the images below, I added a mask to the images to make the problem more apparent).
Since we don't have access to the presented view controller I'm guessing it has to do with the controller that presents the SKStoreProductViewController.  When the user taps on the button that presents the controller I've tried to change/shift the frame of the view, I've also done something like self.navigationController.navigationBar.translucent = NO; but nothing seems to help.
Has anyone have had a similar problem? Any ideas on how to fix it?

A: It seems like there's a bug on the UIAppearance protocol on iOS 7.  I found people having (other) problems when using UIAppearance.
I was using something like:
[[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
which works on iOS 5, but for iOS 6+ I set the background image directly on the navigation bar:
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
It looks like a small difference, but it fixed my problem.


text:
Q: how to achieve an apache Alias with a proxy pass on the same domain We have a NodeJS site running with an Apache VirtualHost that looks like this:
<VirtualHost *:80>
    ServerName      domain.org
    ServerAlias www.domain.org

    ProxyPass / http://localhost:8884/
    ProxyPassReverse / http://localhost:8884/

    ProxyPreserveHost on

    LogLevel debug
</VirtualHost>

This works fine.
however we have now been tasked with installing a wordpress blog as an alias of the domain
www.domain.org/blog
To do this we tried setting up a vhost with an Alias like this:
<VirtualHost *:80>
       Alias /blog /var/apache-vhosts/www.domain.org-blog

       <Directory /var/apache-vhosts/www.domain.org-blog/>
           Options Indexes FollowSymLinks MultiViews
           AllowOverride All
           Order allow,deny
           allow from all
       </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

We have the mod_alias apache module enabled but it just wont pick it up.
Has anyone else achieved this?
I have also tried including the alias without a vhost wrapping tag but still no joy :/

A: Note that ProxyPass has precedence over Alias.
To fix, declare another ProxyPass pointing to an exclamation mark (!).
For example:
<VirtualHost *:80>
    ServerName      domain.org
    ServerAlias www.domain.org

    # the next line is your fix
    ProxyPass /blog !
    Alias     /blog /var/apache-vhosts/www.domain.org-blog

    <Directory /var/apache-vhosts/www.domain.org-blog/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    ProxyPass        / http://localhost:8884/
    ProxyPassReverse / http://localhost:8884/
    ProxyPreserveHost on
    LogLevel debug
</VirtualHost>

You can find more information in the official ProxyPass documentation:

The ! directive is useful in situations where you don't want to reverse-proxy a subdirectory
― https://httpd.apache.org/docs/2.4/mod/mod_proxy.html