text:
Q: Why are my Font Awesome 6.1.1 icons not displaying when loaded? I'm in this course by Brad Traversy's  50 Projects 50 Days course. In the Day 26 - Double Vertical Slider, the Font Awesome CDN he's using is version 5.15.1 which is a really outdated one. I am using version 6.1.1 but my icons are not loading even though I tried to debug it. I want the arrow-down and arrow-up icons in my down-button and up-button classes respectively.
Here's my code:

@import url('https://fonts.googleapis.com/css?family=Open+Sans');
* {
  box-sizing: border-box;
}

body {
  font-family: 'Open Sans', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  overflow: hidden;
  margin: 0;
}
<!DOCTYPE html>

  <meta charset="UTF-8" />
  <meta content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="shortcut icon" href="/favicon.ico" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" referrerpolicy="no-referrer"
  />
  <link rel="stylesheet" href="style.css" />
  <title>Vertical Slider</title>

      <button class="down-button">

        </button>
      <button class="up-button">

        </button>

Thank You!

A: Your integrity code was bad. Just replace it with a newly generated link from https://cdnjs.com/libraries/font-awesome
DO NOT REMOVE THE INTEGRITY ATTRIBUTE See here for a good explanation as to why: https://stackoverflow.com/a/49061277/8565010

@import url('https://fonts.googleapis.com/css?family=Open+Sans');
* {
  box-sizing: border-box;
}

body {
  font-family: 'Open Sans', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  overflow: hidden;
  margin: 0;
}

.down-button {
  display: block;
  width: fit-content;
  height: fit-content;
  padding: 2rem;
  margin: 0 auto 1rem auto;
}

.up-button {
  display: block;
  width: fit-content;
  height: fit-content;
  padding: 2rem;
  margin: 0 auto 1rem auto;
}
<!DOCTYPE html>

  <meta charset="UTF-8" />
  <meta content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="shortcut icon" href="/favicon.ico" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" crossorigin="anonymous" referrerpolicy="no-referrer"
  />
  <link rel="stylesheet" href="style.css" />
  <title>Vertical Slider</title>

      <button class="down-button">

        </button>
      <button class="up-button">

        </button>

A: now you don't need download any files from font awesome .
u can use kit
1- visit website.
2- sign in .
3- go to send kit in gmail inbox.
(kit is code javascre)
4-go to html file and pull code in title .
only........


text:
Q: Delete draggable object in react-dnd I'm using react-dnd. I want to delete a draggable object once it's been used. I took the react-dnd multiple type example and added a delete on drop.
Current behavior:
1. Drag Banana, the top right dustbins is highlighted
2. Drag Bottle into either of the dustbins on the left
3. Drag Banana again, now the left two dustbins are highlighted
Expected behavior:
1. Drag Bottle into either of the dustbins on the left
2. Drag Banana, the top right should be highlighted
What is going on here, and how do I fix it?
https://codesandbox.io/s/pensive-wildflower-q2oxo?file=/src/Dustbin.jsx

A: You are using array index as key to the boxes and doing removals. Don't use indexes as key specially when dealing with item-removal operations. Instead, maintain a unique id for Boxes. Also update the state of the boxes properly.

Code Snippet
const Container = () => {
  const [dustbins, setDustbins] = useState([
    { accepts: [ItemTypes.GLASS], lastDroppedItem: null },
    { accepts: [ItemTypes.FOOD], lastDroppedItem: null },
    {
      accepts: [ItemTypes.PAPER, ItemTypes.GLASS, NativeTypes.URL],
      lastDroppedItem: null
    },
    { accepts: [ItemTypes.PAPER, NativeTypes.FILE], lastDroppedItem: null }
  ]);
  const [boxes, setBoxes] = useState([
    { id: 1, name: "Bottle", type: ItemTypes.GLASS },
    { id: 2, name: "Banana", type: ItemTypes.FOOD },
    { id: 3, name: "Magazine", type: ItemTypes.PAPER }
  ]);
  const [droppedBoxNames, setDroppedBoxNames] = useState([]);
  function isDropped(boxName) {
    return droppedBoxNames.indexOf(boxName) > -1;
  }
  const handleDrop = useCallback(
    (index, item, id) => {
      const { name } = item;
      setDroppedBoxNames(prev => [...prev, name]);
      // setDroppedBoxNames(
      //   update(droppedBoxNames, name ? { $push: [name] } : { $push: [] })
      // );
      setBoxes(prev => prev.filter(x => x.id !== id));
      // setBoxes(update(boxes, { $splice: [[item.id, 1]] }));
      setDustbins(
        update(dustbins, {
          [index]: {
            lastDroppedItem: {
              $set: item
            }
          }
        })
      );
    },
    [droppedBoxNames, boxes, dustbins]
  );
  return (

        {dustbins.map(({ accepts, lastDroppedItem }, index) => (
          <Dustbin
            accept={accepts}
            lastDroppedItem={lastDroppedItem}
            onDrop={item => handleDrop(index, item)}
            key={index}
          />
        ))}

        {boxes.map(({ name, type, id }, index) => (
          <Box
            key={id}
            id={id}
            name={name}
            type={type}
            isDropped={isDropped(name)}
          />
        ))}

  );
};
export default Container;

redpajama_set_name: RedPajamaStackExchange


text:
Q: Are there relation between CPU's Ghz and RAM's Mhz? Could I predict what frequency of RAM should be knowing frequency of CPU ?

A: Today not really. In modern motherboard designs the RAM and the CPU are not that tightly coupled as far as the clocks are concerned.
In the past in many cases the CPU base-clock and the RAM base-clock had to be the same or have a fixed ratio.
E.g Socket 370 Pentium designs had a 100MHz base clock and the corresponding 370 Celerons used a 66 MHZ clock (both directed from a 33MHz system clock that also drove the PCI bus and the RAM). The matching RAM could either be 66 or 100. As you see from that they all used a 2x or 3x clock-multiplier.


text:
Q: Fetch the latest package from gitlab repository I need to get the latest package from my gitlab repository
My repo's packages url is in this format <BASE_URL>/-/packages/<version-id>
And the download url as <BASE_URL>/-/packages/<version-id>/download
In my docker file I refer it (hardcode version) for example as:
ARG BUNDLE_URL="<BASE_URL>/-/packages/210/download"
RUN curl ${BUNDLE_URL} -o /app/bundle.tar.gz

So my question is, there is any way to download the latest version directly from gitlab, for example
to download a url like this <BASE_URL>/-/packages/latest/download or something similar?
Also if the above is not possible there is a way to get in the dockerfile the latest version number and put it on this url format <BASE_URL>/-/packages/<version-id>/download?
I need this to make the docker file more generic
Thanks in advance,

A: To your first question, the easiest I guess would be to use the GitLab packages API. The first one lists packages from a project/a group, sorted from most recent to oldest.
If your group/project is public, you won't need any token to access the API.
Else you might provide a Group Access Token with read_api scope only.


text:
Q: I don't understand UTC date formatting using DateFormat in Dart When UTC date is formatted by DateFormat#format(), I expect to get a String of UTC date formatted, but not.
Please look at the code below. These tests are passed.
My question is why does DateFormat#format() return a time of 12:00 past UTC date? What am I missing here?
Date date(int millisecondsSinceEpoch, bool isUtc) =>
    new Date.fromMillisecondsSinceEpoch(millisecondsSinceEpoch, isUtc:isUtc);

DateFormat df = new DateFormat("yyyy-MM-dd hh:mm");

// JST (+9.00)
expect(date(0, false).toString(), equals("1970-01-01 09:00:00.000"));
expect(df.format(date(0, false)), equals("1970-01-01 09:00"));

expect(date(0, true).toString(), equals("1970-01-01 00:00:00.000Z"));
// Why 12 o'clock?
expect(df.format(date(0, true)), equals("1970-01-01 12:00"));

A: Your format string you've written uses lowercase hh which is a 12 hour clock.  Use uppercase HH for the hours to get a 24-hour clock.  The output you are getting in the last line is currently saying 12 midnight, rather than 00 hours in a 24-hour clock.
See the explicit pattern syntax in DateFormat


text:
Q: Outer div does not expand with inner div I have got a set of HTML webpages that use the HTML template as below and each HTML page has a different amount of content. All HTML pages use the same CSS file which is also given below.
So as I said, the content of each page is different and I want the outer div (#main) to resize automatically based on the content (#content).
HTML:

            Content goes here

            Created by Cleopatra Masy © August, 2015

CSS:
body {
background:url('/images/bg.jpg') no-repeat center center fixed;
background-size:cover;
width:100%;
height:100%;
margin:0;
}

#main {
box-shadow:6px 0 15px -4px rgba(31,73,125,0.8), -6px 0 8px -4px rgba(31,73,125,0.8);
position:relative;
height:1000px;
width:980px;
margin:0 auto;
}

#content {
font-weight: normal;
min-height:655px;
margin-right:20px;
margin-left:220px;
width:740px;
position:absolute;
margin-top:105px;
}

#footer {
background:url('/images/footer-back.png') repeat-x left top;
font-size:17px;
color:#FFF;
position:absolute;
text-align:center;
width:980px;
line-height:30px;
vertical-align:middle;
bottom:0;
}

I have tried the following which haven't seemed to work...
Attempt 1
I set the min-height of #main to 1000px but this did not do anything.
Attempt 2
I set the height of #main to 100% but this caused the box-shadows and footer to disappear.
NB: I have also tried looking over previous questions but none of them have seemed to work for me. In most situations the box-shadows and footer disappears.
Please also note that this is a new issue and I require serious help.
Any help will be grateful.
Thanks,
Cleopatra Masy

A: Containers will not expand if they have a fixed height or width set. Just by changing that height to min-height, you can preserve the box-shadows.
#main {
box-shadow:6px 0 15px -4px rgba(31,73,125,0.8), -6px 0 8px -4pxrgba(31,73,125,0.8);
width:980px;
margin: 10px auto;
min-height: 500px;
position: relative;
}

#content {
font-weight: normal;
margin-right:20px;
margin-left:220px;
width:740px;
margin-top:55px;
}

See this example: http://jsfiddle.net/ahbfmvbx/1/

A: The problem is that #content is positioned absolutely.
Thus it does not take up any space.
The code you've included suggests that it should be save to remove the position property of #content altogether. Just make sure to set the min-height of  #main instead of height such that the element can actually grow.
To avoid overlapping of the content and footer you should also add a padding to the bottom of #main.

var lines = 0;
var content = document.getElementById('content');
content.addEventListener('click', function() {
  lines++;
  content.innerHTML += '
Line ' + lines;
});
#main {
  background-color: red;
  position: relative;
  min-height: 100px;
  padding-bottom: 30px;
}

#content {
  background-color: green;
}

#footer {
  background-color: blue;
  line-height: 30px;
  position: absolute;
  bottom: 0;
  width: 100%;
}

    Click to add line.

    © 2015 ...

A: I think this is what you're looking for. Here's a http://jsfiddle.net/u1L9nz6o/:
#main {
  box-shadow:6px 0 15px -4px rgba(31,73,125,0.8), -6px 0 8px -4px rgba(31,73,125,0.8);
  position:relative;
  height:1000px;
  width:980px;
  margin:0 auto;
  text-align: center;
}

#content {
  position: relative;
  font-weight: normal;
  min-height:655px;
  display: inline-block;
  margin: 0 auto;
  text-align: left;
}


text:
Q: Display route.steps (swift ) I am having some problem when it comes to display the steps from MKDirections route into a UILabel. I tried get each index from the steps array using the for in loop, it only show the Arrive at destination which means that all the instructions within the loop went by so fast, therefore i am seeing the last index in the array . Can someone help me please ...

A: it shows "Arrive at destination" because you are cycling the whole array and the label gets only the object at the end, you are basically overwriting it over and over until the for cycle arrives to its final element

A: You are seeing only the last value from the array in the UILabel, though it is actually displaying all the values very, very quickly. If you just want to see each of the values in the UILabel, you could either use UITimeInterval to change the value every few seconds, or add a UIButton that would handle updating of the text on the UILabel.


text:
Q: nginx + Jetty - thousands of connections stuck in LAST_ACK I have a FreeBSD machine with jails -- two in particular, one that runs nginx and another that runs a Java program that accepts requests via Jetty (embedded mode)
Jetty receives upwards of 500 requests/sec constantly and there has been an issue lately where I will constantly have over 60,000 connections in the LAST_ACK state between nginx and jetty.
Distribution of all connections (includes some other services, particularly php-fpm)
root@host:/root # netstat -an > conns.txt
root@host:/root # cat conns.txt | awk '{print $6}' | sort | uniq -c | sort -n
18 LISTEN
112 CLOSING
485 ESTABLISHED
650 FIN_WAIT_2
1425 FIN_WAIT_1
3301 TIME_WAIT
64215 LAST_ACK

Distribution of nginx -> jetty connections
root@host:/root # cat conns.txt | grep '10.10.1.57' | awk '{print $6}' | sort | uniq -c | sort -n
1
3 CLOSE_WAIT
3 LISTEN
18 FIN_WAIT_2
125 ESTABLISHED
64193 LAST_ACK

I'd prefer every request to fully close the connection. Clients requests are about 10 minutes apart from each other so connections must be closed.
Some of the connections,
tcp4       0      0 10.10.1.50.46809       10.10.1.57.9050        LAST_ACK
tcp4       0      0 10.10.1.50.46805       10.10.1.57.9050        LAST_ACK
tcp4       0      0 10.10.1.50.46797       10.10.1.57.9050        LAST_ACK
tcp4       0      0 10.10.1.50.46794       10.10.1.57.9050        LAST_ACK
tcp4       0      0 10.10.1.50.46790       10.10.1.57.9050        LAST_ACK
tcp4       0      0 10.10.1.50.46789       10.10.1.57.9050        LAST_ACK
tcp4       0      0 10.10.1.50.46771       10.10.1.57.9050        LAST_ACK
etc..

*

*On Jetty's end I've set maxIdleTime to 2000 -- before this all connections were in ESTABLISHED but they are now LAST_ACK

*On Jetty's end I've set Connection: close (i.e response.setHeader(HttpHeaders.CONNECTION, HttpHeaderValues.CLOSE);)

*Jetty never reports a lot of open connections -- always very few.

*PF/IPFW is not currently being used

*nginx - reset_timedout_connection is on

I cannot figure out how to get nginx or jetty to forcibly close the connection, is this simply something that needs to be fixed in Jetty so that it fully closes the socket after the request finishes?
Thanks a lot in advance
EDIT: forgot my nginx config for the proxy setup-
    proxy_pass              http://10.10.1.57:9050;
    proxy_set_header        HTTP_X_GEOIP $http_x_geoip;
    proxy_set_header        GEOIP_COUNTRY_CODE $geoip_country_code;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        Host $http_host;
    proxy_set_header        Connection "";
    proxy_http_version      1.1;

EDIT2: Forcing Jetty to close the connection via request.getConnection().getEndPoint().close() does nothing -- it's obvious the connection IS being closed (as it's in LAST_ACK) but why isn't it getting past this? Is Nginx keeping the connection open to the backend for some reason?

A: OK well I was finally able to convince Jetty to play nicely.
Just to recap, here's what my connections look like now, machine-wide:
24 LAST_ACK
36 CLOSING
117 FIN_WAIT_2
175 ESTABLISHED
351 FIN_WAIT_1
4725 TIME_WAIT

And between nginx and Jetty
1 FIN_WAIT_2
3 LISTEN
14 ESTABLISHED

I've already been closing the entire connection and EndPoint (calling close() on the EndPoint closes the underlying SocketChannel) using this convenience method:
private void finishRequest(String message, Request baseRequest, HttpServletResponse response) throws IOException {
    ByteArrayISO8859Writer writer = new ByteArrayISO8859Writer(1500);
    writer.write(message);
    writer.flush();

    // set the content length
    response.setContentLength(writer.size());

    // write the response
    OutputStream outputStream = response.getOutputStream();
    writer.writeTo(outputStream);

    // close the streams
    outputStream.close();
    writer.close();
    baseRequest.getConnection().getEndPoint().close();
}

( I only send max one line to the client, so nothing fancy is needed )
However this still resulted in filling the entire server with LAST_ACK ... What made these finally disappear was enabling SO_LINGER (and making it forcefully close the socket immediately, with no timeout)
connector.setSoLingerTime(0);


text:
Q: Editing Webpart on aspx page with Filter to display nothing initially I've got a issue that I have been sitting on for about 4 hours now. The page was created by another developer that I have to edit now and cannot seem to figure out.
The scenario is as follows.
Categories are added into the page as clickable blocks, this is pulled from a separate list into a web part on the page. The products per categories are also pulled from another list onto this page. When the user clicks a category at the top of the page the products are filtered to display only related products.
The client would like to load the page with no products being displayed until a user clicks on a specific category.
This is what I am working with for now, I cannot get the page to display no products first however the filters work correct, screenshot to follow, the first web part being the "category" bar and the second being the products.
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
    <SharePoint:ListItemProperty Property="BaseName" maxlength="40" runat="server"/>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">

                                            Store

    </asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderTitleAreaClass" runat="server">

</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">
    <meta name="GENERATOR" content="Microsoft SharePoint" />
    <meta name="ProgId" content="SharePoint.WebPartPage.Document" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="CollaborationServer" content="SharePoint Team Web Site" />

    <SharePoint:UIVersionedContent ID="WebPartPageHideQLStyles" UIVersion="4" runat="server">
        <ContentTemplate>

        </ContentTemplate>
    </SharePoint:UIVersionedContent>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">

<link type="text/css" href="../SiteAssets/style.css" rel="stylesheet">

Interested in ordering?

Contact Cliantha James for more information on the items here.

mail@mail.com

<WebPartPages:DataFormWebPart runat="server" IsIncluded="True" AsyncRefresh="True" FrameType="None" NoDefaultStyle="TRUE" ViewFlag="8" Title="Promo Shop - Categories" PageType="PAGE_NORMALVIEW" ListName="{FD912C31-C4C1-4AE2-9C0E-6BC7D28FE6DE}" Default="FALSE" DisplayName="Promo Shop - Categories" __markuptype="vsattributemarkup" __WebPartId="{807A1620-854D-4D2E-8932-1A109AFA5A82}" id="g_807a1620_854d_4d2e_8932_1a109afa5a82" __AllowXSLTEditing="true" WebPart="true" Height="" Width="">
    <DataSources>
        <SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" UseServerDataFormat="true" selectcommand="<View><Query><OrderBy><FieldRef Name="ID" Ascending="TRUE"/></OrderBy></Query></View>" id="Promo_x0020_Shop_x0020__x002d__x0020_Categories2"><SelectParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{FD912C31-C4C1-4AE2-9C0E-6BC7D28FE6DE}"/></SelectParameters><DeleteParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{FD912C31-C4C1-4AE2-9C0E-6BC7D28FE6DE}"/></DeleteParameters><UpdateParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{FD912C31-C4C1-4AE2-9C0E-6BC7D28FE6DE}"/></UpdateParameters><InsertParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{FD912C31-C4C1-4AE2-9C0E-6BC7D28FE6DE}"/></InsertParameters></SharePoint:SPDataSource>
    </DataSources>
    <ParameterBindings>
    <ParameterBinding Name="ListID" Location="None" DefaultValue="{FD912C31-C4C1-4AE2-9C0E-6BC7D28FE6DE}"/>
    <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
    <ParameterBinding Name="ManualRefresh" Location="WPProperty[ManualRefresh]"/>
    <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
    <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
</ParameterBindings>
    <datafields>@ID,ID;@ContentType,Content Type;@Created,Created;@Author,Created By;@Modified,Modified;@Editor,Modified By;@_CopySource,Copy Source;@CheckoutUser,Checked Out To;@FileLeafRef,Name (for use in forms);@_CheckinComment,Check In Comment;@CheckedOutTitle,Checked Out To;@CheckedOutUserId,ID of the User who has the item Checked Out;@FileDirRef,Path;@FSObjType,Item Type;@HTML_x0020_File_x0020_Type,HTML File Type;@File_x0020_Type,File Type;@IsCheckedoutToLocal,Is Checked out to local;@_SourceUrl,Source URL;@_HasCopyDestinations,Has Copy Destinations;@ContentTypeId,Content Type ID;@_ModerationStatus,Approval Status;@_UIVersion,UI Version;@Created_x0020_Date,Created;@FileRef,URL Path;@File_x0020_Size,File Size;@ItemChildCount,Item Child Count;@FolderChildCount,Folder Child Count;@_UIVersionString,Version;@ParentVersionString,Source Version (Converted Document);@ParentLeafName,Source Name (Converted Document);@PreviewExists,Preview Exists;@ThumbnailExists,Thumbnail Exists;@_Author,Author;@Title,Title;@ImageWidth,Width;@ImageHeight,Height;@ImageCreateDate,Date Picture Taken;@_Comments,Comments;@Keywords,Keywords;@wic_System_Copyright,Copyright;@AlternateThumbnailUrl,Preview Image URL;@MediaLengthInSeconds,Length (seconds);@PublishingStartDate,Scheduling Start Date;@PublishingExpirationDate,Scheduling End Date;@VideoWidthInPixels,Frame Width;@VideoHeightInPixels,Frame Height;</datafields>
    <XSL>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:output method="html" indent="no"/>
    <xsl:decimal-format NaN=""/>
    <xsl:param name="dvt_apos">'</xsl:param>
    <xsl:param name="ManualRefresh"></xsl:param>
    <xsl:variable name="dvt_1_automode">0</xsl:variable>

    <xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
        <xsl:choose>
            <xsl:when test="($ManualRefresh = 'True')">

                            <xsl:call-template name="dvt_1"/>

            </xsl:when>
            <xsl:otherwise>

                        <xsl:call-template name="dvt_1"/>

            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="dvt_1">
        <xsl:variable name="dvt_StyleName">RepForm3</xsl:variable>
        <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
        <xsl:variable name="dvt_RowCount" select="count($Rows)"/>
        <xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
        <xsl:variable name="dvt_IsEmpty" select="$dvt_RowCount = 0"/>

        <xsl:choose>
            <xsl:when test="$dvt_IsEmpty">
                <xsl:call-template name="dvt_1.empty"/>
            </xsl:when>
            <xsl:otherwise>

                    <xsl:call-template name="dvt_1.body">
                        <xsl:with-param name="Rows" select="$Rows"/>
                        </xsl:call-template>

            </xsl:otherwise>
        </xsl:choose>
        </xsl:template>
    <xsl:template name="dvt_1.body">
        <xsl:param name="Rows"/>
        <xsl:for-each select="$Rows">
                    <xsl:call-template name="dvt_1.rowview" /></xsl:for-each>

    </xsl:template>

    <xsl:template name="dvt_1.rowview">
                <xsl:variable name="precate" select="translate(@Title,' ','-')"/>

<xsl:value-of select="@Title"/>

                    <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">

                    </xsl:if>
    </xsl:template>
    <xsl:template name="dvt_1.empty">
        <xsl:variable name="dvt_ViewEmptyText">There are no items to show in this view.</xsl:variable>

                    <xsl:value-of select="$dvt_ViewEmptyText"/>

    </xsl:template>
    </xsl:stylesheet>   </XSL>
</WebPartPages:DataFormWebPart>

<WebPartPages:DataFormWebPart runat="server" IsIncluded="True" AsyncRefresh="True" FrameType="None" NoDefaultStyle="TRUE" ViewFlag="8" Title="Promo Shop" PageType="PAGE_NORMALVIEW" ListName="{19A69ED6-141F-434F-9D22-BC27AAD49E7F}" Default="FALSE" DisplayName="Promo Shop" __markuptype="vsattributemarkup" __WebPartId="{9B6B016A-4B0F-42A1-B104-12CD2B2CE8C1}" id="g_9b6b016a_4b0f_42a1_b104_12cd2b2ce8c1" __AllowXSLTEditing="true" WebPart="true" Height="" Width="">
    <DataSources>
        <SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" UseServerDataFormat="true" selectcommand="<View><Query><OrderBy><FieldRef
        Name="Created_x0020_Date" Ascending="FALSE"/></OrderBy><Where><Or><Eq><FieldRef Name="Out_x0020_of_x0020_Stock"/><Value
        Type="Boolean">0</Value></Eq><IsNull><FieldRef
        Name="Out_x0020_of_x0020_Stock"/></IsNull></Or></Where></Query></View>"
id="Promo_x0020_Shop1">

        <SelectParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{19A69ED6-141F-434F-9D22-BC27AAD49E7F}"/></SelectParameters>

        <DeleteParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue=""/></DeleteParameters>

        <UpdateParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="}"/></UpdateParameters>

        <InsertParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue=""/></InsertParameters></SharePoint:SPDataSource>

    </DataSources>
    <ParameterBindings>
    <ParameterBinding Name="ListID" Location="None" DefaultValue=""/>
    <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
    <ParameterBinding Name="ManualRefresh" Location="WPProperty[ManualRefresh]"/>
    <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
    <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
</ParameterBindings>
    <datafields>@FileLeafRef,Name (for use in forms);@FileDirRef,Path;@FSObjType,Item Type;@PreviewExists,Preview Exists;@_ModerationStatus,Approval Status;@ThumbnailExists,Thumbnail Exists;@_Author,Author;@File_x0020_Type,File Type;@Title,Title;@ImageWidth,Width;@ImageHeight,Height;@ImageCreateDate,Date Picture Taken;@_Comments,Comments;@FileRef,URL Path;@HTML_x0020_File_x0020_Type,HTML File Type;@_UIVersion,UI Version;@_HasCopyDestinations,Has Copy Destinations;@Keywords,Keywords;@wic_System_Copyright,Copyright;@AlternateThumbnailUrl,Preview Image URL;@MediaLengthInSeconds,Length (seconds);@PublishingStartDate,Scheduling Start Date;@PublishingExpirationDate,Scheduling End Date;@VideoWidthInPixels,Frame Width;@VideoHeightInPixels,Frame Height;@Price,Price;@Category,Category;@Out_x0020_of_x0020_Stock,Out of Stock;@ID,ID;@ContentType,Content Type;@Created,Created;@Author,Created By;@Modified,Modified;@Editor,Modified By;@_CopySource,Copy Source;@CheckoutUser,Checked Out To;@_CheckinComment,Check In Comment;@CheckedOutTitle,Checked Out To;@CheckedOutUserId,ID of the User who has the item Checked Out;@IsCheckedoutToLocal,Is Checked out to local;@_SourceUrl,Source URL;@ContentTypeId,Content Type ID;@Created_x0020_Date,Created;@File_x0020_Size,File Size;@ItemChildCount,Item Child Count;@FolderChildCount,Folder Child Count;@_UIVersionString,Version;@ParentVersionString,Source Version (Converted Document);@ParentLeafName,Source Name (Converted Document);</datafields>

    <XSL>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:output method="html" indent="no"/>
    <xsl:decimal-format NaN=""/>
    <xsl:param name="dvt_apos">'</xsl:param>
    <xsl:param name="ManualRefresh"></xsl:param>
    <xsl:variable name="dvt_1_automode">0</xsl:variable>

    <xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
        <xsl:choose>
            <xsl:when test="($ManualRefresh = 'True')">

                            <xsl:call-template name="dvt_1"/>

            </xsl:when>
            <xsl:otherwise>

                    <xsl:call-template name="dvt_1"/>

            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="dvt_1">
        <xsl:variable name="dvt_StyleName">RepForm3</xsl:variable>
        <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
        <xsl:variable name="dvt_RowCount" select="count($Rows)"/>
        <xsl:variable name="dvt_RowCountMax" select="$dvt_RowCount"/>
        <xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
        <xsl:variable name="dvt_IsEmpty" select="$dvt_RowCount = 0"/>

                <xsl:choose>
            <xsl:when test="$dvt_IsEmpty">
                <xsl:call-template name="dvt_1.empty"/>
            </xsl:when>
            <xsl:otherwise>

                    <xsl:call-template name="dvt_1.body">
                        <xsl:with-param name="Rows" select="$Rows"/>
                        </xsl:call-template>
                        <xsl:copy-of select="$Rows"/>

            </xsl:otherwise>
        </xsl:choose>
        </xsl:template>

    <xsl:template name="dvt_1.body">
        <xsl:param name="Rows"/>
        <xsl:for-each select="$Rows">

                    <xsl:call-template name="dvt_1.rowview" /></xsl:for-each>

    </xsl:template>

                    <xsl:template name="removeHtmlTags">
                        <xsl:param name="html"/>
                        <xsl:choose>
                            <xsl:when test="contains($html, '<')">
                        <xsl:value-of select="substring-before($html, '<')"/>

                                <xsl:call-template name="removeHtmlTags">
                                    <xsl:with-param name="html" select="substring-after($html, '>')"/>
                                </xsl:call-template>
                      </xsl:when>
                            <xsl:otherwise>
                        <xsl:value-of select="$html"/>
                      </xsl:otherwise>
                        </xsl:choose>
          </xsl:template>

        <xsl:template name="dvt_1.rowview">

            <xsl:variable name="pureText">
                <xsl:call-template name="removeHtmlTags">
                    <xsl:with-param name="html" select="@Body" />
                </xsl:call-template>
        </xsl:variable>
            <xsl:variable name="invalidchar" select="' .'" />
            <xsl:variable name="precate" select="translate(@Category.,' ','-')"/>
            <xsl:variable name="cate" select="translate($precate,'#;',' ')"/>
            <xsl:variable name="multicate" select="translate(@Category.,'#',' ')"/>
            <xsl:variable name="Title" select="translate(@Title,$invalidchar,'-')"/>

                                <xsl:value-of select="@Title" />

                            <xsl:value-of select="@Price" disable-output-escaping="yes"/>

                            <xsl:value-of select="@_Comments" disable-output-escaping="yes"/>

                    <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">

                    </xsl:if>

    </xsl:template>

    <xsl:template name="dvt_1.empty">
        <xsl:variable name="dvt_ViewEmptyText">There are no items to show in this view.</xsl:variable>

                    <xsl:value-of select="$dvt_ViewEmptyText"/>

    </xsl:template>
    </xsl:stylesheet>   </XSL>

    </WebPartPages:DataFormWebPart>

</asp:Content>

All Products shows below, this is what Im trying to remove so it doesnt show until a category is clicked.

A: This was used at the end of the page, just passed the piece of Javascript.

                        <xsl:call-template name="dvt_1"/>


text:
Q: Meteor bootstrap less mixins not working across files I am using bootstrap with Meteor, and importing the bootstrap.less files, which is installed in the public folder, through an import command in main.less:
@import "public/bower_components/bootstrap/less/bootstrap.less";

Below it, I can start using the bootstrap mixins such as .clearfix() and text-hide() and they compile fine.
However, when I want to abstract my own less code into a separate file apply.less and import that file back into main.less, which now looks like this:
@import "public/bower_components/bootstrap/less/bootstrap.less";
@import "apply.less";

I now gets an error
=> Errors prevented startup:

While building the application:
client/less/apply.less:10:2: Less compiler error: .clearfix is undefined

This is really strange. Is this an issue with Meteor?
Another thing I found out - if I put this empty mixin definition
.clearfix(){}

at the top of my apply.less file, things will compile fine again.
Has anyone come across this issue before and figured out a workaround?

A: Rename your second file as apply.lessimport and import it as:
@import "apply.lessimport";

Basically, the less package looks for every file in the directory tree with a ".less" extension and compiles it to CSS individually, regardless of whether the file is being imported by another file.
When it finds a file with a ".lessimport" extension, it adds it to the list of watched files, but does not actually compile or do anything with it.


text:
Q: Transfer of control and data between C and C# C# main program needs to call a C program GA.c This C code executes many functions and one function initialize() calls objective() function. But this objective function needs to be written in C#.This call is in a loop in the C code and the C code needs to continue execution after the return from objective() until its main is over and return control
to C# main program.
C# main()
{
  //code

  call to GA in C;
  //remaining code;
}

GA in C:

Ga Main()
{

 //code
 call to initialize function();
 //remaining code
}

initialize function() in GA
{

 for(some condition)
 {
   //code
   call to objective(parameter) function in C#;
   //code
  }
}

How do we do this?

A: Your unmanaged C code needs to be in a library, not an executable.  When a program "calls another program", that means it executes another executable, and any communication between the two processes is either in the form of command-line arguments to the callee coupled with an integer return value to the caller, or via some sort of IPC*.  Neither of which allows the passing of a callback function (although equivalent functionality can be built with IPC, it's a lot of trouble).
From this C library, you'll need to export the function(s) you wish to be entry points from the C# code.  You can then call this/these exported function(s) with platform invoke in C#.
C library (example for MSVC):
#include <windows.h>

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved){
    switch(ul_reason_for_call){
    case DLL_PROCESS_ATTACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}

#ifdef __cplusplus
extern "C"
#endif
__declspec(dllexport)
void WINAPI Foo(int start, int end, void (CALLBACK *callback)(int i)){
    for(int i = start; i <= end; i++)
        callback(i);
}

C# program:
using System;
using System.Runtime.InteropServices;

static class Program{

    delegate void FooCallback(int i);

    [DllImport(@"C:\Path\To\Unmanaged\C.dll")]
    static extern void Foo(int start, int end, FooCallback callback);

    static void Main(){
        FooCallback callback = i=>Console.WriteLine(i);
        Foo(0, 10, callback);
        GC.KeepAlive(callback); // to keep the GC from collecting the delegate
    }
}

This is working example code.  Expand it to your needs.

A note about P/Invoke
Not that you asked, but there are two typical cases where platform invoke is used:

*

*To leverage "legacy" code.  A couple of good uses here:

*

*To make use of existing code from your own code base.  For instance, your company might want a brand new GUI for their accounting software, but choose to P/Invoke to the old business layer so as to avoid the time and expense of rewriting and testing a new implementation.

*To interface with third-party C code.  For instance, a lot of .NET applications use P/Invoke to access native Windows API functionality not exposed through the BCL.

*To optimize performance-critical sections of code.  Finding a bottleneck in a certain routine, a developer might decide to drop down to native code for this routine in an attempt  to get more speed.
It is in this second case that there is usually a misjudgment.  A number of considerations usually prove this to be a bad idea:

*

*There is rarely a significant speed benefit to be obtained by using unmanaged code.  This is a hard one for a lot of developers to swallow, but well-written managed code usually (though not always) performs nearly as fast as well-written unmanaged code.  In a few cases, it can perform faster.  There are some good discussions on this topic here on SO and elsewhere on the Net, if you're interested in searching for them.

*Some of the techniques that can make unmanaged code more performant can also be done in  C#.  Primarily, I'm referring here to unsafe code blocks in C#, which allow one to use pointers, bypassing array boundary checking.  In addition, straight C code is usually written in a procedural fashion, eliminating the slight overhead that comes from object-oriented code.  C# can also be written procedurally, using static methods and static fields.  While unsafe code and gratuitous use of static members are generally best avoided, I'd say that they are preferable to mixing managed and unmanaged code.

*Managed code is garbaged-collected, while unmanaged code is usually not.  While this is mostly a speed benefit while coding, it is sometimes a speed benefit at runtime, too.  When one has to manage one's own memory, there is often a bit of overhead involved, such as passing an additional parameter to functions denoting the size of a block of memory.  There is also eager destruction and deallocation, a necessity in most unmanaged code, whereas managed code can offload these tasks to the lazy collector, where they can be performed later, perhaps when the CPU isn't so busy doing real work.  From what I've read, garbage collection also means that allocations can be faster than in unmanaged code.  Lastly, some amount of manual memory management is possible in C#, using Managed.AllocHGlobal and unsafe pointers, and this might allow one to make fewer larger allocations instead of many smaller ones.  Another technique is to convert types used in large arrays to value types instead of reference types, so that the memory for the entire array is allocated in one block.

*Often overlooked is the cost within the platform invoke layer.  This can outweigh small  native code performance gains, especially when many transitions from managed to unmanaged (or vice versa, such as with your callback function) must occur.  And this cost can increase exponentially when marshaling must take place.

*There's a maintenance hassle when splitting your code between managed and unmanaged components.  It means maintaining logic in two different projects, possibly using two different development environments, and possibly even requiring two different developers with different skill sets.  The typical C# developer is not a good C developer, and vice versa.  At minimum, having the code split this way will be a mental stumbling block for any new maintainers of the project.

*Oftentimes, a better performance gain can be had by just rethinking the existing implementation, and rewriting it with a new approach.  In fact, I'd say that most real performance gains that are achieved when bottleneck code is rewritten for a "faster" platform are probably directly due to the developer being forced to rethink the problem.

*Sometimes, the code that is chosen to be dropped out into unmanaged is not the real bottleneck.  People too often make assumptions about what is slowing them down without doing actual profiling to verify.  Profiling can often reveal inefficiencies that can be correctly fairly easily without dropping down to a lower-level platform.
If you find yourself faced with a temptation to mix platforms to increase performance, keep these pitfalls in mind.

* There is one more thing, sort of.  The parent process can redirect the stdin and stdout streams of the child process, implementing character-based message passing via stdio.  This is really just an IPC mechanism, it's just one that's been around longer than the term "IPC" (AFAIK).

A: This is known as a callback. When you create an instance of GA, pass it your c# objective() method as a delegate (a delegate is reference to a class method). Look for the MSDN help topic on delegates in C#.
I don't know the proper syntax for the C side of this. And there are sure to be some special considerations for calling out to unmanaged code. Someone else is bound to provide the whole answer. :)


text:
Q: Updating Embedded Array And Objects In Mongo In Mongo I have a collection of post and each post has comments that are embed with a user id, user name and user email.
- post
    - comments
           - user_id name email

I was wondering how can I update the all the emails that are associated with a certain id?

A: Currently, you would have to retrieve comments first, and then update emails.
Depending on which client you use, here is a mongoid example:
comments = post.comments
comments.update_attributes(:email => "a@b.c")

Also there is already a "Use positional operator to update all items in an array" JIRA that, once implemented, will allow you to do it in one shot.

A: Have you tried the $ positional operator, its the only way to update the matching sub(embedded docs) docs.


text:
Q: Kerberos issue through RRAS VPN I set up a Windows VPN infrastructure with RRAS NPS CA roles. A user certificate is deployed on each laptop and are joined to a single domain. VPN use IKEv2.
VPN is UP, communications are working to our internals networks, except applications that use integrated authentication.
The issue seems related to Kerberos authentication because I have the following error on the event viewer
Source : LSA
Event : 40960
The failure code from authentication protocol Kerberos was "that request is not supported"(0xc00000bb)
When i'm directly connected to my internal network, everything is working well.
The VPN infrastructure seemms to be causing the issue.
Thanks for your help :)
Edit :
We use Remote Desktop Manager which try to authenticate to a SQL Server. This error is returned.
SQL Server error


text:
Q: How to use the same label in TFS? I am trying to use labels in TFS.  I understand that labels have scope but I don't understand why am I getting an error:
A label with the name 'CB-ARCHIVE-2018' already exists. Do you want to continue? The existing label will be replaced.
I created a ('CB-ARCHIVE-2018') labeled for '$/SourceCode/WebService' and I am trying to use the same label for folder '$/SourceCode/WebService-branch'.

Thank you!

A: When you use Visual Studio to apply a label that already exists, the operation removes the label from all file versions and then applies the label. From the command prompt, however, the label operation is additive. See Label Command (Team Foundation Version Control). So use tf command to add the exist label:
tf label CB-ARCHIVE-2018 $/SourceCode/WebService-branch /collection:http://tfs:8080/tfs/DefaultCollection

Check the link below for more information:
https://learn.microsoft.com/en-us/vsts/tfvc/use-labels-take-snapshot-your-files?view=vsts#apply-a-label

A: Labels are a bit if a confusing beast in TFVC, mostly because the Ui doesn't enable all options.
From the Ui the scope is always set to $/. The path you specify tells Visual Studio which files/folders to include in the label.
You could try adding @$/SourceCode/Webservice to the label name, not sure if that works.
The sure way to specify a label scope is from the commandline from where you can issue the following command to apply the label:
tf.exe vc label CB-ARCHIVE-2018@$/SourceCode/Webservice  $/SourceCode/Webservice

Label scopes can't intercect, so you'll probably need to delete the existing labels first.


text:
Q: wrapping TCL/TK file with AWK command inside I've created a simple TCL/TK file which contains a button which executes awk command:
#!/usr/bin/env wish
package require Tk
pack [button .b -text "process" -command {exec awk {$1=="aa" {print $0}} ./input.txt > ./temp.txt}]

Using freewrap I made this file executable on Windows (.exe) and when I push the button I have such an error:
Error: couldn't execute "awk": no such file or directory
Is there a way to include/add awk into .exe output file or attach awk libraires to .exe as external file or other way to make awk command recognized without rewriting awk command on TCL code?
Regards

A: awk {$1=="aa" {print $0}} ./input.txt > ./temp.txt

in Tcl:
set in [open ./input.txt r]
set out [open ./temp.txt w]
while {[gets $in line] != -1} {
    set firstword [lindex [split [string trim $line]] 0]
    # or: regexp {\S+} $line firstword
    if {$firstword eq "aa"} {puts $out $line}
}
close $in
close $out

A: The awk-code you showed here is quite simple and can easily be rewritten in tcl.
But you want to know a solution without this, so you need to install an awk exe on your computer.
One may find an executable here: http://gnuwin32.sourceforge.net/packages/gawk.htm


text:
Q: Add radio buttons to specific shipping method on WooCommerce checkout I added a new shipping method "pickup from store" with free shipping to WooCommerce.
I have 2 stores, "Barsha" and "Deira".
I would like when customer choose pickup from a store to be able to select which store he will visit.
Here is what I added to cart-shipping.php template file:
<?php

Please choose the pickup store:

        <input type="radio" id="barsha" sname="store" value="barsha">
        Barsha Check Location

        <input type="radio" id="deira" sname="store" value="deira">
        Deira Check Location

    $sname= sname;
    if ( $sname = 'barsha'); {
        printf ('barsha')
    } else {
        printf ('deira')
    }
?>

But I can't get it working. How can I add some radio buttons to a specific shipping method and save the chosen option when order is submitted?

A: I suppose that in your case, you want to display some fields under "Local pickup" WooCommerce enabled shipping method.
Instead of overriding cart-shipping.php template, you can better use the dedicated action hook for shipping methods that will allow you to display fields for a specific shipping method.
The following code will allow you to display 2 radio buttons under "Local pickup" shipping method, when it's selected. If customer forget to choose a store, a message will remind him to chose a store for pickup. Then when order will be placed, the chosen store will be saved as custom order meta data, displayed in admin order under the billing address and everywhere near the chosen shipping method (orders and email notifications):
// Add custom fields to a specific selected shipping method
add_action( 'woocommerce_after_shipping_rate', 'pickup_store_custom_field', 100, 2 );
function pickup_store_custom_field( $method, $index ) {
    // Only on checkout page and for Local pickup shipping method
    if( is_cart() || $method->method_id !== 'local_pickup' )
        return;

    $chosen_shipping_methods = WC()->session->get('chosen_shipping_methods')[ $index ];

    $chosen_method_id = explode(':', $chosen_shipping_methods);
    $chosen_method_id = reset($chosen_method_id);

    // Only when the chosen shipping method is "local_pickup"
    if( $chosen_method_id !== 'local_pickup' )
        return;

    echo '

        ' . __("Choose your pickup store") . ':

            <input type="radio" id="barsha-store" name="pickup_store" value="Barsha">'
            . __("Barsha") . ' '. __("Check Location") . '

            <input type="radio" id="deira-store" name="pickup_store" value="Deira">'
            . __("Deira") . ' '. __("Check Location") . '

';
}

// Pickup store field validation
add_action('woocommerce_checkout_process', 'pickup_store_checkout_validation');
function pickup_store_checkout_validation() {

    $chosen_shipping_methods = WC()->session->get('chosen_shipping_methods')['0'];

    $chosen_method_id = explode(':', $chosen_shipping_methods);
    $chosen_method_id = reset($chosen_method_id);

    if( $chosen_method_id === 'local_pickup' && empty( $_POST['pickup_store'] ) )
        wc_add_notice( __("Please choose a pickup store"), "error" );
}

// Save chosen Pickup store as custom order meta data
add_action( 'woocommerce_checkout_create_order', 'pickup_store_update_order_meta' );
function pickup_store_update_order_meta( $order ) {
    if( isset( $_POST['pickup_store'] ) && ! empty( $_POST['pickup_store'] ) )
        $order->update_meta_data( 'pickup_store', esc_attr( $_POST['pickup_store'] ) );
}

// Display the chosen pickup store under billing address
add_action( 'woocommerce_admin_order_data_after_billing_address', 'display_pickup_store_on_order_edit_pages' );
function display_pickup_store_on_order_edit_pages( $order ){
    if( $pickup_store = $order->get_meta( 'pickup_store' ) )
        echo '
Pickup store: '.$pickup_store.'
';
}

// Display the chosen pickup store below the chosen shipping method everywhere
add_filter( 'woocommerce_get_order_item_totals', 'display_pickup_store_on_order_item_totals', 1000, 3 );
function display_pickup_store_on_order_item_totals( $total_rows, $order, $tax_display ){
    if( $pickup_store = $order->get_meta( 'pickup_store' ) ) {
        $new_total_rows = [];

        // Loop through order total rows
        foreach( $total_rows as $key => $values ) {
            $new_total_rows[$key] = $values;
            // Inserting the pickup store under shipping method
            if( $key === 'shipping' ) {
                $new_total_rows['pickup_store'] = array(
                    'label' => __("Pickup store"),
                    'value' => $pickup_store
                );
            }
        }
        return $new_total_rows;
    }

    return $total_rows;
}

Code goes in functions.php file of your active child theme (or active theme). Tested and works.

On checkout page:

On customer Orders (and email notifications):

On admin order edit pages (under the billing address):

Related answers:

*

*Shipping carrier custom fields validation in Woocommerce checkout page

*Add a checkbox below a specific shipping method in WooCommerce 3


text:
Q: How do I create a NuGet package for a C++/CLI using MSBuild? I've read these instructions for creating NuGet packages for C++/CLI .vcxproj projects using a .nuspec file. However, I'd like to use MSBuild to create my package instead of using a .nuspec file. I've seen these instructions for packaging .NET Framework projects using MSBuild, but I haven't been able to find anything for doing the same with .vcxproj files.

A: MSBuild can pack a Visual Studio project into a NuGet package, but only if that project uses PackageReference instead of packages.config.
As of this writing, the Visual Studio UI doesn't allow you to choose PackageReference instead of packages.config as the NuGet package configuration mechanic for VCXPROJ files. However, you can manually edit the .vcxproj file and convert it to PackageReference format.
Edit .vcxproj
By default, .vcxproj files are not SDK-style projects (I don't know if they can even be converted to SDK-style projects). To build NuGet packages from non-SDK-style projects, you'll need to reference NuGet.Build.Tasks.Pack:
Add the following to your .vcxproj (inside the Project element):
  <ItemGroup>
    <PackageReference Include="NuGet.Build.Tasks.Pack">
      <Version>5.11.0</Version>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>

Add any other packages your project depends on. Notice the <PrivateAssets>all</PrivateAssets> element. You need NuGet.Build.Tasks.Pack to pack your project, but you don't want it as a dependency when others try and install your NuGet package. Adjust the version for NuGet.Build.Tasks.Pack as appropriate.
If your project references static libraries, you don't want those included as NuGet package dependencies. Use the PrivateAssets element to exclude them. I.e:
  <ItemGroup>
    <ProjectReference Include="..\vendor\static-lib-build\static-lib\static-lib.vcxproj">
      <Project>{8aa99891-3ff7-3fa7-b1b5-131664298a26}</Project>
      <PrivateAssets>all</PrivateAssets>
    </ProjectReference>
  </ItemGroup>

Also add the following inside the Project element"
  <PropertyGroup>
    <PackageId>Your.Package.Id</PackageId>
    <Authors>Your Name</Authors>
    <BuildOutputTargetFolder>lib</BuildOutputTargetFolder>
    <PackageDescription>A description of this package.</PackageDescription>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>

What's in the TargetFramework element should correspond to what's in the TargetFrameworkVersion element elsewere in your project.
Note that I haven't covered building a cross-platform NuGet package. By its very nature, C++/CLI projects are targeted to a specific processor / architecture. You can include native libraries for multiple architectures in the runtime directory of your NuGet package, but I don't cover that here.
Restore, Build, and Pack Using MSBuild
This line will restore your NuGet packages, build the project, and then pack it:
"c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" path\to\the_project.vcxproj /p:Platform="Any CPU" /p:ProductVersion=1.0.0.69 /t:Restore;Build /t:pack

Change the command line options to suit your needs. You may need to run this command twice if NuGet.Build.Tasks.Pack hasn't already been restored.


text:
Q: using href to two links(php and a webpage) While($enreg=mysql_fetch_array($res))
{
   $link_d.="clic here to download	"
}

i want to use the href so it leads to download link, also to send the id to a php file so i can get how many times the files have been downloaded !
How can we use href to multiple links !

A: You can't.  A link can only point to one resource.
Instead, what you should do is have your PHP script redirect to the file.  The link points at your PHP script with the counter, and then set a Location: header (which automatically sets a 302 status code for redirection) with the value being the URL you want to redirect to.
Also, you should really use htmlspecialchars() around any variable data you use in an HTML context, to ensure you are generating valid HTML.

A: Ideally you would have some checks to see if it's a human downloading (Web crawlers may trigger it - we will put no-follow in the link which will help though). You could also use a database but that gets more complicated. My preferred way would be to use Google Analytics Events. But here is a simple PHP script that might fulfill your needs without the complexity of the other solutions.
First modify your links to have a tracker script and to urlencode
$link_d.= 'click here to download';

}
Then create a script that will record downloads (tracker.php)
 <?php

// keep stats in a file - you can change the path to have it be below server root
// or just use a secret name - must be writeable by server
$statsfile = 'stats.txt';

// only do something if there is a url
if(isset($_GET['url'])) {

  //decode it
  $url = urldecode($_GET['url']);

  // Do whatever check you want here to see if it's a valud link - you can add a regex for a URL for example
  if(strpos($url, 'http') != -1) {

    // load current data into an array
    $lines = file($statsfile);

    // parse array into something useable by php
    $stats = array();
    foreach($lines as $line) {
      $bits = explode('|', $line);
      $stats[(string)$bits[0]] = (int)$bits[1];
    }

    // see if there is an entry already
    if(!isset($stats[$url])) {

      // no so let's add it with a count of 1
      $stats[$url] = 1;

    } else {

      // yes let's increment
      $stats[$url]++;

    }
    // get a blank string to write to file
    $data = null;

    // get our array into some human readabke format
    foreach($stats as $url => $count) {
      $data .= $url.'|'.$count."\n";
    }

    // and write to file
    file_put_contents($statsfile, $data);
  }

  // now redirect to file
  header('Location: ' . $url);

}

A: You can't.
Anchor are meant to lead to one ressource.
What you want to do is tipically addressed by using an intermediate script that count the hit and redirect to the ressource.
eg.
Click here to download

redirect.php
// Increment for example, a database :
// UPDATE downloads SET hits = (hits + 1) WHERE id=42

// Get the URI
// SELECT uri FROM downloads WHERE id=42

// Redirect to the URI
// (You may also need to set Content-type header for file downloads)
header( "Location: $uri" );

You may optimize this by passing the uri as a second parameter so that you won't need to fetch it at redirect time.
Click here to download

Another way of collecting this kind of statistics is to use some javascript tools provided by your statistics provider, like Google Analytics or Piwik, adding a listener to the click event.
It is less invasive for your base code but won't let you easily reuse collected data in your site  (for example if you want to show a "top download" list).

A: Create a file with download script for example download.php and route all your downloads through it. Update your counter in this page and use appropriate headers for download.
eg:
url may be download.php?id=1&file=yourfile
in download.php
//get id and file
//database operation to update your count
//headers for download


text:
Q: Navigation Drawer in a google maps activity I'm exploring ways on how codes work in android and I'm a beginner. I'm wondering how can you add navigation drawer since you can't add widgets in the .xml file of the google map. Is it possible to add navigation drawer?
Also is it possible to add a button and put the codes in MapsActivity.java?

A: You would not add the navigation drawer to the inside of the Google map, but you could certainly have an Activity that hosted both a Google map and a navigation drawer.


text:
Q: select2 change color of dropdown Yeah, so I have no idea what I'm doing. Hah.
I want to change the color of select2's un-opened dropdown (and maybe the button on the side), but hunting for a solution has only managed to snag me
.select2-choice{
  min-height: 35px;
  max-height: 35px;
  background: #222;
  overflow-y: auto;
}

.select2-search {
    background-color: #666;
}

.select2-search input {
    background-color: #666;
}
.select2-results {
    background-color: #666;
}

Which gets the options changed (Which is good!) but isn't 100% what I'm after.

Is there a class that changes the color of the dropdown's initial state?

A:
select2 change color of dropdown

.select2-results__option {
    background-color: red;
    color: yellow;
}

look

A: it might be the answer:
i had those problems with SelectBox if you know the plugin, after like 10 mins i told to my self = "darn, it isn't my problem".
problem in those plugin its that they are taking the options from your select tag and just creates an object of thier own.
the solution is to destroy the created element and re-create it again.
if its not working, tell me, ill delete the answer even though im 90% convinced its the problem.

A: There is no class to change a dropdown's initial state, but you can write your own very short and easy to understand Jquery to set a dropdown's color.
First, write the color changing function:
var changeColor = function (element, selection) {//changes colors of dropdowns
    if (selection == 1 || selection == "green") {//Mine works based on the dropdown itself
        element.css('background-color', 'green');
    }
    else if (selection == 2 || selection == "yellow") {
        element.css('background-color', 'yellow');
    }
    else {
        element.css('background-color', 'red');
    }
}

Then, make sure that you run the function when your page is finished rendering:
jQuery(document).ready(function ($) {
    changeColor($('#ColoredDropdown'), $('#ColoredDropdown').val());
});

Finally, be sure to call the color changing function whenever you need it - in this case, when you change another dropdown:
$('#FirstDropdown').change(function () {
    changeColor($('#SecondDropdown'), $('#FirstDropdown').val());
});

Sorry this answer is so late! I don't totally understand your question so you'll have to get the "gist" of what I'm saying rather than just copying and pasting, but I hope it helps.

A: I realize this is an old question now but it has been viewed quite a few times over the years and has no accepted answer yet.  I just recently worked on a theming project where I had to theme these controls so I wanted to share how I solved this problem.
The following CSS overrides different pieces of the Select 2 drop-down control.  If you would like to see it in action and/or change the somewhat garish example colors to something matching your own project, you can try it out in out in this fiddle: https://jsfiddle.net/0t4ky6e5/2
:root {
    --Color1: #3333FF;
    --Color2: #FFFFFF;
    --Color3: #EC2121;
    --Color4: #000000;
    --Color5: #AAAAAA;
    --Color6: #F99320;
}

.js-example-basic-single {
  width: 200px;
}

/* Search Box */
.select2-container--default .select2-search--dropdown .select2-search__field {
  background: var(--Color4);
  color: var(--Color2) !important;
}

/* Search Box border */
.select2-search--dropdown{
  background: var(--Color6);
}

/* Selected / Initial state input */
.select2-container--default .select2-selection--single .select2-selection__rendered {
  background: var(--Color1);
  color: var(--Color2) !important;
}

/* Option List Area */
.select2-results__option {
  background: var(--Color1);
  color: var(--Color2) !important;
}

/* Arrow button */
.select2-container--default .select2-selection--single .select2-selection__arrow {
  background: var(--Color3);
}

/* Selectable items highlight */
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
  background: var(--Color3) !important;
}

/* Selected item highlight */
.select2-container--default .select2-results__option--selected {
  background: var(--Color5) !important;
  color: var(--color4) !important;
}

/* Search result message area */
.select2-results__message {
  background: var(--Color6);
}


text:
Q: Retrieving a model based on combined value of two columns? I need a relatively simple statement where I sort my model based on two columns, hours and minutes, on said model.
The following works
$recipes->where('minutes','>', $minTime)->get();

But what I really want to do is
$recipes->where('hours * 60 + minutes','<', $minTime)->get();

Sadly this syntax is not available, I have been messing around with a couple of other solutions but I have been unable to solve it.
I was hoping for some directions as I have gotten stuck!

A: By default Laravel uses bindings in where statements and escapes them. To do calculations and such, use whereRaw:
$recipes->whereRaw('hours * 60 + minutes < '.$minTime)->get();

However now your query is vulnerable to SQL injection to avoid that create a binding manually:
$recipes->whereRaw('hours * 60 + minutes < ?', [$minTime])->get();

Instead of whereRaw you can also use DB::raw() inside the normal where function:
$recipes->where(DB::raw('hours * 60 + minutes'),'<', $minTime)->get();

This tells Laravel to not escape this part of the query.


text:
Q: How to define a protocol that lets implementers return their type in a static method? How to define a protocol that lets implementers return their class type in a static method?
protocol Insertable {

static func insertObjectWithAttributes(attributes: [String : AnyObject], managedObjectContext: NSManagedObjectContext) -> Self

}

class Item: NSManagedObject, Insertable {
static func insertObjectWithAttributes(attributes: [String : AnyObject],  managedObjectContext: NSManagedObjectContext) -> Self {

    var item = Item()
    return item  // Error, must return Self
    }

If i change Self to Item, the compiler says the class must return Self, and it doesn't work with returning Self either. How can this pattern be implemented?

A: You need to make your class final. Otherwise, your implementation doesn't return Self. If someone subclassed Item and added class Table: Item then the method should return Table not Item.
To make it short. Try the following:
protocol Insertable {

    static func insertObjectWithAttributes(attributes: [String : AnyObject], managedObjectContext: NSManagedObjectContext) -> Self

}

final class Item: NSManagedObject, Insertable {
    static func insertObjectWithAttributes(attributes: [String : AnyObject],  managedObjectContext: NSManagedObjectContext) -> Item {

        let item = Item()
        return item  // Error, must return Self
    }
}


text:
Q: Show different windows when editing a form vs editing a class When in Visual Studio 2010 is it possible to have presets on window layouts?  I would like to have VS auto show/hide windows depending on what type of document I'm viewing at the time.  For example...
When editing a FORM I want to see the following windows in the IDE

*

*Solution Explorer

*Toolbox

*Properties

When editing a CLASS I want to see the following windows in the IDE

*

*Solution Explorer

*Find and Replace

It would also be acceptable to simply have a quick way to change layouts manually instead of it happening automatically based on the type of document I'm viewing at the time.

A: Just found the answer after some helpful feedback from CodingGorilla!
Solution:
Install the Layouts O Rama Visual Studio extension.

How To Install The Extension:

*

*Open up Tools -> Extension Manager

*On the left, click on Online Gallery

*On the top right click in the Search Online Gallery text box.

*Search for Layouts O Rama

*Click install

*Restart Visual Studio

The new options will be located under the Tools menu.

How To Assign Shortcuts To Access The Layouts Quickly
Once you set all your layouts up with Save Windows Layout for each layout, you can then assign some keyboard shortcuts to each layout for quick access!

*

*Open Tools -> Layouts O Rama Window

*Click the little lightning bolt at the top

*Setup your layouts for quick access.  For me personally I just set 1 to my layout Code Layout and 2 to my layout Design Layout

*Close the Layouts O Rama Window window

*Open Tools -> Options

*Find Enviroment -> Keyboard on the left side

*In the Show commands containing: text box to the right type windowslayout

*For each Tools.LoadWindowsLayout (0-9) do the following steps 9-12

*Click on Tools.LoadWindowsLayout0 (0 should be the number layout you are working with ex: 0, 1, 2, 3, 4, 5, 6, 7, 8 or 9)

*Click in the Press shortcut keys: text box

*Press Ctrl+W then press 0 (0 should be the number layout you are working with ex: 0, 1, 2, 3, 4, 5, 6, 7, 8 or 9)

*Click the Assign button


text:
Q: Let $D=\{z \in \mathbb{C}: |z|<1\}$, then which of the following are true? Let $D=\{z \in \mathbb{C}: |z|<1\}$, then which of the following are true?

*

*There exists a holomorphic function $f:D\to D$ with $f(0)=0$ and $f'(0)=2$.

*There exists a holomorphic function $f:D\to D$ with $f(3/4)=3/4$ and $f'(2/3)=3/4$.

*There exists a holomorphic function $f:D\to D$ with $f(3/4)=-3/4$ and $f'(3/4)=-3/4$.

*There exists a holomorphic function $f:D\to D$ with $f(1/2)=-1/2$ and $f'(1/4)=1$.

Now for option $1$, I see that it is not true by Schwarz lemma. But I don't know how to decide the rest. Schwarz lemma says one more thing that if $|f(z)|=|z|$ then $f(z)=az$ where $|a|=1$. So $|f(3/4)|=|-3/4|=3/4$, is this going to help? How can I proceed further? Help needed please.
Edit: Ok I just found that this is a duplicate of this question, but I still appreciate some answers as I didn't properly understand the answer given.


text:
Q: LocalBroadcastReciever not working in fragment I am trying to display a scanned barcode inside of an editText field (which is inside a fragment) using local broadcast receiver.
This is my code:
OnActivityResult in MainActivity.java
public void onActivityResult(int requestCode, int resultCode, Intent intent){
    Log.d("onActivityResultCalled", "yes");
    if(requestCode == IntentIntegrator.REQUEST_CODE){
        if (resultCode == RESULT_OK){
            String contents = intent.getStringExtra("SCAN_RESULT");
            String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
            Log.d("content", contents);
            Log.d("format", format);
            Log.d("sender", "Broadcasting message");
            Intent scanIntent = new Intent("scanEvent");
            scanIntent.putExtra("isbn",contents);
            LocalBroadcastManager.getInstance(this).sendBroadcast(scanIntent);

        }else if(resultCode == RESULT_CANCELED){
            Log.e("MainActivity","Scan cancelled?");
        }
    }
}

Code for recieving broadcast and displaying the isbn:
@Override
public void onResume()
{
    super.onResume();
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mMessageReceiver,
            new IntentFilter("scanEvent"));
}

// Our handler for received Intents. This will be called whenever an Intent
// with an action named "scanEvent" is broadcasted.

private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        // Get extra data included in the Intent
        isbnData = intent.getStringExtra("isbn");
        Log.d("receiver", "Got message: " + isbnData);
        isbn.setText(isbnData);
    }
};

@Override
public void onPause() {
    // Unregister since the activity is about to be closed.
    LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(mMessageReceiver);
    super.onDestroy();
}

The scanning of the barcode itself works successfully. The issue is being able to display that barcode in the edittext.

A: It looks like you're unregistering your broadcast receiver.
Taking a look at this question regarding onResume and onActivityResult, onActivityResult gets called before onResume, so by the time your fragment registers as a receiver it's too late.
Try moving your broadcast receiver registration to onCreate and onDestroy instead.


text:
Q: Deploying Qt with MinGW requires VC++ redistributable? I'm testing an application using Qt 4.7.3 compiled with MinGW on a clean XP virtual box.  The application wasn't working and after much grief, I traced the error to needing to download the Visual C++ 2005 redistributable.  I downloaded this and it worked.  Something doesn't seem right here, shouldn't I not need any VC++ libraries since I'm using MinGW?  Could it be a problem with my compilation?  I should mention that I'm not using qmake to build.

A: The dependency on MSVCRT.DLL is due to MinGW itself. To quote mingw.org..

MinGW provides a complete Open Source programming tool set which is
  suitable for the development of native MS-Windows applications, and
  which do not depend on any 3rd-party C-Runtime DLLs. (It does depend
  on a number of DLLs provided by Microsoft themselves, as components of
  the operating system; most notable among these is MSVCRT.DLL, the
  Microsoft C runtime library.

Also see: Should I redistribute msvcrt.dll with my application?

A: As noted in the Qt documentation, yes, that is required:
http://doc.qt.io/qt-5/windows-deployment.html


text:
Q: find by name or by grep find . -perm -u+x,g+x,o+x -type f -exec grep -i -l -H -E '#!/bin/bash|#!/bin/sh' {} \; 2>/dev/null 1>/$user_scripts

I am tasked with finding any script that could exist for N users in 4 folders. I will be using ssh and executing the command above to generate a list of files for later use. Some scripts with the file extension .sh and .bash which do not contain #!/bin/bash|#!/bin/sh are not found.
I need to improve upon this but I am struggling to find something that works in the Solaris server which I have no admin rights for (No special software / libraries). If possible I would prefer not to need to execute another script that would needlessly appear in each list for each user.
Basically I need some kind of "If(find or grep)" in the same line. Is this possible?

A: You can do this by OR-ing different parts of your find command. Consider splitting your selection criteria into three parts: necessary requirements for all files (permissions, etc), and then EITHER named files OR those with an appropriate header.
This can be expressed with find like this (split onto multiple lines here for readability only):
find . -perm -u+x,g+x,o+x -type f \(
    -name '*.sh' -o
    -name '*.bash' -o
    -exec grep -il -E '^#!/bin/bash|^#!/bin/sh' {} \;
\) 2>/dev/null >/$user_scripts


text:
Q: Find condition in cakePHP with Containable behavior I have 2 models, User and Evolution. User has many Evolution, Evolution belongs to User.
I have 10 000 users and I want to do a condition that give me 500 users that DON'T have today's date in the Evolution table.
Originally, I was taking every one in the USER table and then I was looking if they had their row in Evolution like:
$user=$this->User->find('all',array('contain' => array(

                'Evolution' => array('conditions' => array('date'=>$lastupdate))
            ),
        'fields' => array(
            'name',
            'id',
        )
    ));

and then looking if there was a row or not :
if(empty($user['Evolution']))
        {

But I think that is farely stupid to take 10 000 users and foreach them all to just take 500.
How can I do my find to directly have 500 users that DO NOT have today's date in Evolution table.
Thanks!!

A: What about doing something like this:
$evolutions = $this->User->Evolution->find('all',
        array(
             'conditions'=>array('date !='=>$lastupdate),
             'fields'=>array('MAX(date) as max_date', 'user_id', 'User.name', 'User.email'),
             'group'=>array('user_id', 'User.name', 'User.email')
        ),
        'contain'=>array('User'),
        'limit'=>500
)

This way, you search in evolutions table, but because they are linked you will have the user's record for each evolution.
The problem will come if there are more than one evolution per day, but then you can play with MAX() somehow.

A: How about
$user=$this->User->find('all',array('contain' => array(

            'Evolution' => array('conditions' => array('date !='=>$lastupdate))
        ),
    'fields' => array(
        'name',
        'id',
    )
    'limit'=>500
));


text:
Q: PHPExcel: Some Lines are not exporting in my .xls file while importing but shown when i echo the output? I am using PHPExcel with mysql and MongoDB to export data in Excel .XLS file but only in 1 Column some Lines are not showing and some are showing in same Columns while exporting although all are shown when i use $print_() to check output in browser
Here is my PHP Code -
    $objPHPExcel = new PHPExcel();
$sheet = $objPHPExcel->getActiveSheet();
$sheet->setCellValue('M1', 'Headline');

 $objPHPExcel->getActiveSheet()->getStyle('M')->applyFromArray($styleArray);
        $objPHPExcel->getActiveSheet()->getStyle('M')->getFont()->setUnderline(true);

            if ($result['type'] == "WEB") {

                $sheet->setCellValue('M' . ($results + 2), $result['headline']);
                $sheet->getCell('M' . ($results + 2))->getHyperlink()->setUrl($result['url']);
                $sheet->getCell('M' . ($results + 2))->getHyperlink()->setTooltip('Navigate to website');

}

and this is my output
output

A: I post here an example without link (you can edit my code):
$objPHPExcel    =   new PHPExcel();
$result         =   $db->query("SELECT * FROM YOURTABLE") or die(mysql_error());

$objPHPExcel->setActiveSheetIndex(0);

$objPHPExcel->getActiveSheet()->SetCellValue('M1', 'Headline');

$objPHPExcel->getActiveSheet()->getStyle("M1")->getFont()->setBold(true);

 $rowCount   =   2;
while($row  =   $result->fetch_assoc()){
    $objPHPExcel->getActiveSheet()->SetCellValue('M'.$rowCount, mb_strtoupper($row['headline'],'UTF-8'));

    $rowCount++;
}

$objWriter  =   new PHPExcel_Writer_Excel2007($objPHPExcel);

header('Content-Type: application/vnd.ms-excel'); //mime type
header('Content-Disposition: attachment;filename="you-file-name.xlsx"'); //tell browser what's the file name
header('Cache-Control: max-age=0'); //no cache
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');


text:
Q: Display sum of mutlple rows value in single column between date range using sql query I  have following sql query.
SELECT E.EMPID, TM.LOGIN, TM.LOGOUT,
    SUM(DATEDIFF(MINUTE,TM.LOGIN,TM.LOGOUT)/60)+':'+
    SUM(DATEDIFF(MINUTE,TM.LOGIN,TM.LOGOUT)%60) AS WORKEDHOURS
FROM EMPLOYEE_DETAILS E
LEFT JOIN TIMING_DETAILS TM
    ON(E.EMPID=TM.EMPID)
WHERE TM.LOGIN BETWEEN '2013-09-02' AND DATEADD(DAY, 1, '2013-09-03')
GROUP BY E.EMPID,TM.LOGIN,TM.LOGOUT
ORDER BY E.EMPID

After running above query, I get following output :
EMPID   LOGIN               LOGOUT          WORKEDHOURS
1     2-9-2013 9:30      2-9-2013 1:00          3:30
1     2-9-2013 2:00      2-9-2013 6:00          4:00

2     2-9-2013 9:30      2-9-2013 2:00          4:30
2     2-9-2013 3:00      2-9-2013 6:00          3:00

1     3-9-2013 9:30      3-9-2013 6:00          8:30

But, I want to display result as follows, Anybody please help here, thanks
EMPID   LOGIN               LOGOUT          WORKEDHOURS
1     2-9-2013 9:30      2-9-2013 1:00          7:30
1     2-9-2013 2:00      2-9-2013 6:00

2     2-9-2013 9:30      2-9-2013 2:00          7:30
2     2-9-2013 3:00      2-9-2013 6:00

1     3-9-2013 9:30      3-9-2013 6:00          8:30

A: EDIT, found a simpler solution:
    SELECT T.EMPID, T.LOGIN, T.LOGOUT, X.WORKEDHOURS
FROM TIMING_DETAILS T
INNER JOIN
    (SELECT EMPID, DATEPART(YEAR, TM.LOGIN) YEAR, DATEPART(MONTH, TM.LOGIN) MONTH, DATEPART(DAY, TM.LOGIN) DAY,
        CAST(SUM(DATEDIFF(MINUTE,TM.LOGIN,TM.LOGOUT))/60 AS VARCHAR(MAX))
        + ':'
        + CAST(SUM(DATEDIFF(MINUTE,TM.LOGIN,TM.LOGOUT))%60 AS VARCHAR(MAX)) AS WORKEDHOURS
    FROM TIMING_DETAILS TM
    WHERE TM.LOGIN BETWEEN '2013-09-02' AND DATEADD(DAY, 1, '2013-09-03')
    GROUP BY EMPID, DATEPART(YEAR, TM.LOGIN), DATEPART(MONTH, TM.LOGIN), DATEPART(DAY, TM.LOGIN)) X
ON X.EMPID = T.EMPID
    AND DATEPART(YEAR, T.LOGIN) = X.YEAR
    AND DATEPART(MONTH, T.LOGIN) = X.MONTH
    AND DATEPART(DAY, T.LOGIN) = X.DAY
ORDER BY X.EMPID, X.YEAR DESC, X.MONTH DESC, X.DAY DESC

A: SELECT E.EMPID, TM.LOGIN, TM.LOGOUT,WORKHOURS_TABLE.WORKEDHOURS

FROM EMPLOYEE_DETAILS E, TIMING_DETAILS TM ,

(SELECT EMPID,
concat(
sum(hour(timeDIFF(TM.LOGOUT, TM.LOGIN )))
+
sum(minute(timeDIFF(TM.LOGOUT, TM.LOGIN ))) div 60 ,
":" ,
sum(minute(timeDIFF(TM.LOGOUT, TM.LOGIN ))) % 60
)

AS WORKEDHOURS
FROM TIMING_DETAILS TM
GROUP BY EMPID) AS WORKHOURS_TABLE

WHERE E.EMPID =  WORKHOURS_TABLE.EMPID AND E.EMPID=TM.EMPID
ORDER BY E.EMPID

The output might be :
EMPID   LOGIN               LOGOUT          WORKEDHOURS
1     2-9-2013 9:30      2-9-2013 1:00          7:30
1     2-9-2013 2:00      2-9-2013 6:00          7:30

2     2-9-2013 9:30      2-9-2013 2:00          7:30
2     2-9-2013 3:00      2-9-2013 6:00          7:30

If you want to group by date then you have to keep a separate column for date and time, and then you can group by date.
I have tried the query in  my MySQL database and it works fine. You try it out.

A: Try this one -
SELECT
      t.EMPID
    , t.LOGIN
    , t.LOGOUT
    , WORKEDHOURS = CASE WHEN rn = 1 THEN t.WORKEDHOURS END
FROM (
    SELECT
          TM2.EMPID
        , TM2.LOGIN
        , TM2.LOGOUT
        , TM.WORKEDHOURS
        , rn = ROW_NUMBER() OVER (PARTITION BY TM2.EMPID ORDER BY TM2.EMPID)
    FROM dbo.TIMING_DETAILS TM2
    JOIN (
        SELECT
              EMPID
            , WORKEDHOURS = CAST(SUM(DATEDIFF(MINUTE, [login], LOGOUT)) / 60 AS VARCHAR(100)) + ':' + CAST(SUM(DATEDIFF(MINUTE, [login], LOGOUT)) % 60 AS VARCHAR(10))
        FROM dbo.TIMING_DETAILS
        WHERE [login] BETWEEN '20130902' AND '20130904'
        GROUP BY EMPID
    ) TM ON TM2.EMPID = TM.EMPID
    WHERE EXISTS( -- maybe this is unnecessary
         SELECT 1
         FROM dbo.EMPLOYEE_DETAILS E
         WHERE E.EMPID = TM2.EMPID
    )
) t

A: After our dialogue, and also reviewing your dialogue with other participants, I see that your problem is slightly more constrained.  The output you actually want is something like this:
EMPID   DAY          WORKEDHOURS
    1   2-9-2013     7:30
    1   3-9-2013     8:30
    2   2-9-2013     7:30

CASE 1: single day in range
If you are only interested in a single day, then you can just insert the date into the result.  Please try the following:
SELECT E.EMPID,
       '2013-09-02' AS DAY,
       SUM(DATEDIFF(MINUTE,TM.LOGIN,TM.LOGOUT)/60)+':'+
       SUM(DATEDIFF(MINUTE,TM.LOGIN,TM.LOGOUT)%60) AS WORKEDHOURS
FROM EMPLOYEE_DETAILS E
     LEFT JOIN TIMING_DETAILS TM
     ON (E.EMPID=TM.EMPID)
WHERE TM.LOGIN BETWEEN '2013-09-02' AND DATEADD(DAY, 1, '2013-09-03')
GROUP BY E.EMPID
ORDER BY E.EMPID

You can also rewrite your query to use a named parameter for the date in question.  Here is an example, but to use it you will have to bind a value to the parameter TheDay:
SELECT E.EMPID,
       @TheDay AS DAY,
       SUM(DATEDIFF(MINUTE,TM.LOGIN,TM.LOGOUT)/60)+':'+
       SUM(DATEDIFF(MINUTE,TM.LOGIN,TM.LOGOUT)%60) AS WORKEDHOURS
FROM EMPLOYEE_DETAILS E
     LEFT JOIN TIMING_DETAILS TM
     ON (E.EMPID=TM.EMPID)
WHERE TM.LOGIN BETWEEN @TheDay AND DATEADD(DAY, 1, @TheDay)
GROUP BY E.EMPID
ORDER BY E.EMPID

CASE 2: multiple days in range
If you need multiple rows per EMPID, but only one such row per day, then things are more complicated.  I think it is possible in several (perhaps all) DBMSs, but might require using non-portable features.  What we need to do is GROUP BY the day part of the LOGIN date-time value.
If you are using SQL Server 2008 (or newer), then you can try the following:
SELECT E.EMPID,
       CAST(TM.LOGIN AS DATE) AS DAY,
       SUM(DATEDIFF(MINUTE,TM.LOGIN,TM.LOGOUT)/60)+':'+
       SUM(DATEDIFF(MINUTE,TM.LOGIN,TM.LOGOUT)%60) AS WORKEDHOURS
FROM EMPLOYEE_DETAILS E
     LEFT JOIN TIMING_DETAILS TM
     ON (E.EMPID=TM.EMPID)
WHERE TM.LOGIN BETWEEN '2013-09-02' AND DATEADD(DAY, 1, '2013-09-03')
GROUP BY E.EMPID, CAST(TM.LOGIN AS DATE)
ORDER BY E.EMPID

Note that I have not been in a position to test this query.  You may, for example, have to GROUP BY DAY instead of repeating the expression.
CASE 2B: multiple days in range, with first and last login
Do you want one row per day per EMPID, but the first login time, and the last logout time?  You could try the following:
SELECT E.EMPID,
       MIN(TM.LOGIN) AS FIRSTLOGIN,
       MAX(TM.LOGOUT) AS LASTLOGOUT,
       SUM(DATEDIFF(MINUTE,TM.LOGIN,TM.LOGOUT)/60)+':'+
       SUM(DATEDIFF(MINUTE,TM.LOGIN,TM.LOGOUT)%60) AS WORKEDHOURS
FROM EMPLOYEE_DETAILS E
     LEFT JOIN TIMING_DETAILS TM
     ON (E.EMPID=TM.EMPID)
WHERE TM.LOGIN BETWEEN '2013-09-02' AND DATEADD(DAY, 1, '2013-09-03')
GROUP BY E.EMPID, CAST(TM.LOGIN AS DATE)
ORDER BY E.EMPID

Again, I have not been in a position to test this query.
TESTED CASE: A query on a local SQL Server Express database within Visual Studio 2010
I am not able to test on Sql Server today, but here is a version of the query that I have tested under Visual Studio 2010 on a local Sql Server Express database.
SELECT
    E.EMPID, E.NAME,
    MIN(TM.LOGIN) AS FirstLogIn,
    MAX(TM.LOGOUT) AS LastLogOut,
    CAST(SUM(DATEDIFF(MINUTE, TM.LOGIN, TM.LOGOUT) / 60) AS NVARCHAR)+':'+CAST(SUM(DATEDIFF(MINUTE, TM.LOGIN, TM.LOGOUT) % 60) AS NVARCHAR) AS WorkedHours
FROM
    EMPLOYEE_DETAILS AS E LEFT OUTER JOIN TIMING_DETAILS AS TM ON E.EMPID = TM.EMPID
WHERE
    TM.LOGIN BETWEEN '2013-09-21' AND DATEADD(DAY, 1, '2013-09-22')
GROUP BY
    E.EMPID, E.NAME,
    DATEADD(DAY, DATEDIFF(DAY, 0, TM.LOGIN), 0)
ORDER BY
    E.EMPID, FirstLogin

Test data EMPLOYEE_DETAILS:
EMPID    NAME
1        Joe
2        Jane
3        Martha

Test data TIMING_DETAILS:
EMPID    LOGIN                    LOGOUT
1        '2013-09-21 09:00:00'    '2013-09-21 10:30:00'
1        '2013-09-21 14:00:00'    '2013-09-21 16:00:00'
1        '2013-09-22 08:30:00'    '2013-09-22 11:00:00'
2        '2013-09-21 10:45:00'    '2013-09-21 13:30:00'

Results:
EMPID    NAME   FirstLogIn               LastLogOut               WorkedHours
1        Joe    '2013-09-21 09:00:00'    '2013-09-21 16:00:00'    3:30
1        Joe    '2013-09-22 08:30:00'    '2013-09-22 11:00:00'    2:30
2        Jane   '2013-09-21 10:45:00'    '2013-09-21 13:30:00'    2:45

That seems correct to me.  The only differences in my SQL Server Express query is that it does not provide the DATE type, so I had to modify the CAST.  Oh, and I had to explicitly cast to NVARCHAR for WorkedHours as well.
Please adapt accordingly for your environment.
Hope this helps.


text:
Q: PPPoE restart - Avoid dropping connections My ISP, like many others, is using the technique of terminating the users' PPPoE connection after 24 hours. I would obviously like to have the highest availability possible. I manually arranged the restart to happen early in the morning and also tuned the config option lcp-echo-interval 3 to get a quicker reconnect.
However, this is not a truly satisfactory solution. Is there a way to make Linux buffer outgoing packets until the connection is re-established, rather than sending back the ICMP Destination network unreachable? There may also be other caveats I'm not yet sure of, like netfilter dropping the connections table when the ppp0 interface disappears.
EDIT: I have the necessary prerequisites for this to work in principle, like a static IP every time. How do I stop the ICMP errors, keep the NAT table and, optionally, also buffer at least non-bulk packets?


text:
Q: Compile Python Program Linux Is there a way where I can compile my python program (.py) to become just a regular program that I don't haft to run threw the terminal to run it???
Example I don't wanna do this to run it threw the terminal.
./whatever.py
Example I wanna be able to make the file like a Windows .exe, but for Linux like the one below, for example.
http://img535.imageshack.us/img535/4883/executable.png

A: You need to add a Shebang at the first line of your file like this:
#!/usr/bin/env python

and make your file executable by typing (in a terminal):
chmod u+x my_file.py

A: If you want to make a frozen binary from python scripts, use cx_Freeze


text:
Q: add JWT token single claim property as an array element in C# I want to add one role as an array element in JWT token in C#.
{
   "roles": ["Administrator"]
}

Currently, I used this type of code to generate the JWT token claims. This does not help me to create an array type of claim.
string PrivateKey = "string private here";
List<Claim> claims = new List<Claim>();
claims.Add(new Claim("roles", "[Administrator]"));
string tokenString = CreateToken(claims, PrivateKey);

public string CreateToken(List<Claim> claims, string privateRsaKey)
        {
.........................................................
                JwtSecurityToken token = new JwtSecurityToken(
                        Issuer,
                        Audience,
                        claims,
                        now,
                        Expiration,
                        null);

                string payload = token.Payload.SerializeToJson();
                return Jose.JWT.Encode(payload, rsa, Jose.JwsAlgorithm.RS256);

}

Actually I want to add only one array element.  I can't do like this. because it adds multiple array elements.
List<Claim> claims = new List<Claim>();
claims.Add(new Claim("roles", "[Administrator]"));
claims.Add(new Claim("roles", "[Administrator]"));

How can I do this?

A: Finally, spending hours I found the answer, I have to change the way of generating claims and encode the jwt token
List < string > roleOptions = new List < string > () {
 "Administrator"
};
var payload = new JwtPayload {
 {
  "roles",
  roleOptions
 }
};

    string key = "eyJjb21wYW5pZXMiOlt7IklkIjoxLCJDb2RlIjoiQzAxIiwiTmFtZSI6IkNvbXBhbnkgSSIsIkJyYW5jaGVzIjpudWxsLCJVc2VycyI6W3siSWQiOjEsIk5hbWUiOiJV";
    var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(key));
    var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256Signature);
    var header = new JwtHeader(credentials);
    var secToken = new JwtSecurityToken(header, payload);
    var handler = new JwtSecurityTokenHandler();
    var tokenString1 = handler.WriteToken(secToken);
    _logger.Info(secToken.ToString());
    _logger.Info(tokenString1);

A: This part really helped me:
For adding array as a key we have to make it a list and then add it to jwt payload.
    List < string > roleOptions = new List < string > () {
      "Administrator"
    };
    var payload = new JwtPayload {
      {
        "roles",
         roleOptions
      }
    };

A: This is my implementation
contains

*

*expiration of token

*array of roles as List<string>
https://github.com/scholtz/covid-sk-api/blob/main/CovidMassTesting/Model/Token.cs
Note, that usr.Roles must be List<string> and not string[]
        /// <summary>
        /// Method creates jwt token
        /// </summary>
        /// <param name="usr">User object</param>
        /// <param name="configuration">APP Configuran</param>
        /// <returns></returns>
        public static string CreateToken(User usr, IConfiguration configuration)
        {
            if (usr is null)
            {
                throw new ArgumentNullException(nameof(usr));
            }

            if (configuration is null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var key = Encoding.ASCII.GetBytes(configuration["JWTTokenSecret"]);

            var payload = new JwtPayload {
                  {
                    Token.Claims.Email,
                     usr.Email
                  },{
                    Token.Claims.Name,
                     usr.Name
                  },
                  {
                    Token.Claims.Role,
                     usr.Roles
                  },
                  {
                    "nbf",
                     DateTimeOffset.UtcNow.AddSeconds(-1).ToUnixTimeSeconds()
                  },
                  {
                    "iat",
                     DateTimeOffset.UtcNow.AddSeconds(-1).ToUnixTimeSeconds()
                  },
                  {
                    "exp",
                     DateTimeOffset.UtcNow.AddDays(1).ToUnixTimeSeconds()
                  },
            };

            var credentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature);

            var header = new JwtHeader(credentials);
            var secToken = new JwtSecurityToken(header, payload);
            var handler = new JwtSecurityTokenHandler();
            return handler.WriteToken(secToken);
        }

A: After so many unsuccessful attempts and trying this for the whole weekend, I could finally fix the problem of converting a singleton array,
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using Newtonsoft.Json;

IList<string> roleList = new List<string>();
roleList.Add("Administrator");

string rolesJson = JsonConvert.SerializeObject(roleList);

claims.Add(new Claim("roles", rolesJson, JsonClaimValueTypes.JsonArray));

var jwt = new JwtSecurityToken(
                issuer: ...,
                audience: ...,
                claims: claims ..);

This serialises the array of values as JSON and adds the claim as JSON Value Type. Hope this will help someone who's struggling with the same.
Cheers!


text:
Q: Cannot specify a comparer in Contains method of an array in C++/CLI In C#, I can specify a comparer in the Contains method of an array.  That is, the following is working well.
((ICollection<string>)aryStr).Contains(str, StringComparer.OrdinalIgnoreCase)

However, in C++/CLI, I cannot specify a comparer in the Contains method of an array, and the following is invalid.
((ICollection<String^>^)aryStr)->Contains(val, StringComparer::OrdinalIgnoreCase)

In C++/CLI, only the following is valid.
((ICollection<String^>^)aryStr)->Contains(val)

Any comment?

A: For C++/CLI, it may be written as follows.
Enumerable::Contains((ICollection<String^>^)aryStr, val, StringComparer::OrdinalIgnoreCase)


text:
Q: Where have I made my mistake in this javascript code to force download? I have the following function in javascript.
function downloadFile(data, name = 'transcript.pdf', type = 'pdf') {
  const anchor = document.createElement('a')
  anchor.href = window.URL.createObjectURL(new Blob([data], { type }))
  anchor.download = name
  anchor.click()
}

downloadFile();

Long story short, I am using a Learning management system. I cannot insert html, only javascript. So i Have a button press that executes the function above. I get the download window I want, the file looks right, its the right size, but when I go to open it, I get an unsupported file type/ corrupted file from adobe acrobat.
I know next to nothing about JS. I'm floundering around. Can anyone see the mistake I made and know how to correct it?


text:
Q: Any ideas for a JS circle calendar/flexible gauge? I see lots of JS examples of timelines, but I want to represent data that are continuous/cyclical. What I'd like to do is display 4 "seasons" on a circle, highlighting the part of the circle that the current date applies to, and likely having some interaction/mouseover capability to display more information.
I've attached a simple diagram. I'm a novice coder but have dealt with JS long enough where if I had a general template I could make it work for my purposes.
Does anyone know about a JS script that can support this or what the best way to implement this is? I'm guessing the circle would have to have the dates "mapped" on it, so the dynamic data would be dates, but the script would know what part of the circle corresponds to what date.
I've seen gauges that could do similar things like google gauge from their charts API, but that doesn't have enough flexibility.
Thanks very much!

A: You can start with a Javascript pie chart and work from there. d3js is probably your best option.
You can structure your data as follow:
Activity,Start,End
Basketball,Jan 1, Mar 31
Tennis, April 1, Aug 24
...

Then in the code, convert them to days and feed to Pie chart data to do percentage. Finally, create the label on arc and around pie chart.
Here's an example to start with:
http://vida.io/documents/gSvr8dAH23eirKQDp


text:
Q: How can WYSIWYG editors directly edit HTML? I was reading an old Lifehacker article titled, "Five Best WYSIWYG HTML Editors", and it got me thinking.
It seems to me that the phrase WYSIWYG editor that can also directly edit HTML is a contradiction. "WYSIWYG" means, as most of you probably know, "What You See Is What You Get". But direct HTML editing is, by definition, actually WYSIWYM ("What You See Is What You Mean").
So how can something that has both WYSIWYG and WYSIWYM functionality be both WYSIWYG and WYSIWYM software. Just because I talk like a Human and have social skills like a Lego person doesn't mean I'm both a Human and a Lego person.
Or are the terms not black-and-white like it's so often described?

A: WYSIWYG HTML editors output HTML, but the editing of the document is WYSIWYG.  Its no different than editing a document in Microsoft Word and saving as HTML.  You arent editing in HTML, but the output is HTML.

A: CKeditor will clear up the disconnect here (plus their forum is great).
You may have become confused because of other markup and the way Microsoft Expressions used to have different view modes.